X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=gl_rsurf.c;h=5cd7f27a3ebafa89394167a4eb3cc14e5a0bba9c;hb=a00d6cf48d4e49715abec095309e203b743d07f7;hp=db9cc5459c272b2d191e0e9f6875d942d39f5b2e;hpb=50099d9c0934fe93646fa2792fa7a9657422333b;p=xonotic%2Fdarkplaces.git diff --git a/gl_rsurf.c b/gl_rsurf.c index db9cc545..5cd7f27a 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -404,7 +404,7 @@ void R_DrawPortals(void) } } -void R_View_WorldVisibility(void) +void R_View_WorldVisibility(qboolean forcenovis) { int i, j, *mark; mleaf_t *leaf; @@ -414,11 +414,34 @@ void R_View_WorldVisibility(void) if (!model) return; + if (r_view.usecustompvs) + { + // clear the visible surface and leaf flags arrays + memset(r_viewcache.world_surfacevisible, 0, model->num_surfaces); + memset(r_viewcache.world_leafvisible, 0, model->brush.num_leafs); + r_viewcache.world_novis = false; + + // simply cull each marked leaf to the frustum (view pyramid) + for (j = 0, leaf = model->brush.data_leafs;j < model->brush.num_leafs;j++, leaf++) + { + // if leaf is in current pvs and on the screen, mark its surfaces + if (CHECKPVSBIT(r_viewcache.world_pvsbits, leaf->clusterindex) && !R_CullBox(leaf->mins, leaf->maxs)) + { + r_refdef.stats.world_leafs++; + r_viewcache.world_leafvisible[j] = true; + if (leaf->numleafsurfaces) + for (i = 0, mark = leaf->firstleafsurface;i < leaf->numleafsurfaces;i++, mark++) + r_viewcache.world_surfacevisible[*mark] = true; + } + } + return; + } + // if possible find the leaf the view origin is in viewleaf = model->brush.PointInLeaf ? model->brush.PointInLeaf(model, r_view.origin) : NULL; // if possible fetch the visible cluster bits if (!r_lockpvs.integer && model->brush.FatPVS) - model->brush.FatPVS(model, r_view.origin, 2, r_viewcache.world_pvsbits, sizeof(r_viewcache.world_pvsbits)); + model->brush.FatPVS(model, r_view.origin, 2, r_viewcache.world_pvsbits, sizeof(r_viewcache.world_pvsbits), false); if (!r_lockvisibility.integer) { @@ -430,7 +453,7 @@ void R_View_WorldVisibility(void) // if floating around in the void (no pvs data available, and no // portals available), simply use all on-screen leafs. - if (!viewleaf || viewleaf->clusterindex < 0) + if (!viewleaf || viewleaf->clusterindex < 0 || forcenovis) { // no visibility method: (used when floating around in the void) // simply cull each leaf to the frustum (view pyramid) @@ -524,9 +547,20 @@ void R_Q1BSP_DrawSky(entity_render_t *ent) if (ent->model == NULL) return; if (ent == r_refdef.worldentity) - R_DrawWorldSurfaces(true, true, false); + R_DrawWorldSurfaces(true, true, false, false, false); + else + R_DrawModelSurfaces(ent, true, true, false, false, false); +} + +void R_Q1BSP_DrawAddWaterPlanes(entity_render_t *ent) +{ + model_t *model = ent->model; + if (model == NULL) + return; + if (ent == r_refdef.worldentity) + R_DrawWorldSurfaces(false, false, false, true, false); else - R_DrawModelSurfaces(ent, true, true, false); + R_DrawModelSurfaces(ent, false, false, false, true, false); } void R_Q1BSP_Draw(entity_render_t *ent) @@ -535,9 +569,9 @@ void R_Q1BSP_Draw(entity_render_t *ent) if (model == NULL) return; if (ent == r_refdef.worldentity) - R_DrawWorldSurfaces(false, true, false); + R_DrawWorldSurfaces(false, true, false, false, false); else - R_DrawModelSurfaces(ent, false, true, false); + R_DrawModelSurfaces(ent, false, true, false, false, false); } void R_Q1BSP_DrawDepth(entity_render_t *ent) @@ -546,9 +580,19 @@ void R_Q1BSP_DrawDepth(entity_render_t *ent) if (model == NULL) return; if (ent == r_refdef.worldentity) - R_DrawWorldSurfaces(false, false, true); + R_DrawWorldSurfaces(false, false, true, false, false); else - R_DrawModelSurfaces(ent, false, false, true); + R_DrawModelSurfaces(ent, false, false, true, false, false); +} + +void R_Q1BSP_DrawDebug(entity_render_t *ent) +{ + if (ent->model == NULL) + return; + if (ent == r_refdef.worldentity) + R_DrawWorldSurfaces(false, false, false, false, true); + else + R_DrawModelSurfaces(ent, false, false, false, false, true); } typedef struct r_q1bsp_getlightinfo_s @@ -930,6 +974,8 @@ void R_Q1BSP_CompileShadowVolume(entity_render_t *ent, vec3_t relativelightorigi r_shadow_compilingrtlight->static_meshchain_shadow = Mod_ShadowMesh_Finish(r_main_mempool, r_shadow_compilingrtlight->static_meshchain_shadow, false, false, true); } +extern cvar_t r_polygonoffset_submodel_factor; +extern cvar_t r_polygonoffset_submodel_offset; void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, vec3_t relativelightdirection, float lightradius, int modelnumsurfaces, const int *modelsurfacelist, const vec3_t lightmins, const vec3_t lightmaxs) { model_t *model = ent->model; @@ -940,6 +986,8 @@ void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, if (!BoxesOverlap(model->normalmins, model->normalmaxs, lightmins, lightmaxs)) return; R_UpdateAllTextureInfo(ent); + if (ent->model->brush.submodel) + GL_PolygonOffset(r_refdef.shadowpolygonfactor + r_polygonoffset_submodel_factor.value, r_refdef.shadowpolygonoffset + r_polygonoffset_submodel_offset.value); if (model->brush.shadowmesh) { R_Shadow_PrepareShadowMark(model->brush.shadowmesh->numtriangles); @@ -968,6 +1016,8 @@ void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, } 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); } + if (ent->model->brush.submodel) + GL_PolygonOffset(r_refdef.shadowpolygonfactor, r_refdef.shadowpolygonoffset); } #define BATCHSIZE 1024 @@ -1138,6 +1188,11 @@ void R_ReplaceWorldTexture (void) int i; const char *r, *newt; skinframe_t *skinframe; + if (!r_refdef.worldmodel) + { + Con_Printf("There is no worldmodel\n"); + return; + } m = r_refdef.worldmodel; if(Cmd_Argc() < 2) @@ -1180,6 +1235,11 @@ void R_ListWorldTextures (void) model_t *m; texture_t *t; int i; + if (!r_refdef.worldmodel) + { + Con_Printf("There is no worldmodel\n"); + return; + } m = r_refdef.worldmodel; Con_Print("Worldmodel textures :\n");