[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51150] trunk/blender/source/gameengine/ Physics/Bullet: BGE: When applying movement to an object with the Character physics type, use the btKinematicCharacterController's setWalkDirection() instead of moving the physics object ourselves.

Mitchell Stokes mogurijin at gmail.com
Sun Oct 7 21:10:04 CEST 2012


Revision: 51150
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51150
Author:   moguri
Date:     2012-10-07 19:10:03 +0000 (Sun, 07 Oct 2012)
Log Message:
-----------
BGE: When applying movement to an object with the Character physics type, use the btKinematicCharacterController's setWalkDirection() instead of moving the physics object ourselves. This reduces issues with tunneling (the character going through other objects).

Modified Paths:
--------------
    trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
    trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h

Modified: trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
===================================================================
--- trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp	2012-10-07 15:39:47 UTC (rev 51149)
+++ trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp	2012-10-07 19:10:03 UTC (rev 51150)
@@ -895,18 +895,22 @@
 			return;
 		}
 
-		// btRigidBody* body = GetRigidBody(); // not used anymore
-
 		btVector3 dloc(dlocX,dlocY,dlocZ);
 		btTransform xform = m_object->getWorldTransform();
 	
 		if (local)
+			dloc = xform.getBasis()*dloc;
+
+		if (m_characterController)
 		{
-			dloc = xform.getBasis()*dloc;
+			m_characterController->setWalkDirection(dloc/GetPhysicsEnvironment()->getNumTimeSubSteps());
 		}
+		else
+		{
 
-		xform.setOrigin(xform.getOrigin() + dloc);
-		SetCenterOfMassTransform(xform);
+			xform.setOrigin(xform.getOrigin() + dloc);
+			SetCenterOfMassTransform(xform);
+		}
 	}
 
 }

Modified: trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
===================================================================
--- trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h	2012-10-07 15:39:47 UTC (rev 51149)
+++ trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h	2012-10-07 19:10:03 UTC (rev 51150)
@@ -115,6 +115,11 @@
 		virtual void		setLinearAirDamping(float damping);
 		virtual void		setUseEpa(bool epa);
 
+		int					getNumTimeSubSteps()
+		{
+			return m_numTimeSubSteps;
+		}
+
 		virtual	void		beginFrame();
 		virtual void		endFrame() {}
 		/// Perform an integration step of duration 'timeStep'.




More information about the Bf-blender-cvs mailing list