$ show LogicalError/realtime-CSG-for-unity
RealtimeCSG is a real-time constructive solid geometry (CSG) level design tool for Unity. It operates exclusively as an Editor extension, providing non-destructive boolean operations on brushes (box, sphere, cylinder, stairs, free-draw) with immediate visual feedback in the Scene view. The architecture is manager-driven: `InternalCSGModelManager` orchestrates hierarchy updates, mesh generation, and caching, while a native C++ DLL handles performance-critical CSG calculations. The tool offers multiple edit modes (Generate, Edit, Clip, Place, Surface) each with custom scene tools, handles, and inspector GUIs. It supports material assignment, UV editing, export to FBX or Unity prefab, and includes a full half-edge mesh representation (`ControlMesh`) for local mesh editing (vertex/edge/polygon). The codebase heavily relies on Unity Editor APIs, reflection to access internal Unity systems, and conditionals for cross-version compatibility. It is a production-grade, feature-rich tool used in game development workflows, though the closed-source native core and editor-only architecture limit runtime usage and cross-platform deployment.
The LLM identified 4 files worth highlighting for reuse:
Provides a global tooltip display system for editor elements. Manages delayed tooltip state (`currentToolTip`, `previousToolTip`, `currentFrame`) and draws tooltips with a consistent style. The 'SetToolTip' / 'DrawToolTip' pattern is isolated and can be reused in any Unity Editor extension for custom tooltips.
Implements `IDisposable` to wrap a group of undo operations (`Undo.IncrementCurrentGroup`, `Undo.RegisterCompleteObjectUndo`) with optional collapse (`Undo.FlushUndoRecordObjects`). Allows batching multiple modifications into a single undo step. The pattern is independent and can be extracted for any Unity tool needing atomic undo grouping.
A static utility class for converting and displaying distance and angle values in various units (meters, millimeters, inches, imperial fractions). Provides string formatting with localization support (e.g., `Meters`, `FeetAndInches`). The conversion logic is self-contained and can be reused in any Unity tool that needs metric/imperial display.
A static utility class for 2D polygon operations: duplicate vertex removal, self-intersection detection, convexity checks, and control mesh generation from a flat outline. Used by extruded shape generators (box, cylinder, stairs). The algorithms are well-defined and could be extracted as a reusable geometry library for editor tools or runtime mesh creation.