diff --git a/include/QF/model.h b/include/QF/model.h index 2489dfb88..3ec574062 100644 --- a/include/QF/model.h +++ b/include/QF/model.h @@ -199,7 +199,7 @@ typedef struct mleaf_s { byte *compressed_vis; efrag_t *efrags; - msurface_t **firstmarksurface; + int firstmarksurface; int nummarksurfaces; int key; // BSP sequence number for leaf's contents byte ambient_sound_level[NUM_AMBIENTS]; diff --git a/libs/models/brush/model_brush.c b/libs/models/brush/model_brush.c index ee307da3d..a13ed16ba 100644 --- a/libs/models/brush/model_brush.c +++ b/libs/models/brush/model_brush.c @@ -683,8 +683,9 @@ Mod_SetLeafFlags (mod_brush_t *brush) for (unsigned i = 0; i < brush->modleafs; i++) { int flags = 0; mleaf_t *leaf = &brush->leafs[i]; + msurface_t **msurf = brush->marksurfaces + leaf->firstmarksurface; for (int j = 0; j < leaf->nummarksurfaces; j++) { - msurface_t *surf = leaf->firstmarksurface[j]; + msurface_t *surf = *msurf++; flags |= surf->flags; } brush->leaf_flags[i] = flags; @@ -780,7 +781,7 @@ Mod_LoadLeafs (model_t *mod, bsp_t *bsp) p = in->contents; out->contents = p; - out->firstmarksurface = brush->marksurfaces + in->firstmarksurface; + out->firstmarksurface = in->firstmarksurface; out->nummarksurfaces = in->nummarksurfaces; p = in->visofs; @@ -795,12 +796,18 @@ Mod_LoadLeafs (model_t *mod, bsp_t *bsp) // gl underwater warp if (out->contents != CONTENTS_EMPTY) { - for (j = 0; j < out->nummarksurfaces; j++) - out->firstmarksurface[j]->flags |= SURF_UNDERWATER; + msurface_t **msurf = brush->marksurfaces + out->firstmarksurface; + for (j = 0; j < out->nummarksurfaces; j++) { + msurface_t *surf = *msurf++; + surf->flags |= SURF_UNDERWATER; + } } if (isnotmap) { - for (j = 0; j < out->nummarksurfaces; j++) - out->firstmarksurface[j]->flags |= SURF_DONTWARP; + msurface_t **msurf = brush->marksurfaces + out->firstmarksurface; + for (j = 0; j < out->nummarksurfaces; j++) { + msurface_t *surf = *msurf++; + surf->flags |= SURF_DONTWARP; + } } } } diff --git a/libs/video/renderer/r_bsp.c b/libs/video/renderer/r_bsp.c index 2976bda16..f534d4b1b 100644 --- a/libs/video/renderer/r_bsp.c +++ b/libs/video/renderer/r_bsp.c @@ -79,7 +79,7 @@ R_MarkLeaves (mleaf_t *viewleaf) if (set_is_member (vis, i)) { leaf = &brush->leafs[i + 1]; if ((c = leaf->nummarksurfaces)) { - mark = leaf->firstmarksurface; + mark = brush->marksurfaces + leaf->firstmarksurface; do { (*mark)->visframe = r_visframecount; mark++; diff --git a/libs/video/renderer/r_light.c b/libs/video/renderer/r_light.c index 4949ad3e4..5c805fb54 100644 --- a/libs/video/renderer/r_light.c +++ b/libs/video/renderer/r_light.c @@ -304,8 +304,9 @@ R_MarkLights (const vec3_t lightorigin, dlight_t *light, int lightnum, continue; if (R_CullBox (r_refdef.frustum, leaf->mins, leaf->maxs)) continue; + msurface_t **msurf = brush->marksurfaces + leaf->firstmarksurface; for (m = 0; m < leaf->nummarksurfaces; m++) { - msurface_t *surf = leaf->firstmarksurface[m]; + msurface_t *surf = *msurf++; if (surf->visframe != r_visframecount) continue; mark_surfaces (surf, lightorigin, light, lightnum);