static void FindLoop(BLOCK *b) { BLOCKLIST *loop = NULL; BLOCKLIST *bl; BLOCK *Z = b; bl = b->pred; while (bl) { if (getEdgeType(bl->block->blocknum, b->blocknum) == F_BACKEDGE) { Z = findCommonDominator(Z, bl->block); if (bl->block != b) // we don't care about duplicates, they will be filtered later { BLOCKLIST *bm = oAlloc(sizeof(BLOCKLIST)); bm->block = bl->block; bm->next = loop; loop = bm; } } bl = bl->next; } if (Z != b) { /* again we don't care about duplicates */ BLOCKLIST **bp = &Z->loopGenerators; while (*bp) bp = &(*bp)->next; (*bp) = loop; } else { FindBody(loop, b, LT_SINGLE); } }
void FloorTri::write ( Iff & iff ) const { ConnectedTri::write(iff); iff.insertChunkFloatVector( getNormal() ); iff.insertChunkData( static_cast<uint8>(getEdgeType(0)) ); iff.insertChunkData( static_cast<uint8>(getEdgeType(1)) ); iff.insertChunkData( static_cast<uint8>(getEdgeType(2)) ); iff.insertChunkData( isFallthrough() ); iff.insertChunkData( getPartTag() ); iff.insertChunkData( getPortalId(0) ); iff.insertChunkData( getPortalId(1) ); iff.insertChunkData( getPortalId(2) ); }
SurroundingVerticesFromEdge getSurroundingVerticesFromEdge(EdgeLocation location) { SurroundingVerticesFromEdge result; EdgeType type = getEdgeType(location); if (type == EDGE_FLAT) { RegionLocation upperRegion = location.region0; if (location.region1.y > upperRegion.y) { upperRegion = location.region1; } // Left result.locations[0].region0 = location.region0; result.locations[0].region1 = location.region1; result.locations[0].region2 = getAdjacentRegion(upperRegion, DOWN_LEFT); // Right result.locations[1].region0 = location.region0; result.locations[1].region1 = location.region1; result.locations[1].region2 = getAdjacentRegion(upperRegion, DOWN_RIGHT); } else if (type == EDGE_POSITIVE) { RegionLocation upperRegion = location.region0; if (location.region1.y > upperRegion.y) { upperRegion = location.region1; } // Up-right result.locations[0].region0 = location.region0; result.locations[0].region1 = location.region1; result.locations[0].region2 = getAdjacentRegion(upperRegion, UP_RIGHT); // Down-left result.locations[1].region0 = location.region0; result.locations[1].region1 = location.region1; result.locations[1].region2 = getAdjacentRegion(upperRegion, DOWN); } else { // EDGE_NEGATIVE RegionLocation upperRegion = location.region0; if (location.region1.x > upperRegion.x) { upperRegion = location.region1; } // Up-left result.locations[0].region0 = location.region0; result.locations[0].region1 = location.region1; result.locations[0].region2 = getAdjacentRegion(upperRegion, UP_LEFT); // Down-right result.locations[1].region0 = location.region0; result.locations[1].region1 = location.region1; result.locations[1].region2 = getAdjacentRegion(upperRegion, DOWN); } return result; }