2008-07-25 07:31:37 +00:00
|
|
|
/* -------------------------------------------------------------------------------
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
Copyright (C) 1999-2007 id Software, Inc. and contributors.
|
|
|
|
For a list of contributors, see the accompanying CONTRIBUTORS file.
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
This file is part of GtkRadiant.
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
GtkRadiant is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
GtkRadiant is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with GtkRadiant; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
----------------------------------------------------------------------------------
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
This code has been altered significantly from its original form, to support
|
|
|
|
several games based on the Quake III Arena engine, in the form of "Q3Map2."
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
------------------------------------------------------------------------------- */
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* marker */
|
|
|
|
#define FACEBSP_C
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* dependencies */
|
|
|
|
#include "q3map2.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
int c_faceLeafs;
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
================
|
|
|
|
AllocBspFace
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
face_t *AllocBspFace( void ) {
|
|
|
|
face_t *f;
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
f = safe_malloc( sizeof( *f ) );
|
|
|
|
memset( f, 0, sizeof( *f ) );
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
================
|
|
|
|
FreeBspFace
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void FreeBspFace( face_t *f ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
if ( f->w ) {
|
|
|
|
FreeWinding( f->w );
|
|
|
|
}
|
|
|
|
free( f );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
SelectSplitPlaneNum()
|
|
|
|
finds the best split plane for this node
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void SelectSplitPlaneNum( node_t *node, face_t *list, int *splitPlaneNum, int *compileFlags ){
|
|
|
|
face_t *split;
|
|
|
|
face_t *check;
|
|
|
|
face_t *bestSplit;
|
|
|
|
int splits, facing, front, back;
|
|
|
|
int side;
|
|
|
|
plane_t *plane;
|
|
|
|
int value, bestValue;
|
|
|
|
int i;
|
|
|
|
vec3_t normal;
|
|
|
|
float dist;
|
|
|
|
int planenum;
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: set some defaults */
|
|
|
|
*splitPlaneNum = -1; /* leaf */
|
|
|
|
*compileFlags = 0;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar 2002-06-24: changed this to split on z-axis as well */
|
|
|
|
/* ydnar 2002-09-21: changed blocksize to be a vector, so mappers can specify a 3 element value */
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* if it is crossing a block boundary, force a split */
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < 3; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( blockSize[ i ] <= 0 ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
continue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
dist = blockSize[ i ] * ( floor( node->mins[ i ] / blockSize[ i ] ) + 1 );
|
|
|
|
if ( node->maxs[ i ] > dist ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
VectorClear( normal );
|
|
|
|
normal[ i ] = 1;
|
|
|
|
planenum = FindFloatPlane( normal, dist, 0, NULL );
|
|
|
|
*splitPlaneNum = planenum;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* pick one of the face planes */
|
|
|
|
bestValue = -99999;
|
|
|
|
bestSplit = list;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
|
|
|
for ( split = list; split; split = split->next )
|
2007-11-04 03:34:51 +00:00
|
|
|
split->checked = qfalse;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
|
|
|
for ( split = list; split; split = split->next )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( split->checked ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
continue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
plane = &mapplanes[ split->planenum ];
|
|
|
|
splits = 0;
|
|
|
|
facing = 0;
|
|
|
|
front = 0;
|
|
|
|
back = 0;
|
|
|
|
for ( check = list ; check ; check = check->next ) {
|
|
|
|
if ( check->planenum == split->planenum ) {
|
|
|
|
facing++;
|
2012-03-17 20:01:54 +00:00
|
|
|
check->checked = qtrue; // won't need to test this plane again
|
2007-11-04 03:34:51 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
side = WindingOnPlaneSide( check->w, plane->normal, plane->dist );
|
|
|
|
if ( side == SIDE_CROSS ) {
|
|
|
|
splits++;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else if ( side == SIDE_FRONT ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
front++;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else if ( side == SIDE_BACK ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
back++;
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
value = 5 * facing - 5 * splits; // - abs(front-back);
|
2007-11-04 03:34:51 +00:00
|
|
|
if ( plane->type < 3 ) {
|
2012-03-17 20:01:54 +00:00
|
|
|
value += 5; // axial is better
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
value += split->priority; // prioritize hints higher
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
if ( value > bestValue ) {
|
|
|
|
bestValue = value;
|
|
|
|
bestSplit = split;
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* nothing, we have a leaf */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( bestValue == -99999 ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* set best split data */
|
|
|
|
*splitPlaneNum = bestSplit->planenum;
|
|
|
|
*compileFlags = bestSplit->compileFlags;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
CountFaceList()
|
|
|
|
counts bsp faces in the linked list
|
|
|
|
*/
|
|
|
|
|
|
|
|
int CountFaceList( face_t *list ){
|
|
|
|
int c;
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
c = 0;
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( ; list != NULL; list = list->next )
|
2007-11-04 03:34:51 +00:00
|
|
|
c++;
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
BuildFaceTree_r()
|
|
|
|
recursively builds the bsp, splitting on face planes
|
|
|
|
*/
|
|
|
|
|
|
|
|
void BuildFaceTree_r( node_t *node, face_t *list ){
|
|
|
|
face_t *split;
|
|
|
|
face_t *next;
|
|
|
|
int side;
|
|
|
|
plane_t *plane;
|
|
|
|
face_t *newFace;
|
|
|
|
face_t *childLists[2];
|
|
|
|
winding_t *frontWinding, *backWinding;
|
|
|
|
int i;
|
|
|
|
int splitPlaneNum, compileFlags;
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* count faces left */
|
|
|
|
i = CountFaceList( list );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* select the best split plane */
|
|
|
|
SelectSplitPlaneNum( node, list, &splitPlaneNum, &compileFlags );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* if we don't have any more faces, this is a node */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( splitPlaneNum == -1 ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
node->planenum = PLANENUM_LEAF;
|
|
|
|
c_faceLeafs++;
|
|
|
|
return;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* partition the list */
|
|
|
|
node->planenum = splitPlaneNum;
|
|
|
|
node->compileFlags = compileFlags;
|
|
|
|
plane = &mapplanes[ splitPlaneNum ];
|
|
|
|
childLists[0] = NULL;
|
|
|
|
childLists[1] = NULL;
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( split = list; split; split = next )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
/* set next */
|
|
|
|
next = split->next;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* don't split by identical plane */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( split->planenum == node->planenum ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
FreeBspFace( split );
|
|
|
|
continue;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* determine which side the face falls on */
|
|
|
|
side = WindingOnPlaneSide( split->w, plane->normal, plane->dist );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* switch on side */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( side == SIDE_CROSS ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
ClipWindingEpsilon( split->w, plane->normal, plane->dist, CLIP_EPSILON * 2,
|
2012-03-17 20:01:54 +00:00
|
|
|
&frontWinding, &backWinding );
|
|
|
|
if ( frontWinding ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
newFace = AllocBspFace();
|
|
|
|
newFace->w = frontWinding;
|
|
|
|
newFace->next = childLists[0];
|
|
|
|
newFace->planenum = split->planenum;
|
|
|
|
newFace->priority = split->priority;
|
|
|
|
newFace->compileFlags = split->compileFlags;
|
|
|
|
childLists[0] = newFace;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( backWinding ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
newFace = AllocBspFace();
|
|
|
|
newFace->w = backWinding;
|
|
|
|
newFace->next = childLists[1];
|
|
|
|
newFace->planenum = split->planenum;
|
|
|
|
newFace->priority = split->priority;
|
|
|
|
newFace->compileFlags = split->compileFlags;
|
|
|
|
childLists[1] = newFace;
|
|
|
|
}
|
|
|
|
FreeBspFace( split );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else if ( side == SIDE_FRONT ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
split->next = childLists[0];
|
|
|
|
childLists[0] = split;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else if ( side == SIDE_BACK ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
split->next = childLists[1];
|
|
|
|
childLists[1] = split;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// recursively process children
|
|
|
|
for ( i = 0 ; i < 2 ; i++ ) {
|
|
|
|
node->children[i] = AllocNode();
|
|
|
|
node->children[i]->parent = node;
|
|
|
|
VectorCopy( node->mins, node->children[i]->mins );
|
|
|
|
VectorCopy( node->maxs, node->children[i]->maxs );
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( i = 0 ; i < 3 ; i++ ) {
|
|
|
|
if ( plane->normal[i] == 1 ) {
|
|
|
|
node->children[0]->mins[i] = plane->dist;
|
|
|
|
node->children[1]->maxs[i] = plane->dist;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( i = 0 ; i < 2 ; i++ ) {
|
2012-03-17 20:01:54 +00:00
|
|
|
BuildFaceTree_r( node->children[i], childLists[i] );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
================
|
|
|
|
FaceBSP
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
List will be freed before returning
|
|
|
|
================
|
|
|
|
*/
|
2007-11-04 03:34:51 +00:00
|
|
|
tree_t *FaceBSP( face_t *list ) {
|
2012-03-17 20:01:54 +00:00
|
|
|
tree_t *tree;
|
|
|
|
face_t *face;
|
|
|
|
int i;
|
|
|
|
int count;
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
Sys_FPrintf( SYS_VRB, "--- FaceBSP ---\n" );
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
tree = AllocTree();
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
count = 0;
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( face = list; face != NULL; face = face->next )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
count++;
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < face->w->numpoints; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
AddPointToBounds( face->w->p[ i ], tree->mins, tree->maxs );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Sys_FPrintf( SYS_VRB, "%9d faces\n", count );
|
|
|
|
|
|
|
|
tree->headnode = AllocNode();
|
|
|
|
VectorCopy( tree->mins, tree->headnode->mins );
|
|
|
|
VectorCopy( tree->maxs, tree->headnode->maxs );
|
|
|
|
c_faceLeafs = 0;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
BuildFaceTree_r( tree->headnode, list );
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
Sys_FPrintf( SYS_VRB, "%9d leafs\n", c_faceLeafs );
|
|
|
|
|
|
|
|
return tree;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
MakeStructuralBSPFaceList()
|
|
|
|
get structural brush faces
|
|
|
|
*/
|
|
|
|
|
|
|
|
face_t *MakeStructuralBSPFaceList( brush_t *list ){
|
|
|
|
brush_t *b;
|
|
|
|
int i;
|
|
|
|
side_t *s;
|
|
|
|
winding_t *w;
|
|
|
|
face_t *f, *flist;
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
flist = NULL;
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( b = list; b != NULL; b = b->next )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( b->detail ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
continue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for ( i = 0; i < b->numsides; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
/* get side and winding */
|
|
|
|
s = &b->sides[ i ];
|
|
|
|
w = s->winding;
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( w == NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
continue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: skip certain faces */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( s->compileFlags & C_SKIP ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
continue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* allocate a face */
|
|
|
|
f = AllocBspFace();
|
|
|
|
f->w = CopyWinding( w );
|
|
|
|
f->planenum = s->planenum & ~1;
|
2012-03-17 20:01:54 +00:00
|
|
|
f->compileFlags = s->compileFlags; /* ydnar */
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: set priority */
|
|
|
|
f->priority = 0;
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( f->compileFlags & C_HINT ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
f->priority += HINT_PRIORITY;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
if ( f->compileFlags & C_ANTIPORTAL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
f->priority += ANTIPORTAL_PRIORITY;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
if ( f->compileFlags & C_AREAPORTAL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
f->priority += AREAPORTAL_PRIORITY;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* get next face */
|
|
|
|
f->next = flist;
|
|
|
|
flist = f;
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
return flist;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
MakeVisibleBSPFaceList()
|
|
|
|
get visible brush faces
|
|
|
|
*/
|
|
|
|
|
|
|
|
face_t *MakeVisibleBSPFaceList( brush_t *list ){
|
|
|
|
brush_t *b;
|
|
|
|
int i;
|
|
|
|
side_t *s;
|
|
|
|
winding_t *w;
|
|
|
|
face_t *f, *flist;
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
flist = NULL;
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( b = list; b != NULL; b = b->next )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( b->detail ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
continue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for ( i = 0; i < b->numsides; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
/* get side and winding */
|
|
|
|
s = &b->sides[ i ];
|
|
|
|
w = s->visibleHull;
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( w == NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
continue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: skip certain faces */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( s->compileFlags & C_SKIP ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
continue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* allocate a face */
|
|
|
|
f = AllocBspFace();
|
|
|
|
f->w = CopyWinding( w );
|
|
|
|
f->planenum = s->planenum & ~1;
|
2012-03-17 20:01:54 +00:00
|
|
|
f->compileFlags = s->compileFlags; /* ydnar */
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: set priority */
|
|
|
|
f->priority = 0;
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( f->compileFlags & C_HINT ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
f->priority += HINT_PRIORITY;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
if ( f->compileFlags & C_ANTIPORTAL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
f->priority += ANTIPORTAL_PRIORITY;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
if ( f->compileFlags & C_AREAPORTAL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
f->priority += AREAPORTAL_PRIORITY;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* get next face */
|
|
|
|
f->next = flist;
|
|
|
|
flist = f;
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
return flist;
|
|
|
|
}
|