bool addNewSquare() { Edge curEdge = freeEdges[Randomiser.intBetween(0, freeEdges.Count / 2)]; Junction junction = new Junction(Randomiser.pointOnEdge(curEdge), curEdge.axisDirection); Vector3 measurePoint = junction.position + 0.2f * curEdge.axisDirection; if (!checkJunction(measurePoint)) { return(false); } int distanceAlongEdge = Mathf.Min( Randomiser.measureDistance(measurePoint, GenericUtils.rotateClockwise(curEdge.axisDirection), maxLengthR / 2), Randomiser.measureDistance(measurePoint, -1 * GenericUtils.rotateClockwise(curEdge.axisDirection), maxLengthR / 2) ); if (distanceAlongEdge < minLengthS) { return(false); } int distanceAlongAxis = Randomiser.measureDistance(measurePoint, curEdge.axisDirection, maxLengthR); if (distanceAlongAxis * 2 < minLengthS) { return(false); } distanceAlongAxis = Randomiser.clampInRange(distanceAlongAxis, minLengthR, (int)(distanceAlongEdge * 2)); SquareFoundation square = SquareFromJunction(junction, curEdge.axisDirection, Mathf.Min(distanceAlongEdge * 2, distanceAlongAxis)); if (!checkSquareConsistency(square)) { square.delete(); return(false); } if (!checkOverlaps(square)) { square.delete(); return(false); } updateLists(square, curEdge, junction, squares, true, false); return(true); }
bool checkSquareConsistency(SquareFoundation s) { return(s.isConsistent(minLengthS, maxLengthS)); }