diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-07-26 02:57:29 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-07-26 02:57:29 +0400 |
commit | e9ca43521f99c6b9baf6d9278f85323086fcade2 (patch) | |
tree | 58ab9f5afe70d77fa04f920fa2c55adb34cd2990 /source/gameengine/Rasterizer | |
parent | 1c00eacca2b084d7189de33cb75e8612cb542030 (diff) |
BGE Physics
Add support back for reinstancePhysics mesh, a frequently requested feature in the BGE forums.
from what I can tell Sumo supported this but bullet never did.
Currently only accessible via python at the moment.
- rigid body, dynamic, static types work.
- instanced physics meshes are modified too.
- compound shapes are not supported.
Physics mesh can be re-instanced from...
* shape keys & armature deformations
* subsurf (any other modifiers too)
* RAS_TexVert's (can be modified from python)
Moved the reinstancePhysicsMesh functions from RAS_MeshObject into KX_GameObject since the physics data is stored here.
video and blend file demo.
http://www.graphicall.org/ftp/ideasman42/reinstance.ogv
http://www.graphicall.org/ftp/ideasman42/reinstance_demo.blend
Diffstat (limited to 'source/gameengine/Rasterizer')
-rw-r--r-- | source/gameengine/Rasterizer/RAS_Deformer.h | 7 | ||||
-rw-r--r-- | source/gameengine/Rasterizer/RAS_MeshObject.cpp | 7 | ||||
-rw-r--r-- | source/gameengine/Rasterizer/RAS_MeshObject.h | 8 |
3 files changed, 22 insertions, 0 deletions
diff --git a/source/gameengine/Rasterizer/RAS_Deformer.h b/source/gameengine/Rasterizer/RAS_Deformer.h index fe9b1540af8..75c0dcd1eeb 100644 --- a/source/gameengine/Rasterizer/RAS_Deformer.h +++ b/source/gameengine/Rasterizer/RAS_Deformer.h @@ -38,6 +38,7 @@ #include "GEN_Map.h" struct DerivedMesh; +class RAS_MeshObject; class RAS_Deformer { @@ -71,6 +72,12 @@ public: { return NULL; } + virtual class RAS_MeshObject* GetRasMesh() + { + /* m_pMesh does not seem to be being used?? */ + return NULL; + } + virtual float (* GetTransVerts(int *tot))[3] { *tot= 0; return NULL; } protected: class RAS_MeshObject *m_pMesh; diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp index 1dfcb0c512d..0ae6ad9d7ea 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp +++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp @@ -382,6 +382,13 @@ RAS_TexVert* RAS_MeshObject::GetVertex(unsigned int matid, return NULL; } +const float* RAS_MeshObject::GetVertexLocation(unsigned int orig_index) +{ + vector<SharedVertex>& sharedmap = m_sharedvertex_map[orig_index]; + vector<SharedVertex>::iterator it= sharedmap.begin(); + return it->m_darray->m_vertex[it->m_offset].getXYZ(); +} + void RAS_MeshObject::AddMeshUser(void *clientobj, SG_QList *head, RAS_Deformer* deformer) { list<RAS_MeshMaterial>::iterator it; diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h index e763d6e7c7f..bf9c0f7b682 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.h +++ b/source/gameengine/Rasterizer/RAS_MeshObject.h @@ -126,6 +126,7 @@ public: /* vertex and polygon acces */ int NumVertices(RAS_IPolyMaterial* mat); RAS_TexVert* GetVertex(unsigned int matid, unsigned int index); + const float* GetVertexLocation(unsigned int orig_index); int NumPolygons(); RAS_Polygon* GetPolygon(int num) const; @@ -141,6 +142,13 @@ public: bool culled); void RemoveFromBuckets(void *clientobj); + void EndConversion() { +#if 0 + m_sharedvertex_map.clear(); // SharedVertex + vector<vector<SharedVertex> > shared_null(0); + shared_null.swap( m_sharedvertex_map ); /* really free the memory */ +#endif + } /* colors */ void DebugColor(unsigned int abgr); |