1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 10:22:52 +01:00

Tidy up code in object physics handling

This commit is contained in:
Daniel Evans 2018-01-12 04:31:49 +00:00
parent 1c57fb5d98
commit 4f0109b17e
2 changed files with 2 additions and 10 deletions

View File

@ -50,8 +50,6 @@ void InstanceObject::tick(float dt) {
if (dynamics && body) {
if (_enablePhysics) {
if (body->getBulletBody()->isStaticObject()) {
// Apparently bodies must be removed and re-added if their mass
// changes.
body->changeMass(dynamics->mass);
}
}
@ -157,7 +155,6 @@ void InstanceObject::changeModel(BaseModelInfo* incoming) {
if (collision) {
body = std::make_unique<CollisionInstance>();
body->createPhysicsBody(this, collision, dynamics.get());
body->getBulletBody()->setActivationState(ISLAND_SLEEPING);
}
}
}
@ -190,8 +187,7 @@ bool InstanceObject::takeDamage(const GameObject::DamageInfo& dmg) {
smash = dynamics->collDamageFlags == 80;
if (dmg.impulse >= dynamics->uprootForce &&
(body->getBulletBody()->getCollisionFlags() &
btRigidBody::CF_STATIC_OBJECT) != 0) {
body->getBulletBody()->isStaticObject()) {
_enablePhysics = true;
}
}

View File

@ -104,6 +104,7 @@ VehicleObject::VehicleObject(GameWorld* engine, const glm::vec3& pos,
, physVehicle(nullptr) {
collision->createPhysicsBody(this, modelinfo->getCollision(), nullptr,
&info->handling);
collision->getBulletBody()->forceActivationState(DISABLE_DEACTIVATION);
physRaycaster = new VehicleRaycaster(this, engine->dynamicsWorld.get());
btRaycastVehicle::btVehicleTuning tuning;
@ -115,7 +116,6 @@ VehicleObject::VehicleObject(GameWorld* engine, const glm::vec3& pos,
physVehicle =
new btRaycastVehicle(tuning, collision->getBulletBody(), physRaycaster);
physVehicle->setCoordinateSystem(0, 2, 1);
// physBody->setActivationState(DISABLE_DEACTIVATION);
engine->dynamicsWorld->addAction(physVehicle);
float kC = 0.5f;
@ -242,10 +242,6 @@ void VehicleObject::tickPhysics(float dt) {
// todo: a real engine function
float velFac = info->handling.maxVelocity;
float engineForce = info->handling.acceleration * throttle * velFac;
if (std::fabs(engineForce) >= 0.001f) {
collision->getBulletBody()->activate(true);
}
float brakeF = getBraking();
if (handbrake) {