|
| 1 | +--- |
| 2 | +title: "DMP’25 Week 08 Update by Justin Charles" |
| 3 | +excerpt: "Implemented brick disconnection logic for towers, enabling subtree detachment and independent movement of child groups" |
| 4 | +category: "DEVELOPER NEWS" |
| 5 | +date: "2025-07-27" |
| 6 | +slug: "2025-07-27-dmp-25-justin212407-week08" |
| 7 | +author: "@/constants/MarkdownFiles/authors/justin-charles.md" |
| 8 | +tags: "dmp25,sugarlabs,week8,justin212407" |
| 9 | +image: "assets/Images/c4gt_DMP.webp" |
| 10 | +--- |
| 11 | + |
| 12 | +<!-- markdownlint-disable --> |
| 13 | + |
| 14 | +# Week 8 Progress Report by Justin Charles |
| 15 | + |
| 16 | +**Project:** Music Blocks 4 Masonry |
| 17 | +**Mentors:** [Anindya Kundu](https://github.com/meganindya/), [Sumit Srivastava](https://github.com/sum2it) |
| 18 | +**Assisting Mentors:** [Devin Ulibari](https://github.com/pikurasa/), [Walter Bender](https://github.com/walterbender) |
| 19 | +**Reporting Period:** 2025-07-21 - 2025-07-27 |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## Goals for This Week |
| 24 | + |
| 25 | +- Extend tower drag logic by implementing brick disconnection |
| 26 | +- Allow subtree detachment from parent towers when dragging out child bricks |
| 27 | +- Maintain consistent state updates for both the parent and the detached subtree |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## This Week’s Highlights |
| 32 | + |
| 33 | +### 1. **Brick Disconnection Implementation** |
| 34 | + |
| 35 | +Expanded [PR #450](https://github.com/sugarlabs/musicblocks-v4/pull/450) to support brick disconnection: |
| 36 | +- Enabled dragging of a child brick (and its subtree) out of a parent tower |
| 37 | +- Ensured detached bricks retain hierarchy and become a new independent tower |
| 38 | +- Updated `TowerModel` to support `detachSubtree` operation with proper ID remapping |
| 39 | + |
| 40 | +### 2. **State Management for Disconnected Bricks** |
| 41 | + |
| 42 | +- Synced Recoil state so detached subtrees re-register as new towers |
| 43 | +- Updated reverse mapping utility to correctly track parent/child relations after split |
| 44 | +- Maintained integrity of collision maps by removing and re-adding affected nodes |
| 45 | + |
| 46 | +### 3. **Improved Workspace Interactivity** |
| 47 | + |
| 48 | +- Added consistent cursor anchoring when pulling bricks from towers |
| 49 | +- Ensured visual feedback during disconnection (brick shadows and offset updates) |
| 50 | +- Prevented invalid states by blocking disconnection of non-draggable root nodes |
| 51 | + |
| 52 | +--- |
| 53 | + |
| 54 | +## Challenges & Solutions |
| 55 | + |
| 56 | +**Challenge:** Preventing partial subtree corruption during disconnection |
| 57 | +**Solution:** Built a dedicated `detachSubtree()` method that clones and relocates the full hierarchy safely |
| 58 | + |
| 59 | +**Challenge:** Collision map desync when multiple towers updated at once |
| 60 | +**Solution:** Batched tower re-registration to ensure atomic updates across maps |
| 61 | + |
| 62 | +--- |
| 63 | + |
| 64 | +## Key Learnings |
| 65 | + |
| 66 | +- **Subtree Logic** |
| 67 | + Learned how to safely extract and reinitialize hierarchical structures without breaking references |
| 68 | + |
| 69 | +- **Tower Model Flexibility** |
| 70 | + Deepened understanding of extending core tower APIs (`add`, `merge`, `detach`) for scalable interactions |
| 71 | + |
| 72 | +- **Collision Map Resilience** |
| 73 | + Saw how batching state updates helps avoid flickers and false collisions in real-time rendering |
| 74 | + |
| 75 | +--- |
| 76 | + |
| 77 | +## Next Week’s Roadmap |
| 78 | + |
| 79 | +- Implement snapping of detached towers onto valid drop zones |
| 80 | +- Introduce shadow previews for disconnection to guide user interaction |
| 81 | +- Begin refining attach logic for merging detached towers back together |
| 82 | + |
| 83 | +--- |
| 84 | + |
| 85 | +## Resources & References |
| 86 | + |
| 87 | +- [musicblocks-v4 PR #450](https://github.com/sugarlabs/musicblocks-v4/pull/450) |
| 88 | +- [musicblocks-v4 Repository](https://github.com/sugarlabs/musicblocks-v4) |
| 89 | + |
| 90 | +--- |
| 91 | + |
| 92 | +## Acknowledgments |
| 93 | + |
| 94 | +Thanks to my mentors for helping validate the disconnection workflow and ensuring robustness of the tower model. |
0 commit comments