From fc6bf0d4dfa3a811083350da542abb028efc63f5 Mon Sep 17 00:00:00 2001 From: LogicDragon <nathanvnbg@gmail.com> Date: Sat, 2 Jul 2011 13:16:52 -0700 Subject: [PATCH] Added AddEntity, RemoveEntity, ClearEntities, GetEntities to bhkConstraint --- include/obj/bhkConstraint.h | 21 +++++++++++++++++++++ src/obj/bhkConstraint.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/include/obj/bhkConstraint.h b/include/obj/bhkConstraint.h index eb9e701e..8fdf8f2a 100644 --- a/include/obj/bhkConstraint.h +++ b/include/obj/bhkConstraint.h @@ -55,6 +55,27 @@ public: NIFLIB_API virtual const Type & GetType() const; //--BEGIN MISC CUSTOM CODE--// + + /*! + * Adds an entity to this bhkConstraint. + */ + NIFLIB_API void AddEntity( bhkEntity * obj ); + + /*! + * Removes an entity from this bhkConstraint. + */ + NIFLIB_API void RemoveEntity( bhkEntity * obj ); + + /*! + * Removes all entities from this bhkConstraint. + */ + NIFLIB_API void ClearEntities(); + + /*! + * Retrieves all the entities attached to this bhkConstraint. + */ + NIFLIB_API vector< bhkEntity * > GetEntities() const; + //--END CUSTOM CODE--// protected: /*! Number of bodies affected by this constraint. */ diff --git a/src/obj/bhkConstraint.cpp b/src/obj/bhkConstraint.cpp index 0409924d..31cf7299 100644 --- a/src/obj/bhkConstraint.cpp +++ b/src/obj/bhkConstraint.cpp @@ -145,4 +145,28 @@ std::list<NiObject *> bhkConstraint::GetPtrs() const { } //--BEGIN MISC CUSTOM CODE--// + +void bhkConstraint::AddEntity( bhkEntity * obj ) { + entities.push_back( obj ); +} + +void bhkConstraint::RemoveEntity( bhkEntity * obj ) { + //Search Effect list for the one to remove + for ( vector< bhkEntity * >::iterator it = entities.begin(); it != entities.end(); ) { + if ( *it == obj ) { + it = entities.erase( it ); + } else { + ++it; + } + } +} + +void bhkConstraint::ClearEntities() { + entities.clear(); +} + +vector< bhkEntity * > bhkConstraint::GetEntities() const { + return entities; +} + //--END CUSTOM CODE--// -- GitLab