From 3108021007a806ddbeafa0a87035012a63774023 Mon Sep 17 00:00:00 2001 From: andreja6 Date: Sun, 29 Apr 2018 18:33:13 -0700 Subject: [PATCH] Made part selection better --- main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index 2b7be88..fb1f1a2 100644 --- a/main.cpp +++ b/main.cpp @@ -1114,12 +1114,12 @@ void Demo::onUserInput(UserInput* ui) { if(instances.at(i)->className == "Part" && instances.at(i)->parent == dataModel) { PhysicalInstance* test = (PhysicalInstance*)instances.at(i); - if (testRay.intersectionTime(test->getBox()) != inf()) + float time = testRay.intersectionTime(test->getBox()); + if (time != inf()) { - float distanceFromPart = (camPos-test->getPosition()).magnitude(); - if (nearest>distanceFromPart) + if (nearest>time) { - nearest=distanceFromPart; + nearest=time; selectedInstance = test; } }