Просмотр исходного кода

Added constraint remove support to 3D physics scene

Ivan Safrin 12 лет назад
Родитель
Сommit
bdf8aa5a46

+ 3 - 1
Modules/Contents/3DPhysics/Include/PolyPhysicsScene.h

@@ -72,7 +72,7 @@ namespace Polycode {
 
 	class _PolyExport PhysicsHingeConstraint  {
 		public:
-		
+			~PhysicsHingeConstraint();
 			void setLimits(Number minLimit, Number maxLimit);
 			Number getAngle();
 			
@@ -123,6 +123,8 @@ namespace Polycode {
 				
 		void warpEntity(SceneEntity *entity, Vector3 position, bool resetRotation = false);
 		
+		void removeConstraint(PhysicsHingeConstraint *constraint);
+		
 		void applyImpulse(SceneEntity *entity, Vector3 force, Vector3 point);
 		
 		PhysicsVehicle *addVehicleChild(SceneEntity *newEntity, Number mass, Number friction, int group  = 1);

+ 8 - 0
Modules/Contents/3DPhysics/Source/PolyPhysicsScene.cpp

@@ -294,6 +294,14 @@ void PhysicsScene::removeEntity(SceneEntity *entity) {
 	}
 }
 
+void PhysicsScene::removeConstraint(PhysicsHingeConstraint *constraint) {
+	physicsWorld->removeConstraint(constraint->btConstraint);
+}
+
+PhysicsHingeConstraint::~PhysicsHingeConstraint() {
+	delete btConstraint;
+}
+
 void PhysicsHingeConstraint::setLimits(Number minLimit, Number maxLimit) {
 	btConstraint->setLimit(minLimit, maxLimit);
 }