47 #include "Optimizer.h"
48 #include "Primitive.h"
56 void BackFaceCullingOptimizer::optimize(std::vector<PtrPrimitive>& primitives_tab,
VRenderParams&)
61 for(
unsigned int i=0;i<primitives_tab.size();++i)
62 if((P = dynamic_cast<Polygone *>(primitives_tab[i])) != NULL)
64 for(
unsigned int j=0;j<P->nbVertices();++j)
65 if(( (P->vertex(j+2) - P->vertex(j+1))^(P->vertex(j+1) - P->vertex(j))).z() > 0.0 )
67 delete primitives_tab[i] ;
68 primitives_tab[i] = NULL ;
77 for(
unsigned int k=0;k<primitives_tab.size();++k)
78 if(primitives_tab[k] != NULL)
79 primitives_tab[j++] = primitives_tab[k] ;
81 primitives_tab.resize(j) ;
83 cout <<
"Backface culling: " << nb_culled <<
" polygons culled." << endl ;