36    if( aNrReservedTriangles > 0 )
 
   37        m_vertexs.reserve( aNrReservedTriangles * 3 );
 
   40        m_normals.reserve( aNrReservedTriangles * 3 );
 
 
  124                                                 float zBot, 
float zTop, 
bool aInvertFaceDirection,
 
  127    if( aContourPoints.size() >= 4 )
 
  130        std::vector< SFVEC2F > contourNormals;
 
  132        contourNormals.clear();
 
  133        contourNormals.resize( aContourPoints.size() - 1 );
 
  135        if( aInvertFaceDirection )
 
  137            for( 
unsigned int i = 0; i < ( aContourPoints.size() - 1 ); ++i )
 
  139                const SFVEC2F& v0 = aContourPoints[i + 0];
 
  140                const SFVEC2F& 
v1 = aContourPoints[i + 1];
 
  141                const SFVEC2F n = glm::normalize( 
v1 - v0 );
 
  143                contourNormals[i] = 
SFVEC2F( n.y, -n.x );
 
  148            for( 
unsigned int i = 0; i < ( aContourPoints.size() - 1 ); ++i )
 
  150                const SFVEC2F& v0 = aContourPoints[i + 0];
 
  151                const SFVEC2F& 
v1 = aContourPoints[i + 1];
 
  152                const SFVEC2F n = glm::normalize( 
v1 - v0 );
 
  154                contourNormals[i] = 
SFVEC2F( -n.y, n.x );
 
  159        if( aInvertFaceDirection )
 
  160            std::swap( zBot, zTop );
 
  162        const unsigned int nContoursToProcess = ( aContourPoints.size() - 1 );
 
  164        for( 
unsigned int i = 0; i < nContoursToProcess; ++i )
 
  169                lastNormal = contourNormals[i - 1];
 
  171                lastNormal = contourNormals[nContoursToProcess - 1];
 
  173            SFVEC2F n0 = contourNormals[i];
 
  176            if( glm::dot( n0, lastNormal ) > 0.5f )
 
  177                n0 = glm::normalize( n0 + lastNormal );
 
  181            if( i < ( nContoursToProcess - 1) )
 
  182                nextNormal = contourNormals[i + 1];
 
  184                nextNormal = contourNormals[0];
 
  186            SFVEC2F n1 = contourNormals[i];
 
  188            if( glm::dot( n1, nextNormal ) > 0.5f )
 
  189                n1 = glm::normalize( n1 + nextNormal );
 
  194            const SFVEC2F& v0 = aContourPoints[i + 0];
 
  195            const SFVEC2F& 
v1 = aContourPoints[i + 1];
 
 
  217                                                 double aBiuTo3Du, 
bool aInvertFaceDirection,
 
  220    std::vector<SFVEC2F> contourPoints;
 
  222    contourPoints.clear();
 
  223    contourPoints.reserve( outlinePath.
PointCount() + 2 );
 
  229    contourPoints.push_back( lastV );
 
  231    for( 
unsigned int i = 1; i < (
unsigned int)outlinePath.
PointCount(); ++i )
 
  240            contourPoints.push_back( vf );
 
  245    if( lastV != contourPoints[0] )
 
  246        contourPoints.push_back( contourPoints[0] );
 
 
  253                                                 double aBiuTo3Du, 
bool aInvertFaceDirection,
 
  260    unsigned int nrContourPointsToReserve = 0;
 
  266        nrContourPointsToReserve += pathOutline.
PointCount();
 
  268        for( 
int h = 0; h < aPolySet.
HoleCount( i ); ++h )
 
  272            nrContourPointsToReserve += hole.
PointCount();
 
  284        AddToMiddleContours( pathOutline, zBot, zTop, aBiuTo3Du, aInvertFaceDirection, aThroughHoles );
 
  287        for( 
int h = 0; h < aPolySet.
HoleCount( i ); ++h )
 
 
  297                                        GLuint aTextureIndexForSegEnds, 
float aZBot, 
float aZTop )
 
  308    if( aTextureIndexForSegEnds )
 
  310        wxASSERT( glIsTexture( aTextureIndexForSegEnds ) );
 
  312        if( glIsTexture( aTextureIndexForSegEnds ) )
 
  315                                                                     true, aTextureIndexForSegEnds );
 
  318                                                                     false, aTextureIndexForSegEnds );
 
 
  465    glClearStencil( 0x00 );
 
  466    glClear( GL_STENCIL_BUFFER_BIT );
 
  468    glEnable( GL_CULL_FACE );
 
  469    glCullFace( GL_BACK );
 
  471    glDisable( GL_DEPTH_TEST );
 
  472    glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
 
  473    glDepthMask( GL_FALSE );
 
  474    glEnable( GL_STENCIL_TEST );
 
  475    glStencilFunc( GL_ALWAYS, 1, 0 );
 
  476    glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
 
  490    glEnable( GL_DEPTH_TEST );
 
  491    glDepthMask( GL_TRUE );
 
  493    glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
 
  494    glStencilFunc( GL_EQUAL, 0, 1 );
 
  495    glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
 
  498    glDisable( GL_DEPTH_TEST );
 
  499    glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
 
  500    glDepthMask( GL_FALSE );
 
  501    glEnable( GL_STENCIL_TEST );
 
  502    glStencilFunc( GL_ALWAYS, 2, 0 );
 
  503    glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
 
  517    glEnable( GL_DEPTH_TEST );
 
  518    glDepthMask( GL_TRUE );
 
  519    glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
 
  520    glStencilFunc( GL_NOTEQUAL, 2, 0x03 );
 
  521    glStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
 
  527    glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );
 
  529    glCullFace( GL_FRONT );
 
  530    glStencilFunc( GL_GEQUAL, 3, 0x03 );
 
  531    glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
 
  532    glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
 
  540    glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
 
  542    glCullFace( GL_BACK );
 
  543    glDisable( GL_STENCIL_TEST );
 
 
  549    wxCHECK2( aZscale > FLT_EPSILON, aZscale = FLT_EPSILON + 1 );
 
 
  570        const TRIANGLE_LIST* aTriangleContainer, 
bool aIsNormalUp, GLuint aTextureId )
 const 
  572    wxCHECK( aTriangleContainer != 
nullptr, 0 );
 
  574    wxASSERT( ( aTriangleContainer->
GetVertexSize() % 3 ) == 0 );
 
  582        GLuint listIdx = glGenLists( 1 );
 
  584        if( glIsList( listIdx ) )
 
  589            for( 
unsigned int i = 0; i < aTriangleContainer->
GetVertexSize(); i += 3 )
 
  591                uvArray[i + 0] = 
SFVEC2F( 1.0f, 0.0f );
 
  592                uvArray[i + 1] = 
SFVEC2F( 0.0f, 1.0f );
 
  593                uvArray[i + 2] = 
SFVEC2F( 0.0f, 0.0f );
 
  596            glEnableClientState( GL_TEXTURE_COORD_ARRAY );
 
  597            glDisableClientState( GL_COLOR_ARRAY );
 
  598            glDisableClientState( GL_NORMAL_ARRAY );
 
  599            glEnableClientState( GL_VERTEX_ARRAY );
 
  601            glTexCoordPointer( 2, GL_FLOAT, 0, uvArray );
 
  603            glNewList( listIdx, GL_COMPILE );
 
  605            glDisable( GL_COLOR_MATERIAL );
 
  607            glEnable( GL_TEXTURE_2D );
 
  608            glBindTexture( GL_TEXTURE_2D, aTextureId );
 
  610            glAlphaFunc( GL_GREATER, 0.2f );
 
  611            glEnable( GL_ALPHA_TEST );
 
  613            glNormal3f( 0.0f, 0.0f, aIsNormalUp?1.0f:-1.0f );
 
  615            glDrawArrays( GL_TRIANGLES, 0, aTriangleContainer->
GetVertexSize() );
 
  617            glBindTexture( GL_TEXTURE_2D, 0 );
 
  618            glDisable( GL_TEXTURE_2D );
 
  619            glDisable( GL_ALPHA_TEST );
 
  620            glDisable( GL_BLEND );
 
  624            glDisableClientState( GL_VERTEX_ARRAY );
 
  625            glDisableClientState( GL_TEXTURE_COORD_ARRAY );
 
 
  637                                                          bool aIsNormalUp )
 const 
  639    wxCHECK( aTriangleContainer != 
nullptr, 0 );
 
  641    wxASSERT( ( aTriangleContainer->
GetVertexSize() % 3 ) == 0 );
 
  649        const GLuint listIdx = glGenLists( 1 );
 
  651        if( glIsList( listIdx ) )
 
  653            glDisableClientState( GL_TEXTURE_COORD_ARRAY );
 
  654            glDisableClientState( GL_COLOR_ARRAY );
 
  655            glDisableClientState( GL_NORMAL_ARRAY );
 
  656            glEnableClientState( GL_VERTEX_ARRAY );
 
  659            glNewList( listIdx, GL_COMPILE );
 
  663            glNormal3f( 0.0f, 0.0f, aIsNormalUp?1.0f:-1.0f );
 
  665            glDrawArrays( GL_TRIANGLES, 0, aTriangleContainer->
GetVertexSize() );
 
  667            glDisable( GL_BLEND );
 
  670            glDisableClientState( GL_VERTEX_ARRAY );
 
 
  683    wxCHECK( aTriangleContainer != 
nullptr, 0 );
 
  686    wxASSERT( ( aTriangleContainer->
GetVertexSize() % 3 ) == 0 );
 
  699        const GLuint listIdx = glGenLists( 1 );
 
  701        if( glIsList( listIdx ) )
 
  703            glDisableClientState( GL_TEXTURE_COORD_ARRAY );
 
  704            glDisableClientState( GL_COLOR_ARRAY );
 
  705            glEnableClientState( GL_NORMAL_ARRAY );
 
  706            glEnableClientState( GL_VERTEX_ARRAY );
 
  710            glNewList( listIdx, GL_COMPILE );
 
  714            glDrawArrays( GL_TRIANGLES, 0, aTriangleContainer->
GetVertexSize() );
 
  716            glDisable( GL_BLEND );
 
  719            glDisableClientState( GL_VERTEX_ARRAY );
 
  720            glDisableClientState( GL_NORMAL_ARRAY );
 
 
  741    glEnable( GL_BLEND );
 
  742    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
 
 
bool IntersectAny(const RAYSEG2D &aSegRay) const override
Intersect and check if a segment ray hits a object or is inside it.
 
float m_zPositionTransformation
 
GLuint generate_middle_triangles(const TRIANGLE_LIST *aTriangleContainer) const
 
bool m_haveTransformation
 
bool m_draw_it_transparent
 
void beginTransformation() const
 
void DrawMiddle() const
Call the display lists for the middle elements.
 
GLuint generate_top_or_bot_seg_ends(const TRIANGLE_LIST *aTriangleContainer, bool aIsNormalUp, GLuint aTextureId) const
 
GLuint m_layer_bot_segment_ends
 
void DrawTop() const
Call the display lists for the top elements.
 
GLuint m_layer_bot_triangles
 
GLuint m_layer_middle_contours_quads
 
void DrawBot() const
Call the display lists for the bottom elements.
 
void ApplyScalePosition(float aZposition, float aZscale)
 
GLuint m_layer_top_triangles
 
GLuint generate_top_or_bot_triangles(const TRIANGLE_LIST *aTriangleContainer, bool aIsNormalUp) const
 
void setBlendfunction() const
 
void DrawBotAndMiddle() const
Call the display lists for the bottom elements and middle contours.
 
void SetItIsTransparent(bool aSetTransparent)
 
void DrawCulled(bool aDrawMiddle, const OPENGL_RENDER_LIST *aSubtractList=nullptr, const OPENGL_RENDER_LIST *bSubtractList=nullptr, const OPENGL_RENDER_LIST *cSubtractList=nullptr, const OPENGL_RENDER_LIST *dSubtractList=nullptr) const
Draw all layers if they are visible by the camera if camera position is above the layer.
 
void endTransformation() const
 
~OPENGL_RENDER_LIST()
Destroy this class while free the display lists from GPU memory.
 
float m_zScaleTransformation
 
OPENGL_RENDER_LIST(const TRIANGLE_DISPLAY_LIST &aLayerTriangles, GLuint aTextureIndexForSegEnds, float aZBot, float aZTop)
Create the display lists for a layer.
 
GLuint m_layer_top_segment_ends
 
void DrawTopAndMiddle() const
Call the display lists for the top elements and middle contours.
 
void DrawAll(bool aDrawMiddle=true) const
Call to draw all the display lists.
 
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
 
int PointCount() const
Return the number of points (vertices) in this line chain.
 
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
 
Represent a set of closed polygons.
 
int HoleCount(int aOutline) const
Returns the number of holes in a given outline.
 
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
 
int OutlineCount() const
Return the number of outlines in the set.
 
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
 
Store arrays of triangles to be used to create display lists.
 
TRIANGLE_LIST * m_layer_bot_segment_ends
 
void AddToMiddleContours(const SHAPE_LINE_CHAIN &outlinePath, float zBot, float zTop, double aBiuTo3Du, bool aInvertFaceDirection, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
 
TRIANGLE_LIST * m_layer_middle_contours_quads
 
TRIANGLE_LIST * m_layer_top_segment_ends
 
TRIANGLE_LIST * m_layer_bot_triangles
 
TRIANGLE_DISPLAY_LIST(unsigned int aNrReservedTriangles)
Initialize arrays with reserved triangles.
 
TRIANGLE_LIST * m_layer_top_triangles
 
std::mutex m_middle_layer_lock
 
Container to manage a vector of triangles.
 
void AddTriangle(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3)
 
const float * GetVertexPointer() const
Get the array of vertices.
 
SFVEC3F_VECTOR m_normals
normals array
 
unsigned int GetNormalsSize() const
 
void AddQuad(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3, const SFVEC3F &aV4)
 
void AddNormal(const SFVEC3F &aN1, const SFVEC3F &aN2, const SFVEC3F &aN3)
 
unsigned int GetVertexSize() const
 
SFVEC3F_VECTOR m_vertexs
vertex array
 
const float * GetNormalsPointer() const
Get the array of normals.
 
TRIANGLE_LIST(unsigned int aNrReservedTriangles, bool aReserveNormals)
 
void Reserve_More(unsigned int aNrReservedTriangles, bool aReserveNormals)
Reserve more triangles.
 
VECTOR2< int32_t > VECTOR2I