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);
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();

@ -111,8 +111,8 @@ public:
boneIndex = ind;
}
Ogre::Matrix4 getLocalTransform();
Ogre::Matrix4 getWorldTransform();
Ogre::Matrix4 getLocalTransform() const;
Ogre::Matrix4 getWorldTransform() const;
};
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);
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; i<n; i++)
{
@ -256,7 +256,7 @@ void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags,
else if (node->recType == Nif::RC_NiTriShape && (isCollisionNode || !hasCollisionNode))
{
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)
{
@ -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);

@ -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;

@ -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;
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<const Nif::Node*>(nif.getRecord(0));
std::vector<Nif::NiKeyframeController*> ctrls;
std::vector<Nif::NiKeyframeController const*> ctrls;
buildBones(skel, node, ctrls);
std::vector<std::string> 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<Nif::Named*>(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<Nif::NiTriShape*>(node));
handleNiTriShape(mesh, dynamic_cast<Nif::NiTriShape const *>(node));
return true;
}
Nif::NiNode *ninode = dynamic_cast<Nif::NiNode*>(node);
Nif::NiNode const *ninode = dynamic_cast<Nif::NiNode const *>(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::Node*>(nif.getRecord(0));
Nif::Node const *node = dynamic_cast<Nif::Node const *>(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<Nif::Node*>(r);
Nif::Node const *node = dynamic_cast<Nif::Node const *>(r);
if(node == NULL)
{
nif.warn("First record in file was not a node, but a "+

Loading…
Cancel
Save