[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [61096] trunk/blender/source/gameengine: BGE: Cleaning up the BGE' s physics code and removing KX_IPhysicsController and KX_BulletPhysicsController .

Mitchell Stokes mogurijin at gmail.com
Mon Nov 4 20:22:48 CET 2013


Revision: 61096
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=61096
Author:   moguri
Date:     2013-11-04 19:22:47 +0000 (Mon, 04 Nov 2013)
Log Message:
-----------
BGE: Cleaning up the BGE's physics code and removing KX_IPhysicsController and KX_BulletPhysicsController. Instead, we just use PHY_IPhysicsController, which removes a lot of duplicate code.

This is a squashed commit of the following:
    BGE Physics Cleanup: Fix crashes with LibLoading and replication. Also fixing some memory leaks.
    BGE Physics Cleanup: Removing KX_IPhysicsController and KX_BulletPhysicsController.
    BGE Physics Cleanup: Moving the replication code outside of KX_BlenderBulletController and switching KX_ConvertPhysicsObjects to create a CcdPhysicsController instead of a KX_BlenderBulletController.
    BGE Physics Cleanup: Getting rid of an unsued KX_BulletPhysicsController.h include in KX_Scene.cpp.
    BGE Physics Cleanup: Removing unused KX_IPhysicsController and KX_BulletPhysicsController includes.
    BGE Physics Cleanup: Removing m_pPhysicsController1 and GetPhysicsController1() from KX_GameObject.
    BGE Physics Cleanup: Remove SetRigidBody() from KX_IPhysicsController and remove GetName() from CcdPhysicsController.
    BGE Physics Cleanup: Moving Add/RemoveCompoundChild() from KX_IPhysicsController to PHY_IPhysicsController.
    BGE Physics Cleanup: Removing GetLocalInertia() from KX_IPhysicsController.
    BGE Physics Cleanup: Making BlenderBulletCharacterController derive from PHY_ICharacter and removing CharacterWrapper from CcdPhysicsEnvironment.cpp. Also removing the character functions from KX_IPhysicsController.
    BGE Physics Cleanup: Removing GetOrientation(), SetOrientation(), SetPosition(), SetScaling(), and GetRadius() from KX_IPhysicsController.
    BGE Physics Cleanup: Removing GetReactionForce() since all implementations returned (0, 0, 0). The Python interface for KX_GameObject still has reaction force code, but it still also returns (0, 0, 0). This can probably be removed as well, but removing it can break scripts, so I'll leave it for now.
    BGE Physics Cleanup: Removing Get/SetLinVelocityMin() and Get/SetLinVelocityMax() from KX_IPhysicsController.
    BGE Physics Cleanup: Removing SetMargin(), RelativeTranslate(), and RelativeRotate() from KX_IPhysicsController.
    BGE Physics Cleanup: Using constant references for function arguments in PHY_IPhysicsController where appropriate.
    BGE Physics Cleanup: Removing ApplyImpulse() from KX_IPhysicsController.
    BGE Physics Cleanup: Removing ResolveCombinedVelocities() from KX_IPhysicsController.
    BGE Physics Cleanup: Accidently removed a return when cleaning up KX_GameObject::PyGetVelocity().
    BGE Physics Cleanup: Remove GetLinearVelocity(), GetAngularVelocity() and GetVelocity() from KX_IPhysicsController. The corresponding PHY_IPhysicsController functions now also take Moto types instead of scalars to match the KX_IPhysicsController interface.
    BGE Physics Cleanup: Moving SuspendDynamics, RestoreDynamics, SetMass, GetMass, and SetTransform from KX_IPhysicsController to PHY_IPhysicsController.
    BGE Physics Cleanup: PHY_IPhysicsEnvironment and derived classes now use the same naming scheme as PHY_IController.
    BGE Physics Cleanup: PHY_IMotionState and derived classes now use the same naming convention as PHY_IController.
    BGE Phsyics Cleanup: Making PHY_IController and its derived classes follow a consistent naming scheme for member functions. They now all start with capital letters (e.g., setWorldOrientation becomes SetWorldOrientation).
    BGE Physics Cleanup: Getting rid of KX_GameObject::SuspendDynamics() and KX_GameObject::RestoreDynamics(). Instead, use the functions from the physics controller.
    BGE: Some first steps in trying to cleanup the KX_IPhysicsController mess. KX_GameObject now has a GetPhysicsController() and a GetPhysicsController1(). The former returns a PHY_IPhysicsController* while the latter returns a KX_IPhysicsController. The goal is to get everything using GetPhysicsController() instead of GetPhysicsController1().

Modified Paths:
--------------
    trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
    trunk/blender/source/gameengine/Converter/BL_ModifierDeformer.cpp
    trunk/blender/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
    trunk/blender/source/gameengine/Converter/KX_SoftBodyDeformer.cpp
    trunk/blender/source/gameengine/Ketsji/BL_Action.cpp
    trunk/blender/source/gameengine/Ketsji/CMakeLists.txt
    trunk/blender/source/gameengine/Ketsji/KX_CharacterWrapper.cpp
    trunk/blender/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
    trunk/blender/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
    trunk/blender/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
    trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
    trunk/blender/source/gameengine/Ketsji/KX_GameObject.h
    trunk/blender/source/gameengine/Ketsji/KX_IPO_SGController.cpp
    trunk/blender/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
    trunk/blender/source/gameengine/Ketsji/KX_MotionState.cpp
    trunk/blender/source/gameengine/Ketsji/KX_MotionState.h
    trunk/blender/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
    trunk/blender/source/gameengine/Ketsji/KX_NearSensor.cpp
    trunk/blender/source/gameengine/Ketsji/KX_ObjectActuator.cpp
    trunk/blender/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
    trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
    trunk/blender/source/gameengine/Ketsji/KX_RadarSensor.cpp
    trunk/blender/source/gameengine/Ketsji/KX_RayCast.cpp
    trunk/blender/source/gameengine/Ketsji/KX_RayCast.h
    trunk/blender/source/gameengine/Ketsji/KX_RaySensor.cpp
    trunk/blender/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
    trunk/blender/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
    trunk/blender/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
    trunk/blender/source/gameengine/Ketsji/KX_Scene.cpp
    trunk/blender/source/gameengine/Ketsji/KX_TouchEventManager.cpp
    trunk/blender/source/gameengine/Ketsji/KX_TouchSensor.cpp
    trunk/blender/source/gameengine/Physics/Bullet/CcdGraphicController.cpp
    trunk/blender/source/gameengine/Physics/Bullet/CcdGraphicController.h
    trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
    trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.h
    trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
    trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
    trunk/blender/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp
    trunk/blender/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
    trunk/blender/source/gameengine/Physics/common/PHY_IController.h
    trunk/blender/source/gameengine/Physics/common/PHY_IGraphicController.h
    trunk/blender/source/gameengine/Physics/common/PHY_IMotionState.h
    trunk/blender/source/gameengine/Physics/common/PHY_IPhysicsController.h
    trunk/blender/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h

Removed Paths:
-------------
    trunk/blender/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
    trunk/blender/source/gameengine/Ketsji/KX_BulletPhysicsController.h
    trunk/blender/source/gameengine/Ketsji/KX_IPhysicsController.cpp
    trunk/blender/source/gameengine/Ketsji/KX_IPhysicsController.h

Modified: trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp	2013-11-04 19:22:15 UTC (rev 61095)
+++ trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp	2013-11-04 19:22:47 UTC (rev 61096)
@@ -1419,12 +1419,12 @@
 				PHY_IMotionState* motionstate = new KX_MotionState(gameobj->GetSGNode());
 				CcdGraphicController* ctrl = new CcdGraphicController(env, motionstate);
 				gameobj->SetGraphicController(ctrl);
-				ctrl->setNewClientInfo(gameobj->getClientInfo());
-				ctrl->setLocalAabb(localAabbMin, localAabbMax);
+				ctrl->SetNewClientInfo(gameobj->getClientInfo());
+				ctrl->SetLocalAabb(localAabbMin, localAabbMax);
 				if (isActive) {
 					// add first, this will create the proxy handle, only if the object is visible
 					if (gameobj->GetVisible())
-						env->addCcdGraphicController(ctrl);
+						env->AddCcdGraphicController(ctrl);
 					// update the mesh if there is a deformer, this will also update the bounding box for modifiers
 					RAS_Deformer* deformer = gameobj->GetDeformer();
 					if (deformer)
@@ -2027,23 +2027,9 @@
 }
 
 #include "PHY_IPhysicsEnvironment.h"
-#include "KX_IPhysicsController.h"
 #include "PHY_DynamicTypes.h"
 
-#if 0  /* UNUSED */
-static KX_IPhysicsController* getPhId(CListValue* sumolist,STR_String busc) {//not used
 
-	for (int j=0;j<sumolist->GetCount();j++)
-	{
-		KX_GameObject* gameobje = (KX_GameObject*) sumolist->GetValue(j);
-		if (gameobje->GetName()==busc)
-			return gameobje->GetPhysicsController();
-	}
-
-	return 0;
-}
-#endif
-
 static KX_GameObject* getGameOb(STR_String busc,CListValue* sumolist)
 {
 
@@ -2585,7 +2571,7 @@
 			kxscene->SetDbvtOcclusionRes(blenderscene->gm.occlusionRes);
 	}
 	if (blenderscene->world)
-		kxscene->GetPhysicsEnvironment()->setNumTimeSubSteps(blenderscene->gm.physubstep);
+		kxscene->GetPhysicsEnvironment()->SetNumTimeSubSteps(blenderscene->gm.physubstep);
 
 	// now that the scenegraph is complete, let's instantiate the deformers.
 	// We need that to create reusable derived mesh and physic shapes
@@ -2676,12 +2662,12 @@
 						{
 							KX_GameObject *gotar=getGameOb(dat->tar->id.name+2,sumolist);
 							if (gotar && ((gotar->GetLayer()&activeLayerBitInfo)!=0) && gotar->GetPhysicsController())
-								physctr2 = (PHY_IPhysicsController*) gotar->GetPhysicsController()->GetUserData();
+								physctr2 = gotar->GetPhysicsController();
 						}
 
 						if (gameobj->GetPhysicsController())
 						{
-							PHY_IPhysicsController* physctrl = (PHY_IPhysicsController*) gameobj->GetPhysicsController()->GetUserData();
+							PHY_IPhysicsController* physctrl = gameobj->GetPhysicsController();
 							//we need to pass a full constraint frame, not just axis
 
 							//localConstraintFrameBasis
@@ -2690,7 +2676,7 @@
 							MT_Vector3 axis1 = localCFrame.getColumn(1);
 							MT_Vector3 axis2 = localCFrame.getColumn(2);
 								
-							int constraintId = kxscene->GetPhysicsEnvironment()->createConstraint(physctrl,physctr2,(PHY_ConstraintType)dat->type,(float)dat->pivX,
+							int constraintId = kxscene->GetPhysicsEnvironment()->CreateConstraint(physctrl,physctr2,(PHY_ConstraintType)dat->type,(float)dat->pivX,
 								(float)dat->pivY,(float)dat->pivZ,
 								(float)axis0.x(),(float)axis0.y(),(float)axis0.z(),
 								(float)axis1.x(),(float)axis1.y(),(float)axis1.z(),
@@ -2706,11 +2692,11 @@
 									{
 										if (dat->flag & dofbit)
 										{
-											kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]);
+											kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]);
 										} else
 										{
 											//minLimit > maxLimit means free(disabled limit) for this degree of freedom
-											kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1);
+											kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,1,-1);
 										}
 										dofbit<<=1;
 									}
@@ -2724,12 +2710,12 @@
 									{
 										if (dat->flag & dofbit)
 										{
-											kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]);
+											kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]);
 										}
 										else
 										{
 											//maxLimit < 0 means free(disabled limit) for this degree of freedom
-											kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1);
+											kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,1,-1);
 										}
 										dofbit<<=1;
 									}
@@ -2741,12 +2727,12 @@
 									
 									if (dat->flag & dofbit)
 									{
-										kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,
+										kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,
 												dat->minLimit[dof],dat->maxLimit[dof]);
 									} else
 									{
 										//minLimit > maxLimit means free(disabled limit) for this degree of freedom
-										kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1);
+										kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,1,-1);
 									}
 								}
 							}

Modified: trunk/blender/source/gameengine/Converter/BL_ModifierDeformer.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_ModifierDeformer.cpp	2013-11-04 19:22:15 UTC (rev 61095)
+++ trunk/blender/source/gameengine/Converter/BL_ModifierDeformer.cpp	2013-11-04 19:22:47 UTC (rev 61096)
@@ -192,7 +192,7 @@
 				float min_r[3], max_r[3];
 				INIT_MINMAX(min_r, max_r);
 				m_dm->getMinMax(m_dm, min_r, max_r);
-				ctrl->setLocalAabb(min_r, max_r);
+				ctrl->SetLocalAabb(min_r, max_r);
 			}
 		}
 		m_lastModifierUpdate=m_gameobj->GetLastFrame();

Modified: trunk/blender/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/KX_BlenderSceneConverter.cpp	2013-11-04 19:22:15 UTC (rev 61095)
+++ trunk/blender/source/gameengine/Converter/KX_BlenderSceneConverter.cpp	2013-11-04 19:22:47 UTC (rev 61096)
@@ -42,7 +42,6 @@
 #include "PHY_IPhysicsEnvironment.h"
 #include "KX_KetsjiEngine.h"
 #include "KX_PythonInit.h" // So we can handle adding new text datablocks for Python to import
-#include "KX_IPhysicsController.h"
 #include "BL_Material.h"
 #include "BL_ActionActuator.h"
 #include "KX_BlenderMaterial.h"
@@ -355,15 +354,15 @@
 		case UseBullet:
 			{
 				CcdPhysicsEnvironment* ccdPhysEnv = new CcdPhysicsEnvironment(useDbvtCulling);
-				ccdPhysEnv->setDebugDrawer(new BlenderDebugDraw());
-				ccdPhysEnv->setDeactivationLinearTreshold(blenderscene->gm.lineardeactthreshold);
-				ccdPhysEnv->setDeactivationAngularTreshold(blenderscene->gm.angulardeactthreshold);
-				ccdPhysEnv->setDeactivationTime(blenderscene->gm.deactivationtime);
+				ccdPhysEnv->SetDebugDrawer(new BlenderDebugDraw());
+				ccdPhysEnv->SetDeactivationLinearTreshold(blenderscene->gm.lineardeactthreshold);
+				ccdPhysEnv->SetDeactivationAngularTreshold(blenderscene->gm.angulardeactthreshold);
+				ccdPhysEnv->SetDeactivationTime(blenderscene->gm.deactivationtime);
 
 				SYS_SystemHandle syshandle = SYS_GetSystem(); /*unused*/
 				int visualizePhysics = SYS_GetCommandLineInt(syshandle,"show_physics",0);
 				if (visualizePhysics)
-					ccdPhysEnv->setDebugMode(btIDebugDraw::DBG_DrawWireframe|btIDebugDraw::DBG_DrawAabb|btIDebugDraw::DBG_DrawContactPoints|btIDebugDraw::DBG_DrawText|btIDebugDraw::DBG_DrawConstraintLimits|btIDebugDraw::DBG_DrawConstraints);
+					ccdPhysEnv->SetDebugMode(btIDebugDraw::DBG_DrawWireframe|btIDebugDraw::DBG_DrawAabb|btIDebugDraw::DBG_DrawContactPoints|btIDebugDraw::DBG_DrawText|btIDebugDraw::DBG_DrawConstraintLimits|btIDebugDraw::DBG_DrawConstraints);
 		
 				//todo: get a button in blender ?
 				//disable / enable debug drawing (contact points, aabb's etc)
@@ -709,7 +708,6 @@
 			KX_GameObject* gameObj = (KX_GameObject*)parentList->GetValue(g);
 			if (gameObj->IsDynamic())
 			{
-				//KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();
 				
 				Object* blenderObject = gameObj->GetBlenderObject();
 				if (blenderObject)
@@ -825,7 +823,6 @@
 			Object* blenderObject = gameObj->GetBlenderObject();
 			if (blenderObject && blenderObject->parent==NULL && gameObj->IsDynamic())
 			{
-				//KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();
 
 				if (blenderObject->adt==NULL)
 					BKE_id_add_animdata(&blenderObject->id);
@@ -944,7 +941,6 @@
 			KX_GameObject* gameObj = (KX_GameObject*)parentList->GetValue(g);
 			if (gameObj->IsDynamic())
 			{
-				//KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();
 				
 #if 0
 				Object* blenderObject = gameObj->GetBlenderObject();

Modified: trunk/blender/source/gameengine/Converter/KX_SoftBodyDeformer.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/KX_SoftBodyDeformer.cpp	2013-11-04 19:22:15 UTC (rev 61095)
+++ trunk/blender/source/gameengine/Converter/KX_SoftBodyDeformer.cpp	2013-11-04 19:22:47 UTC (rev 61096)
@@ -48,7 +48,6 @@
 #include "CcdPhysicsController.h"
 #include "BulletSoftBody/btSoftBody.h"
 
-#include "KX_BulletPhysicsController.h"
 #include "btBulletDynamicsCommon.h"
 
 void KX_SoftBodyDeformer::Relink(CTR_Map<class CTR_HashedPtr, void*>*map)
@@ -66,7 +65,7 @@
 
 bool KX_SoftBodyDeformer::Apply(class RAS_IPolyMaterial *polymat)
 {
-	KX_BulletPhysicsController* ctrl = (KX_BulletPhysicsController*) m_gameobj->GetPhysicsController();
+	CcdPhysicsController* ctrl = (CcdPhysicsController*) m_gameobj->GetPhysicsController();
 	if (!ctrl)
 		return false;
 

Modified: trunk/blender/source/gameengine/Ketsji/BL_Action.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/BL_Action.cpp	2013-11-04 19:22:15 UTC (rev 61095)
+++ trunk/blender/source/gameengine/Ketsji/BL_Action.cpp	2013-11-04 19:22:47 UTC (rev 61096)
@@ -34,6 +34,8 @@
 #include "KX_IpoConvert.h"
 #include "KX_GameObject.h"
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list