From: Axel Isouard Date: Sun, 29 Jul 2012 08:59:40 +0000 (+0200) Subject: added light array lump loading, taking a look at QFusion to see how they make them... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=refs%2Fheads%2Fexidl%2FRBSP;p=xonotic%2Fdarkplaces.git added light array lump loading, taking a look at QFusion to see how they make them work --- diff --git a/model_brush.c b/model_brush.c index 558624be..6ae6c481 100644 --- a/model_brush.c +++ b/model_brush.c @@ -8864,6 +8864,26 @@ static void Mod_JKBSP_LoadLightGrid(lump_t *l) } } +static void Mod_JKBSP_LoadLightarray(lump_t *l) +{ + int i, count; + short *in; + jkdlightgrid_t **out; + + in = ( void * )( mod_base + l->fileofs ); + if( l->filelen % sizeof( *in ) ) + Host_Error("Mod_JKBSP_LoadLightarray: funny lump size in %s", loadmodel->name ); + Con_Printf("lightarray = %d\n", l->filelen); + count = l->filelen / sizeof( *in ); + out = Mem_Alloc(loadmodel->mempool, count * sizeof( *out ) ); + + loadmodel->brushjk.data_lightarray = &out; + loadmodel->brushjk.num_lightarray = count; + + for( i = 0; i < count; i++, in++, out++ ) + *out = loadmodel->brushjk.data_lightgrid + LittleShort( *in ); +} + static void Mod_JKBSP_LoadPVS(lump_t *l) { jkdpvs_t *in; @@ -9554,6 +9574,7 @@ static void Mod_JKBSP_Load(dp_model_t *mod, void *buffer, void *bufferend) Mod_JKBSP_LoadNodes(&header->lumps[JKLUMP_NODES]); Mod_JKBSP_LoadLightGrid(&header->lumps[JKLUMP_LIGHTGRID]); Mod_JKBSP_LoadPVS(&header->lumps[JKLUMP_PVS]); + Mod_JKBSP_LoadLightarray(&header->lumps[JKLUMP_LIGHTARRAY]); loadmodel->brush.numsubmodels = loadmodel->brushjk.num_models; // the MakePortals code works fine on the q3bsp data as well diff --git a/model_brush.h b/model_brush.h index 025f2250..a519d5af 100644 --- a/model_brush.h +++ b/model_brush.h @@ -728,7 +728,8 @@ q3mbrushside_t; #define JKLUMP_LIGHTMAPS 14 // lightmap textures (used by faces) #define JKLUMP_LIGHTGRID 15 // lighting as a voxel grid (used by rendering) #define JKLUMP_PVS 16 // potentially visible set; bit[clusters][clusters] (used by rendering) -#define JKHEADER_LUMPS 17 +#define JKLUMP_LIGHTARRAY 17 +#define JKHEADER_LUMPS 18 typedef struct jkdheader_s { diff --git a/model_shared.h b/model_shared.h index 151c8128..b287c555 100644 --- a/model_shared.h +++ b/model_shared.h @@ -969,6 +969,8 @@ typedef struct model_brushjk_s // voxel light data with directional shading int num_lightgrid; jkdlightgrid_t *data_lightgrid; + int num_lightarray; + jkdlightgrid_t *data_lightarray; // size of each cell (may vary by map, typically 64 64 128) float num_lightgrid_cellsize[3]; // 1.0 / num_lightgrid_cellsize