#include "wad.h"
-// note: model_shared.c sets up r_notexture, and r_surf_notexture
-
qbyte mod_q1bsp_novis[(MAX_MAP_LEAFS + 7)/ 8];
//cvar_t r_subdivide_size = {CVAR_SAVE, "r_subdivide_size", "128"};
{
int clusterindex, side, nodestackindex = 0;
mnode_t *node, *nodestack[1024];
- node = model->brush.data_nodes + model->brushq1.hulls[0].firstclipnode;
+ if (!model->brush.num_pvsclusters)
+ return true;
+ node = model->brush.data_nodes;
for (;;)
{
if (node->plane)
return false;
}
+static int Mod_Q1BSP_BoxTouchingVisibleLeafs(model_t *model, const qbyte *visibleleafs, const vec3_t mins, const vec3_t maxs)
+{
+ int side, nodestackindex = 0;
+ mnode_t *node, *nodestack[1024];
+ node = model->brush.data_nodes;
+ for (;;)
+ {
+ if (node->plane)
+ {
+ // node - recurse down the BSP tree
+ side = BoxOnPlaneSide(mins, maxs, node->plane) - 1;
+ if (side < 2)
+ {
+ // box is on one side of plane, take that path
+ node = node->children[side];
+ }
+ else
+ {
+ // box crosses plane, take one path and remember the other
+ if (nodestackindex < 1024)
+ nodestack[nodestackindex++] = node->children[0];
+ node = node->children[1];
+ }
+ }
+ else
+ {
+ // leaf - check if it is visible
+ if (visibleleafs[(mleaf_t *)node - model->brush.data_leafs])
+ {
+ // it is visible, return immediately with the news
+ return true;
+ }
+ else
+ {
+ // nothing to see here, try another path we didn't take earlier
+ if (nodestackindex == 0)
+ break;
+ node = nodestack[--nodestackindex];
+ }
+ }
+ }
+ // it is not visible
+ return false;
+}
+
typedef struct findnonsolidlocationinfo_s
{
vec3_t center;
}
findnonsolidlocationinfo_t;
-#if 0
-extern cvar_t samelevel;
-#endif
static void Mod_Q1BSP_FindNonSolidLocation_r_Leaf(findnonsolidlocationinfo_t *info, mleaf_t *leaf)
{
int i, surfacenum, k, *tri, *mark;
float dist, f, vert[3][3], edge[3][3], facenormal[3], edgenormal[3][3], point[3];
-#if 0
- float surfnormal[3];
-#endif
msurface_t *surface;
for (surfacenum = 0, mark = leaf->firstleafsurface;surfacenum < leaf->numleafsurfaces;surfacenum++, mark++)
{
surface = info->model->brush.data_surfaces + *mark;
- if (surface->flags & SURF_SOLIDCLIP)
+ if (surface->texture->supercontents & SUPERCONTENTS_SOLID)
{
-#if 0
- VectorCopy(surface->plane->normal, surfnormal);
- if (surface->flags & SURF_PLANEBACK)
- VectorNegate(surfnormal, surfnormal);
-#endif
for (k = 0;k < surface->mesh.num_triangles;k++)
{
tri = surface->mesh.data_element3i + k * 3;
if (facenormal[0] || facenormal[1] || facenormal[2])
{
VectorNormalize(facenormal);
-#if 0
- if (VectorDistance(facenormal, surfnormal) > 0.01f)
- Con_Printf("a2! %f %f %f != %f %f %f\n", facenormal[0], facenormal[1], facenormal[2], surfnormal[0], surfnormal[1], surfnormal[2]);
-#endif
f = DotProduct(info->center, facenormal) - DotProduct(vert[0], facenormal);
if (f <= info->bestdist && f >= -info->bestdist)
{
CrossProduct(facenormal, edge[0], edgenormal[0]);
CrossProduct(facenormal, edge[1], edgenormal[1]);
CrossProduct(facenormal, edge[2], edgenormal[2]);
-#if 0
- if (samelevel.integer & 1)
- VectorNegate(edgenormal[0], edgenormal[0]);
- if (samelevel.integer & 2)
- VectorNegate(edgenormal[1], edgenormal[1]);
- if (samelevel.integer & 4)
- VectorNegate(edgenormal[2], edgenormal[2]);
- for (i = 0;i < 3;i++)
- if (DotProduct(vert[0], edgenormal[i]) > DotProduct(vert[i], edgenormal[i]) + 0.1f
- || DotProduct(vert[1], edgenormal[i]) > DotProduct(vert[i], edgenormal[i]) + 0.1f
- || DotProduct(vert[2], edgenormal[i]) > DotProduct(vert[i], edgenormal[i]) + 0.1f)
- Con_Printf("a! %i : %f %f %f (%f %f %f)\n", i, edgenormal[i][0], edgenormal[i][1], edgenormal[i][2], facenormal[0], facenormal[1], facenormal[2]);
-#endif
// face distance
if (DotProduct(info->center, edgenormal[0]) < DotProduct(vert[0], edgenormal[0])
&& DotProduct(info->center, edgenormal[1]) < DotProduct(vert[1], edgenormal[1])
surface = r_refdef.worldmodel->brush.data_surfaces + node->firstsurface;
for (i = 0;i < node->numsurfaces;i++, surface++)
{
- if (!(surface->texture->flags & SURF_LIGHTMAP) || !surface->samples)
+ if (!(surface->texture->basematerialflags & MATERIALFLAG_WALL) || !surface->samples)
continue; // no lightmaps
ds = (int) (x * surface->texinfo->vecs[0][0] + y * surface->texinfo->vecs[0][1] + mid * surface->texinfo->vecs[0][2] + surface->texinfo->vecs[0][3]) - surface->texturemins[0];
strcpy(tx->name, "NO TEXTURE FOUND");
tx->width = 16;
tx->height = 16;
- tx->skin.base = r_notexture;
+ tx->skin.base = r_texture_notexture;
if (i == loadmodel->brush.num_textures - 1)
- tx->flags = SURF_DRAWTURB | SURF_LIGHTBOTHSIDES;
+ {
+ tx->basematerialflags |= MATERIALFLAG_WATER | MATERIALFLAG_LIGHTBOTHSIDES;
+ tx->supercontents = SUPERCONTENTS_WATER;
+ }
else
- tx->flags = SURF_LIGHTMAP | SURF_SOLIDCLIP;
+ {
+ tx->basematerialflags |= MATERIALFLAG_WALL;
+ tx->supercontents = SUPERCONTENTS_SOLID;
+ }
+ tx->basematerialflags = 0;
tx->currentframe = tx;
}
}
else
{
- if (!Mod_LoadSkinFrame(&tx->skin, tx->name, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false, true, true))
+ if (!Mod_LoadSkinFrame(&tx->skin, tx->name, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false, tx->name[0] != '*', 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, true, 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] != '*', tx->name[0] != '*' && r_fullbrights.integer, mtdata, tx->width, tx->height);
}
}
if (tx->skin.base == NULL)
// no texture found
tx->width = 16;
tx->height = 16;
- tx->skin.base = r_notexture;
+ tx->skin.base = r_texture_notexture;
}
+ tx->basematerialflags = 0;
if (tx->name[0] == '*')
{
// turb does not block movement
- tx->flags = SURF_DRAWTURB | SURF_LIGHTBOTHSIDES;
+ tx->basematerialflags |= MATERIALFLAG_WATER | MATERIALFLAG_LIGHTBOTHSIDES;
// LordHavoc: some turbulent textures should be fullbright and solid
if (!strncmp(tx->name,"*lava",5)
|| !strncmp(tx->name,"*teleport",9)
|| !strncmp(tx->name,"*rift",5)) // Scourge of Armagon texture
- tx->flags |= SURF_DRAWFULLBRIGHT | SURF_DRAWNOALPHA;
+ tx->basematerialflags |= MATERIALFLAG_FULLBRIGHT;
else
- tx->flags |= SURF_WATERALPHA;
+ tx->basematerialflags |= MATERIALFLAG_WATERALPHA;
+ if (!strncmp(tx->name, "*lava", 5))
+ tx->supercontents = SUPERCONTENTS_LAVA;
+ else if (!strncmp(tx->name, "*slime", 6))
+ tx->supercontents = SUPERCONTENTS_SLIME;
+ else
+ tx->supercontents = SUPERCONTENTS_WATER;
}
else if (tx->name[0] == 's' && tx->name[1] == 'k' && tx->name[2] == 'y')
- tx->flags = SURF_DRAWSKY | SURF_SOLIDCLIP;
+ {
+ tx->supercontents = SUPERCONTENTS_SKY;
+ tx->basematerialflags |= MATERIALFLAG_SKY;
+ }
else
- tx->flags = SURF_LIGHTMAP | SURF_SOLIDCLIP;
+ {
+ tx->supercontents = SUPERCONTENTS_SOLID;
+ tx->basematerialflags |= MATERIALFLAG_WALL;
+ }
+ if (tx->skin.fog)
+ tx->basematerialflags |= MATERIALFLAG_ALPHA | MATERIALFLAG_TRANSPARENT;
// start out with no animation
tx->currentframe = tx;
{
// if texture chosen is NULL or the shader needs a lightmap,
// force to notexture water shader
- if (out->texture == NULL || out->texture->flags & SURF_LIGHTMAP)
+ if (out->texture == NULL || out->texture->basematerialflags & MATERIALFLAG_WALL)
out->texture = loadmodel->brush.data_textures + (loadmodel->brush.num_textures - 1);
}
else
Host_Error("Mod_Q1BSP_LoadFaces: invalid texinfo index %i(model has %i texinfos)\n", i, loadmodel->brushq1.numtexinfo);
surface->texinfo = loadmodel->brushq1.texinfo + i;
surface->texture = surface->texinfo->texture;
- surface->flags = surface->texture->flags;
planenum = LittleShort(in->planenum);
if ((unsigned int) planenum >= (unsigned int) loadmodel->brush.num_planes)
Host_Error("Mod_Q1BSP_LoadFaces: invalid plane index %i (model has %i planes)\n", planenum, loadmodel->brush.num_planes);
- if (LittleShort(in->side))
- surface->flags |= SURF_PLANEBACK;
-
- surface->plane = loadmodel->brush.data_planes + planenum;
+ //surface->flags = surface->texture->flags;
+ //if (LittleShort(in->side))
+ // surface->flags |= SURF_PLANEBACK;
+ //surface->plane = loadmodel->brush.data_planes + planenum;
surface->mesh.num_vertices = numedges;
surface->mesh.num_triangles = numedges - 2;
surface->lightmaptexture = NULL;
i = LittleLong(in->lightofs);
if (i == -1)
+ {
surface->samples = NULL;
+ // give non-lightmapped water a 1x white lightmap
+ if ((surface->texture->basematerialflags & MATERIALFLAG_WATER) && (surface->texinfo->flags & TEX_SPECIAL) && ssize <= 256 && tsize <= 256)
+ {
+ surface->samples = Mem_Alloc(loadmodel->mempool, ssize * tsize * 3);
+ surface->styles[0] = 0;
+ memset(surface->samples, 128, ssize * tsize * 3);
+ }
+ }
else if (loadmodel->brush.ishlbsp) // LordHavoc: HalfLife map (bsp version 30)
surface->samples = loadmodel->brushq1.lightdata + i;
else // LordHavoc: white lighting (bsp version 29)
surface->samples = loadmodel->brushq1.lightdata + (i * 3);
- if (surface->texture->flags & SURF_LIGHTMAP)
+ if (!(surface->texinfo->flags & TEX_SPECIAL) || surface->samples)
{
+ int i, iu, iv;
+ float u, v, ubase, vbase, uscale, vscale;
+
if (ssize > 256 || tsize > 256)
Host_Error("Bad surface extents");
// stainmap for permanent marks on walls
surface->stainsamples = Mem_Alloc(loadmodel->mempool, ssize * tsize * 3);
// clear to white
memset(surface->stainsamples, 255, ssize * tsize * 3);
- }
-
- if (surface->texture->flags & SURF_LIGHTMAP)
- {
- int i, iu, iv;
- float u, v, ubase, vbase, uscale, vscale;
if (r_miplightmaps.integer)
{
}
}
-static void Mod_Q1BSP_SetParent(mnode_t *node, mnode_t *parent)
+static void Mod_Q1BSP_LoadNodes_RecursiveSetParent(mnode_t *node, mnode_t *parent)
{
+ //if (node->parent)
+ // Host_Error("Mod_Q1BSP_LoadNodes_RecursiveSetParent: runaway recursion\n");
node->parent = parent;
if (node->plane)
{
- Mod_Q1BSP_SetParent(node->children[0], node);
- Mod_Q1BSP_SetParent(node->children[1], node);
+ Mod_Q1BSP_LoadNodes_RecursiveSetParent(node->children[0], node);
+ Mod_Q1BSP_LoadNodes_RecursiveSetParent(node->children[1], node);
}
}
}
}
- Mod_Q1BSP_SetParent(loadmodel->brush.data_nodes, NULL); // sets nodes and leafs
+ Mod_Q1BSP_LoadNodes_RecursiveSetParent(loadmodel->brush.data_nodes, NULL); // sets nodes and leafs
}
static void Mod_Q1BSP_LoadLeafs(lump_t *l)
//of the given point.
static int Mod_Q1BSP_FatPVS(model_t *model, const vec3_t org, vec_t radius, qbyte *pvsbuffer, int pvsbufferlength)
{
- int bytes = ((model->brush.num_leafs - 1) + 7) >> 3;
+ int bytes = model->brush.num_pvsclusterbytes;
bytes = min(bytes, pvsbufferlength);
- if (r_novis.integer || !Mod_Q1BSP_GetPVS(model, org))
+ if (r_novis.integer || !model->brush.num_pvsclusters || !Mod_Q1BSP_GetPVS(model, org))
{
memset(pvsbuffer, 0xFF, bytes);
return bytes;
VectorAdd(inmins, hull->clip_size, outmaxs);
}
-/*
-void Mod_Q1BSP_RecursiveGetVisible(mnode_t *node, model_t *model, const vec3_t point, const vec3_t mins, const vec3_t maxs, int maxleafs, mleaf_t *leaflist, int *numleafs, int maxsurfaces, msurface_t *surfacelist, int *numsurfaces, const qbyte *pvs)
-{
- mleaf_t *leaf;
- for (;;)
- {
- if (!BoxesOverlap(node->mins, node->maxs, mins, maxs))
- return;
- if (!node->plane)
- break;
- Mod_Q1BSP_RecursiveGetVisible(node->children[0], model, point, mins, maxs, maxleafs, leaflist, numleafs, maxsurfaces, surfacelist, numsurfaces, pvs);
- node = node->children[1];
- }
- leaf = (mleaf_t *)node;
- if ((pvs == NULL || CHECKPVSBIT(pvs, leaf->clusterindex)))
- {
- int leafsurfacenum;
- msurface_t *surface;
- if (maxleafs && *numleafs < maxleafs)
- leaflist[(*numleafs)++] = leaf;
- if (maxsurfaces)
- {
- for (leafsurfacenum = 0;leafsurfacenum < leaf->numleafsurfaces;leafsurfacenum++)
- {
- surface = model->brush.data_surfaces + leaf->firstleafsurface[leafsurfacenum];
- if (surface->shadowmark != shadowmarkcount)
- {
- surface->shadowmark = shadowmarkcount;
- if (BoxesOverlap(mins, maxs, surface->mins, surface->maxs) && ((surface->flags & SURF_PLANEBACK) ? PlaneDiff(point, surface->plane) < 0 : PlaneDiff(point, surface->plane) > 0) && *numsurfaces < maxsurfaces)
- surfacelist[(*numsurfaces)++] = surface;
- }
- }
- }
- }
-}
-
-void Mod_Q1BSP_GetVisible(model_t *model, const vec3_t point, const vec3_t mins, const vec3_t maxs, int maxleafs, mleaf_t *leaflist, int *numleafs, int maxsurfaces, msurface_t *surfacelist, int *numsurfaces)
-{
- // FIXME: support portals
- if (maxsurfaces)
- *numsurfaces = 0;
- if (maxleafs)
- *numleafs = 0;
- pvs = ent->model->brush.GetPVS(ent->model, relativelightorigin);
- Mod_Q1BSP_RecursiveGetVisible(ent->model->brush.data_nodes + ent->model->brushq1.firstclipnode, model, point, mins, maxs, maxleafs, leaflist, numleafs, maxsurfaces, surfacelist, numsurfaces);
-}
-*/
-
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 *outclusterlist, qbyte *outclusterpvs, int *outnumclusterspointer, 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);
+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, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float *lightcolor, const matrix4x4_t *matrix_modeltolight, const matrix4x4_t *matrix_modeltoattenuationxyz, const matrix4x4_t *matrix_modeltoattenuationz, rtexture_t *lightcubemap, vec_t ambientscale, vec_t diffusescale, vec_t specularscale, int numsurfaces, const int *surfacelist);
void Mod_Q1BSP_Load(model_t *mod, void *buffer)
{
mod->brush.GetPVS = Mod_Q1BSP_GetPVS;
mod->brush.FatPVS = Mod_Q1BSP_FatPVS;
mod->brush.BoxTouchingPVS = Mod_Q1BSP_BoxTouchingPVS;
+ mod->brush.BoxTouchingVisibleLeafs = Mod_Q1BSP_BoxTouchingVisibleLeafs;
mod->brush.LightPoint = Mod_Q1BSP_LightPoint;
mod->brush.FindNonSolidLocation = Mod_Q1BSP_FindNonSolidLocation;
mod->brush.AmbientSoundLevelsForPoint = Mod_Q1BSP_AmbientSoundLevelsForPoint;
mod->brush.GetPVS = NULL;
mod->brush.FatPVS = NULL;
mod->brush.BoxTouchingPVS = NULL;
+ mod->brush.BoxTouchingVisibleLeafs = NULL;
mod->brush.LightPoint = NULL;
mod->brush.AmbientSoundLevelsForPoint = NULL;
}
for (j = 0, surface = &mod->brush.data_surfaces[mod->firstmodelsurface];j < mod->nummodelsurfaces;j++, surface++)
{
// we only need to have a drawsky function if it is used(usually only on world model)
- if (surface->texture->flags & SURF_DRAWSKY)
+ if (surface->texture->basematerialflags & MATERIALFLAG_SKY)
mod->DrawSky = R_Q1BSP_DrawSky;
- // LordHavoc: submodels always clip, even if water
- if (i)
- surface->flags |= SURF_SOLIDCLIP;
// calculate bounding shapes
for (k = 0, vec = surface->mesh.data_vertex3f;k < surface->mesh.num_vertices;k++, vec += 3)
{
{
out->surfaceparms = flags;
out->textureflags = flags2;
+ out->basematerialflags = 0;
+ if (out->surfaceparms & Q3SURFACEPARM_NODRAW)
+ out->basematerialflags |= MATERIALFLAG_NODRAW;
+ else if (out->surfaceparms & Q3SURFACEPARM_SKY)
+ out->basematerialflags |= MATERIALFLAG_SKY;
+ else if (out->surfaceparms & Q3SURFACEPARM_LAVA)
+ out->basematerialflags |= MATERIALFLAG_WATER | MATERIALFLAG_FULLBRIGHT;
+ else if (out->surfaceparms & Q3SURFACEPARM_SLIME)
+ out->basematerialflags |= MATERIALFLAG_WATER | MATERIALFLAG_WATERALPHA;
+ else if (out->surfaceparms & Q3SURFACEPARM_WATER)
+ out->basematerialflags |= MATERIALFLAG_WATER | MATERIALFLAG_WATERALPHA;
+ else
+ out->basematerialflags |= MATERIALFLAG_WALL;
+ if (out->surfaceparms & Q3SURFACEPARM_TRANS)
+ out->basematerialflags |= MATERIALFLAG_TRANSPARENT;
+ if (out->textureflags & Q3TEXTUREFLAG_ADDITIVE)
+ out->basematerialflags |= MATERIALFLAG_ADD | MATERIALFLAG_TRANSPARENT;
strlcpy(out->firstpasstexturename, firstpasstexturename, sizeof(out->firstpasstexturename));
if ((flags & Q3SURFACEPARM_SKY) && sky[0])
{
c++;
Con_DPrintf("%s: No shader found for texture \"%s\"\n", loadmodel->name, out->name);
out->surfaceparms = 0;
+ if (out->surfaceflags & Q3SURFACEFLAG_NODRAW)
+ out->basematerialflags |= MATERIALFLAG_NODRAW;
+ else if (out->surfaceflags & Q3SURFACEFLAG_SKY)
+ out->basematerialflags |= MATERIALFLAG_SKY;
+ else
+ out->basematerialflags |= MATERIALFLAG_WALL;
// these are defaults
//if (!strncmp(out->name, "textures/skies/", 15))
// out->surfaceparms |= Q3SURFACEPARM_SKY;
//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, true, 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, 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, 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))
Con_Printf("%s: texture loading for shader \"%s\" failed (first layer \"%s\" not found either)\n", loadmodel->name, out->name, out->firstpasstexturename);
+ if (out->skin.fog)
+ out->basematerialflags |= (MATERIALFLAG_ALPHA | MATERIALFLAG_TRANSPARENT);
+ // no animation
+ out->currentframe = out;
}
if (c)
Con_DPrintf("%s: %i textures missing shaders\n", loadmodel->name, c);
out->maxs[1] += 1.0f;
out->maxs[2] += 1.0f;
}
+ // set lightmap styles for consistency with q1bsp
+ out->styles[0] = 0;
+ out->styles[1] = 255;
+ out->styles[2] = 255;
+ out->styles[3] = 255;
}
}
}
}
-static void Mod_Q3BSP_LoadNodes_RecursiveSetParent(mnode_t *node, mnode_t *parent)
-{
- if (node->parent)
- Host_Error("Mod_Q3BSP_LoadNodes_RecursiveSetParent: runaway recursion\n");
- node->parent = parent;
- if (node->plane)
- {
- Mod_Q3BSP_LoadNodes_RecursiveSetParent(node->children[0], node);
- Mod_Q3BSP_LoadNodes_RecursiveSetParent(node->children[1], node);
- }
-}
-
static void Mod_Q3BSP_LoadNodes(lump_t *l)
{
q3dnode_t *in;
}
// set the parent pointers
- Mod_Q3BSP_LoadNodes_RecursiveSetParent(loadmodel->brush.data_nodes, NULL);
+ Mod_Q1BSP_LoadNodes_RecursiveSetParent(loadmodel->brush.data_nodes, NULL);
}
static void Mod_Q3BSP_LoadLightGrid(lump_t *l)
memcpy(loadmodel->brush.data_pvsclusters, (qbyte *)(in + 1), totalchains);
}
-static void Mod_Q3BSP_FindNonSolidLocation(model_t *model, const vec3_t in, vec3_t out, vec_t radius)
-{
- // FIXME: finish this code
- VectorCopy(in, out);
-}
-
static void Mod_Q3BSP_LightPoint(model_t *model, const vec3_t p, vec3_t ambientcolor, vec3_t diffusecolor, vec3_t diffusenormal)
{
int i, j, k, index[3];
}
}
-static int Mod_Q3BSP_BoxTouchingPVS(model_t *model, const qbyte *pvs, const vec3_t mins, const vec3_t maxs)
-{
- int clusterindex, side, nodestackindex = 0;
- mnode_t *node, *nodestack[1024];
- node = model->brush.data_nodes;
- if (!model->brush.num_pvsclusters)
- return true;
- for (;;)
- {
- if (node->plane)
- {
- // node - recurse down the BSP tree
- side = BoxOnPlaneSide(mins, maxs, node->plane) - 1;
- if (side < 2)
- {
- // box is on one side of plane, take that path
- node = node->children[side];
- }
- else
- {
- // box crosses plane, take one path and remember the other
- if (nodestackindex < 1024)
- nodestack[nodestackindex++] = node->children[0];
- node = node->children[1];
- }
- }
- else
- {
- // leaf - check cluster bit
- clusterindex = ((mleaf_t *)node)->clusterindex;
-#if 0
- if (clusterindex >= model->brush.num_pvsclusters)
- {
- Con_Printf("%i >= %i\n", clusterindex, model->brush.num_pvsclusters);
- return true;
- }
-#endif
- if (CHECKPVSBIT(pvs, clusterindex))
- {
- // it is visible, return immediately with the news
- return true;
- }
- else
- {
- // nothing to see here, try another path we didn't take earlier
- if (nodestackindex == 0)
- break;
- node = nodestack[--nodestackindex];
- }
- }
- }
- // it is not visible
- return false;
-}
-
-//Returns PVS data for a given point
-//(note: can return NULL)
-static qbyte *Mod_Q3BSP_GetPVS(model_t *model, const vec3_t p)
-{
- mnode_t *node;
- Mod_CheckLoaded(model);
- node = model->brush.data_nodes;
- while (node->plane)
- node = node->children[(node->plane->type < 3 ? p[node->plane->type] : DotProduct(p,node->plane->normal)) < node->plane->dist];
- if (((mleaf_t *)node)->clusterindex >= 0)
- return model->brush.data_pvsclusters + ((mleaf_t *)node)->clusterindex * model->brush.num_pvsclusterbytes;
- else
- return NULL;
-}
-
-static void Mod_Q3BSP_FatPVS_RecursiveBSPNode(model_t *model, const vec3_t org, vec_t radius, qbyte *pvsbuffer, int pvsbytes, mnode_t *node)
-{
- while (node->plane)
- {
- float d = PlaneDiff(org, node->plane);
- if (d > radius)
- node = node->children[0];
- else if (d < -radius)
- node = node->children[1];
- else
- {
- // go down both sides
- Mod_Q3BSP_FatPVS_RecursiveBSPNode(model, org, radius, pvsbuffer, pvsbytes, node->children[0]);
- node = node->children[1];
- }
- }
- // if this leaf is in a cluster, accumulate the pvs bits
- if (((mleaf_t *)node)->clusterindex >= 0)
- {
- int i;
- qbyte *pvs = model->brush.data_pvsclusters + ((mleaf_t *)node)->clusterindex * model->brush.num_pvsclusterbytes;
- for (i = 0;i < pvsbytes;i++)
- pvsbuffer[i] |= pvs[i];
- }
-}
-
-//Calculates a PVS that is the inclusive or of all leafs within radius pixels
-//of the given point.
-static int Mod_Q3BSP_FatPVS(model_t *model, const vec3_t org, vec_t radius, qbyte *pvsbuffer, int pvsbufferlength)
-{
- int bytes = model->brush.num_pvsclusterbytes;
- bytes = min(bytes, pvsbufferlength);
- if (r_novis.integer || !model->brush.num_pvsclusters || !Mod_Q3BSP_GetPVS(model, org))
- {
- memset(pvsbuffer, 0xFF, bytes);
- return bytes;
- }
- memset(pvsbuffer, 0, bytes);
- Mod_Q3BSP_FatPVS_RecursiveBSPNode(model, org, radius, pvsbuffer, bytes, model->brush.data_nodes);
- return bytes;
-}
-
-
static int Mod_Q3BSP_SuperContentsFromNativeContents(model_t *model, int nativecontents)
{
int supercontents = 0;
loadmodel->brush.num_leafs = numleafs;
}
-extern void R_Q3BSP_DrawSky(struct entity_render_s *ent);
-extern void R_Q3BSP_Draw(struct entity_render_s *ent);
-extern void R_Q3BSP_GetLightInfo(entity_render_t *ent, vec3_t relativelightorigin, float lightradius, vec3_t outmins, vec3_t outmaxs, int *outclusterlist, qbyte *outclusterpvs, int *outnumclusterspointer, int *outsurfacelist, qbyte *outsurfacepvs, int *outnumsurfacespointer);
-extern void R_Q3BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, float lightradius, int numsurfaces, const int *surfacelist);
-extern void R_Q3BSP_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float *lightcolor, const matrix4x4_t *matrix_modeltolight, const matrix4x4_t *matrix_modeltoattenuationxyz, const matrix4x4_t *matrix_modeltoattenuationz, rtexture_t *lightcubemap, vec_t ambientscale, vec_t diffusescale, vec_t specularscale, int numsurfaces, const int *surfacelist);
void Mod_Q3BSP_Load(model_t *mod, void *buffer)
{
int i, j, numshadowmeshtriangles;
mod->TraceBox = Mod_Q3BSP_TraceBox;
mod->brush.SuperContentsFromNativeContents = Mod_Q3BSP_SuperContentsFromNativeContents;
mod->brush.NativeContentsFromSuperContents = Mod_Q3BSP_NativeContentsFromSuperContents;
- mod->brush.GetPVS = Mod_Q3BSP_GetPVS;
- mod->brush.FatPVS = Mod_Q3BSP_FatPVS;
- mod->brush.BoxTouchingPVS = Mod_Q3BSP_BoxTouchingPVS;
+ mod->brush.GetPVS = Mod_Q1BSP_GetPVS;
+ mod->brush.FatPVS = Mod_Q1BSP_FatPVS;
+ mod->brush.BoxTouchingPVS = Mod_Q1BSP_BoxTouchingPVS;
+ mod->brush.BoxTouchingVisibleLeafs = Mod_Q1BSP_BoxTouchingVisibleLeafs;
mod->brush.LightPoint = Mod_Q3BSP_LightPoint;
- mod->brush.FindNonSolidLocation = Mod_Q3BSP_FindNonSolidLocation;
- //mod->DrawSky = R_Q3BSP_DrawSky;
- mod->Draw = R_Q3BSP_Draw;
- mod->GetLightInfo = R_Q3BSP_GetLightInfo;
- mod->DrawShadowVolume = R_Q3BSP_DrawShadowVolume;
- mod->DrawLight = R_Q3BSP_DrawLight;
+ mod->brush.FindNonSolidLocation = Mod_Q1BSP_FindNonSolidLocation;
+ mod->Draw = R_Q1BSP_Draw;
+ mod->GetLightInfo = R_Q1BSP_GetLightInfo;
+ mod->DrawShadowVolume = R_Q1BSP_DrawShadowVolume;
+ mod->DrawLight = R_Q1BSP_DrawLight;
mod_base = (qbyte *)header;
Mod_Q3BSP_RecursiveFindNumLeafs(loadmodel->brush.data_nodes);
mod = loadmodel;
- for (i = 0;i < loadmodel->brushq3.num_models;i++)
+ for (i = 0;i < loadmodel->brush.numsubmodels;i++)
{
if (i > 0)
{
mod->brush.GetPVS = NULL;
mod->brush.FatPVS = NULL;
mod->brush.BoxTouchingPVS = NULL;
+ mod->brush.BoxTouchingVisibleLeafs = NULL;
mod->brush.LightPoint = NULL;
- mod->brush.FindNonSolidLocation = Mod_Q3BSP_FindNonSolidLocation;
+ mod->brush.FindNonSolidLocation = Mod_Q1BSP_FindNonSolidLocation;
}
mod->brush.submodel = i;
if (mod->brush.data_surfaces[j + mod->firstmodelsurface].texture->surfaceflags & Q3SURFACEFLAG_SKY)
break;
if (j < mod->nummodelsurfaces)
- mod->DrawSky = R_Q3BSP_DrawSky;
+ mod->DrawSky = R_Q1BSP_DrawSky;
}
}