Try to allow cake and plunger to have collision callbacks

This commit is contained in:
Benau 2022-06-13 16:16:26 +08:00
parent 8ea38a6103
commit 4b17d2133a
3 changed files with 6 additions and 8 deletions

View File

@ -234,12 +234,6 @@ void Bowling::onFireFlyable()
// this would disable gravity.
setAdjustUpVelocity(false);
// unset no_contact_response flags, so that the ball
// will bounce off the track
int flag = getBody()->getCollisionFlags();
flag = flag & (~ btCollisionObject::CF_NO_CONTACT_RESPONSE);
getBody()->setCollisionFlags(flag);
// should not live forever, auto-destruct after 20 seconds
m_max_lifespan = stk_config->time2Ticks(20);
} // onFireFlyable

View File

@ -186,8 +186,6 @@ void Flyable::createPhysics(float forw_offset, const Vec3 &velocity,
m_body->setLinearVelocity(v);
if(!rotates) m_body->setAngularFactor(0.0f); // prevent rotations
}
m_body->setCollisionFlags(m_body->getCollisionFlags() |
btCollisionObject::CF_NO_CONTACT_RESPONSE);
} // createPhysics
// -----------------------------------------------------------------------------

View File

@ -90,6 +90,12 @@ void RubberBall::onFireFlyable()
btVector3(.0f,.0f,.0f) /*gravity*/,
true /*rotates*/);
// add no_contact_response flags, so that the ball
// will not explode if hitting the track or objects
int flag = getBody()->getCollisionFlags();
flag |= btCollisionObject::CF_NO_CONTACT_RESPONSE;
getBody()->setCollisionFlags(flag);
// Do not adjust the up velocity
setAdjustUpVelocity(false);
m_max_lifespan = stk_config->time2Ticks(9999);