Made part selection better

This commit is contained in:
andreja6
2018-04-29 18:33:13 -07:00
parent fa3a0f9aa4
commit 3108021007

View File

@@ -1114,12 +1114,12 @@ void Demo::onUserInput(UserInput* ui) {
if(instances.at(i)->className == "Part" && instances.at(i)->parent == dataModel) if(instances.at(i)->className == "Part" && instances.at(i)->parent == dataModel)
{ {
PhysicalInstance* test = (PhysicalInstance*)instances.at(i); 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>time)
if (nearest>distanceFromPart)
{ {
nearest=distanceFromPart; nearest=time;
selectedInstance = test; selectedInstance = test;
} }
} }