From: havoc Date: Wed, 2 May 2018 07:17:13 +0000 (+0000) Subject: Remove model->surfmesh.shadowmesh which was a vertex-welded version of the regular... X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=fe52804d325b7688cab684f2b83ba1106702a2aa Remove model->surfmesh.shadowmesh which was a vertex-welded version of the regular surfmesh, we don't need that as we're not computing triangle neighbors as shadow volume support was removed. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12415 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/gl_rsurf.c b/gl_rsurf.c index 42250c5a..b66fafdd 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -900,11 +900,11 @@ static void R_Q1BSP_RecursiveGetLightInfo_BSP(r_q1bsp_getlightinfo_t *info, qboo 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]); @@ -928,11 +928,11 @@ static void R_Q1BSP_RecursiveGetLightInfo_BSP(r_q1bsp_getlightinfo_t *info, qboo 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]); @@ -1027,11 +1027,11 @@ static void R_Q1BSP_RecursiveGetLightInfo_BIH(r_q1bsp_getlightinfo_t *info, cons 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]); @@ -1142,10 +1142,7 @@ static void R_Q1BSP_CallRecursiveGetLightInfo(r_q1bsp_getlightinfo_t *info, qboo 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 @@ -1251,10 +1248,7 @@ void R_Q1BSP_GetLightInfo(entity_render_t *ent, vec3_t relativelightorigin, floa 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); @@ -1307,21 +1301,19 @@ void R_Q1BSP_CompileShadowMap(entity_render_t *ent, vec3_t 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++) diff --git a/model_brush.c b/model_brush.c index 0cd1e191..7305b912 100644 --- a/model_brush.c +++ b/model_brush.c @@ -3852,29 +3852,6 @@ static void Mod_Q1BSP_RoundUpToHullSize(dp_model_t *cmodel, const vec3_t inmins, 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) @@ -4039,9 +4016,6 @@ 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 *)); @@ -5025,9 +4999,6 @@ static void Mod_Q2BSP_Load(dp_model_t *mod, void *buffer, void *bufferend) 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 *)); @@ -7992,9 +7963,6 @@ static void Mod_Q3BSP_Load(dp_model_t *mod, void *buffer, void *bufferend) // 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); @@ -8611,9 +8579,6 @@ void Mod_OBJ_Load(dp_model_t *mod, void *buffer, void *bufferend) 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++) diff --git a/model_shared.h b/model_shared.h index 54331d1a..2544036f 100644 --- a/model_shared.h +++ b/model_shared.h @@ -744,9 +744,6 @@ typedef struct msurface_s int num_vertices; // number of vertices int num_firstvertex; // first vertex - // shadow volume building information - int num_firstshadowmeshtriangle; // index into model->brush.shadowmesh - // mesh information for collisions (only used by q3bsp curves) int num_collisiontriangles; // q3bsp int num_collisionvertices; // q3bsp diff --git a/r_shadow.c b/r_shadow.c index 303322c4..ac97241c 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -3087,7 +3087,7 @@ void R_RTLight_Compile(rtlight_t *rtlight) 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; @@ -3706,7 +3706,7 @@ static void R_Shadow_PrepareLight(rtlight_t *rtlight) 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); @@ -4173,7 +4173,7 @@ void R_Shadow_PrepareLights(void) 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;