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 30 of file layer_item_3d.cpp.

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

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; }
BBOX_3D m_bbox
Definition: object_3d.h:97

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; }
SFVEC3F m_centroid
Definition: object_3d.h:98

References OBJECT_3D::m_centroid.

◆ GetDiffuseColor()

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

Implements OBJECT_3D.

Definition at line 474 of file layer_item_3d.cpp.

475 {
476  return m_diffusecolor;
477 }
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 51 of file layer_item_3d.cpp.

52 {
53  float tBBoxStart;
54  float tBBoxEnd;
55 
56  if( !m_bbox.Intersect( aRay, &tBBoxStart, &tBBoxEnd ) )
57  return false;
58 
59  if( tBBoxStart >= aHitInfo.m_tHit )
60  return false;
61 
62  if( fabs( tBBoxStart - tBBoxEnd ) <= FLT_EPSILON )
63  return false;
64 
65  const bool startedInside = m_bbox.Inside( aRay.m_Origin );
66 
67  if( !startedInside )
68  {
69  float tTop = FLT_MAX;
70  float tBot = FLT_MAX;
71  bool hit_top = false;
72  bool hit_bot = false;
73 
74  if( (float) fabs( aRay.m_Dir.z ) > FLT_EPSILON )
75  {
76  tBot = ( m_bbox.Min().z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
77  tTop = ( m_bbox.Max().z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
78 
79  float tBBoxStartAdjusted = NextFloatUp( tBBoxStart );
80 
81  if( tBot > FLT_EPSILON )
82  {
83  hit_bot = tBot <= tBBoxStartAdjusted;
84  tBot = NextFloatDown( tBot );
85  }
86 
87  if( tTop > FLT_EPSILON )
88  {
89  hit_top = tTop <= tBBoxStartAdjusted;
90  tTop = NextFloatDown( tTop );
91  }
92  }
93 
94  SFVEC2F topHitPoint2d;
95  SFVEC2F botHitPoint2d;
96 
97  if( hit_top )
98  topHitPoint2d = SFVEC2F( aRay.m_Origin.x + aRay.m_Dir.x * tTop,
99  aRay.m_Origin.y + aRay.m_Dir.y * tTop );
100 
101  if( hit_bot )
102  botHitPoint2d = SFVEC2F( aRay.m_Origin.x + aRay.m_Dir.x * tBot,
103  aRay.m_Origin.y + aRay.m_Dir.y * tBot );
104 
105  if( hit_top && hit_bot )
106  {
107  if( tBot < tTop )
108  {
109  if( m_object2d->IsPointInside( botHitPoint2d ) )
110  {
111  if( tBot < aHitInfo.m_tHit )
112  {
113  aHitInfo.m_tHit = tBot;
114  aHitInfo.m_HitPoint = aRay.at( tBot );
115  aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, -1.0f );
116  aHitInfo.pHitObject = this;
117 
118  m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
119 
120  return true;
121  }
122 
123  return false;
124  }
125  }
126  else
127  {
128  if( m_object2d->IsPointInside( topHitPoint2d ) )
129  {
130  if( tTop < aHitInfo.m_tHit )
131  {
132  aHitInfo.m_tHit = tTop;
133  aHitInfo.m_HitPoint = aRay.at( tTop );
134  aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, 1.0f );
135  aHitInfo.pHitObject = this;
136 
137  m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
138 
139  return true;
140  }
141 
142  return false;
143  }
144  }
145  }
146  else
147  {
148  if( hit_top )
149  {
150  if( tTop < tBot )
151  {
152  if( m_object2d->IsPointInside( topHitPoint2d ) )
153  {
154  if( tTop < aHitInfo.m_tHit )
155  {
156  aHitInfo.m_tHit = tTop;
157  aHitInfo.m_HitPoint = aRay.at( tTop );
158  aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, 1.0f );
159  aHitInfo.pHitObject = this;
160 
161  m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
162 
163  return true;
164  }
165 
166  return false;
167  }
168  }
169  }
170  else
171  {
172  if( hit_bot )
173  {
174  if( tBot < tTop )
175  {
176  if( m_object2d->IsPointInside( botHitPoint2d ) )
177  {
178  if( tBot < aHitInfo.m_tHit )
179  {
180  aHitInfo.m_tHit = tBot;
181  aHitInfo.m_HitPoint = aRay.at( tBot );
182  aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, -1.0f );
183  aHitInfo.pHitObject = this;
184 
185  m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
186 
187  return true;
188  }
189 
190  return false;
191  }
192  }
193  }
194  else
195  {
196  // At this point, the ray miss the two planes but it still
197  // hits the box. It means that the rays are "(almost)parallel"
198  // to the planes, so must calc the intersection
199  }
200  }
201  }
202 
203  SFVEC3F boxHitPointStart = aRay.at( tBBoxStart );
204  SFVEC3F boxHitPointEnd = aRay.at( tBBoxEnd );
205 
206  SFVEC2F boxHitPointStart2D( boxHitPointStart.x, boxHitPointStart.y );
207  SFVEC2F boxHitPointEnd2D( boxHitPointEnd.x, boxHitPointEnd.y );
208 
209  float tOut;
210  SFVEC2F outNormal;
211  RAYSEG2D raySeg( boxHitPointStart2D, boxHitPointEnd2D );
212 
213  if( m_object2d->Intersect( raySeg, &tOut, &outNormal ) )
214  {
215  // The hitT is a hit value for the segment length 'start' - 'end',
216  // so it ranges from 0.0 - 1.0. We now convert it to a 3D hit position
217  // and calculate the real hitT of the ray.
218  SFVEC3F hitPoint = boxHitPointStart + ( boxHitPointEnd - boxHitPointStart ) * tOut;
219 
220  const float t = glm::length( hitPoint - aRay.m_Origin );
221 
222  if( t < aHitInfo.m_tHit )
223  {
224  aHitInfo.m_tHit = t;
225  aHitInfo.m_HitPoint = hitPoint;
226 
227  if( ( outNormal.x == 0.0f ) && ( outNormal.y == 0.0f ) )
228  {
229  aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, 1.0f );
230  }
231  else
232  {
233  aHitInfo.m_HitNormal = SFVEC3F( outNormal.x, outNormal.y, 0.0f );
234  }
235 
236  aHitInfo.pHitObject = this;
237 
238  m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
239 
240  return true;
241  }
242  }
243 
244  return false;
245  }
246  else
247  {
249  // Disabled due to refraction artifacts
250  // this will mostly happen inside the board body
251 #if 0
252  // Started inside
253  const SFVEC3F boxHitPointStart = aRay.at( tBBoxStart );
254  const SFVEC3F boxHitPointEnd = aRay.at( tBBoxEnd );
255 
256  const SFVEC2F boxHitPointStart2D( boxHitPointStart.x, boxHitPointStart.y );
257 
258  const SFVEC2F boxHitPointEnd2D( boxHitPointEnd.x, boxHitPointEnd.y );
259 
260  if( !( m_object2d->IsPointInside( boxHitPointStart2D ) &&
261  m_object2d->IsPointInside( boxHitPointEnd2D ) ) )
262  return false;
263 
264  float tOut;
265  SFVEC2F outNormal;
266  RAYSEG2D raySeg( boxHitPointStart2D, boxHitPointEnd2D );
267 
268  if( ( m_object2d->IsPointInside( boxHitPointStart2D ) &&
269  m_object2d->IsPointInside( boxHitPointEnd2D ) ) )
270  {
271  if( tBBoxEnd < aHitInfo.m_tHit )
272  {
273  aHitInfo.m_tHit = tBBoxEnd;
274  aHitInfo.m_HitPoint = aRay.at( tBBoxEnd );
275  aHitInfo.pHitObject = this;
276 
277  if( aRay.m_Dir.z > 0.0f )
278  aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, -1.0f );
279  else
280  aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, 1.0f );
281 
282  m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
283 
284  return true;
285  }
286  }
287  else
288  {
289  if( m_object2d->Intersect( raySeg, &tOut, &outNormal ) )
290  {
291  // The hitT is a hit value for the segment length 'start' - 'end',
292  // so it ranges from 0.0 - 1.0. We now convert it to a 3D hit position
293  // and calculate the real hitT of the ray.
294  const SFVEC3F hitPoint = boxHitPointStart +
295  ( boxHitPointEnd - boxHitPointStart ) * tOut;
296 
297  const float t = glm::length( hitPoint - aRay.m_Origin );
298 
299  if( t < aHitInfo.m_tHit )
300  {
301  aHitInfo.m_tHit = t;
302  aHitInfo.m_HitPoint = hitPoint;
303  aHitInfo.m_HitNormal = SFVEC3F( outNormal.x, outNormal.y, 0.0f );
304  aHitInfo.pHitObject = this;
305 
306  m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
307 
308  return true;
309  }
310  }
311  }
312 #endif
313  }
314 
315  return false;
316 }
const SFVEC3F & Max() const
Return the maximum vertex pointer.
Definition: bbox_3d.h:198
bool Intersect(const RAY &aRay, float *t) const
Definition: bbox_3d_ray.cpp:46
void Generate(SFVEC3F &aNormal, const RAY &aRay, const HITINFO &aHitInfo) const
Definition: material.cpp:89
float m_tHit
( 4) distance
Definition: hitinfo.h:38
SFVEC3F at(float t) const
Definition: ray.h:84
bool Inside(const SFVEC3F &aPoint) const
Check if a point is inside this bounding box.
Definition: bbox_3d.cpp:240
const SFVEC3F & Min() const
Return the minimum vertex pointer.
Definition: bbox_3d.h:191
SFVEC3F m_InvDir
Definition: ray.h:70
SFVEC3F m_HitPoint
(12) hit position
Definition: hitinfo.h:44
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
float NextFloatDown(float v)
Definition: 3d_fastmath.h:157
BBOX_3D m_bbox
Definition: object_3d.h:97
virtual bool Intersect(const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut) const =0
const MATERIAL * m_material
Definition: object_3d.h:100
const OBJECT_3D * pHitObject
( 4) Object that was hitted
Definition: hitinfo.h:40
SFVEC3F m_Dir
Definition: ray.h:67
SFVEC3F m_Origin
Definition: ray.h:64
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
float NextFloatUp(float v)
Definition: 3d_fastmath.h:136
SFVEC3F m_HitNormal
(12) normal at the hit point
Definition: hitinfo.h:37
const OBJECT_2D * m_object2d
Definition: layer_item_3d.h:45
virtual bool IsPointInside(const SFVEC2F &aPoint) const =0
Definition: ray.h:105

References RAY::at(), MATERIAL::Generate(), BBOX_3D::Inside(), OBJECT_2D::Intersect(), BBOX_3D::Intersect(), OBJECT_2D::IsPointInside(), 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 319 of file layer_item_3d.cpp.

320 {
321  float tBBoxStart;
322  float tBBoxEnd;
323 
324  if( !m_bbox.Intersect( aRay, &tBBoxStart, &tBBoxEnd ) )
325  return false;
326 
327  if( ( tBBoxStart > aMaxDistance ) || ( fabs( tBBoxStart - tBBoxEnd ) < FLT_EPSILON ) )
328  return false;
329 
330  float tTop = FLT_MAX;
331  float tBot = FLT_MAX;
332  bool hit_top = false;
333  bool hit_bot = false;
334 
335  if( (float)fabs( aRay.m_Dir.z ) > FLT_EPSILON )
336  {
337  tBot = ( m_bbox.Min().z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
338  tTop = ( m_bbox.Max().z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
339 
340  const float tBBoxStartAdjusted = NextFloatUp( tBBoxStart );
341 
342  if( tBot > FLT_EPSILON )
343  {
344  hit_bot = tBot <= tBBoxStartAdjusted;
345  tBot = NextFloatDown( tBot );
346  }
347 
348  if( tTop > FLT_EPSILON )
349  {
350  hit_top = tTop <= tBBoxStartAdjusted;
351  tTop = NextFloatDown( tTop );
352  }
353  }
354 
355  tBBoxStart = NextFloatDown( tBBoxStart );
356  tBBoxEnd = NextFloatUp( tBBoxEnd );
357 
358  SFVEC2F topHitPoint2d;
359  SFVEC2F botHitPoint2d;
360 
361  if( hit_top )
362  topHitPoint2d = SFVEC2F( aRay.m_Origin.x + aRay.m_Dir.x * tTop,
363  aRay.m_Origin.y + aRay.m_Dir.y * tTop );
364 
365  if( hit_bot )
366  botHitPoint2d = SFVEC2F( aRay.m_Origin.x + aRay.m_Dir.x * tBot,
367  aRay.m_Origin.y + aRay.m_Dir.y * tBot );
368 
369  if( hit_top && hit_bot )
370  {
371  if( tBot < tTop )
372  {
373  if( m_object2d->IsPointInside( botHitPoint2d ) )
374  {
375  if( tBot < aMaxDistance )
376  return true;
377 
378  return false;
379  }
380  }
381  else
382  {
383  if( m_object2d->IsPointInside( topHitPoint2d ) )
384  {
385  if( tTop < aMaxDistance )
386  return true;
387 
388  return false;
389  }
390  }
391  }
392  else
393  {
394  if( hit_top )
395  {
396  if( tTop < tBot )
397  {
398  if( m_object2d->IsPointInside( topHitPoint2d ) )
399  {
400  if( tTop < aMaxDistance )
401  return true;
402 
403  return false;
404  }
405  }
406  }
407  else
408  {
409  if( hit_bot )
410  {
411  if( tBot < tTop )
412  {
413  if( m_object2d->IsPointInside( botHitPoint2d ) )
414  {
415  if( tBot < aMaxDistance )
416  return true;
417 
418  return false;
419  }
420  }
421  }
422  else
423  {
424  // At this point, the ray miss the two planes but it still
425  // hits the box. It means that the rays are "(almost)parallel"
426  // to the planes, so must calc the intersection
427  }
428  }
429  }
430 
431  SFVEC3F boxHitPointStart = aRay.at( tBBoxStart );
432  SFVEC3F boxHitPointEnd = aRay.at( tBBoxEnd );
433 
434  SFVEC2F boxHitPointStart2D( boxHitPointStart.x, boxHitPointStart.y );
435 
436  SFVEC2F boxHitPointEnd2D( boxHitPointEnd.x, boxHitPointEnd.y );
437 
438  float tOut;
439  SFVEC2F outNormal;
440  RAYSEG2D raySeg( boxHitPointStart2D, boxHitPointEnd2D );
441 
442  if( m_object2d->Intersect( raySeg, &tOut, &outNormal ) )
443  {
444  //if( (tOut > FLT_EPSILON) && (tOut < 1.0f) )
445  {
446  // The hitT is a hit value for the segment length 'start' - 'end',
447  // so it ranges from 0.0 - 1.0. We now convert it to a 3D hit position
448  // and calculate the real hitT of the ray.
449  const SFVEC3F hitPoint = boxHitPointStart +
450  ( boxHitPointEnd - boxHitPointStart ) * tOut;
451  const float t = glm::length( hitPoint - aRay.m_Origin );
452 
453  if( ( t < aMaxDistance ) && ( t > FLT_EPSILON ) )
454  return true;
455  }
456  }
457 
458  return false;
459 }
const SFVEC3F & Max() const
Return the maximum vertex pointer.
Definition: bbox_3d.h:198
bool Intersect(const RAY &aRay, float *t) const
Definition: bbox_3d_ray.cpp:46
SFVEC3F at(float t) const
Definition: ray.h:84
const SFVEC3F & Min() const
Return the minimum vertex pointer.
Definition: bbox_3d.h:191
SFVEC3F m_InvDir
Definition: ray.h:70
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
float NextFloatDown(float v)
Definition: 3d_fastmath.h:157
BBOX_3D m_bbox
Definition: object_3d.h:97
virtual bool Intersect(const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut) const =0
SFVEC3F m_Dir
Definition: ray.h:67
SFVEC3F m_Origin
Definition: ray.h:64
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
float NextFloatUp(float v)
Definition: 3d_fastmath.h:136
const OBJECT_2D * m_object2d
Definition: layer_item_3d.h:45
virtual bool IsPointInside(const SFVEC2F &aPoint) const =0
Definition: ray.h:105

References RAY::at(), OBJECT_2D::Intersect(), BBOX_3D::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 462 of file layer_item_3d.cpp.

463 {
464  if( !m_bbox.Intersects( aBBox ) )
465  return false;
466 
467  const BBOX_2D bbox2D( SFVEC2F( aBBox.Min().x, aBBox.Min().y ),
468  SFVEC2F( aBBox.Max().x, aBBox.Max().y ) );
469 
470  return m_object2d->Intersects( bbox2D );
471 }
const SFVEC3F & Max() const
Return the maximum vertex pointer.
Definition: bbox_3d.h:198
const SFVEC3F & Min() const
Return the minimum vertex pointer.
Definition: bbox_3d.h:191
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
BBOX_3D m_bbox
Definition: object_3d.h:97
Manage a bounding box defined by two SFVEC2F min max points.
Definition: bbox_2d.h:41
const OBJECT_2D * m_object2d
Definition: layer_item_3d.h:45
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:227

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; }
BOARD_ITEM * m_boardItem
Definition: object_3d.h:102

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

Definition at line 58 of file object_3d.h.

59  {
60  m_material = aMaterial;
61  m_modelTransparency = aMaterial->GetTransparency(); // Default transparency is from material
62  }
float GetTransparency() const
Definition: material.h:273
float m_modelTransparency
Definition: object_3d.h:106
const MATERIAL * m_material
Definition: object_3d.h:100

References MATERIAL::GetTransparency(), OBJECT_3D::m_material, and OBJECT_3D::m_modelTransparency.

Referenced by RENDER_3D_RAYTRACE::addModels(), RENDER_3D_RAYTRACE::createItemsFromContainer(), RENDER_3D_RAYTRACE::createObject(), RENDER_3D_RAYTRACE::insertHole(), and RENDER_3D_RAYTRACE::Reload().

◆ SetModelTransparency()

void OBJECT_3D::SetModelTransparency ( float  aModelTransparency)
inlineinherited

Definition at line 66 of file object_3d.h.

67  {
68  m_modelTransparency = aModelTransparency;
69  }
float m_modelTransparency
Definition: object_3d.h:106

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: