Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #pragma once
0002 
0003 /**
0004 SCUDA_MeshGroup.h : collect vectors of NP from each SMeshGroup sub, upload together with SCU_BufferView 
0005 =========================================================================================================
0006 
0007 Try following the pattern of SGLFW_Mesh.h 
0008 
0009 **/
0010 
0011 #include "SMeshGroup.h"
0012 #include "SCU_BufferView.h"
0013 
0014 struct SCUDA_MeshGroup
0015 {
0016     static SCUDA_MeshGroup* Upload( const SMeshGroup* mg ); 
0017 
0018     static constexpr const int INST_ELEM = 4*4 ; 
0019 
0020     std::vector<const NP*> _vtx ; 
0021     std::vector<const NP*> _nrm ; 
0022     std::vector<const NP*> _idx ; 
0023 
0024     SCU_BufferView<float> vtx = {} ;
0025     SCU_BufferView<float> nrm = {} ;
0026     SCU_BufferView<int>   idx = {} ; 
0027 
0028     size_t num_part() const ; 
0029     void free(); 
0030     std::string desc() const ; 
0031 
0032     SCUDA_MeshGroup(const SMeshGroup* mg ) ; 
0033 }; 
0034 
0035 inline SCUDA_MeshGroup* SCUDA_MeshGroup::Upload( const SMeshGroup* mg ) // static
0036 {
0037     return new SCUDA_MeshGroup(mg); 
0038 }
0039 
0040 inline size_t SCUDA_MeshGroup::num_part() const 
0041 {
0042     return vtx.num_part(); 
0043 } 
0044 
0045 inline void SCUDA_MeshGroup::free()
0046 {
0047     vtx.free(); 
0048     nrm.free(); 
0049     idx.free();
0050 }
0051 
0052 inline std::string SCUDA_MeshGroup::desc() const
0053 {
0054     std::stringstream ss ; 
0055     ss << "[SCUDA_MeshGroup::desc\n" ;
0056     ss << vtx.desc() ;  
0057     ss << nrm.desc() ;  
0058     ss << idx.desc() ;  
0059     ss << "]SCUDA_MeshGroup::desc\n" ;
0060     std::string str = ss.str(); 
0061     return str ; 
0062 }
0063 
0064 
0065 inline SCUDA_MeshGroup::SCUDA_MeshGroup(const SMeshGroup* mg )
0066 {
0067     int num_sub = mg->subs.size() ; 
0068     for(int i=0 ; i < num_sub ; i++)
0069     {
0070         const SMesh* m = mg->subs[i] ;  
0071         _vtx.push_back(m->vtx);          
0072         _nrm.push_back(m->nrm);          
0073         _idx.push_back(m->tri); 
0074     }
0075 
0076     vtx.upload(_vtx); 
0077     nrm.upload(_nrm); 
0078     idx.upload(_idx); 
0079     //std::cout << "SCUDA_MeshGroup::SCUDA_MeshGroup\n" << desc() ; 
0080 }
0081 
0082