Made surface not crash, made surface release only on motor
This commit is contained in:
@@ -37,26 +37,30 @@ void SurfaceTool::onButton1MouseDown(Mouse mouse)
|
|||||||
{
|
{
|
||||||
AudioPlayer::playSound(dingSound);
|
AudioPlayer::playSound(dingSound);
|
||||||
PartInstance * target = mouse.getTarget();
|
PartInstance * target = mouse.getTarget();
|
||||||
G3D::Ray ray = mouse.getLastRay();
|
if(target != NULL)
|
||||||
std::vector<G3D::Box> surfacesHit = getSurfaces(target);
|
|
||||||
int closest;
|
|
||||||
float nearValue = G3D::inf();
|
|
||||||
for(size_t i = 0; i < surfacesHit.size(); i++)
|
|
||||||
{
|
{
|
||||||
float newTime = ray.intersectionTime(surfacesHit[i]);
|
G3D::Ray ray = mouse.getLastRay();
|
||||||
if(nearValue > newTime)
|
std::vector<G3D::Box> surfacesHit = getSurfaces(target);
|
||||||
|
int closest;
|
||||||
|
float nearValue = G3D::inf();
|
||||||
|
for(size_t i = 0; i < surfacesHit.size(); i++)
|
||||||
{
|
{
|
||||||
nearValue = newTime;
|
float newTime = ray.intersectionTime(surfacesHit[i]);
|
||||||
closest = (int)i;
|
if(nearValue > newTime)
|
||||||
|
{
|
||||||
|
nearValue = newTime;
|
||||||
|
closest = (int)i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(G3D::isFinite(nearValue))
|
||||||
|
{
|
||||||
|
target->setSurface(closest, Enum::SurfaceType::Value(surface));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(G3D::isFinite(nearValue))
|
if(surface == Enum::SurfaceType::Motor)
|
||||||
{
|
{
|
||||||
|
g_usableApp->changeTool(NULL);
|
||||||
printf("\n%d\n", closest);
|
|
||||||
target->setSurface(closest, Enum::SurfaceType::Value(surface));
|
|
||||||
}
|
}
|
||||||
g_usableApp->changeTool(NULL);
|
|
||||||
}
|
}
|
||||||
void SurfaceTool::onButton1MouseUp(Mouse mouse)
|
void SurfaceTool::onButton1MouseUp(Mouse mouse)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user