mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-17 17:43:52 +00:00
Fix terrain collision by correcting spawn coordinates
- Spawn position changed to (-9080, -100, 100) which is on actual terrain - The terrain mesh uses WoW coordinates from ADT files directly - Camera/spawn position must use same coordinate system as terrain - Cleaned up getHeightAt comments to clarify coordinate system - Removed debug logging from WMO floor detection
This commit is contained in:
parent
a97ebfbc60
commit
a9dd685398
3 changed files with 18 additions and 12 deletions
|
|
@ -126,8 +126,9 @@ private:
|
||||||
static constexpr float WOW_GRAVITY = -19.29f;
|
static constexpr float WOW_GRAVITY = -19.29f;
|
||||||
static constexpr float WOW_JUMP_VELOCITY = 7.96f;
|
static constexpr float WOW_JUMP_VELOCITY = 7.96f;
|
||||||
|
|
||||||
// Default spawn position (on the road outside Stormwind)
|
// Default spawn position (on terrain near Stormwind)
|
||||||
glm::vec3 defaultPosition = glm::vec3(-8830.0f, -150.0f, 82.0f);
|
// Terrain chunks are around X=[-9100, -9066], Y=[-533, 0]
|
||||||
|
glm::vec3 defaultPosition = glm::vec3(-9080.0f, -100.0f, 100.0f);
|
||||||
float defaultYaw = 180.0f; // Look south toward Stormwind gate
|
float defaultYaw = 180.0f; // Look south toward Stormwind gate
|
||||||
float defaultPitch = -5.0f;
|
float defaultPitch = -5.0f;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -708,18 +708,25 @@ std::string TerrainManager::getADTPath(const TileCoord& coord) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<float> TerrainManager::getHeightAt(float glX, float glY) const {
|
std::optional<float> TerrainManager::getHeightAt(float glX, float glY) const {
|
||||||
// Terrain mesh vertices are positioned as:
|
// Terrain mesh vertices use chunk.position directly (WoW coordinates)
|
||||||
// vertex.position[0] = chunk.position[0] - (offsetY * unitSize) -> GL X
|
// But camera is in GL coordinates. We query using the mesh coordinates directly
|
||||||
// vertex.position[1] = chunk.position[1] - (offsetX * unitSize) -> GL Y
|
// since terrain is rendered without model transformation.
|
||||||
// vertex.position[2] = chunk.position[2] + height -> GL Z (height)
|
|
||||||
//
|
//
|
||||||
// The 9x9 outer vertex grid has offsetX, offsetY in [0, 8].
|
// The terrain mesh generation puts vertices at:
|
||||||
// So the chunk spans:
|
// vertex.position[0] = chunk.position[0] - (offsetY * unitSize)
|
||||||
|
// vertex.position[1] = chunk.position[1] - (offsetX * unitSize)
|
||||||
|
// vertex.position[2] = chunk.position[2] + height
|
||||||
|
//
|
||||||
|
// So chunk spans:
|
||||||
// X: [chunk.position[0] - 8*unitSize, chunk.position[0]]
|
// X: [chunk.position[0] - 8*unitSize, chunk.position[0]]
|
||||||
// Y: [chunk.position[1] - 8*unitSize, chunk.position[1]]
|
// Y: [chunk.position[1] - 8*unitSize, chunk.position[1]]
|
||||||
|
|
||||||
const float unitSize = CHUNK_SIZE / 8.0f;
|
const float unitSize = CHUNK_SIZE / 8.0f;
|
||||||
|
|
||||||
|
// Query coordinates are the same as what we pass (terrain uses identity model matrix)
|
||||||
|
float queryX = glX;
|
||||||
|
float queryY = glY;
|
||||||
|
|
||||||
for (const auto& [coord, tile] : loadedTiles) {
|
for (const auto& [coord, tile] : loadedTiles) {
|
||||||
if (!tile || !tile->loaded) continue;
|
if (!tile || !tile->loaded) continue;
|
||||||
|
|
||||||
|
|
@ -733,8 +740,8 @@ std::optional<float> TerrainManager::getHeightAt(float glX, float glY) const {
|
||||||
float chunkMaxY = chunk.position[1];
|
float chunkMaxY = chunk.position[1];
|
||||||
float chunkMinY = chunk.position[1] - 8.0f * unitSize;
|
float chunkMinY = chunk.position[1] - 8.0f * unitSize;
|
||||||
|
|
||||||
if (glX < chunkMinX || glX > chunkMaxX ||
|
if (queryX < chunkMinX || queryX > chunkMaxX ||
|
||||||
glY < chunkMinY || glY > chunkMaxY) {
|
queryY < chunkMinY || queryY > chunkMaxY) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -764,8 +764,6 @@ std::optional<float> WMORenderer::getFloorHeight(float glX, float glY, float glZ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// (debug logging removed)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bestFloor;
|
return bestFloor;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue