spread some const around NIF loading

actorid
Nathan Jeffords 12 years ago
parent 9d4f8c6722
commit 0989b44b41

@ -211,14 +211,14 @@ void NiSkinInstance::post(NIFFile *nif)
} }
} }
Ogre::Matrix4 Node::getLocalTransform() Ogre::Matrix4 Node::getLocalTransform() const
{ {
Ogre::Matrix4 mat4(Ogre::Matrix4::IDENTITY); Ogre::Matrix4 mat4(Ogre::Matrix4::IDENTITY);
mat4.makeTransform(trafo.pos, Ogre::Vector3(trafo.scale), Ogre::Quaternion(trafo.rotation)); mat4.makeTransform(trafo.pos, Ogre::Vector3(trafo.scale), Ogre::Quaternion(trafo.rotation));
return mat4; return mat4;
} }
Ogre::Matrix4 Node::getWorldTransform() Ogre::Matrix4 Node::getWorldTransform() const
{ {
if(parent != NULL) if(parent != NULL)
return parent->getWorldTransform() * getLocalTransform(); return parent->getWorldTransform() * getLocalTransform();

@ -111,8 +111,8 @@ public:
boneIndex = ind; boneIndex = ind;
} }
Ogre::Matrix4 getLocalTransform(); Ogre::Matrix4 getLocalTransform() const;
Ogre::Matrix4 getWorldTransform(); Ogre::Matrix4 getWorldTransform() const;
}; };
struct NiNode : Node struct NiNode : Node

@ -51,7 +51,7 @@ ManualBulletShapeLoader::~ManualBulletShapeLoader()
} }
btQuaternion ManualBulletShapeLoader::getbtQuat(Ogre::Matrix3 &m) btQuaternion ManualBulletShapeLoader::getbtQuat(Ogre::Matrix3 const &m)
{ {
Ogre::Quaternion oquat(m); Ogre::Quaternion oquat(m);
btQuaternion quat; btQuaternion quat;
@ -62,7 +62,7 @@ btQuaternion ManualBulletShapeLoader::getbtQuat(Ogre::Matrix3 &m)
return quat; return quat;
} }
btVector3 ManualBulletShapeLoader::getbtVector(Ogre::Vector3 &v) btVector3 ManualBulletShapeLoader::getbtVector(Ogre::Vector3 const &v)
{ {
return btVector3(v[0], v[1], v[2]); 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) if (node->recType == Nif::RC_NiNode)
{ {
@ -164,7 +164,7 @@ bool ManualBulletShapeLoader::hasRootCollisionNode(Nif::Node* node)
return false; 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) 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 // Check for extra data
Nif::Extra *e = node; Nif::Extra const *e = node;
while (!e->extra.empty()) while (!e->extra.empty())
{ {
// Get the next extra data in the list // 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->boxTranslation = node->boundPos;
cShape->boxRotation = node->boundRot; cShape->boxRotation = node->boundRot;
@ -243,7 +243,7 @@ void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags,
// For NiNodes, loop through children // For NiNodes, loop through children
if (node->recType == Nif::RC_NiNode) 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(); int n = list.length();
for (int i=0; i<n; i++) for (int i=0; i<n; i++)
{ {
@ -256,7 +256,7 @@ void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags,
else if (node->recType == Nif::RC_NiTriShape && (isCollisionNode || !hasCollisionNode)) else if (node->recType == Nif::RC_NiTriShape && (isCollisionNode || !hasCollisionNode))
{ {
cShape->mCollide = !(flags&0x800); cShape->mCollide = !(flags&0x800);
handleNiTriShape(dynamic_cast<Nif::NiTriShape *>(node), flags,childTrafo.rotation,childTrafo.pos,childTrafo.scale,raycastingOnly); handleNiTriShape(dynamic_cast<Nif::NiTriShape const *>(node), flags,childTrafo.rotation,childTrafo.pos,childTrafo.scale,raycastingOnly);
} }
else if(node->recType == Nif::RC_RootCollisionNode) 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) bool raycastingOnly)
{ {
assert(shape != NULL); assert(shape != NULL);

@ -79,25 +79,25 @@ public:
void load(const std::string &name,const std::string &group); void load(const std::string &name,const std::string &group);
private: 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. *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); const Nif::Transformation *trafo, bool hasCollisionNode,bool isCollisionNode,bool raycastingOnly);
/** /**
*Helper function *Helper function
*/ */
bool hasRootCollisionNode(Nif::Node* node); bool hasRootCollisionNode(Nif::Node const * node);
/** /**
*convert a NiTriShape to a bullet trishape. *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 resourceName;
std::string resourceGroup; std::string resourceGroup;

@ -187,7 +187,7 @@ static TextKeyMap extractTextKeys(const Nif::NiTextKeyExtraData *tk)
} }
void buildBones(Ogre::Skeleton *skel, const Nif::Node *node, std::vector<Nif::NiKeyframeController*> &ctrls, Ogre::Bone *parent=NULL) void buildBones(Ogre::Skeleton *skel, const Nif::Node *node, std::vector<Nif::NiKeyframeController const*> &ctrls, Ogre::Bone *parent=NULL)
{ {
Ogre::Bone *bone; Ogre::Bone *bone;
if(!skel->hasBone(node->name)) if(!skel->hasBone(node->name))
@ -255,7 +255,7 @@ void loadResource(Ogre::Resource *resource)
Nif::NIFFile nif(skel->getName()); Nif::NIFFile nif(skel->getName());
const Nif::Node *node = dynamic_cast<const Nif::Node*>(nif.getRecord(0)); const Nif::Node *node = dynamic_cast<const Nif::Node*>(nif.getRecord(0));
std::vector<Nif::NiKeyframeController*> ctrls; std::vector<Nif::NiKeyframeController const*> ctrls;
buildBones(skel, node, ctrls); buildBones(skel, node, ctrls);
std::vector<std::string> targets; std::vector<std::string> targets;
@ -266,7 +266,7 @@ void loadResource(Ogre::Resource *resource)
float maxtime = 0.0f; float maxtime = 0.0f;
for(size_t i = 0;i < ctrls.size();i++) 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); maxtime = std::max(maxtime, ctrl->timeStop);
Nif::Named *target = dynamic_cast<Nif::Named*>(ctrl->target.getPtr()); Nif::Named *target = dynamic_cast<Nif::Named*>(ctrl->target.getPtr());
if(target != NULL) if(target != NULL)
@ -289,8 +289,8 @@ void loadResource(Ogre::Resource *resource)
for(size_t i = 0;i < ctrls.size();i++) for(size_t i = 0;i < ctrls.size();i++)
{ {
Nif::NiKeyframeController *kfc = ctrls[i]; Nif::NiKeyframeController const *kfc = ctrls[i];
Nif::NiKeyframeData *kf = kfc->data.getPtr(); Nif::NiKeyframeData const *kf = kfc->data.getPtr();
/* Get the keyframes and make sure they're sorted first to last */ /* Get the keyframes and make sure they're sorted first to last */
Nif::QuaternionKeyList quatkeys = kf->mRotations; Nif::QuaternionKeyList quatkeys = kf->mRotations;
@ -711,7 +711,7 @@ class NIFMeshLoader : Ogre::ManualResourceLoader
// Convert NiTriShape to Ogre::SubMesh // 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; Ogre::SkeletonPtr skel;
const Nif::NiTriShapeData *data = shape->data.getPtr(); const Nif::NiTriShapeData *data = shape->data.getPtr();
@ -909,18 +909,18 @@ class NIFMeshLoader : Ogre::ManualResourceLoader
sub->setMaterialName(mMaterialName); 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) if(node->recType == Nif::RC_NiTriShape && mShapeName == node->name)
{ {
handleNiTriShape(mesh, dynamic_cast<Nif::NiTriShape*>(node)); handleNiTriShape(mesh, dynamic_cast<Nif::NiTriShape const *>(node));
return true; return true;
} }
Nif::NiNode *ninode = dynamic_cast<Nif::NiNode*>(node); Nif::NiNode const *ninode = dynamic_cast<Nif::NiNode const *>(node);
if(ninode) if(ninode)
{ {
Nif::NodeList &children = ninode->children; Nif::NodeList const &children = ninode->children;
for(size_t i = 0;i < children.length();i++) for(size_t i = 0;i < children.length();i++)
{ {
if(!children[i].empty()) if(!children[i].empty())
@ -957,7 +957,7 @@ public:
} }
Nif::NIFFile nif(mName); Nif::NIFFile nif(mName);
Nif::Node *node = dynamic_cast<Nif::Node*>(nif.getRecord(0)); Nif::Node const *node = dynamic_cast<Nif::Node const *>(nif.getRecord(0));
findTriShape(mesh, node); 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 // 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); assert(r != NULL);
Nif::Node *node = dynamic_cast<Nif::Node*>(r); Nif::Node const *node = dynamic_cast<Nif::Node const *>(r);
if(node == NULL) if(node == NULL)
{ {
nif.warn("First record in file was not a node, but a "+ nif.warn("First record in file was not a node, but a "+

Loading…
Cancel
Save