medfall

A super great game engine
Log | Files | Refs

commit 146a8c45de7093a29bc50591eb1887d2a8781f79
parent 54bedac24a79a63697ad71008324fb6e09f2d559
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Wed, 21 Aug 2019 03:39:55 +0300

Load BSP map models

Diffstat:
Mbsp.cc | 1+
Mbsp.h | 11++++++++++-
Mbsp_renderer.cc | 6+++---
3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/bsp.cc b/bsp.cc @@ -77,6 +77,7 @@ void bsp_init( BSP * bsp, const char * filename ) { bsp->load_lump( bsp->num_leaves, bsp->leaves, LUMP_LEAVES ); bsp->load_lump( bsp->num_leaf_faces, bsp->leaf_faces, LUMP_LEAFFACES ); bsp->load_lump( bsp->num_leaf_brushes, bsp->leaf_brushes, LUMP_LEAFBRUSHES ); + bsp->load_lump( bsp->num_map_models, bsp->map_models, LUMP_MODELS ); bsp->load_lump( bsp->num_brushes, bsp->brushes, LUMP_BRUSHES ); bsp->load_lump( bsp->num_mesh_verts, bsp->mesh_verts, LUMP_MESHVERTS ); diff --git a/bsp.h b/bsp.h @@ -80,7 +80,13 @@ struct BSP_Leaf { typedef u32 BSP_LeafFace; typedef u32 BSP_LeafBrush; -// LUMP_MODELS +struct BSP_MapModel { + v3 mins, maxs; + s32 first_face; + s32 num_faces; + s32 first_brush; + s32 num_brushes; +}; struct BSP_Brush { u32 first_side; @@ -215,6 +221,9 @@ public: // TODO u32 num_leaf_brushes; BSP_LeafBrush * leaf_brushes; + u32 num_map_models; + BSP_MapModel * map_models; + u32 num_brushes; BSP_Brush * brushes; diff --git a/bsp_renderer.cc b/bsp_renderer.cc @@ -87,8 +87,8 @@ void bsp_to_mesh( const BSP * bsp, DynamicArray< VertexData > * verts, DynamicAr verts->add( v ); } - for( u32 f = 0; f < bsp->num_faces; f++ ) { - const BSP_Face & face = bsp->faces[ f ]; + for( s32 f = 0; f < bsp->map_models[ 0 ].num_faces; f++ ) { + const BSP_Face & face = bsp->faces[ bsp->map_models[ 0 ].first_face + f ]; v3 colour = bspr_face_colour( bsp, face ); // drop outlines @@ -109,7 +109,7 @@ void bsp_to_mesh( const BSP * bsp, DynamicArray< VertexData > * verts, DynamicAr void bspr_init( BSPRenderer * bspr, const BSP * bsp ) { bspr->bsp = bsp; - DynamicArray< VertexData > verts; + DynamicArray< VertexData > verts( bsp->num_vertices ); DynamicArray< u32 > indices; bsp_to_mesh( bsp, &verts, &indices );