//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"};
{
// Cvar_RegisterVariable(&r_subdivide_size);
Cvar_RegisterVariable(&halflifebsp);
+ Cvar_RegisterVariable(&mcbsp);
Cvar_RegisterVariable(&r_novis);
Cvar_RegisterVariable(&r_miplightmaps);
Cvar_RegisterVariable(&r_lightmaprgba);
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
}
else
{
- if (!Mod_LoadSkinFrame(&tx->skin, tx->name, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false, tx->name[0] != '*', true))
+ if (!Mod_LoadSkinFrame(&tx->skin, tx->name, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false, true))
{
// did not find external texture, load it from the bsp or wad3
if (loadmodel->brush.ishlbsp)
Mem_Free(freepixels);
}
else if (mtdata) // texture included
- Mod_LoadSkinFrame_Internal(&tx->skin, tx->name, TEXF_MIPMAP | TEXF_PRECACHE | TEXF_PICMIP, false, tx->name[0] != '*', tx->name[0] != '*' && r_fullbrights.integer, mtdata, tx->width, tx->height);
+ Mod_LoadSkinFrame_Internal(&tx->skin, tx->name, TEXF_MIPMAP | TEXF_PRECACHE | TEXF_PICMIP, false, tx->name[0] != '*' && r_fullbrights.integer, mtdata, tx->width, tx->height);
}
}
if (tx->skin.base == NULL)
for (i=0; i<l->filelen; 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
// vertex limit
loadmodel->nummeshes = 1;
loadmodel->meshlist = Mem_Alloc(loadmodel->mempool, sizeof(surfmesh_t *));
- loadmodel->meshlist[0] = Mod_AllocSurfMesh(loadmodel->mempool, totalverts, totaltris, true, true, false, false);
+ loadmodel->meshlist[0] = Mod_AllocSurfMesh(loadmodel->mempool, totalverts, totaltris, true, false, false);
totalverts = 0;
totaltris = 0;
t = DotProduct(((surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex) + i * 3), surface->lightmapinfo->texinfo->vecs[1]) + surface->lightmapinfo->texinfo->vecs[1][3];
(surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex)[i * 2 + 0] = s / surface->texture->width;
(surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex)[i * 2 + 1] = t / surface->texture->height;
- (surface->groupmesh->data_texcoorddetail2f + 2 * surface->num_firstvertex)[i * 2 + 0] = s * (1.0f / 16.0f);
- (surface->groupmesh->data_texcoorddetail2f + 2 * surface->num_firstvertex)[i * 2 + 1] = t * (1.0f / 16.0f);
(surface->groupmesh->data_texcoordlightmap2f + 2 * surface->num_firstvertex)[i * 2 + 0] = 0;
(surface->groupmesh->data_texcoordlightmap2f + 2 * surface->num_firstvertex)[i * 2 + 1] = 0;
(surface->groupmesh->data_lightmapoffsets + surface->num_firstvertex)[i] = 0;
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;
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
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 Mod_Q1BSP_Load(model_t *mod, void *buffer, void *bufferend)
{
int i, j, k;
dheader_t *header;
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 != 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;
+ 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;
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;
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)
*/
}
-void static Mod_Q2BSP_Load(model_t *mod, void *buffer)
+void static Mod_Q2BSP_Load(model_t *mod, void *buffer, void *bufferend)
{
int i;
q2dheader_t *header;
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;
//if (R_TextureHasAlpha(out->skin.base))
// out->surfaceparms |= Q3SURFACEPARM_TRANS;
}
- if (!Mod_LoadSkinFrame(&out->skin, out->name, (((out->textureflags & Q3TEXTUREFLAG_NOMIPMAPS) || (out->surfaceparms & Q3SURFACEPARM_NOMIPMAPS)) ? 0 : TEXF_MIPMAP) | TEXF_ALPHA | TEXF_PRECACHE | (out->textureflags & Q3TEXTUREFLAG_NOPICMIP ? 0 : TEXF_PICMIP), false, false, true))
- if (!Mod_LoadSkinFrame(&out->skin, out->firstpasstexturename, (((out->textureflags & Q3TEXTUREFLAG_NOMIPMAPS) || (out->surfaceparms & Q3SURFACEPARM_NOMIPMAPS)) ? 0 : TEXF_MIPMAP) | TEXF_ALPHA | TEXF_PRECACHE | (out->textureflags & Q3TEXTUREFLAG_NOPICMIP ? 0 : TEXF_PICMIP), false, false, true))
+ if (!Mod_LoadSkinFrame(&out->skin, out->name, (((out->textureflags & Q3TEXTUREFLAG_NOMIPMAPS) || (out->surfaceparms & Q3SURFACEPARM_NOMIPMAPS)) ? 0 : TEXF_MIPMAP) | TEXF_ALPHA | TEXF_PRECACHE | (out->textureflags & Q3TEXTUREFLAG_NOPICMIP ? 0 : TEXF_PICMIP), false, true))
+ if (!Mod_LoadSkinFrame(&out->skin, out->firstpasstexturename, (((out->textureflags & Q3TEXTUREFLAG_NOMIPMAPS) || (out->surfaceparms & Q3SURFACEPARM_NOMIPMAPS)) ? 0 : TEXF_MIPMAP) | TEXF_ALPHA | TEXF_PRECACHE | (out->textureflags & Q3TEXTUREFLAG_NOPICMIP ? 0 : TEXF_PICMIP), false, true))
if (cls.state != ca_dedicated)
Con_Printf("%s: texture loading for shader \"%s\" failed (first layer \"%s\" not found either)\n", loadmodel->name, out->name, out->firstpasstexturename);
// no animation
{
strlcpy (out->shadername, in->shadername, sizeof (out->shadername));
n = LittleLong(in->brushindex);
- if (n < 0 || n >= loadmodel->brush.num_brushes)
- Host_Error("Mod_Q3BSP_LoadEffects: invalid brushindex %i (%i brushes)\n", n, loadmodel->brush.num_brushes);
+ if (n >= loadmodel->brush.num_brushes)
+ {
+ Con_Printf("Mod_Q3BSP_LoadEffects: invalid brushindex %i (%i brushes), setting to -1\n", n, loadmodel->brush.num_brushes);
+ n = -1;
+ }
out->brushindex = n;
out->unknown = LittleLong(in->unknown);
}
i = oldi;
in = oldin;
out = oldout;
- mesh = tempmeshlist[meshnum] = Mod_AllocSurfMesh(loadmodel->mempool, meshvertices, meshtriangles, false, false, true, false);
+ mesh = tempmeshlist[meshnum] = Mod_AllocSurfMesh(loadmodel->mempool, meshvertices, meshtriangles, false, true, false);
meshvertices = 0;
meshtriangles = 0;
for (;i < count && meshvertices + out->num_vertices <= mesh->num_vertices;i++, in++, out++)
loadmodel->brush.num_leafs = numleafs;
}
-void Mod_Q3BSP_Load(model_t *mod, void *buffer)
+void Mod_Q3BSP_Load(model_t *mod, void *buffer, void *bufferend)
{
int i, j, numshadowmeshtriangles;
q3dheader_t *header;
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;
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;
}
}
-void Mod_IBSP_Load(model_t *mod, void *buffer)
+void Mod_IBSP_Load(model_t *mod, void *buffer, void *bufferend)
{
int i = LittleLong(((int *)buffer)[1]);
if (i == Q3BSPVERSION)
- Mod_Q3BSP_Load(mod,buffer);
+ Mod_Q3BSP_Load(mod,buffer, bufferend);
else if (i == Q2BSPVERSION)
- Mod_Q2BSP_Load(mod,buffer);
+ Mod_Q2BSP_Load(mod,buffer, bufferend);
else
Host_Error("Mod_IBSP_Load: unknown/unsupported version %i\n", i);
}
-void Mod_MAP_Load(model_t *mod, void *buffer)
+void Mod_MAP_Load(model_t *mod, void *buffer, void *bufferend)
{
Host_Error("Mod_MAP_Load: not yet implemented\n");
}