diff --git a/include/obj/bhkRigidBody.h b/include/obj/bhkRigidBody.h index 9d2eb8b828c995e59e8dba5aae7a07c07a284cbe..835dd1c08d6503c428121843508c85ee4e80fac3 100644 --- a/include/obj/bhkRigidBody.h +++ b/include/obj/bhkRigidBody.h @@ -290,6 +290,26 @@ public: // \param[in] value The new value. NIFLIB_API void SetSolverDeactivation( const SolverDeactivation & value ); + /*! + * Adds a constraint to this bhkRigidBody. + */ + NIFLIB_API void AddConstraint( bhkSerializable * obj ); + + /*! + * Removes a constraint from this bhkRigidBody. + */ + NIFLIB_API void RemoveConstraint( bhkSerializable * obj ); + + /*! + * Removes all constraints from this bhkRigidBody. + */ + NIFLIB_API void ClearConstraints(); + + /*! + * Retrieves all the constraints attached to this bhkRigidBody. + */ + NIFLIB_API vector< Ref<bhkSerializable> > GetConstraints() const; + // Apply scale factor <scale> on data. // \param[in] scale Factor to scale by NIFLIB_API void ApplyScale(float scale); diff --git a/src/obj/bhkRigidBody.cpp b/src/obj/bhkRigidBody.cpp index 4d8a299b3ca3dd3c348a60019c5f10e566e41bfd..267355db9180ec7338386666b9cfc724c0b8a4e3 100644 --- a/src/obj/bhkRigidBody.cpp +++ b/src/obj/bhkRigidBody.cpp @@ -447,6 +447,28 @@ void bhkRigidBody::SetSolverDeactivation( const SolverDeactivation & value ) { solverDeactivation = value; } +void bhkRigidBody::AddConstraint( bhkSerializable * obj ) { + constraints.push_back( obj ); +} + +void bhkRigidBody::RemoveConstraint( bhkSerializable * obj ) { + //Search Effect list for the one to remove + for ( vector< bhkSerializableRef >::iterator it = constraints.begin(); it != constraints.end(); ) { + if ( *it == obj ) { + it = constraints.erase( it ); + } else { + ++it; + } + } +} + +void bhkRigidBody::ClearConstraints() { + constraints.clear(); +} + +vector< Ref<bhkSerializable> > bhkRigidBody::GetConstraints() const { + return constraints; +} // Apply scale factor <scale> on data.