static void tjunc_fix_r(node_t *node) { face_t *f, *next; if (node->planenum == PLANENUM_LEAF) return; newlist = NULL; for (f = node->faces; f; f = next) { next = f->next; FixFaceEdges(f); } node->faces = newlist; tjunc_fix_r(node->children[0]); tjunc_fix_r(node->children[1]); }
void FixTJunctions(tree_t *tree) { vec_t radius; vec3_t maxs, mins; qprintf ("---- tjunc ----\n"); if (notjunc) { printf ("skipped\n"); return; } // // identify all points on common edges // // origin points won't allways be inside the map, so extend the hash area radius = RadiusFromBounds( tree->mins, tree->maxs ); VectorSet( maxs, radius, radius, radius ); VectorSet( mins, -radius, -radius, -radius ); InitHash (mins, maxs); numwedges = numwverts = 0; wverts = qmalloc( sizeof(*wverts) * MAX_WVERTS ); wedges = qmalloc( sizeof(*wverts) * MAX_WEDGES ); superface = qmalloc (sizeof(superface_t)); tjunc_find_r (tree->headnode); qprintf ("%i world edges %i edge points\n", numwedges, numwverts); // // add extra vertexes on edges where needed // c_tjuncs = c_tjuncfaces = c_degenerateEdges = c_degenerateFaces = c_rotated = 0; tjunc_fix_r (tree->headnode); qfree( wverts ); qfree( wedges ); qfree (superface); // Vic: report number of degenerate edges qprintf ("%i degenerate edges\n", c_degenerateEdges); qprintf ("%i degenerate faces\n", c_degenerateFaces); qprintf ("%i edges added by tjunctions\n", c_tjuncs); qprintf ("%i faces added by tjunctions\n", c_tjuncfaces); qprintf ("%i naturally ordered\n", c_tjuncfaces - c_rotated); qprintf ("%i rotated orders\n", c_rotated); }
/* =========== tjunc =========== */ void TJunc(const mapentity_t *ent, node_t *headnode) { vec3_t maxs, mins; int i; Message(msgProgress, "Tjunc"); // Guess edges = 1/2 verts // Verts are arbitrarily multiplied by 2 because there appears to // be a need for them to "grow" slightly. cWVerts = 0; tjunc_count_r(headnode); cWEdges = cWVerts; cWVerts *= 2; pWVerts = AllocMem(WVERT, cWVerts, true); pWEdges = AllocMem(WEDGE, cWEdges, true); // identify all points on common edges // origin points won't allways be inside the map, so extend the hash area for (i = 0; i < 3; i++) { if (fabs(ent->maxs[i]) > fabs(ent->mins[i])) maxs[i] = fabs(ent->maxs[i]); else maxs[i] = fabs(ent->mins[i]); } VectorSubtract(vec3_origin, maxs, mins); InitHash(mins, maxs); numwedges = numwverts = 0; tjunc_find_r(headnode); Message(msgStat, "%5i world edges", numwedges); Message(msgStat, "%5i edge points", numwverts); // add extra vertexes on edges where needed tjuncs = tjuncfaces = 0; tjunc_fix_r(headnode); FreeMem(pWVerts, WVERT, cWVerts); FreeMem(pWEdges, WEDGE, cWEdges); Message(msgStat, "%5i edges added by tjunctions", tjuncs); Message(msgStat, "%5i faces added by tjunctions", tjuncfaces); }
/* * =========== * tjunc * * =========== */ void tjunc(node_t* headnode) { vec3_t maxs, mins; int i; Verbose("---- tjunc ----\n"); if (g_notjunc) { return; } // // identify all points on common edges // // origin points won't allways be inside the map, so extend the hash area for (i = 0; i < 3; i++) { if (fabs(headnode->maxs[i]) > fabs(headnode->mins[i])) { maxs[i] = fabs(headnode->maxs[i]); } else { maxs[i] = fabs(headnode->mins[i]); } } VectorSubtract(vec3_origin, maxs, mins); InitHash(mins, maxs); numwedges = numwverts = 0; tjunc_find_r(headnode); Verbose("%i world edges %i edge points\n", numwedges, numwverts); // // add extra vertexes on edges where needed // tjuncs = tjuncfaces = 0; tjunc_fix_r(headnode); Verbose("%i edges added by tjunctions\n", tjuncs); Verbose("%i faces added by tjunctions\n", tjuncfaces); }