Skip to content

Commit f03d084

Browse files
authored
DMP 2025 Week 9 updates by Justin Charles (#416)
Signed-off-by: justin212407 <[email protected]>
1 parent c245f1d commit f03d084

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
title: "DMP’25 Week 09 Update by Justin Charles"
3+
excerpt: "Mapped out the integration plan for brick connections in Music Blocks 4, including collision maps, detection workflow, and tower merge/stale strategies"
4+
category: "DEVELOPER NEWS"
5+
date: "2025-08-03"
6+
slug: "2025-08-03-dmp-25-justin212407-week09"
7+
author: "@/constants/MarkdownFiles/authors/justin-charles.md"
8+
tags: "dmp25,sugarlabs,week9,justin212407"
9+
image: "assets/Images/c4gt_DMP.webp"
10+
---
11+
12+
<!-- markdownlint-disable -->
13+
14+
# Week 9 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-28 - 2025-08-03
20+
21+
---
22+
23+
## Goals for This Week
24+
25+
- Map out a concrete plan for integrating **brick-to-brick connections**
26+
- Define data structures and maps for efficient collision queries
27+
- Document full lifecycle of connection events: drag start → collision → drop → merge/stale
28+
29+
---
30+
31+
## This Week’s Highlights
32+
33+
### 1. **Workspace Presentation Design**
34+
35+
- On adding a tower (or the very first brick) to the workspace, we compute **absolute coordinates** of all *incoming* connection points:
36+
- Expression right-side notches
37+
- Statement bottom notches
38+
- Compound brick inner-top notches
39+
40+
- These coordinates are registered into quadtree-based data structures for performance.
41+
- Reverse mapping utility (`notchId → {BrickId, TowerId}`) ensures we can quickly trace which tower/brick owns a given notch.
42+
- For efficiency, only the towers/bricks that change are recomputed.
43+
44+
---
45+
46+
### 2. **Collision Maps**
47+
48+
Created a two-map design for separating brick connection points:
49+
- **Expression Map** → Holds all expression brick notches
50+
- **Statement Map** → Holds all statement brick notches
51+
52+
Each entry is indexed by a unique **Notch ID**, which reverse maps to `{BrickId, TowerId}`.
53+
This allows collision queries to resolve directly into the correct brick and tower model.
54+
55+
---
56+
57+
### 3. **Collision Detection Workflow**
58+
59+
- On **drag start**, all notch coordinates belonging to the dragged brick/tower are removed from the maps (to avoid self-matching).
60+
- During drag, we continuously check outgoing notch coordinates against the target map (expression or statement).
61+
- On **each mouse move**, detect overlapping notch pairs:
62+
- When overlap occurs → log `{BrickId, TowerId}` from the map as a *potential connection*.
63+
- Reverse mapping utility helps locate the parent brick within its tower for precise attachment.
64+
65+
---
66+
67+
### 4. **Merge & Stale Tower Logic**
68+
69+
- **Merge:**
70+
If drag ends on a collision, fetch the target tower via reverse mapping. Merge dragged tower into it, attaching at the correct brick notch.
71+
72+
- **Shadow Feedback:**
73+
During drag, show a shadow element preview of where the connection will happen.
74+
75+
- **Stale:**
76+
- If no collision occurs and drag ends → tower remains standalone.
77+
- Its incoming connection coordinates are re-registered into the collision maps.
78+
- If no collision occurs and drag continues → shadow disappears.
79+
80+
---
81+
82+
## Challenges & Considerations
83+
84+
- **Efficient Updates:** Needed a strategy to update only changed towers instead of recomputing the entire map.
85+
- **Shadow Feedback:** Designing the UI to show previews without interfering with state was tricky.
86+
- **Tower Integrity:** Ensured merge/disconnection logic didn’t break brick hierarchies when recomputed.
87+
88+
---
89+
90+
## Key Learnings
91+
92+
- Importance of **reverse mapping utilities** for bridging geometry (notch coords) with logical models (brick/tower).
93+
- How **separating expression vs statement maps** simplifies collision lookups and prevents false positives.
94+
- Designing clear **merge vs stale outcomes** ensures intuitive user interactions in the workspace.
95+
96+
---
97+
98+
## Next Week’s Roadmap
99+
100+
- Begin implementing the **connection merge logic** in the workspace manager
101+
- Add real-time shadow previews for possible brick connections
102+
- Start writing utility tests for collision detection and merge scenarios
103+
104+
---
105+
106+
## Resources & References
107+
108+
- [musicblocks-v4 Repository](https://github.com/sugarlabs/musicblocks-v4)
109+
- [Document for brick connection](https://docs.google.com/document/d/1C0t4iSze2eDEv6lWbloK3MnvJgAa6HvmXmk2sQ0lCZs/edit?tab=t.wc31i1lo6mgp)
110+
- [Quadtree Algorithm Notes](https://en.wikipedia.org/wiki/Quadtree)
111+
112+
---
113+
114+
## Acknowledgments
115+
116+
Thanks to my mentor Anindya Kundu on revisiting the basic of brick connections and helping me refine the connection lifecycle and reviewing the mapping approach.

0 commit comments

Comments
 (0)