@@ -2872,6 +2872,9 @@ bool afSoftBody::createFromAttribs(afSoftBodyAttributes *a_attribs)
2872
2872
return 0 ;
2873
2873
}
2874
2874
2875
+ m_shaderAttribs = a_attribs->m_shaderAttribs ;
2876
+ loadShaderProgram ();
2877
+
2875
2878
if (m_collisionMesh->loadFromFile (a_attribs->m_collisionAttribs .m_meshFilepath .c_str ())){
2876
2879
m_collisionMesh->removeDuplicateVertices ();
2877
2880
m_collisionMesh->scale (m_scale);
@@ -2985,6 +2988,22 @@ bool afSoftBody::createFromAttribs(afSoftBodyAttributes *a_attribs)
2985
2988
softBody->randomizeConstraints ();
2986
2989
}
2987
2990
2991
+ for (uint gI = 0 ; gI < a_attribs->m_collisionAttribs .m_groups .size () ; gI ++){
2992
+ uint group = a_attribs->m_collisionAttribs .m_groups [gI ];
2993
+ // Sanity check for the group number
2994
+ if (group >= 0 && group <= 999 ){
2995
+ m_afWorld->m_collisionGroups [group].push_back (this );
2996
+ m_collisionGroups.push_back (group);
2997
+ // Print the soft body name and group
2998
+ cout << " SoftBody Name: " << m_name << " , Group: " << group << endl;
2999
+ }
3000
+ else {
3001
+ cerr << " WARNING! Body "
3002
+ << m_name
3003
+ << " 's group number is \" " << group << " \" which should be between [0 - 999], ignoring\n " ;
3004
+ }
3005
+ }
3006
+
2988
3007
addChildSceneObject (m_visualMesh, cTransform ());
2989
3008
((btSoftRigidDynamicsWorld*)m_afWorld->m_bulletWorld )->addSoftBody (m_bulletSoftBody);
2990
3009
m_afWorld->m_bulletSoftBodyWorldInfo ->m_sparsesdf .Reset ();
@@ -6018,14 +6037,32 @@ void afWorld::buildCollisionGroups(){
6018
6037
afInertialObjectPtr bodyA = grpA[aBodyIdx];
6019
6038
for (uint bBodyIdx = 0 ; bBodyIdx < grpB.size () ; bBodyIdx++){
6020
6039
afInertialObjectPtr bodyB = grpB[bBodyIdx];
6021
- if (bodyA != bodyB && !bodyB->isCommonCollisionGroupIdx (bodyA->m_collisionGroups ))
6022
- bodyA->m_bulletRigidBody ->setIgnoreCollisionCheck (bodyB->m_bulletRigidBody , true );
6040
+ if (bodyA != bodyB && !bodyB->isCommonCollisionGroupIdx (bodyA->m_collisionGroups )){
6041
+ if (bodyA->m_bulletRigidBody && bodyB->m_bulletRigidBody ) {
6042
+ bodyA->m_bulletRigidBody ->setIgnoreCollisionCheck (bodyB->m_bulletRigidBody , true );
6043
+ // cout << "Ignoring collision between rigid bodies: " << bodyA << " and " << bodyB << endl;
6044
+ }
6045
+ // Handle Soft Body
6046
+ else if (bodyA->m_bulletSoftBody && bodyB->m_bulletRigidBody ) {
6047
+ bodyB->m_bulletRigidBody ->setIgnoreCollisionCheck (bodyA->m_bulletSoftBody , true );
6048
+ // cout << "Ignoring collision between soft body: " << bodyA << " and rigid body: " << bodyB << endl;
6049
+ }
6050
+ else if (bodyA->m_bulletRigidBody && bodyB->m_bulletSoftBody ) {
6051
+ bodyA->m_bulletRigidBody ->setIgnoreCollisionCheck (bodyB->m_bulletSoftBody , true );
6052
+ // cout << "Ignoring collision between rigid body: " << bodyA << " and soft body: " << bodyB << endl;
6053
+ }
6054
+ else if (bodyA->m_bulletSoftBody && bodyB->m_bulletSoftBody ) {
6055
+ // Set ignore collision for both soft bodies
6056
+ bodyA->m_bulletSoftBody ->setIgnoreCollisionCheck (bodyB->m_bulletSoftBody , true );
6057
+ // cout << "Ignoring collision between soft bodies: " << bodyA << " and " << bodyB << endl;
6058
+ }
6023
6059
}
6024
6060
}
6025
6061
}
6026
6062
}
6027
6063
}
6028
6064
}
6065
+ }
6029
6066
6030
6067
6031
6068
0 commit comments