// flag arrays used for visibility checking on world model
// (all other entities have no per-surface/per-leaf visibility checks)
// TODO: dynamic resize according to r_refdef.worldmodel->brush.num_clusters
-qbyte r_pvsbits[(32768+7)>>3];
+unsigned char r_pvsbits[(32768+7)>>3];
// TODO: dynamic resize according to r_refdef.worldmodel->brush.num_leafs
-qbyte r_worldleafvisible[32768];
+unsigned char r_worldleafvisible[32768];
// TODO: dynamic resize according to r_refdef.worldmodel->num_surfaces
-qbyte r_worldsurfacevisible[262144];
+unsigned char r_worldsurfacevisible[262144];
/*
===============
{
int smax, tmax, i, j, size, size3, maps, stride, l;
unsigned int *bl, scale;
- qbyte *lightmap, *out, *stain;
+ unsigned char *lightmap, *out, *stain;
static unsigned int intblocklights[MAX_LIGHTMAP_SIZE*MAX_LIGHTMAP_SIZE*3]; // LordHavoc: *3 for colored lighting
- static qbyte templight[MAX_LIGHTMAP_SIZE*MAX_LIGHTMAP_SIZE*4];
+ static unsigned char templight[MAX_LIGHTMAP_SIZE*MAX_LIGHTMAP_SIZE*4];
// update cached lighting info
surface->cached_dlight = 0;
{
bl = intblocklights;
for (maps = 0;maps < MAXLIGHTMAPS && surface->lightmapinfo->styles[maps] != 255;maps++, lightmap += size3)
- for (scale = d_lightstylevalue[surface->lightmapinfo->styles[maps]], i = 0;i < size3;i++)
+ for (scale = r_refdef.lightstylevalue[surface->lightmapinfo->styles[maps]], i = 0;i < size3;i++)
bl[i] += lightmap[i] * scale;
}
}
float ndist, a, ratio, maxdist, maxdist2, maxdist3, invradius, sdtable[256], td, dist2;
msurface_t *surface, *endsurface;
int i, s, t, smax, tmax, smax3, impacts, impactt, stained;
- qbyte *bl;
+ unsigned char *bl;
vec3_t impact;
maxdist = radius * radius;
{
if (a > 1)
a = 1;
- bl[0] = (qbyte) ((float) bl[0] + a * ((fcolor[0] + ratio * fcolor[4]) - (float) bl[0]));
- bl[1] = (qbyte) ((float) bl[1] + a * ((fcolor[1] + ratio * fcolor[5]) - (float) bl[1]));
- bl[2] = (qbyte) ((float) bl[2] + a * ((fcolor[2] + ratio * fcolor[6]) - (float) bl[2]));
+ bl[0] = (unsigned char) ((float) bl[0] + a * ((fcolor[0] + ratio * fcolor[4]) - (float) bl[0]));
+ bl[1] = (unsigned char) ((float) bl[1] + a * ((fcolor[1] + ratio * fcolor[5]) - (float) bl[1]));
+ bl[2] = (unsigned char) ((float) bl[2] + a * ((fcolor[2] + ratio * fcolor[6]) - (float) bl[2]));
stained = true;
}
}
model = ent->model;
if (model && model->name[0] == '*')
{
- Mod_CheckLoaded(model);
if (model->brush.data_nodes)
{
Matrix4x4_Transform(&ent->inversematrix, origin, org);
int i;
float *v;
rmeshstate_t m;
- const mportal_t *portal = calldata1;
+ const mportal_t *portal = (mportal_t *)calldata1;
GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GL_DepthMask(false);
GL_DepthTest(true);
// if leaf is in current pvs and on the screen, mark its surfaces
if (CHECKPVSBIT(r_pvsbits, leaf->clusterindex) && !R_CullBox(leaf->mins, leaf->maxs))
{
- c_leafs++;
+ renderstats.world_leafs++;
r_worldleafvisible[j] = true;
if (leaf->numleafsurfaces)
for (i = 0, mark = leaf->firstleafsurface;i < leaf->numleafsurfaces;i++, mark++)
leafstackpos = 1;
while (leafstackpos)
{
- c_leafs++;
+ renderstats.world_leafs++;
leaf = leafstack[--leafstackpos];
r_worldleafvisible[leaf - model->brush.data_leafs] = true;
// mark any surfaces bounding this leaf
// and the leaf is visible in the pvs
// (the first two checks won't cause as many cache misses as the leaf checks)
for (p = leaf->portals;p;p = p->next)
+ {
+ renderstats.world_portals++;
if (DotProduct(r_vieworigin, p->plane.normal) < (p->plane.dist + 1) && !R_CullBox(p->mins, p->maxs) && !r_worldleafvisible[p->past - model->brush.data_leafs] && CHECKPVSBIT(r_pvsbits, p->past->clusterindex))
leafstack[leafstackpos++] = p->past;
+ }
}
}
void R_Q1BSP_Draw(entity_render_t *ent)
{
- if (ent->model == NULL)
+ model_t *model = ent->model;
+ if (model == NULL)
return;
- c_bmodels++;
if (r_drawcollisionbrushes.integer < 2)
R_DrawSurfaces(ent, false);
- if (r_drawcollisionbrushes.integer >= 1 && ent->model->brush.num_brushes)
+ if (r_drawcollisionbrushes.integer >= 1 && model->brush.num_brushes)
{
int i;
- model_t *model = ent->model;
msurface_t *surface;
q3mbrush_t *brush;
R_Mesh_Matrix(&ent->matrix);
vec3_t relativelightorigin;
float lightradius;
int *outleaflist;
- qbyte *outleafpvs;
+ unsigned char *outleafpvs;
int outnumleafs;
int *outsurfacelist;
- qbyte *outsurfacepvs;
+ unsigned char *outsurfacepvs;
int outnumsurfaces;
vec3_t outmins;
vec3_t outmaxs;
vec3_t lightmins;
vec3_t lightmaxs;
- const qbyte *pvs;
+ const unsigned char *pvs;
}
r_q1bsp_getlightinfo_t;
mleaf_t *leaf;
for (;;)
{
- if (!BoxesOverlap(info->lightmins, info->lightmaxs, node->mins, node->maxs))
- return;
- if (!node->plane)
+ mplane_t *plane = node->plane;
+ //if (!BoxesOverlap(info->lightmins, info->lightmaxs, node->mins, node->maxs))
+ // return;
+ if (!plane)
break;
- sides = BoxOnPlaneSide(info->lightmins, info->lightmaxs, node->plane) - 1;
- if (sides == 2)
+ if (plane->type < 3)
+ sides = ((info->lightmaxs[plane->type] >= plane->dist) | ((info->lightmins[plane->type] < plane->dist) << 1));
+ else
+ sides = BoxOnPlaneSide(info->lightmins, info->lightmaxs, plane);
+ if (sides == 3)
{
R_Q1BSP_RecursiveGetLightInfo(info, node->children[0]);
node = node->children[1];
}
else
- node = node->children[sides];
+ node = node->children[sides - 1];
}
leaf = (mleaf_t *)node;
if (info->pvs == NULL || CHECKPVSBIT(info->pvs, leaf->clusterindex))
}
}
-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)
+void R_Q1BSP_GetLightInfo(entity_render_t *ent, vec3_t relativelightorigin, float lightradius, vec3_t outmins, vec3_t outmaxs, int *outleaflist, unsigned char *outleafpvs, int *outnumleafspointer, int *outsurfacelist, unsigned char *outsurfacepvs, int *outnumsurfacespointer)
{
r_q1bsp_getlightinfo_t info;
VectorCopy(relativelightorigin, info.relativelightorigin);
if ((ent == r_refdef.worldentity && !r_worldsurfacevisible[surfacelist[surfacelistindex]]))
continue;
surface = model->data_surfaces + surfacelist[surfacelistindex];
+ renderstats.lights_lighttriangles += surface->num_triangles;
if (tex != surface->texture)
{
if (batchnumsurfaces > 0)