Skip to content

Conversation

@PJensen
Copy link
Owner

@PJensen PJensen commented Nov 9, 2025

Summary

  • merge consecutive capsule strokes so straight hallway passes render as single segments
  • finalize drag strokes on pointer release to avoid short corridor gaps
  • consolidate imported carvings automatically to clean up artifacts

Testing

  • npm test (fails: missing src/lib/ecs-js/index.js)

Codex Task

Copilot AI review requested due to automatic review settings November 9, 2025 17:57
Copy link

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 adds capsule consolidation functionality to the world carving editor, which merges consecutive, aligned capsule primitives created during circle brush strokes to optimize the geometry representation.

Key Changes:

  • Implements a new consolidateCapsules() function that merges consecutive capsules with matching properties, similar directions, and touching endpoints
  • Automatically applies consolidation after circle brush strokes and when deserializing saved worlds
  • Enhances the pointerup handler to add final segments, release pointer capture properly, and trigger consolidation

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

window.addEventListener('pointerup',()=>{ isDragging=false; });
window.addEventListener('pointerup',e=>{ if(!isDragging) return; isDragging=false; if(canvas.releasePointerCapture){ try{ canvas.releasePointerCapture(e.pointerId);}catch(err){/* ignore */} }
if(ui.mode.value!=='carve') return; const [x,y]=canvasToWorld(e); const dx=x-lastX,dy=y-lastY; const dist=Math.hypot(dx,dy); if(dist>0.01){ addSegment(lastX,lastY,x,y,e); lastX=x; lastY=y; }
if(ui.brush.value==='circle'){ if(Kernel.consolidateCapsules()) undoStack.length=Kernel.carves.length; } else { undoStack.length=Kernel.carves.length; }
Copy link

Copilot AI Nov 9, 2025

Choose a reason for hiding this comment

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

The undo stack synchronization is performed in both branches of the conditional, making the code redundant. Consider simplifying to:

if(ui.brush.value==='circle') Kernel.consolidateCapsules();
undoStack.length=Kernel.carves.length;

This makes the intent clearer: consolidate capsules for circle brush, then always sync the undo stack length.

Suggested change
if(ui.brush.value==='circle'){ if(Kernel.consolidateCapsules()) undoStack.length=Kernel.carves.length; } else { undoStack.length=Kernel.carves.length; }
if(ui.brush.value==='circle') Kernel.consolidateCapsules();
undoStack.length=Kernel.carves.length;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants