I made an optix prime project based on primeSimple, where I:

- I create a bunch of rays: laying on the centroid of triangle:

```
//Identify vertexs of the triangle
int3 tri = mesh.getVertexIndices()[i];
float3 v0 = mesh.getVertexData()[ tri.x ];
float3 v1 = mesh.getVertexData()[ tri.y ];
float3 v2 = mesh.getVertexData()[ tri.z ];
float3 centroid;
centroid.x = (v0.x+v1.x+v2.x)/3.0 ;
centroid.y = (v0.y+v1.y+v2.y)/3.0 ;
centroid.z = (v0.z+v1.z+v2.z)/3.0 ;
Ray r = { centroid, tolerance, rayDir, 1e34f };
```

- launch the hit process.

```
RTPquery query;
CHK_PRIME( rtpQueryCreate( model, RTP_QUERY_TYPE_ANY, &query ) );
CHK_PRIME( rtpQuerySetRays( query, raysDesc ) );
CHK_PRIME( rtpQuerySetHits( query, hitsDesc ) );
CHK_PRIME( rtpQueryExecute( query, 0 /* hints */ ) );
```

if

```
tolerance = 0
```

meaning, the initial ray origin is actually on the triangle, I get about half my ray intersecting with the initial triangle. I want to avoid that

So in order to avoid that, I need to increase the tolerance to a value.

This does the trick for now.

However,

n1) it will not work when mixing triangle of different size whose order of magnitude differs from about the floating precision (I don’t want to use double for performance purpose).

n2) It will also fail if I have triangle that are very close from each other. That makes sense.

n3) It will also be an issue if I use uniform sampling distribution on the triangle and that the angle between 2 adjacent triangles is >90 deg (or close)

So I was thinking that maybe there is a way to exclude a triangle from the intersection process.

I could consider doing that as an iterative post-processing, but I would need to move the origin of the ray anyway so that the ray does not perpetually stays there. This brings me back to this being an issue for n3) anyway

So my question is: Is there a way to exclude a triangle from the process when ** CHK_PRIME( rtpQueryExecute( query, 0 /* hints */ )** is called so “auto intersection” is excluded ?

As a side question, and if that is not possible in optiX prime, I assume that I can implement that in a **void mesh_intersect( int primIdx )** program, for example in **sphereTessellate/triangle_mesh.cu **. Please correct me if I am wrong. (or if there is a more straight forward way )