KiCad PCB EDA Suite
CDUMMYBLOCK Class Reference

A dummy block is used to fill the polygons. More...

#include <cdummyblock.h>

Inheritance diagram for CDUMMYBLOCK:
COBJECT

Public Member Functions

 CDUMMYBLOCK (const CBBOX &aBBox)
 
void SetColor (SFVEC3F aObjColor)
 
bool Intersect (const RAY &aRay, HITINFO &aHitInfo) const override
 Functions Intersect. More...
 
bool IntersectP (const RAY &aRay, float aMaxDistance) const override
 Functions Intersect for shadow test. More...
 
bool Intersects (const CBBOX &aBBox) const override
 Function Intersects. More...
 
SFVEC3F GetDiffuseColor (const HITINFO &aHitInfo) const override
 
void SetMaterial (const CMATERIAL *aMaterial)
 
const CMATERIALGetMaterial () const
 
const CBBOXGetBBox () const
 
const SFVEC3FGetCentroid () const
 

Protected Attributes

CBBOX m_bbox
 
SFVEC3F m_centroid
 
OBJECT3D_TYPE m_obj_type
 
const CMATERIALm_material
 

Private Attributes

SFVEC3F m_diffusecolor
 

Detailed Description

A dummy block is used to fill the polygons.

It will only will be intersepted from top or from bottom

Definition at line 39 of file cdummyblock.h.

Constructor & Destructor Documentation

CDUMMYBLOCK::CDUMMYBLOCK ( const CBBOX aBBox)
explicit

Definition at line 33 of file cdummyblock.cpp.

References CBBOX::GetCenter(), COBJECT::m_bbox, COBJECT::m_centroid, CBBOX::Reset(), and CBBOX::Set().

34 {
35  m_centroid = aBBox.GetCenter();
36  m_bbox.Reset();
37  m_bbox.Set( aBBox );
38 }
SFVEC3F m_centroid
Definition: cobject.h:54
CBBOX m_bbox
Definition: cobject.h:53
void Set(const SFVEC3F &aPbMin, const SFVEC3F &aPbMax)
Function Set Set bounding box with new parameters.
Definition: cbbox.cpp:67
COBJECT(OBJECT3D_TYPE aObjType)
Definition: cobject.cpp:38
SFVEC3F GetCenter() const
Function GetCenter return the center point of the bounding box.
Definition: cbbox.cpp:135
void Reset()
Function Reset reset the bounding box to zero and de-initialized it.
Definition: cbbox.cpp:98

Member Function Documentation

const CBBOX& COBJECT::GetBBox ( ) const
inlineinherited

Definition at line 94 of file cobject.h.

References COBJECT::m_bbox.

Referenced by CGENERICCONTAINER::Add(), and CBVH_PBRT::Intersect().

94 { return m_bbox; }
CBBOX m_bbox
Definition: cobject.h:53
const SFVEC3F& COBJECT::GetCentroid ( ) const
inlineinherited

Definition at line 96 of file cobject.h.

References COBJECT::m_centroid.

96 { return m_centroid; }
SFVEC3F m_centroid
Definition: cobject.h:54
SFVEC3F CDUMMYBLOCK::GetDiffuseColor ( const HITINFO aHitInfo) const
overridevirtual

Implements COBJECT.

Definition at line 89 of file cdummyblock.cpp.

References m_diffusecolor.

90 {
91  (void)aHitInfo; // unused
92 
93  return m_diffusecolor;
94 }
SFVEC3F m_diffusecolor
Definition: cdummyblock.h:53
const CMATERIAL* COBJECT::GetMaterial ( ) const
inlineinherited

Definition at line 63 of file cobject.h.

References COBJECT::m_material.

Referenced by CBVH_PBRT::IntersectP(), and C3D_RENDER_RAYTRACING::shadeHit().

63 { return m_material; }
const CMATERIAL * m_material
Definition: cobject.h:56
bool CDUMMYBLOCK::Intersect ( const RAY aRay,
HITINFO aHitInfo 
) const
overridevirtual

Functions Intersect.

Intersect

Parameters
aRay
aHitInfo
Returns
TRUE if the aRay intersects the object

Implements COBJECT.

Definition at line 41 of file cdummyblock.cpp.

References RAY::at(), CBBOX::Intersect(), COBJECT::m_bbox, RAY::m_dirIsNeg, HITINFO::m_HitNormal, HITINFO::m_HitPoint, COBJECT::m_material, HITINFO::m_tHit, CMATERIAL::PerturbeNormal(), and HITINFO::pHitObject.

42 {
43  float t;
44 
45  if( !m_bbox.Intersect( aRay, &t ) )
46  return false;
47 
48  if( t < aHitInfo.m_tHit )
49  {
50  aHitInfo.m_tHit = t;
51  aHitInfo.m_HitPoint = aRay.at( t );
52 
53  if( aRay.m_dirIsNeg[2] )
54  aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, 1.0f );
55  else
56  aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f,-1.0f );
57 
58  m_material->PerturbeNormal( aHitInfo.m_HitNormal, aRay, aHitInfo );
59 
60  aHitInfo.pHitObject = this;
61 
62  return true;
63  }
64 
65  return false;
66 }
SFVEC3F at(float t) const
Definition: ray.h:65
CBBOX m_bbox
Definition: cobject.h:53
const CMATERIAL * m_material
Definition: cobject.h:56
float m_tHit
( 4) distance
Definition: hitinfo.h:43
SFVEC3F m_HitPoint
(12) hit position
Definition: hitinfo.h:49
void PerturbeNormal(SFVEC3F &aNormal, const RAY &aRay, const HITINFO &aHitInfo) const
Definition: cmaterial.cpp:88
unsigned int m_dirIsNeg[3]
Definition: ray.h:56
bool Intersect(const RAY &aRay, float *t) const
Function Intersect.
Definition: cbbox_ray.cpp:46
const COBJECT * pHitObject
( 4) Object that was hitted
Definition: hitinfo.h:45
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
SFVEC3F m_HitNormal
(12) normal at the hit point
Definition: hitinfo.h:42
bool CDUMMYBLOCK::IntersectP ( const RAY aRay,
float  aMaxDistance 
) const
overridevirtual

Functions Intersect for shadow test.

Intersect

Parameters
aRay
aDistance- max distance of the test
Returns
TRUE if the aRay intersects the object

Implements COBJECT.

Definition at line 69 of file cdummyblock.cpp.

References CBBOX::Intersect(), and COBJECT::m_bbox.

70 {
71  float t;
72 
73  if( !m_bbox.Intersect( aRay, &t ) )
74  return false;
75 
76  if( t < aMaxDistance )
77  return true;
78 
79  return false;
80 }
CBBOX m_bbox
Definition: cobject.h:53
bool Intersect(const RAY &aRay, float *t) const
Function Intersect.
Definition: cbbox_ray.cpp:46
bool CDUMMYBLOCK::Intersects ( const CBBOX aBBox) const
overridevirtual

Function Intersects.

Intersects - a.Intersects(b) ⇔ !a.Disjoint(b) ⇔ !(a ∩ b = ∅) It intersects if the result intersection is not null

Parameters
aBBox
Returns

Implements COBJECT.

Definition at line 83 of file cdummyblock.cpp.

References CBBOX::Intersects(), and COBJECT::m_bbox.

84 {
85  return m_bbox.Intersects( aBBox );
86 }
bool Intersects(const CBBOX &aBBox) const
Function Intersects test if a bounding box intersects this box.
Definition: cbbox.cpp:230
CBBOX m_bbox
Definition: cobject.h:53
void CDUMMYBLOCK::SetColor ( SFVEC3F  aObjColor)
inline

Definition at line 45 of file cdummyblock.h.

References m_diffusecolor.

45 { m_diffusecolor = aObjColor; }
SFVEC3F m_diffusecolor
Definition: cdummyblock.h:53
void COBJECT::SetMaterial ( const CMATERIAL aMaterial)
inlineinherited

Member Data Documentation

SFVEC3F CDUMMYBLOCK::m_diffusecolor
private

Definition at line 53 of file cdummyblock.h.

Referenced by GetDiffuseColor(), and SetColor().

OBJECT3D_TYPE COBJECT::m_obj_type
protectedinherited

Definition at line 55 of file cobject.h.

Referenced by COBJECT::COBJECT().


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