below is the code of triangle_mesh maybe something is wrong there?

#include <optix_cuda.h>

#include <optixu/optixu_math_namespace.h>

#include <optixu/optixu_matrix.h>

#include <optixu/optixu_aabb.h>

#include “helpers.h”

// Ray data

rtDeclareVariable( optix::Ray, ray, rtCurrentRay, );

// Attributes to communicate with shader programs

rtDeclareVariable( float2, texcoord, attribute texcoord, );

rtDeclareVariable( float3, geometric_normal, attribute geometric_normal, );

rtDeclareVariable( uint, geometric_uniqueID, attribute geometric_uniqueID, );

rtDeclareVariable( uint, geometric_inclusionID, attribute geometric_inclusionID, );

rtDeclareVariable( unsigned char, geometric_inclusionDescription, attribute geometric_inclusionDescription, );

rtDeclareVariable( float, geometric_cloudAbsorptionFactor, attribute geometric_cloudAbsorptionFactor, );

rtDeclareVariable( int, geometric_facetID, attribute geometric_facetID, );

// Externally set API vars

rtDeclareVariable( uint, m_ID, , ) = 0; //u // the unique ID of the object (unsigned int)

rtDeclareVariable( uint, m_uInclusionID, , ) = 0; //u // the inclusion ID of the object (unsigned int)

rtDeclareVariable( unsigned char, m_cIncDescription, , ) = 0;//u // uchar simulating Inclusion::DescriptionEnum

rtDeclareVariable( float, m_fCloudAbsorptionFactor, , ) = 1.f; // 1 / [ % of absorption relative to regular diamond ] ^ 4 , relevant only if geometric_inclusionDescription == eCloud

// Geometry description

rtBuffer vertex_buffer; // vertex list

rtBuffer texcoord_buffer; // texture-map coords for each vertex. ** May alternatively be empty if texture doesnt exist **

rtBuffer vindex_buffer; // facets list (each int3 holds indexes of vertices composing a single triangle facet)

rtBuffer material_buffer; // material index for each facet. ** May alternatively be empty if all facets are same material **

rtBuffer facet_id_buffer; // id for each facet. ** May alternatively be empty if no ids are provided **

// This is to be plugged into an RTgeometry object to represent

// a triangle mesh with a vertex buffer of triangle soup (triangle list)

// with an interleaved position, normal, texturecoordinate layout.

RT_PROGRAM void mesh_intersect( int primIdx )

{

const int3& v_idx = vindex_buffer[primIdx];

```
const float3& p0 = vertex_buffer[v_idx.x];
const float3& p1 = vertex_buffer[v_idx.y];
const float3& p2 = vertex_buffer[v_idx.z];
// Intersect ray with triangle
volatile float fZero = 0.f;
float3 n = make_float3( fZero, fZero, fZero );
float t = RT_DEFAULT_MAX, // ray parametric equation: origin + t * direction
fBeta = fZero, fGamma = fZero; // barycentric coordinates of intersection point
if ( TriangleIntersection( ray, p0, p1, p2, n, t, fBeta, fGamma ) )
{
if ( rtPotentialIntersection( t ) )
{
// Geometric Attributes
geometric_normal = intrinsicNormalize( n );
geometric_uniqueID = m_ID;
geometric_inclusionID = m_uInclusionID;
geometric_inclusionDescription = m_cIncDescription;
geometric_cloudAbsorptionFactor = m_fCloudAbsorptionFactor;
if ( facet_id_buffer.size() == 0 ) //u
geometric_facetID = 0;
else
geometric_facetID = facet_id_buffer[primIdx];
// Texture
if ( texcoord_buffer.size() == 0 ) //u
{
texcoord = make_float2( fZero, fZero );
}
else
{
const float2& t0 = texcoord_buffer[v_idx.x];
const float2& t1 = texcoord_buffer[v_idx.y];
const float2& t2 = texcoord_buffer[v_idx.z];
texcoord = t1*fBeta + ( t2*fGamma ) + t0*( 1.f - fBeta - fGamma );
}
if ( material_buffer.size() == 0 ) //u
rtReportIntersection( 0 ); //u
else
rtReportIntersection( material_buffer[primIdx] );
}
}
```

}

RT_PROGRAM void mesh_bounds (int primIdx, float result[6])

{

const int3& v_idx = vindex_buffer[primIdx];

```
const float3& v0 = vertex_buffer[ v_idx.x ];
const float3& v1 = vertex_buffer[ v_idx.y ];
const float3& v2 = vertex_buffer[ v_idx.z ];
const float3 n = cross( v1 - v0, v2 - v0 );
const float fPseudoArea = dot( n, n );
optix::Aabb* aabb = ( optix::Aabb* )result;
if ( fPseudoArea > 0.0f && !isinf( fPseudoArea ) )
{
aabb->m_min = fminf( v0, v1, v2 );
aabb->m_max = fmaxf( v0, v1, v2 );
}
else
aabb->invalidate();
```

}