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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include "layer_triangles.h"
26#include "../raytracing/ray.h"
27#include <wx/debug.h> // For the wxASSERT
28#include <mutex>
29
30
31TRIANGLE_LIST::TRIANGLE_LIST( unsigned int aNrReservedTriangles, bool aReserveNormals )
32{
33 m_vertexs.clear();
34 m_normals.clear();
35
36 if( aNrReservedTriangles > 0 )
37 m_vertexs.reserve( aNrReservedTriangles * 3 );
38
39 if( aReserveNormals )
40 m_normals.reserve( aNrReservedTriangles * 3 );
41}
42
43
44void TRIANGLE_LIST::Reserve_More( unsigned int aNrReservedTriangles, bool aReserveNormals )
45{
46 m_vertexs.reserve( m_vertexs.size() + aNrReservedTriangles * 3 );
47
48 if( aReserveNormals )
49 m_normals.reserve( m_normals.size() + aNrReservedTriangles * 3 );
50}
51
52
53void TRIANGLE_LIST::AddQuad( const SFVEC3F& aV1, const SFVEC3F& aV2, const SFVEC3F& aV3,
54 const SFVEC3F& aV4 )
55{
56 m_vertexs.push_back( aV1 );
57 m_vertexs.push_back( aV2 );
58 m_vertexs.push_back( aV3 );
59
60 m_vertexs.push_back( aV3 );
61 m_vertexs.push_back( aV4 );
62 m_vertexs.push_back( aV1 );
63}
64
65
66void TRIANGLE_LIST::AddTriangle( const SFVEC3F& aV1, const SFVEC3F& aV2, const SFVEC3F& aV3 )
67{
68 m_vertexs.push_back( aV1 );
69 m_vertexs.push_back( aV2 );
70 m_vertexs.push_back( aV3 );
71}
72
73
74void TRIANGLE_LIST::AddNormal( const SFVEC3F& aN1, const SFVEC3F& aN2, const SFVEC3F& aN3 )
75{
76 m_normals.push_back( aN1 );
77 m_normals.push_back( aN2 );
78 m_normals.push_back( aN3 );
79}
80
81void TRIANGLE_LIST::AddNormal( const SFVEC3F& aN1, const SFVEC3F& aN2, const SFVEC3F& aN3,
82 const SFVEC3F& aN4 )
83{
84 m_normals.push_back( aN1 );
85 m_normals.push_back( aN2 );
86 m_normals.push_back( aN3 );
87
88 m_normals.push_back( aN3 );
89 m_normals.push_back( aN4 );
90 m_normals.push_back( aN1 );
91}
92
93
94TRIANGLE_DISPLAY_LIST::TRIANGLE_DISPLAY_LIST( unsigned int aNrReservedTriangles )
95{
96 m_layer_top_segment_ends = new TRIANGLE_LIST( aNrReservedTriangles, false );
97 m_layer_top_triangles = new TRIANGLE_LIST( aNrReservedTriangles, false );
98 m_layer_middle_contourns_quads = new TRIANGLE_LIST( aNrReservedTriangles, true );
99 m_layer_bot_triangles = new TRIANGLE_LIST( aNrReservedTriangles, false );
100 m_layer_bot_segment_ends = new TRIANGLE_LIST( aNrReservedTriangles, false );
101}
102
103
121
122
123void TRIANGLE_DISPLAY_LIST::AddToMiddleContourns( const std::vector< SFVEC2F >& aContournPoints,
124 float zBot, float zTop, bool aInvertFaceDirection,
125 const BVH_CONTAINER_2D* aThroughHoles )
126{
127 if( aContournPoints.size() >= 4 )
128 {
129 // Calculate normals of each segment of the contour
130 std::vector< SFVEC2F > contournNormals;
131
132 contournNormals.clear();
133 contournNormals.resize( aContournPoints.size() - 1 );
134
135 if( aInvertFaceDirection )
136 {
137 for( unsigned int i = 0; i < ( aContournPoints.size() - 1 ); ++i )
138 {
139 const SFVEC2F& v0 = aContournPoints[i + 0];
140 const SFVEC2F& v1 = aContournPoints[i + 1];
141 const SFVEC2F n = glm::normalize( v1 - v0 );
142
143 contournNormals[i] = SFVEC2F( n.y,-n.x );
144 }
145 }
146 else
147 {
148 for( unsigned int i = 0; i < ( aContournPoints.size() - 1 ); ++i )
149 {
150 const SFVEC2F& v0 = aContournPoints[i + 0];
151 const SFVEC2F& v1 = aContournPoints[i + 1];
152 const SFVEC2F n = glm::normalize( v1 - v0 );
153
154 contournNormals[i] = SFVEC2F( -n.y, n.x );
155 }
156 }
157
158
159 if( aInvertFaceDirection )
160 std::swap( zBot, zTop );
161
162 const unsigned int nContournsToProcess = ( aContournPoints.size() - 1 );
163
164 for( unsigned int i = 0; i < nContournsToProcess; ++i )
165 {
166 SFVEC2F lastNormal;
167
168 if( i > 0 )
169 lastNormal = contournNormals[i - 1];
170 else
171 lastNormal = contournNormals[nContournsToProcess - 1];
172
173 SFVEC2F n0 = contournNormals[i];
174
175 // Only interpolate the normal if the angle is closer
176 if( glm::dot( n0, lastNormal ) > 0.5f )
177 n0 = glm::normalize( n0 + lastNormal );
178
179 SFVEC2F nextNormal;
180
181 if( i < (nContournsToProcess - 1) )
182 nextNormal = contournNormals[i + 1];
183 else
184 nextNormal = contournNormals[0];
185
186 SFVEC2F n1 = contournNormals[i];
187
188 if( glm::dot( n1, nextNormal ) > 0.5f )
189 n1 = glm::normalize( n1 + nextNormal );
190
191 const SFVEC3F n3d0 = SFVEC3F( n0.x, n0.y, 0.0f );
192 const SFVEC3F n3d1 = SFVEC3F( n1.x, n1.y, 0.0f );
193
194 const SFVEC2F& v0 = aContournPoints[i + 0];
195 const SFVEC2F& v1 = aContournPoints[i + 1];
196
197 if( aThroughHoles && aThroughHoles->IntersectAny( RAYSEG2D( v0, v1 ) ) )
198 {
199 continue;
200 }
201 else
202 {
203 std::lock_guard<std::mutex> lock( m_middle_layer_lock );
204 m_layer_middle_contourns_quads->AddQuad( SFVEC3F( v0.x, v0.y, zTop ),
205 SFVEC3F( v1.x, v1.y, zTop ),
206 SFVEC3F( v1.x, v1.y, zBot ),
207 SFVEC3F( v0.x, v0.y, zBot ) );
208
209 m_layer_middle_contourns_quads->AddNormal( n3d0, n3d1, n3d1, n3d0 );
210 }
211 }
212 }
213}
214
215
217 float zTop, double aBiuTo3Du,
218 bool aInvertFaceDirection,
219 const BVH_CONTAINER_2D* aThroughHoles )
220{
221 std::vector< SFVEC2F >contournPoints;
222
223 contournPoints.clear();
224 contournPoints.reserve( outlinePath.PointCount() + 2 );
225
226 const VECTOR2I& firstV = outlinePath.CPoint( 0 );
227
228 SFVEC2F lastV = SFVEC2F( firstV.x * aBiuTo3Du, -firstV.y * aBiuTo3Du );
229
230 contournPoints.push_back( lastV );
231
232 for( unsigned int i = 1; i < (unsigned int)outlinePath.PointCount(); ++i )
233 {
234 const VECTOR2I& v = outlinePath.CPoint( i );
235
236 const SFVEC2F vf = SFVEC2F( v.x * aBiuTo3Du, -v.y * aBiuTo3Du );
237
238 if( vf != lastV ) // Do not add repeated points
239 {
240 lastV = vf;
241 contournPoints.push_back( vf );
242 }
243 }
244
245 // Add first position of the list to close the path.
246 if( lastV != contournPoints[0] )
247 contournPoints.push_back( contournPoints[0] );
248
249 AddToMiddleContourns( contournPoints, zBot, zTop, aInvertFaceDirection, aThroughHoles );
250}
251
252
254 float zTop, double aBiuTo3Du,
255 bool aInvertFaceDirection,
256 const BVH_CONTAINER_2D* aThroughHoles )
257{
258 if( aPolySet.OutlineCount() == 0 )
259 return;
260
261 // Calculate an estimation of points to reserve
262 unsigned int nrContournPointsToReserve = 0;
263
264 for( int i = 0; i < aPolySet.OutlineCount(); ++i )
265 {
266 const SHAPE_LINE_CHAIN& pathOutline = aPolySet.COutline( i );
267
268 nrContournPointsToReserve += pathOutline.PointCount();
269
270 for( int h = 0; h < aPolySet.HoleCount( i ); ++h )
271 {
272 const SHAPE_LINE_CHAIN& hole = aPolySet.CHole( i, h );
273
274 nrContournPointsToReserve += hole.PointCount();
275 }
276 }
277
278 // Request to reserve more space
279 m_layer_middle_contourns_quads->Reserve_More( nrContournPointsToReserve * 2, true );
280
281 for( int i = 0; i < aPolySet.OutlineCount(); i++ )
282 {
283 // Add outline
284 const SHAPE_LINE_CHAIN& pathOutline = aPolySet.COutline( i );
285
286 AddToMiddleContourns( pathOutline, zBot, zTop, aBiuTo3Du, aInvertFaceDirection,
287 aThroughHoles );
288
289 // Add holes for this outline
290 for( int h = 0; h < aPolySet.HoleCount( i ); ++h )
291 {
292 const SHAPE_LINE_CHAIN& hole = aPolySet.CHole( i, h );
293 AddToMiddleContourns( hole, zBot, zTop, aBiuTo3Du, aInvertFaceDirection,
294 aThroughHoles );
295 }
296 }
297}
298
299
301 GLuint aTextureIndexForSegEnds,
302 float aZBot, float aZTop )
303{
304 m_zBot = aZBot;
305 m_zTop = aZTop;
306
312
313 if( aTextureIndexForSegEnds )
314 {
315 wxASSERT( glIsTexture( aTextureIndexForSegEnds ) );
316
317 if( glIsTexture( aTextureIndexForSegEnds ) )
318 {
321 true, aTextureIndexForSegEnds );
322
325 false, aTextureIndexForSegEnds );
326 }
327 }
328
330 true );
331
333 false );
334
335
336 if( aLayerTriangles.m_layer_middle_contourns_quads->GetVertexSize() > 0 )
337 {
340 }
341
342 m_draw_it_transparent = false;
343 m_haveTransformation = false;
346}
347
348
350{
351 if( glIsList( m_layer_top_segment_ends ) )
352 glDeleteLists( m_layer_top_segment_ends, 1 );
353
354 if( glIsList( m_layer_top_triangles ) )
355 glDeleteLists( m_layer_top_triangles, 1 );
356
357 if( glIsList( m_layer_middle_contourns_quads ) )
358 glDeleteLists( m_layer_middle_contourns_quads, 1 );
359
360 if( glIsList( m_layer_bot_triangles ) )
361 glDeleteLists( m_layer_bot_triangles, 1 );
362
363 if( glIsList( m_layer_bot_segment_ends ) )
364 glDeleteLists( m_layer_bot_segment_ends, 1 );
365
371}
372
373
375{
377
378 if( glIsList( m_layer_middle_contourns_quads ) )
379 glCallList( m_layer_middle_contourns_quads );
380
381 if( glIsList( m_layer_top_triangles ) )
382 glCallList( m_layer_top_triangles );
383
384 if( glIsList( m_layer_top_segment_ends ) )
385 glCallList( m_layer_top_segment_ends );
386
388}
389
390
392{
394
395 if( glIsList( m_layer_middle_contourns_quads ) )
396 glCallList( m_layer_middle_contourns_quads );
397
398 if( glIsList( m_layer_bot_triangles ) )
399 glCallList( m_layer_bot_triangles );
400
401 if( glIsList( m_layer_bot_segment_ends ) )
402 glCallList( m_layer_bot_segment_ends );
403
405}
406
407
409{
411
412 if( glIsList( m_layer_top_triangles ) )
413 glCallList( m_layer_top_triangles );
414
415 if( glIsList( m_layer_top_segment_ends ) )
416 glCallList( m_layer_top_segment_ends );
417
419}
420
421
423{
425
426 if( glIsList( m_layer_bot_triangles ) )
427 glCallList( m_layer_bot_triangles );
428
429 if( glIsList( m_layer_bot_segment_ends ) )
430 glCallList( m_layer_bot_segment_ends );
431
433}
434
435
437{
439
440 if( glIsList( m_layer_middle_contourns_quads ) )
441 glCallList( m_layer_middle_contourns_quads );
442
444}
445
446
447void OPENGL_RENDER_LIST::DrawAll( bool aDrawMiddle ) const
448{
450
451 if( aDrawMiddle )
452 if( glIsList( m_layer_middle_contourns_quads ) )
453 glCallList( m_layer_middle_contourns_quads );
454
455 if( glIsList( m_layer_top_triangles ) )
456 glCallList( m_layer_top_triangles );
457
458 if( glIsList( m_layer_bot_triangles ) )
459 glCallList( m_layer_bot_triangles );
460
461 if( glIsList( m_layer_top_segment_ends ) )
462 glCallList( m_layer_top_segment_ends );
463
464 if( glIsList( m_layer_bot_segment_ends ) )
465 glCallList( m_layer_bot_segment_ends );
466
468}
469
470
471void OPENGL_RENDER_LIST::DrawCulled( bool aDrawMiddle,
472 const OPENGL_RENDER_LIST* aSubtractList,
473 const OPENGL_RENDER_LIST* bSubtractList,
474 const OPENGL_RENDER_LIST* cSubtractList,
475 const OPENGL_RENDER_LIST* dSubtractList ) const
476{
477 glClearStencil( 0x00 );
478 glClear( GL_STENCIL_BUFFER_BIT );
479
480 glEnable( GL_CULL_FACE );
481 glCullFace( GL_BACK );
482
483 glDisable( GL_DEPTH_TEST );
484 glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
485 glDepthMask( GL_FALSE );
486 glEnable( GL_STENCIL_TEST );
487 glStencilFunc( GL_ALWAYS, 1, 0 );
488 glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
489
490 if( aSubtractList )
491 aSubtractList->DrawBot();
492
493 if( bSubtractList )
494 bSubtractList->DrawBot();
495
496 if( cSubtractList )
497 cSubtractList->DrawBot();
498
499 if( dSubtractList )
500 dSubtractList->DrawBot();
501
502 glEnable( GL_DEPTH_TEST );
503 glDepthMask( GL_TRUE );
504
505 glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
506 glStencilFunc( GL_EQUAL, 0, 1 );
507 glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
508 DrawBot();
509
510 glDisable( GL_DEPTH_TEST );
511 glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
512 glDepthMask( GL_FALSE );
513 glEnable( GL_STENCIL_TEST );
514 glStencilFunc( GL_ALWAYS, 2, 0 );
515 glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
516
517 if( aSubtractList )
518 aSubtractList->DrawTop();
519
520 if( bSubtractList )
521 bSubtractList->DrawTop();
522
523 if( cSubtractList )
524 cSubtractList->DrawTop();
525
526 if( dSubtractList )
527 dSubtractList->DrawTop();
528
529 glEnable( GL_DEPTH_TEST );
530 glDepthMask( GL_TRUE );
531 glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
532 glStencilFunc( GL_NOTEQUAL, 2, 0x03 );
533 glStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
534 DrawTop();
535
536 if( aDrawMiddle )
537 DrawMiddle();
538
539 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );
540
541 glCullFace( GL_FRONT );
542 glStencilFunc( GL_GEQUAL, 3, 0x03 );
543 glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
544 glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
545
546 if( aDrawMiddle )
547 {
548 if( aSubtractList )
549 aSubtractList->DrawMiddle();
550 }
551
552 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
553
554 glCullFace( GL_BACK );
555 glDisable( GL_STENCIL_TEST );
556}
557
558
559void OPENGL_RENDER_LIST::ApplyScalePosition( float aZposition, float aZscale )
560{
561 wxCHECK2( aZscale > FLT_EPSILON, aZscale = FLT_EPSILON + 1 );
562
563 m_zPositionTransformation = aZposition;
564 m_zScaleTransformation = aZscale;
566}
567
568
570{
571 ApplyScalePosition( aOtherList->GetZBot(), aOtherList->GetZTop() - aOtherList->GetZBot() );
572}
573
574
575void OPENGL_RENDER_LIST::SetItIsTransparent( bool aSetTransparent )
576{
577 m_draw_it_transparent = aSetTransparent;
578}
579
580
582 const TRIANGLE_LIST* aTriangleContainer, bool aIsNormalUp, GLuint aTextureId ) const
583{
584 wxCHECK( aTriangleContainer != nullptr, 0 );
585
586 wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 );
587
588 // Top and Bot don't have normals array stored in container
589 wxASSERT( aTriangleContainer->GetNormalsSize() == 0 );
590
591 if( ( aTriangleContainer->GetVertexSize() > 0 )
592 && ( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 ) )
593 {
594 GLuint listIdx = glGenLists( 1 );
595
596 if( glIsList( listIdx ) )
597 {
598 // Prepare an array of UV text coordinates
599 SFVEC2F* uvArray = new SFVEC2F[aTriangleContainer->GetVertexSize()];
600
601 for( unsigned int i = 0; i < aTriangleContainer->GetVertexSize(); i += 3 )
602 {
603 uvArray[i + 0] = SFVEC2F( 1.0f, 0.0f );
604 uvArray[i + 1] = SFVEC2F( 0.0f, 1.0f );
605 uvArray[i + 2] = SFVEC2F( 0.0f, 0.0f );
606 }
607
608 glEnableClientState( GL_TEXTURE_COORD_ARRAY );
609 glDisableClientState( GL_COLOR_ARRAY );
610 glDisableClientState( GL_NORMAL_ARRAY );
611 glEnableClientState( GL_VERTEX_ARRAY );
612 glVertexPointer( 3, GL_FLOAT, 0, aTriangleContainer->GetVertexPointer() );
613 glTexCoordPointer( 2, GL_FLOAT, 0, uvArray );
614
615 glNewList( listIdx, GL_COMPILE );
616
617 glDisable( GL_COLOR_MATERIAL );
618
619 glEnable( GL_TEXTURE_2D );
620 glBindTexture( GL_TEXTURE_2D, aTextureId );
621
622 glAlphaFunc( GL_GREATER, 0.2f );
623 glEnable( GL_ALPHA_TEST );
624
625 glNormal3f( 0.0f, 0.0f, aIsNormalUp?1.0f:-1.0f );
626
627 glDrawArrays( GL_TRIANGLES, 0, aTriangleContainer->GetVertexSize() );
628
629 glBindTexture( GL_TEXTURE_2D, 0 );
630 glDisable( GL_TEXTURE_2D );
631 glDisable( GL_ALPHA_TEST );
632 glDisable( GL_BLEND );
633
634 glEndList();
635
636 glDisableClientState( GL_VERTEX_ARRAY );
637 glDisableClientState( GL_TEXTURE_COORD_ARRAY );
638
639 delete [] uvArray;
640 return listIdx;
641 }
642 }
643
644 return 0;
645}
646
647
649 bool aIsNormalUp ) const
650{
651 wxCHECK( aTriangleContainer != nullptr, 0 );
652
653 wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 );
654
655 // Top and Bot dint have normals array stored in container
656 wxASSERT( aTriangleContainer->GetNormalsSize() == 0 );
657
658 if( ( aTriangleContainer->GetVertexSize() > 0 )
659 && ( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 ) )
660 {
661 const GLuint listIdx = glGenLists( 1 );
662
663 if( glIsList( listIdx ) )
664 {
665 glDisableClientState( GL_TEXTURE_COORD_ARRAY );
666 glDisableClientState( GL_COLOR_ARRAY );
667 glDisableClientState( GL_NORMAL_ARRAY );
668 glEnableClientState( GL_VERTEX_ARRAY );
669 glVertexPointer( 3, GL_FLOAT, 0, aTriangleContainer->GetVertexPointer() );
670
671 glNewList( listIdx, GL_COMPILE );
672
674
675 glNormal3f( 0.0f, 0.0f, aIsNormalUp?1.0f:-1.0f );
676
677 glDrawArrays( GL_TRIANGLES, 0, aTriangleContainer->GetVertexSize() );
678
679 glDisable( GL_BLEND );
680 glEndList();
681
682 glDisableClientState( GL_VERTEX_ARRAY );
683
684 return listIdx;
685 }
686 }
687
688 return 0;
689}
690
691
693 const TRIANGLE_LIST* aTriangleContainer ) const
694{
695 wxCHECK( aTriangleContainer != nullptr, 0 );
696
697 // We expect that it is a multiple of 3 vertex
698 wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 );
699
700 // We expect that it is a multiple of 6 vertex (because we expect to add quads)
701 wxASSERT( (aTriangleContainer->GetVertexSize() % 6 ) == 0 );
702
703 // We expect that there are normals with same size as vertex
704 wxASSERT( aTriangleContainer->GetNormalsSize() == aTriangleContainer->GetVertexSize() );
705
706 if( ( aTriangleContainer->GetVertexSize() > 0 )
707 && ( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 )
708 && ( ( aTriangleContainer->GetVertexSize() % 6 ) == 0 )
709 && ( aTriangleContainer->GetNormalsSize() == aTriangleContainer->GetVertexSize() ) )
710 {
711 const GLuint listIdx = glGenLists( 1 );
712
713 if( glIsList( listIdx ) )
714 {
715 glDisableClientState( GL_TEXTURE_COORD_ARRAY );
716 glDisableClientState( GL_COLOR_ARRAY );
717 glEnableClientState( GL_NORMAL_ARRAY );
718 glEnableClientState( GL_VERTEX_ARRAY );
719 glVertexPointer( 3, GL_FLOAT, 0, aTriangleContainer->GetVertexPointer() );
720 glNormalPointer( GL_FLOAT, 0, aTriangleContainer->GetNormalsPointer() );
721
722 glNewList( listIdx, GL_COMPILE );
723
725
726 glDrawArrays( GL_TRIANGLES, 0, aTriangleContainer->GetVertexSize() );
727
728 glDisable( GL_BLEND );
729 glEndList();
730
731 glDisableClientState( GL_VERTEX_ARRAY );
732 glDisableClientState( GL_NORMAL_ARRAY );
733
734 return listIdx;
735 }
736 }
737
738 return 0;
739}
740
741
743{
745 {
746 glPopMatrix();
747 }
748}
749
750
752{
753 glEnable( GL_BLEND );
754 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
755}
756
757
759{
761 {
762 glPushMatrix();
763 glTranslatef( 0.0f, 0.0f, m_zPositionTransformation );
764 glScalef( 1.0f, 1.0f, m_zScaleTransformation );
765 }
766}
767
768// 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
GLuint m_layer_middle_contourns_quads
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.
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
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
void AddToMiddleContourns(const SHAPE_LINE_CHAIN &outlinePath, float zBot, float zTop, double aBiuTo3Du, bool aInvertFaceDirection, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
TRIANGLE_LIST * m_layer_middle_contourns_quads
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.
VECTOR3I v1(5, 5, 5)
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695
glm::vec2 SFVEC2F
Definition xv3d_types.h:42
glm::vec3 SFVEC3F
Definition xv3d_types.h:44