if (!castshadow)
continue;
insidebox = BoxInsideBox(surface->mins, surface->maxs, info->lightmins, info->lightmaxs);
- for (triangleindex = 0, t = surface->num_firstshadowmeshtriangle, e = info->model->brush.shadowmesh->element3i + t * 3;triangleindex < surface->num_triangles;triangleindex++, t++, e += 3)
+ for (triangleindex = 0, t = surface->num_firsttriangle, e = info->model->surfmesh.data_element3i + t * 3;triangleindex < surface->num_triangles;triangleindex++, t++, e += 3)
{
- v[0] = info->model->brush.shadowmesh->vertex3f + e[0] * 3;
- v[1] = info->model->brush.shadowmesh->vertex3f + e[1] * 3;
- v[2] = info->model->brush.shadowmesh->vertex3f + e[2] * 3;
+ v[0] = info->model->surfmesh.data_vertex3f + e[0] * 3;
+ v[1] = info->model->surfmesh.data_vertex3f + e[1] * 3;
+ v[2] = info->model->surfmesh.data_vertex3f + e[2] * 3;
VectorCopy(v[0], v2[0]);
VectorCopy(v[1], v2[1]);
VectorCopy(v[2], v2[2]);
currentmaterialflags = R_GetCurrentTexture(surface->texture)->currentmaterialflags;
castshadow = !(currentmaterialflags & MATERIALFLAG_NOSHADOW);
insidebox = BoxInsideBox(surface->mins, surface->maxs, info->lightmins, info->lightmaxs);
- for (triangleindex = 0, t = surface->num_firstshadowmeshtriangle, e = info->model->brush.shadowmesh->element3i + t * 3;triangleindex < surface->num_triangles;triangleindex++, t++, e += 3)
+ for (triangleindex = 0, t = surface->num_firsttriangle, e = info->model->surfmesh.data_element3i + t * 3;triangleindex < surface->num_triangles;triangleindex++, t++, e += 3)
{
- v[0] = info->model->brush.shadowmesh->vertex3f + e[0] * 3;
- v[1] = info->model->brush.shadowmesh->vertex3f + e[1] * 3;
- v[2] = info->model->brush.shadowmesh->vertex3f + e[2] * 3;
+ v[0] = info->model->surfmesh.data_vertex3f + e[0] * 3;
+ v[1] = info->model->surfmesh.data_vertex3f + e[1] * 3;
+ v[2] = info->model->surfmesh.data_vertex3f + e[2] * 3;
VectorCopy(v[0], v2[0]);
VectorCopy(v[1], v2[1]);
VectorCopy(v[2], v2[2]);
surface = info->model->data_surfaces + surfaceindex;
currentmaterialflags = R_GetCurrentTexture(surface->texture)->currentmaterialflags;
castshadow = !(currentmaterialflags & MATERIALFLAG_NOSHADOW);
- t = leaf->itemindex + surface->num_firstshadowmeshtriangle - surface->num_firsttriangle;
- e = info->model->brush.shadowmesh->element3i + t * 3;
- v[0] = info->model->brush.shadowmesh->vertex3f + e[0] * 3;
- v[1] = info->model->brush.shadowmesh->vertex3f + e[1] * 3;
- v[2] = info->model->brush.shadowmesh->vertex3f + e[2] * 3;
+ t = leaf->itemindex;
+ e = info->model->surfmesh.data_element3i + t * 3;
+ v[0] = info->model->surfmesh.data_vertex3f + e[0] * 3;
+ v[1] = info->model->surfmesh.data_vertex3f + e[1] * 3;
+ v[2] = info->model->surfmesh.data_vertex3f + e[2] * 3;
VectorCopy(v[0], v2[0]);
VectorCopy(v[1], v2[1]);
VectorCopy(v[2], v2[2]);
info->outnumsurfaces = 0;
memset(info->outleafpvs, 0, (info->model->brush.num_leafs + 7) >> 3);
memset(info->outsurfacepvs, 0, (info->model->nummodelsurfaces + 7) >> 3);
- if (info->model->brush.shadowmesh)
- memset(info->outshadowtrispvs, 0, (info->model->brush.shadowmesh->numtriangles + 7) >> 3);
- else
- memset(info->outshadowtrispvs, 0, (info->model->surfmesh.num_triangles + 7) >> 3);
+ memset(info->outshadowtrispvs, 0, (info->model->surfmesh.num_triangles + 7) >> 3);
memset(info->outlighttrispvs, 0, (info->model->surfmesh.num_triangles + 7) >> 3);
}
else
memset(visitingleafpvs, 0, (info.model->brush.num_leafs + 7) >> 3);
memset(outleafpvs, 0, (info.model->brush.num_leafs + 7) >> 3);
memset(outsurfacepvs, 0, (info.model->nummodelsurfaces + 7) >> 3);
- if (info.model->brush.shadowmesh)
- memset(outshadowtrispvs, 0, (info.model->brush.shadowmesh->numtriangles + 7) >> 3);
- else
- memset(outshadowtrispvs, 0, (info.model->surfmesh.num_triangles + 7) >> 3);
+ memset(outshadowtrispvs, 0, (info.model->surfmesh.num_triangles + 7) >> 3);
memset(outlighttrispvs, 0, (info.model->surfmesh.num_triangles + 7) >> 3);
if (info.model->brush.GetPVS && !info.noocclusion)
info.pvs = info.model->brush.GetPVS(info.model, info.relativelightorigin);
int surfacelistindex;
int sidetotals[6] = { 0, 0, 0, 0, 0, 0 }, sidemasks = 0;
int i;
- if (!model->brush.shadowmesh)
- return;
// FIXME: the sidetotals code incorrectly assumes that static_meshchain is
// a single mesh - to prevent that from crashing (sideoffsets, sidetotals
// exceeding the number of triangles in a single mesh) we have to make sure
// that we make only a single mesh - so over-estimate the size of the mesh
// to match the model.
r_shadow_compilingrtlight->static_meshchain_shadow_shadowmap = Mod_ShadowMesh_Begin(r_main_mempool, model->surfmesh.num_vertices, model->surfmesh.num_triangles, NULL, NULL, NULL, false, true);
- R_Shadow_PrepareShadowSides(model->brush.shadowmesh->numtriangles);
+ R_Shadow_PrepareShadowSides(model->surfmesh.num_triangles);
for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
{
surface = model->data_surfaces + surfacelist[surfacelistindex];
- sidemasks |= R_Shadow_ChooseSidesFromBox(surface->num_firstshadowmeshtriangle, surface->num_triangles, model->brush.shadowmesh->vertex3f, model->brush.shadowmesh->element3i, &r_shadow_compilingrtlight->matrix_worldtolight, relativelightorigin, relativelightdirection, r_shadow_compilingrtlight->cullmins, r_shadow_compilingrtlight->cullmaxs, surface->mins, surface->maxs, surface->texture->basematerialflags & MATERIALFLAG_NOSHADOW ? NULL : sidetotals);
+ sidemasks |= R_Shadow_ChooseSidesFromBox(surface->num_firsttriangle, surface->num_triangles, model->surfmesh.data_vertex3f, model->surfmesh.data_element3i, &r_shadow_compilingrtlight->matrix_worldtolight, relativelightorigin, relativelightdirection, r_shadow_compilingrtlight->cullmins, r_shadow_compilingrtlight->cullmaxs, surface->mins, surface->maxs, surface->texture->basematerialflags & MATERIALFLAG_NOSHADOW ? NULL : sidetotals);
}
- R_Shadow_ShadowMapFromList(model->brush.shadowmesh->numverts, model->brush.shadowmesh->numtriangles, model->brush.shadowmesh->vertex3f, model->brush.shadowmesh->element3i, numshadowsides, sidetotals, shadowsides, shadowsideslist);
+ R_Shadow_ShadowMapFromList(model->surfmesh.num_vertices, model->surfmesh.num_triangles, model->surfmesh.data_vertex3f, model->surfmesh.data_element3i, numshadowsides, sidetotals, shadowsides, shadowsideslist);
r_shadow_compilingrtlight->static_meshchain_shadow_shadowmap = Mod_ShadowMesh_Finish(r_main_mempool, r_shadow_compilingrtlight->static_meshchain_shadow_shadowmap, false, true);
r_shadow_compilingrtlight->static_shadowmap_receivers &= sidemasks;
for(i = 0;i<6;i++)
VectorAdd(inmins, hull->clip_size, outmaxs);
}
-static int Mod_Q1BSP_CreateShadowMesh(dp_model_t *mod)
-{
- int j;
- int numshadowmeshtriangles = 0;
- msurface_t *surface;
- if (cls.state == ca_dedicated)
- return 0;
- // make a single combined shadow mesh to allow optimized shadow volume creation
-
- for (j = 0, surface = mod->data_surfaces;j < mod->num_surfaces;j++, surface++)
- {
- surface->num_firstshadowmeshtriangle = numshadowmeshtriangles;
- numshadowmeshtriangles += surface->num_triangles;
- }
- mod->brush.shadowmesh = Mod_ShadowMesh_Begin(mod->mempool, numshadowmeshtriangles * 3, numshadowmeshtriangles, NULL, NULL, NULL, false, true);
- for (j = 0, surface = mod->data_surfaces;j < mod->num_surfaces;j++, surface++)
- if (surface->num_triangles > 0)
- Mod_ShadowMesh_AddMesh(mod->mempool, mod->brush.shadowmesh, NULL, NULL, NULL, mod->surfmesh.data_vertex3f, NULL, NULL, NULL, NULL, surface->num_triangles, (mod->surfmesh.data_element3i + 3 * surface->num_firsttriangle));
- mod->brush.shadowmesh = Mod_ShadowMesh_Finish(mod->mempool, mod->brush.shadowmesh, false, false);
-
- return numshadowmeshtriangles;
-}
-
void Mod_CollisionBIH_TraceLineAgainstSurfaces(dp_model_t *model, const frameblend_t *frameblend, const skeleton_t *skeleton, trace_t *trace, const vec3_t start, const vec3_t end, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask);
void Mod_Q1BSP_Load(dp_model_t *mod, void *buffer, void *bufferend)
mod->numframes = 2; // regular and alternate animation
mod->numskins = 1;
- // make a single combined shadow mesh to allow optimized shadow volume creation
- Mod_Q1BSP_CreateShadowMesh(loadmodel);
-
if (loadmodel->brush.numsubmodels)
loadmodel->brush.submodels = (dp_model_t **)Mem_Alloc(loadmodel->mempool, loadmodel->brush.numsubmodels * sizeof(dp_model_t *));
mod->numframes = 0; // q2bsp animations are kind of special, frame is unbounded...
mod->numskins = 1;
- // make a single combined shadow mesh to allow optimized shadow volume creation
- Mod_Q1BSP_CreateShadowMesh(loadmodel);
-
if (loadmodel->brush.numsubmodels)
loadmodel->brush.submodels = (dp_model_t **)Mem_Alloc(loadmodel->mempool, loadmodel->brush.numsubmodels * sizeof(dp_model_t *));
// FIXME: shader alpha should replace r_wateralpha support in q3bsp
loadmodel->brush.supportwateralpha = true;
- // make a single combined shadow mesh to allow optimized shadow volume creation
- Mod_Q1BSP_CreateShadowMesh(loadmodel);
-
loadmodel->brush.num_leafs = 0;
Mod_Q3BSP_RecursiveFindNumLeafs(loadmodel->brush.data_nodes);
Mem_Free(vertexhashtable);
Mem_Free(vertexhashdata);
- // make a single combined shadow mesh to allow optimized shadow volume creation
- Mod_Q1BSP_CreateShadowMesh(loadmodel);
-
// compute all the mesh information that was not loaded from the file
if (loadmodel->surfmesh.data_element3s)
for (i = 0;i < loadmodel->surfmesh.num_triangles*3;i++)
model->GetLightInfo(ent, rtlight->shadoworigin, rtlight->radius, rtlight->cullmins, rtlight->cullmaxs, r_shadow_buffer_leaflist, r_shadow_buffer_leafpvs, &numleafs, r_shadow_buffer_surfacelist, r_shadow_buffer_surfacepvs, &numsurfaces, r_shadow_buffer_shadowtrispvs, r_shadow_buffer_lighttrispvs, r_shadow_buffer_visitingleafpvs, 0, NULL, rtlight->shadow == 0);
R_FrameData_ReturnToMark();
numleafpvsbytes = (model->brush.num_leafs + 7) >> 3;
- numshadowtrispvsbytes = ((model->brush.shadowmesh ? model->brush.shadowmesh->numtriangles : model->surfmesh.num_triangles) + 7) >> 3;
+ numshadowtrispvsbytes = (model->surfmesh.num_triangles + 7) >> 3;
numlighttrispvsbytes = (model->surfmesh.num_triangles + 7) >> 3;
data = (unsigned char *)Mem_Alloc(r_main_mempool, sizeof(int) * numsurfaces + sizeof(int) * numleafs + numleafpvsbytes + numshadowtrispvsbytes + numlighttrispvsbytes);
rtlight->static_numsurfaces = numsurfaces;
rtlight->cached_shadowentities_noselfshadow = (entity_render_t**)R_FrameData_Store(numshadowentities_noselfshadow*sizeof(entity_render_t *), (void*)shadowentities_noselfshadow);
if (shadowtrispvs == r_shadow_buffer_shadowtrispvs)
{
- int numshadowtrispvsbytes = (((r_refdef.scene.worldmodel->brush.shadowmesh ? r_refdef.scene.worldmodel->brush.shadowmesh->numtriangles : r_refdef.scene.worldmodel->surfmesh.num_triangles) + 7) >> 3);
+ int numshadowtrispvsbytes = ((r_refdef.scene.worldmodel->surfmesh.num_triangles + 7) >> 3);
int numlighttrispvsbytes = ((r_refdef.scene.worldmodel->surfmesh.num_triangles + 7) >> 3);
rtlight->cached_shadowtrispvs = (unsigned char *)R_FrameData_Store(numshadowtrispvsbytes, shadowtrispvs);
rtlight->cached_lighttrispvs = (unsigned char *)R_FrameData_Store(numlighttrispvsbytes, lighttrispvs);
break;
}
- R_Shadow_EnlargeLeafSurfaceTrisBuffer(r_refdef.scene.worldmodel->brush.num_leafs, r_refdef.scene.worldmodel->num_surfaces, r_refdef.scene.worldmodel->brush.shadowmesh ? r_refdef.scene.worldmodel->brush.shadowmesh->numtriangles : r_refdef.scene.worldmodel->surfmesh.num_triangles, r_refdef.scene.worldmodel->surfmesh.num_triangles);
+ R_Shadow_EnlargeLeafSurfaceTrisBuffer(r_refdef.scene.worldmodel->brush.num_leafs, r_refdef.scene.worldmodel->num_surfaces, r_refdef.scene.worldmodel->surfmesh.num_triangles, r_refdef.scene.worldmodel->surfmesh.num_triangles);
r_shadow_scenenumlights = 0;
flag = r_refdef.scene.rtworld ? LIGHTFLAG_REALTIMEMODE : LIGHTFLAG_NORMALMODE;