X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=model_brush.c;h=430de3fbbc06a06e607ead60a857e8cdbd325480;hb=f166f21fa69e9f10fc92217207fa51693dc1b411;hp=4cca197c43c502d12328c52f539cbebe0ba1e3a1;hpb=3c626a98c5ea3971a9a3a06d133c72f63c1386eb;p=xonotic%2Fdarkplaces.git diff --git a/model_brush.c b/model_brush.c index 4cca197c..430de3fb 100644 --- a/model_brush.c +++ b/model_brush.c @@ -28,6 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //cvar_t r_subdivide_size = {CVAR_SAVE, "r_subdivide_size", "128"}; cvar_t halflifebsp = {0, "halflifebsp", "0"}; +cvar_t mcbsp = {0, "mcbsp", "0"}; cvar_t r_novis = {0, "r_novis", "0"}; cvar_t r_miplightmaps = {CVAR_SAVE, "r_miplightmaps", "0"}; cvar_t r_lightmaprgba = {0, "r_lightmaprgba", "1"}; @@ -48,6 +49,7 @@ void Mod_BrushInit(void) { // Cvar_RegisterVariable(&r_subdivide_size); Cvar_RegisterVariable(&halflifebsp); + Cvar_RegisterVariable(&mcbsp); Cvar_RegisterVariable(&r_novis); Cvar_RegisterVariable(&r_miplightmaps); Cvar_RegisterVariable(&r_lightmaprgba); @@ -637,6 +639,13 @@ static void Mod_Q1BSP_TraceBox(struct model_s *model, int frame, trace_t *trace, VectorSubtract(boxstartmaxs, boxstartmins, boxsize); if (boxsize[0] < 3) rhc.hull = &model->brushq1.hulls[0]; // 0x0x0 + else if (model->brush.ismcbsp) + { + if (boxsize[2] < 48) // pick the nearest of 40 or 56 + rhc.hull = &model->brushq1.hulls[2]; // 16x16x40 + else + rhc.hull = &model->brushq1.hulls[1]; // 16x16x56 + } else if (model->brush.ishlbsp) { // LordHavoc: this has to have a minor tolerance (the .1) because of @@ -1328,6 +1337,11 @@ static void Mod_Q1BSP_LoadLighting(lump_t *l) for (i=0; ifilelen; i++) loadmodel->brushq1.lightdata[i] = mod_base[l->fileofs+i] >>= 1; } + else if (loadmodel->brush.ismcbsp) + { + loadmodel->brushq1.lightdata = Mem_Alloc(loadmodel->mempool, l->filelen); + memcpy(loadmodel->brushq1.lightdata, mod_base + l->fileofs, l->filelen); + } else // LordHavoc: bsp version 29 (normal white lighting) { // LordHavoc: hope is not lost yet, check for a .lit file to load @@ -2117,7 +2131,35 @@ static void Mod_Q1BSP_LoadClipnodes(lump_t *l) loadmodel->brushq1.clipnodes = out; loadmodel->brushq1.numclipnodes = count; - if (loadmodel->brush.ishlbsp) + if (loadmodel->brush.ismcbsp) + { + hull = &loadmodel->brushq1.hulls[1]; + hull->clipnodes = out; + hull->firstclipnode = 0; + hull->lastclipnode = count-1; + hull->planes = loadmodel->brush.data_planes; + hull->clip_mins[0] = -12; + hull->clip_mins[1] = -12; + hull->clip_mins[2] = -24; + hull->clip_maxs[0] = 12; + hull->clip_maxs[1] = 12; + hull->clip_maxs[2] = 32; + VectorSubtract(hull->clip_maxs, hull->clip_mins, hull->clip_size); + + hull = &loadmodel->brushq1.hulls[2]; + hull->clipnodes = out; + hull->firstclipnode = 0; + hull->lastclipnode = count-1; + hull->planes = loadmodel->brush.data_planes; + hull->clip_mins[0] = -12; + hull->clip_mins[1] = -12; + hull->clip_mins[2] = -24; + hull->clip_maxs[0] = 12; + hull->clip_maxs[1] = 12; + hull->clip_maxs[2] = 16; + VectorSubtract(hull->clip_maxs, hull->clip_mins, hull->clip_size); + } + else if (loadmodel->brush.ishlbsp) { hull = &loadmodel->brushq1.hulls[1]; hull->clipnodes = out; @@ -2885,7 +2927,16 @@ static void Mod_Q1BSP_RoundUpToHullSize(model_t *cmodel, const vec3_t inmins, co const hull_t *hull; VectorSubtract(inmaxs, inmins, size); - if (cmodel->brush.ishlbsp) + if (cmodel->brush.ismcbsp) + { + if (size[0] < 3) + hull = &cmodel->brushq1.hulls[0]; // 0x0x0 + else if (size[2] < 48) // pick the nearest of 40 or 56 + hull = &cmodel->brushq1.hulls[2]; // 16x16x40 + else + hull = &cmodel->brushq1.hulls[1]; // 16x16x56 + } + else if (cmodel->brush.ishlbsp) { if (size[0] < 3) hull = &cmodel->brushq1.hulls[0]; // 0x0x0 @@ -2912,11 +2963,6 @@ static void Mod_Q1BSP_RoundUpToHullSize(model_t *cmodel, const vec3_t inmins, co VectorAdd(inmins, hull->clip_size, outmaxs); } -extern void R_Q1BSP_DrawSky(entity_render_t *ent); -extern void R_Q1BSP_Draw(entity_render_t *ent); -extern void R_Q1BSP_GetLightInfo(entity_render_t *ent, vec3_t relativelightorigin, float lightradius, vec3_t outmins, vec3_t outmaxs, int *outleaflist, qbyte *outleafpvs, int *outnumleafspointer, int *outsurfacelist, qbyte *outsurfacepvs, int *outnumsurfacespointer); -extern void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, float lightradius, int numsurfaces, const int *surfacelist, const vec3_t lightmins, const vec3_t lightmaxs); -extern void R_Q1BSP_DrawLight(entity_render_t *ent, float *lightcolor, int numsurfaces, const int *surfacelist); void Mod_Q1BSP_Load(model_t *mod, void *buffer, void *bufferend) { int i, j, k; @@ -2929,12 +2975,25 @@ void Mod_Q1BSP_Load(model_t *mod, void *buffer, void *bufferend) mod->type = mod_brushq1; - header = (dheader_t *)buffer; + if (!memcmp(buffer, "MCBSP", 5)) + { + header = (dheader_t *)((unsigned char*)buffer + 5); - i = LittleLong(header->version); - if (i != BSPVERSION && i != 30) - Host_Error("Mod_Q1BSP_Load: %s has wrong version number(%i should be %i(Quake) or 30(HalfLife))", mod->name, i, BSPVERSION); - mod->brush.ishlbsp = i == 30; + i = LittleLong(header->version); + if (i != MCBSPVERSION) + Host_Error("Mod_Q1BSP_Load: %s has wrong version number(MCBSP %i should be %i", mod->name, i, MCBSPVERSION); + mod->brush.ismcbsp = true; + mod->brush.ishlbsp = false; + } + else + { + header = (dheader_t *)buffer; + + i = LittleLong(header->version); + if (i != BSPVERSION && i != 30) + Host_Error("Mod_Q1BSP_Load: %s has wrong version number(%i should be %i(Quake) or 30(HalfLife)", mod->name, i, BSPVERSION); + mod->brush.ishlbsp = i == 30; + } mod->soundfromcenter = true; mod->TraceBox = Mod_Q1BSP_TraceBox; @@ -2952,7 +3011,10 @@ void Mod_Q1BSP_Load(model_t *mod, void *buffer, void *bufferend) mod->brush.PointInLeaf = Mod_Q1BSP_PointInLeaf; if (loadmodel->isworldmodel) + { Cvar_SetValue("halflifebsp", mod->brush.ishlbsp); + Cvar_SetValue("mcbsp", mod->brush.ismcbsp); + } // swap all the lumps mod_base = (qbyte *)header; @@ -3093,6 +3155,7 @@ void Mod_Q1BSP_Load(model_t *mod, void *buffer, void *bufferend) mod->DrawSky = NULL; mod->Draw = R_Q1BSP_Draw; mod->GetLightInfo = R_Q1BSP_GetLightInfo; + mod->CompileShadowVolume = R_Q1BSP_CompileShadowVolume; mod->DrawShadowVolume = R_Q1BSP_DrawShadowVolume; mod->DrawLight = R_Q1BSP_DrawLight; if (i != 0) @@ -3554,8 +3617,12 @@ void static Mod_Q2BSP_Load(model_t *mod, void *buffer, void *bufferend) if (i != Q2BSPVERSION) Host_Error("Mod_Q2BSP_Load: %s has wrong version number (%i, should be %i)", mod->name, i, Q2BSPVERSION); mod->brush.ishlbsp = false; + mod->brush.ismcbsp = false; if (loadmodel->isworldmodel) + { Cvar_SetValue("halflifebsp", mod->brush.ishlbsp); + Cvar_SetValue("mcbsp", mod->brush.ismcbsp); + } mod_base = (qbyte *)header; @@ -5428,8 +5495,13 @@ void Mod_Q3BSP_Load(model_t *mod, void *buffer, void *bufferend) i = LittleLong(header->version); if (i != Q3BSPVERSION) Host_Error("Mod_Q3BSP_Load: %s has wrong version number (%i, should be %i)", mod->name, i, Q3BSPVERSION); - if (mod->isworldmodel) - Cvar_SetValue("halflifebsp", false); + mod->brush.ishlbsp = false; + mod->brush.ismcbsp = false; + if (loadmodel->isworldmodel) + { + Cvar_SetValue("halflifebsp", mod->brush.ishlbsp); + Cvar_SetValue("mcbsp", mod->brush.ismcbsp); + } mod->soundfromcenter = true; mod->TraceBox = Mod_Q3BSP_TraceBox; @@ -5445,6 +5517,7 @@ void Mod_Q3BSP_Load(model_t *mod, void *buffer, void *bufferend) mod->brush.PointInLeaf = Mod_Q1BSP_PointInLeaf; mod->Draw = R_Q1BSP_Draw; mod->GetLightInfo = R_Q1BSP_GetLightInfo; + mod->CompileShadowVolume = R_Q1BSP_CompileShadowVolume; mod->DrawShadowVolume = R_Q1BSP_DrawShadowVolume; mod->DrawLight = R_Q1BSP_DrawLight;