#include "quakedef.h"
#include "r_shadow.h"
#include "portals.h"
+#include "csprogs.h"
cvar_t r_ambient = {0, "r_ambient", "0", "brightens map, value is 0-128"};
cvar_t r_lockpvs = {0, "r_lockpvs", "0", "disables pvs switching, allows you to walk around and inspect what is visible from a given location in the map (anything not visible from your current location will not be drawn)"};
numpoints = min(portal->numpoints, POLYGONELEMENTS_MAXPOINTS);
- R_Mesh_VertexPointer(vertex3f, 0, 0);
- R_Mesh_ColorPointer(NULL, 0, 0);
R_Mesh_ResetTextureState();
- R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1);
isvis = (portal->here->clusterindex >= 0 && portal->past->clusterindex >= 0 && portal->here->clusterindex != portal->past->clusterindex);
isvis ? 0.125f : 0.03125f);
for (i = 0, v = vertex3f;i < numpoints;i++, v += 3)
VectorCopy(portal->points[i].position, v);
- R_Mesh_Draw(0, numpoints, 0, numpoints - 2, polygonelement3i, polygonelement3s, 0, 0);
+ R_Mesh_PrepareVertices_Generic_Arrays(numpoints, vertex3f, NULL, NULL);
+ R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1);
+ R_Mesh_Draw(0, numpoints, 0, numpoints - 2, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0);
}
// LordHavoc: this is just a nice debugging tool, very slow
R_DrawModelSurfaces(ent, true, true, false, false, false);
}
-extern void R_Water_AddWaterPlane(msurface_t *surface);
+extern void R_Water_AddWaterPlane(msurface_t *surface, int entno);
void R_Q1BSP_DrawAddWaterPlanes(entity_render_t *ent)
{
- int i, j, flagsmask;
+ int i, j, n, flagsmask;
dp_model_t *model = ent->model;
msurface_t *surfaces;
if (model == NULL)
RSurf_ActiveModelEntity(ent, false, false, false);
surfaces = model->data_surfaces;
- flagsmask = MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_REFLECTION;
+ flagsmask = MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_REFLECTION | MATERIALFLAG_CAMERA;
// add visible surfaces to draw list
if (ent == r_refdef.scene.worldentity)
j = model->sortedmodelsurfaces[i];
if (r_refdef.viewcache.world_surfacevisible[j])
if (surfaces[j].texture->basematerialflags & flagsmask)
- R_Water_AddWaterPlane(surfaces + j);
+ R_Water_AddWaterPlane(surfaces + j, 0);
}
}
else
{
+ if(ent->entitynumber >= MAX_EDICTS) // && CL_VM_TransformView(ent->entitynumber - MAX_EDICTS, NULL, NULL, NULL))
+ n = ent->entitynumber;
+ else
+ n = 0;
for (i = 0;i < model->nummodelsurfaces;i++)
{
j = model->sortedmodelsurfaces[i];
if (surfaces[j].texture->basematerialflags & flagsmask)
- R_Water_AddWaterPlane(surfaces + j);
+ R_Water_AddWaterPlane(surfaces + j, n);
}
}
rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveWorldEntity/RSurf_ActiveModelEntity
GL_BlendFunc(GL_ONE, GL_ZERO);
GL_DepthMask(true);
GL_AlphaTest(false);
- R_Mesh_ColorPointer(NULL, 0, 0);
R_Mesh_ResetTextureState();
R_SetupShader_DepthOrShadow();
if (ent == r_refdef.scene.worldentity)
if (SVBSP_AddPolygon(&r_svbsp, portal->numpoints, points[0], false, NULL, NULL, 0) & 2)
break;
}
- if (portal == NULL)
+ if (leaf->portals && portal == NULL)
return; // no portals of this leaf visible
}
if (info->svbsp_insertoccluder)
rsurface.texture = R_GetCurrentTexture(surface->texture);
if (rsurface.texture->currentmaterialflags & MATERIALFLAG_NOSHADOW)
continue;
- RSurf_PrepareVerticesForBatch(false, false, 1, &surface);
- R_Shadow_MarkVolumeFromBox(surface->num_firsttriangle, surface->num_triangles, rsurface.vertex3f, rsurface.modelelement3i, relativelightorigin, relativelightdirection, lightmins, lightmaxs, surface->mins, surface->maxs);
+ R_Shadow_MarkVolumeFromBox(surface->num_firsttriangle, surface->num_triangles, rsurface.modelvertex3f, rsurface.modelelement3i, relativelightorigin, relativelightdirection, lightmins, lightmaxs, surface->mins, surface->maxs);
}
- R_Shadow_VolumeFromList(model->surfmesh.num_vertices, model->surfmesh.num_triangles, rsurface.vertex3f, model->surfmesh.data_element3i, model->surfmesh.data_neighbor3i, relativelightorigin, relativelightdirection, projectdistance, numshadowmark, shadowmarklist, ent->mins, ent->maxs);
+ R_Shadow_VolumeFromList(model->surfmesh.num_vertices, model->surfmesh.num_triangles, rsurface.modelvertex3f, model->surfmesh.data_element3i, model->surfmesh.data_neighbor3i, relativelightorigin, relativelightdirection, projectdistance, numshadowmark, shadowmarklist, ent->mins, ent->maxs);
}
if (ent->model->brush.submodel)
GL_PolygonOffset(r_refdef.shadowpolygonfactor, r_refdef.shadowpolygonoffset);
}
--modelsurfacelistindex;
GL_CullFace(rsurface.texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE ? GL_NONE : r_refdef.view.cullface_back);
- RSurf_PrepareVerticesForBatch(false, false, batchnumsurfaces, batchsurfacelist);
- RSurf_DrawBatch_Simple(batchnumsurfaces, batchsurfacelist);
+ RSurf_PrepareVerticesForBatch(BATCHNEED_VERTEXPOSITION, batchnumsurfaces, batchsurfacelist);
+ R_Mesh_PrepareVertices_Position(rsurface.batchnumvertices, rsurface.batchvertexposition, rsurface.batchvertexpositionbuffer);
+ RSurf_DrawBatch();
}
}
int i, j, endsurface;
texture_t *t;
const msurface_t *surface;
- // note: in practice this never actually receives batches), oh well
+ // note: in practice this never actually receives batches
R_Shadow_RenderMode_Begin();
R_Shadow_RenderMode_ActiveLight(rtlight);
R_Shadow_RenderMode_Lighting(false, true, false);
surface = rsurface.modelsurfaces + surfacelist[j];
if (t != surface->texture)
break;
- RSurf_PrepareVerticesForBatch(true, true, 1, &surface);
- R_Shadow_RenderLighting(surface->num_firstvertex, surface->num_vertices, surface->num_firsttriangle, surface->num_triangles, ent->model->surfmesh.data_element3i, ent->model->surfmesh.data_element3s, ent->model->surfmesh.ebo3i, ent->model->surfmesh.ebo3s);
+ R_Shadow_RenderLighting(1, &surface);
}
}
R_Shadow_RenderMode_End();
{
dp_model_t *model = ent->model;
const msurface_t *surface;
- int i, k, kend, l, m, mend, endsurface, batchnumsurfaces, batchnumtriangles, batchfirstvertex, batchlastvertex, batchfirsttriangle;
+ int i, k, kend, l, endsurface, batchnumsurfaces, texturenumsurfaces;
+ const msurface_t **texturesurfacelist;
const int *element3i;
- static int batchelements[BATCHSIZE*3];
texture_t *tex;
CHECKGLERROR
element3i = rsurface.modelelement3i;
// now figure out what to do with this particular range of surfaces
if (!(rsurface.texture->currentmaterialflags & MATERIALFLAG_WALL))
continue;
- if (r_waterstate.renderingscene && (rsurface.texture->currentmaterialflags & (MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_REFLECTION)))
+ if (r_waterstate.renderingscene && (rsurface.texture->currentmaterialflags & (MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_REFLECTION | MATERIALFLAG_CAMERA)))
continue;
if (rsurface.texture->currentmaterialflags & MATERIALFLAGMASK_DEPTHSORTED)
{
}
if (r_shadow_usingdeferredprepass)
continue;
- batchnumtriangles = 0;
- batchfirsttriangle = surface->num_firsttriangle;
- m = 0; // hush warning
- for (l = k;l < kend;l++)
- {
- surface = batchsurfacelist[l];
- RSurf_PrepareVerticesForBatch(true, true, 1, &surface);
- for (m = surface->num_firsttriangle, mend = m + surface->num_triangles;m < mend;m++)
- {
- if (lighttrispvs && r_test.integer && !CHECKPVSBIT(lighttrispvs, m))
- continue;
- if (batchnumtriangles >= BATCHSIZE)
- {
- r_refdef.stats.lights_lighttriangles += batchnumtriangles;
- Mod_VertexRangeFromElements(batchnumtriangles*3, batchelements, &batchfirstvertex, &batchlastvertex);
- // use the element buffer if all triangles are consecutive
- if (m == batchfirsttriangle + batchnumtriangles)
- R_Shadow_RenderLighting(batchfirstvertex, batchlastvertex + 1 - batchfirstvertex, batchfirsttriangle, batchnumtriangles, ent->model->surfmesh.data_element3i, ent->model->surfmesh.data_element3s, ent->model->surfmesh.ebo3i, ent->model->surfmesh.ebo3s);
- else
- R_Shadow_RenderLighting(batchfirstvertex, batchlastvertex + 1 - batchfirstvertex, 0, batchnumtriangles, batchelements, NULL, 0, 0);
- batchnumtriangles = 0;
- batchfirsttriangle = m;
- }
- batchelements[batchnumtriangles*3+0] = element3i[m*3+0];
- batchelements[batchnumtriangles*3+1] = element3i[m*3+1];
- batchelements[batchnumtriangles*3+2] = element3i[m*3+2];
- batchnumtriangles++;
- }
- }
- if (batchnumtriangles > 0)
- {
- r_refdef.stats.lights_lighttriangles += batchnumtriangles;
- Mod_VertexRangeFromElements(batchnumtriangles*3, batchelements, &batchfirstvertex, &batchlastvertex);
- // use the element buffer if all triangles are consecutive
- if (m == batchfirsttriangle + batchnumtriangles)
- R_Shadow_RenderLighting(batchfirstvertex, batchlastvertex + 1 - batchfirstvertex, batchfirsttriangle, batchnumtriangles, ent->model->surfmesh.data_element3i, ent->model->surfmesh.data_element3s, ent->model->surfmesh.ebo3i, ent->model->surfmesh.ebo3s);
- else
- R_Shadow_RenderLighting(batchfirstvertex, batchlastvertex + 1 - batchfirstvertex, 0, batchnumtriangles, batchelements, NULL, 0, 0);
- }
+ texturenumsurfaces = kend - k;
+ texturesurfacelist = batchsurfacelist + k;
+ R_Shadow_RenderLighting(texturenumsurfaces, texturesurfacelist);
}
}
}
skinframe_t *skinframe;
if (!r_refdef.scene.worldmodel)
{
- if (gamemode != GAME_BLOODOMNICIDE)
- Con_Printf("There is no worldmodel\n");
+ Con_Printf("There is no worldmodel\n");
return;
}
m = r_refdef.scene.worldmodel;
}
if(!cl.islocalgame || !cl.worldmodel)
{
- if (gamemode != GAME_BLOODOMNICIDE)
- Con_Print("This command works only in singleplayer\n");
+ Con_Print("This command works only in singleplayer\n");
return;
}
r = Cmd_Argv(1);
// t->skinframes[0] = skinframe;
t->currentskinframe = skinframe;
t->currentskinframe = skinframe;
- if (gamemode != GAME_BLOODOMNICIDE)
- Con_Printf("%s replaced with %s\n", r, newt);
+ Con_Printf("%s replaced with %s\n", r, newt);
}
else
{
- if (gamemode != GAME_BLOODOMNICIDE)
- Con_Printf("%s was not found\n", newt);
+ Con_Printf("%s was not found\n", newt);
return;
}
}