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:
parent
14ef8c2539
commit
43047269ab
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user