mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-03 00:03:50 +00:00
Implement comprehensive taxi flight optimizations and proper spline paths
Major improvements: - Load TaxiPathNode.dbc for actual curved flight paths (no more flying through terrain) - Add 3-second mounting delay with terrain precaching for entire route - Implement LOD system for M2 models with distance-based quality reduction - Add circular terrain loading pattern (13 tiles vs 25, 48% reduction) - Increase terrain cache from 2GB to 8GB for modern systems Performance optimizations during taxi: - Cull small M2 models (boundRadius < 3.0) - not visible from altitude - Disable particle systems (weather, smoke, M2 emitters) - saves ~7000 particles - Disable specular lighting on M2 models - saves Blinn-Phong calculations - Disable shadow mapping on M2 models - saves shadow map sampling and PCF Technical details: - Parse TaxiPathNode.dbc spline waypoints for curved paths around terrain - Build full path from node pairs using TaxiPathEdge lookup - Precache callback triggers during mounting delay for smooth takeoff - Circular tile loading uses Euclidean distance check (dx²+dy² <= r²) - LOD fallback to base mesh when higher LODs unavailable Result: Buttery smooth taxi flights with no terrain clipping or performance hitches
This commit is contained in:
parent
b1104d1e3d
commit
d7d6fe9810
9 changed files with 249 additions and 32 deletions
|
|
@ -1084,6 +1084,9 @@ bool M2Renderer::loadModel(const pipeline::M2Model& model, uint32_t modelId) {
|
|||
bgpu.materialFlags = model.materials[batch.materialIndex].flags;
|
||||
}
|
||||
|
||||
// Copy LOD level from batch
|
||||
bgpu.submeshLevel = batch.submeshLevel;
|
||||
|
||||
// Resolve texture: batch.textureIndex → textureLookup → allTextures
|
||||
GLuint tex = whiteTexture;
|
||||
if (batch.textureIndex < model.textureLookup.size()) {
|
||||
|
|
@ -1621,15 +1624,17 @@ void M2Renderer::render(const Camera& camera, const glm::mat4& view, const glm::
|
|||
shader->setUniform("uProjection", projection);
|
||||
shader->setUniform("uLightDir", lightDir);
|
||||
shader->setUniform("uLightColor", glm::vec3(1.5f, 1.4f, 1.3f));
|
||||
shader->setUniform("uSpecularIntensity", 0.5f);
|
||||
shader->setUniform("uSpecularIntensity", onTaxi_ ? 0.0f : 0.5f); // Disable specular during taxi for performance
|
||||
shader->setUniform("uAmbientColor", ambientColor);
|
||||
shader->setUniform("uViewPos", camera.getPosition());
|
||||
shader->setUniform("uFogColor", fogColor);
|
||||
shader->setUniform("uFogStart", fogStart);
|
||||
shader->setUniform("uFogEnd", fogEnd);
|
||||
shader->setUniform("uShadowEnabled", shadowEnabled ? 1 : 0);
|
||||
// Disable shadows during taxi for better performance
|
||||
bool useShadows = shadowEnabled && !onTaxi_;
|
||||
shader->setUniform("uShadowEnabled", useShadows ? 1 : 0);
|
||||
shader->setUniform("uShadowStrength", 0.65f);
|
||||
if (shadowEnabled) {
|
||||
if (useShadows) {
|
||||
shader->setUniform("uLightSpaceMatrix", lightSpaceMatrix);
|
||||
glActiveTexture(GL_TEXTURE7);
|
||||
glBindTexture(GL_TEXTURE_2D, shadowDepthTex);
|
||||
|
|
@ -1708,6 +1713,12 @@ void M2Renderer::render(const Camera& camera, const glm::mat4& view, const glm::
|
|||
|
||||
const M2ModelGPU& model = *currentModel;
|
||||
|
||||
// Skip small models when on taxi (performance optimization)
|
||||
// Small props/foliage aren't visible from flight altitude anyway
|
||||
if (onTaxi_ && model.boundRadius < 3.0f) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Distance-based fade alpha for smooth pop-in (squared-distance, no sqrt)
|
||||
float fadeAlpha = 1.0f;
|
||||
float fadeFrac = model.disableAnimation ? 0.55f : fadeStartFraction;
|
||||
|
|
@ -1734,20 +1745,35 @@ void M2Renderer::render(const Camera& camera, const glm::mat4& view, const glm::
|
|||
glDepthMask(GL_FALSE);
|
||||
}
|
||||
|
||||
// LOD selection based on distance (WoW retail behavior)
|
||||
// submeshLevel: 0=base detail, 1=LOD1, 2=LOD2, 3=LOD3
|
||||
float dist = std::sqrt(entry.distSq);
|
||||
uint16_t desiredLOD = 0;
|
||||
if (dist > 150.0f) desiredLOD = 3; // Far: LOD3 (lowest detail)
|
||||
else if (dist > 80.0f) desiredLOD = 2; // Medium-far: LOD2
|
||||
else if (dist > 40.0f) desiredLOD = 1; // Medium: LOD1
|
||||
// else desiredLOD = 0 (close: base detail)
|
||||
|
||||
// Check if model has the desired LOD level; if not, fall back to LOD 0
|
||||
uint16_t targetLOD = desiredLOD;
|
||||
if (desiredLOD > 0) {
|
||||
bool hasDesiredLOD = false;
|
||||
for (const auto& b : model.batches) {
|
||||
if (b.submeshLevel == desiredLOD) {
|
||||
hasDesiredLOD = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasDesiredLOD) {
|
||||
targetLOD = 0; // Fall back to base LOD
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& batch : model.batches) {
|
||||
if (batch.indexCount == 0) continue;
|
||||
|
||||
// LOD selection based on distance (WoW retail behavior)
|
||||
// submeshLevel: 0=base detail, 1=LOD1, 2=LOD2, 3=LOD3
|
||||
float dist = std::sqrt(entry.distSq);
|
||||
uint16_t desiredLOD = 0;
|
||||
if (dist > 150.0f) desiredLOD = 3; // Far: LOD3 (lowest detail)
|
||||
else if (dist > 80.0f) desiredLOD = 2; // Medium-far: LOD2
|
||||
else if (dist > 40.0f) desiredLOD = 1; // Medium: LOD1
|
||||
// else desiredLOD = 0 (close: base detail)
|
||||
|
||||
// Skip batches that don't match desired LOD level
|
||||
if (batch.submeshLevel != desiredLOD) continue;
|
||||
// Skip batches that don't match target LOD level
|
||||
if (batch.submeshLevel != targetLOD) continue;
|
||||
|
||||
// Additive/mod batches (glow halos, light effects): collect as glow sprites
|
||||
// instead of rendering the mesh geometry which appears as flat orange disks.
|
||||
|
|
|
|||
|
|
@ -1552,7 +1552,9 @@ void Renderer::renderWorld(game::World* world) {
|
|||
}
|
||||
|
||||
// Render weather particles (after terrain/water, before characters)
|
||||
if (weather && camera) {
|
||||
// Skip during taxi flights for performance and visual clarity
|
||||
bool onTaxi = cameraController && cameraController->isOnTaxi();
|
||||
if (weather && camera && !onTaxi) {
|
||||
weather->render(*camera);
|
||||
}
|
||||
|
||||
|
|
@ -1586,11 +1588,15 @@ void Renderer::renderWorld(game::World* world) {
|
|||
// Dim M2 lighting when player is inside a WMO
|
||||
if (cameraController) {
|
||||
m2Renderer->setInsideInterior(cameraController->isInsideWMO());
|
||||
m2Renderer->setOnTaxi(cameraController->isOnTaxi());
|
||||
}
|
||||
auto m2Start = std::chrono::steady_clock::now();
|
||||
m2Renderer->render(*camera, view, projection);
|
||||
m2Renderer->renderSmokeParticles(*camera, view, projection);
|
||||
m2Renderer->renderM2Particles(view, projection);
|
||||
// Skip particle fog during taxi (expensive and visually distracting)
|
||||
if (!onTaxi) {
|
||||
m2Renderer->renderSmokeParticles(*camera, view, projection);
|
||||
m2Renderer->renderM2Particles(view, projection);
|
||||
}
|
||||
auto m2End = std::chrono::steady_clock::now();
|
||||
lastM2RenderMs = std::chrono::duration<double, std::milli>(m2End - m2Start).count();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1161,6 +1161,11 @@ void TerrainManager::streamTiles() {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Circular pattern: skip corner tiles beyond radius (Euclidean distance)
|
||||
if (dx*dx + dy*dy > loadRadius*loadRadius) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TileCoord coord = {tileX, tileY};
|
||||
|
||||
// Skip if already loaded, pending, or failed
|
||||
|
|
@ -1183,11 +1188,11 @@ void TerrainManager::streamTiles() {
|
|||
for (const auto& pair : loadedTiles) {
|
||||
const TileCoord& coord = pair.first;
|
||||
|
||||
int dx = std::abs(coord.x - currentTile.x);
|
||||
int dy = std::abs(coord.y - currentTile.y);
|
||||
int dx = coord.x - currentTile.x;
|
||||
int dy = coord.y - currentTile.y;
|
||||
|
||||
// Chebyshev distance
|
||||
if (dx > unloadRadius || dy > unloadRadius) {
|
||||
// Circular pattern: unload beyond radius (Euclidean distance)
|
||||
if (dx*dx + dy*dy > unloadRadius*unloadRadius) {
|
||||
tilesToUnload.push_back(coord);
|
||||
}
|
||||
}
|
||||
|
|
@ -1210,5 +1215,24 @@ void TerrainManager::streamTiles() {
|
|||
}
|
||||
}
|
||||
|
||||
void TerrainManager::precacheTiles(const std::vector<std::pair<int, int>>& tiles) {
|
||||
std::lock_guard<std::mutex> lock(queueMutex);
|
||||
|
||||
for (const auto& [x, y] : tiles) {
|
||||
TileCoord coord = {x, y};
|
||||
|
||||
// Skip if already loaded, pending, or failed
|
||||
if (loadedTiles.find(coord) != loadedTiles.end()) continue;
|
||||
if (pendingTiles.find(coord) != pendingTiles.end()) continue;
|
||||
if (failedTiles.find(coord) != failedTiles.end()) continue;
|
||||
|
||||
loadQueue.push(coord);
|
||||
pendingTiles[coord] = true;
|
||||
}
|
||||
|
||||
// Notify workers to start loading
|
||||
queueCV.notify_all();
|
||||
}
|
||||
|
||||
} // namespace rendering
|
||||
} // namespace wowee
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue