// // P_FindNextLowestFloor() // // Passed a sector and a floor height, returns the fixed point value // of the largest floor height in a surrounding sector smaller than // the floor height passed. If no such height exists the floorheight // passed is returned. // // jff 02/03/98 Twiddled Lee's P_FindNextHighestFloor to make this // fixed_t sector_t::FindNextLowestFloor (vertex_t **v) const { fixed_t height; fixed_t heightdiff; fixed_t ofloor, floor; sector_t *other; vertex_t *spot; line_t *check; int i; if (linecount == 0) return GetPlaneTexZ(sector_t::floor); spot = lines[0]->v1; height = floorplane.ZatPoint (spot); heightdiff = FIXED_MAX; for (i = 0; i < linecount; i++) { check = lines[i]; if (NULL != (other = getNextSector (check, this))) { if (other - sectors == 6) other = other; ofloor = other->floorplane.ZatPoint (check->v1); floor = floorplane.ZatPoint (check->v1); if (ofloor < floor && floor - ofloor < heightdiff && !IsLinked(other, false)) { heightdiff = floor - ofloor; height = ofloor; spot = check->v1; } ofloor = other->floorplane.ZatPoint (check->v2); floor = floorplane.ZatPoint (check->v2); if (ofloor < floor && floor - ofloor < heightdiff && !IsLinked(other, false)) { heightdiff = floor - ofloor; height = ofloor; spot = check->v2; } } } if (v != NULL) *v = spot; return height; }
// // P_FindNextLowestCeiling() // // Passed a sector and a ceiling height, returns the fixed point value // of the largest ceiling height in a surrounding sector smaller than // the ceiling height passed. If no such height exists the ceiling height // passed is returned. // // jff 02/03/98 Twiddled Lee's P_FindNextHighestFloor to make this // fixed_t sector_t::FindNextLowestCeiling (vertex_t **v) const { fixed_t height; fixed_t heightdiff; fixed_t oceil, ceil; sector_t *other; vertex_t *spot; line_t *check; int i; if (linecount == 0) return GetPlaneTexZ(sector_t::ceiling); spot = lines[0]->v1; height = ceilingplane.ZatPoint (spot); heightdiff = FIXED_MAX; for (i = 0; i < linecount; i++) { check = lines[i]; if (NULL != (other = getNextSector (check, this))) { oceil = other->ceilingplane.ZatPoint (check->v1); ceil = ceilingplane.ZatPoint (check->v1); if (oceil < ceil && ceil - oceil < heightdiff && !IsLinked(other, true)) { heightdiff = ceil - oceil; height = oceil; spot = check->v1; } oceil = other->ceilingplane.ZatPoint (check->v2); ceil = ceilingplane.ZatPoint (check->v2); if (oceil < ceil && ceil - oceil < heightdiff && !IsLinked(other, true)) { heightdiff = ceil - oceil; height = oceil; spot = check->v2; } } } if (v != NULL) *v = spot; return height; }
// // P_FindLowestFloorSurrounding() // FIND LOWEST FLOOR HEIGHT IN SURROUNDING SECTORS // fixed_t sector_t::FindLowestFloorSurrounding (vertex_t **v) const { int i; sector_t *other; line_t *check; fixed_t floor; fixed_t ofloor; vertex_t *spot; if (linecount == 0) return GetPlaneTexZ(sector_t::floor); spot = lines[0]->v1; floor = floorplane.ZatPoint (spot); for (i = 0; i < linecount; i++) { check = lines[i]; if (NULL != (other = getNextSector (check, this))) { ofloor = other->floorplane.ZatPoint (check->v1); if (ofloor < floor && ofloor < floorplane.ZatPoint (check->v1)) { floor = ofloor; spot = check->v1; } ofloor = other->floorplane.ZatPoint (check->v2); if (ofloor < floor && ofloor < floorplane.ZatPoint (check->v2)) { floor = ofloor; spot = check->v2; } } } if (v != NULL) *v = spot; return floor; }
// // FIND HIGHEST CEILING IN THE SURROUNDING SECTORS // fixed_t sector_t::FindHighestCeilingSurrounding (vertex_t **v) const { fixed_t height; fixed_t oceil; sector_t *other; vertex_t *spot; line_t *check; int i; if (linecount == 0) return GetPlaneTexZ(sector_t::ceiling); spot = lines[0]->v1; height = FIXED_MIN; for (i = 0; i < linecount; i++) { check = lines[i]; if (NULL != (other = getNextSector (check, this))) { oceil = other->ceilingplane.ZatPoint (check->v1); if (oceil > height) { height = oceil; spot = check->v1; } oceil = other->ceilingplane.ZatPoint (check->v2); if (oceil > height) { height = oceil; spot = check->v2; } } } if (v != NULL) *v = spot; return height; }