[Bf-blender-cvs] [f5c3c62] master: BGE Cleanup: Moving reinstancing physics shapes from KX_ConvertPhysicsObject to PHY_IPhysicsController

Mitchell Stokes noreply at git.blender.org
Thu Apr 24 04:40:05 CEST 2014


Commit: f5c3c624f8e62f266994be42fa4c85ce579321c0
Author: Mitchell Stokes
Date:   Wed Apr 23 19:37:54 2014 -0700
https://developer.blender.org/rBf5c3c624f8e62f266994be42fa4c85ce579321c0

BGE Cleanup: Moving reinstancing physics shapes from KX_ConvertPhysicsObject to PHY_IPhysicsController

This was the last item in KX_ConvertPhysicsObject. Therefore,
KX_ConvertPhysicsObject.h and KX_ConvertPhysicsObjects.cpp have been
removed.

===================================================================

M	source/gameengine/Converter/BL_BlenderDataConversion.cpp
M	source/gameengine/Converter/KX_BlenderSceneConverter.cpp
M	source/gameengine/Converter/KX_SoftBodyDeformer.cpp
M	source/gameengine/Ketsji/CMakeLists.txt
D	source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
D	source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
M	source/gameengine/Ketsji/KX_GameObject.cpp
M	source/gameengine/Ketsji/KX_MeshProxy.cpp
M	source/gameengine/Ketsji/KX_Scene.cpp
M	source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
M	source/gameengine/Physics/Bullet/CcdPhysicsController.h
M	source/gameengine/Physics/common/PHY_IPhysicsController.h

===================================================================

diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index 47d25c5..2fefea7 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -180,7 +180,6 @@ extern Material defmaterial;	/* material.c */
 #include "SG_BBox.h"
 #include "SG_Tree.h"
 
-#include "KX_ConvertPhysicsObject.h"
 #ifdef WITH_BULLET
 #include "CcdPhysicsEnvironment.h"
 #include "CcdGraphicController.h"
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
index 1df5184..bad99b5 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
@@ -50,7 +50,6 @@
 
 #include "DummyPhysicsEnvironment.h"
 
-#include "KX_ConvertPhysicsObject.h"
 
 #ifdef WITH_BULLET
 #include "CcdPhysicsEnvironment.h"
diff --git a/source/gameengine/Converter/KX_SoftBodyDeformer.cpp b/source/gameengine/Converter/KX_SoftBodyDeformer.cpp
index fcdaaaa..877aebf 100644
--- a/source/gameengine/Converter/KX_SoftBodyDeformer.cpp
+++ b/source/gameengine/Converter/KX_SoftBodyDeformer.cpp
@@ -36,7 +36,6 @@
 
 #include "MT_assert.h"
 
-#include "KX_ConvertPhysicsObject.h"
 #include "KX_SoftBodyDeformer.h"
 #include "RAS_MeshObject.h"
 #include "CTR_Map.h"
diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt
index 141dd5e..09ef167 100644
--- a/source/gameengine/Ketsji/CMakeLists.txt
+++ b/source/gameengine/Ketsji/CMakeLists.txt
@@ -77,7 +77,6 @@ set(SRC
 	KX_CharacterWrapper.cpp
 	KX_ConstraintActuator.cpp
 	KX_ConstraintWrapper.cpp
-	KX_ConvertPhysicsObjects.cpp
 	KX_Dome.cpp
 	KX_EmptyObject.cpp
 	KX_FontObject.cpp
@@ -151,7 +150,6 @@ set(SRC
 	KX_ClientObjectInfo.h
 	KX_ConstraintActuator.h
 	KX_ConstraintWrapper.h
-	KX_ConvertPhysicsObject.h
 	KX_Dome.h
 	KX_EmptyObject.h
 	KX_FontObject.h
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
deleted file mode 100644
index efe4f2e..0000000
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file KX_ConvertPhysicsObject.h
- *  \ingroup ketsji
- */
-
-#ifndef __KX_CONVERTPHYSICSOBJECT_H__
-#define __KX_CONVERTPHYSICSOBJECT_H__
-
-class KX_GameObject;
-class RAS_MeshObject;
-
-#ifdef WITH_BULLET
-
-bool KX_ReInstanceBulletShapeFromMesh(KX_GameObject *gameobj, KX_GameObject *from_gameobj, RAS_MeshObject* from_meshobj);
-
-#endif
-#endif  /* __KX_CONVERTPHYSICSOBJECT_H__ */
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
deleted file mode 100644
index 111d62b..0000000
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
- *  \ingroup ketsji
- */
-
-#ifdef _MSC_VER
-#  pragma warning (disable:4786)
-#endif
-
-#include "KX_ConvertPhysicsObject.h"
-
-#include "KX_GameObject.h"
-#include "RAS_MeshObject.h"
-
-#ifdef WITH_BULLET
-
-#include "CcdPhysicsEnvironment.h"
-#include "CcdPhysicsController.h"
-
-/* Refresh the physics object from either an object or a mesh.
- * gameobj must be valid
- * from_gameobj and from_meshobj can be NULL
- * 
- * when setting the mesh, the following vars get priority
- * 1) from_meshobj - creates the phys mesh from RAS_MeshObject
- * 2) from_gameobj - creates the phys mesh from the DerivedMesh where possible, else the RAS_MeshObject
- * 3) gameobj - update the phys mesh from DerivedMesh or RAS_MeshObject
- * 
- * Most of the logic behind this is in shapeInfo->UpdateMesh(...)
- */
-bool KX_ReInstanceBulletShapeFromMesh(KX_GameObject *gameobj, KX_GameObject *from_gameobj, RAS_MeshObject* from_meshobj)
-{
-	CcdPhysicsController	*spc= static_cast<CcdPhysicsController*>(gameobj->GetPhysicsController());
-	CcdShapeConstructionInfo	*shapeInfo;
-
-	/* if this is the child of a compound shape this can happen
-	 * don't support compound shapes for now */
-	if (spc==NULL)
-		return false;
-	
-	shapeInfo = spc->GetShapeInfo();
-	
-	if (shapeInfo->m_shapeType != PHY_SHAPE_MESH/* || spc->GetSoftBody()*/)
-		return false;
-	
-	spc->DeleteControllerShape();
-	
-	if (from_gameobj==NULL && from_meshobj==NULL)
-		from_gameobj= gameobj;
-	
-	/* updates the arrays used for making the new bullet mesh */
-	shapeInfo->UpdateMesh(from_gameobj, from_meshobj);
-
-	/* create the new bullet mesh */
-	CcdConstructionInfo& cci = spc->GetConstructionInfo();
-	btCollisionShape* bm= shapeInfo->CreateBulletShape(cci.m_margin, cci.m_bGimpact, !cci.m_bSoft);
-
-	spc->ReplaceControllerShape(bm);
-	return true;
-}
-#endif // WITH_BULLET
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index ec64d09..bd8d688 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -1908,11 +1908,11 @@ PyObject *KX_GameObject::PyReinstancePhysicsMesh(PyObject *args)
 		) {
 		return NULL;
 	}
-#ifdef WITH_BULLET
+
 	/* gameobj and mesh can be NULL */
-	if (KX_ReInstanceBulletShapeFromMesh(this, gameobj, mesh))
+	if (GetPhysicsController() && GetPhysicsController()->ReinstancePhysicsShape(gameobj, mesh))
 		Py_RETURN_TRUE;
-#endif
+
 	Py_RETURN_FALSE;
 }
 
diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp
index c288c64..a6f2f72 100644
--- a/source/gameengine/Ketsji/KX_MeshProxy.cpp
+++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp
@@ -42,7 +42,6 @@
 #include "KX_BlenderMaterial.h"
 
 #include "KX_PyMath.h"
-#include "KX_ConvertPhysicsObject.h"
 
 #include "PyObjectPlus.h" 
 
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index 5088551..4ed5d83 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -95,7 +95,6 @@
 
 #ifdef WITH_BULLET
 #include "KX_SoftBodyDeformer.h"
-#include "KX_ConvertPhysicsObject.h"
 #endif
 
 #include "KX_Light.h"
@@ -1276,11 +1275,10 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj, bool use_gfx, bool u
 	gameobj->AddMeshUser();
 	}
 
-#ifdef WITH_BULLET
 	if (use_phys) { /* update the new assigned mesh with the physics mesh */
-		KX_ReInstanceBulletShapeFromMesh(gameobj, NULL, use_gfx?NULL:mesh);
+		if (gameobj->GetPhysicsController())
+			gameobj->GetPhysicsController()->ReinstancePhysicsShape(NULL, use_gfx?NULL:mesh);
 	}
-#endif
 }
 
 /* Font Object routines */
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
index 3372601..c98cf21 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
@@ -1625,6 +1625,41 @@ PHY_IPhysicsController*	CcdPhysicsController::GetReplicaForSensors()
 	return replica;
 }
 
+/* Refresh the physics object from either an object or a mesh.
+ * from_gameobj and from_meshobj can be NULL
+ *
+ * when setting the mesh, the following vars get priority
+ * 1) from_meshobj - creates the phys mesh from RAS_MeshObject
+ * 2) from_gameobj - creates the phys mesh from the DerivedMesh where possible, else the RAS_MeshObject
+ * 3) this - update the phys mesh from DerivedMesh or RAS_MeshObject
+ *
+ * Most of the logic behind this is in shapeInfo->UpdateMesh(...)
+ */
+bool CcdPhysicsController::ReinstancePhysicsShape(KX_GameObject *from_gameobj, RAS_MeshObject *from_meshobj)
+{
+	CcdShapeConstructionInfo	*shapeInfo;
+
+	shapeInfo = this->GetShapeInfo();
+
+	if (shapeInfo->m_shapeType != PHY_SHAPE_MESH/* || spc->GetSoftBody()*/)
+		return false;
+
+	this->DeleteControllerShape();
+
+	if (from_gameobj==NULL && from_meshobj==NULL)
+		from_gameobj = KX_GameObject::GetClientObject((KX_ClientObjectInfo*)this->GetNewClientInfo());
+
+	/* updates the arrays used for making the new bullet mesh */
+	shapeInfo->UpdateMesh(from_gameobj, from_meshobj);
+
+	/* create the new bullet mesh */
+	CcdConstructionInfo& cci = this->GetConstructionInfo();
+	btCollisionShape* bm= shapeInfo->CreateBull

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list