Revert "vis: remove max portals on leaf limit"

This reverts commit b111346cca.
This commit is contained in:
Eric Wasylishen 2017-09-15 14:32:13 -06:00
parent b111346cca
commit 258f69a27f
3 changed files with 29 additions and 29 deletions

View File

@ -24,8 +24,6 @@
#include <common/bspfile.hh>
#include <vis/leafbits.hh>
#include <vector>
#define PORTALFILE "PRT1"
#define PORTALFILE2 "PRT2"
#define PORTALFILEAM "PRT1-AM"
@ -71,20 +69,15 @@ typedef struct passage_s {
sep_t *planes;
} passage_t;
class leaf_t {
public:
passage_t *passages;
std::vector<portal_t *> portals;
int numportals() const {
return static_cast<int>(portals.size());
}
int visofs; // used when writing final visdata
/* Increased MAX_PORTALS_ON_LEAF from 128 */
#define MAX_PORTALS_ON_LEAF 256
leaf_t() :
passages{ nullptr },
portals{},
visofs{ 0 } {}
};
typedef struct leaf_s {
int numportals;
passage_t *passages;
portal_t *portals[MAX_PORTALS_ON_LEAF];
int visofs; // used when writing final visdata
} leaf_t;
#define MAX_SEPARATORS MAX_WINDING
#define STACK_WINDINGS 3 // source, pass and a temp for clipping

View File

@ -195,7 +195,7 @@ RecursiveLeafFlow(int leafnum, threaddata_t *thread, pstack_t *prevstack)
vis = thread->leafvis->bits;
// check all portals for flowing into other leafs
for (i = 0; i < leaf->numportals(); i++) {
for (i = 0; i < leaf->numportals; i++) {
p = leaf->portals[i];
if (!TestLeafBit(prevstack->mightsee, p->leaf)) {
@ -406,7 +406,7 @@ SimpleFlood(portal_t *srcportal, int leafnum, byte *portalsee)
srcportal->nummightsee++;
leaf = &leafs[leafnum];
for (i = 0; i < leaf->numportals(); i++) {
for (i = 0; i < leaf->numportals; i++) {
p = leaf->portals[i];
if (!portalsee[p - portals])
continue;

View File

@ -20,7 +20,7 @@ int portalleafs_real; /* real no. of leafs after expanding PRT2 clusters */
int *clustermap; /* mapping from real leaf to cluster number */
portal_t *portals;
leaf_t *leafs; // new[]/delete[]
leaf_t *leafs;
int c_portaltest, c_portalpass, c_portalcheck, c_mightseeupdate;
int c_noclip = 0;
@ -157,7 +157,7 @@ LogLeaf(const leaf_t *leaf)
if (!verbose)
return;
for (i = 0; i < leaf->numportals(); i++) {
for (i = 0; i < leaf->numportals; i++) {
portal = leaf->portals[i];
plane = &portal->plane;
logprint("portal %4i to leaf %4i : %7.1f : (%4.2f, %4.2f, %4.2f)\n",
@ -404,7 +404,7 @@ UpdateMightsee(const leaf_t *source, const leaf_t *dest)
portal_t *p;
leafnum = dest - leafs;
for (i = 0; i < source->numportals(); i++) {
for (i = 0; i < source->numportals; i++) {
p = source->portals[i];
if (p->status != pstat_none)
continue;
@ -446,7 +446,7 @@ PortalCompleted(portal_t *completed)
* mightsee during the full vis so far.
*/
myleaf = &leafs[completed->leaf];
for (i = 0; i < myleaf->numportals(); i++) {
for (i = 0; i < myleaf->numportals; i++) {
p = myleaf->portals[i];
if (p->status != pstat_done)
continue;
@ -463,7 +463,7 @@ PortalCompleted(portal_t *completed)
* If any of these changed bits are still visible from another
* portal, we can't update yet.
*/
for (k = 0; k < myleaf->numportals(); k++) {
for (k = 0; k < myleaf->numportals; k++) {
if (k == i)
continue;
p2 = myleaf->portals[k];
@ -587,7 +587,7 @@ LeafFlow(int leafnum, bsp2_dleaf_t *dleaf)
*/
outbuffer = uncompressed + leafnum * leafbytes;
leaf = &leafs[leafnum];
for (i = 0; i < leaf->numportals(); i++) {
for (i = 0; i < leaf->numportals; i++) {
p = leaf->portals[i];
if (p->status != pstat_done)
Error("portal not done");
@ -647,7 +647,7 @@ ClusterFlow(int clusternum, leafbits_t *buffer)
*/
leaf = &leafs[clusternum];
numblocks = (portalleafs + LEAFMASK) >> LEAFSHIFT;
for (i = 0; i < leaf->numportals(); i++) {
for (i = 0; i < leaf->numportals; i++) {
p = leaf->portals[i];
if (p->status != pstat_done)
Error("portal not done");
@ -946,9 +946,9 @@ CalcPassages(void)
for (i = 0; i < portalleafs; i++) {
l = &leafs[i];
for (j = 0; j < l->numportals(); j++) {
for (j = 0; j < l->numportals; j++) {
p1 = l->portals[j];
for (k = 0; k < l->numportals(); k++) {
for (k = 0; k < l->numportals; k++) {
if (k == j)
continue;
@ -1079,7 +1079,8 @@ LoadPortals(char *name, bsp2_t *bsp)
portals = static_cast<portal_t *>(malloc(2 * numportals * sizeof(portal_t)));
memset(portals, 0, 2 * numportals * sizeof(portal_t));
leafs = new leaf_t[portalleafs];
leafs = static_cast<leaf_t *>(malloc(portalleafs * sizeof(leaf_t)));
memset(leafs, 0, portalleafs * sizeof(leaf_t));
originalvismapsize = portalleafs_real * ((portalleafs_real + 7) / 8);
@ -1123,7 +1124,10 @@ LoadPortals(char *name, bsp2_t *bsp)
// create forward portal
l = &leafs[leafnums[0]];
l->portals.push_back(p);
if (l->numportals == MAX_PORTALS_ON_LEAF)
Error("Leaf with too many portals");
l->portals[l->numportals] = p;
l->numportals++;
p->winding = w;
VectorSubtract(vec3_origin, plane.normal, p->plane.normal);
@ -1134,7 +1138,10 @@ LoadPortals(char *name, bsp2_t *bsp)
// create backwards portal
l = &leafs[leafnums[1]];
l->portals.push_back(p);
if (l->numportals == MAX_PORTALS_ON_LEAF)
Error("Leaf with too many portals");
l->portals[l->numportals] = p;
l->numportals++;
// Create a reverse winding
p->winding = NewWinding(numpoints);