KiCad PCB EDA Suite
LAYER_ITEM Class Reference

#include <layer_item_3d.h>

Inheritance diagram for LAYER_ITEM:
OBJECT_3D

Public Member Functions

 LAYER_ITEM (const OBJECT_2D *aObject2D, float aZMin, float aZMax)
 
void SetColor (SFVEC3F aObjColor)
 
bool Intersect (const RAY &aRay, HITINFO &aHitInfo) const override
 
bool IntersectP (const RAY &aRay, float aMaxDistance) const override
 
bool Intersects (const BBOX_3D &aBBox) const override
 
SFVEC3F GetDiffuseColor (const HITINFO &aHitInfo) const override
 
const void SetBoardItem (BOARD_ITEM *aBoardItem)
 
BOARD_ITEMGetBoardItem () const
 
void SetMaterial (const MATERIAL *aMaterial)
 
const MATERIALGetMaterial () const
 
float GetModelTransparency () const
 
void SetModelTransparency (float aModelTransparency)
 
const BBOX_3DGetBBox () const
 
const SFVEC3FGetCentroid () const
 

Protected Attributes

const OBJECT_2Dm_object2d
 
BBOX_3D m_bbox
 
SFVEC3F m_centroid
 
OBJECT_3D_TYPE m_obj_type
 
const MATERIALm_material
 
BOARD_ITEMm_boardItem
 
float m_modelTransparency
 

Private Attributes

SFVEC3F m_diffusecolor
 

Detailed Description

Definition at line 32 of file layer_item_3d.h.

Constructor & Destructor Documentation

◆ LAYER_ITEM()

LAYER_ITEM::LAYER_ITEM ( const OBJECT_2D aObject2D,
float  aZMin,
float  aZMax 
)

Definition at line 34 of file layer_item_3d.cpp.

34 :
36 m_object2d( aObject2D )
37{
38 wxASSERT( aObject2D );
39
40 BBOX_2D bbox2d = m_object2d->GetBBox();
41 bbox2d.ScaleNextUp();
42 bbox2d.ScaleNextUp();
43
44 m_bbox.Reset();
45 m_bbox.Set( SFVEC3F( bbox2d.Min().x, bbox2d.Min().y, aZMin ),
46 SFVEC3F( bbox2d.Max().x, bbox2d.Max().y, aZMax ) );
48 m_bbox.Scale( 1.0001f );
49
50 m_centroid = SFVEC3F( aObject2D->GetCentroid().x, aObject2D->GetCentroid().y,
51 ( aZMax + aZMin ) * 0.5f );
52}
const OBJECT_2D * m_object2d
Definition: layer_item_3d.h:45
const SFVEC2F & GetCentroid() const
Definition: object_2d.h:105
const BBOX_2D & GetBBox() const
Definition: object_2d.h:103
BBOX_3D m_bbox
Definition: object_3d.h:97
SFVEC3F m_centroid
Definition: object_3d.h:98
OBJECT_3D(OBJECT_3D_TYPE aObjType)
Definition: object_3d.cpp:41
Manage a bounding box defined by two SFVEC2F min max points.
Definition: bbox_2d.h:42
const SFVEC2F & Min() const
Definition: bbox_2d.h:167
const SFVEC2F & Max() const
Definition: bbox_2d.h:172
void ScaleNextUp()
Scale a bounding box to the next float representation making it larger.
Definition: bbox_2d.cpp:162
void ScaleNextUp()
Scale a bounding box to the next float representation making it larger.
Definition: bbox_3d.cpp:194
void Set(const SFVEC3F &aPbMin, const SFVEC3F &aPbMax)
Set bounding box with new parameters.
Definition: bbox_3d.cpp:68
void Reset()
Reset the bounding box to zero and de-initialize it.
Definition: bbox_3d.cpp:95
void Scale(float aScale)
Scales a bounding box by its center.
Definition: bbox_3d.cpp:182
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44

References OBJECT_2D::GetBBox(), OBJECT_2D::GetCentroid(), LAYERITEM, OBJECT_3D::m_bbox, OBJECT_3D::m_centroid, m_object2d, BBOX_2D::Max(), BBOX_2D::Min(), BBOX_3D::Reset(), BBOX_3D::Scale(), BBOX_2D::ScaleNextUp(), BBOX_3D::ScaleNextUp(), and BBOX_3D::Set().

Member Function Documentation

◆ GetBBox()

const BBOX_3D & OBJECT_3D::GetBBox ( ) const
inlineinherited

Definition at line 92 of file object_3d.h.

92{ return m_bbox; }

References OBJECT_3D::m_bbox.

Referenced by CONTAINER_3D_BASE::Add(), and BVH_PBRT::Intersect().

◆ GetBoardItem()

BOARD_ITEM * OBJECT_3D::GetBoardItem ( ) const
inlineinherited

Definition at line 56 of file object_3d.h.

56{ return m_boardItem; }
BOARD_ITEM * m_boardItem
Definition: object_3d.h:102

References OBJECT_3D::m_boardItem.

Referenced by RENDER_3D_RAYTRACE::IntersectBoardItem().

◆ GetCentroid()

const SFVEC3F & OBJECT_3D::GetCentroid ( ) const
inlineinherited

Definition at line 94 of file object_3d.h.

94{ return m_centroid; }

References OBJECT_3D::m_centroid.

◆ GetDiffuseColor()

SFVEC3F LAYER_ITEM::GetDiffuseColor ( const HITINFO aHitInfo) const
overridevirtual

Implements OBJECT_3D.

Definition at line 513 of file layer_item_3d.cpp.

514{
515 return m_diffusecolor;
516}
SFVEC3F m_diffusecolor
Definition: layer_item_3d.h:48

References m_diffusecolor.

◆ GetMaterial()

const MATERIAL * OBJECT_3D::GetMaterial ( ) const
inlineinherited

Definition at line 64 of file object_3d.h.

64{ return m_material; }
const MATERIAL * m_material
Definition: object_3d.h:100

References OBJECT_3D::m_material.

Referenced by BVH_PBRT::IntersectP(), and RENDER_3D_RAYTRACE::shadeHit().

◆ GetModelTransparency()

float OBJECT_3D::GetModelTransparency ( ) const
inlineinherited

Definition at line 65 of file object_3d.h.

65{ return m_modelTransparency; }
float m_modelTransparency
Definition: object_3d.h:106

References OBJECT_3D::m_modelTransparency.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ Intersect()

bool LAYER_ITEM::Intersect ( const RAY aRay,
HITINFO aHitInfo 
) const
overridevirtual
Returns
true if the aRay intersects the object.
Todo:
Either fix the code below or get rid of it.

Implements OBJECT_3D.

Definition at line 55 of file layer_item_3d.cpp.

56{
57 float tBBoxStart;
58 float tBBoxEnd;
59
60 if( !m_bbox.Intersect( aRay, &tBBoxStart, &tBBoxEnd ) )
61 return false;
62
63 if( tBBoxStart >= aHitInfo.m_tHit )
64 return false;
65
66 if( fabs( tBBoxStart - tBBoxEnd ) <= FLT_EPSILON )
67 return false;
68
69 const bool startedInside = m_bbox.Inside( aRay.m_Origin );
70
71 if( !startedInside )
72 {
73 float tTop = FLT_MAX;
74 float tBot = FLT_MAX;
75 bool hit_top = false;
76 bool hit_bot = false;
77
78 if( (float) fabs( aRay.m_Dir.z ) > FLT_EPSILON )
79 {
80 tBot = ( m_bbox.Min().z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
81 tTop = ( m_bbox.Max().z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
82
83 float tBBoxStartAdjusted = NextFloatUp( tBBoxStart );
84
85 if( tBot > FLT_EPSILON )
86 {
87 hit_bot = tBot <= tBBoxStartAdjusted;
88 tBot = NextFloatDown( tBot );
89 }
90
91 if( tTop > FLT_EPSILON )
92 {
93 hit_top = tTop <= tBBoxStartAdjusted;
94 tTop = NextFloatDown( tTop );
95 }
96 }
97
98 SFVEC2F topHitPoint2d;
99 SFVEC2F botHitPoint2d;
100
101 if( hit_top )
102 topHitPoint2d = SFVEC2F( aRay.m_Origin.x + aRay.m_Dir.x * tTop,
103 aRay.m_Origin.y + aRay.m_Dir.y * tTop );
104
105 if( hit_bot )
106 botHitPoint2d = SFVEC2F( aRay.m_Origin.x + aRay.m_Dir.x * tBot,
107 aRay.m_Origin.y + aRay.m_Dir.y * tBot );
108
109 if( hit_top && hit_bot )
110 {
111 if( tBot < tTop )
112 {
113 if( m_object2d->IsPointInside( botHitPoint2d ) )
114 {
115 if( tBot < aHitInfo.m_tHit )
116 {
117 aHitInfo.m_tHit = tBot;
118 aHitInfo.m_HitPoint = aRay.at( tBot );
119 aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, -1.0f );
120 aHitInfo.pHitObject = this;
121
122 m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
123
124 return true;
125 }
126
127 return false;
128 }
129 }
130 else
131 {
132 if( m_object2d->IsPointInside( topHitPoint2d ) )
133 {
134 if( tTop < aHitInfo.m_tHit )
135 {
136 aHitInfo.m_tHit = tTop;
137 aHitInfo.m_HitPoint = aRay.at( tTop );
138 aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, 1.0f );
139 aHitInfo.pHitObject = this;
140
141 m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
142
143 return true;
144 }
145
146 return false;
147 }
148 }
149 }
150 else
151 {
152 if( hit_top )
153 {
154 if( tTop < tBot )
155 {
156 if( m_object2d->IsPointInside( topHitPoint2d ) )
157 {
158 if( tTop < aHitInfo.m_tHit )
159 {
160 aHitInfo.m_tHit = tTop;
161 aHitInfo.m_HitPoint = aRay.at( tTop );
162 aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, 1.0f );
163 aHitInfo.pHitObject = this;
164
165 m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
166
167 return true;
168 }
169
170 return false;
171 }
172 }
173 }
174 else
175 {
176 if( hit_bot )
177 {
178 if( tBot < tTop )
179 {
180 if( m_object2d->IsPointInside( botHitPoint2d ) )
181 {
182 if( tBot < aHitInfo.m_tHit )
183 {
184 aHitInfo.m_tHit = tBot;
185 aHitInfo.m_HitPoint = aRay.at( tBot );
186 aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, -1.0f );
187 aHitInfo.pHitObject = this;
188
189 m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
190
191 return true;
192 }
193
194 return false;
195 }
196 }
197 }
198 else
199 {
200 // At this point, the ray miss the two planes but it still
201 // hits the box. It means that the rays are "(almost)parallel"
202 // to the planes, so must calc the intersection
203 }
204 }
205 }
206
207 SFVEC3F boxHitPointStart = aRay.at( tBBoxStart );
208 SFVEC3F boxHitPointEnd = aRay.at( tBBoxEnd );
209
210 SFVEC2F boxHitPointStart2D( boxHitPointStart.x, boxHitPointStart.y );
211 SFVEC2F boxHitPointEnd2D( boxHitPointEnd.x, boxHitPointEnd.y );
212
213 float tOut;
214 SFVEC2F outNormal;
215 RAYSEG2D raySeg( boxHitPointStart2D, boxHitPointEnd2D );
216
217 if( m_object2d->Intersect( raySeg, &tOut, &outNormal ) )
218 {
219 // The hitT is a hit value for the segment length 'start' - 'end',
220 // so it ranges from 0.0 - 1.0. We now convert it to a 3D hit position
221 // and calculate the real hitT of the ray.
222 SFVEC3F hitPoint = boxHitPointStart + ( boxHitPointEnd - boxHitPointStart ) * tOut;
223
224 const float t = glm::length( hitPoint - aRay.m_Origin );
225
226 if( t < aHitInfo.m_tHit )
227 {
228 aHitInfo.m_tHit = t;
229 aHitInfo.m_HitPoint = hitPoint;
230 aHitInfo.pHitObject = this;
231
232 const float zNormalDir = hit_top?1.0f:hit_bot?-1.0f:0.0f;
233
234 if( ( outNormal.x == 0.0f ) && ( outNormal.y == 0.0f ) )
235 {
236 aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, zNormalDir );
237 }
238 else
239 {
240 // Calculate smooth bevel normal
241 float zBend = 0.0f;
242
243 if( hit_top || hit_bot )
244 {
245 float zDistanceToTopOrBot;
246
247 // Calculate the distance from hitpoint z to the Max/Min z of the layer
248 if( hit_top )
249 {
250 zDistanceToTopOrBot = ( m_bbox.Max().z - hitPoint.z );
251 }
252 else
253 {
254 zDistanceToTopOrBot = ( hitPoint.z - m_bbox.Min().z );
255 }
256
257 // For items that are > than g_BevelThickness3DU
258 // (eg on board vias / plated holeS) use a factor based on m_bbox.GetExtent().z
259 const float bevelThickness = glm::max( g_BevelThickness3DU,
260 m_bbox.GetExtent().z *
262
263 if( ( zDistanceToTopOrBot > 0.0f ) && ( zDistanceToTopOrBot < bevelThickness ) )
264 {
265 // Invert and Normalize the distance 0..1
266 zBend = ( bevelThickness - zDistanceToTopOrBot ) / bevelThickness;
267 }
268 }
269
270 const SFVEC3F normalLateral = SFVEC3F( outNormal.x, outNormal.y, 0.0f );
271 const SFVEC3F normalTopBot = SFVEC3F( 0.0f, 0.0f, zNormalDir );
272
273 // Interpolate between the regular lateral normal and the top/bot normal
274 aHitInfo.m_HitNormal = glm::mix( normalLateral, normalTopBot, zBend );
275 }
276
277 m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
278
279 return true;
280 }
281 }
282
283 return false;
284 }
285 else
286 {
288 // Disabled due to refraction artifacts
289 // this will mostly happen inside the board body
290#if 0
291 // Started inside
292 const SFVEC3F boxHitPointStart = aRay.at( tBBoxStart );
293 const SFVEC3F boxHitPointEnd = aRay.at( tBBoxEnd );
294
295 const SFVEC2F boxHitPointStart2D( boxHitPointStart.x, boxHitPointStart.y );
296
297 const SFVEC2F boxHitPointEnd2D( boxHitPointEnd.x, boxHitPointEnd.y );
298
299 if( !( m_object2d->IsPointInside( boxHitPointStart2D ) &&
300 m_object2d->IsPointInside( boxHitPointEnd2D ) ) )
301 return false;
302
303 float tOut;
304 SFVEC2F outNormal;
305 RAYSEG2D raySeg( boxHitPointStart2D, boxHitPointEnd2D );
306
307 if( ( m_object2d->IsPointInside( boxHitPointStart2D ) &&
308 m_object2d->IsPointInside( boxHitPointEnd2D ) ) )
309 {
310 if( tBBoxEnd < aHitInfo.m_tHit )
311 {
312 aHitInfo.m_tHit = tBBoxEnd;
313 aHitInfo.m_HitPoint = aRay.at( tBBoxEnd );
314 aHitInfo.pHitObject = this;
315
316 if( aRay.m_Dir.z > 0.0f )
317 aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, -1.0f );
318 else
319 aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, 1.0f );
320
321 m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
322
323 return true;
324 }
325 }
326 else
327 {
328 if( m_object2d->Intersect( raySeg, &tOut, &outNormal ) )
329 {
330 // The hitT is a hit value for the segment length 'start' - 'end',
331 // so it ranges from 0.0 - 1.0. We now convert it to a 3D hit position
332 // and calculate the real hitT of the ray.
333 const SFVEC3F hitPoint = boxHitPointStart +
334 ( boxHitPointEnd - boxHitPointStart ) * tOut;
335
336 const float t = glm::length( hitPoint - aRay.m_Origin );
337
338 if( t < aHitInfo.m_tHit )
339 {
340 aHitInfo.m_tHit = t;
341 aHitInfo.m_HitPoint = hitPoint;
342 aHitInfo.m_HitNormal = SFVEC3F( outNormal.x, outNormal.y, 0.0f );
343 aHitInfo.pHitObject = this;
344
345 m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
346
347 return true;
348 }
349 }
350 }
351#endif
352 }
353
354 return false;
355}
float NextFloatDown(float v)
Definition: 3d_fastmath.h:157
float NextFloatUp(float v)
Definition: 3d_fastmath.h:136
double m_3DRT_BevelExtentFactor
3D-Viewer, Raytracing Factor applied to Extent.z of the item layer, used on calculation of the bevel'...
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void Generate(SFVEC3F &aNormal, const RAY &aRay, const HITINFO &aHitInfo) const
Definition: material.cpp:89
virtual bool Intersect(const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut) const =0
virtual bool IsPointInside(const SFVEC2F &aPoint) const =0
float g_BevelThickness3DU
const SFVEC3F GetExtent() const
Definition: bbox_3d.cpp:145
bool Intersect(const RAY &aRay, float *t) const
Definition: bbox_3d_ray.cpp:46
const SFVEC3F & Min() const
Return the minimum vertex pointer.
Definition: bbox_3d.h:183
const SFVEC3F & Max() const
Return the maximum vertex pointer.
Definition: bbox_3d.h:190
bool Inside(const SFVEC3F &aPoint) const
Check if a point is inside this bounding box.
Definition: bbox_3d.cpp:231
float m_tHit
( 4) distance
Definition: hitinfo.h:38
const OBJECT_3D * pHitObject
( 4) Object that was hitted
Definition: hitinfo.h:40
SFVEC3F m_HitNormal
(12) normal at the hit point
Definition: hitinfo.h:37
SFVEC3F m_HitPoint
(12) hit position
Definition: hitinfo.h:44
Definition: ray.h:106
SFVEC3F m_Dir
Definition: ray.h:67
SFVEC3F m_InvDir
Definition: ray.h:70
SFVEC3F m_Origin
Definition: ray.h:64
SFVEC3F at(float t) const
Definition: ray.h:84
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42

References RAY::at(), g_BevelThickness3DU, MATERIAL::Generate(), ADVANCED_CFG::GetCfg(), BBOX_3D::GetExtent(), BBOX_3D::Inside(), BBOX_3D::Intersect(), OBJECT_2D::Intersect(), OBJECT_2D::IsPointInside(), ADVANCED_CFG::m_3DRT_BevelExtentFactor, OBJECT_3D::m_bbox, RAY::m_Dir, HITINFO::m_HitNormal, HITINFO::m_HitPoint, RAY::m_InvDir, OBJECT_3D::m_material, m_object2d, RAY::m_Origin, HITINFO::m_tHit, BBOX_3D::Max(), BBOX_3D::Min(), NextFloatDown(), NextFloatUp(), and HITINFO::pHitObject.

◆ IntersectP()

bool LAYER_ITEM::IntersectP ( const RAY aRay,
float  aMaxDistance 
) const
overridevirtual
Parameters
aMaxDistanceis the maximum distance of the test.
Returns
true if aRay intersects the object.

Implements OBJECT_3D.

Definition at line 358 of file layer_item_3d.cpp.

359{
360 float tBBoxStart;
361 float tBBoxEnd;
362
363 if( !m_bbox.Intersect( aRay, &tBBoxStart, &tBBoxEnd ) )
364 return false;
365
366 if( ( tBBoxStart > aMaxDistance ) || ( fabs( tBBoxStart - tBBoxEnd ) < FLT_EPSILON ) )
367 return false;
368
369 float tTop = FLT_MAX;
370 float tBot = FLT_MAX;
371 bool hit_top = false;
372 bool hit_bot = false;
373
374 if( (float)fabs( aRay.m_Dir.z ) > FLT_EPSILON )
375 {
376 tBot = ( m_bbox.Min().z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
377 tTop = ( m_bbox.Max().z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
378
379 const float tBBoxStartAdjusted = NextFloatUp( tBBoxStart );
380
381 if( tBot > FLT_EPSILON )
382 {
383 hit_bot = tBot <= tBBoxStartAdjusted;
384 tBot = NextFloatDown( tBot );
385 }
386
387 if( tTop > FLT_EPSILON )
388 {
389 hit_top = tTop <= tBBoxStartAdjusted;
390 tTop = NextFloatDown( tTop );
391 }
392 }
393
394 tBBoxStart = NextFloatDown( tBBoxStart );
395 tBBoxEnd = NextFloatUp( tBBoxEnd );
396
397 SFVEC2F topHitPoint2d;
398 SFVEC2F botHitPoint2d;
399
400 if( hit_top )
401 topHitPoint2d = SFVEC2F( aRay.m_Origin.x + aRay.m_Dir.x * tTop,
402 aRay.m_Origin.y + aRay.m_Dir.y * tTop );
403
404 if( hit_bot )
405 botHitPoint2d = SFVEC2F( aRay.m_Origin.x + aRay.m_Dir.x * tBot,
406 aRay.m_Origin.y + aRay.m_Dir.y * tBot );
407
408 if( hit_top && hit_bot )
409 {
410 if( tBot < tTop )
411 {
412 if( m_object2d->IsPointInside( botHitPoint2d ) )
413 {
414 if( tBot < aMaxDistance )
415 return true;
416
417 return false;
418 }
419 }
420 else
421 {
422 if( m_object2d->IsPointInside( topHitPoint2d ) )
423 {
424 if( tTop < aMaxDistance )
425 return true;
426
427 return false;
428 }
429 }
430 }
431 else
432 {
433 if( hit_top )
434 {
435 if( tTop < tBot )
436 {
437 if( m_object2d->IsPointInside( topHitPoint2d ) )
438 {
439 if( tTop < aMaxDistance )
440 return true;
441
442 return false;
443 }
444 }
445 }
446 else
447 {
448 if( hit_bot )
449 {
450 if( tBot < tTop )
451 {
452 if( m_object2d->IsPointInside( botHitPoint2d ) )
453 {
454 if( tBot < aMaxDistance )
455 return true;
456
457 return false;
458 }
459 }
460 }
461 else
462 {
463 // At this point, the ray miss the two planes but it still
464 // hits the box. It means that the rays are "(almost)parallel"
465 // to the planes, so must calc the intersection
466 }
467 }
468 }
469
470 SFVEC3F boxHitPointStart = aRay.at( tBBoxStart );
471 SFVEC3F boxHitPointEnd = aRay.at( tBBoxEnd );
472
473 SFVEC2F boxHitPointStart2D( boxHitPointStart.x, boxHitPointStart.y );
474
475 SFVEC2F boxHitPointEnd2D( boxHitPointEnd.x, boxHitPointEnd.y );
476
477 float tOut;
478 SFVEC2F outNormal;
479 RAYSEG2D raySeg( boxHitPointStart2D, boxHitPointEnd2D );
480
481 if( m_object2d->Intersect( raySeg, &tOut, &outNormal ) )
482 {
483 //if( (tOut > FLT_EPSILON) && (tOut < 1.0f) )
484 {
485 // The hitT is a hit value for the segment length 'start' - 'end',
486 // so it ranges from 0.0 - 1.0. We now convert it to a 3D hit position
487 // and calculate the real hitT of the ray.
488 const SFVEC3F hitPoint = boxHitPointStart +
489 ( boxHitPointEnd - boxHitPointStart ) * tOut;
490 const float t = glm::length( hitPoint - aRay.m_Origin );
491
492 if( ( t < aMaxDistance ) && ( t > FLT_EPSILON ) )
493 return true;
494 }
495 }
496
497 return false;
498}

References RAY::at(), BBOX_3D::Intersect(), OBJECT_2D::Intersect(), OBJECT_2D::IsPointInside(), OBJECT_3D::m_bbox, RAY::m_Dir, RAY::m_InvDir, m_object2d, RAY::m_Origin, BBOX_3D::Max(), BBOX_3D::Min(), NextFloatDown(), and NextFloatUp().

◆ Intersects()

bool LAYER_ITEM::Intersects ( const BBOX_3D aBBox) const
overridevirtual
Returns
true if this object intersects aBBox.

Implements OBJECT_3D.

Definition at line 501 of file layer_item_3d.cpp.

502{
503 if( !m_bbox.Intersects( aBBox ) )
504 return false;
505
506 const BBOX_2D bbox2D( SFVEC2F( aBBox.Min().x, aBBox.Min().y ),
507 SFVEC2F( aBBox.Max().x, aBBox.Max().y ) );
508
509 return m_object2d->Intersects( bbox2D );
510}
virtual bool Intersects(const BBOX_2D &aBBox) const =0
a.Intersects(b) ⇔ !a.Disjoint(b) ⇔ !(a ∩ b = ∅)
bool Intersects(const BBOX_3D &aBBox) const
Test if a bounding box intersects this box.
Definition: bbox_3d.cpp:218

References OBJECT_2D::Intersects(), BBOX_3D::Intersects(), OBJECT_3D::m_bbox, m_object2d, BBOX_3D::Max(), and BBOX_3D::Min().

◆ SetBoardItem()

const void OBJECT_3D::SetBoardItem ( BOARD_ITEM aBoardItem)
inlineinherited

Definition at line 55 of file object_3d.h.

55{ m_boardItem = aBoardItem; }

References OBJECT_3D::m_boardItem.

Referenced by RENDER_3D_RAYTRACE::addModels().

◆ SetColor()

void LAYER_ITEM::SetColor ( SFVEC3F  aObjColor)
inline

◆ SetMaterial()

void OBJECT_3D::SetMaterial ( const MATERIAL aMaterial)
inlineinherited

◆ SetModelTransparency()

void OBJECT_3D::SetModelTransparency ( float  aModelTransparency)
inlineinherited

Definition at line 66 of file object_3d.h.

67 {
68 m_modelTransparency = aModelTransparency;
69 }

References OBJECT_3D::m_modelTransparency.

Referenced by RENDER_3D_RAYTRACE::addModels().

Member Data Documentation

◆ m_bbox

◆ m_boardItem

BOARD_ITEM* OBJECT_3D::m_boardItem
protectedinherited

◆ m_centroid

◆ m_diffusecolor

SFVEC3F LAYER_ITEM::m_diffusecolor
private

Definition at line 48 of file layer_item_3d.h.

Referenced by GetDiffuseColor(), and SetColor().

◆ m_material

◆ m_modelTransparency

float OBJECT_3D::m_modelTransparency
protectedinherited

◆ m_obj_type

OBJECT_3D_TYPE OBJECT_3D::m_obj_type
protectedinherited

Definition at line 99 of file object_3d.h.

Referenced by OBJECT_3D::OBJECT_3D().

◆ m_object2d

const OBJECT_2D* LAYER_ITEM::m_object2d
protected

Definition at line 45 of file layer_item_3d.h.

Referenced by Intersect(), IntersectP(), Intersects(), and LAYER_ITEM().


The documentation for this class was generated from the following files: