From d2bd1e5d4f77bd32c204c8a7f4696b00a015b655 Mon Sep 17 00:00:00 2001 From: havoc Date: Wed, 20 Apr 2005 06:02:47 +0000 Subject: [PATCH] enabled portals on q3bsp for a small (occasionally huge) fps increase git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5202 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rsurf.c | 2 +- model_brush.c | 6 +++++- model_shared.h | 3 +-- portals.c | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/gl_rsurf.c b/gl_rsurf.c index fcfdf8c7..82d9af45 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -1593,7 +1593,7 @@ void R_WorldVisibility(void) return; // if possible find the leaf the view origin is in - viewleaf = model->brushq1.PointInLeaf ? model->brushq1.PointInLeaf(model, r_vieworigin) : NULL; + viewleaf = model->brush.PointInLeaf ? model->brush.PointInLeaf(model, r_vieworigin) : NULL; // if possible fetch the visible cluster bits if (model->brush.FatPVS) model->brush.FatPVS(model, r_vieworigin, 2, r_pvsbits, sizeof(r_pvsbits)); diff --git a/model_brush.c b/model_brush.c index 20856b6e..de599574 100644 --- a/model_brush.c +++ b/model_brush.c @@ -2906,7 +2906,7 @@ void Mod_Q1BSP_Load(model_t *mod, void *buffer) mod->brush.FindNonSolidLocation = Mod_Q1BSP_FindNonSolidLocation; mod->brush.AmbientSoundLevelsForPoint = Mod_Q1BSP_AmbientSoundLevelsForPoint; mod->brush.RoundUpToHullSize = Mod_Q1BSP_RoundUpToHullSize; - mod->brushq1.PointInLeaf = Mod_Q1BSP_PointInLeaf; + mod->brush.PointInLeaf = Mod_Q1BSP_PointInLeaf; if (loadmodel->isworldmodel) Cvar_SetValue("halflifebsp", mod->brush.ishlbsp); @@ -5410,6 +5410,7 @@ void Mod_Q3BSP_Load(model_t *mod, void *buffer) mod->brush.BoxTouchingVisibleLeafs = Mod_Q1BSP_BoxTouchingVisibleLeafs; mod->brush.LightPoint = Mod_Q3BSP_LightPoint; mod->brush.FindNonSolidLocation = Mod_Q1BSP_FindNonSolidLocation; + mod->brush.PointInLeaf = Mod_Q1BSP_PointInLeaf; mod->Draw = R_Q1BSP_Draw; mod->GetLightInfo = R_Q1BSP_GetLightInfo; mod->DrawShadowVolume = R_Q1BSP_DrawShadowVolume; @@ -5445,6 +5446,9 @@ void Mod_Q3BSP_Load(model_t *mod, void *buffer) Mod_Q3BSP_LoadPVS(&header->lumps[Q3LUMP_PVS]); loadmodel->brush.numsubmodels = loadmodel->brushq3.num_models; + // the MakePortals code works fine on the q3bsp data as well + Mod_Q1BSP_MakePortals(); + // make a single combined shadow mesh to allow optimized shadow volume creation numshadowmeshtriangles = 0; for (j = 0, surface = loadmodel->brush.data_surfaces;j < loadmodel->brush.num_surfaces;j++, surface++) diff --git a/model_shared.h b/model_shared.h index 349a9619..cf8aaf3a 100644 --- a/model_shared.h +++ b/model_shared.h @@ -239,6 +239,7 @@ typedef struct model_brush_s int (*BoxTouchingVisibleLeafs)(struct model_s *model, const qbyte *visibleleafs, const vec3_t mins, const vec3_t maxs); void (*LightPoint)(struct model_s *model, const vec3_t p, vec3_t ambientcolor, vec3_t diffusecolor, vec3_t diffusenormal); void (*FindNonSolidLocation)(struct model_s *model, const vec3_t in, vec3_t out, vec_t radius); + mleaf_t *(*PointInLeaf)(struct model_s *model, const float *p); // these are actually only found on brushq1, but NULL is handled gracefully void (*AmbientSoundLevelsForPoint)(struct model_s *model, const vec3_t p, qbyte *out, int outsize); void (*RoundUpToHullSize)(struct model_s *cmodel, const vec3_t inmins, const vec3_t inmaxs, vec3_t outmins, vec3_t outmaxs); @@ -289,8 +290,6 @@ typedef struct model_brushq1_s int *light_stylevalue; msurface_t ***light_styleupdatechains; msurface_t **light_styleupdatechainsbuffer; - - mleaf_t *(*PointInLeaf)(struct model_s *model, const float *p); } model_brushq1_t; diff --git a/portals.c b/portals.c index f6f85766..4f62b17e 100644 --- a/portals.c +++ b/portals.c @@ -187,7 +187,7 @@ int Portal_CheckPolygon(model_t *model, vec3_t eye, float *polypoints, int numpo vec3_t center, v1, v2; // if there is no model, it can not block visibility - if (model == NULL || !model->brushq1.PointInLeaf) + if (model == NULL || !model->brush.PointInLeaf) return true; portal_markid++; @@ -195,7 +195,7 @@ int Portal_CheckPolygon(model_t *model, vec3_t eye, float *polypoints, int numpo Mod_CheckLoaded(model); Portal_PolygonRecursiveMarkLeafs(model->brush.data_nodes, polypoints, numpoints); - eyeleaf = model->brushq1.PointInLeaf(model, eye); + eyeleaf = model->brush.PointInLeaf(model, eye); // find the center by averaging VectorClear(center); -- 2.39.2