Do not use kart position if there is no kart

This commit is contained in:
Vincent Lejeune 2014-09-15 00:42:48 +02:00
parent 866cd2b979
commit 0d982e55f0

View File

@ -464,16 +464,21 @@ void PostProcessing::renderMotionBlur(unsigned cam, FrameBuffer &in_fbo, FrameBu
scene::ICameraSceneNode * const camnode =
Camera::getCamera(cam)->getCameraSceneNode();
// Calculate the kart's Y position on screen
const core::vector3df pos =
Camera::getCamera(cam)->getKart()->getNode()->getPosition();
float ndc[4];
core::matrix4 trans = camnode->getProjectionMatrix();
trans *= camnode->getViewMatrix();
trans.transformVect(ndc, pos);
const float karty = (ndc[1] / ndc[3]) * 0.5f + 0.5f;
setMotionBlurCenterY(cam, karty);
// Calculate the kart's Y position on screen
if (Camera::getCamera(cam)->getKart())
{
const core::vector3df pos = Camera::getCamera(cam)->getKart()->getNode()->getPosition();
float ndc[4];
core::matrix4 trans = camnode->getProjectionMatrix();
trans *= camnode->getViewMatrix();
trans.transformVect(ndc, pos);
const float karty = (ndc[1] / ndc[3]) * 0.5f + 0.5f;
setMotionBlurCenterY(cam, karty);
}
else
setMotionBlurCenterY(cam, 0.5f);
out_fbo.Bind();
glClear(GL_COLOR_BUFFER_BIT);