new files and modified files - #990
Conversation
There was a problem hiding this comment.
Pull request overview
Adds incremental rectangle and circle packing layouts with historical position preservation and registers them for city rendering.
Changes:
- Implements incremental rectangle and circle packing algorithms.
- Extends packing models with hierarchy and history metadata.
- Adds new layout kinds and renderer factories.
Reviewed changes
Copilot reviewed 11 out of 17 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
Assets/SEE/Layout/NodeTransform.cs |
Associates transforms with packed nodes. |
Assets/SEE/Layout/NodeLayouts/RectanglePacking/PTree.cs |
Adds incremental rectangle operations. |
Assets/SEE/Layout/NodeLayouts/RectanglePacking/PNode.cs |
Adds hierarchy and rectangle metadata. |
Assets/SEE/Layout/NodeLayouts/IncrementalRectanglePackingLayout.cs |
Implements incremental rectangle packing. |
Assets/SEE/Layout/NodeLayouts/IncrementalRectanglePackingLayout.cs.meta |
Adds Unity metadata. |
Assets/SEE/Layout/NodeLayouts/IncrementalCirclePackingNodeLayout.cs |
Implements incremental circle layout integration. |
Assets/SEE/Layout/NodeLayouts/IncrementalCirclePackingNodeLayout.cs.meta |
Adds Unity metadata. |
Assets/SEE/Layout/NodeLayouts/CirclePacking/TheCircle.cs |
Defines incremental circle state. |
Assets/SEE/Layout/NodeLayouts/CirclePacking/TheCircle.cs.meta |
Adds Unity metadata. |
Assets/SEE/Layout/NodeLayouts/CirclePacking/SpatialHashGrid.cs |
Adds spatial collision lookup. |
Assets/SEE/Layout/NodeLayouts/CirclePacking/SpatialHashGrid.cs.meta |
Adds Unity metadata. |
Assets/SEE/Layout/NodeLayouts/CirclePacking/IncrementalCirclePackerExtended.cs |
Adds PBD-based circle relaxation. |
Assets/SEE/Layout/NodeLayouts/CirclePacking/IncrementalCirclePackerExtended.cs.meta |
Adds Unity metadata. |
Assets/SEE/Layout/NodeLayouts/CirclePacking/IncrementalCirclePacker.cs |
Adds history-aware circle placement. |
Assets/SEE/Layout/NodeLayouts/CirclePacking/IncrementalCirclePacker.cs.meta |
Adds Unity metadata. |
Assets/SEE/Game/CityRendering/GraphRenderer.cs |
Instantiates the new layouts. |
Assets/SEE/Game/City/NodeLayoutKind.cs |
Registers new layout kinds. |
Files not reviewed (6)
- Assets/SEE/Layout/NodeLayouts/CirclePacking/IncrementalCirclePacker.cs.meta: Generated file
- Assets/SEE/Layout/NodeLayouts/CirclePacking/IncrementalCirclePackerExtended.cs.meta: Generated file
- Assets/SEE/Layout/NodeLayouts/CirclePacking/SpatialHashGrid.cs.meta: Generated file
- Assets/SEE/Layout/NodeLayouts/CirclePacking/TheCircle.cs.meta: Generated file
- Assets/SEE/Layout/NodeLayouts/IncrementalCirclePackingNodeLayout.cs.meta: Generated file
- Assets/SEE/Layout/NodeLayouts/IncrementalRectanglePackingLayout.cs.meta: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| foreach (TheCircle c in dealingCircles) | ||
| { | ||
| (string, float, Vector2) tupple = bufferLastPos.FirstOrDefault(l => l.Item1 == c.ID); | ||
| if (c.Radius < c.nextRadius) | ||
| { | ||
| ExpandFromCircleA(circles, c, c.nextRadius); | ||
| } | ||
| else if (c.Radius > c.nextRadius) | ||
| { | ||
| c.Radius = c.nextRadius; | ||
| } | ||
|
|
||
| List<TheCircle> notPlacedCircles = circles.Where(c => !c.IsPlaced).ToList(); | ||
|
|
||
| newNodeIDsSizes = notPlacedCircles.Select(n => (n.ID, n.Radius)).ToList(); | ||
|
|
||
| PackingCircles(circles, containerCenter, out containerRadius, newNodeIDsSizes); | ||
|
|
||
| List<(string, float, Vector2)> placedCircles = circles.Select(c => (c.ID, c.Radius, c.Center)).ToList(); | ||
|
|
||
| lastPositions[parent] = placedCircles; | ||
| } |
| if (R > largestRadius) | ||
| { | ||
| largestRadius = R; | ||
| best = new TheCircle( |
There was a problem hiding this comment.
it produces the largest radius which encloses the set of circles as close as possible this is what it meant to do
| if (R > largestRadius) | ||
| { | ||
| largestRadius = R; | ||
| best = new TheCircle( | ||
| null, |
koschke
left a comment
There was a problem hiding this comment.
I read the code only superficially looking for coding style violations only. Not for semantic problems.
Please fix those.
| /// <summary> | ||
| /// Finds an empty position for the given circle that does not overlap with already placed circles. | ||
| /// </summary> | ||
| /// <param name="placedCircles"></param> |
| /// <summary> | ||
| /// Checks if the given position and radius overlaps with any of the already placed circles. | ||
| /// </summary> | ||
| /// <param name="pos"></param> |
| /// Computes the smallest circle that can surround all the given circles, | ||
| /// returning a new circle with the computed center and radius. | ||
| /// </summary> | ||
| /// <param name="circles"></param> |
| /// Computes the smallest circle that can surround all the given circles, | ||
| /// and resets the positions of all circles to be relative to the surrounding circle. | ||
| /// </summary> | ||
| /// <param name="circles"></param> |
| internal TheCircle ComputeSurroundingCircleAndResetCircles(List<TheCircle> circles) | ||
| { | ||
| if (circles.Count == 0) { return new TheCircle(null, Vector2.zero, 0); } | ||
|
|
| public class IncrementalCirclePacker | ||
| { | ||
| /// <summary> | ||
| /// Packs the given list of circles into a container, adjusting |
There was a problem hiding this comment.
Warning
Trailing whitespace detected! Please remove it.
| /// Packs the given list of circles into a container, adjusting | |
| /// Packs the given list of circles into a container, adjusting |
| } | ||
|
|
||
| /// <summary> | ||
| /// Performs the packing of circles based on their last known positions, |
There was a problem hiding this comment.
Warning
Trailing whitespace detected! Please remove it.
| /// Performs the packing of circles based on their last known positions, | |
| /// Performs the packing of circles based on their last known positions, |
| } | ||
|
|
||
| /// <summary> | ||
| /// Packs the given list of circles into a container, |
There was a problem hiding this comment.
Warning
Trailing whitespace detected! Please remove it.
| /// Packs the given list of circles into a container, | |
| /// Packs the given list of circles into a container, |
| } | ||
|
|
||
| /// <summary> | ||
| /// Computes the smallest circle that can surround all the given circles, |
There was a problem hiding this comment.
Warning
Trailing whitespace detected! Please remove it.
| /// Computes the smallest circle that can surround all the given circles, | |
| /// Computes the smallest circle that can surround all the given circles, |
|
|
||
| /// <summary> | ||
| /// Implements a mass-weighted centripetal relaxation algorithm to pack circles densely in a 2D space. | ||
| /// Utilizing Position-Based Dynamics (PBD), this class creates a tightly nested, center-seeking cluster |
There was a problem hiding this comment.
Warning
Trailing whitespace detected! Please remove it.
| /// Utilizing Position-Based Dynamics (PBD), this class creates a tightly nested, center-seeking cluster | |
| /// Utilizing Position-Based Dynamics (PBD), this class creates a tightly nested, center-seeking cluster |
| /// This layout packs rectangles closely together as a set of nested packed rectangles to decrease | ||
| /// the total area of city. It also ensures that the layout is incremental, meaning that if a node | ||
| /// is added or removed, the layout will adjust accordingly without having to recompute the entire | ||
| /// layout from scratch. The algorithm finds the best position for each rectangle based on its size |
There was a problem hiding this comment.
Warning
Trailing whitespace detected! Please remove it.
| /// layout from scratch. The algorithm finds the best position for each rectangle based on its size | |
| /// layout from scratch. The algorithm finds the best position for each rectangle based on its size |
| } | ||
|
|
||
| /// <summary> | ||
| /// A reference to the layout calculated in the previous frame or state. |
There was a problem hiding this comment.
Warning
Trailing whitespace detected! Please remove it.
| /// A reference to the layout calculated in the previous frame or state. | |
| /// A reference to the layout calculated in the previous frame or state. |
| /// <summary> | ||
| /// A reference to the layout calculated in the previous frame or state. | ||
| /// This is strictly required for the "incremental" aspect of the layout, as the algorithm | ||
| /// uses the positions from this old layout to try and keep nodes as close to their previous |
There was a problem hiding this comment.
Warning
Trailing whitespace detected! Please remove it.
| /// uses the positions from this old layout to try and keep nodes as close to their previous | |
| /// uses the positions from this old layout to try and keep nodes as close to their previous |
| public IncrementalRectanglePackingLayout oldLayout; | ||
|
|
||
| /// <summary> | ||
| /// Implements the IIncrementalNodeLayout interface property. Provides a safe setter to |
There was a problem hiding this comment.
Warning
Trailing whitespace detected! Please remove it.
| /// Implements the IIncrementalNodeLayout interface property. Provides a safe setter to | |
| /// Implements the IIncrementalNodeLayout interface property. Provides a safe setter to |
|
|
||
| /// <summary> | ||
| /// Implements the IIncrementalNodeLayout interface property. Provides a safe setter to | ||
| /// inject the previous layout instance. It ensures type safety by throwing an ArgumentException |
There was a problem hiding this comment.
Warning
Trailing whitespace detected! Please remove it.
| /// inject the previous layout instance. It ensures type safety by throwing an ArgumentException | |
| /// inject the previous layout instance. It ensures type safety by throwing an ArgumentException |
koschke
left a comment
There was a problem hiding this comment.
There are still many open issues left raised by Copilot and me. There are new issues with trailing whitespaces.
Please fix those.
Adds incremental rectangle and circle packing layouts with historical position preservation and registers them for city rendering.
Changes: