-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Problem
The floor plan rendering was showing irregular triangular/polygonal shapes instead of proper rectangular room boundaries. This was causing:
- Assertion failures: 'boundaryCount > 1' failed
- Malformed room shapes showing as irregular triangles
- Coordinate misalignment between RoomPlan data and UI rendering
- Complex geometry extraction that didn't follow Apple's intended RoomPlan usage
Root Cause
The original RoomAnalyzer.swift was attempting to reconstruct room geometry from individual wall segments instead of using Apple's CapturedRoom.Surface data directly. This led to:
- Over-complex wall analysis - Trying to connect individual wall segments into room boundaries
- Coordinate transformation issues - Manual calculations instead of using RoomPlan transforms
- Ignoring Apple's architecture - Not leveraging
CapturedRoom.Surfacepolygons as intended
Solution
Completely rewrote RoomAnalyzer.swift to follow Apple's RoomPlan architecture:
Key Changes:
- Direct Surface Usage - Use
CapturedRoom.Surfacetransform matrices and dimensions directly - Simplified Geometry - Create room boundaries from surface data instead of reconstructing from walls
- Proper Transform Handling - Use RoomPlan's transform matrices for rotation and positioning
- Apple's Data Structures - Leverage
doors,windows,openingsarrays from RoomPlan
Technical Implementation:
// OLD: Complex wall reconstruction
let relevantWalls = capturedRoom.walls.filter { /* complex filtering */ }
let boundary = createOrderedRoomBoundary(walls: relevantWalls, ...)
// NEW: Direct surface usage
let center = extractSurfaceCenter(surface)
let dimensions = surface.dimensions
let transform = surface.transform
let rotation = atan2(transform.columns.0.z, transform.columns.0.x)
return corners.map { /* apply transform directly */ }Benefits:
- ✅ Proper rectangular room shapes
- ✅ No more assertion failures
- ✅ Follows Apple's intended RoomPlan usage
- ✅ Simplified, maintainable code
- ✅ Better coordinate alignment
Files Changed:
RoomPlanSimple/RoomAnalyzer.swift- Complete rewrite following Apple's architecture- Moved old implementation to
RoomAnalyzer_Old.swiftfor reference
Testing:
- App builds successfully
- No assertion failures during geometry extraction
- Need to test actual room rendering in simulator
Next Steps:
- Test the simplified implementation with actual room scanning
- Verify proper coordinate alignment with WiFi heatmap
- Clean up any remaining geometry issues
This fix aligns the codebase with Apple's intended usage of RoomPlan as demonstrated in their documentation and WWDC sessions.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels