Skip to content

Cycle cell shapes per pattern in cinematic mode#10

Merged
hybridmachine merged 2 commits into
masterfrom
feature/cinematic-cell-shape-cycling
May 16, 2026
Merged

Cycle cell shapes per pattern in cinematic mode#10
hybridmachine merged 2 commits into
masterfrom
feature/cinematic-cell-shape-cycling

Conversation

@hybridmachine
Copy link
Copy Markdown
Owner

Summary

  • Cinematic mode now randomizes the cell shape on every pattern transition, mirroring the existing palette-cycling behavior in CinematicController.
  • Uses the same "pick random but never repeat the previous index" algorithm as PickNextPaletteIndex, so consecutive cycles always differ.
  • The user's pre-cinematic RenderSettings.Shape is saved on Start() and restored on Stop(), matching how GradientStops is preserved.

All 9 shapes (Cube, BeveledCube, Tetrahedron, Octahedron, SquarePyramid, Icosahedron, Dodecahedron, Sphere, Capsule) are eligible. No changes outside CinematicController.cs — the existing shape plumbing in RenderSettings, InstancedCellRenderer, ImGuiUI, and SessionManager is reused as-is.

Test plan

  • dotnet build succeeds with no warnings
  • Enter cinematic mode (press P) and watch 3+ transitions — each shows a visibly different cell shape, no two consecutive shapes repeat, and palette cycling still works independently
  • Set Cell Shape dropdown to a distinctive value (e.g. Capsule), enter cinematic, let it run, press Escape — dropdown and rendered cells return to Capsule
  • Toggle cinematic on/off twice — camera flythrough, fade-in reveal, and pattern label overlay all behave as before
  • Save a session before entering cinematic, reload after exiting — shape persists correctly

🤖 Generated with Claude Code

Mirrors the existing palette-cycling behavior: each new pattern in
cinematic mode now also picks a random cell shape, avoiding the shape
used in the previous cycle. The user's pre-cinematic shape is saved on
Start() and restored on Stop() so toggling cinematic mode does not
silently overwrite their working selection.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 16, 2026 03:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates cinematic mode to also cycle the rendered cell shape on each pattern transition, using the same “random but never repeat the previous selection” approach already used for palette cycling. It also preserves the user’s pre-cinematic shape choice by saving it on Start() and restoring it on Stop().

Changes:

  • Save/restore RenderSettings.Shape when entering/exiting cinematic mode.
  • Randomize RenderSettings.Shape on each cinematic cycle, avoiding consecutive repeats.
  • Track last-picked shape index to support non-repeating selection logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +264 to +272
private int PickNextCellShapeIndex()
{
int n = Enum.GetValues<CellShape>().Length;
if (n <= 1) return 0;
if (_lastShapeIndex < 0) return Random.Shared.Next(n);
int next = Random.Shared.Next(n - 1);
if (next >= _lastShapeIndex) next++;
return next;
}
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call — there was an asymmetry with PickNextPaletteIndex, which already indexes into the actual GradientPresets.Presets array. Fixed in c117d8c by caching Enum.GetValues<CellShape>() as a static AllCellShapes array and using Array.IndexOf / array indexing instead of int casts. Now correct even if the enum gains non-contiguous values.

Addresses Copilot review feedback on PR #10. Cache the CellShape values
array once as a static field, then look up the previously-applied shape
via Array.IndexOf and pick the next one by indexing into the array. This
mirrors how PickNextPaletteIndex already works (indexing into
GradientPresets.Presets) and stays correct if CellShape ever gains
non-contiguous explicit values.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hybridmachine hybridmachine merged commit f06a2fa into master May 16, 2026
@hybridmachine hybridmachine deleted the feature/cinematic-cell-shape-cycling branch May 16, 2026 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants