1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 19:32:49 +01:00

Add function to disable collision for InstanceObjects

This commit is contained in:
Jannik Vogel 2016-06-02 17:13:00 +02:00
parent 42ef84998a
commit e5014e29f9
2 changed files with 18 additions and 0 deletions

View File

@ -38,6 +38,8 @@ public:
virtual bool takeDamage(const DamageInfo& damage); virtual bool takeDamage(const DamageInfo& damage);
void setSolid(bool solid);
float getHealth() const { return health; } float getHealth() const { return health; }
}; };

View File

@ -174,4 +174,20 @@ bool InstanceObject::takeDamage(const GameObject::DamageInfo& dmg)
return false; return false;
} }
void InstanceObject::setSolid(bool solid)
{
// Early out in case we don't have a collision body
if (body == nullptr || body->body == nullptr) {
return;
}
int flags = body->body->getCollisionFlags();
if (solid) {
flags &= ~btCollisionObject::CF_NO_CONTACT_RESPONSE;
} else {
flags |= btCollisionObject::CF_NO_CONTACT_RESPONSE;
}
body->body->setCollisionFlags(flags);
}