mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-22 02:12:45 +01:00
Boats have a different DFF structure
This commit is contained in:
parent
04ed374de8
commit
7743626acb
@ -156,25 +156,30 @@ VehicleObject::VehicleObject(GameWorld* engine, const glm::vec3& pos,
|
||||
setModel(getVehicle()->getModel());
|
||||
setClump(ClumpPtr(getModelInfo<VehicleModelInfo>()->getModel()->clone()));
|
||||
|
||||
const auto vehicleInfo = getModelInfo<VehicleModelInfo>();
|
||||
const auto isBoat = (vehicleInfo->vehicletype_ == VehicleModelInfo::BOAT);
|
||||
const std::string baseName = isBoat? "boat":"chassis";
|
||||
|
||||
// Locate the Atomics for the chassis_hi and chassis_vlo frames
|
||||
for (const auto& atomic : getClump()->getAtomics()) {
|
||||
auto frame = atomic->getFrame().get();
|
||||
if (frame->getName() == "chassis_vlo") {
|
||||
if (frame->getName() == baseName+"_vlo") {
|
||||
chassislow_ = atomic.get();
|
||||
}
|
||||
if (frame->getName() == "chassis_hi") {
|
||||
if (frame->getName() == baseName+"_hi") {
|
||||
chassishigh_ = atomic.get();
|
||||
}
|
||||
}
|
||||
|
||||
// Create meta-data for dummy parts
|
||||
auto chassisframe = getClump()->findFrame("chassis_dummy");
|
||||
RW_CHECK(chassisframe, "Vehicle has no chassis_dummy");
|
||||
for (auto& frame : chassisframe->getChildren()) {
|
||||
auto& name = frame->getName();
|
||||
bool isDum = name.find("_dummy") != name.npos;
|
||||
if (isDum) {
|
||||
registerPart(frame.get());
|
||||
auto dummy = getClump()->findFrame("chassis_dummy");
|
||||
if (dummy) {
|
||||
for (auto& frame : dummy->getChildren()) {
|
||||
auto& name = frame->getName();
|
||||
bool isDum = name.find("_dummy") != name.npos;
|
||||
if (isDum) {
|
||||
registerPart(frame.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -257,19 +257,17 @@ void ObjectRenderer::renderVehicle(VehicleObject* vehicle,
|
||||
}
|
||||
|
||||
float mindist = glm::length(vehicle->getPosition() - m_camera.position) / kVehicleDrawDistanceFactor;
|
||||
if (mindist < kVehicleLODDistance) {
|
||||
// Swich visibility to the high LOD
|
||||
vehicle->getHighLOD()->setFlag(Atomic::ATOMIC_RENDER, true);
|
||||
vehicle->getLowLOD()->setFlag(Atomic::ATOMIC_RENDER, false);
|
||||
} else if (mindist < kVehicleDrawDistance) {
|
||||
// Switch to low
|
||||
vehicle->getHighLOD()->setFlag(Atomic::ATOMIC_RENDER, false);
|
||||
vehicle->getLowLOD()->setFlag(Atomic::ATOMIC_RENDER, true);
|
||||
} else {
|
||||
if (mindist > kVehicleDrawDistance) {
|
||||
culled++;
|
||||
return;
|
||||
}
|
||||
|
||||
if (vehicle->getLowLOD() && vehicle->getHighLOD()) {
|
||||
const bool highLOD = mindist < kVehicleLODDistance;
|
||||
vehicle->getHighLOD()->setFlag(Atomic::ATOMIC_RENDER, highLOD);
|
||||
vehicle->getLowLOD()->setFlag(Atomic::ATOMIC_RENDER, !highLOD);
|
||||
}
|
||||
|
||||
renderClump(clump.get(), glm::mat4(), vehicle, outList);
|
||||
|
||||
auto modelinfo = vehicle->getVehicle();
|
||||
|
Loading…
Reference in New Issue
Block a user