From 0989b44b415d56246a02d754733e971b7a8458bf Mon Sep 17 00:00:00 2001 From: Nathan Jeffords Date: Thu, 3 Jan 2013 09:33:19 -0800 Subject: [PATCH] spread some const around NIF loading --- components/nif/nif_file.cpp | 4 ++-- components/nif/node.hpp | 4 ++-- components/nifbullet/bullet_nif_loader.cpp | 18 +++++++-------- components/nifbullet/bullet_nif_loader.hpp | 10 ++++----- components/nifogre/ogre_nif_loader.cpp | 26 +++++++++++----------- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/components/nif/nif_file.cpp b/components/nif/nif_file.cpp index 3313d89ab1..38ff5b2708 100644 --- a/components/nif/nif_file.cpp +++ b/components/nif/nif_file.cpp @@ -211,14 +211,14 @@ void NiSkinInstance::post(NIFFile *nif) } } -Ogre::Matrix4 Node::getLocalTransform() +Ogre::Matrix4 Node::getLocalTransform() const { Ogre::Matrix4 mat4(Ogre::Matrix4::IDENTITY); mat4.makeTransform(trafo.pos, Ogre::Vector3(trafo.scale), Ogre::Quaternion(trafo.rotation)); return mat4; } -Ogre::Matrix4 Node::getWorldTransform() +Ogre::Matrix4 Node::getWorldTransform() const { if(parent != NULL) return parent->getWorldTransform() * getLocalTransform(); diff --git a/components/nif/node.hpp b/components/nif/node.hpp index f7d3c6e96b..07e7868cce 100644 --- a/components/nif/node.hpp +++ b/components/nif/node.hpp @@ -111,8 +111,8 @@ public: boneIndex = ind; } - Ogre::Matrix4 getLocalTransform(); - Ogre::Matrix4 getWorldTransform(); + Ogre::Matrix4 getLocalTransform() const; + Ogre::Matrix4 getWorldTransform() const; }; struct NiNode : Node diff --git a/components/nifbullet/bullet_nif_loader.cpp b/components/nifbullet/bullet_nif_loader.cpp index 0c8de0c27f..cea8c4b52a 100644 --- a/components/nifbullet/bullet_nif_loader.cpp +++ b/components/nifbullet/bullet_nif_loader.cpp @@ -51,7 +51,7 @@ ManualBulletShapeLoader::~ManualBulletShapeLoader() } -btQuaternion ManualBulletShapeLoader::getbtQuat(Ogre::Matrix3 &m) +btQuaternion ManualBulletShapeLoader::getbtQuat(Ogre::Matrix3 const &m) { Ogre::Quaternion oquat(m); btQuaternion quat; @@ -62,7 +62,7 @@ btQuaternion ManualBulletShapeLoader::getbtQuat(Ogre::Matrix3 &m) return quat; } -btVector3 ManualBulletShapeLoader::getbtVector(Ogre::Vector3 &v) +btVector3 ManualBulletShapeLoader::getbtVector(Ogre::Vector3 const &v) { return btVector3(v[0], v[1], v[2]); } @@ -138,7 +138,7 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource) } } -bool ManualBulletShapeLoader::hasRootCollisionNode(Nif::Node* node) +bool ManualBulletShapeLoader::hasRootCollisionNode(Nif::Node const * node) { if (node->recType == Nif::RC_NiNode) { @@ -164,7 +164,7 @@ bool ManualBulletShapeLoader::hasRootCollisionNode(Nif::Node* node) return false; } -void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags, +void ManualBulletShapeLoader::handleNode(Nif::Node const *node, int flags, const Nif::Transformation *parentTrafo,bool hasCollisionNode,bool isCollisionNode,bool raycastingOnly) { @@ -181,7 +181,7 @@ void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags, } // Check for extra data - Nif::Extra *e = node; + Nif::Extra const *e = node; while (!e->extra.empty()) { // Get the next extra data in the list @@ -232,7 +232,7 @@ void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags, { - btVector3 boxsize = getbtVector((node->boundXYZ)); + btVector3 boxsize = getbtVector(node->boundXYZ); cShape->boxTranslation = node->boundPos; cShape->boxRotation = node->boundRot; @@ -243,7 +243,7 @@ void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags, // For NiNodes, loop through children if (node->recType == Nif::RC_NiNode) { - Nif::NodeList &list = ((Nif::NiNode*)node)->children; + Nif::NodeList const &list = ((Nif::NiNode const *)node)->children; int n = list.length(); for (int i=0; irecType == Nif::RC_NiTriShape && (isCollisionNode || !hasCollisionNode)) { cShape->mCollide = !(flags&0x800); - handleNiTriShape(dynamic_cast(node), flags,childTrafo.rotation,childTrafo.pos,childTrafo.scale,raycastingOnly); + handleNiTriShape(dynamic_cast(node), flags,childTrafo.rotation,childTrafo.pos,childTrafo.scale,raycastingOnly); } else if(node->recType == Nif::RC_RootCollisionNode) { @@ -270,7 +270,7 @@ void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags, } } -void ManualBulletShapeLoader::handleNiTriShape(Nif::NiTriShape *shape, int flags,Ogre::Matrix3 parentRot,Ogre::Vector3 parentPos,float parentScale, +void ManualBulletShapeLoader::handleNiTriShape(Nif::NiTriShape const *shape, int flags,Ogre::Matrix3 parentRot,Ogre::Vector3 parentPos,float parentScale, bool raycastingOnly) { assert(shape != NULL); diff --git a/components/nifbullet/bullet_nif_loader.hpp b/components/nifbullet/bullet_nif_loader.hpp index 2190fda1b8..520878ce1c 100644 --- a/components/nifbullet/bullet_nif_loader.hpp +++ b/components/nifbullet/bullet_nif_loader.hpp @@ -79,25 +79,25 @@ public: void load(const std::string &name,const std::string &group); private: - btQuaternion getbtQuat(Ogre::Matrix3 &m); + btQuaternion getbtQuat(Ogre::Matrix3 const &m); - btVector3 getbtVector(Ogre::Vector3 &v); + btVector3 getbtVector(Ogre::Vector3 const &v); /** *Parse a node. */ - void handleNode(Nif::Node *node, int flags, + void handleNode(Nif::Node const *node, int flags, const Nif::Transformation *trafo, bool hasCollisionNode,bool isCollisionNode,bool raycastingOnly); /** *Helper function */ - bool hasRootCollisionNode(Nif::Node* node); + bool hasRootCollisionNode(Nif::Node const * node); /** *convert a NiTriShape to a bullet trishape. */ - void handleNiTriShape(Nif::NiTriShape *shape, int flags,Ogre::Matrix3 parentRot,Ogre::Vector3 parentPos,float parentScales,bool raycastingOnly); + void handleNiTriShape(Nif::NiTriShape const *shape, int flags,Ogre::Matrix3 parentRot,Ogre::Vector3 parentPos,float parentScales,bool raycastingOnly); std::string resourceName; std::string resourceGroup; diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index 489acb1088..207d01ff65 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -187,7 +187,7 @@ static TextKeyMap extractTextKeys(const Nif::NiTextKeyExtraData *tk) } -void buildBones(Ogre::Skeleton *skel, const Nif::Node *node, std::vector &ctrls, Ogre::Bone *parent=NULL) +void buildBones(Ogre::Skeleton *skel, const Nif::Node *node, std::vector &ctrls, Ogre::Bone *parent=NULL) { Ogre::Bone *bone; if(!skel->hasBone(node->name)) @@ -255,7 +255,7 @@ void loadResource(Ogre::Resource *resource) Nif::NIFFile nif(skel->getName()); const Nif::Node *node = dynamic_cast(nif.getRecord(0)); - std::vector ctrls; + std::vector ctrls; buildBones(skel, node, ctrls); std::vector targets; @@ -266,7 +266,7 @@ void loadResource(Ogre::Resource *resource) float maxtime = 0.0f; for(size_t i = 0;i < ctrls.size();i++) { - Nif::NiKeyframeController *ctrl = ctrls[i]; + Nif::NiKeyframeController const *ctrl = ctrls[i]; maxtime = std::max(maxtime, ctrl->timeStop); Nif::Named *target = dynamic_cast(ctrl->target.getPtr()); if(target != NULL) @@ -289,8 +289,8 @@ void loadResource(Ogre::Resource *resource) for(size_t i = 0;i < ctrls.size();i++) { - Nif::NiKeyframeController *kfc = ctrls[i]; - Nif::NiKeyframeData *kf = kfc->data.getPtr(); + Nif::NiKeyframeController const *kfc = ctrls[i]; + Nif::NiKeyframeData const *kf = kfc->data.getPtr(); /* Get the keyframes and make sure they're sorted first to last */ Nif::QuaternionKeyList quatkeys = kf->mRotations; @@ -711,7 +711,7 @@ class NIFMeshLoader : Ogre::ManualResourceLoader // Convert NiTriShape to Ogre::SubMesh - void handleNiTriShape(Ogre::Mesh *mesh, Nif::NiTriShape *shape) + void handleNiTriShape(Ogre::Mesh *mesh, Nif::NiTriShape const *shape) { Ogre::SkeletonPtr skel; const Nif::NiTriShapeData *data = shape->data.getPtr(); @@ -909,18 +909,18 @@ class NIFMeshLoader : Ogre::ManualResourceLoader sub->setMaterialName(mMaterialName); } - bool findTriShape(Ogre::Mesh *mesh, Nif::Node *node) + bool findTriShape(Ogre::Mesh *mesh, Nif::Node const *node) { if(node->recType == Nif::RC_NiTriShape && mShapeName == node->name) { - handleNiTriShape(mesh, dynamic_cast(node)); + handleNiTriShape(mesh, dynamic_cast(node)); return true; } - Nif::NiNode *ninode = dynamic_cast(node); + Nif::NiNode const *ninode = dynamic_cast(node); if(ninode) { - Nif::NodeList &children = ninode->children; + Nif::NodeList const &children = ninode->children; for(size_t i = 0;i < children.length();i++) { if(!children[i].empty()) @@ -957,7 +957,7 @@ public: } Nif::NIFFile nif(mName); - Nif::Node *node = dynamic_cast(nif.getRecord(0)); + Nif::Node const *node = dynamic_cast(nif.getRecord(0)); findTriShape(mesh, node); } @@ -1062,10 +1062,10 @@ MeshPairList NIFLoader::load(std::string name, std::string skelName, const std:: } // The first record is assumed to be the root node - Nif::Record *r = nif.getRecord(0); + Nif::Record const *r = nif.getRecord(0); assert(r != NULL); - Nif::Node *node = dynamic_cast(r); + Nif::Node const *node = dynamic_cast(r); if(node == NULL) { nif.warn("First record in file was not a node, but a "+