Skip to content

Geometric shape box revision#1051

Merged
Xiangyu-Hu merged 11 commits intomasterfrom
geometric_shape_box_revision
Apr 12, 2026
Merged

Geometric shape box revision#1051
Xiangyu-Hu merged 11 commits intomasterfrom
geometric_shape_box_revision

Conversation

@Xiangyu-Hu
Copy link
Copy Markdown
Owner

@Xiangyu-Hu Xiangyu-Hu commented Apr 7, 2026

This pull request introduces several improvements and refactorings to the geometric shape and entity management systems, as well as some related code cleanup in both 2D and 3D builds. The most significant changes include a major refactor and extension of the MultiPolygon API, enhanced ownership semantics in the EntityManager, and unification and simplification of box shape proxy writing logic. These changes improve code clarity, maintainability, and extensibility.

Geometric Shape and Proxy Refactoring:

  • Refactored the proxy writing logic for box shapes in both 2D and 3D: removed duplicated code from body part files and unified the functionality in the GeometricShapeBox class with a new writeProxy() method. This centralizes the proxy writing logic and makes it reusable. (src/for_2D_build/geometries/geometric_shape_2d.cppsrc/for_2D_build/geometries/geometric_shape_2d.cpp, src/for_3D_build/geometries/geometric_shape_3d.cpp, src/shared/bodies/base_body_part.cpp, src/for_3D_build/bodies/base_body_part_3d.cpp, src/shared/geometries/geometric_shape.h, src/shared/geometries/geometric_shape.cpp) [1] [2] [3] [4] [5] [6]

  • Added a constructor to GeometricShapeBox that accepts a TransformGeometryBox for more flexible instantiation. (src/shared/geometries/geometric_shape.cpp, src/shared/geometries/geometric_shape.h) [1] [2]

MultiPolygon API Refactor and Extension:

  • Renamed and refactored methods in MultiPolygon for better clarity and consistency (e.g., addAPolygonaddPolygon, addACircleaddCircle). Added new methods such as addBox (from a bounding box), addContainerBox, and improved const-correctness for getBoostMultiPoly. This makes the API more intuitive and extensible. (src/for_2D_build/geometries/multi_polygon_shape.cpp, src/for_2D_build/geometries/multi_polygon_shape.h) [1] [2] [3] [4] [5] [6]

Entity Manager Ownership and API Improvements:

  • Enhanced the EntityManager to support managed ownership of entities via SharedPtr, including new methods for adding, emplacing, and removing entities with ownership semantics. The manager now properly releases owned entities on clear or removal, improving memory safety and lifecycle management. (src/shared/common/sphinxsys_entity.h) [1] [2]

General Codebase Cleanup and Improvements:

  • Removed redundant type aliases (Rotationd = Rotation2d/3d) from common data type headers. (src/for_2D_build/common/data_type.h, src/for_3D_build/common/data_type.h) [1] [2]
  • Improved GeometricBox with a HalfSize() getter for encapsulation. (src/shared/geometries/geometric_element.h)
  • Minor improvements to includes, constructors (e.g., ComplexShape default name), and code formatting for clarity and consistency. (src/shared/geometries/complex_geometry.h, src/shared/common/sphinxsys_entity.h, src/for_3D_build/geometries/sdf_shape.h) [1] [2] [3] [4] [5]

These changes collectively improve the maintainability, clarity, and extensibility of the geometric and entity management infrastructure.

@Xiangyu-Hu Xiangyu-Hu requested a review from Lisu-lisa April 7, 2026 22:39
@Xiangyu-Hu Xiangyu-Hu merged commit 3f2b3b5 into master Apr 12, 2026
8 checks passed
@Xiangyu-Hu Xiangyu-Hu deleted the geometric_shape_box_revision branch April 12, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants