perf(world): cull distant players from updates and rendering

Add distance2 utility function. On client, skip rendering other players if distance squared exceeds rendering distance. On server, only send player position and block change updates to players in relevant chunks.
This commit is contained in:
2026-06-30 17:41:12 +08:00
parent 9fc94c56b5
commit b24ce458dc
3 changed files with 32 additions and 6 deletions

View File

@@ -14,6 +14,11 @@ bool is_aabb_in_frustum(const glm::vec3& center, const glm::vec3& half_extents,
float deterministic_random(int x, int z, uint64_t seed);
glm::vec3 slerp(const glm::vec3& from, const glm::vec3& to, float t);
inline float distance2(const glm::vec3& a, const glm::vec3& b) {
glm::vec3 diff = a - b;
return glm::dot(diff, diff);
}
} // namespace Math
} // namespace Cubed