From cf9927fcfc6695f92a060c6f6ae21e69ba1a226d Mon Sep 17 00:00:00 2001
From: LogicDragon <nathanvnbg@gmail.com>
Date: Sat, 2 Jul 2011 13:33:51 -0700
Subject: [PATCH] Added AddConstraint, RemoveConstraint, ClearConstraints,
 GetConstraints to bhkRigidBody

---
 include/obj/bhkRigidBody.h | 20 ++++++++++++++++++++
 src/obj/bhkRigidBody.cpp   | 22 ++++++++++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/include/obj/bhkRigidBody.h b/include/obj/bhkRigidBody.h
index 9d2eb8b8..835dd1c0 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 4d8a299b..267355db 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.
-- 
GitLab