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

Offset vehicle spawn height to account for dimensions

Should prevent vehicles spawning in, and falling through, the ground.
This commit is contained in:
Daniel Evans 2017-10-19 00:01:29 +01:00
parent 14ef8c2539
commit 43047269ab

View File

@ -864,6 +864,17 @@ VehicleObject* GameWorld::tryToSpawnVehicle(VehicleGenerator& gen) {
/// @todo use zone information to decide vehicle id
}
auto model = data->findModelInfo<VehicleModelInfo>(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);