Skip to content

Commit

Permalink
fix: Private office, classroom relative transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
serenayl committed Jul 17, 2024
1 parent 5ee86c5 commit 4a9108c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 0 additions & 2 deletions LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,6 @@ public static void LimitWallCandidateOptionsByConfigId<TSpaceBoundary>(List<(Roo
// If a set of wall candidate options are provided, limit to the one that aligns with the boundary's first edge.
// In the future, as room shapes become more editable, we might want to pass in an explicit "orientation edge" instead of just using the first edge.
var roomOrientationEdge = room.Boundary.Perimeter.Segments().First();
// // If we keep passing in already-transformed lines, we need to compare against the transformed first segment.
// var roomOrientationEdge = room.Boundary.Perimeter.Segments().First().TransformedLine(room.Transform);
for (int i = wallCandidateOptions.Count - 1; i >= 0; i--)
{
var (OrientationGuideEdge, _) = wallCandidateOptions[i];
Expand Down
10 changes: 7 additions & 3 deletions LayoutFunctions/LayoutFunctionCommon/WallGeneration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public static List<RoomEdge> FindWallCandidates(ISpaceBoundary room, Profile lev
}), corridorSegments, levelProfile, out var wallCandidates);
orientationGuideEdge.Type = room.DefaultWallType ?? "Glass";
orientationGuideEdge.PrimaryEntryEdge = true;
// Return the orientation guide edge relative to the room's transform.
orientationGuideEdge.Line = orientationGuideEdge.Line.TransformedLine(room.Transform.Inverted());
wallCandidateLines.Add(orientationGuideEdge);
if (levelProfile != null)
{
Expand Down Expand Up @@ -70,14 +72,16 @@ public static List<RoomEdge> FindWallCandidates(ISpaceBoundary room, Profile lev
var thicknesses = room.Boundary.GetEdgeThickness();
var allSegments = room.Boundary.Perimeter.Segments().Select((s, i) => new RoomEdge
{
Line = new Line(s.Start, s.End),
Line = s.TransformedLine(room.Transform),
Thickness = thicknesses?.ElementAtOrDefault(i)
}).ToList();
var orientationGuideEdges = SortEdgesByPrimaryAccess(allSegments, corridorSegments, levelProfile, 0.3);
foreach (var orientationGuideEdge in orientationGuideEdges)
{
orientationGuideEdge.Line.Type = room.DefaultWallType ?? "Glass";
orientationGuideEdge.Line.PrimaryEntryEdge = true;
// Return the orientation guide edge relative to the room's transform.
orientationGuideEdge.Line.Line = orientationGuideEdge.Line.Line.TransformedLine(room.Transform.Inverted());
var wallCandidateLines = new List<RoomEdge>
{
orientationGuideEdge.Line
Expand All @@ -87,7 +91,7 @@ public static List<RoomEdge> FindWallCandidates(ISpaceBoundary room, Profile lev
var exteriorWalls = FindAllEdgesAdjacentToSegments(orientationGuideEdge.OtherSegments, levelProfile.Segments(), out var notAdjacentToFloorBoundary, out var corridorEdges);
wallCandidateLines.AddRange(notAdjacentToFloorBoundary.Select(s =>
{
if (!orientationGuideEdges.Select(x => x.Line).Contains(s))
if (!orientationGuideEdges.Select(x => x.Line.Line.TransformedLine(room.Transform)).Contains(s.Line))
{
s.Type = "Solid";
}
Expand All @@ -99,7 +103,7 @@ public static List<RoomEdge> FindWallCandidates(ISpaceBoundary room, Profile lev
// if no level or floor is present, everything that's not glass is solid.
wallCandidateLines.AddRange(orientationGuideEdge.OtherSegments.Select(s =>
{
if (!orientationGuideEdges.Select(x => x.Line).Contains(s))
if (!orientationGuideEdges.Select(x => x.Line.Line.TransformedLine(room.Transform)).Contains(s.Line))
{
s.Type = "Solid";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ private static IEnumerable<SpaceBoundary> DivideBoundaryAlongVAxis(SpaceBoundary
}
var relativeRoomTransform = room.Transform.Concatenated(levelInvertedTransform);
var relativeRoomTransformProjected = new Transform(0, 0, -relativeRoomTransform.Origin.Z);
var orientationTransform = new Transform(Vector3.Origin, orientationGuideEdge.Direction, Vector3.ZAxis);
orientationTransform.Concatenate(relativeRoomTransform);
var orientationTransform = new Transform(Vector3.Origin, orientationGuideEdge.Direction, Vector3.ZAxis).Concatenated(relativeRoomTransform);
var boundaryCurves = new List<Polygon>();
boundaryCurves.Add(room.Boundary.Perimeter.TransformedPolygon(relativeRoomTransform));
boundaryCurves.AddRange(room.Boundary.Voids?.Select(v => v.TransformedPolygon(relativeRoomTransform)) ?? new List<Polygon>());
Expand Down

Large diffs are not rendered by default.

0 comments on commit 4a9108c

Please sign in to comment.