Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How to query Obi geometry with raycasts?
#1
Pregunta 
Does Obi provide the ability to query the geometry of Obi Actors, like how Physics.Raycast, .Spherecast, etc. allows you to query colliders?

I'm assuming that most of the math involved for this has already been done somewhere in there in order to support collision detection.

I see there is ObiParticlePicker, but it seems like this approach isn't optimal:
  • Only allows picking particles directly, instead of by their collision geometry (simplexes)
  • Doesn't return a point on the surface that the ray first made contact
  • Doesn't query the particle grid to filter out most of the tests
  • Isn't written in efficient threaded code in the same way that other collision checks are
  • Only considers one solver
  • Cannot be invoked in a static way (like Physics.Raycast)
If I were more familiar with how to interface with the internal stuff of Obi, I'd be willing to write these queries myself. An interesting idea might be to provide some sort of base query class where you can implement custom queries (for example, getting the closest point on a simplex to the query point, within a certain radius (or infinite radius)). If I wrote something like this, I'd be willing to share the code with the hope that it'd be maintained as Obi is developed.

A global query would probably follow this procedure:
  1. Test the query condition against the oriented bounding box of each solver. If a given solver passes, then...
  2. Test the query condition against all occupied cells, OR, in cases where it is possible to determine which cells pass the query condition without enumerating through each cell, get a list of cells that pass the query condition. If a given cell passes, then...
  3. Test the query condition against all simplexes occupying the cell.
  4. For each simplex that passes the query condition, modify the query result.
    • In the case of a Raycast, replace the current hit point if its distance from the ray is closer. 
    • In the case of a RaycastAll, add the hit point to the list of hit points.
    • In the case of a Checksphere (which returns true if any object occupies a spherical volume, otherwise false), terminate the query and return "true" as the query result if and when a simplex passes the query condition, otherwise false. (A similar test could be done on the cell/solver bounding box itself if it is fully contained within the Checksphere volume.)
A solver specific query would be similar, sans step 1.

I'm guessing that it'd be wasteful to redo all of the work involved in calculating queries like these, given that collision tests between line simplexes and other types are already possible. (A line simplex can be treated like a raycast or a spherecast, with minor modifications.)
Reply


Messages In This Thread
How to query Obi geometry with raycasts? - by Hatchling - 15-05-2021, 06:57 AM