From 786ae3aca02c001371f94e009d24c88fc58f8fbd Mon Sep 17 00:00:00 2001 From: Shon Ferguson <shonferg@users.sourceforge.net> Date: Sat, 10 Dec 2005 23:22:40 +0000 Subject: [PATCH] Fixed a bug that was introduced in the reference bone reference tracking. --- NIF_Blocks.cpp | 6 ++++-- NIF_Blocks.h | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NIF_Blocks.cpp b/NIF_Blocks.cpp index 650327ea..9d24e290 100644 --- a/NIF_Blocks.cpp +++ b/NIF_Blocks.cpp @@ -1656,11 +1656,13 @@ void NiSkinData::SetBones( vector<blk_ref> bone_blocks ) { if (node_int == NULL) throw runtime_error("Attempted to add a block as a bone that is not a node."); + //---------------Problem Area---------------// //move the data bone_map.insert( pair<IBlock *, Bone>(bone_blocks[i].get_block(), bones[i]) ); //Increment reference at bone node site node_int->IncSkinRef(this); + //------------------------------------------// } //Clear temporary vector data @@ -1849,9 +1851,9 @@ void NiSkinData::AddBone( blk_ref const & bone, map<int, float> const & in ) { node_int->IncSkinRef(this); } -void NiSkinData::RemoveBoneByPtr( blk_ref const & bone ) { +void NiSkinData::RemoveBoneByPtr( IBlock * bone ) { //Remove bone from internal list - bone_map.erase( bone.get_block() ); + bone_map.erase( bone ); //Do not decrement bone node locatoin because it is already dead } diff --git a/NIF_Blocks.h b/NIF_Blocks.h index f7844c23..dcd777e1 100644 --- a/NIF_Blocks.h +++ b/NIF_Blocks.h @@ -1154,7 +1154,7 @@ public: virtual void SetBones( vector<blk_ref> bone_blocks ) = 0; virtual void RepositionTriShape() = 0; virtual void StraightenSkeleton() = 0; - virtual void RemoveBoneByPtr( blk_ref const & bone ) = 0; + virtual void RemoveBoneByPtr( IBlock * bone ) = 0; }; class NiSkinData : public AData, public ISkinData, public ISkinDataInternal { @@ -1184,7 +1184,7 @@ class NiSkinData : public AData, public ISkinData, public ISkinDataInternal { void SetBones( vector<blk_ref> bone_blocks ); // not vector<blk_ref> const &, since we must cast the blk_ref's into (non-constant) IBlock * pointers void RepositionTriShape(); void StraightenSkeleton(); - void RemoveBoneByPtr( blk_ref const & bone ); + void RemoveBoneByPtr( IBlock * bone ); //ISkinData vector<blk_ref> GetBones(); // cannot be const, since this changes the reference counts for the bone blocks! -- GitLab