medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit a45e611b0871cc707e16a1db2c9d77504476a0d7
parent 658623a3babaf9acded65a117353df12873ad471
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sun Dec 11 14:22:53 +0200

Make segment_vs_terrain collide segments instead of rays

Diffstat:
terrain_manager.cc | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/terrain_manager.cc b/terrain_manager.cc @@ -558,7 +558,9 @@ v3 terrain_normal( const TerrainManager * tm, v3 position ) { } bool segment_vs_terrain( const TerrainManager * tm, v3 seg_origin, v3 seg_end, float * t ) { + float segment_length = length( seg_end - seg_origin ); v3 ray_direction = normalize( seg_end - seg_origin ); + bool hit = false; // TODO: bresenhams vs top level @@ -581,7 +583,7 @@ bool segment_vs_terrain( const TerrainManager * tm, v3 seg_origin, v3 seg_end, f float tile_t; bool tile_hit = ray_vs_quadtree( qt, local_seg_origin, ray_direction, &tile_t ); - if( tile_hit && ( !hit || tile_t < *t ) ) { + if( tile_hit && ( !hit || tile_t < *t ) && tile_t <= segment_length ) { hit = true; *t = tile_t; }