Add barycentric coordinates to ray vs. triangle collision results#2663
Open
Add barycentric coordinates to ray vs. triangle collision results#2663
Conversation
Agent-Logs-Url: https://github.com/jMonkeyEngine/jmonkeyengine/sessions/75a9c930-942a-438a-b24e-9cc4c7daa5a2 Co-authored-by: riccardobl <4943530+riccardobl@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add barycentric coordinates calculation for ray-triangle collision
Add barycentric coordinates to ray vs. triangle collision results
Mar 28, 2026
Member
|
Can you add a boolean flag to CollisionResults to enable barycentric coordinate computation? So that it is done only when the developer need them? @copilot |
Agent-Logs-Url: https://github.com/jMonkeyEngine/jmonkeyengine/sessions/86d05467-fc58-41ed-a878-1c31d48e6575 Co-authored-by: riccardobl <4943530+riccardobl@users.noreply.github.com>
Contributor
Author
Done in commit 16a97ce. Added |
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.
Ray-triangle collision results (
CollisionResult) had no way to retrieve barycentric coordinates of the contact point, making texture-coord interpolation and surface-parameter lookups impossible without redundant re-computation.Changes
CollisionResult: AddedcontactBaryCoords(Vector2f) field with getter/setter. Convention:(u, v)whereu= weight ofv1,v= weight ofv2,1-u-v= weight ofv0.CollisionResults: AddedrequiresBaryCoordsboolean flag (defaultfalse) withsetRequiresBaryCoords(boolean)/isRequiresBaryCoords(). Barycentric coordinates are only computed and stored when this flag is enabled, avoiding unnecessary allocation and math for callers that don't need them.Ray: Addedintersects(Vector3f v0, Vector3f v1, Vector3f v2, Vector2f baryCoords)overload that computes barycentric coordinates alongside the hit distance in a single pass. UpdatedcollideWith(AbstractTriangle)to populatecontactBaryCoordson the result only when the flag is set.BIHNode: UpdatedintersectWhere()leaf loop (mesh collision path) to use the new overload and store barycentric coords on eachCollisionResultonly when the flag is set.Usage
getContactBaryCoords()returnsnullwhen the flag is disabled (default) or for collision types that don't involve a triangle (e.g. bounding volume hits).✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.