1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 21:49:55 +00:00

Eliminate dynamic_cast in BillboardCallback

This commit is contained in:
scrawl 2016-03-05 20:02:33 +01:00
parent 60a12b3dee
commit 82b792f808

View file

@ -132,31 +132,27 @@ namespace
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{ {
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv); osgUtil::CullVisitor* cv = static_cast<osgUtil::CullVisitor*>(nv);
if (node && cv)
osg::Matrix modelView = *cv->getModelViewMatrix();
// attempt to preserve scale
float mag[3];
for (int i=0;i<3;++i)
{ {
osg::Matrix modelView = *cv->getModelViewMatrix(); mag[i] = std::sqrt(modelView(0,i) * modelView(0,i) + modelView(1,i) * modelView(1,i) + modelView(2,i) * modelView(2,i));
// attempt to preserve scale
float mag[3];
for (int i=0;i<3;++i)
{
mag[i] = std::sqrt(modelView(0,i) * modelView(0,i) + modelView(1,i) * modelView(1,i) + modelView(2,i) * modelView(2,i));
}
modelView.setRotate(osg::Quat());
modelView(0,0) = mag[0];
modelView(1,1) = mag[1];
modelView(2,2) = mag[2];
cv->pushModelViewMatrix(new osg::RefMatrix(modelView), osg::Transform::RELATIVE_RF);
traverse(node, nv);
cv->popModelViewMatrix();
} }
else
traverse(node, nv); modelView.setRotate(osg::Quat());
modelView(0,0) = mag[0];
modelView(1,1) = mag[1];
modelView(2,2) = mag[2];
cv->pushModelViewMatrix(new osg::RefMatrix(modelView), osg::Transform::RELATIVE_RF);
traverse(node, nv);
cv->popModelViewMatrix();
} }
}; };