NL3D::CPSFaceHelper Class Reference


Detailed Description

Well, we could have put a method template in CPSFace, but some compilers want the definition of the methods in the header, and some compilers don't want friend with function template, so we use a static method template of a friend class instead, which gives us the same result :)

Definition at line 51 of file ps_face.cpp.

Static Public Member Functions

template<class T, class U> void drawFaces (T posIt, U indexIt, CPSFace &f, uint size, uint32 srcStep)


Member Function Documentation

template<class T, class U>
void NL3D::CPSFaceHelper::drawFaces posIt,
indexIt,
CPSFace f,
uint  size,
uint32  srcStep
[inline, static]
 

Definition at line 55 of file ps_face.cpp.

References NL3D::CPSMaterial::_Mat, NL3D::CPSLocatedBindable::_Owner, NL3D::CPSSizedParticle::_ParticleSize, NL3D::CPSRotated3DPlaneParticle::_PlaneBasis, NL3D::CPSRotated3DPlaneParticle::_PlaneBasisScheme, NL3D::CPSFace::_PrecompBasis, NL3D::CPSSizedParticle::_SizeScheme, NL3D::CPSTexturedParticle::_Tex, NL3D::IDriver::activeVertexBuffer(), CHECK_VERTEX_BUFFER, NL3D::CPSLocatedBindable::getDriver(), NL3D::CPSQuad::getNeededVB(), NL3D::CVertexBuffer::getVertexCoordPointer(), NL3D::CVertexBuffer::getVertexSize(), NL3D::CPSLocated::incrementNbDrawnParticles(), NL3D::CPSMultiTexturedParticle::isMultiTextureEnabled(), NL3D::CPSAttribMaker< CPlaneBasis >::make(), NL3D::CPSAttribMaker< float >::make(), nlassert, PARTICLES_CHECK_MEM, NL3D::IDriver::renderQuads(), NL3D::CPSLocatedBindable::setupDriverModelMatrix(), NL3D::CPSMultiTexturedParticle::setupMaterial(), size, stride, uint, uint32, uint8, NL3D::CPSQuad::updateMatBeforeRendering(), NL3D::CPSQuad::updateVbColNUVForRender(), NLMISC::CVector::x, NL3D::CPlaneBasis::X, NL3D::CPlaneBasis::Y, NLMISC::CVector::y, and NLMISC::CVector::z.

00056         {
00057                 PARTICLES_CHECK_MEM;
00058                 nlassert(f._Owner);             
00059                 IDriver *driver = f.getDriver();
00060 
00061                 f.updateMatBeforeRendering(driver);
00062 
00063                 CVertexBuffer &vb = f.getNeededVB();
00064                 uint8 *currVertex;      
00065 
00066                 // number of left faces to draw, number of faces to process at once
00067                 uint32 leftFaces = size, toProcess;
00068                 f._Owner->incrementNbDrawnParticles(size); // for benchmark purpose             
00069                 f.setupDriverModelMatrix();
00070                 driver->activeVertexBuffer(vb);
00071                 if (f.isMultiTextureEnabled())
00072                 {
00073                         f.setupMaterial(f._Tex, driver, f._Mat);
00074                 }
00075                 float sizeBuf[CPSQuad::quadBufSize];
00076                 float *ptSize;          
00077                 T endPosIt;
00078 
00079                 // if constant size is used, the pointer points always the same float 
00080                 uint32 ptSizeIncrement = f._SizeScheme ? 1 : 0;
00081 
00082                 if (f._PrecompBasis.size()) // do we use precomputed basis ?
00083                 {                                       
00084                         do
00085                         {               
00086                                 toProcess = leftFaces > CPSQuad::quadBufSize ? CPSQuad::quadBufSize : leftFaces;
00087                                 currVertex = (uint8 *) vb.getVertexCoordPointer() ; 
00088                                 if (f._SizeScheme)
00089                                 {                               
00090                                         ptSize = (float *) (f._SizeScheme->make(f._Owner, size - leftFaces, sizeBuf, sizeof(float), toProcess, true, srcStep));                                                         
00091                                 }
00092                                 else
00093                                 {       
00094                                         ptSize = &f._ParticleSize;                      
00095                                 }                                       
00096                                 f.updateVbColNUVForRender(vb, size - leftFaces, toProcess, srcStep);                    
00097                                 const uint32 stride = vb.getVertexSize();
00098                                 endPosIt = posIt + toProcess;                                                   
00099                                 do              
00100                                 {                       
00101                                         const CPlaneBasis &currBasis = f._PrecompBasis[*indexIt].Basis;
00102                                         CHECK_VERTEX_BUFFER(vb, currVertex);
00103                                         ((CVector *) currVertex)->x = (*posIt).x  + *ptSize * currBasis.X.x;                    
00104                                         ((CVector *) currVertex)->y = (*posIt).y  + *ptSize * currBasis.X.y;                    
00105                                         ((CVector *) currVertex)->z = (*posIt).z  + *ptSize * currBasis.X.z;                    
00106                                         currVertex += stride;
00107 
00108                                         CHECK_VERTEX_BUFFER(vb, currVertex);
00109                                         ((CVector *) currVertex)->x = (*posIt).x  + *ptSize * currBasis.Y.x;                    
00110                                         ((CVector *) currVertex)->y = (*posIt).y  + *ptSize * currBasis.Y.y;                    
00111                                         ((CVector *) currVertex)->z = (*posIt).z  + *ptSize * currBasis.Y.z;                    
00112                                         currVertex += stride;
00113 
00114                                         CHECK_VERTEX_BUFFER(vb, currVertex);
00115                                         ((CVector *) currVertex)->x = (*posIt).x  - *ptSize * currBasis.X.x;                    
00116                                         ((CVector *) currVertex)->y = (*posIt).y  - *ptSize * currBasis.X.y;                    
00117                                         ((CVector *) currVertex)->z = (*posIt).z  - *ptSize * currBasis.X.z;                    
00118                                         currVertex += stride;
00119 
00120                                         CHECK_VERTEX_BUFFER(vb, currVertex);
00121                                         ((CVector *) currVertex)->x = (*posIt).x  - *ptSize * currBasis.Y.x;                    
00122                                         ((CVector *) currVertex)->y = (*posIt).y  - *ptSize * currBasis.Y.y;                    
00123                                         ((CVector *) currVertex)->z = (*posIt).z  - *ptSize * currBasis.Y.z;                    
00124                                         currVertex += stride;                                           
00125                                         ptSize += ptSizeIncrement;
00126                                         ++indexIt;
00127                                         ++posIt;
00128                                 }
00129                                 while (posIt != endPosIt);
00130                                 driver->renderQuads(f._Mat, 0, toProcess);                              
00131                                 leftFaces -= toProcess;
00132                         }
00133                         while (leftFaces);
00134                 }
00135                 else
00136                 {
00137                         // must compute each particle basis at each time
00138                         static CPlaneBasis planeBasis[CPSQuad::quadBufSize]; // buffer to compute each particle basis
00139                         CPlaneBasis *currBasis;
00140                         uint32    ptPlaneBasisIncrement = f._PlaneBasisScheme ? 1 : 0;
00141                         const uint32 vSize = vb.getVertexSize();
00142                         do
00143                         {                       
00144                                 toProcess = leftFaces > CPSQuad::quadBufSize ? CPSQuad::quadBufSize : leftFaces;
00145                                 currVertex = (uint8 *) vb.getVertexCoordPointer() ; 
00146                                 if (f._SizeScheme)
00147                                 {                               
00148                                         ptSize  = (float *) (f._SizeScheme->make(f._Owner, size - leftFaces, sizeBuf, sizeof(float), toProcess, true, srcStep));                                                                
00149                                 }
00150                                 else
00151                                 {       
00152                                         ptSize = &f._ParticleSize;                      
00153                                 }
00154 
00155                                 if (f._PlaneBasisScheme)
00156                                 {
00157                                         currBasis = (CPlaneBasis *) (f._PlaneBasisScheme->make(f._Owner, size - leftFaces, planeBasis, sizeof(CPlaneBasis), toProcess, true, srcStep));                         
00158                                 }
00159                                 else
00160                                 {
00161                                         currBasis = &f._PlaneBasis;
00162                                 }                                               
00163                                 f.updateVbColNUVForRender(vb, size - leftFaces, toProcess, srcStep);                                            
00164                                 endPosIt = posIt + toProcess;                                   
00165                                 do              
00166                                 {                       
00167                                         // we use this instead of the + operator, because we avoid 4 constructor calls this way
00168                                         CHECK_VERTEX_BUFFER(vb, currVertex);
00169                                         ((CVector *) currVertex)->x = (*posIt).x  + *ptSize * currBasis->X.x;                   
00170                                         ((CVector *) currVertex)->y = (*posIt).y  + *ptSize * currBasis->X.y;                   
00171                                         ((CVector *) currVertex)->z = (*posIt).z  + *ptSize * currBasis->X.z;                   
00172                                         currVertex += vSize;
00173 
00174                                         CHECK_VERTEX_BUFFER(vb, currVertex);
00175                                         ((CVector *) currVertex)->x = (*posIt).x  + *ptSize * currBasis->Y.x;                   
00176                                         ((CVector *) currVertex)->y = (*posIt).y  + *ptSize * currBasis->Y.y;                   
00177                                         ((CVector *) currVertex)->z = (*posIt).z  + *ptSize * currBasis->Y.z;                   
00178                                         currVertex += vSize;
00179 
00180                                         CHECK_VERTEX_BUFFER(vb, currVertex);
00181                                         ((CVector *) currVertex)->x = (*posIt).x  - *ptSize * currBasis->X.x;                   
00182                                         ((CVector *) currVertex)->y = (*posIt).y  - *ptSize * currBasis->X.y;                   
00183                                         ((CVector *) currVertex)->z = (*posIt).z  - *ptSize * currBasis->X.z;                   
00184                                         currVertex += vSize;
00185 
00186                                         CHECK_VERTEX_BUFFER(vb, currVertex);
00187                                         ((CVector *) currVertex)->x = (*posIt).x  - *ptSize * currBasis->Y.x;                   
00188                                         ((CVector *) currVertex)->y = (*posIt).y  - *ptSize * currBasis->Y.y;                   
00189                                         ((CVector *) currVertex)->z = (*posIt).z  - *ptSize * currBasis->Y.z;                   
00190                                         currVertex += vSize;
00191                                         ptSize += ptSizeIncrement;                                              
00192                                         ++posIt;
00193                                         currBasis += ptPlaneBasisIncrement;
00194                                 }
00195                                 while (posIt != endPosIt);
00196                                 driver->renderQuads(f._Mat, 0, toProcess);                              
00197                                 leftFaces -= toProcess;
00198                         }
00199                         while (leftFaces);
00200                 }
00201                 PARTICLES_CHECK_MEM;    
00202         }


The documentation for this class was generated from the following file:
Generated on Tue Mar 16 07:11:18 2004 for NeL by doxygen 1.3.6