Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Collision Filtering and Loaded Shaders for Softbodies #238

Open
wants to merge 1 commit into
base: ambf-2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions adf_loader/version_1_0/adf_loader_1_0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1509,6 +1509,7 @@ bool ADFLoader_1_0::loadSoftBodyAttribs(YAML::Node *a_node, afSoftBodyAttributes
YAML::Node colorNode = node["color"];
YAML::Node colorRGBANode = node["color rgba"];
YAML::Node colorComponentsNode = node["color components"];
YAML::Node collisionGroupsNode = node["collision groups"];

YAML::Node configDataNode = node["config"];

Expand Down
41 changes: 39 additions & 2 deletions ambf_framework/afFramework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2872,6 +2872,9 @@ bool afSoftBody::createFromAttribs(afSoftBodyAttributes *a_attribs)
return 0;
}

m_shaderAttribs = a_attribs->m_shaderAttribs;
loadShaderProgram();

if (m_collisionMesh->loadFromFile(a_attribs->m_collisionAttribs.m_meshFilepath.c_str())){
m_collisionMesh->removeDuplicateVertices();
m_collisionMesh->scale(m_scale);
Expand Down Expand Up @@ -2985,6 +2988,22 @@ bool afSoftBody::createFromAttribs(afSoftBodyAttributes *a_attribs)
softBody->randomizeConstraints();
}

for (uint gI = 0 ; gI < a_attribs->m_collisionAttribs.m_groups.size() ; gI++){
uint group = a_attribs->m_collisionAttribs.m_groups[gI];
// Sanity check for the group number
if (group >= 0 && group <= 999){
m_afWorld->m_collisionGroups[group].push_back(this);
m_collisionGroups.push_back(group);
// Print the soft body name and group
cout << "SoftBody Name: " << m_name << ", Group: " << group << endl;
}
else{
cerr << "WARNING! Body "
<< m_name
<< "'s group number is \"" << group << "\" which should be between [0 - 999], ignoring\n";
}
}

addChildSceneObject(m_visualMesh, cTransform());
((btSoftRigidDynamicsWorld*)m_afWorld->m_bulletWorld)->addSoftBody(m_bulletSoftBody);
m_afWorld->m_bulletSoftBodyWorldInfo->m_sparsesdf.Reset();
Expand Down Expand Up @@ -5993,14 +6012,32 @@ void afWorld::buildCollisionGroups(){
afInertialObjectPtr bodyA = grpA[aBodyIdx];
for(uint bBodyIdx = 0 ; bBodyIdx < grpB.size() ; bBodyIdx++){
afInertialObjectPtr bodyB = grpB[bBodyIdx];
if (bodyA != bodyB && !bodyB->isCommonCollisionGroupIdx(bodyA->m_collisionGroups))
bodyA->m_bulletRigidBody->setIgnoreCollisionCheck(bodyB->m_bulletRigidBody, true);
if (bodyA != bodyB && !bodyB->isCommonCollisionGroupIdx(bodyA->m_collisionGroups)){
if (bodyA->m_bulletRigidBody && bodyB->m_bulletRigidBody) {
bodyA->m_bulletRigidBody->setIgnoreCollisionCheck(bodyB->m_bulletRigidBody, true);
//cout << "Ignoring collision between rigid bodies: " << bodyA << " and " << bodyB << endl;
}
// Handle Soft Body
else if (bodyA->m_bulletSoftBody && bodyB->m_bulletRigidBody) {
bodyB->m_bulletRigidBody->setIgnoreCollisionCheck(bodyA->m_bulletSoftBody, true);
//cout << "Ignoring collision between soft body: " << bodyA << " and rigid body: " << bodyB << endl;
}
else if (bodyA->m_bulletRigidBody && bodyB->m_bulletSoftBody) {
bodyA->m_bulletRigidBody->setIgnoreCollisionCheck(bodyB->m_bulletSoftBody, true);
//cout << "Ignoring collision between rigid body: " << bodyA << " and soft body: " << bodyB << endl;
}
else if (bodyA->m_bulletSoftBody && bodyB->m_bulletSoftBody) {
// Set ignore collision for both soft bodies
bodyA->m_bulletSoftBody->setIgnoreCollisionCheck(bodyB->m_bulletSoftBody, true);
//cout << "Ignoring collision between soft bodies: " << bodyA << " and " << bodyB << endl;
}
}
}
}
}
}
}
}



Expand Down