entity_render_t *ent;
model_t *model;
vec3_t org;
- if (cl.worldmodel == NULL)
+ if (cl.worldmodel == NULL || !cl.worldmodel->brushq1.nodes)
return;
fcolor[0] = cr1;
fcolor[1] = cg1;
if (model && model->name[0] == '*')
{
Mod_CheckLoaded(model);
- if (model->type == mod_brush)
+ if (model->brushq1.nodes)
{
Matrix4x4_Transform(&ent->inversematrix, origin, org);
R_StainNode(model->brushq1.nodes + model->brushq1.hulls[0].firstclipnode, model, org, radius, fcolor);
rmeshstate_t m;
// LordHavoc: HalfLife maps have freaky skypolys...
- if (ent->model->brushq1.ishlbsp)
+ if (ent->model->brush.ishlbsp)
return;
if (skyrendernow)
R_Mesh_Draw(portal->numpoints, portal->numpoints - 2, polygonelements);
}
+// LordHavoc: this is just a nice debugging tool, very slow
static void R_DrawPortals(entity_render_t *ent)
{
int i;
return;
for (portal = ent->model->brushq1.portals, endportal = portal + ent->model->brushq1.numportals;portal < endportal;portal++)
{
- if ((portal->here->pvsframe == ent->model->brushq1.pvsframecount || portal->past->pvsframe == ent->model->brushq1.pvsframecount) && portal->numpoints <= POLYGONELEMENTS_MAXPOINTS)
+ if (portal->numpoints <= POLYGONELEMENTS_MAXPOINTS)
{
VectorClear(temp);
for (i = 0;i < portal->numpoints;i++)
static void R_PortalWorldNode(entity_render_t *ent, mleaf_t *viewleaf)
{
- int c, leafstackpos, *mark, *surfacevisframes;
+ int c, leafstackpos, *mark, *surfacevisframes, bitnum;
#if WORLDNODECULLBACKFACES
int n;
msurface_t *surf;
{
leaf->worldnodeframe = r_framecount;
// FIXME: R_CullBox is absolute, should be done relative
- if (leaf->pvsframe == ent->model->brushq1.pvsframecount && !R_CullBox(leaf->mins, leaf->maxs))
+ bitnum = (leaf - ent->model->brushq1.leafs) - 1;
+ if ((r_pvsbits[bitnum >> 3] & (1 << (bitnum & 7))) && !R_CullBox(leaf->mins, leaf->maxs))
leafstack[leafstackpos++] = leaf;
}
}
void R_PVSUpdate (entity_render_t *ent, mleaf_t *viewleaf)
{
- int i, j, l, c, bits, *surfacepvsframes, *mark;
+ int j, c, *surfacepvsframes, *mark;
mleaf_t *leaf;
- qbyte *vis;
model_t *model;
model = ent->model;
if (viewleaf)
{
surfacepvsframes = model->brushq1.surfacepvsframes;
- vis = model->brushq1.LeafPVS(model, viewleaf);
- for (j = 0;j < model->brushq1.numleafs;j += 8)
+ for (j = 0;j < model->brushq1.visleafs;j++)
{
- bits = *vis++;
- if (bits)
+ if (r_pvsbits[j >> 3] & (1 << (j & 7)))
{
- l = model->brushq1.numleafs - j;
- if (l > 8)
- l = 8;
- for (i = 0;i < l;i++)
- {
- if (bits & (1 << i))
- {
- leaf = &model->brushq1.leafs[j + i + 1];
- leaf->pvschain = model->brushq1.pvsleafchain;
- model->brushq1.pvsleafchain = leaf;
- leaf->pvsframe = model->brushq1.pvsframecount;
- // mark surfaces bounding this leaf as visible
- for (c = leaf->nummarksurfaces, mark = leaf->firstmarksurface;c;c--, mark++)
- surfacepvsframes[*mark] = model->brushq1.pvsframecount;
- }
- }
+ leaf = model->brushq1.leafs + j + 1;
+ leaf->pvsframe = model->brushq1.pvsframecount;
+ leaf->pvschain = model->brushq1.pvsleafchain;
+ model->brushq1.pvsleafchain = leaf;
+ // mark surfaces bounding this leaf as visible
+ for (c = leaf->nummarksurfaces, mark = leaf->firstmarksurface;c;c--, mark++)
+ surfacepvsframes[*mark] = model->brushq1.pvsframecount;
}
}
model->brushq1.BuildPVSTextureChains(model);
}
}
-void R_WorldVisibility (entity_render_t *ent)
+void R_WorldVisibility(entity_render_t *ent)
{
vec3_t modelorg;
mleaf_t *viewleaf;
Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
- viewleaf = ent->model ? ent->model->brushq1.PointInLeaf(ent->model, modelorg) : NULL;
+ viewleaf = (ent->model && ent->model->brushq1.PointInLeaf) ? ent->model->brushq1.PointInLeaf(ent->model, modelorg) : NULL;
R_PVSUpdate(ent, viewleaf);
if (!viewleaf)
R_PortalWorldNode (ent, viewleaf);
}
-void R_DrawWorld (entity_render_t *ent)
+void R_DrawWorld(entity_render_t *ent)
{
if (ent->model == NULL)
return;
- R_PrepareSurfaces(ent);
- R_DrawSurfaces(ent, SHADERSTAGE_SKY, ent->model->brushq1.pvstexturechains);
- R_DrawSurfaces(ent, SHADERSTAGE_NORMAL, ent->model->brushq1.pvstexturechains);
- if (r_drawportals.integer)
- R_DrawPortals(ent);
+ if (!ent->model->brushq1.numleafs && ent->model->Draw)
+ ent->model->Draw(ent);
+ else
+ {
+ R_PrepareSurfaces(ent);
+ R_DrawSurfaces(ent, SHADERSTAGE_SKY, ent->model->brushq1.pvstexturechains);
+ R_DrawSurfaces(ent, SHADERSTAGE_NORMAL, ent->model->brushq1.pvstexturechains);
+ if (r_drawportals.integer)
+ R_DrawPortals(ent);
+ }
}
-void R_Model_Brush_DrawSky (entity_render_t *ent)
+void R_Model_Brush_DrawSky(entity_render_t *ent)
{
if (ent->model == NULL)
return;
R_DrawSurfaces(ent, SHADERSTAGE_SKY, ent->model->brushq1.pvstexturechains);
}
-void R_Model_Brush_Draw (entity_render_t *ent)
+void R_Model_Brush_Draw(entity_render_t *ent)
{
if (ent->model == NULL)
return;
}
}
+void R_Q3BSP_DrawFace_Mesh(entity_render_t *ent, q3mface_t *face)
+{
+ const surfmesh_t *mesh;
+ rmeshstate_t m;
+ memset(&m, 0, sizeof(m));
+ GL_BlendFunc(GL_ONE, GL_ZERO);
+ GL_DepthMask(true);
+ GL_DepthTest(true);
+ m.tex[0] = R_GetTexture(face->texture->skin.base);
+ m.pointer_texcoord[0] = face->data_texcoordtexture2f;
+ if (face->lightmaptexture)
+ {
+ m.tex[1] = R_GetTexture(face->lightmaptexture);
+ m.pointer_texcoord[1] = face->data_texcoordlightmap2f;
+ m.texrgbscale[1] = 2;
+ GL_Color(r_colorscale, r_colorscale, r_colorscale, 1);
+ }
+ else
+ {
+ m.texrgbscale[0] = 2;
+ GL_ColorPointer(face->data_color4f);
+ }
+ R_Mesh_State_Texture(&m);
+ GL_VertexPointer(face->data_vertex3f);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->element3i);
+}
+
+void R_Q3BSP_DrawFace_Patch(entity_render_t *ent, q3mface_t *face)
+{
+}
+
+void R_Q3BSP_DrawFace(entity_render_t *ent, q3mface_t *face)
+{
+ switch(face->type)
+ {
+ case Q3FACETYPE_POLYGON:
+ case Q3FACETYPE_MESH:
+ R_Q3BSP_DrawFace_Mesh(ent, face);
+ break;
+ case Q3FACETYPE_PATCH:
+ R_Q3BSP_DrawFace_Patch(ent, face);
+ break;
+ case Q3FACETYPE_FLARE:
+ break;
+ }
+}
+
+/*
+void R_Q3BSP_DrawSky(entity_render_t *ent)
+{
+}
+*/
+
+void R_Q3BSP_Draw(entity_render_t *ent)
+{
+ int i;
+ q3mface_t *face;
+ model_t *model;
+ model = ent->model;
+ for (i = 0, face = model->brushq3.data_thismodel->firstface;i < model->brushq3.data_thismodel->numfaces;i++, face++)
+ R_Q3BSP_DrawFace(ent, face);
+}
+
+/*
+void R_Q3BSP_DrawFakeShadow(entity_render_t *ent)
+{
+}
+*/
+
+/*
+void R_Q3BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, float lightradius)
+{
+}
+*/
+
+/*
+void R_Q3BSP_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float *lightcolor, const matrix4x4_t *matrix_modeltofilter, const matrix4x4_t *matrix_modeltoattenuationxyz, const matrix4x4_t *matrix_modeltoattenuationz)
+{
+}
+*/
+
static void gl_surf_start(void)
{
}