rodecomp/Source/Contents/World/WorldGroundImport.cpp
ragnarok-clanker a47d20f8be Reconstruct readable C++ and organize cohesive source subsystems
Administrative source import: native x86 compilation passed for 423 authored units. Source placement and submission states are migrated separately; this commit does not imply peer acceptance.

Previous head: 35d2a8cb36
Payload SHA256: 592f016d2730c5593bb653aa054c1e5f76a6df72c8f5a09e66f74876e2e33dee
2026-10-25 07:42:41 +00:00

55 lines
1.7 KiB
C++

#include "Client/Application/ErrorDialog.h"
#include "Contents/Ground/GroundGeometry.h"
#include "Contents/World/WorldGroundImport.h"
#include "Resource/World/GroundResource.h"
#include "Resource/ResourceMgr.h"
#include "Resource/World/TerrainResource.h"
#include "Resource/World/WorldResource.h"
#include "Utility/Math/ScalarConversion.h"
bool ImportWorldGround(
const C3dWorldRes& world, ResourceMgr& resources, TextureCache& textures, CRenderSystemBase* renderSystem, C3dAttr*& terrain, GroundGeometry*& ground,
int& nearbyRange, const float* lightDirection, const float* diffuse, const float* ambient
) {
if (world.terrainName.empty()) {
ShowErrorDialog(renderSystem, "attr ", 0);
return false;
}
terrain = static_cast<C3dAttr*>(resources.Load(world.terrainName.c_str()));
if (!terrain) {
ShowErrorDialog(renderSystem, "attr ", 0);
return false;
}
terrain->cellSize = 5;
nearbyRange *= terrain->cellSize;
if (world.groundName.empty()) {
ShowErrorDialog(renderSystem, "gnd ", 0);
return false;
}
auto* resource = static_cast<CGndRes*>(resources.Load(world.groundName.c_str()));
if (!resource) {
ShowErrorDialog(renderSystem, "ground", 0);
return false;
}
if (!resource->loaded) {
ShowErrorDialog(renderSystem, "", 0);
return false;
}
ground = new GroundGeometry;
ground->Build(*resource, textures, lightDirection, diffuse, ambient);
const int pitch = TruncateToInt(world.waveSpeed);
const int phase = TruncateToInt(world.wavePitch);
ground->water.Set(world.waterLevel, world.waterType, world.waterAnimation, pitch, phase, world.waveHeight);
ground->water.Import(*resource, textures);
resources.Remove(resource);
return true;
}