/* ================== MakeNodePortal create the new portal by taking the full plane winding for the cutting plane and clipping it by all of parents of this node ================== */ static void MakeNodePortal( node_t *node ) { uPortal_t *new_portal, *p; idWinding *w; idVec3 normal; int side; w = BaseWindingForNode( node ); // clip the portal by all the other portals in the node for( p = node->portals ; p && w; p = p->next[side] ) { idPlane plane; if( p->nodes[0] == node ) { side = 0; plane = p->plane; } else if( p->nodes[1] == node ) { side = 1; plane = -p->plane; } else { common->Error( "CutNodePortals_r: mislinked portal" ); side = 0; // quiet a compiler warning } w = w->Clip( plane, CLIP_EPSILON ); } if( !w ) { return; } if( w->IsTiny() ) { c_tinyportals++; delete w; return; } new_portal = AllocPortal(); new_portal->plane = dmapGlobals.mapPlanes[node->planenum]; new_portal->onnode = node; new_portal->winding = w; AddPortalToNodes( new_portal, node->children[0], node->children[1] ); }
static void DrawPartitions() { face_t *face; winding_t *w; // create temporary winding to draw the split plane w = BaseWindingForNode(drawSplitNode); ChopWindingByBounds(&w, drawSplitNode->mins, drawSplitNode->maxs, 32); if(w != NULL) { Draw_Winding(w, 0, 0, 1, 0.3); FreeWinding(w); } for(face = drawChildLists[0]; face != NULL; face = face->next) { w = face->w; Draw_Winding(w, 0, 1, 0, 0.3); } for(face = drawChildLists[1]; face != NULL; face = face->next) { w = face->w; Draw_Winding(w, 1, 0, 0, 0.3); } }
/* ================== MakeNodePortal create the new portal by taking the full plane winding for the cutting plane and clipping it by all of parents of this node ================== */ void MakeNodePortal (node_t *node) { portal_t *new_portal, *p; winding_t *w; Vector normal; float dist = 0.0f; int side = 0; w = BaseWindingForNode (node); // clip the portal by all the other portals in the node for (p = node->portals ; p && w; p = p->next[side]) { if (p->nodes[0] == node) { side = 0; VectorCopy (p->plane.normal, normal); dist = p->plane.dist; } else if (p->nodes[1] == node) { side = 1; VectorSubtract (vec3_origin, p->plane.normal, normal); dist = -p->plane.dist; } else { Error ("CutNodePortals_r: mislinked portal"); } ChopWindingInPlace (&w, normal, dist, 0.1); } if (!w) { return; } if (WindingIsTiny (w)) { c_tinyportals++; FreeWinding (w); return; } new_portal = AllocPortal (); new_portal->plane = mapplanes[node->planenum]; new_portal->onnode = node; new_portal->winding = w; AddPortalToNodes (new_portal, node->children[0], node->children[1]); }
void MakeNodePortal(node_t *node) { portal_t *new_portal, *p; winding_t *w; vec3_t normal; float dist = 0; // TTimo: init int side = 0; w = BaseWindingForNode(node); // clip the portal by all the other portals in the node for(p = node->portals; p && w; p = p->next[side]) { if(p->nodes[0] == node) { side = 0; VectorCopy(p->plane.normal, normal); dist = p->plane.dist; } //end if else if(p->nodes[1] == node) { side = 1; VectorSubtract(vec3_origin, p->plane.normal, normal); dist = -p->plane.dist; } //end else if else { Error("MakeNodePortal: mislinked portal"); } //end else ChopWindingInPlace(&w, normal, dist, 0.1); } //end for if(!w) { return; } //end if if(WindingIsTiny(w)) { c_tinyportals++; FreeWinding(w); return; } //end if #ifdef DEBUG /* //NOTE: don't use this winding ok check // all the invalid windings only have a degenerate edge if (WindingError(w)) { Log_Print("MakeNodePortal: %s\n", WindingErrorString()); FreeWinding(w); return; } //end if*/ #endif //DEBUG new_portal = AllocPortal(); new_portal->plane = mapplanes[node->planenum]; #ifdef ME new_portal->planenum = node->planenum; #endif //ME new_portal->onnode = node; new_portal->winding = w; AddPortalToNodes(new_portal, node->children[0], node->children[1]); } //end of the function MakeNodePortal
/* ================== MakeNodePortal create the new portal by taking the full plane winding for the cutting plane and clipping it by all of parents of this node ================== */ void MakeNodePortal (node_t *node) { portal_t *new_portal, *p; winding_t *w; vec3_t normal; float dist; int side; w = BaseWindingForNode (node); // clip the portal by all the other portals in the node for (p = node->portals ; p && w; p = p->next[side]) { if (p->nodes[0] == node) { side = 0; VectorCopy (p->plane.normal, normal); dist = p->plane.dist; } else if (p->nodes[1] == node) { side = 1; VectorSubtract (vec3_origin, p->plane.normal, normal); dist = -p->plane.dist; } else Error ("CutNodePortals_r: mislinked portal"); ChopWindingInPlace (&w, normal, dist, CLIP_EPSILON); } if (!w) { return; } /* ydnar: adding this here to fix degenerate windings */ #if 0 if( FixWinding( w ) == qfalse ) { c_badportals++; FreeWinding( w ); return; } #endif if (WindingIsTiny (w)) { c_tinyportals++; FreeWinding (w); return; } new_portal = AllocPortal (); new_portal->plane = mapplanes[node->planenum]; new_portal->onnode = node; new_portal->winding = w; new_portal->compileFlags = node->compileFlags; AddPortalToNodes (new_portal, node->children[0], node->children[1]); }