From 645b507ba06a34be6aaa9a75eb1a6b2cc409da48 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 12 Jul 2012 05:37:56 -0700 Subject: [PATCH] Return a reference to the RecordPtr from operator[] for consistency RecordListT is supposed to be a list of RecordPtrT objects. --- components/nif/nif_file.cpp | 4 ++-- components/nif/node.hpp | 4 ++-- components/nif/record_ptr.hpp | 7 ++----- components/nifbullet/bullet_nif_loader.cpp | 12 ++++++------ components/nifogre/ogre_nif_loader.cpp | 18 ++++++++---------- 5 files changed, 20 insertions(+), 25 deletions(-) diff --git a/components/nif/nif_file.cpp b/components/nif/nif_file.cpp index 36badbf0d8..231349302f 100644 --- a/components/nif/nif_file.cpp +++ b/components/nif/nif_file.cpp @@ -205,8 +205,8 @@ void NiSkinInstance::post(NIFFile *nif) for(size_t i=0; ifail("Oops: Missing bone! Don't know how to handle this."); - bones[i].makeBone(i, data->bones[i]); + bones[i]->makeBone(i, data->bones[i]); } } diff --git a/components/nif/node.hpp b/components/nif/node.hpp index 64ef1e3e9c..e7ba03276f 100644 --- a/components/nif/node.hpp +++ b/components/nif/node.hpp @@ -151,8 +151,8 @@ struct NiNode : Node for(size_t i = 0;i < children.length();i++) { // Why would a unique list of children contain empty refs? - if(children.has(i)) - children[i].parent = this; + if(!children[i].empty()) + children[i]->parent = this; } } }; diff --git a/components/nif/record_ptr.hpp b/components/nif/record_ptr.hpp index 8f8fc244ae..ef5bb1deec 100644 --- a/components/nif/record_ptr.hpp +++ b/components/nif/record_ptr.hpp @@ -114,11 +114,8 @@ public: list[i].post(nif); } - X& operator[](size_t index) const - { return list.at(index).get(); } - - bool has(size_t index) const - { return !list.at(index).empty(); } + const Ptr& operator[](size_t index) const + { return list.at(index); } size_t length() const { return list.size(); } diff --git a/components/nifbullet/bullet_nif_loader.cpp b/components/nifbullet/bullet_nif_loader.cpp index 4105c4c790..bfcaf36e57 100644 --- a/components/nifbullet/bullet_nif_loader.cpp +++ b/components/nifbullet/bullet_nif_loader.cpp @@ -138,9 +138,9 @@ bool ManualBulletShapeLoader::hasRootCollisionNode(Nif::Node* node) int n = list.length(); for (int i=0; itrafo,hasCollisionNode,isCollisionNode,raycastingOnly); + handleNode(list[i].getPtr(), flags,&node->trafo,hasCollisionNode,isCollisionNode,raycastingOnly); } } } @@ -239,8 +239,8 @@ void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags, int n = list.length(); for (int i=0; itrafo, hasCollisionNode,true,raycastingOnly); + if (!list[i].empty()) + handleNode(list[i].getPtr(), flags,&node->trafo, hasCollisionNode,true,raycastingOnly); } } } diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index aca1966b92..643d7acf89 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -649,10 +649,9 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou for (int i=0; irecType == RC_NiTexturingProperty) t = static_cast(pr); else if (pr->recType == RC_NiMaterialProperty) @@ -803,13 +802,13 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou { if(mSkel.isNull()) { - std::cout << "No skeleton for :" << shape->skin->bones[boneIndex].name << std::endl; + std::cout << "No skeleton for :" << shape->skin->bones[boneIndex]->name << std::endl; break; } //get the bone from bones array of skindata - if(!mSkel->hasBone(shape->skin->bones[boneIndex].name)) + if(!mSkel->hasBone(shape->skin->bones[boneIndex]->name)) std::cout << "We don't have this bone"; - bonePtr = mSkel->getBone(shape->skin->bones[boneIndex].name); + bonePtr = mSkel->getBone(shape->skin->bones[boneIndex]->name); // final_vector = old_vector + old_rotation*new_vector*old_scale @@ -817,7 +816,7 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou Nif::NiSkinData::BoneInfoCopy boneinfocopy; boneinfocopy.trafo.rotation = it->trafo.rotation; boneinfocopy.trafo.trans = it->trafo.trans; - boneinfocopy.bonename = shape->skin->bones[boneIndex].name; + boneinfocopy.bonename = shape->skin->bones[boneIndex]->name; boneinfocopy.bonehandle = bonePtr->getHandle(); copy.boneinfo.push_back(boneinfocopy); for (unsigned int i=0; iweights.size(); i++) @@ -1138,9 +1137,8 @@ void NIFLoader::handleNode(Nif::Node *node, int flags, int n = list.length(); for (int i = 0; itrafo, bounds, bone, boneSequence); + if (!list[i].empty()) + handleNode(list[i].getPtr(), flags, &node->trafo, bounds, bone, boneSequence); } } else if (node->recType == RC_NiTriShape && bNiTri)