mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
Eliminate dynamic_cast in BillboardCallback
This commit is contained in:
parent
60a12b3dee
commit
82b792f808
1 changed files with 19 additions and 23 deletions
|
@ -132,31 +132,27 @@ namespace
|
|||
|
||||
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
{
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv);
|
||||
if (node && cv)
|
||||
osgUtil::CullVisitor* cv = static_cast<osgUtil::CullVisitor*>(nv);
|
||||
|
||||
osg::Matrix modelView = *cv->getModelViewMatrix();
|
||||
|
||||
// attempt to preserve scale
|
||||
float mag[3];
|
||||
for (int i=0;i<3;++i)
|
||||
{
|
||||
osg::Matrix modelView = *cv->getModelViewMatrix();
|
||||
|
||||
// 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();
|
||||
mag[i] = std::sqrt(modelView(0,i) * modelView(0,i) + modelView(1,i) * modelView(1,i) + modelView(2,i) * modelView(2,i));
|
||||
}
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue