Sprite render distance tweaks and optimisations

This commit is contained in:
Joshua Barretto 2019-08-20 11:03:49 +01:00
parent 245c9af2e8
commit 4ed21a2e59
2 changed files with 4 additions and 2 deletions

View File

@ -12,7 +12,7 @@ out vec4 tgt_color;
#include <sky.glsl>
#include <light.glsl>
const float RENDER_DIST = 128.0;
const float RENDER_DIST = 112.0;
const float FADE_DIST = 32.0;
void main() {

View File

@ -437,7 +437,9 @@ impl Terrain {
let chunk_center = pos.map2(Vec2::from(TerrainChunkSize::SIZE), |e, sz: u32| {
(e as f32 + 0.5) * sz as f32
});
if Vec2::from(focus_pos).distance(chunk_center) < SPRITE_RENDER_DISTANCE {
if Vec2::from(focus_pos).distance_squared(chunk_center)
< SPRITE_RENDER_DISTANCE * SPRITE_RENDER_DISTANCE
{
for (kind, instances) in &chunk.sprite_instances {
renderer.render_sprites(
&self.sprite_models[&kind],