Made part selection better
This commit is contained in:
8
main.cpp
8
main.cpp
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user