21-05-2021, 03:16 PM
(This post was last modified: 21-05-2021, 03:20 PM by josemendez.)
(21-05-2021, 02:53 PM)Hatchling Wrote: I also hope I'm not being a pain in the ass.
Not at all! These are all reasonable requests.
A rough idea of how this could work:
ObiSolver has a Query() method, to which you pass an array of QueryShape structs, an array of AffineTransform structs (one per QueryShape) and it returns an array of QueryResult structs. Internally, calling solver.Query(shapes,transforms) schedules a job that parallelizes over all shapes.
QueryShape would have the following fields:
type (box, sphere, ray)
contactOffset (adds extra thickness to the shape, turning a ray into a capsule, rounding box corners, etc).
minDistance (minimum distance to look for simplices around the shape)
filter (category+mask, used for collision filtering)
QueryResult would have the following fields:
shapeIndex: index of the shape in the QueryShape array passed to the function.
simplexIndex: index of a simplex in the solver.
point: point in the surface of the shape closest to the simplex.
normal: direction of the shortest path between the shape and the simplex.
distance: distance between the shape and the simplex along the normal. negative if they overlap, positive otherwise.
I think this covers raycasts, spherecasts, overlap tests (check whether result distance is negative) and distance tests against capsules, spheres and boxes. What do you think?