Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:42

0001 #pragma once
0002 /**
0003 SOPTIX_MeshGroup.h : create SOPTIX_BuildInput_Mesh for each part of SCUDA_MeshGroup, use those to form SOPTIX_Accel gas  
0004 ========================================================================================================================
0005 
0006 Used from SOPTIX_Scene.h  and  CSGOptiX/SBT::createGAS
0007 
0008 From optix7sdk.bash notes::
0009 
0010     CSGOptiX uses one GAS for each CSGSolid ("compound" of numPrim CSGPrim)
0011     and that one GAS always has only one buildInput which references
0012     numPrim SBT records which have "sbt-geometry-acceleration-structure-index" 
0013     of (0,1,2,...,numPrim-1)  
0014 
0015 For sanity need to do something with triangles that 
0016 follows the same pattern as that. 
0017 
0018 Q: Can see the point of having multiple triangle BuildInputs 
0019    with an SBT record for each. But am mystified what use is numSbtRecords > 1 
0020    for a bunch of triangles ? Because no way to address them ?  
0021 
0022 **/
0023 
0024 #include "SCUDA_Mesh.h"
0025 #include "SOPTIX_BuildInput_Mesh.h"
0026 #include "SOPTIX_Options.h"
0027 
0028 struct SOPTIX_MeshGroup
0029 {
0030     static int Initialize(); 
0031 
0032     int irc ; 
0033     const SCUDA_MeshGroup* cmg ; 
0034     std::vector<const SOPTIX_BuildInput*> bis ; 
0035 
0036     std::string desc() const ; 
0037     size_t num_buildInputs() const ; 
0038 
0039     SOPTIX_MeshGroup( const SCUDA_MeshGroup* cmg ); 
0040     void init(); 
0041 
0042     static SOPTIX_MeshGroup* Create( const SMeshGroup* mg );  // more vertical API
0043 }; 
0044 
0045 inline int SOPTIX_MeshGroup::Initialize()
0046 {
0047     if(SOPTIX_Options::Level()>0) std::cout << "-SOPTIX_MeshGroup::Initialize\n" ; 
0048     return 0 ; 
0049 }
0050 
0051 
0052 inline std::string SOPTIX_MeshGroup::desc() const 
0053 {
0054     int num_bi = bis.size() ; 
0055     std::stringstream ss ; 
0056     ss << "[SOPTIX_MeshGroup::desc num_bi "  << num_bi << std::endl ; 
0057     for(int i=0 ; i < num_bi ; i++)
0058     {
0059         const SOPTIX_BuildInput* bi = bis[i] ; 
0060         ss << "bi[" << i << "]" << std::endl ; 
0061         ss << bi->desc() << std::endl ; 
0062     }
0063     ss << "]SOPTIX_MeshGroup::desc num_bi "  << num_bi << std::endl ; 
0064     std::string str = ss.str() ; 
0065     return str ; 
0066 }
0067 
0068 inline size_t SOPTIX_MeshGroup::num_buildInputs() const
0069 {
0070     return bis.size() ; 
0071 }
0072 
0073 /**
0074 SOPTIX_MeshGroup::SOPTIX_MeshGroup
0075 -----------------------------------
0076 
0077 **/
0078 
0079 inline SOPTIX_MeshGroup::SOPTIX_MeshGroup( const SCUDA_MeshGroup* _cmg )
0080     :
0081     irc(Initialize()),
0082     cmg(_cmg)
0083 {
0084     init();
0085 }
0086 
0087 inline void SOPTIX_MeshGroup::init()
0088 {
0089     if(SOPTIX_Options::Level()>0) std::cout << "[SOPTIX_Meshgroup::init\n" ; 
0090     size_t num_part = cmg->num_part() ;  
0091     for(size_t i=0 ; i < num_part ; i++)
0092     {
0093         const SOPTIX_BuildInput* bi = new SOPTIX_BuildInput_Mesh(cmg, i); 
0094         bis.push_back(bi); 
0095     }
0096     if(SOPTIX_Options::Level()>0) std::cout << "]SOPTIX_Meshgroup::init\n" ; 
0097 }
0098 
0099 
0100 /**
0101 SOPTIX_MeshGroup::Create : More vertical API
0102 ----------------------------------------------
0103 
0104 This one-step API from CPU side SMeshGroup (from SScene) to GPU side SOPTIX_MeshGroup
0105 is to facilitate tri/ana integration. 
0106 
0107 **/
0108 
0109 inline SOPTIX_MeshGroup* SOPTIX_MeshGroup::Create( const SMeshGroup* mg )
0110 {
0111     SCUDA_MeshGroup* cmg = SCUDA_MeshGroup::Upload(mg) ; 
0112     SOPTIX_MeshGroup* xmg = new SOPTIX_MeshGroup( cmg ); 
0113     return xmg ;  
0114 }
0115 
0116