Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Bolsee <benoit.bolsee@online.be>2009-11-28 20:30:34 +0300
committerBenoit Bolsee <benoit.bolsee@online.be>2009-11-28 20:30:34 +0300
commit1c4150f21138ad0ab6e8b1a41688074e8a87e64c (patch)
tree885104ef63e7beccd5c540be5bdffe37bbb83e72 /source/gameengine
parent38ba32a42396aeb320beee88a3909cfb6de5e631 (diff)
BGE: ray casting works on soft body, the hit polygon is also returned. The modifications to Bullet have been reported to Bullet forum. Note: welding is completely disabled on soft body as it breaks the relationship between the soft body collision shape and the graphics mesh without bringing any additional stability (the reverse actually).
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.cpp4
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp10
2 files changed, 12 insertions, 2 deletions
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index d837b2c4466..31616fdec15 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -1458,7 +1458,9 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
objprop.m_soft_kAHR= blenderobject->bsoft->kAHR; /* Anchors hardness [0,1] */
objprop.m_soft_collisionflags= blenderobject->bsoft->collisionflags; /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
objprop.m_soft_numclusteriterations= blenderobject->bsoft->numclusteriterations; /* number of iterations to refine collision clusters*/
- objprop.m_soft_welding = blenderobject->bsoft->welding; /* welding */
+ //objprop.m_soft_welding = blenderobject->bsoft->welding; /* welding */
+ /* disable welding: it doesn't bring any additional stability and it breaks the relation between soft body collision shape and graphic mesh */
+ objprop.m_soft_welding = 0.f;
objprop.m_margin = blenderobject->bsoft->margin;
objprop.m_contactProcessingThreshold = 0.f;
} else
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index 5cd20a3ec12..3d1fa6fc180 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -1070,6 +1070,8 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallbac
rayCallback.m_hitTriangleIndex < shapeInfo->m_polygonIndexArray.size())
{
result.m_meshObject = shapeInfo->GetMesh();
+ // note for softbody: this assumes that the softbody shape uses the same triangle numbering
+ // than the triangle mesh shape that was used to build it
result.m_polygon = shapeInfo->m_polygonIndexArray.at(rayCallback.m_hitTriangleIndex);
// Bullet returns the normal from "outside".
@@ -1078,7 +1080,13 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallbac
{
// mesh shapes are shared and stored in the shapeInfo
btTriangleMeshShape* triangleShape = shapeInfo->GetMeshShape();
- if (triangleShape)
+
+ if (shape->isSoftBody())
+ {
+ // we can get the real normal directly from the body
+ btSoftBody* softBody = static_cast<btSoftBody*>(rayCallback.m_collisionObject);
+ rayCallback.m_hitNormalWorld = softBody->m_faces[rayCallback.m_hitTriangleIndex].m_normal;
+ } else if (triangleShape)
{
// this code is copied from Bullet
btVector3 triangle[3];