medfall

A super great game engine
Log | Files | Refs

heightmap.h (860B)


      1 #pragma once
      2 
      3 #include <float.h>
      4 
      5 #include "intrinsics.h"
      6 #include "memory_arena.h"
      7 #include "array.h"
      8 #include "linear_algebra.h"
      9 
     10 struct QuadTreeNode {
     11 	u16 min_z, max_z;
     12 };
     13 
     14 struct QuadTree {
     15 	array< QuadTreeNode > nodes;
     16 	array2d< u16 > heightmap;
     17 };
     18 
     19 float heightmap_height( const array2d< u16 > hm, u32 x, u32 y );
     20 u16 heightmap_height_u16( const array2d< u16 > hm, u32 x, u32 y );
     21 v3 heightmap_point( const array2d< u16 > hm, u32 x, u32 y );
     22 
     23 bool ray_vs_quadtree( const QuadTree & qt, const Ray3 & ray, float * t, v3 * xnormal, float max_dist = FLT_MAX );
     24 bool ray_vs_terrain( const QuadTree & qt, const Ray3 & ray, float * t, v3 * xnormal, float max_dist = FLT_MAX );
     25 bool segment_vs_terrain( const QuadTree & qt, const v3 & start, const v3 & end, float * t, v3 * xnormal );
     26 
     27 void bc5_to_heightmap( MemoryArena * arena, array2d< u16 > hm, u8 * bc5 );