Expose JPH::PlaneShape via JPC_PlaneShapeSettings - #25
Merged
Conversation
3 tasks
Member
|
Hello and thank you! Can you remove the titan comments from the code? Then it's good to merge! |
JPH ships PlaneShape (an infinite-half-space collider; "negative half
space is solid") but JoltC did not expose it via the C API. Downstream
backends that want a real halfspace primitive — e.g. Titan's
`titan-jolt-3d` mapping its `BodyShape::Halfspace { normal }` — had to
approximate with a thin static box, which loses the authored normal +
forces an arbitrary thickness offset.
Add `JPC_PlaneShapeSettings { UserData, Normal, Constant, HalfExtent }`
+ `_default` + `_Create`. The C-side struct carries Normal + Constant
rather than a Plane wrapper to avoid introducing a new JPC_Plane
binding for a single use site; the implementation constructs the
JPH::Plane via its `Plane(Vec3 normal, float constant)` ctor. Material
is stubbed (`TODO: Material`) consistent with every other
`*ShapeSettings` in the codebase.
PlaneShape MUST be static or kinematic per JPH; that constraint is the
caller's responsibility (matches the existing PlaneShape usage in the
JoltPhysics samples).
Contributor
Author
|
Done — removed both |
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.
Problem
JoltC does not expose
JPH::PlaneShape(the infinite-half-space collider; "negative half space is solid"). Downstream consumers that want a real halfspace primitive — for example mapping aHalfspace { normal }shape from a higher-level physics abstraction — have no choice but to approximate with a thin static box, which loses the authored normal direction and forces an arbitrary thickness offset.Fix
Add
JPC_PlaneShapeSettings+ matching_default/_Createexports following the same pattern asJPC_BoxShapeSettings,JPC_SphereShapeSettings, etc.The C-side struct carries
Normal+Constantrather than aJPC_Planewrapper to avoid introducing a new binding type for a single use site; the C++ side constructs theJPH::Planevia itsPlane(Vec3 normal, float constant)ctor.Materialis stubbed with aTODOcomment, consistent with every other*ShapeSettingsin the codebase.HalfExtentdefaults toJPH::PlaneShapeSettings::cDefaultHalfExtent(1000.0f), matching JPH's own default.Constraint
PlaneShapeMUST be static or kinematic per JPH (PlaneShape::MustBeStatic() == true). Caller's responsibility, same contract asJoltPhysics/Samples/Tests/Shapes/PlaneShapeTest.cppupstream.Validation
Downstream verification: Titan engine's
titan-jolt-3dplugin uses this binding to back itsBodyShape::Halfspace { normal }. New integration test (halfspace_authors_non_y_normal) raycasts a non-+Y halfspace and asserts:The same test against the prior thin-box approximation returned axis-aligned normals on the box faces, never the authored plane normal — concrete evidence that the new path actually exercises
PlaneShape::GetSurfaceNormal.Test plan
mainon Windows host (msvc).JPC_PlaneShapeSettings_Createreturns a validJPC_Shape*for a +Y normal at the origin.TODOlike every other shape).