Explicitely opt for float matrices in performance critical places

This commit is contained in:
scrawl 2015-11-21 23:35:56 +01:00
parent ffea9ec2c4
commit fc7456e0a1
6 changed files with 8 additions and 8 deletions

View file

@ -49,7 +49,7 @@ void InverseWorldMatrix::operator()(osg::Node *node, osg::NodeVisitor *nv)
osg::Matrix mat = osg::computeLocalToWorld( path );
mat.orthoNormalize(mat); // don't undo the scale
mat = osg::Matrix::inverse(mat);
mat.invert(mat);
trans->setMatrix(mat);
}
traverse(node,nv);

View file

@ -82,7 +82,7 @@ namespace
osg::MatrixList mats = node->getWorldMatrices();
if (mats.empty())
return;
osg::Matrix worldMat = mats[0];
osg::Matrixf worldMat = mats[0];
worldMat.orthoNormalize(worldMat); // scale is already applied on the particle node
for (int i=0; i<partsys->numParticles(); ++i)
{

View file

@ -164,7 +164,7 @@ namespace SceneUtil
mStateSetCache.clear();
}
void LightManager::addLight(LightSource* lightSource, osg::Matrix worldMat)
void LightManager::addLight(LightSource* lightSource, osg::Matrixf worldMat)
{
LightSourceTransform l;
l.mLightSource = lightSource;
@ -221,7 +221,7 @@ namespace SceneUtil
for (std::vector<LightSourceTransform>::iterator lightIt = mLights.begin(); lightIt != mLights.end(); ++lightIt)
{
osg::Matrix worldViewMat = lightIt->mWorldMatrix * (*viewMatrix);
osg::Matrixf worldViewMat = lightIt->mWorldMatrix * (*viewMatrix);
osg::BoundingSphere viewBound = osg::BoundingSphere(osg::Vec3f(0,0,0), lightIt->mLightSource->getRadius());
transformBoundingSphere(worldViewMat, viewBound);

View file

@ -77,12 +77,12 @@ namespace SceneUtil
void update();
// Called automatically by the LightSource's UpdateCallback
void addLight(LightSource* lightSource, osg::Matrix worldMat);
void addLight(LightSource* lightSource, osg::Matrixf worldMat);
struct LightSourceTransform
{
LightSource* mLightSource;
osg::Matrix mWorldMatrix;
osg::Matrixf mWorldMatrix;
};
const std::vector<LightSourceTransform>& getLights() const;

View file

@ -3,7 +3,7 @@
namespace SceneUtil
{
void transformBoundingSphere (const osg::Matrix& matrix, osg::BoundingSphere& bsphere)
void transformBoundingSphere (const osg::Matrixf& matrix, osg::BoundingSphere& bsphere)
{
osg::BoundingSphere::vec_type xdash = bsphere._center;
xdash.x() += bsphere._radius;

View file

@ -11,7 +11,7 @@ namespace SceneUtil
// Transform a bounding sphere by a matrix
// based off private code in osg::Transform
// TODO: patch osg to make public
void transformBoundingSphere (const osg::Matrix& matrix, osg::BoundingSphere& bsphere);
void transformBoundingSphere (const osg::Matrixf& matrix, osg::BoundingSphere& bsphere);
osg::Vec4f colourFromRGB (unsigned int clr);