KiCad PCB EDA Suite
Loading...
Searching...
No Matches
layer_triangles.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2015-2016 Mario Luzeiro <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#include "layer_triangles.h"
22#include "../raytracing/ray.h"
23#include <wx/debug.h> // For the wxASSERT
24#include <mutex>
25
26
27TRIANGLE_LIST::TRIANGLE_LIST( unsigned int aNrReservedTriangles, bool aReserveNormals )
28{
29 m_vertexs.clear();
30 m_normals.clear();
31
32 if( aNrReservedTriangles > 0 )
33 m_vertexs.reserve( aNrReservedTriangles * 3 );
34
35 if( aReserveNormals )
36 m_normals.reserve( aNrReservedTriangles * 3 );
37}
38
39
40void TRIANGLE_LIST::Reserve_More( unsigned int aNrReservedTriangles, bool aReserveNormals )
41{
42 m_vertexs.reserve( m_vertexs.size() + aNrReservedTriangles * 3 );
43
44 if( aReserveNormals )
45 m_normals.reserve( m_normals.size() + aNrReservedTriangles * 3 );
46}
47
48
49void TRIANGLE_LIST::AddQuad( const SFVEC3F& aV1, const SFVEC3F& aV2, const SFVEC3F& aV3,
50 const SFVEC3F& aV4 )
51{
52 m_vertexs.push_back( aV1 );
53 m_vertexs.push_back( aV2 );
54 m_vertexs.push_back( aV3 );
55
56 m_vertexs.push_back( aV3 );
57 m_vertexs.push_back( aV4 );
58 m_vertexs.push_back( aV1 );
59}
60
61
62void TRIANGLE_LIST::AddTriangle( const SFVEC3F& aV1, const SFVEC3F& aV2, const SFVEC3F& aV3 )
63{
64 m_vertexs.push_back( aV1 );
65 m_vertexs.push_back( aV2 );
66 m_vertexs.push_back( aV3 );
67}
68
69
70void TRIANGLE_LIST::AddNormal( const SFVEC3F& aN1, const SFVEC3F& aN2, const SFVEC3F& aN3 )
71{
72 m_normals.push_back( aN1 );
73 m_normals.push_back( aN2 );
74 m_normals.push_back( aN3 );
75}
76
77void TRIANGLE_LIST::AddNormal( const SFVEC3F& aN1, const SFVEC3F& aN2, const SFVEC3F& aN3,
78 const SFVEC3F& aN4 )
79{
80 m_normals.push_back( aN1 );
81 m_normals.push_back( aN2 );
82 m_normals.push_back( aN3 );
83
84 m_normals.push_back( aN3 );
85 m_normals.push_back( aN4 );
86 m_normals.push_back( aN1 );
87}
88
89
90TRIANGLE_DISPLAY_LIST::TRIANGLE_DISPLAY_LIST( unsigned int aNrReservedTriangles )
91{
92 m_layer_top_segment_ends = new TRIANGLE_LIST( aNrReservedTriangles, false );
93 m_layer_top_triangles = new TRIANGLE_LIST( aNrReservedTriangles, false );
94 m_layer_middle_contours_quads = new TRIANGLE_LIST( aNrReservedTriangles, true );
95 m_layer_bot_triangles = new TRIANGLE_LIST( aNrReservedTriangles, false );
96 m_layer_bot_segment_ends = new TRIANGLE_LIST( aNrReservedTriangles, false );
97}
98
99
117
118
119void TRIANGLE_DISPLAY_LIST::AddToMiddleContours( const std::vector<SFVEC2F>& aContourPoints,
120 float zBot, float zTop, bool aInvertFaceDirection,
121 const BVH_CONTAINER_2D* aThroughHoles )
122{
123 if( aContourPoints.size() >= 4 )
124 {
125 // Calculate normals of each segment of the contour
126 std::vector< SFVEC2F > contourNormals;
127
128 contourNormals.clear();
129 contourNormals.resize( aContourPoints.size() - 1 );
130
131 if( aInvertFaceDirection )
132 {
133 for( unsigned int i = 0; i < ( aContourPoints.size() - 1 ); ++i )
134 {
135 const SFVEC2F& v0 = aContourPoints[i + 0];
136 const SFVEC2F& v1 = aContourPoints[i + 1];
137 const SFVEC2F n = glm::normalize( v1 - v0 );
138
139 contourNormals[i] = SFVEC2F( n.y, -n.x );
140 }
141 }
142 else
143 {
144 for( unsigned int i = 0; i < ( aContourPoints.size() - 1 ); ++i )
145 {
146 const SFVEC2F& v0 = aContourPoints[i + 0];
147 const SFVEC2F& v1 = aContourPoints[i + 1];
148 const SFVEC2F n = glm::normalize( v1 - v0 );
149
150 contourNormals[i] = SFVEC2F( -n.y, n.x );
151 }
152 }
153
154
155 if( aInvertFaceDirection )
156 std::swap( zBot, zTop );
157
158 const unsigned int nContoursToProcess = ( aContourPoints.size() - 1 );
159
160 for( unsigned int i = 0; i < nContoursToProcess; ++i )
161 {
162 SFVEC2F lastNormal;
163
164 if( i > 0 )
165 lastNormal = contourNormals[i - 1];
166 else
167 lastNormal = contourNormals[nContoursToProcess - 1];
168
169 SFVEC2F n0 = contourNormals[i];
170
171 // Only interpolate the normal if the angle is closer
172 if( glm::dot( n0, lastNormal ) > 0.5f )
173 n0 = glm::normalize( n0 + lastNormal );
174
175 SFVEC2F nextNormal;
176
177 if( i < ( nContoursToProcess - 1) )
178 nextNormal = contourNormals[i + 1];
179 else
180 nextNormal = contourNormals[0];
181
182 SFVEC2F n1 = contourNormals[i];
183
184 if( glm::dot( n1, nextNormal ) > 0.5f )
185 n1 = glm::normalize( n1 + nextNormal );
186
187 const SFVEC3F n3d0 = SFVEC3F( n0.x, n0.y, 0.0f );
188 const SFVEC3F n3d1 = SFVEC3F( n1.x, n1.y, 0.0f );
189
190 const SFVEC2F& v0 = aContourPoints[i + 0];
191 const SFVEC2F& v1 = aContourPoints[i + 1];
192
193 if( aThroughHoles && aThroughHoles->IntersectAny( RAYSEG2D( v0, v1 ) ) )
194 {
195 continue;
196 }
197 else
198 {
199 std::lock_guard<std::mutex> lock( m_middle_layer_lock );
200 m_layer_middle_contours_quads->AddQuad( SFVEC3F( v0.x, v0.y, zTop ),
201 SFVEC3F( v1.x, v1.y, zTop ),
202 SFVEC3F( v1.x, v1.y, zBot ),
203 SFVEC3F( v0.x, v0.y, zBot ) );
204
205 m_layer_middle_contours_quads->AddNormal( n3d0, n3d1, n3d1, n3d0 );
206 }
207 }
208 }
209}
210
211
212void TRIANGLE_DISPLAY_LIST::AddToMiddleContours( const SHAPE_LINE_CHAIN& outlinePath, float zBot, float zTop,
213 double aBiuTo3Du, bool aInvertFaceDirection,
214 const BVH_CONTAINER_2D* aThroughHoles )
215{
216 std::vector<SFVEC2F> contourPoints;
217
218 contourPoints.clear();
219 contourPoints.reserve( outlinePath.PointCount() + 2 );
220
221 const VECTOR2I& firstV = outlinePath.CPoint( 0 );
222
223 SFVEC2F lastV = SFVEC2F( firstV.x * aBiuTo3Du, -firstV.y * aBiuTo3Du );
224
225 contourPoints.push_back( lastV );
226
227 for( unsigned int i = 1; i < (unsigned int)outlinePath.PointCount(); ++i )
228 {
229 const VECTOR2I& v = outlinePath.CPoint( i );
230
231 const SFVEC2F vf = SFVEC2F( v.x * aBiuTo3Du, -v.y * aBiuTo3Du );
232
233 if( vf != lastV ) // Do not add repeated points
234 {
235 lastV = vf;
236 contourPoints.push_back( vf );
237 }
238 }
239
240 // Add first position of the list to close the path.
241 if( lastV != contourPoints[0] )
242 contourPoints.push_back( contourPoints[0] );
243
244 AddToMiddleContours( contourPoints, zBot, zTop, aInvertFaceDirection, aThroughHoles );
245}
246
247
248void TRIANGLE_DISPLAY_LIST::AddToMiddleContours( const SHAPE_POLY_SET& aPolySet, float zBot, float zTop,
249 double aBiuTo3Du, bool aInvertFaceDirection,
250 const BVH_CONTAINER_2D* aThroughHoles )
251{
252 if( aPolySet.OutlineCount() == 0 )
253 return;
254
255 // Calculate an estimation of points to reserve
256 unsigned int nrContourPointsToReserve = 0;
257
258 for( int i = 0; i < aPolySet.OutlineCount(); ++i )
259 {
260 const SHAPE_LINE_CHAIN& pathOutline = aPolySet.COutline( i );
261
262 nrContourPointsToReserve += pathOutline.PointCount();
263
264 for( int h = 0; h < aPolySet.HoleCount( i ); ++h )
265 {
266 const SHAPE_LINE_CHAIN& hole = aPolySet.CHole( i, h );
267
268 nrContourPointsToReserve += hole.PointCount();
269 }
270 }
271
272 // Request to reserve more space
273 m_layer_middle_contours_quads->Reserve_More( nrContourPointsToReserve * 2, true );
274
275 for( int i = 0; i < aPolySet.OutlineCount(); i++ )
276 {
277 // Add outline
278 const SHAPE_LINE_CHAIN& pathOutline = aPolySet.COutline( i );
279
280 AddToMiddleContours( pathOutline, zBot, zTop, aBiuTo3Du, aInvertFaceDirection, aThroughHoles );
281
282 // Add holes for this outline
283 for( int h = 0; h < aPolySet.HoleCount( i ); ++h )
284 {
285 const SHAPE_LINE_CHAIN& hole = aPolySet.CHole( i, h );
286 AddToMiddleContours( hole, zBot, zTop, aBiuTo3Du, aInvertFaceDirection, aThroughHoles );
287 }
288 }
289}
290
291
293 GLuint aTextureIndexForSegEnds, float aZBot, float aZTop )
294{
295 m_zBot = aZBot;
296 m_zTop = aZTop;
297
303
304 if( aTextureIndexForSegEnds )
305 {
306 wxASSERT( glIsTexture( aTextureIndexForSegEnds ) );
307
308 if( glIsTexture( aTextureIndexForSegEnds ) )
309 {
311 true, aTextureIndexForSegEnds );
312
314 false, aTextureIndexForSegEnds );
315 }
316 }
317
319
321
322
323 if( aLayerTriangles.m_layer_middle_contours_quads->GetVertexSize() > 0 )
325
326 m_draw_it_transparent = false;
327 m_haveTransformation = false;
330}
331
332
334{
335 if( glIsList( m_layer_top_segment_ends ) )
336 glDeleteLists( m_layer_top_segment_ends, 1 );
337
338 if( glIsList( m_layer_top_triangles ) )
339 glDeleteLists( m_layer_top_triangles, 1 );
340
341 if( glIsList( m_layer_middle_contours_quads ) )
342 glDeleteLists( m_layer_middle_contours_quads, 1 );
343
344 if( glIsList( m_layer_bot_triangles ) )
345 glDeleteLists( m_layer_bot_triangles, 1 );
346
347 if( glIsList( m_layer_bot_segment_ends ) )
348 glDeleteLists( m_layer_bot_segment_ends, 1 );
349
355}
356
357
359{
361
362 if( glIsList( m_layer_middle_contours_quads ) )
363 glCallList( m_layer_middle_contours_quads );
364
365 if( glIsList( m_layer_top_triangles ) )
366 glCallList( m_layer_top_triangles );
367
368 if( glIsList( m_layer_top_segment_ends ) )
369 glCallList( m_layer_top_segment_ends );
370
372}
373
374
376{
378
379 if( glIsList( m_layer_middle_contours_quads ) )
380 glCallList( m_layer_middle_contours_quads );
381
382 if( glIsList( m_layer_bot_triangles ) )
383 glCallList( m_layer_bot_triangles );
384
385 if( glIsList( m_layer_bot_segment_ends ) )
386 glCallList( m_layer_bot_segment_ends );
387
389}
390
391
393{
395
396 if( glIsList( m_layer_top_triangles ) )
397 glCallList( m_layer_top_triangles );
398
399 if( glIsList( m_layer_top_segment_ends ) )
400 glCallList( m_layer_top_segment_ends );
401
403}
404
405
407{
409
410 if( glIsList( m_layer_bot_triangles ) )
411 glCallList( m_layer_bot_triangles );
412
413 if( glIsList( m_layer_bot_segment_ends ) )
414 glCallList( m_layer_bot_segment_ends );
415
417}
418
419
421{
423
424 if( glIsList( m_layer_middle_contours_quads ) )
425 glCallList( m_layer_middle_contours_quads );
426
428}
429
430
431void OPENGL_RENDER_LIST::DrawAll( bool aDrawMiddle ) const
432{
434
435 if( aDrawMiddle )
436 if( glIsList( m_layer_middle_contours_quads ) )
437 glCallList( m_layer_middle_contours_quads );
438
439 if( glIsList( m_layer_top_triangles ) )
440 glCallList( m_layer_top_triangles );
441
442 if( glIsList( m_layer_bot_triangles ) )
443 glCallList( m_layer_bot_triangles );
444
445 if( glIsList( m_layer_top_segment_ends ) )
446 glCallList( m_layer_top_segment_ends );
447
448 if( glIsList( m_layer_bot_segment_ends ) )
449 glCallList( m_layer_bot_segment_ends );
450
452}
453
454
455void OPENGL_RENDER_LIST::DrawCulled( bool aDrawMiddle,
456 const OPENGL_RENDER_LIST* aSubtractList,
457 const OPENGL_RENDER_LIST* bSubtractList,
458 const OPENGL_RENDER_LIST* cSubtractList,
459 const OPENGL_RENDER_LIST* dSubtractList ) const
460{
461 glClearStencil( 0x00 );
462 glClear( GL_STENCIL_BUFFER_BIT );
463
464 glEnable( GL_CULL_FACE );
465 glCullFace( GL_BACK );
466
467 glDisable( GL_DEPTH_TEST );
468 glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
469 glDepthMask( GL_FALSE );
470 glEnable( GL_STENCIL_TEST );
471 glStencilFunc( GL_ALWAYS, 1, 0 );
472 glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
473
474 if( aSubtractList )
475 aSubtractList->DrawBot();
476
477 if( bSubtractList )
478 bSubtractList->DrawBot();
479
480 if( cSubtractList )
481 cSubtractList->DrawBot();
482
483 if( dSubtractList )
484 dSubtractList->DrawBot();
485
486 glEnable( GL_DEPTH_TEST );
487 glDepthMask( GL_TRUE );
488
489 glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
490 glStencilFunc( GL_EQUAL, 0, 1 );
491 glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
492 DrawBot();
493
494 glDisable( GL_DEPTH_TEST );
495 glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
496 glDepthMask( GL_FALSE );
497 glEnable( GL_STENCIL_TEST );
498 glStencilFunc( GL_ALWAYS, 2, 0 );
499 glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
500
501 if( aSubtractList )
502 aSubtractList->DrawTop();
503
504 if( bSubtractList )
505 bSubtractList->DrawTop();
506
507 if( cSubtractList )
508 cSubtractList->DrawTop();
509
510 if( dSubtractList )
511 dSubtractList->DrawTop();
512
513 glEnable( GL_DEPTH_TEST );
514 glDepthMask( GL_TRUE );
515 glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
516 glStencilFunc( GL_NOTEQUAL, 2, 0x03 );
517 glStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
518 DrawTop();
519
520 if( aDrawMiddle )
521 DrawMiddle();
522
523 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );
524
525 glCullFace( GL_FRONT );
526 glStencilFunc( GL_GEQUAL, 3, 0x03 );
527 glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
528 glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
529
530 if( aDrawMiddle )
531 {
532 if( aSubtractList )
533 aSubtractList->DrawMiddle();
534 }
535
536 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
537
538 glCullFace( GL_BACK );
539 glDisable( GL_STENCIL_TEST );
540}
541
542
543void OPENGL_RENDER_LIST::ApplyScalePosition( float aZposition, float aZscale )
544{
545 wxCHECK2( aZscale > FLT_EPSILON, aZscale = FLT_EPSILON + 1 );
546
547 m_zPositionTransformation = aZposition;
548 m_zScaleTransformation = aZscale;
550}
551
552
554{
555 ApplyScalePosition( aOtherList->GetZBot(), aOtherList->GetZTop() - aOtherList->GetZBot() );
556}
557
558
559void OPENGL_RENDER_LIST::SetItIsTransparent( bool aSetTransparent )
560{
561 m_draw_it_transparent = aSetTransparent;
562}
563
564
566 const TRIANGLE_LIST* aTriangleContainer, bool aIsNormalUp, GLuint aTextureId ) const
567{
568 wxCHECK( aTriangleContainer != nullptr, 0 );
569
570 wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 );
571
572 // Top and Bot don't have normals array stored in container
573 wxASSERT( aTriangleContainer->GetNormalsSize() == 0 );
574
575 if( ( aTriangleContainer->GetVertexSize() > 0 )
576 && ( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 ) )
577 {
578 GLuint listIdx = glGenLists( 1 );
579
580 if( glIsList( listIdx ) )
581 {
582 // Prepare an array of UV text coordinates
583 SFVEC2F* uvArray = new SFVEC2F[aTriangleContainer->GetVertexSize()];
584
585 for( unsigned int i = 0; i < aTriangleContainer->GetVertexSize(); i += 3 )
586 {
587 uvArray[i + 0] = SFVEC2F( 1.0f, 0.0f );
588 uvArray[i + 1] = SFVEC2F( 0.0f, 1.0f );
589 uvArray[i + 2] = SFVEC2F( 0.0f, 0.0f );
590 }
591
592 glEnableClientState( GL_TEXTURE_COORD_ARRAY );
593 glDisableClientState( GL_COLOR_ARRAY );
594 glDisableClientState( GL_NORMAL_ARRAY );
595 glEnableClientState( GL_VERTEX_ARRAY );
596 glVertexPointer( 3, GL_FLOAT, 0, aTriangleContainer->GetVertexPointer() );
597 glTexCoordPointer( 2, GL_FLOAT, 0, uvArray );
598
599 glNewList( listIdx, GL_COMPILE );
600
601 glDisable( GL_COLOR_MATERIAL );
602
603 glEnable( GL_TEXTURE_2D );
604 glBindTexture( GL_TEXTURE_2D, aTextureId );
605
606 glAlphaFunc( GL_GREATER, 0.2f );
607 glEnable( GL_ALPHA_TEST );
608
609 glNormal3f( 0.0f, 0.0f, aIsNormalUp?1.0f:-1.0f );
610
611 glDrawArrays( GL_TRIANGLES, 0, aTriangleContainer->GetVertexSize() );
612
613 glBindTexture( GL_TEXTURE_2D, 0 );
614 glDisable( GL_TEXTURE_2D );
615 glDisable( GL_ALPHA_TEST );
616 glDisable( GL_BLEND );
617
618 glEndList();
619
620 glDisableClientState( GL_VERTEX_ARRAY );
621 glDisableClientState( GL_TEXTURE_COORD_ARRAY );
622
623 delete [] uvArray;
624 return listIdx;
625 }
626 }
627
628 return 0;
629}
630
631
633 bool aIsNormalUp ) const
634{
635 wxCHECK( aTriangleContainer != nullptr, 0 );
636
637 wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 );
638
639 // Top and Bot dint have normals array stored in container
640 wxASSERT( aTriangleContainer->GetNormalsSize() == 0 );
641
642 if( ( aTriangleContainer->GetVertexSize() > 0 )
643 && ( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 ) )
644 {
645 const GLuint listIdx = glGenLists( 1 );
646
647 if( glIsList( listIdx ) )
648 {
649 glDisableClientState( GL_TEXTURE_COORD_ARRAY );
650 glDisableClientState( GL_COLOR_ARRAY );
651 glDisableClientState( GL_NORMAL_ARRAY );
652 glEnableClientState( GL_VERTEX_ARRAY );
653 glVertexPointer( 3, GL_FLOAT, 0, aTriangleContainer->GetVertexPointer() );
654
655 glNewList( listIdx, GL_COMPILE );
656
658
659 glNormal3f( 0.0f, 0.0f, aIsNormalUp?1.0f:-1.0f );
660
661 glDrawArrays( GL_TRIANGLES, 0, aTriangleContainer->GetVertexSize() );
662
663 glDisable( GL_BLEND );
664 glEndList();
665
666 glDisableClientState( GL_VERTEX_ARRAY );
667
668 return listIdx;
669 }
670 }
671
672 return 0;
673}
674
675
677 const TRIANGLE_LIST* aTriangleContainer ) const
678{
679 wxCHECK( aTriangleContainer != nullptr, 0 );
680
681 // We expect that it is a multiple of 3 vertex
682 wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 );
683
684 // We expect that it is a multiple of 6 vertex (because we expect to add quads)
685 wxASSERT( (aTriangleContainer->GetVertexSize() % 6 ) == 0 );
686
687 // We expect that there are normals with same size as vertex
688 wxASSERT( aTriangleContainer->GetNormalsSize() == aTriangleContainer->GetVertexSize() );
689
690 if( ( aTriangleContainer->GetVertexSize() > 0 )
691 && ( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 )
692 && ( ( aTriangleContainer->GetVertexSize() % 6 ) == 0 )
693 && ( aTriangleContainer->GetNormalsSize() == aTriangleContainer->GetVertexSize() ) )
694 {
695 const GLuint listIdx = glGenLists( 1 );
696
697 if( glIsList( listIdx ) )
698 {
699 glDisableClientState( GL_TEXTURE_COORD_ARRAY );
700 glDisableClientState( GL_COLOR_ARRAY );
701 glEnableClientState( GL_NORMAL_ARRAY );
702 glEnableClientState( GL_VERTEX_ARRAY );
703 glVertexPointer( 3, GL_FLOAT, 0, aTriangleContainer->GetVertexPointer() );
704 glNormalPointer( GL_FLOAT, 0, aTriangleContainer->GetNormalsPointer() );
705
706 glNewList( listIdx, GL_COMPILE );
707
709
710 glDrawArrays( GL_TRIANGLES, 0, aTriangleContainer->GetVertexSize() );
711
712 glDisable( GL_BLEND );
713 glEndList();
714
715 glDisableClientState( GL_VERTEX_ARRAY );
716 glDisableClientState( GL_NORMAL_ARRAY );
717
718 return listIdx;
719 }
720 }
721
722 return 0;
723}
724
725
727{
729 {
730 glPopMatrix();
731 }
732}
733
734
736{
737 glEnable( GL_BLEND );
738 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
739}
740
741
743{
745 {
746 glPushMatrix();
747 glTranslatef( 0.0f, 0.0f, m_zPositionTransformation );
748 glScalef( 1.0f, 1.0f, m_zScaleTransformation );
749 }
750}
751
752// LocalWords: EDA Luzeiro txt MERCHANTABILITY wxASSERT normals fo
bool IntersectAny(const RAYSEG2D &aSegRay) const override
Intersect and check if a segment ray hits a object or is inside it.
GLuint generate_middle_triangles(const TRIANGLE_LIST *aTriangleContainer) const
float GetZBot() const
float GetZTop() const
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
void DrawTop() const
Call the display lists for the top elements.
GLuint m_layer_middle_contours_quads
void DrawBot() const
Call the display lists for the bottom elements.
void ApplyScalePosition(float aZposition, float aZscale)
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.
OPENGL_RENDER_LIST(const TRIANGLE_DISPLAY_LIST &aLayerTriangles, GLuint aTextureIndexForSegEnds, float aZBot, float aZTop)
Create the display lists for a layer.
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
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.
std::vector< SFVEC3F > m_vertexs
vertex array
unsigned int GetNormalsSize() const
std::vector< SFVEC3F > m_normals
normals array
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
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.
VECTOR3I v1(5, 5, 5)
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683
glm::vec2 SFVEC2F
Definition xv3d_types.h:38
glm::vec3 SFVEC3F
Definition xv3d_types.h:40