-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add 3D cube topology support and wrapping animations #5604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -185,9 +185,66 @@ bool Segment::isPixelXYClipped(int x, int y) const { | |
| return false; | ||
| } | ||
|
|
||
| void Segment::_applyCubeWrapping(int &x, int &y) const | ||
| { | ||
| // AI: below section was generated by an AI | ||
| if (!strip.isCube || map1D2D != M12_Cube) return; | ||
| const uint16_t vH = vHeight(); | ||
| const uint16_t vW = vWidth(); | ||
| if (vH % 3 != 0 || vW != (vH / 3) * 4) return; | ||
|
|
||
| int n = vH / 3; | ||
| // AI: end | ||
| // Horizontal belt wrap (Left, Front, Right, Back) | ||
| if (y >= n && y < 2 * n) { | ||
| x %= (4 * n); if (x < 0) x += (4 * n); | ||
| return; | ||
| } | ||
|
|
||
| // AI: below section was generated by an AI | ||
| // Handle vertical transitions and corner gaps | ||
| int fx = (x >= 0) ? (x / n) : -1; | ||
| int fy = (y >= 0) ? (y / n) : -1; | ||
| int u = (x % n + n) % n; | ||
| int v = (y % n + n) % n; | ||
|
|
||
| // 1. Moving UP from Top face (Face 0) or belt faces into Top gap | ||
| if (y < n) { | ||
| if (fx == 1) { // On Top face | ||
| if (y < 0) { // Move UP to Back face (Face 4) | ||
| x = 4 * n - 1 - u; y = n + v; // Back face top meets Top face top (inverted) | ||
| } | ||
| } else { // In gaps or outside | ||
| if (fx == 0) { // Top-Left gap -> map to Top face left edge | ||
| x = n + v; y = u; | ||
| } else if (fx == 2) { // Top-Right gap -> map to Top face right edge | ||
| x = 2 * n - 1 - v; y = n - 1 - u; | ||
| } else { // Back face top part | ||
| x = (4 * n) - 1 - u; y = (n - 1) - v; | ||
| } | ||
| } | ||
| } | ||
| // 2. Moving DOWN from Bottom face (Face 5) or belt faces into Bottom gap | ||
| else if (y >= 2 * n) { | ||
| if (fx == 1) { // On Bottom face | ||
| if (y >= 3 * n) { // Move DOWN to Back face (Face 4) | ||
| x = 4 * n - 1 - u; y = 2 * n - 1 - (y - 3 * n); | ||
| } | ||
| } else { // In gaps | ||
| if (fx == 0) { // Bottom-Left gap -> map to Bottom face left edge | ||
| x = n + (n - 1 - v); y = 2 * n + u; | ||
| } else if (fx == 2) { // Bottom-Right gap -> map to Bottom face right edge | ||
| x = 2 * n - 1 - (n - 1 - v); y = 2 * n + (n - 1 - u); | ||
| } | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| } | ||
| // AI: end | ||
| } | ||
|
Comment on lines
+188
to
+223
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Inside the
This contradicts the design that out-of-cube-net coordinates should remain out of range so the caller's Tightening to an exact 🛠️ Proposed fix } else if (fy == 0) {
if (fx == 0) { // Top-Left gap -> maps to Top face left edge
x = n + (n - 1 - v); y = u;
} else if (fx == 2) { // Top-Right gap -> maps to Top face right edge
x = n + v; y = n - 1 - u;
- } else if (fx != 1) { // fx == 3 (Top-Back gap) -> maps to Top face top edge
+ } else if (fx == 3) { // Top-Back gap -> maps to Top face top edge
x = 2 * n - 1 - u; y = n - 1 - v;
}
} else if (fy == 2) {
if (fx == 0) { // Bottom-Left gap -> maps to Bottom face left edge
x = n + v; y = 3 * n - 1 - u;
} else if (fx == 2) { // Bottom-Right gap -> maps to Bottom face right edge
x = 2 * n - 1 - v; y = 2 * n + u;
- } else if (fx != 1) { // fx == 3 (Bottom-Back gap) -> maps to Bottom face bottom edge
+ } else if (fx == 3) { // Bottom-Back gap -> maps to Bottom face bottom edge
x = 2 * n - 1 - u; y = 3 * n - 1 - v;
}
}🤖 Prompt for AI Agents |
||
|
|
||
| void IRAM_ATTR_YN Segment::setPixelColorXY(int x, int y, uint32_t col) const | ||
| { | ||
| if (!isActive()) return; // not active | ||
| if (strip.isCube && map1D2D == M12_Cube) _applyCubeWrapping(x, y); | ||
| if ((unsigned)x >= vWidth() || (unsigned)y >= vHeight()) return; // if pixel would fall out of virtual segment just exit | ||
| setPixelColorXYRaw(x, y, col); | ||
| } | ||
|
|
@@ -238,6 +295,7 @@ void Segment::setPixelColorXY(float x, float y, uint32_t col, bool aa) const | |
| // returns RGBW values of pixel | ||
| uint32_t IRAM_ATTR_YN Segment::getPixelColorXY(int x, int y) const { | ||
| if (!isActive()) return 0; // not active | ||
| if (strip.isCube && map1D2D == M12_Cube) _applyCubeWrapping(x, y); | ||
| if ((unsigned)x >= vWidth() || (unsigned)y >= vHeight()) return 0; // if pixel would fall out of virtual segment just exit | ||
| return getPixelColorXYRaw(x,y); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.