29 #include "../../../idlib/precompiled.h"
108 common->
Error(
"AddPortalToNode: allready included");
136 common->
Error(
"RemovePortalFromNode: portal not in leaf");
141 if (t->
nodes[0] == l)
143 else if (t->
nodes[1] == l)
146 common->
Error(
"RemovePortalFromNode: portal not bounding leaf");
149 if ( portal->
nodes[0] == l ) {
150 *pp = portal->
next[0];
152 }
else if ( portal->
nodes[1] == l ) {
153 *pp = portal->
next[1];
156 common->
Error(
"RemovePortalFromNode: mislinked" );
169 common->
Printf(
"(%5.0f,%5.0f,%5.0f)\n",(*w)[i][0], (*w)[i][1], (*w)[i][2]);
180 static void MakeHeadnodePortals(
tree_t *tree ) {
200 for (i=0 ; i<3 ; i++) {
203 if ( bounds[0][i] >= bounds[1][i] ) {
208 for (i=0 ; i<3 ; i++) {
209 for (j=0 ; j<2 ; j++) {
216 memset (pl, 0,
sizeof(*pl));
219 (*pl)[3] = bounds[
j][
i];
222 (*pl)[3] = -bounds[
j][
i];
231 for (i=0 ; i<6 ; i++) {
232 for (j=0 ; j<6 ; j++) {
249 #define BASE_WINDING_EPSILON 0.001f
250 #define SPLIT_WINDING_EPSILON 0.001f
259 for ( n = node->
parent ; n && w ; ) {
287 static void MakeNodePortal(
node_t *node ) {
296 for (p = node->
portals ; p && w; p = p->
next[side])
300 if (p->
nodes[0] == node)
305 else if (p->
nodes[1] == node)
311 common->
Error(
"CutNodePortals_r: mislinked portal");
333 new_portal->
onnode = node;
347 static void SplitNodePortals(
node_t *node ) {
358 for ( p = node->
portals ; p ; p = next_portal ) {
359 if (p->
nodes[0] == node ) {
361 }
else if ( p->
nodes[1] == node ) {
364 common->
Error(
"SplitNodePortals: mislinked portal" );
367 next_portal = p->
next[side];
369 other_node = p->
nodes[!side];
378 if ( frontwinding && frontwinding->
IsTiny() )
385 if ( backwinding && backwinding->
IsTiny() )
392 if ( !frontwinding && !backwinding )
419 new_portal->
winding = backwinding;
453 s = (p->
nodes[1] == node);
476 for ( i = 0; i < 3; i++ ) {
486 MakeNodePortal (node);
487 SplitNodePortals (node);
501 MakeHeadnodePortals (tree);
536 s = (p->
nodes[1] == node);
593 bool errorShown =
false;
609 if ( !
strcmp( cl,
"light" ) ) {
645 common->
Printf(
"Entity origin is: %f %f %f\n\n\n", origin.
x, origin.
y, origin.
z);
658 common->
Printf (
"entity reached from outside -- no filling\n");
673 static int c_areaFloods;
688 for ( i = 0 ; i < 2 ; i++ ) {
695 for ( j = 0 ; j < orig->
numsides ; j++ ) {
707 for ( k = 0; k < orig->
numsides; k++ ) {
711 s2 = orig->
sides + k;
739 if ( node->
area != -1 ) {
747 node->
area = c_areas;
752 s = (p->
nodes[1] == node);
755 if ( !Portal_Passable(p) ) {
760 if ( FindSideForPortal( p ) ) {
787 if ( node->
area != -1 ) {
793 common->
Printf(
"area %i has %i leafs\n", c_areas, c_areaFloods );
838 static void FindInterAreaPortals_r(
node_t *node ) {
847 FindInterAreaPortals_r( node->
children[0] );
848 FindInterAreaPortals_r( node->
children[1] );
859 s = (p->
nodes[1] == node);
872 side = FindSideForPortal( p );
885 iap = &interAreaPortals[
i];
887 if ( side == iap->
side &&
894 if ( i != numInterAreaPortals ) {
899 numInterAreaPortals++;
942 numInterAreaPortals = 0;
955 static int c_outside;
void PrintPortal(uPortal_t *p)
void MakeTreePortals_r(node_t *node)
float Distance(const idVec3 &v) const
struct uPortal_s * next[2]
#define MAX_INTER_AREA_PORTALS
virtual const idMaterial * FindMaterial(const char *name, bool makeDefault=true)=0
idWinding * Clip(const idPlane &plane, const float epsilon=ON_EPSILON, const bool keepOn=false)
uPortal_t * AllocPortal(void)
void FillOutside_r(node_t *node)
void CalcNodeBounds(node_t *node)
#define BASE_WINDING_EPSILON
const idMaterial * material
bool AddPoint(const idVec3 &v)
void FloodAreas_r(node_t *node)
int GetNumPoints(void) const
bool FloodEntities(tree_t *tree)
struct node_s * children[2]
const char * GetString(const char *key, const char *defaultString="") const
GLubyte GLubyte GLubyte GLubyte w
void FloodAreas(uEntity_t *e)
#define SPLIT_WINDING_EPSILON
void FindAreas_r(node_t *node)
idWinding * BaseWindingForNode(node_t *node)
void RemovePortalFromNode(uPortal_t *portal, node_t *l)
struct uPortal_s * portals
const int GetContentFlags(void) const
idVec3 GetVector(const char *key, const char *defaultString=NULL) const
void ClearAreas_r(node_t *node)
void FreePortal(uPortal_t *p)
virtual void Printf(const char *fmt,...) id_attribute((format(printf
const char * ToString(int precision=2) const
idDeclManager * declManager
void FillOutside(uEntity_t *e)
int Split(const idPlane &plane, const float epsilon, idWinding **front, idWinding **back) const
struct bspbrush_s * original
interAreaPortal_t interAreaPortals[MAX_INTER_AREA_PORTALS]
bool PlaceOccupant(node_t *headnode, idVec3 origin, uEntity_t *occupant)
idVec3 GetCenter(void) const
void CheckAreas_r(node_t *node)
void AddPortalToNodes(uPortal_t *p, node_t *front, node_t *back)
void FloodPortals_r(node_t *node, int dist)
void * Mem_Alloc(const int size)
dmapGlobals_t dmapGlobals
virtual void Error(const char *fmt,...) id_attribute((format(printf
virtual void virtual void Warning(const char *fmt,...) id_attribute((format(printf
void MakeTreePortals(tree_t *tree)