-
-
Notifications
You must be signed in to change notification settings - Fork 18
Refactor capsule creation to support dynamic shape selection #597
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
Changes from all 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 |
|---|---|---|
|
|
@@ -58,7 +58,7 @@ const disposePhysics = (targetMesh) => { | |
| const createPhysicsShape = (mesh, shapeType) => { | ||
| if (shapeType === "CAPSULE") { | ||
| mesh.computeWorldMatrix(true); | ||
| return flock.createCapsuleFromBoundingBox(mesh, flock.scene); | ||
| return flock.createShapeFromBoundingBox(mesh, flock.scene); | ||
| } | ||
|
Comment on lines
58
to
62
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. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C3 'getShapeTypeFromPhysics|PhysicsShapeBox|createShapeFromBoundingBox|physicsShapeType|physicsCache|resolvedShapeType|setupMesh' api/physics.js api/mesh.jsRepository: flipcomputing/flock Length of output: 6511 🏁 Script executed: sed -n '3,17p' api/physics.jsRepository: flipcomputing/flock Length of output: 448 Persist the actual collider type returned by
Derive the real shape type from the returned object immediately after creation and cache it instead of the requested type. 🤖 Prompt for AI Agents |
||
| return new flock.BABYLON.PhysicsShapeMesh(mesh, flock.scene); | ||
| }; | ||
|
|
@@ -325,7 +325,7 @@ export const flockPhysics = { | |
| disposePhysics(targetMesh); | ||
|
|
||
| // IMPORTANT: use targetMesh (not outer mesh) | ||
| const physicsShape = flock.createCapsuleFromBoundingBox( | ||
| const physicsShape = flock.createShapeFromBoundingBox( | ||
| targetMesh, | ||
| flock.scene, | ||
| ); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the same threshold for the fallback and the shrink step.
height < 2 * radiusis checked before subtractingshrinkAmount, so meshes atheight === 2 * radius— or within0.01above it — still go down the capsule path and end up with a negativecylinderHeight. That reintroduces the degenerate geometry this change is trying to avoid.Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents