From fc7456e0a10e31c03057d2b46974c1b05efe218f Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 21 Nov 2015 23:35:56 +0100 Subject: [PATCH] Explicitely opt for float matrices in performance critical places --- components/nifosg/particle.cpp | 2 +- components/resource/scenemanager.cpp | 2 +- components/sceneutil/lightmanager.cpp | 4 ++-- components/sceneutil/lightmanager.hpp | 4 ++-- components/sceneutil/util.cpp | 2 +- components/sceneutil/util.hpp | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/components/nifosg/particle.cpp b/components/nifosg/particle.cpp index 68f3de8aa..e30837d39 100644 --- a/components/nifosg/particle.cpp +++ b/components/nifosg/particle.cpp @@ -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); diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index cd3aeb3d6..b2ba5c4cf 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -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; inumParticles(); ++i) { diff --git a/components/sceneutil/lightmanager.cpp b/components/sceneutil/lightmanager.cpp index d3e11050d..43f11cf00 100644 --- a/components/sceneutil/lightmanager.cpp +++ b/components/sceneutil/lightmanager.cpp @@ -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::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); diff --git a/components/sceneutil/lightmanager.hpp b/components/sceneutil/lightmanager.hpp index 27ee1cdaa..ecee873e8 100644 --- a/components/sceneutil/lightmanager.hpp +++ b/components/sceneutil/lightmanager.hpp @@ -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& getLights() const; diff --git a/components/sceneutil/util.cpp b/components/sceneutil/util.cpp index 52f9c9e54..3add3bb23 100644 --- a/components/sceneutil/util.cpp +++ b/components/sceneutil/util.cpp @@ -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; diff --git a/components/sceneutil/util.hpp b/components/sceneutil/util.hpp index c99771c5e..d8fefdb29 100644 --- a/components/sceneutil/util.hpp +++ b/components/sceneutil/util.hpp @@ -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);