Repository navigation
Keep things in the level with SolidCollision, not layer 30 - #70
Merged
Merged
Conversation
pererikbergman
approved these changes
Nov 27, 2026
pererikbergman
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me. It does what #67 asked, and the implementation points from the issue thread are in:
- The particle flag is a bit in
Particles.flags, andSolids.collideonly reads it onceanyPassSolidsis set, so default scenes cost what they did. PASScovers the grid and the moving solids, inSolids.collide,RigidContacts.findAgainstSolidsand both bullet sweeps.RigidBodies.setPassesSolidsreturns early when nothing changes and wakes the body in both directions, and both cases have tests.- Reused slots start clean (
Particles.addoverwritesflags,addAtclearspassesSolids,grow()copies it). SoftBodies.setSolidCollisioncovers the ring and the core, and the getter reads the core.
A few points, none blocking:
NONEdoesn't match the issue. #67's "Done when" sayssetLayersacceptsCollisionLayers.NONEaslayers, butcheckLayersstill rejects it, andlayersAreOneOrMoreOfAllThirtyTwomakes that deliberate. Rejecting it is defensible, since under the both-sides rulelayers = NONEdoes the same asmask = NONE. Could you say so in the PR description or update the issue, so #67 doesn't close with that line unmet?- Nit: the two settings are set in different places.
bodyCollisionis only a parameter ofadd(no setter), whilesolidCollisionis only a setter (no parameter onadd). AsolidCollision =parameter onadd,ropeandclothwould let a ghost spark be created in one call. - Nit: strands and cloth have no
setSolidCollision. Letting a rope or a cloth fall through the level means looping over its particles. That could be a follow-up. - Nit:
BodyCollisionis a slightly misleading name. It also controls particle-to-particle (grain) collisions, and it reads like a property of a body rather than of a particle. The KDoc explains it, so this is fine to keep. - A soft-body test would help. Only the
SoftBodySamples.setSolidCollisionsample coversSoftBodies.setSolidCollision. AFiltersTestcase with a soft body set toPASSfalling through the floor would be worth adding.
CI: the push-triggered Linux run failed after 11 seconds, before any tests ran, because Gradle couldn't download com.vanniktech.maven.publish 0.37.0. The pull_request run passed on all three platforms, so a re-run should clear it.
Owner
Author
|
Thanks. Fixed in 03d54a5:
|
The physics level sat on PhysicsLayers.SOLIDS, layer 30, and checkLayers
rejected layers 30 and 31, so a game lost two of the 32 layers it shares
with klyph.collision. Each rigid body, soft body and particle now has a
SolidCollision (COLLIDE by default, PASS falls through the level), set
with setSolidCollision, and every layer is the game's own.
ParticleCollision { SOLIDS, EVERYTHING } becomes BodyCollision
{ PASS, COLLIDE }, since it no longer says anything about solids.
The CollisionLayers and PhysicsLayers KDoc and the physics docs state
both layer rules: either side for Collisions, both sides for physics.
Resolves #67.
…OLLIDE #67 asks for setLayers to accept NONE, as a klyph Collider does. Under the both-sides rule a thing on no layer collides with no other thing, and the level still holds it, so the check had nothing left to guard.
inemtsev
force-pushed
the
physics-solid-collision
branch
from
November 28, 2026 12:12
03d54a5 to
9b3c825
Compare
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.
Resolves #67.
The level sat on
PhysicsLayers.SOLIDS(layer 30), andcheckLayersrejected layers 30 and 31. A game therefore had 30 of the 32 layers it shares withklyph.collision, and a mask that left out bit 30 dropped a body through the floor. Now every rigid body, soft body and particle has aSolidCollision. It isCOLLIDEby default, andPASSlets the thing fall through the grid and its moving solids, bullets included. All 32 layers belong to the game. Body-to-body filtering is unchanged.ParticleCollision { SOLIDS, EVERYTHING }is nowBodyCollision { PASS, COLLIDE }, because it no longer has anything to do with solids. TheCollisionLayersandPhysicsLayersKDoc anddocs/physics*state both rules:Collisionsneeds one side's mask to match, physics needs both.API changes (unreleased module)
enum class SolidCollision { COLLIDE, PASS }RigidBodies/SoftBodies/Particles:setSolidCollision(handle, SolidCollision),solidCollisionOf(handle)ParticleCollision→BodyCollision,collision =→bodyCollision =onParticles.add,rope,chain,strand,cloth;collisionOf→bodyCollisionOfPhysicsLayers.SOLIDSVerification
./gradlew checkpasses, and so do thegames/physicsscene tests (-Pklyph.physics.sceneTests=1). The new tests are inFiltersTest.benchmarkPhysics, release build on an M4 Max, ms per step:A 600-step boxes run reads about 0.6 ms slower on the branch. The gap is gone at 150 steps, turns into a win at 1,200, and the profiles match.
API style checklist
Booleanbehavior flags, lambda is last, defaults over overloads.data class, no platform types.require/checkfor validation; exception types and messages follow section 5.OrNullsibling where failure is expected.infix/operator/property use passes section 6.@throwsfor each exception.@samplepresent and runs as a test.toStringon every stateful public type.