[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21909] branches/blender2.5/blender/source /gameengine: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/ blender -r21899:21908
Campbell Barton
ideasman42 at gmail.com
Sun Jul 26 01:16:45 CEST 2009
Revision: 21909
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21909
Author: campbellbarton
Date: 2009-07-26 01:16:45 +0200 (Sun, 26 Jul 2009)
Log Message:
-----------
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r21899:21908
Modified Paths:
--------------
branches/blender2.5/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
branches/blender2.5/blender/source/gameengine/Converter/BL_MeshDeformer.h
branches/blender2.5/blender/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
branches/blender2.5/blender/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
branches/blender2.5/blender/source/gameengine/Ketsji/KX_GameObject.cpp
branches/blender2.5/blender/source/gameengine/Ketsji/KX_GameObject.h
branches/blender2.5/blender/source/gameengine/Ketsji/KX_MeshProxy.cpp
branches/blender2.5/blender/source/gameengine/Ketsji/KX_MeshProxy.h
branches/blender2.5/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
branches/blender2.5/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.h
branches/blender2.5/blender/source/gameengine/PyDoc/GameTypes.py
branches/blender2.5/blender/source/gameengine/Rasterizer/RAS_Deformer.h
branches/blender2.5/blender/source/gameengine/Rasterizer/RAS_MeshObject.cpp
branches/blender2.5/blender/source/gameengine/Rasterizer/RAS_MeshObject.h
Modified: branches/blender2.5/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
===================================================================
--- branches/blender2.5/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp 2009-07-25 22:57:29 UTC (rev 21908)
+++ branches/blender2.5/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp 2009-07-25 23:16:45 UTC (rev 21909)
@@ -1039,7 +1039,10 @@
layer.face++;
}
}
- meshobj->m_sharedvertex_map.clear();
+ // keep meshobj->m_sharedvertex_map for reinstance phys mesh.
+ // 2.49a and before it did: meshobj->m_sharedvertex_map.clear();
+ // but this didnt save much ram. - Campbell
+ meshobj->EndConversion();
// pre calculate texture generation
for(list<RAS_MeshMaterial>::iterator mit = meshobj->GetFirstMaterial();
Modified: branches/blender2.5/blender/source/gameengine/Converter/BL_MeshDeformer.h
===================================================================
--- branches/blender2.5/blender/source/gameengine/Converter/BL_MeshDeformer.h 2009-07-25 22:57:29 UTC (rev 21908)
+++ branches/blender2.5/blender/source/gameengine/Converter/BL_MeshDeformer.h 2009-07-25 23:16:45 UTC (rev 21909)
@@ -68,6 +68,8 @@
virtual RAS_Deformer* GetReplica(){return NULL;};
virtual void ProcessReplica();
struct Mesh* GetMesh() { return m_bmesh; };
+ virtual class RAS_MeshObject* GetRasMesh() { return (RAS_MeshObject*)m_pMeshObject; };
+ virtual float (* GetTransVerts(int *tot))[3] { *tot= m_tvtot; return m_transverts; }
// virtual void InitDeform(double time){};
protected:
Modified: branches/blender2.5/blender/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
===================================================================
--- branches/blender2.5/blender/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h 2009-07-25 22:57:29 UTC (rev 21908)
+++ branches/blender2.5/blender/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h 2009-07-25 23:16:45 UTC (rev 21909)
@@ -164,7 +164,7 @@
struct KX_ObjectProperties* objprop);
void KX_ClearBulletSharedShapes();
-//bool KX_ReInstanceShapeFromMesh(RAS_MeshObject* meshobj);
+bool KX_ReInstanceBulletShapeFromMesh(KX_GameObject *gameobj, KX_GameObject *from_gameobj, RAS_MeshObject* from_meshobj);
#endif
#endif //KX_CONVERTPHYSICSOBJECTS
Modified: branches/blender2.5/blender/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
===================================================================
--- branches/blender2.5/blender/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp 2009-07-25 22:57:29 UTC (rev 21908)
+++ branches/blender2.5/blender/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp 2009-07-25 23:16:45 UTC (rev 21909)
@@ -628,5 +628,44 @@
{
}
+/* 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)
+{
+ KX_BulletPhysicsController *spc= static_cast<KX_BulletPhysicsController*>((gameobj->GetPhysicsController()));
+ CcdShapeConstructionInfo *shapeInfo;
+
+ /* if this is the child of a compound shape this can happen
+ * dont 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 */
+ btCollisionShape* bm= shapeInfo->CreateBulletShape(spc->getConstructionInfo().m_margin);
+
+ spc->ReplaceControllerShape(bm);
+ return true;
+}
#endif
-
Modified: branches/blender2.5/blender/source/gameengine/Ketsji/KX_GameObject.cpp
===================================================================
--- branches/blender2.5/blender/source/gameengine/Ketsji/KX_GameObject.cpp 2009-07-25 22:57:29 UTC (rev 21908)
+++ branches/blender2.5/blender/source/gameengine/Ketsji/KX_GameObject.cpp 2009-07-25 23:16:45 UTC (rev 21909)
@@ -66,6 +66,7 @@
#include "KX_PythonInit.h"
#include "KX_PyMath.h"
#include "KX_PythonSeq.h"
+#include "KX_ConvertPhysicsObject.h"
#include "SCA_IActuator.h"
#include "SCA_ISensor.h"
#include "SCA_IController.h"
@@ -1389,6 +1390,7 @@
{"getPropertyNames", (PyCFunction)KX_GameObject::sPyGetPropertyNames,METH_NOARGS},
{"replaceMesh",(PyCFunction) KX_GameObject::sPyReplaceMesh, METH_O},
{"endObject",(PyCFunction) KX_GameObject::sPyEndObject, METH_NOARGS},
+ {"reinstancePhysicsMesh", (PyCFunction)KX_GameObject::sPyReinstancePhysicsMesh,METH_VARARGS},
KX_PYMETHODTABLE(KX_GameObject, rayCastTo),
KX_PYMETHODTABLE(KX_GameObject, rayCast),
@@ -1486,7 +1488,29 @@
}
+PyObject* KX_GameObject::PyReinstancePhysicsMesh(PyObject* args)
+{
+ KX_GameObject *gameobj= NULL;
+ RAS_MeshObject *mesh= NULL;
+
+ PyObject *gameobj_py= NULL;
+ PyObject *mesh_py= NULL;
+ if ( !PyArg_ParseTuple(args,"|OO:reinstancePhysicsMesh",&gameobj_py, &mesh_py) ||
+ (gameobj_py && !ConvertPythonToGameObject(gameobj_py, &gameobj, true, "gameOb.reinstancePhysicsMesh(obj, mesh): KX_GameObject")) ||
+ (mesh_py && !ConvertPythonToMesh(mesh_py, &mesh, true, "gameOb.reinstancePhysicsMesh(obj, mesh): KX_GameObject"))
+ ) {
+ return NULL;
+ }
+
+ /* gameobj and mesh can be NULL */
+ if(KX_ReInstanceBulletShapeFromMesh(this, gameobj, mesh))
+ Py_RETURN_TRUE;
+
+ Py_RETURN_FALSE;
+}
+
+
PyObject* KX_GameObject::PyGetPosition()
{
ShowDeprecationWarning("getPosition()", "the position property");
Modified: branches/blender2.5/blender/source/gameengine/Ketsji/KX_GameObject.h
===================================================================
--- branches/blender2.5/blender/source/gameengine/Ketsji/KX_GameObject.h 2009-07-25 22:57:29 UTC (rev 21908)
+++ branches/blender2.5/blender/source/gameengine/Ketsji/KX_GameObject.h 2009-07-25 23:16:45 UTC (rev 21909)
@@ -856,6 +856,7 @@
KX_PYMETHOD_DOC_O(KX_GameObject,getDistanceTo);
KX_PYMETHOD_DOC_O(KX_GameObject,getVectTo);
KX_PYMETHOD_DOC_VARARGS(KX_GameObject, sendMessage);
+ KX_PYMETHOD_VARARGS(KX_GameObject, ReinstancePhysicsMesh);
/* Dict access */
KX_PYMETHOD_VARARGS(KX_GameObject,get);
Modified: branches/blender2.5/blender/source/gameengine/Ketsji/KX_MeshProxy.cpp
===================================================================
--- branches/blender2.5/blender/source/gameengine/Ketsji/KX_MeshProxy.cpp 2009-07-25 22:57:29 UTC (rev 21908)
+++ branches/blender2.5/blender/source/gameengine/Ketsji/KX_MeshProxy.cpp 2009-07-25 23:16:45 UTC (rev 21909)
@@ -84,7 +84,6 @@
{"getVertexArrayLength", (PyCFunction)KX_MeshProxy::sPyGetVertexArrayLength,METH_VARARGS},
{"getVertex", (PyCFunction)KX_MeshProxy::sPyGetVertex,METH_VARARGS},
{"getPolygon", (PyCFunction)KX_MeshProxy::sPyGetPolygon,METH_VARARGS},
-KX_PYMETHODTABLE(KX_MeshProxy, reinstancePhysicsMesh),
//{"getIndexArrayLength", (PyCFunction)KX_MeshProxy::sPyGetIndexArrayLength,METH_VARARGS},
{NULL,NULL} //Sentinel
@@ -243,17 +242,6 @@
return polyob;
}
-KX_PYMETHODDEF_DOC(KX_MeshProxy, reinstancePhysicsMesh,
-"Reinstance the physics mesh.")
-{
-#if 0
- //this needs to be reviewed, it is dependend on Sumo/Solid. Who is using this ?
- if(KX_ReInstanceShapeFromMesh(m_meshobj))
- Py_RETURN_TRUE;
-#endif
- Py_RETURN_FALSE;
-}
-
PyObject* KX_MeshProxy::pyattr_get_materials(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_MeshProxy* self= static_cast<KX_MeshProxy*>(self_v);
Modified: branches/blender2.5/blender/source/gameengine/Ketsji/KX_MeshProxy.h
===================================================================
--- branches/blender2.5/blender/source/gameengine/Ketsji/KX_MeshProxy.h 2009-07-25 22:57:29 UTC (rev 21908)
+++ branches/blender2.5/blender/source/gameengine/Ketsji/KX_MeshProxy.h 2009-07-25 23:16:45 UTC (rev 21909)
@@ -66,7 +66,6 @@
KX_PYMETHOD(KX_MeshProxy,GetVertexArrayLength);
KX_PYMETHOD(KX_MeshProxy,GetVertex);
KX_PYMETHOD(KX_MeshProxy,GetPolygon);
- KX_PYMETHOD_DOC(KX_MeshProxy, reinstancePhysicsMesh);
static PyObject* pyattr_get_materials(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject * pyattr_get_numMaterials(void * self, const KX_PYATTRIBUTE_DEF * attrdef);
Modified: branches/blender2.5/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
===================================================================
--- branches/blender2.5/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp 2009-07-25 22:57:29 UTC (rev 21908)
+++ branches/blender2.5/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp 2009-07-25 23:16:45 UTC (rev 21909)
@@ -22,6 +22,8 @@
#include "PHY_IMotionState.h"
#include "CcdPhysicsEnvironment.h"
#include "RAS_MeshObject.h"
+#include "KX_GameObject.h"
+
#include "BulletSoftBody/btSoftBody.h"
#include "BulletSoftBody//btSoftBodyInternals.h"
#include "BulletSoftBody/btSoftBodyHelpers.h"
@@ -529,7 +531,7 @@
}
-static void DeleteBulletShape(btCollisionShape* shape)
+static void DeleteBulletShape(btCollisionShape* shape, bool free)
{
if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
{
@@ -539,21 +541,13 @@
if (meshInterface)
delete meshInterface;
}
- delete shape;
+ if(free) {
+ delete shape;
+ }
}
-CcdPhysicsController::~CcdPhysicsController()
+bool CcdPhysicsController::DeleteControllerShape( )
{
- //will be reference counted, due to sharing
- if (m_cci.m_physicsEnv)
- m_cci.m_physicsEnv->removeCcdPhysicsController(this);
-
- if (m_MotionState)
- delete m_MotionState;
- if (m_bulletMotionState)
- delete m_bulletMotionState;
- delete m_object;
-
if (m_collisionShape)
{
// collision shape is always unique to the controller, can delete it here
@@ -565,11 +559,64 @@
for (int i=numChild-1 ; i >= 0; i--)
{
btCollisionShape* childShape = compoundShape->getChildShape(i);
- DeleteBulletShape(childShape);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list