3D Collision debug view in-editor & in-game#8598
Draft
Bouh wants to merge 6 commits into
Draft
Conversation
`onBehaviorUpdated` in CompactObjectPropertiesEditor was a no-op, so editing behavior properties from the compact panel never propagated to the in-app editor preview. Wire it to `onObjectsModified([object])` like the other property edits in the same file. Debounced at 250ms via `useDebounce` to avoid one hot reload per keystroke on fields.
Extract the field initialization from the constructor into a private `_applyBehaviorData` helper, and reuse it for both the constructor (full data) and the hot-reload hook `applyBehaviorOverriding` (diff containing only changed fields). When any shape-related property is present in the diff, the body is rebuilt via `recreateBody()`. Previously the default `applyBehaviorOverriding` returned false, so hot reload of Physics3D properties was silently dropped, forcing a full restart of the app or closing and reopening the tab to see any tweak made in the editor.
Add `_debugDraw3DEnabled`, `_debugDraw3DColorHex` and `_debugDraw3DDepthTest` to RuntimeInstanceContainer, plus a new `enableDebugDraw3D(enabled, colorHex, depthTest)` method that mirrors the existing 2D `enableDebugDraw`. When the settings change while a draw is active, the existing wireframes are cleared so the renderer rebuilds them with the new configuration. `RuntimeScene.renderAndStep` calls `renderDebugDraw3D` each frame when the flag is on — same hook point as the 2D debug draw. The actual rendering is implemented in a follow-up commit.
Implement `renderDebugDraw3D` and `clearDebugDraw3D` on
DebuggerPixiRenderer. Wireframes are rendered as THREE.js meshes
attached to each object's 3D renderer object.
Supports the four Physics3D primitive shapes (Box, Sphere, Capsule,
Cylinder) including orientation (X/Y/Z), shape offsets, parent-scale
compensation, and the PhysicsCharacter3D bottom-origin adjustment.
Also supports the Mesh shape: each child mesh of the object's 3D
renderer is wrapped with a `THREE.WireframeGeometry` + LineSegments.
Async-loaded Model3D meshes are picked up automatically each frame,
and detached source meshes are pruned.
State is tracked in a `Map<RuntimeObject, DebugDraw3DState>` on the
renderer, with a per-frame `seen` set that disposes wireframes whose
owning object disappeared. CustomRuntimeObject children are visited
recursively so nested Physics3D objects are covered.
Wireframes opt out of raycasting (`mesh.raycast = () => {}`) so that
the community Raycaster3D extension doesn't crash on intersections
without normals.
Expose the new 3D debug-draw via two GDevelop actions in the Debugger Tools extension: - `EnableDebugDraw3D` — enable/disable with explicit color (R;G;B) and depth-test parameters. Mirrors the existing `EnableDebugDraw` action used for 2D. - `ToggleDebugDraw3D` — flips the current state, reusing the last color and depth-test values stored on the instance container. Both delegate to `RuntimeInstanceContainer.enableDebugDraw3D`.
…editor Add a Debug-icon button next to the Lightbulb in the root row of the Layers tree view (only when in embedded-game / in-app editor mode). Clicking it toggles the local state `areCollisionsShownInEditor` in SceneEditor and broadcasts a `set3DCollisionsShownInEditor` message to the embedded preview frames via `previewDebuggerServer`. The runtime debugger client receives the command and calls `enableDebugDraw3D` on the edited instance container, reusing the default color and depth-test settings. Props are threaded through the `EditorsDisplay` interface, both mosaic and swipeable-drawer displays, plus the LayersList story mock.
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.
Second part of #8597
The debug view displays Jolt's actual colliders and isn't meant to resize with the object. If we want collision shapes to follow the object on non-uniform rescaling across the three axes, we'd need to change the Jolt implementation itself so the body is rebuilt/scaled accordingly, not only the debug renderer.
Editor + in-game preview
592075839-68ae613b-c5e1-4633-baa3-e1ee7f091992.mp4
This also add an action to enable the debug from the events, and a toggle for it.
Credits goes to Eldarduil for his help and work on the debug threejs functions.
https://eldarduil.itch.io/show-3d-collision-shapes-for-gdevelop