Fix carving tool hallway gaps and consolidate strokes#15
Open
Fix carving tool hallway gaps and consolidate strokes#15
Conversation
…nability Refactor main orchestration into modular helpers
…, repoint ecs-lib
…n-simulation-iwvzyn Render analytic demo dungeon with FOV overlays
…y-items Show pickup tooltip within reach
…-mechanics Improve overlay interactions and movement
…iptref Refactor rules scripting to use shared ScriptRef
…th-emissive-torches Add emissive torch lighting with occlusion
…add-lightning-spell-mechanic Add lightning gesture casting and improve movement
wooden bow + projectile
…hanics Fix touch targeting and ranged ammo handling
…ctional-movement Add grid-based movement and wall glyph rendering
…le-for-passageway Add demo entry door and shrink player collision radius
There was a problem hiding this comment.
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; } |
There was a problem hiding this comment.
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Testing
Codex Task