mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-20 18:52:28 +00:00
[qfvis] Add an option to limit the processed portals
It's not documented as I needed it for debugging memory allocations and it causes qfvis to error out due to unprocessed portals.
This commit is contained in:
parent
f2b6b23acc
commit
3ef38188ce
3 changed files with 24 additions and 10 deletions
|
@ -35,6 +35,7 @@ typedef struct {
|
|||
int threads;
|
||||
qboolean minimal;
|
||||
int level;
|
||||
size_t portal_limit;
|
||||
struct dstring_s *bspfile;
|
||||
} options_t;
|
||||
|
||||
|
|
|
@ -46,6 +46,11 @@
|
|||
|
||||
const char *this_program;
|
||||
|
||||
enum {
|
||||
start_opts = 255, // not used, starts the enum.
|
||||
OPT_PORTAL_LIMIT,
|
||||
};
|
||||
|
||||
static struct option const long_options[] = {
|
||||
{"quiet", no_argument, 0, 'q'},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
|
@ -55,6 +60,7 @@ static struct option const long_options[] = {
|
|||
{"minimal", no_argument, 0, 'm'},
|
||||
{"level", required_argument, 0, 'l'},
|
||||
{"file", required_argument, 0, 'f'},
|
||||
{"portal-limit", required_argument, 0, OPT_PORTAL_LIMIT},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
|
@ -131,6 +137,9 @@ DecodeArgs (int argc, char **argv)
|
|||
case 't': // threads
|
||||
options.threads = atoi (optarg);
|
||||
break;
|
||||
case OPT_PORTAL_LIMIT:
|
||||
options.portal_limit = atoi (optarg);
|
||||
break;
|
||||
case 'm': // minimal vis
|
||||
options.minimal = true;
|
||||
break;
|
||||
|
|
|
@ -294,16 +294,20 @@ ClipWinding (threaddata_t *thread, winding_t *in, const plane_t *split, qboolean
|
|||
}
|
||||
|
||||
static portal_t *
|
||||
GetNextPortal (void)
|
||||
GetNextPortal (int limit)
|
||||
{
|
||||
portal_t *p = 0;
|
||||
|
||||
WRLOCK (global_lock);
|
||||
if (portal_count < 2 * numportals) {
|
||||
p = portal_queue[portal_count++];
|
||||
p->status = stat_selected;
|
||||
if (!(limit
|
||||
&& options.portal_limit > 0
|
||||
&& portal_count >= options.portal_limit)) {
|
||||
WRLOCK (global_lock);
|
||||
if (portal_count < 2 * numportals) {
|
||||
p = portal_queue[portal_count++];
|
||||
p->status = stat_selected;
|
||||
}
|
||||
UNLOCK (global_lock);
|
||||
}
|
||||
UNLOCK (global_lock);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -390,7 +394,7 @@ LeafThread (void *_thread)
|
|||
set_pool_init (&data.set_pool);
|
||||
data.memsuper = new_memsuper ();
|
||||
do {
|
||||
portal = GetNextPortal ();
|
||||
portal = GetNextPortal (1);
|
||||
if (!portal)
|
||||
break;
|
||||
|
||||
|
@ -430,7 +434,7 @@ BaseVisThread (void *_thread)
|
|||
set_pool_init (&set_pool);
|
||||
data.portalsee = set_new_size_r (&set_pool, numportals * 2);
|
||||
do {
|
||||
portal = GetNextPortal ();
|
||||
portal = GetNextPortal (0);
|
||||
if (!portal)
|
||||
break;
|
||||
|
||||
|
@ -693,8 +697,6 @@ CalcPortalVis (void)
|
|||
unsigned i;
|
||||
double start, end;
|
||||
|
||||
portal_count = 0;
|
||||
|
||||
// fastvis just uses mightsee for a very loose bound
|
||||
if (options.minimal) {
|
||||
for (i = 0; i < numportals * 2; i++) {
|
||||
|
@ -714,6 +716,8 @@ CalcPortalVis (void)
|
|||
if (options.verbosity >= 1)
|
||||
printf ("\n");
|
||||
|
||||
portal_count = 0;
|
||||
|
||||
RunThreads (LeafThread);
|
||||
|
||||
if (options.verbosity > 0) {
|
||||
|
|
Loading…
Reference in a new issue