mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-07 11:22:45 +01:00
Add function to disable collision for InstanceObjects
This commit is contained in:
parent
42ef84998a
commit
e5014e29f9
@ -38,6 +38,8 @@ public:
|
||||
|
||||
virtual bool takeDamage(const DamageInfo& damage);
|
||||
|
||||
void setSolid(bool solid);
|
||||
|
||||
float getHealth() const { return health; }
|
||||
};
|
||||
|
||||
|
@ -174,4 +174,20 @@ bool InstanceObject::takeDamage(const GameObject::DamageInfo& dmg)
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user