Added dynamic cast to camera to prevent corrupted CFrame
This commit is contained in:
@@ -133,17 +133,19 @@ void CameraController::tiltDown()
|
|||||||
void CameraController::centerCamera(Instance* selection)
|
void CameraController::centerCamera(Instance* selection)
|
||||||
{
|
{
|
||||||
CoordinateFrame frame = CoordinateFrame(g3dCamera.getCoordinateFrame().translation);
|
CoordinateFrame frame = CoordinateFrame(g3dCamera.getCoordinateFrame().translation);
|
||||||
if(selection == NULL)
|
if(PartInstance* part = dynamic_cast<PartInstance*>(selection))
|
||||||
|
{
|
||||||
|
Vector3 partPos = (part)->getPosition()/2;
|
||||||
|
lookAt(partPos);
|
||||||
|
focusPosition=partPos;
|
||||||
|
zoom=((partPos-frame.translation).magnitude());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
{
|
{
|
||||||
lookAt(Vector3(0,0,0));
|
lookAt(Vector3(0,0,0));
|
||||||
focusPosition=Vector3(0,0,0);
|
focusPosition=Vector3(0,0,0);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Vector3 partPos = ((PartInstance*)selection)->getPosition()/2;
|
|
||||||
lookAt(partPos);
|
|
||||||
focusPosition=partPos;
|
|
||||||
zoom=((partPos-frame.translation).magnitude());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user