mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-09 02:07:04 +08:00
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:
@@ -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
|
||||
Reference in New Issue
Block a user