Performance optimizations and collision improvements

Performance:
- Remove expensive inverse() from all vertex shaders (terrain, WMO, M2, water, character)
- Add uniform location caching to avoid repeated glGetUniformLocation calls
- Add proper frustum culling for WMO groups using AABB intersection
- Add distance-based culling for WMO and M2 instances
- Add cleanup of unused M2/WMO models when tiles unload

Collision & Movement:
- Add M2 doodad collision detection (fences, boxes, etc.)
- Reduce character eye height (5.0 -> 1.8) and collision radius (2.5 -> 0.5)
- Enable WoW-style movement speed by default (14 units/sec run, 5 walk, 9 back)
- Fix emote grammar ("You waves." -> "You wave.")

Misc:
- Rename window title to "Wowee"
This commit is contained in:
Kelsi 2026-02-02 23:03:45 -08:00
parent 0c85fcd444
commit 4287878a73
16 changed files with 258 additions and 32 deletions

View file

@ -72,7 +72,9 @@ bool CharacterRenderer::initialize() {
vec4 worldPos = uModel * skinnedPos;
FragPos = worldPos.xyz;
Normal = mat3(transpose(inverse(uModel * boneTransform))) * aNormal;
// Use mat3 directly - avoid expensive inverse() in shader
// Works correctly for uniform scaling; normalize in fragment shader handles the rest
Normal = mat3(uModel) * mat3(boneTransform) * aNormal;
TexCoord = aTexCoord;
gl_Position = uProjection * uView * worldPos;
@ -984,11 +986,10 @@ void CharacterRenderer::render(const Camera& camera, const glm::mat4& view, cons
: getModelMatrix(instance);
characterShader->setUniform("uModel", modelMat);
// Set bone matrices
// Set bone matrices (upload all at once for performance)
int numBones = std::min(static_cast<int>(instance.boneMatrices.size()), MAX_BONES);
for (int i = 0; i < numBones; i++) {
std::string uniformName = "uBones[" + std::to_string(i) + "]";
characterShader->setUniform(uniformName, instance.boneMatrices[i]);
if (numBones > 0) {
characterShader->setUniformMatrixArray("uBones[0]", instance.boneMatrices.data(), numBones);
}
// Bind VAO and draw