From 43047269abfcdfe41b973d778cd44669b39f2a8a Mon Sep 17 00:00:00 2001 From: Daniel Evans Date: Thu, 19 Oct 2017 00:01:29 +0100 Subject: [PATCH] Offset vehicle spawn height to account for dimensions Should prevent vehicles spawning in, and falling through, the ground. --- rwengine/src/engine/GameWorld.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rwengine/src/engine/GameWorld.cpp b/rwengine/src/engine/GameWorld.cpp index ccf1f327..abfabd8d 100644 --- a/rwengine/src/engine/GameWorld.cpp +++ b/rwengine/src/engine/GameWorld.cpp @@ -864,6 +864,17 @@ VehicleObject* GameWorld::tryToSpawnVehicle(VehicleGenerator& gen) { /// @todo use zone information to decide vehicle id } + auto model = data->findModelInfo(id); + RW_ASSERT(model); + if (model) { + auto info = data->vehicleInfo.find(model->handling_); + if (info != data->vehicleInfo.end()) { + const auto& handling = info->second->handling; + position.z += + (handling.dimensions.z / 2.f) - handling.centerOfMass.z; + } + } + auto vehicle = createVehicle(id, position); vehicle->setHeading(gen.heading); vehicle->setLifetime(GameObject::TrafficLifetime);