bool VLevel::CheckPlanes(linetrace_t& Trace, sector_t* Sec) const { guard(VLevel::CheckPlanes); sec_region_t* StartReg = SV_PointInRegion(Sec, Trace.LineStart); if (StartReg != NULL) { for (sec_region_t* Reg = StartReg; Reg != NULL; Reg = Reg->next) { if (!CheckPlane(Trace, Reg->floor)) { // Hit floor return false; } if (!CheckPlane(Trace, Reg->ceiling)) { // Hit ceiling return false; } } for (sec_region_t* Reg = StartReg->prev; Reg != NULL; Reg = Reg->prev) { if (!CheckPlane(Trace, Reg->floor)) { // Hit floor return false; } if (!CheckPlane(Trace, Reg->ceiling)) { // Hit ceiling return false; } } } return true; unguard; }
void lcs::UnitTestForTetBlkIntersection(lcs::TetrahedralGrid *grid, double blockSize, double globalMinX, double globalMinY, double globalMinZ, int numOfBlocksInY, int numOfBlocksInZ, int *queryTetrahedron, int *queryBlock, bool *queryResults, int numOfQueries, double epsilon) { printf("Unit test for tetrahedron-block intersection ... "); for (int i = 0; i < numOfQueries; i++) { int tetID = queryTetrahedron[i]; int blkID = queryBlock[i]; lcs::Tetrahedron tet = grid->GetTetrahedron(tetID); int x, y, z; z = blkID % numOfBlocksInZ; int temp = blkID / numOfBlocksInZ; y = temp % numOfBlocksInY; x = temp / numOfBlocksInY; double localMinX = globalMinX + x * blockSize; double localMinY = globalMinY + y * blockSize; double localMinZ = globalMinZ + z * blockSize; // Test tetrahedral edge and block point bool flag = 0; for (int tetEdgeID = 0; !flag && tetEdgeID < 6; tetEdgeID++) { Vector p1, p2; switch (tetEdgeID) { case 0: { p1 = tet.GetVertex(0); p2 = tet.GetVertex(1); } break; case 1: { p1 = tet.GetVertex(0); p2 = tet.GetVertex(2); } break; case 2: { p1 = tet.GetVertex(0); p2 = tet.GetVertex(3); } break; case 3: { p1 = tet.GetVertex(1); p2 = tet.GetVertex(2); } break; case 4: { p1 = tet.GetVertex(1); p2 = tet.GetVertex(3); } break; case 5: { p1 = tet.GetVertex(2); p2 = tet.GetVertex(3); } break; } for (int dx = 0; !flag && dx <= 1; dx++) for (int dy = 0; !flag && dy <= 1; dy++) for (int dz = 0; dz <= 1; dz++) { Vector p3 = Vector(localMinX, localMinY, localMinZ) + Vector(dx, dy, dz) * blockSize; if (CheckPlane(p1, p2, p3, tet, localMinX, localMinY, localMinZ, blockSize, epsilon)) { flag = 1; //printf("tetrahedral edge and block point: %d, %d %d %d\n", tetEdgeID, dx, dy, dz); break; } } } // Test tetrahedral point and block edge for (int x1 = 0; !flag && x1 <= 1; x1++) for (int y1 = 0; !flag && y1 <= 1; y1++) for (int z1 = 0; !flag && z1 <= 1; z1++) { Vector p1(localMinX + x1 * blockSize, localMinY + y1 * blockSize, localMinZ + z1 *blockSize); for (int k = 0; !flag && k < 3; k++) { int x2 = x1, y2 = y1, z2 = z1; if (k == 0) if (x1 == 0) x2++; else continue; if (k == 1) if (y1 == 0) y2++; else continue; if (k == 2) if (z1 == 0) z2++; else continue; Vector p2(localMinX + x2 * blockSize, localMinY + y2 * blockSize, localMinZ + z2 * blockSize); for (int j = 0; j < 4; j++) { Vector p3 = tet.GetVertex(j); if (CheckPlane(p1, p2, p3, tet, localMinX, localMinY, localMinZ, blockSize, epsilon)) { flag = 1; break; } } } } bool result = !flag; if (result != queryResults[i]) { char error[100]; sprintf(error, "Query %d has incorrect result.\ntet = %d, blk = %d\nkernel result: %d, CPU result: %d", i + 1, queryTetrahedron[i], queryBlock[i], queryResults[i], result); lcs::Error(error); } } printf("Passed\n"); }
bool Check3DFloorPlane(const F3DFloor *ffloor, bool checkBottom) { return CheckPlane(checkBottom? *(ffloor->bottom.plane) : *(ffloor->top.plane)); }
bool CheckSectorPlane(const sector_t *sector, bool checkFloor) { return CheckPlane(checkFloor ? sector->floorplane : sector->ceilingplane); }