RealityKit, collision mesh - exact mesh option - no convex/box/approximation

Hello

I'm in need of a precise raycast intersection function.

Currently the native ones that realitykit/etc provide are :

generateConvex
generateBox
generateSphere
generateCapsule

But I would like to get... "exact" as in, just take the mesh as is and use it for raycast intersection & give me exact point on mesh. Not approximation.

I know its something that a "game" would NOT want. But for my application I need exact intersection point.

Ideally I would like to either do

view.raycast() or hitTest() but give it a list of meshes I want to raycast against so it does specific test for specific meshes only.

If this can not be provided by native library, then I need to

  1. Get vertex/indices data of a mesh to rebuild my own mesh structure - pain
  2. Get exact camera matrix/etc to create my own ray/cast/intersection test. - more pain

I have to reimplement my own raycast test from 0 essentially.

Would it be possible to add to SDK a shape of exact mesh? I don't want it to generate anything, just take the mesh ash is. I tried doing convexMesh on my model, after 5 min generation time I gave up and stopped the process. So yea... high poly count, say USD with 30 000 objects and up to 40 mil polygons... lets think "BIG" here, like automotive cad data set that was lightly optimised.

Regards Dariusz

Hi Dariusz, can you file a feature request for this on Feedback Assistant? Also, can you please talk a bit more about your specific use case? RealityKit is optimized for AR and mobile rendering, and we don't really stress test the engine to render a 40 million polygon model. You'll probably need to write your own custom intersection function if you need exact results. Fortunately, Metal provides some ray tracing APIs that should make this task relatively straightforward. You could also see if there's a way to break your model up into smaller convex shapes, and then attach colliders to those shapes. You should also look for a way to simplify your mesh geometry, and use a lower polygon model for intersection testing.

RealityKit, collision mesh - exact mesh option - no convex/box/approximation
 
 
Q