diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2012-02-05 13:32:35 +0400 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2012-02-05 13:32:35 +0400 |
commit | 223216a36f0adc23341307042cc4d838b7dde800 (patch) | |
tree | 33c62097a6bf0dc9125c5f2fb755f00ff93b2a96 /source/gameengine | |
parent | 5e92c4e38125849c5790a14be3d98441afaf2edb (diff) |
BGE bug #21947: Softbodies not using object size. Fixed by scaling the shape before creating the soft body.
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Physics/Bullet/CcdPhysicsController.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 22aa781ebc2..4b3e2ea33a3 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -231,6 +231,8 @@ bool CcdPhysicsController::CreateSoftbody() if (trimeshshape->getMeshInterface()->getNumSubParts()==1) { unsigned char* vertexBase; + btScalar* scaledVertexBase; + btVector3 localScaling; PHY_ScalarType vertexType; int numverts; int vertexstride; @@ -238,8 +240,16 @@ bool CcdPhysicsController::CreateSoftbody() int indexstride; PHY_ScalarType indexType; trimeshshape->getMeshInterface()->getLockedVertexIndexBase(&vertexBase,numverts,vertexType,vertexstride,&indexbase,indexstride,numtris,indexType); - - psb = btSoftBodyHelpers::CreateFromTriMesh(worldInfo,(const btScalar*)vertexBase,(const int*)indexbase,numtris,false); + localScaling = scaledtrimeshshape->getLocalScaling(); + scaledVertexBase = new btScalar[numverts*3]; + for (int i=0; i<numverts*3; i+=3) + { + scaledVertexBase[i] = ((const btScalar*)vertexBase)[i] * localScaling.getX(); + scaledVertexBase[i+1] = ((const btScalar*)vertexBase)[i+1] * localScaling.getY(); + scaledVertexBase[i+2] = ((const btScalar*)vertexBase)[i+2] * localScaling.getZ(); + } + psb = btSoftBodyHelpers::CreateFromTriMesh(worldInfo,scaledVertexBase,(const int*)indexbase,numtris,false); + delete [] scaledVertexBase; } } else { |