3D Viewer: more code cleaning and naming improvements.

This commit is contained in:
Wayne Stambaugh 2021-01-07 14:33:43 -05:00
parent a342bb9ab3
commit 926cc3a00d
38 changed files with 747 additions and 903 deletions

View File

@ -51,7 +51,7 @@ const wxChar *BOARD_ADAPTER::m_logTrace = wxT( "KI_TRACE_EDA_CINFO3D_VISU" );
BOARD_ADAPTER::BOARD_ADAPTER() :
m_board( nullptr ),
m_3d_model_manager( nullptr ),
m_3dModelManager( nullptr ),
m_colors( nullptr ),
m_layerZcoordTop(),
m_layerZcoordBottom()
@ -91,9 +91,6 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
m_averageHoleDiameter = 0.0f;
m_averageTrackWidth = 0.0f;
m_calc_seg_min_factor3DU = 0.0f;
m_calc_seg_max_factor3DU = 0.0f;
SetFlag( FL_USE_REALISTIC_MODE, true );
SetFlag( FL_FP_ATTRIBUTES_NORMAL, true );
SetFlag( FL_SHOW_BOARD_BODY, true );
@ -131,16 +128,16 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
m_backPlatedPadPolys = nullptr;
// Avoid raytracing options not initialized:
m_raytrace_nrsamples_shadows = 0;
m_raytrace_nrsamples_reflections = 0;
m_raytrace_nrsamples_refractions = 0;
m_RtShadowSampleCount = 0;
m_RtReflectionSampleCount = 0;
m_RtRefractionSampleCount = 0;
m_raytrace_spread_shadows = 0.0;
m_raytrace_spread_reflections = 0.0;
m_raytrace_spread_refractions = 0.0;
m_RtSpreadShadows = 0.0;
m_RtSpreadReflections = 0.0;
m_RtSpreadRefractions = 0.0;
m_raytrace_recursivelevel_reflections = 0;
m_raytrace_recursivelevel_refractions = 0;
m_RtRecursiveReflectionCount = 0;
m_RtRecursiveRefractionCount = 0;
}

View File

@ -78,7 +78,7 @@ public:
*/
void Set3dCacheManager( S3D_CACHE* aCachePointer ) noexcept
{
m_3d_model_manager = aCachePointer;
m_3dModelManager = aCachePointer;
}
/**
@ -86,7 +86,7 @@ public:
*/
S3D_CACHE* Get3dCacheManager() const noexcept
{
return m_3d_model_manager;
return m_3dModelManager;
}
/**
@ -616,32 +616,30 @@ public:
SFVEC4F m_SilkScreenColorTop; ///< in realistic mode: SilkScreen color ( top )
SFVEC4F m_CopperColor; ///< in realistic mode: copper color
SFVEC3F m_opengl_selectionColor;
SFVEC3F m_OpenGlSelectionColor;
// Raytracing light colors
SFVEC3F m_RtCameraLightColor;
SFVEC3F m_RtLightColorTop;
SFVEC3F m_RtLightColorBottom;
SFVEC3F m_raytrace_lightColorCamera;
SFVEC3F m_raytrace_lightColorTop;
SFVEC3F m_raytrace_lightColorBottom;
std::vector<SFVEC3F> m_raytrace_lightColor;
std::vector<SFVEC2F> m_raytrace_lightSphericalCoords;
std::vector<SFVEC3F> m_RtLightColor;
std::vector<SFVEC2F> m_RtLightSphericalCoords;
// Raytracing options
int m_raytrace_nrsamples_shadows;
int m_raytrace_nrsamples_reflections;
int m_raytrace_nrsamples_refractions;
int m_RtShadowSampleCount;
int m_RtReflectionSampleCount;
int m_RtRefractionSampleCount;
int m_RtRecursiveReflectionCount;
int m_RtRecursiveRefractionCount;
float m_raytrace_spread_shadows;
float m_raytrace_spread_reflections;
float m_raytrace_spread_refractions;
int m_raytrace_recursivelevel_reflections;
int m_raytrace_recursivelevel_refractions;
float m_RtSpreadShadows;
float m_RtSpreadReflections;
float m_RtSpreadRefractions;
private:
BOARD* m_board;
S3D_CACHE* m_3d_model_manager;
S3D_CACHE* m_3dModelManager;
COLOR_SETTINGS* m_colors;
std::vector< bool > m_drawFlags;
@ -692,58 +690,46 @@ private:
///< The holes per each layer.
MAP_CONTAINER_2D_BASE m_layerHoleMap;
/// It contains the list of throughHoles of the board,
/// the radius of the hole is inflated with the copper thickness
///< List of through holes with the radius of the hole inflated with the copper thickness.
BVH_CONTAINER_2D m_throughHoleOds;
/// It contains the list of throughHoles of the board,
/// the radius of the hole is inflated with the annular ring size
///< List of plated through hole annular rings.
BVH_CONTAINER_2D m_throughHoleAnnularRings;
/// It contains the list of throughHoles of the board,
/// the radius is the inner hole
///< List of through hole inner diameters.
BVH_CONTAINER_2D m_throughHoleIds;
/// It contains the list of throughHoles vias of the board,
/// the radius of the hole is inflated with the copper thickness
///< List of through hole vias with the radius of the hole inflated with the copper thickness.
BVH_CONTAINER_2D m_throughHoleViaOds;
/// It contains the list of throughHoles vias of the board,
/// the radius of the hole
///< List of through hole via inner diameters.
BVH_CONTAINER_2D m_throughHoleViaIds;
/// Number of copper layers actually used by the board
///< Number of copper layers actually used by the board.
unsigned int m_copperLayersCount;
/// Normalization scale to convert board internal units to 3D units to
/// normalize 3D units between -1.0 and +1.0
///< Scale factor to convert board internal units to 3D units normalized between -1.0 and 1.0.
double m_biuTo3Dunits;
/// Top (End) Z position of each layer (normalized)
///< Top (End) Z position of each layer in 3D units.
std::array<float, PCB_LAYER_ID_COUNT> m_layerZcoordTop;
/// Bottom (Start) Z position of each layer (normalized)
///< Bottom (Start) Z position of each layer in 3D units.
std::array<float, PCB_LAYER_ID_COUNT> m_layerZcoordBottom;
/// Copper thickness (normalized)
///< Copper thickness in 3D units.
float m_copperThickness3DU;
/// Epoxy thickness (normalized)
///< Epoxy thickness in 3D units.
float m_epoxyThickness3DU;
/// Non copper layers thickness
///< Non copper layers thickness in 3D units.
float m_nonCopperLayerThickness3DU;
/// min factor used for circle segment approximation calculation
float m_calc_seg_min_factor3DU;
/// max factor used for circle segment approximation calculation
float m_calc_seg_max_factor3DU;
///< Number of tracks in the board.
unsigned int m_trackCount;
/// Track average width
///< Track average width.
float m_averageTrackWidth;
///< Number of through hole vias in the board.
@ -755,7 +741,7 @@ private:
///< Number of holes in the board.
unsigned int m_holeCount;
/// Computed average diameter of the holes in 3D units.
///< Computed average diameter of the holes in 3D units.
float m_averageHoleDiameter;
/**

View File

@ -291,7 +291,7 @@ bool EDA_3D_CANVAS::initializeOpenGL()
void EDA_3D_CANVAS::GetScreenshot( wxImage& aDstImage )
{
OGL_GetScreenshot( aDstImage );
OglGetScreenshot( aDstImage );
}
@ -318,7 +318,6 @@ void EDA_3D_CANVAS::RenderRaytracingRequest()
m_3d_render->ReloadRequest();
m_render_raytracing_was_requested = true;
//m_mouse_was_moved = true;
Request_refresh();
}
@ -341,10 +340,7 @@ void EDA_3D_CANVAS::DisplayStatus()
void EDA_3D_CANVAS::OnPaint( wxPaintEvent& aEvent )
{
// Please have a look at:
// https://lists.launchpad.net/kicad-developers/msg25149.html
// wxPaintDC( this );
// aEvent.Skip( false );
// Please have a look at: https://lists.launchpad.net/kicad-developers/msg25149.html
DoRePaint();
}
@ -374,7 +370,6 @@ void EDA_3D_CANVAS::DoRePaint()
wxString err_messages;
// !TODO: implement error reporter
//WX_STRING_REPORTER errorReporter( &err_messages );
INFOBAR_REPORTER warningReporter( m_parentInfoBar );
STATUSBAR_REPORTER activityReporter( m_parentStatusBar,
(int) EDA_3D_VIEWER_STATUSBAR::STATUS_TEXT );
@ -1080,6 +1075,7 @@ bool EDA_3D_CANVAS::SetView3D( int aKeycode )
m_camera.SetT0_and_T1_current_T();
m_camera.Reset_T1();
m_camera.RotateX_T1( glm::radians( -90.0f ) );
// The rotation angle should be 180.
// We use 179.999 (180 - epsilon) to avoid a full 360 deg rotation when
// using 180 deg if the previous rotated position was already 180 deg

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2016-2002 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,7 @@
/**
* @file PerlinNoise.h
* @brief This source code comes from the project:
* https://github.com/sol-prog/Perlin_Noise
* @brief This source code comes from the project: https://github.com/sol-prog/Perlin_Noise
*
* It was changed to work with floats instead of doubles
*
@ -126,20 +125,12 @@ float PerlinNoise::noise( float x, float y, float z ) const
const int BB = p[B + 1] + Z;
// Add blended results from 8 corners of cube
const float res = lerp( w,
lerp( v,
lerp( u,
grad( p[AA], x , y, z),
grad( p[BA], x - 1, y, z) ),
lerp( u,
grad( p[AB], x , y - 1, z ),
grad( p[BB], x - 1, y - 1, z) ) ),
lerp( v,
lerp( u,
grad( p[AA + 1], x , y, z - 1 ),
grad( p[BA + 1], x - 1, y, z - 1) ),
lerp( u,
grad( p[AB + 1], x , y - 1, z - 1 ),
const float res = lerp(
w,
lerp( v, lerp( u, grad( p[AA], x, y, z ), grad( p[BA], x - 1, y, z ) ),
lerp( u, grad( p[AB], x, y - 1, z ), grad( p[BB], x - 1, y - 1, z ) ) ),
lerp( v, lerp( u, grad( p[AA + 1], x, y, z - 1 ), grad( p[BA + 1], x - 1, y, z - 1 ) ),
lerp( u, grad( p[AB + 1], x, y - 1, z - 1 ),
grad( p[BB + 1], x - 1, y - 1, z - 1 ) ) ) );
return (res + 1.0f) / 2.0f;
@ -169,27 +160,22 @@ float PerlinNoise::noise( float x, float y ) const
const int BB = p[B + 1] + 0;
// Add blended results from 8 corners of cube
const float res = lerp( v,
lerp( u,
grad( p[AA], x , y ),
grad( p[BA], x - 1, y ) ),
lerp( u,
grad( p[AB], x , y - 1 ),
grad( p[BB], x - 1, y - 1 ) ) );
const float res = lerp( v, lerp( u, grad( p[AA], x, y ), grad( p[BA], x - 1, y ) ),
lerp( u, grad( p[AB], x, y - 1 ), grad( p[BB], x - 1, y - 1 ) ) );
return (res + 1.0f) / 2.0f;
return ( res + 1.0f ) / 2.0f;
}
float PerlinNoise::fade( float t ) const
{
return t * t * t * (t * (t * 6.0f - 15.0f) + 10.0f);
return t * t * t * ( t * ( t * 6.0f - 15.0f ) + 10.0f );
}
float PerlinNoise::lerp( float t, float a, float b ) const
{
return a + t * (b - a);
return a + t * ( b - a );
}
@ -201,7 +187,7 @@ float PerlinNoise::grad( int hash, float x, float y, float z ) const
const float u = h < 8 ? x : y;
const float v = h < 4 ? y : h == 12 || h == 14 ? x : z;
return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v);
return ( ( h & 1 ) == 0 ? u : -u ) + ( ( h & 2 ) == 0 ? v : -v );
}
@ -213,5 +199,5 @@ float PerlinNoise::grad( int hash, float x, float y ) const
const float u = h < 8 ? x : y;
const float v = h < 4 ? y : h == 12 || h == 14 ? x : 0.0f;
return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v);
return ( ( h & 1 ) == 0 ? u : -u ) + ( ( h & 2 ) == 0 ? v : -v );
}

View File

@ -98,7 +98,7 @@ bool BVH_PBRT::Intersect( const RAYPACKET& aRayPacket, HITINFO_PACKET* aHitInfoP
if( &m_nodes[0] == nullptr )
return false;
bool anyHitted = false;
bool anyHit = false;
int todoOffset = 0, nodeNum = 0;
StackNode todo[MAX_TODOS];
@ -133,13 +133,13 @@ bool BVH_PBRT::Intersect( const RAYPACKET& aRayPacket, HITINFO_PACKET* aHitInfoP
{
for( unsigned int i = ia; i < ie; ++i )
{
const bool hitted = obj->Intersect( aRayPacket.m_ray[i],
const bool hit = obj->Intersect( aRayPacket.m_ray[i],
aHitInfoPacket[i].m_HitInfo );
if( hitted )
if( hit )
{
anyHitted |= hitted;
aHitInfoPacket[i].m_hitresult |= hitted;
anyHit |= hit;
aHitInfoPacket[i].m_hitresult |= hit;
aHitInfoPacket[i].m_HitInfo.m_acc_node_info = nodeNum;
}
}
@ -157,9 +157,9 @@ bool BVH_PBRT::Intersect( const RAYPACKET& aRayPacket, HITINFO_PACKET* aHitInfoP
ia = node.ia;
}
return anyHitted;
return anyHit;
}// Ranged Traversal
}
#endif
@ -210,7 +210,7 @@ static inline unsigned int partRays( const RAYPACKET& aRayPacket, const BBOX_3D&
bool BVH_PBRT::Intersect( const RAYPACKET& aRayPacket, HITINFO_PACKET* aHitInfoPacket ) const
{
bool anyHitted = false;
bool anyHit = false;
int todoOffset = 0, nodeNum = 0;
StackNode todo[MAX_TODOS];
@ -238,7 +238,7 @@ bool BVH_PBRT::Intersect( const RAYPACKET& aRayPacket, HITINFO_PACKET* aHitInfoP
}
else
{
unsigned int ie = geetLastHit( aRayPacket, curCell->bounds, ia, I,
unsigned int ie = getLastHit( aRayPacket, curCell->bounds, ia, I,
aHitInfoPacket );
for( int j = 0; j < curCell->nPrimitives; ++j )
@ -251,13 +251,13 @@ bool BVH_PBRT::Intersect( const RAYPACKET& aRayPacket, HITINFO_PACKET* aHitInfoP
{
unsigned int idx = I[i];
bool hitted = obj->Intersect( aRayPacket.m_ray[idx],
bool hit = obj->Intersect( aRayPacket.m_ray[idx],
aHitInfoPacket[idx].m_HitInfo );
if( hitted )
if( hit )
{
anyHitted |= hitted;
aHitInfoPacket[idx].m_hitresult |= hitted;
anyHit |= hit;
aHitInfoPacket[idx].m_hitresult |= hit;
aHitInfoPacket[idx].m_HitInfo.m_acc_node_info = nodeNum;
}
}
@ -275,6 +275,6 @@ bool BVH_PBRT::Intersect( const RAYPACKET& aRayPacket, HITINFO_PACKET* aHitInfoP
ia = node.ia;
}
return anyHitted;
}// Partition Traversal
return anyHit;
}
#endif

View File

@ -149,16 +149,16 @@ inline uint32_t LeftShift3( uint32_t x )
{
wxASSERT( x <= (1 << 10) );
if( x == (1 << 10) )
if( x == ( 1 << 10 ) )
--x;
x = (x | (x << 16)) & 0b00000011000000000000000011111111;
x = ( x | ( x << 16 ) ) & 0b00000011000000000000000011111111;
// x = ---- --98 ---- ---- ---- ---- 7654 3210
x = (x | (x << 8)) & 0b00000011000000001111000000001111;
x = ( x | ( x << 8 ) ) & 0b00000011000000001111000000001111;
// x = ---- --98 ---- ---- 7654 ---- ---- 3210
x = (x | (x << 4)) & 0b00000011000011000011000011000011;
x = ( x | ( x << 4 ) ) & 0b00000011000011000011000011000011;
// x = ---- --98 ---- 76-- --54 ---- 32-- --10
x = (x | (x << 2)) & 0b00001001001001001001001001001001;
x = ( x | ( x << 2 ) ) & 0b00001001001001001001001001001001;
// x = ---- 9--8 --7- -6-- 5--4 --3- -2-- 1--0
return x;
@ -182,7 +182,7 @@ static void RadixSort( std::vector<MortonPrimitive>* v )
const int bitsPerPass = 6;
const int nBits = 30;
wxASSERT( (nBits % bitsPerPass) == 0 );
wxASSERT( ( nBits % bitsPerPass ) == 0 );
const int nPasses = nBits / bitsPerPass;
@ -198,7 +198,7 @@ static void RadixSort( std::vector<MortonPrimitive>* v )
// Count number of zero bits in array for current radix sort bit
const int nBuckets = 1 << bitsPerPass;
int bucketCount[nBuckets] = {0};
const int bitMask = (1 << bitsPerPass) - 1;
const int bitMask = ( 1 << bitsPerPass ) - 1;
for( uint32_t i = 0; i < in.size(); ++i )
{
@ -285,7 +285,7 @@ BVH_PBRT::BVH_PBRT( const CONTAINER_3D_BASE& aObjectContainer, int aMaxPrimsInNo
// Compute representation of depth-first traversal of BVH tree
m_nodes = static_cast<LinearBVHNode*>( malloc( sizeof( LinearBVHNode ) * totalNodes ) );
m_addresses_pointer_to_mm_free.push_back( m_nodes );
m_nodesToFree.push_back( m_nodes );
for( int i = 0; i < totalNodes; ++i )
{
@ -305,10 +305,9 @@ BVH_PBRT::BVH_PBRT( const CONTAINER_3D_BASE& aObjectContainer, int aMaxPrimsInNo
BVH_PBRT::~BVH_PBRT()
{
if( !m_addresses_pointer_to_mm_free.empty() )
if( !m_nodesToFree.empty() )
{
for( std::list<void *>::iterator ii = m_addresses_pointer_to_mm_free.begin();
ii != m_addresses_pointer_to_mm_free.end();
for( std::list<void *>::iterator ii = m_nodesToFree.begin(); ii != m_nodesToFree.end();
++ii )
{
free( *ii );
@ -316,7 +315,7 @@ BVH_PBRT::~BVH_PBRT()
}
}
m_addresses_pointer_to_mm_free.clear();
m_nodesToFree.clear();
}
@ -440,7 +439,7 @@ BVHBuildNode *BVH_PBRT::recursiveBuild ( std::vector<BVHPrimitiveInfo>& primitiv
// !TODO: implement an memory Arena
BVHBuildNode *node = static_cast<BVHBuildNode *>( malloc( sizeof( BVHBuildNode ) ) );
m_addresses_pointer_to_mm_free.push_back( node );
m_nodesToFree.push_back( node );
node->bounds.Reset();
node->firstPrimOffset = 0;
@ -524,7 +523,7 @@ BVHBuildNode *BVH_PBRT::recursiveBuild ( std::vector<BVHPrimitiveInfo>& primitiv
wxASSERT( ( mid >= start ) && ( mid <= end ) );
if( (mid != start) && (mid != end) )
if( ( mid != start ) && ( mid != end ) )
break;
}
@ -535,7 +534,7 @@ BVHBuildNode *BVH_PBRT::recursiveBuild ( std::vector<BVHPrimitiveInfo>& primitiv
case SPLITMETHOD::EQUALCOUNTS:
{
// Partition primitives into equally-sized subsets
mid = (start + end) / 2;
mid = ( start + end ) / 2;
std::nth_element( &primitiveInfo[start], &primitiveInfo[mid],
&primitiveInfo[end - 1] + 1, ComparePoints( dim ) );
@ -550,7 +549,7 @@ BVHBuildNode *BVH_PBRT::recursiveBuild ( std::vector<BVHPrimitiveInfo>& primitiv
if( nPrimitives <= 2 )
{
// Partition primitives into equally-sized subsets
mid = (start + end) / 2;
mid = ( start + end ) / 2;
std::nth_element( &primitiveInfo[start], &primitiveInfo[mid],
&primitiveInfo[end - 1] + 1, ComparePoints( dim ) );
@ -622,7 +621,7 @@ BVHBuildNode *BVH_PBRT::recursiveBuild ( std::vector<BVHPrimitiveInfo>& primitiv
float minCost = cost[0];
int minCostSplitBucket = 0;
for( int i = 1; i < (nBuckets - 1); ++i )
for( int i = 1; i < ( nBuckets - 1 ); ++i )
{
if( cost[i] < minCost )
{
@ -732,7 +731,7 @@ BVHBuildNode *BVH_PBRT::HLBVHBuild( const std::vector<BVHPrimitiveInfo>& primiti
BVHBuildNode *nodes = static_cast<BVHBuildNode *>( malloc( maxBVHNodes *
sizeof( BVHBuildNode ) ) );
m_addresses_pointer_to_mm_free.push_back( nodes );
m_nodesToFree.push_back( nodes );
for( int i = 0; i < maxBVHNodes; ++i )
{
@ -851,7 +850,7 @@ BVHBuildNode *BVH_PBRT::emitLBVH( BVHBuildNode* &buildNodes,
{
wxASSERT(searchStart != searchEnd);
const int mid = (searchStart + searchEnd) / 2;
const int mid = ( searchStart + searchEnd ) / 2;
if( ( mortonPrims[searchStart].mortonCode & mask ) ==
( mortonPrims[mid].mortonCode & mask ) )
@ -866,9 +865,9 @@ BVHBuildNode *BVH_PBRT::emitLBVH( BVHBuildNode* &buildNodes,
const int splitOffset = searchEnd;
wxASSERT( splitOffset <= (nPrimitives - 1) );
wxASSERT( (mortonPrims[splitOffset - 1].mortonCode & mask) !=
(mortonPrims[splitOffset].mortonCode & mask) );
wxASSERT( splitOffset <= ( nPrimitives - 1 ) );
wxASSERT( ( mortonPrims[splitOffset - 1].mortonCode & mask )
!= ( mortonPrims[splitOffset].mortonCode & mask ) );
// Create and return interior LBVH node
(*totalNodes)++;
@ -908,7 +907,7 @@ BVHBuildNode *BVH_PBRT::buildUpperSAH( std::vector<BVHBuildNode*>& treeletRoots,
BVHBuildNode* node = static_cast<BVHBuildNode*>( malloc( sizeof( BVHBuildNode ) ) );
m_addresses_pointer_to_mm_free.push_back( node );
m_nodesToFree.push_back( node );
node->bounds.Reset();
node->firstPrimOffset = 0;

View File

@ -144,7 +144,7 @@ private:
CONST_VECTOR_OBJECT m_primitives;
LinearBVHNode* m_nodes;
std::list<void*> m_addresses_pointer_to_mm_free;
std::list<void*> m_nodesToFree;
// Partition traversal
unsigned int m_I[RAYPACKET_RAYS_PER_PACKET];

View File

@ -83,8 +83,8 @@ BVH_CONTAINER_2D::BVH_CONTAINER_2D() : CONTAINER_2D_BASE( OBJECT_2D_TYPE::BVHCON
{
m_isInitialized = false;
m_bbox.Reset();
m_elements_to_delete.clear();
m_Tree = nullptr;
m_elementsToDelete.clear();
m_tree = nullptr;
}
@ -97,15 +97,15 @@ void BVH_CONTAINER_2D::Clear()
void BVH_CONTAINER_2D::destroy()
{
for( std::list<BVH_CONTAINER_NODE_2D*>::iterator ii = m_elements_to_delete.begin();
ii != m_elements_to_delete.end();
for( std::list<BVH_CONTAINER_NODE_2D*>::iterator ii = m_elementsToDelete.begin();
ii != m_elementsToDelete.end();
++ii )
{
delete *ii;
}
m_elements_to_delete.clear();
m_Tree = nullptr;
m_elementsToDelete.clear();
m_tree = nullptr;
m_isInitialized = false;
}
@ -131,17 +131,17 @@ void BVH_CONTAINER_2D::BuildBVH()
return;
}
m_Tree = new BVH_CONTAINER_NODE_2D;
m_tree = new BVH_CONTAINER_NODE_2D;
m_elements_to_delete.push_back( m_Tree );
m_Tree->m_BBox = m_bbox;
m_elementsToDelete.push_back( m_tree );
m_tree->m_BBox = m_bbox;
for( LIST_OBJECT2D::const_iterator ii = m_objects.begin(); ii != m_objects.end(); ++ii )
{
m_Tree->m_LeafList.push_back( static_cast<const OBJECT_2D*>( *ii ) );
m_tree->m_LeafList.push_back( static_cast<const OBJECT_2D*>( *ii ) );
}
recursiveBuild_MIDDLE_SPLIT( m_Tree );
recursiveBuild_MIDDLE_SPLIT( m_tree );
}
@ -152,19 +152,19 @@ void BVH_CONTAINER_2D::BuildBVH()
// "Split in the middle of the longest Axis"
// "Creates a binary tree with Top-Down approach.
// Fastest BVH building, but least [speed] accuracy."
static bool sortByCentroid_X( const OBJECT_2D* a, const OBJECT_2D* b )
static bool sortByCentroidX( const OBJECT_2D* a, const OBJECT_2D* b )
{
return a->GetCentroid()[0] < b->GetCentroid()[0];
}
static bool sortByCentroid_Y( const OBJECT_2D* a, const OBJECT_2D* b )
static bool sortByCentroidY( const OBJECT_2D* a, const OBJECT_2D* b )
{
return a->GetCentroid()[0] < b->GetCentroid()[0];
}
static bool sortByCentroid_Z( const OBJECT_2D* a, const OBJECT_2D* b )
static bool sortByCentroidZ( const OBJECT_2D* a, const OBJECT_2D* b )
{
return a->GetCentroid()[0] < b->GetCentroid()[0];
}
@ -181,8 +181,8 @@ void BVH_CONTAINER_2D::recursiveBuild_MIDDLE_SPLIT( BVH_CONTAINER_NODE_2D* aNode
// Create Leaf Nodes
BVH_CONTAINER_NODE_2D* leftNode = new BVH_CONTAINER_NODE_2D;
BVH_CONTAINER_NODE_2D* rightNode = new BVH_CONTAINER_NODE_2D;
m_elements_to_delete.push_back( leftNode );
m_elements_to_delete.push_back( rightNode );
m_elementsToDelete.push_back( leftNode );
m_elementsToDelete.push_back( rightNode );
leftNode->m_BBox.Reset();
rightNode->m_BBox.Reset();
@ -195,9 +195,9 @@ void BVH_CONTAINER_2D::recursiveBuild_MIDDLE_SPLIT( BVH_CONTAINER_NODE_2D* aNode
// Divide the objects
switch( axis_to_split )
{
case 0: aNodeParent->m_LeafList.sort( sortByCentroid_X ); break;
case 1: aNodeParent->m_LeafList.sort( sortByCentroid_Y ); break;
case 2: aNodeParent->m_LeafList.sort( sortByCentroid_Z ); break;
case 0: aNodeParent->m_LeafList.sort( sortByCentroidX ); break;
case 1: aNodeParent->m_LeafList.sort( sortByCentroidY ); break;
case 2: aNodeParent->m_LeafList.sort( sortByCentroidZ ); break;
}
unsigned int i = 0;
@ -252,8 +252,8 @@ bool BVH_CONTAINER_2D::IntersectAny( const RAYSEG2D& aSegRay ) const
{
wxASSERT( m_isInitialized == true );
if( m_Tree )
return recursiveIntersectAny( m_Tree, aSegRay );
if( m_tree )
return recursiveIntersectAny( m_tree, aSegRay );
return false;
}
@ -289,6 +289,7 @@ bool BVH_CONTAINER_2D::recursiveIntersectAny( const BVH_CONTAINER_NODE_2D* aNode
// Node
if( recursiveIntersectAny( aNode->m_Children[0], aSegRay ) )
return true;
if( recursiveIntersectAny( aNode->m_Children[1], aSegRay ) )
return true;
}
@ -306,8 +307,8 @@ void BVH_CONTAINER_2D::GetListObjectsIntersects( const BBOX_2D& aBBox,
aOutList.clear();
if( m_Tree )
recursiveGetListObjectsIntersects( m_Tree, aBBox, aOutList );
if( m_tree )
recursiveGetListObjectsIntersects( m_tree, aBBox, aOutList );
}

View File

@ -138,8 +138,8 @@ private:
const RAYSEG2D& aSegRay ) const;
bool m_isInitialized;
std::list<BVH_CONTAINER_NODE_2D*> m_elements_to_delete;
BVH_CONTAINER_NODE_2D* m_Tree;
std::list<BVH_CONTAINER_NODE_2D*> m_elementsToDelete;
BVH_CONTAINER_NODE_2D* m_tree;
};

View File

@ -71,7 +71,7 @@ void CONTAINER_3D_BASE::ConvertTo( CONST_VECTOR_OBJECT &aOutVector ) const
{
wxASSERT( (*ii) != nullptr );
aOutVector[i++] = static_cast<const OBJECT_3D *>(*ii);
aOutVector[i++] = static_cast<const OBJECT_3D*>( *ii );
}
}
}

View File

@ -75,32 +75,31 @@ static float TransparencyControl( float aGrayColorValue, float aTransparency )
void RENDER_3D_RAYTRACE::setupMaterials()
{
MATERIAL::SetDefaultNrRefractionsSamples( m_boardAdapter.m_raytrace_nrsamples_refractions );
MATERIAL::SetDefaultNrReflectionsSamples( m_boardAdapter.m_raytrace_nrsamples_reflections );
MATERIAL::SetDefaultRefractionRayCount( m_boardAdapter.m_RtRefractionSampleCount );
MATERIAL::SetDefaultReflectionRayCount( m_boardAdapter.m_RtReflectionSampleCount );
MATERIAL::SetDefaultRefractionsLevel( m_boardAdapter.m_raytrace_recursivelevel_refractions );
MATERIAL::SetDefaultReflectionsLevel( m_boardAdapter.m_raytrace_recursivelevel_reflections );
MATERIAL::SetDefaultRefractionRecursionCount( m_boardAdapter.m_RtRecursiveRefractionCount );
MATERIAL::SetDefaultReflectionRecursionCount( m_boardAdapter.m_RtRecursiveReflectionCount );
double mmTo3Dunits = IU_PER_MM * m_boardAdapter.BiuTo3dUnits();
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) )
{
m_board_normal_perturbator = BOARD_NORMAL( 0.40f * mmTo3Dunits );
m_boardMaterial = BOARD_NORMAL( 0.40f * mmTo3Dunits );
m_copper_normal_perturbator =
COPPER_NORMAL( 4.0f * mmTo3Dunits, &m_board_normal_perturbator );
m_copperMaterial = COPPER_NORMAL( 4.0f * mmTo3Dunits, &m_boardMaterial );
m_platedcopper_normal_perturbator = PLATED_COPPER_NORMAL( 0.5f * mmTo3Dunits );
m_platedCopperMaterial = PLATED_COPPER_NORMAL( 0.5f * mmTo3Dunits );
m_solder_mask_normal_perturbator = SOLDER_MASK_NORMAL( &m_board_normal_perturbator );
m_solderMaskMaterial = SOLDER_MASK_NORMAL( &m_boardMaterial );
m_plastic_normal_perturbator = PLASTIC_NORMAL( 0.05f * mmTo3Dunits );
m_plasticMaterial = PLASTIC_NORMAL( 0.05f * mmTo3Dunits );
m_plastic_shine_normal_perturbator = PLASTIC_SHINE_NORMAL( 0.1f * mmTo3Dunits );
m_shinyPlasticMaterial = PLASTIC_SHINE_NORMAL( 0.1f * mmTo3Dunits );
m_brushed_metal_normal_perturbator = BRUSHED_METAL_NORMAL( 0.05f * mmTo3Dunits );
m_brushedMetalMaterial = BRUSHED_METAL_NORMAL( 0.05f * mmTo3Dunits );
m_silkscreen_normal_perturbator = SILK_SCREEN_NORMAL( 0.25f * mmTo3Dunits );
m_silkScreenMaterial = SILK_SCREEN_NORMAL( 0.25f * mmTo3Dunits );
}
// http://devernay.free.fr/cours/opengl/materials.html
@ -114,14 +113,14 @@ void RENDER_3D_RAYTRACE::setupMaterials()
SFVEC3F( 0.0f ), copperSpecularLinear, 0.4f * 128.0f, 0.0f, 0.0f );
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) )
m_materials.m_Copper.SetNormalPerturbator( &m_platedcopper_normal_perturbator );
m_materials.m_Copper.SetGenerator( &m_platedCopperMaterial );
m_materials.m_NonPlatedCopper = BLINN_PHONG_MATERIAL(
ConvertSRGBToLinear( SFVEC3F( 0.191f, 0.073f, 0.022f ) ), SFVEC3F( 0.0f, 0.0f, 0.0f ),
SFVEC3F( 0.256f, 0.137f, 0.086f ), 0.15f * 128.0f, 0.0f, 0.0f );
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) )
m_materials.m_NonPlatedCopper.SetNormalPerturbator( &m_copper_normal_perturbator );
m_materials.m_NonPlatedCopper.SetGenerator( &m_copperMaterial );
m_materials.m_Paste = BLINN_PHONG_MATERIAL(
ConvertSRGBToLinear( (SFVEC3F) m_boardAdapter.m_SolderPasteColor )
@ -139,7 +138,7 @@ void RENDER_3D_RAYTRACE::setupMaterials()
SFVEC3F( 0.0f ), SFVEC3F( 0.10f ) ), 0.078125f * 128.0f, 0.0f, 0.0f );
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) )
m_materials.m_SilkS.SetNormalPerturbator( &m_silkscreen_normal_perturbator );
m_materials.m_SilkS.SetGenerator( &m_silkScreenMaterial );
// Assume that SolderMaskTop == SolderMaskBot
const float solderMask_gray =
@ -157,10 +156,10 @@ void RENDER_3D_RAYTRACE::setupMaterials()
solderMask_transparency, 0.16f );
m_materials.m_SolderMask.SetCastShadows( true );
m_materials.m_SolderMask.SetNrRefractionsSamples( 1 );
m_materials.m_SolderMask.SetRefractionRayCount( 1 );
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) )
m_materials.m_SolderMask.SetNormalPerturbator( &m_solder_mask_normal_perturbator );
m_materials.m_SolderMask.SetGenerator( &m_solderMaskMaterial );
m_materials.m_EpoxyBoard =
BLINN_PHONG_MATERIAL( ConvertSRGBToLinear( SFVEC3F( 16.0f / 255.0f, 14.0f / 255.0f,
@ -173,7 +172,7 @@ void RENDER_3D_RAYTRACE::setupMaterials()
m_materials.m_EpoxyBoard.SetAbsorvance( 10.0f );
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) )
m_materials.m_EpoxyBoard.SetNormalPerturbator( &m_board_normal_perturbator );
m_materials.m_EpoxyBoard.SetGenerator( &m_boardMaterial );
SFVEC3F bgTop = ConvertSRGBToLinear( (SFVEC3F) m_boardAdapter.m_BgColorTop );
@ -181,20 +180,20 @@ void RENDER_3D_RAYTRACE::setupMaterials()
( SFVEC3F( 1.0f ) - bgTop ) / 3.0f,
0.10f * 128.0f, 0.0f, 0.50f );
m_materials.m_Floor.SetCastShadows( false );
m_materials.m_Floor.SetReflectionsRecursiveLevel( 1 );
m_materials.m_Floor.SetReflectionRecursionCount( 1 );
}
void RENDER_3D_RAYTRACE::create_3d_object_from( CONTAINER_3D& aDstContainer,
const OBJECT_2D* aObject2D, float aZMin, float aZMax, const MATERIAL* aMaterial,
void RENDER_3D_RAYTRACE::createObject( CONTAINER_3D& aDstContainer, const OBJECT_2D* aObject2D,
float aZMin, float aZMax, const MATERIAL* aMaterial,
const SFVEC3F& aObjColor )
{
switch( aObject2D->GetObjectType() )
{
case OBJECT_2D_TYPE::DUMMYBLOCK:
{
m_stats_converted_dummy_to_plane++;
#if 1
m_convertedDummyBlockCount++;
XY_PLANE* objPtr;
objPtr = new XY_PLANE( BBOX_3D(
SFVEC3F( aObject2D->GetBBox().Min().x, aObject2D->GetBBox().Min().y, aZMin ),
@ -209,28 +208,20 @@ void RENDER_3D_RAYTRACE::create_3d_object_from( CONTAINER_3D& aDstContainer,
objPtr->SetMaterial( aMaterial );
objPtr->SetColor( ConvertSRGBToLinear( aObjColor ) );
aDstContainer.Add( objPtr );
#else
objPtr = new DUMMY_BLOCK( BBOX_3D(
SFVEC3F( aObject2D->GetBBox().Min().x, aObject2D->GetBBox().Min().y, aZMin ),
SFVEC3F( aObject2D->GetBBox().Max().x, aObject2D->GetBBox().Max().y, aZMax ) ) );
objPtr->SetMaterial( aMaterial );
aDstContainer.Add( objPtr );
#endif
}
break;
}
case OBJECT_2D_TYPE::ROUNDSEG:
{
m_stats_converted_roundsegment2d_to_roundsegment++;
m_converted2dRoundSegmentCount++;
const ROUND_SEGMENT_2D* aRoundSeg2D = static_cast<const ROUND_SEGMENT_2D*>( aObject2D );
ROUND_SEGMENT* objPtr = new ROUND_SEGMENT( *aRoundSeg2D, aZMin, aZMax );
objPtr->SetMaterial( aMaterial );
objPtr->SetColor( ConvertSRGBToLinear( aObjColor ) );
aDstContainer.Add( objPtr );
}
break;
}
default:
{
@ -238,9 +229,9 @@ void RENDER_3D_RAYTRACE::create_3d_object_from( CONTAINER_3D& aDstContainer,
objPtr->SetMaterial( aMaterial );
objPtr->SetColor( ConvertSRGBToLinear( aObjColor ) );
aDstContainer.Add( objPtr );
}
break;
}
}
}
@ -395,7 +386,7 @@ void RENDER_3D_RAYTRACE::createItemsFromContainer( const BVH_CONTAINER_2D* aCont
m_boardAdapter.GetLayerTopZPos( aLayer_id ) + aLayerZOffset );
objPtr->SetMaterial( aMaterialLayer );
objPtr->SetColor( ConvertSRGBToLinear( aLayerColor ) );
m_object_container.Add( objPtr );
m_objectContainer.Add( objPtr );
}
else
{
@ -410,7 +401,7 @@ void RENDER_3D_RAYTRACE::createItemsFromContainer( const BVH_CONTAINER_2D* aCont
objPtr->SetMaterial( aMaterialLayer );
objPtr->SetColor( ConvertSRGBToLinear( aLayerColor ) );
m_object_container.Add( objPtr );
m_objectContainer.Add( objPtr );
}
}
}
@ -424,7 +415,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
{
m_reloadRequested = false;
m_model_materials.clear();
m_modelMaterialMap.clear();
OBJECT_2D_STATS::Instance().ResetStats();
OBJECT_3D_STATS::Instance().ResetStats();
@ -439,7 +430,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
m_camera.SetBoardLookAtPos( camera_pos );
}
m_object_container.Clear();
m_objectContainer.Clear();
m_containerWithObjectsToDelete.Clear();
setupMaterials();
@ -563,7 +554,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
objPtr->SetMaterial( &m_materials.m_EpoxyBoard );
objPtr->SetColor(
ConvertSRGBToLinear( (SFVEC3F) m_boardAdapter.m_BoardBodyColor ) );
m_object_container.Add( objPtr );
m_objectContainer.Add( objPtr );
}
else
{
@ -581,7 +572,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
objPtr->SetMaterial( &m_materials.m_EpoxyBoard );
objPtr->SetColor(
ConvertSRGBToLinear( (SFVEC3F) m_boardAdapter.m_BoardBodyColor ) );
m_object_container.Add( objPtr );
m_objectContainer.Add( objPtr );
}
}
@ -630,7 +621,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
objPtr->SetColor( ConvertSRGBToLinear(
(SFVEC3F) m_boardAdapter.m_BoardBodyColor ) );
m_object_container.Add( objPtr );
m_objectContainer.Add( objPtr );
}
break;
@ -849,15 +840,15 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
if( object2d_B == CSGITEM_EMPTY )
{
#if 0
create_3d_object_from( m_object_container, object2d_A, zLayerMin,
zLayerMax, materialLayer, layerColor );
createObject( m_objectContainer, object2d_A, zLayerMin, zLayerMax,
materialLayer, layerColor );
#else
LAYER_ITEM* objPtr = new LAYER_ITEM( object2d_A, zLayerMin, zLayerMax );
objPtr->SetMaterial( materialLayer );
objPtr->SetColor( ConvertSRGBToLinear( layerColor ) );
m_object_container.Add( objPtr );
m_objectContainer.Add( objPtr );
#endif
}
else
@ -872,13 +863,13 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
objPtr->SetMaterial( materialLayer );
objPtr->SetColor( ConvertSRGBToLinear( layerColor ) );
m_object_container.Add( objPtr );
m_objectContainer.Add( objPtr );
}
}
}
}
add_3D_vias_and_pads_to_container();
addPadsAndVias();
}
#ifdef PRINT_STATISTICS_3D_VIEWER
@ -889,7 +880,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
if( aStatusReporter )
aStatusReporter->Report( _( "Loading 3D models" ) );
load_3D_models( m_object_container, aOnlyLoadCopperAndShapes );
loadModels( m_objectContainer, aOnlyLoadCopperAndShapes );
#ifdef PRINT_STATISTICS_3D_VIEWER
unsigned stats_endLoad3DmodelsTime = GetRunningMicroSecs();
@ -906,9 +897,9 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
{
boardBBox.Scale( 3.0f );
if( m_object_container.GetList().size() > 0 )
if( m_objectContainer.GetList().size() > 0 )
{
BBOX_3D containerBBox = m_object_container.GetBBox();
BBOX_3D containerBBox = m_objectContainer.GetBBox();
containerBBox.Scale( 1.3f );
@ -934,8 +925,8 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
TRIANGLE* newTriangle1 = new TRIANGLE( v1, v2, v3 );
TRIANGLE* newTriangle2 = new TRIANGLE( v3, v4, v1 );
m_object_container.Add( newTriangle1 );
m_object_container.Add( newTriangle2 );
m_objectContainer.Add( newTriangle1 );
m_objectContainer.Add( newTriangle2 );
newTriangle1->SetMaterial( (const MATERIAL*) &m_materials.m_Floor );
newTriangle2->SetMaterial( (const MATERIAL*) &m_materials.m_Floor );
@ -954,8 +945,8 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
TRIANGLE* newTriangle3 = new TRIANGLE( v7, v6, v5 );
TRIANGLE* newTriangle4 = new TRIANGLE( v5, v8, v7 );
m_object_container.Add( newTriangle3 );
m_object_container.Add( newTriangle4 );
m_objectContainer.Add( newTriangle3 );
m_objectContainer.Add( newTriangle4 );
newTriangle3->SetMaterial( (const MATERIAL*) &m_materials.m_Floor );
newTriangle4->SetMaterial( (const MATERIAL*) &m_materials.m_Floor );
@ -976,37 +967,37 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
&& ( aSource.b < ( 1.0f / 255.0f ) ) );
};
m_camera_light = new DIRECTIONAL_LIGHT( SFVEC3F( 0.0f, 0.0f, 0.0f ),
m_boardAdapter.m_raytrace_lightColorCamera );
m_camera_light->SetCastShadows( false );
m_cameraLight = new DIRECTIONAL_LIGHT( SFVEC3F( 0.0f, 0.0f, 0.0f ),
m_boardAdapter.m_RtCameraLightColor );
m_cameraLight->SetCastShadows( false );
if( !IsColorZero( m_boardAdapter.m_raytrace_lightColorCamera ) )
m_lights.Add( m_camera_light );
if( !IsColorZero( m_boardAdapter.m_RtCameraLightColor ) )
m_lights.Add( m_cameraLight );
const SFVEC3F& boardCenter = m_boardAdapter.GetBBox().GetCenter();
if( !IsColorZero( m_boardAdapter.m_raytrace_lightColorTop ) )
if( !IsColorZero( m_boardAdapter.m_RtLightColorTop ) )
m_lights.Add( new POINT_LIGHT( SFVEC3F( boardCenter.x, boardCenter.y,
+RANGE_SCALE_3D * 2.0f ),
m_boardAdapter.m_raytrace_lightColorTop ) );
m_boardAdapter.m_RtLightColorTop ) );
if( !IsColorZero( m_boardAdapter.m_raytrace_lightColorBottom ) )
if( !IsColorZero( m_boardAdapter.m_RtLightColorBottom ) )
m_lights.Add( new POINT_LIGHT( SFVEC3F( boardCenter.x, boardCenter.y,
-RANGE_SCALE_3D * 2.0f ),
m_boardAdapter.m_raytrace_lightColorBottom ) );
m_boardAdapter.m_RtLightColorBottom ) );
wxASSERT( m_boardAdapter.m_raytrace_lightColor.size()
== m_boardAdapter.m_raytrace_lightSphericalCoords.size() );
wxASSERT( m_boardAdapter.m_RtLightColor.size()
== m_boardAdapter.m_RtLightSphericalCoords.size() );
for( size_t i = 0; i < m_boardAdapter.m_raytrace_lightColor.size(); ++i )
for( size_t i = 0; i < m_boardAdapter.m_RtLightColor.size(); ++i )
{
if( !IsColorZero( m_boardAdapter.m_raytrace_lightColor[i] ) )
if( !IsColorZero( m_boardAdapter.m_RtLightColor[i] ) )
{
const SFVEC2F sc = m_boardAdapter.m_raytrace_lightSphericalCoords[i];
const SFVEC2F sc = m_boardAdapter.m_RtLightSphericalCoords[i];
m_lights.Add( new DIRECTIONAL_LIGHT(
SphericalToCartesian( glm::pi<float>() * sc.x, glm::pi<float>() * sc.y ),
m_boardAdapter.m_raytrace_lightColor[i] ) );
m_boardAdapter.m_RtLightColor[i] ) );
}
}
}
@ -1019,7 +1010,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
m_accelerator = 0;
m_accelerator = new BVH_PBRT( m_object_container, 8, SPLITMETHOD::MIDDLE );
m_accelerator = new BVH_PBRT( m_objectContainer, 8, SPLITMETHOD::MIDDLE );
if( aStatusReporter )
{
@ -1032,7 +1023,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
}
void RENDER_3D_RAYTRACE::insert3DViaHole( const VIA* aVia )
void RENDER_3D_RAYTRACE::insertHole( const VIA* aVia )
{
PCB_LAYER_ID top_layer, bottom_layer;
int radiusBUI = ( aVia->GetDrillValue() / 2 );
@ -1064,11 +1055,11 @@ void RENDER_3D_RAYTRACE::insert3DViaHole( const VIA* aVia )
objPtr->SetColor( ConvertSRGBToLinear( m_boardAdapter.GetItemColor(
LAYER_VIAS + static_cast<int>( aVia->GetViaType() ) ) ) );
m_object_container.Add( objPtr );
m_objectContainer.Add( objPtr );
}
void RENDER_3D_RAYTRACE::insert3DPadHole( const PAD* aPad )
void RENDER_3D_RAYTRACE::insertHole( const PAD* aPad )
{
const OBJECT_2D* object2d_A = nullptr;
@ -1238,7 +1229,7 @@ void RENDER_3D_RAYTRACE::insert3DPadHole( const PAD* aPad )
objPtr->SetMaterial( &m_materials.m_Copper );
objPtr->SetColor( ConvertSRGBToLinear( objColor ) );
m_object_container.Add( objPtr );
m_objectContainer.Add( objPtr );
}
else
{
@ -1252,13 +1243,13 @@ void RENDER_3D_RAYTRACE::insert3DPadHole( const PAD* aPad )
objPtr->SetMaterial( &m_materials.m_Copper );
objPtr->SetColor( ConvertSRGBToLinear( objColor ) );
m_object_container.Add( objPtr );
m_objectContainer.Add( objPtr );
}
}
}
void RENDER_3D_RAYTRACE::add_3D_vias_and_pads_to_container()
void RENDER_3D_RAYTRACE::addPadsAndVias()
{
// Insert plated vertical holes inside the board
@ -1268,7 +1259,7 @@ void RENDER_3D_RAYTRACE::add_3D_vias_and_pads_to_container()
if( track->Type() == PCB_VIA_T )
{
const VIA* via = static_cast<const VIA*>( track );
insert3DViaHole( via );
insertHole( via );
}
}
@ -1279,15 +1270,14 @@ void RENDER_3D_RAYTRACE::add_3D_vias_and_pads_to_container()
{
if( pad->GetAttribute() != PAD_ATTRIB_NPTH )
{
insert3DPadHole( pad );
insertHole( pad );
}
}
}
}
void RENDER_3D_RAYTRACE::load_3D_models( CONTAINER_3D& aDstContainer,
bool aSkipMaterialInformation )
void RENDER_3D_RAYTRACE::loadModels( CONTAINER_3D& aDstContainer, bool aSkipMaterialInformation )
{
// Go for all footprints
for( FOOTPRINT* fp : m_boardAdapter.GetBoard()->Footprints() )
@ -1365,7 +1355,7 @@ void RENDER_3D_RAYTRACE::load_3D_models( CONTAINER_3D& aDstContainer,
modelMatrix = glm::scale( modelMatrix,
SFVEC3F( sM->m_Scale.x, sM->m_Scale.y, sM->m_Scale.z ) );
add_3D_models( aDstContainer, modelPtr, modelMatrix, (float) sM->m_Opacity,
addModels( aDstContainer, modelPtr, modelMatrix, (float) sM->m_Opacity,
aSkipMaterialInformation, boardItem );
}
}
@ -1377,23 +1367,23 @@ void RENDER_3D_RAYTRACE::load_3D_models( CONTAINER_3D& aDstContainer,
}
MODEL_MATERIALS* RENDER_3D_RAYTRACE::get_3D_model_material( const S3DMODEL* a3DModel )
MODEL_MATERIALS* RENDER_3D_RAYTRACE::getModelMaterial( const S3DMODEL* a3DModel )
{
MODEL_MATERIALS* materialVector;
// Try find if the materials already exists in the map list
if( m_model_materials.find( a3DModel ) != m_model_materials.end() )
if( m_modelMaterialMap.find( a3DModel ) != m_modelMaterialMap.end() )
{
// Found it, so get the pointer
materialVector = &m_model_materials[a3DModel];
materialVector = &m_modelMaterialMap[a3DModel];
}
else
{
// Materials was not found in the map, so it will create a new for
// this model.
m_model_materials[a3DModel] = MODEL_MATERIALS();
materialVector = &m_model_materials[a3DModel];
m_modelMaterialMap[a3DModel] = MODEL_MATERIALS();
materialVector = &m_modelMaterialMap[a3DModel];
materialVector->resize( a3DModel->m_MaterialsSize );
@ -1434,7 +1424,7 @@ MODEL_MATERIALS* RENDER_3D_RAYTRACE::get_3D_model_material( const S3DMODEL* a3DM
< 0.15f ) ) )
{
// This may be a black plastic..
blinnMaterial.SetNormalPerturbator( &m_plastic_normal_perturbator );
blinnMaterial.SetGenerator( &m_plasticMaterial );
}
else
{
@ -1447,8 +1437,7 @@ MODEL_MATERIALS* RENDER_3D_RAYTRACE::get_3D_model_material( const S3DMODEL* a3DM
> 0.25f ) ) )
{
// This may be a color plastic ...
blinnMaterial.SetNormalPerturbator(
&m_plastic_shine_normal_perturbator );
blinnMaterial.SetGenerator( &m_shinyPlasticMaterial );
}
else
{
@ -1463,8 +1452,7 @@ MODEL_MATERIALS* RENDER_3D_RAYTRACE::get_3D_model_material( const S3DMODEL* a3DM
< 0.40f ) ) )
{
// This may be a brushed metal
blinnMaterial.SetNormalPerturbator(
&m_brushed_metal_normal_perturbator );
blinnMaterial.SetGenerator( &m_brushedMetalMaterial );
}
}
}
@ -1482,7 +1470,7 @@ MODEL_MATERIALS* RENDER_3D_RAYTRACE::get_3D_model_material( const S3DMODEL* a3DM
}
void RENDER_3D_RAYTRACE::add_3D_models( CONTAINER_3D& aDstContainer, const S3DMODEL* a3DModel,
void RENDER_3D_RAYTRACE::addModels( CONTAINER_3D& aDstContainer, const S3DMODEL* a3DModel,
const glm::mat4& aModelMatrix, float aFPOpacity,
bool aSkipMaterialInformation, BOARD_ITEM* aBoardItem )
{
@ -1511,7 +1499,7 @@ void RENDER_3D_RAYTRACE::add_3D_models( CONTAINER_3D& aDstContainer, const S3DMO
if( !aSkipMaterialInformation )
{
materialVector = get_3D_model_material( a3DModel );
materialVector = getModelMaterial( a3DModel );
}
const glm::mat3 normalMatrix = glm::transpose( glm::inverse( glm::mat3( aModelMatrix ) ) );

View File

@ -30,10 +30,10 @@
#include <3d_math.h>
#include <wx/debug.h>
int MATERIAL::m_default_nrsamples_refractions = 4;
int MATERIAL::m_default_nrsamples_reflections = 3;
int MATERIAL::m_default_refractions_recursive_levels = 2;
int MATERIAL::m_default_reflections_recursive_levels = 3;
int MATERIAL::m_defaultRefractionRayCount = 4;
int MATERIAL::m_defaultReflectionRayCount = 3;
int MATERIAL::m_defaultRefractionRecursionCount = 2;
int MATERIAL::m_defaultFeflectionRecursionCount = 3;
// This may be a good value if based on nr of lights
// that contribute to the illumination of that point
@ -46,17 +46,17 @@ MATERIAL::MATERIAL()
m_ambientColor = SFVEC3F( 0.2f, 0.2f, 0.2f );
m_emissiveColor = SFVEC3F( 0.0f, 0.0f, 0.0f );
m_specularColor = SFVEC3F( 1.0f, 1.0f, 1.0f );
m_shinness = 50.2f;
m_reflectivity = 50.2f;
m_transparency = 0.0f; // completely opaque
m_cast_shadows = true;
m_castShadows = true;
m_reflection = 0.0f;
m_absorbance = 1.0f;
m_refraction_nr_samples = m_default_nrsamples_refractions;
m_reflections_nr_samples = m_default_nrsamples_reflections;
m_refractions_recursive_levels = m_default_refractions_recursive_levels;
m_reflections_recursive_levels = m_default_reflections_recursive_levels;
m_refractionRayCount = m_defaultRefractionRayCount;
m_reflectionRayCount = m_defaultReflectionRayCount;
m_refractionRecursionCount = m_defaultRefractionRecursionCount;
m_reflectionRecursionCount = m_defaultFeflectionRecursionCount;
m_normal_perturbator = nullptr;
m_generator = nullptr;
}
@ -76,25 +76,25 @@ MATERIAL::MATERIAL( const SFVEC3F& aAmbient, const SFVEC3F& aEmissive, const SFV
m_emissiveColor = aEmissive;
m_specularColor = aSpecular;
m_shinness = aShinness;
m_reflectivity = aShinness;
m_transparency = glm::clamp( aTransparency, 0.0f, 1.0f );
m_absorbance = 1.0f;
m_reflection = aReflection;
m_cast_shadows = true;
m_refraction_nr_samples = m_default_nrsamples_refractions;
m_reflections_nr_samples = m_default_nrsamples_reflections;
m_refractions_recursive_levels = m_default_refractions_recursive_levels;
m_reflections_recursive_levels = m_default_reflections_recursive_levels;
m_castShadows = true;
m_refractionRayCount = m_defaultRefractionRayCount;
m_reflectionRayCount = m_defaultReflectionRayCount;
m_refractionRecursionCount = m_defaultRefractionRecursionCount;
m_reflectionRecursionCount = m_defaultFeflectionRecursionCount;
m_normal_perturbator = nullptr;
m_generator = nullptr;
}
void MATERIAL::PerturbeNormal( SFVEC3F& aNormal, const RAY& aRay, const HITINFO& aHitInfo ) const
void MATERIAL::Generate( SFVEC3F& aNormal, const RAY& aRay, const HITINFO& aHitInfo ) const
{
if( m_normal_perturbator )
if( m_generator )
{
aNormal = aNormal + m_normal_perturbator->Generate( aRay, aHitInfo );
aNormal = aNormal + m_generator->Generate( aRay, aHitInfo );
aNormal = glm::normalize( aNormal );
}
}
@ -121,7 +121,7 @@ SFVEC3F BLINN_PHONG_MATERIAL::Shade( const RAY& aRay, const HITINFO& aHitInfo, f
//Intensity of the specular light
const float NdotH = glm::dot( H, aHitInfo.m_HitNormal );
const float intensitySpecular = glm::pow( glm::max( NdotH, 0.0f ), m_shinness );
const float intensitySpecular = glm::pow( glm::max( NdotH, 0.0f ), m_reflectivity );
return m_ambientColor +
aShadowAttenuationFactor * ( diffuse * aDiffuseObjColor + SPECULAR_FACTOR *
@ -132,7 +132,7 @@ SFVEC3F BLINN_PHONG_MATERIAL::Shade( const RAY& aRay, const HITINFO& aHitInfo, f
}
PROCEDURAL_GENERATOR::PROCEDURAL_GENERATOR()
MATERIAL_GENERATOR::MATERIAL_GENERATOR()
{
}
@ -140,7 +140,7 @@ PROCEDURAL_GENERATOR::PROCEDURAL_GENERATOR()
static PerlinNoise s_perlinNoise = PerlinNoise( 0 );
BOARD_NORMAL::BOARD_NORMAL( float aScale ) : PROCEDURAL_GENERATOR()
BOARD_NORMAL::BOARD_NORMAL( float aScale ) : MATERIAL_GENERATOR()
{
m_scale = ( 2.0f * glm::pi<float>() ) / aScale;
}
@ -165,7 +165,7 @@ SFVEC3F BOARD_NORMAL::Generate( const RAY& aRay, const HITINFO& aHitInfo ) const
}
COPPER_NORMAL::COPPER_NORMAL( float aScale, const PROCEDURAL_GENERATOR* aBoardNormalGenerator )
COPPER_NORMAL::COPPER_NORMAL( float aScale, const MATERIAL_GENERATOR* aBoardNormalGenerator )
{
m_board_normal_generator = aBoardNormalGenerator;
m_scale = 1.0f / aScale;
@ -199,7 +199,7 @@ SFVEC3F COPPER_NORMAL::Generate( const RAY& aRay, const HITINFO& aHitInfo ) cons
}
SOLDER_MASK_NORMAL::SOLDER_MASK_NORMAL( const PROCEDURAL_GENERATOR* aCopperNormalGenerator )
SOLDER_MASK_NORMAL::SOLDER_MASK_NORMAL( const MATERIAL_GENERATOR* aCopperNormalGenerator )
{
m_copper_normal_generator = aCopperNormalGenerator;
}

View File

@ -36,12 +36,12 @@
/**
* A base class that can be used to derive procedurally generated materials.
*/
class PROCEDURAL_GENERATOR
class MATERIAL_GENERATOR
{
public:
PROCEDURAL_GENERATOR();
MATERIAL_GENERATOR();
virtual ~PROCEDURAL_GENERATOR()
virtual ~MATERIAL_GENERATOR()
{
}
@ -56,10 +56,10 @@ public:
};
class BOARD_NORMAL : public PROCEDURAL_GENERATOR
class BOARD_NORMAL : public MATERIAL_GENERATOR
{
public:
BOARD_NORMAL() : PROCEDURAL_GENERATOR() { m_scale = 1.0f; }
BOARD_NORMAL() : MATERIAL_GENERATOR() { m_scale = 1.0f; }
BOARD_NORMAL( float aScale );
virtual ~BOARD_NORMAL()
@ -76,16 +76,16 @@ private:
/**
* Procedural generation of the copper normals.
*/
class COPPER_NORMAL : public PROCEDURAL_GENERATOR
class COPPER_NORMAL : public MATERIAL_GENERATOR
{
public:
COPPER_NORMAL() : PROCEDURAL_GENERATOR()
COPPER_NORMAL() : MATERIAL_GENERATOR()
{
m_board_normal_generator = nullptr;
m_scale = 1.0f;
}
COPPER_NORMAL( float aScale, const PROCEDURAL_GENERATOR* aBoardNormalGenerator );
COPPER_NORMAL( float aScale, const MATERIAL_GENERATOR* aBoardNormalGenerator );
virtual ~COPPER_NORMAL()
{
@ -94,15 +94,15 @@ public:
SFVEC3F Generate( const RAY& aRay, const HITINFO& aHitInfo ) const override;
private:
const PROCEDURAL_GENERATOR* m_board_normal_generator;
const MATERIAL_GENERATOR* m_board_normal_generator;
float m_scale;
};
class PLATED_COPPER_NORMAL : public PROCEDURAL_GENERATOR
class PLATED_COPPER_NORMAL : public MATERIAL_GENERATOR
{
public:
PLATED_COPPER_NORMAL() : PROCEDURAL_GENERATOR()
PLATED_COPPER_NORMAL() : MATERIAL_GENERATOR()
{
m_scale = 1.0f;
}
@ -126,11 +126,11 @@ private:
/**
* Procedural generation of the solder mask.
*/
class SOLDER_MASK_NORMAL : public PROCEDURAL_GENERATOR
class SOLDER_MASK_NORMAL : public MATERIAL_GENERATOR
{
public:
SOLDER_MASK_NORMAL() : PROCEDURAL_GENERATOR() { m_copper_normal_generator = nullptr; }
SOLDER_MASK_NORMAL( const PROCEDURAL_GENERATOR* aCopperNormalGenerator );
SOLDER_MASK_NORMAL() : MATERIAL_GENERATOR() { m_copper_normal_generator = nullptr; }
SOLDER_MASK_NORMAL( const MATERIAL_GENERATOR* aCopperNormalGenerator );
virtual ~SOLDER_MASK_NORMAL()
{
@ -139,17 +139,17 @@ public:
SFVEC3F Generate( const RAY& aRay, const HITINFO& aHitInfo ) const override;
private:
const PROCEDURAL_GENERATOR* m_copper_normal_generator;
const MATERIAL_GENERATOR* m_copper_normal_generator;
};
/**
* Procedural generation of the plastic normals.
*/
class PLASTIC_NORMAL : public PROCEDURAL_GENERATOR
class PLASTIC_NORMAL : public MATERIAL_GENERATOR
{
public:
PLASTIC_NORMAL() : PROCEDURAL_GENERATOR()
PLASTIC_NORMAL() : MATERIAL_GENERATOR()
{
m_scale = 1.0f;
}
@ -170,10 +170,10 @@ private:
/**
* Procedural generation of the shiny plastic normals.
*/
class PLASTIC_SHINE_NORMAL : public PROCEDURAL_GENERATOR
class PLASTIC_SHINE_NORMAL : public MATERIAL_GENERATOR
{
public:
PLASTIC_SHINE_NORMAL() : PROCEDURAL_GENERATOR()
PLASTIC_SHINE_NORMAL() : MATERIAL_GENERATOR()
{
m_scale = 1.0f;
}
@ -184,7 +184,7 @@ public:
{
}
// Imported from PROCEDURAL_GENERATOR
// Imported from MATERIAL_GENERATOR
SFVEC3F Generate( const RAY& aRay, const HITINFO& aHitInfo ) const override;
private:
@ -195,10 +195,10 @@ private:
/**
* Procedural generation of the shiny brushed metal.
*/
class BRUSHED_METAL_NORMAL : public PROCEDURAL_GENERATOR
class BRUSHED_METAL_NORMAL : public MATERIAL_GENERATOR
{
public:
BRUSHED_METAL_NORMAL() : PROCEDURAL_GENERATOR()
BRUSHED_METAL_NORMAL() : MATERIAL_GENERATOR()
{
m_scale = 1.0f;
}
@ -216,10 +216,10 @@ private:
};
class SILK_SCREEN_NORMAL : public PROCEDURAL_GENERATOR
class SILK_SCREEN_NORMAL : public MATERIAL_GENERATOR
{
public:
SILK_SCREEN_NORMAL() : PROCEDURAL_GENERATOR()
SILK_SCREEN_NORMAL() : MATERIAL_GENERATOR()
{
m_scale = 1.0f;
}
@ -243,24 +243,24 @@ private:
class MATERIAL
{
public:
static void SetDefaultNrRefractionsSamples( unsigned int aNrRefractions )
static void SetDefaultRefractionRayCount( unsigned int aCount )
{
m_default_nrsamples_refractions = aNrRefractions;
m_defaultRefractionRayCount = aCount;
}
static void SetDefaultNrReflectionsSamples( unsigned int aNrReflections )
static void SetDefaultReflectionRayCount( unsigned int aCount )
{
m_default_nrsamples_reflections = aNrReflections;
m_defaultReflectionRayCount = aCount;
}
static void SetDefaultRefractionsLevel( unsigned int aRefractionLevel )
static void SetDefaultRefractionRecursionCount( unsigned int aCount )
{
m_default_refractions_recursive_levels = aRefractionLevel;
m_defaultRefractionRecursionCount = aCount;
}
static void SetDefaultReflectionsLevel( unsigned int aReflectionLevel )
static void SetDefaultReflectionRecursionCount( unsigned int aCount )
{
m_default_reflections_recursive_levels = aReflectionLevel;
m_defaultFeflectionRecursionCount = aCount;
}
MATERIAL();
@ -273,34 +273,34 @@ public:
const SFVEC3F& GetEmissiveColor() const { return m_emissiveColor; }
const SFVEC3F& GetSpecularColor() const { return m_specularColor; }
float GetShinness() const { return m_shinness; }
float GetReflectivity() const { return m_reflectivity; }
float GetTransparency() const { return m_transparency; }
float GetReflection() const { return m_reflection; }
float GetAbsorvance() const { return m_absorbance; }
unsigned int GetNrRefractionsSamples() const { return m_refraction_nr_samples; }
unsigned int GetNrReflectionsSamples() const { return m_reflections_nr_samples; }
unsigned int GetReflectionsRecursiveLevel() const { return m_reflections_recursive_levels; }
unsigned int GetRefractionsRecursiveLevel() const { return m_refractions_recursive_levels; }
unsigned int GetRefractionRayCount() const { return m_refractionRayCount; }
unsigned int GetReflectionRayCount() const { return m_reflectionRayCount; }
unsigned int GetReflectionRecursionCount() const { return m_reflectionRecursionCount; }
unsigned int GetRefractionRecursionCount() const { return m_refractionRecursionCount; }
void SetAbsorvance( float aAbsorvanceFactor ) { m_absorbance = aAbsorvanceFactor; }
void SetNrRefractionsSamples( unsigned int aNrRefractions )
void SetRefractionRayCount( unsigned int aCount )
{
m_refraction_nr_samples = aNrRefractions;
m_refractionRayCount = aCount;
}
void SetNrReflectionsSamples( unsigned int aNrReflections )
void SetReflectionRayCount( unsigned int aCount )
{
m_reflections_nr_samples = aNrReflections;
m_reflectionRayCount = aCount;
}
void SetReflectionsRecursiveLevel( unsigned int aReflectionsLevel )
void SetReflectionRecursionCount( unsigned int aCount )
{
m_reflections_recursive_levels = aReflectionsLevel;
m_reflectionRecursionCount = aCount;
}
void SetRefractionsRecursiveLevel( unsigned int aRefractionsLevel )
void SetRefractionRecursionCount( unsigned int aCount )
{
m_refractions_recursive_levels = aRefractionsLevel;
m_refractionRecursionCount = aCount;
}
/**
@ -308,9 +308,9 @@ public:
*
* @param aCastShadows true yes it can, false not it cannot
*/
void SetCastShadows( bool aCastShadows ) { m_cast_shadows = aCastShadows; }
void SetCastShadows( bool aCastShadows ) { m_castShadows = aCastShadows; }
bool GetCastShadows() const { return m_cast_shadows; }
bool GetCastShadows() const { return m_castShadows; }
/**
* Shade an intersection point.
@ -329,14 +329,14 @@ public:
const SFVEC3F& aLightColor,
float aShadowAttenuationFactor ) const = 0;
void SetNormalPerturbator( const PROCEDURAL_GENERATOR* aPerturbator )
void SetGenerator( const MATERIAL_GENERATOR* aGenerator )
{
m_normal_perturbator = aPerturbator;
m_generator = aGenerator;
}
const PROCEDURAL_GENERATOR* GetNormalPerturbator() const { return m_normal_perturbator; }
const MATERIAL_GENERATOR* GetGenerator() const { return m_generator; }
void PerturbeNormal( SFVEC3F& aNormal, const RAY& aRay, const HITINFO& aHitInfo ) const;
void Generate( SFVEC3F& aNormal, const RAY& aRay, const HITINFO& aHitInfo ) const;
protected:
SFVEC3F m_ambientColor;
@ -347,33 +347,33 @@ protected:
SFVEC3F m_emissiveColor;
SFVEC3F m_specularColor;
float m_shinness;
float m_reflectivity;
///< 1.0 is completely transparent, 0.0 completely opaque.
float m_transparency;
float m_absorbance; ///< absorbance factor for the transparent material.
float m_reflection; ///< 1.0 completely reflective, 0.0 no reflective.
bool m_cast_shadows; ///< true if this object will block the light.
bool m_castShadows; ///< true if this object will block the light.
///< Number of rays that will be interpolated for this material if it is a transparent.
unsigned int m_refraction_nr_samples;
///< Number of rays that will be interpolated for this material if it is transparent.
unsigned int m_refractionRayCount;
///< Number of rays that will be interpolated for this material if it is reflective.
unsigned int m_reflections_nr_samples;
unsigned int m_reflectionRayCount;
///< Number of levels it allows for refraction recursiveness.
unsigned int m_refractions_recursive_levels;
unsigned int m_refractionRecursionCount;
///< Number of levels it allows for reflection recursiveness.
unsigned int m_reflections_recursive_levels;
unsigned int m_reflectionRecursionCount;
const PROCEDURAL_GENERATOR* m_normal_perturbator;
const MATERIAL_GENERATOR* m_generator;
private:
static int m_default_nrsamples_refractions;
static int m_default_nrsamples_reflections;
static int m_default_refractions_recursive_levels;
static int m_default_reflections_recursive_levels;
static int m_defaultRefractionRayCount;
static int m_defaultReflectionRayCount;
static int m_defaultRefractionRecursionCount;
static int m_defaultFeflectionRecursionCount;
};

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -35,10 +35,10 @@
uint32_t Part1By1( uint32_t x )
{
x &= 0x0000ffff; // x = ---- ---- ---- ---- fedc ba98 7654 3210
x = (x ^ (x << 8)) & 0x00ff00ff; // x = ---- ---- fedc ba98 ---- ---- 7654 3210
x = (x ^ (x << 4)) & 0x0f0f0f0f; // x = ---- fedc ---- ba98 ---- 7654 ---- 3210
x = (x ^ (x << 2)) & 0x33333333; // x = --fe --dc --ba --98 --76 --54 --32 --10
x = (x ^ (x << 1)) & 0x55555555; // x = -f-e -d-c -b-a -9-8 -7-6 -5-4 -3-2 -1-0
x = ( x ^ ( x << 8 ) ) & 0x00ff00ff; // x = ---- ---- fedc ba98 ---- ---- 7654 3210
x = ( x ^ ( x << 4 ) ) & 0x0f0f0f0f; // x = ---- fedc ---- ba98 ---- 7654 ---- 3210
x = ( x ^ ( x << 2 ) ) & 0x33333333; // x = --fe --dc --ba --98 --76 --54 --32 --10
x = ( x ^ ( x << 1 ) ) & 0x55555555; // x = -f-e -d-c -b-a -9-8 -7-6 -5-4 -3-2 -1-0
return x;
}
@ -48,10 +48,10 @@ uint32_t Part1By1( uint32_t x )
uint32_t Part1By2( uint32_t x )
{
x &= 0x000003ff; // x = ---- ---- ---- ---- ---- --98 7654 3210
x = (x ^ (x << 16)) & 0xff0000ff; // x = ---- --98 ---- ---- ---- ---- 7654 3210
x = (x ^ (x << 8)) & 0x0300f00f; // x = ---- --98 ---- ---- 7654 ---- ---- 3210
x = (x ^ (x << 4)) & 0x030c30c3; // x = ---- --98 ---- 76-- --54 ---- 32-- --10
x = (x ^ (x << 2)) & 0x09249249; // x = ---- 9--8 --7- -6-- 5--4 --3- -2-- 1--0
x = ( x ^ ( x << 16 ) ) & 0xff0000ff; // x = ---- --98 ---- ---- ---- ---- 7654 3210
x = ( x ^ ( x << 8 ) ) & 0x0300f00f; // x = ---- --98 ---- ---- 7654 ---- ---- 3210
x = ( x ^ ( x << 4 ) ) & 0x030c30c3; // x = ---- --98 ---- 76-- --54 ---- 32-- --10
x = ( x ^ ( x << 2 ) ) & 0x09249249; // x = ---- 9--8 --7- -6-- 5--4 --3- -2-- 1--0
return x;
}
@ -61,10 +61,10 @@ uint32_t Part1By2( uint32_t x )
uint32_t Compact1By1( uint32_t x )
{
x &= 0x55555555; // x = -f-e -d-c -b-a -9-8 -7-6 -5-4 -3-2 -1-0
x = (x ^ (x >> 1)) & 0x33333333; // x = --fe --dc --ba --98 --76 --54 --32 --10
x = (x ^ (x >> 2)) & 0x0f0f0f0f; // x = ---- fedc ---- ba98 ---- 7654 ---- 3210
x = (x ^ (x >> 4)) & 0x00ff00ff; // x = ---- ---- fedc ba98 ---- ---- 7654 3210
x = (x ^ (x >> 8)) & 0x0000ffff; // x = ---- ---- ---- ---- fedc ba98 7654 3210
x = ( x ^ ( x >> 1 ) ) & 0x33333333; // x = --fe --dc --ba --98 --76 --54 --32 --10
x = ( x ^ ( x >> 2 ) ) & 0x0f0f0f0f; // x = ---- fedc ---- ba98 ---- 7654 ---- 3210
x = ( x ^ ( x >> 4 ) ) & 0x00ff00ff; // x = ---- ---- fedc ba98 ---- ---- 7654 3210
x = ( x ^ ( x >> 8 ) ) & 0x0000ffff; // x = ---- ---- ---- ---- fedc ba98 7654 3210
return x;
}
@ -74,10 +74,10 @@ uint32_t Compact1By1( uint32_t x )
uint32_t Compact1By2( uint32_t x )
{
x &= 0x09249249; // x = ---- 9--8 --7- -6-- 5--4 --3- -2-- 1--0
x = (x ^ (x >> 2)) & 0x030c30c3; // x = ---- --98 ---- 76-- --54 ---- 32-- --10
x = (x ^ (x >> 4)) & 0x0300f00f; // x = ---- --98 ---- ---- 7654 ---- ---- 3210
x = (x ^ (x >> 8)) & 0xff0000ff; // x = ---- --98 ---- ---- ---- ---- 7654 3210
x = (x ^ (x >> 16)) & 0x000003ff; // x = ---- ---- ---- ---- ---- --98 7654 3210
x = ( x ^ ( x >> 2 ) ) & 0x030c30c3; // x = ---- --98 ---- 76-- --54 ---- 32-- --10
x = ( x ^ ( x >> 4 ) ) & 0x0300f00f; // x = ---- --98 ---- ---- 7654 ---- ---- 3210
x = ( x ^ ( x >> 8 ) ) & 0xff0000ff; // x = ---- --98 ---- ---- ---- ---- 7654 3210
x = ( x ^ ( x >> 16 ) ) & 0x000003ff; // x = ---- ---- ---- ---- ---- --98 7654 3210
return x;
}

View File

@ -103,6 +103,7 @@ void RAY::Init( const SFVEC3F& o, const SFVEC3F& d )
if( m_Dir.z < 0 )
{
m_Classification = RAY_CLASSIFICATION::MPM;
if( m_Dir.y == 0 )
m_Classification = RAY_CLASSIFICATION::MOM;
}
@ -126,6 +127,7 @@ void RAY::Init( const SFVEC3F& o, const SFVEC3F& d )
if( m_Dir.z < 0 )
{
m_Classification = RAY_CLASSIFICATION::PMM;
if( m_Dir.x == 0 )
m_Classification = RAY_CLASSIFICATION::OMM;
}
@ -185,8 +187,7 @@ void RAY::Init( const SFVEC3F& o, const SFVEC3F& d )
bool IntersectSegment( const SFVEC2F &aStartA, const SFVEC2F &aEnd_minus_startA,
const SFVEC2F &aStartB, const SFVEC2F &aEnd_minus_startB )
{
float rxs = aEnd_minus_startA.x *
aEnd_minus_startB.y - aEnd_minus_startA.y *
float rxs = aEnd_minus_startA.x * aEnd_minus_startB.y - aEnd_minus_startA.y *
aEnd_minus_startB.x;
if( std::abs( rxs ) > glm::epsilon<float>() )
@ -216,33 +217,6 @@ bool IntersectSegment( const SFVEC2F &aStartA, const SFVEC2F &aEnd_minus_startA,
bool RAY::IntersectSphere( const SFVEC3F &aCenter, float aRadius, float &aOutT0,
float &aOutT1 ) const
{
/*
// Ray-sphere intersection: algebraic
SFVEC3F CO = m_Origin - aCenter;
float a = glm::dot( m_Dir, m_Dir );
float b = 2.0f * glm::dot( CO, m_Dir );
float c = glm::dot( CO, CO ) - aRadius*aRadius;
float discriminant = b * b - 4.0f * a * c;
if( discriminant < 0.0f )
return false;
aOutT0 = (-b - sqrtf(discriminant)) / (2.0f * a);
aOutT1 = (-b + sqrtf(discriminant)) / (2.0f * a);
if( aOutT0 > aOutT1 )
{
float temp = aOutT0;
aOutT0 = aOutT1;
aOutT1 = temp;
}
return true;
*/
// Ray-sphere intersection: geometric
SFVEC3F OC = aCenter - m_Origin;
float p_dot_d = glm::dot( OC, m_Dir );
@ -291,8 +265,7 @@ RAYSEG2D::RAYSEG2D( const SFVEC2F& s, const SFVEC2F& e )
}
bool RAYSEG2D::IntersectSegment( const SFVEC2F &aStart,
const SFVEC2F &aEnd_minus_start,
bool RAYSEG2D::IntersectSegment( const SFVEC2F &aStart, const SFVEC2F &aEnd_minus_start,
float *aOutT ) const
{
float rxs = m_End_minus_start.x * aEnd_minus_start.y - m_End_minus_start.y *
@ -349,12 +322,8 @@ float RAYSEG2D::DistanceToPointSquared( const SFVEC2F &aPoint ) const
}
bool RAYSEG2D::IntersectCircle( const SFVEC2F &aCenter,
float aRadius,
float *aOutT0,
float *aOutT1,
SFVEC2F *aOutNormalT0,
SFVEC2F *aOutNormalT1 ) const
bool RAYSEG2D::IntersectCircle( const SFVEC2F &aCenter, float aRadius, float *aOutT0,
float *aOutT1, SFVEC2F *aOutNormalT0, SFVEC2F *aOutNormalT1 ) const
{
// This code used directly from Steve Marschner's CS667 framework
// http://cs665pd.googlecode.com/svn/trunk/photon/sphere.cpp

View File

@ -79,10 +79,8 @@ RAYPACKET::RAYPACKET( const CAMERA& aCamera, const SFVEC2F& aWindowsPosition )
RAYPACKET::RAYPACKET( const CAMERA& aCamera, const SFVEC2F& aWindowsPosition,
const SFVEC2F& a2DWindowsPosDisplacementFactor )
{
RAYPACKET_InitRays_with2DDisplacement( aCamera,
aWindowsPosition,
a2DWindowsPosDisplacementFactor,
m_ray );
RAYPACKET_InitRays_with2DDisplacement( aCamera, aWindowsPosition,
a2DWindowsPosDisplacementFactor, m_ray );
RAYPACKET_GenerateFrustum( &m_Frustum, m_ray );
}

View File

@ -42,37 +42,34 @@
#include "../common_ogl/ogl_utils.h"
#include <profile.h> // To use GetRunningMicroSecs or another profiling utility
// This should be used in future for the function
// convertLinearToSRGB
//#include <glm/gtc/color_space.hpp>
RENDER_3D_RAYTRACE::RENDER_3D_RAYTRACE( BOARD_ADAPTER& aAdapter, CAMERA& aCamera ) :
RENDER_3D_BASE( aAdapter, aCamera ),
m_postshader_ssao( aCamera )
m_postShaderSsao( aCamera )
{
wxLogTrace( m_logTrace, wxT( "RENDER_3D_RAYTRACE::RENDER_3D_RAYTRACE" ) );
m_opengl_support_vertex_buffer_object = false;
m_openglSupportsVertexBufferObjects = false;
m_pboId = GL_NONE;
m_pboDataSize = 0;
m_accelerator = nullptr;
m_stats_converted_dummy_to_plane = 0;
m_stats_converted_roundsegment2d_to_roundsegment = 0;
m_convertedDummyBlockCount = 0;
m_converted2dRoundSegmentCount = 0;
m_oldWindowsSize.x = 0;
m_oldWindowsSize.y = 0;
m_outlineBoard2dObjects = nullptr;
m_antioutlineBoard2dObjects = nullptr;
m_firstHitinfo = nullptr;
m_shaderBuffer = nullptr;
m_camera_light = nullptr;
m_cameraLight = nullptr;
m_xoffset = 0;
m_yoffset = 0;
m_isPreview = false;
m_rt_render_state = RT_RENDER_STATE_MAX; // Set to an initial invalid state
m_stats_start_rendering_time = 0;
m_nrBlocksRenderProgress = 0;
m_renderState = RT_RENDER_STATE_MAX; // Set to an initial invalid state
m_renderStartTime = 0;
m_blockRenderProgressCount = 0;
}
@ -92,7 +89,7 @@ RENDER_3D_RAYTRACE::~RENDER_3D_RAYTRACE()
delete[] m_shaderBuffer;
m_shaderBuffer = nullptr;
opengl_delete_pbo();
deletePbo();
}
@ -102,10 +99,10 @@ int RENDER_3D_RAYTRACE::GetWaitForEditingTimeOut()
}
void RENDER_3D_RAYTRACE::opengl_delete_pbo()
void RENDER_3D_RAYTRACE::deletePbo()
{
// Delete PBO if it was created
if( m_opengl_support_vertex_buffer_object )
if( m_openglSupportsVertexBufferObjects )
{
if( glIsBufferARB( m_pboId ) )
glDeleteBuffers( 1, &m_pboId );
@ -127,14 +124,14 @@ void RENDER_3D_RAYTRACE::SetCurWindowSize( const wxSize& aSize )
}
void RENDER_3D_RAYTRACE::restart_render_state()
void RENDER_3D_RAYTRACE::restartRenderState()
{
m_stats_start_rendering_time = GetRunningMicroSecs();
m_renderStartTime = GetRunningMicroSecs();
m_rt_render_state = RT_RENDER_STATE_TRACING;
m_nrBlocksRenderProgress = 0;
m_renderState = RT_RENDER_STATE_TRACING;
m_blockRenderProgressCount = 0;
m_postshader_ssao.InitFrame();
m_postShaderSsao.InitFrame();
m_blockPositionsWasProcessed.resize( m_blockPositions.size() );
@ -145,7 +142,10 @@ void RENDER_3D_RAYTRACE::restart_render_state()
static inline void SetPixel( GLubyte* p, const COLOR_RGB& v )
{
p[0] = v.c[0]; p[1] = v.c[1]; p[2] = v.c[2]; p[3] = 255;
p[0] = v.c[0];
p[1] = v.c[1];
p[2] = v.c[2];
p[3] = 255;
}
@ -166,7 +166,7 @@ bool RENDER_3D_RAYTRACE::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
// It will assign the first time the windows size, so it will now
// revert to preview mode the first time the Redraw is called
m_oldWindowsSize = m_windowSize;
initialize_block_positions();
initializeBlockPositions();
}
std::unique_ptr<BUSY_INDICATOR> busy = CreateBusyIndicator();
@ -190,7 +190,7 @@ bool RENDER_3D_RAYTRACE::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
aIsMoving = true;
requestRedraw = true;
initialize_block_positions();
initializeBlockPositions();
}
@ -214,17 +214,17 @@ bool RENDER_3D_RAYTRACE::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
const bool was_camera_changed = m_camera.ParametersChanged();
if( requestRedraw || aIsMoving || was_camera_changed )
m_rt_render_state = RT_RENDER_STATE_MAX; // Set to an invalid state,
m_renderState = RT_RENDER_STATE_MAX; // Set to an invalid state,
// so it will restart again latter
// This will only render if need, otherwise it will redraw the PBO on the screen again
if( aIsMoving || was_camera_changed )
{
// Set head light (camera view light) with the opposite direction of the camera
if( m_camera_light )
m_camera_light->SetDirection( -m_camera.GetDir() );
if( m_cameraLight )
m_cameraLight->SetDirection( -m_camera.GetDir() );
OGL_DrawBackground( SFVEC3F( m_boardAdapter.m_BgColorTop),
OglDrawBackground( SFVEC3F( m_boardAdapter.m_BgColorTop),
SFVEC3F( m_boardAdapter.m_BgColorBot) );
// Bind PBO
@ -236,7 +236,7 @@ bool RENDER_3D_RAYTRACE::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
if( ptrPBO )
{
render_preview( ptrPBO );
renderPreview( ptrPBO );
// release pointer to mapping buffer, this initialize the coping to PBO
glUnmapBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB );
@ -249,7 +249,7 @@ bool RENDER_3D_RAYTRACE::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
// Bind PBO
glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, m_pboId );
if( m_rt_render_state != RT_RENDER_STATE_FINISH )
if( m_renderState != RT_RENDER_STATE_FINISH )
{
// Get the PBO pixel pointer to write the data
GLubyte* ptrPBO = (GLubyte *)glMapBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB,
@ -259,7 +259,7 @@ bool RENDER_3D_RAYTRACE::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
{
render( ptrPBO, aStatusReporter );
if( m_rt_render_state != RT_RENDER_STATE_FINISH )
if( m_renderState != RT_RENDER_STATE_FINISH )
requestRedraw = true;
// release pointer to mapping buffer, this initialize the coping to PBO
@ -267,13 +267,9 @@ bool RENDER_3D_RAYTRACE::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
}
}
if( m_rt_render_state == RT_RENDER_STATE_FINISH )
if( m_renderState == RT_RENDER_STATE_FINISH )
{
glClear( GL_COLOR_BUFFER_BIT );
// Options if we want draw background instead
//OGL_DrawBackground( SFVEC3F(m_boardAdapter.m_BgColorTop),
// SFVEC3F(m_boardAdapter.m_BgColorBot) );
}
glWindowPos2i( m_xoffset, m_yoffset );
@ -293,13 +289,12 @@ bool RENDER_3D_RAYTRACE::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
void RENDER_3D_RAYTRACE::render( GLubyte* ptrPBO, REPORTER* aStatusReporter )
{
if( ( m_rt_render_state == RT_RENDER_STATE_FINISH )
|| ( m_rt_render_state >= RT_RENDER_STATE_MAX ) )
if( ( m_renderState == RT_RENDER_STATE_FINISH ) || ( m_renderState >= RT_RENDER_STATE_MAX ) )
{
restart_render_state();
restartRenderState();
if( m_camera_light )
m_camera_light->SetDirection( -m_camera.GetDir() );
if( m_cameraLight )
m_cameraLight->SetDirection( -m_camera.GetDir() );
if( m_boardAdapter.GetRenderEngine() == RENDER_ENGINE::OPENGL_LEGACY )
{
@ -316,43 +311,41 @@ void RENDER_3D_RAYTRACE::render( GLubyte* ptrPBO, REPORTER* aStatusReporter )
}
}
m_BgColorTop_LinearRGB = ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_BgColorTop );
m_BgColorBot_LinearRGB = ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_BgColorBot );
m_backgroundColorTop = ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_BgColorTop );
m_backgroundColorBottom = ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_BgColorBot );
}
switch( m_rt_render_state )
switch( m_renderState )
{
case RT_RENDER_STATE_TRACING:
rt_render_tracing( ptrPBO, aStatusReporter );
renderTracing( ptrPBO, aStatusReporter );
break;
case RT_RENDER_STATE_POST_PROCESS_SHADE:
rt_render_post_process_shade( ptrPBO, aStatusReporter );
postProcessShading( ptrPBO, aStatusReporter );
break;
case RT_RENDER_STATE_POST_PROCESS_BLUR_AND_FINISH:
rt_render_post_process_blur_finish( ptrPBO, aStatusReporter );
postProcessBlurFinish( ptrPBO, aStatusReporter );
break;
default:
wxASSERT_MSG( false, "Invalid state on m_rt_render_state");
restart_render_state();
wxASSERT_MSG( false, "Invalid state on m_renderState");
restartRenderState();
break;
}
if( aStatusReporter && ( m_rt_render_state == RT_RENDER_STATE_FINISH ) )
if( aStatusReporter && ( m_renderState == RT_RENDER_STATE_FINISH ) )
{
// Calculation time in seconds
const double calculation_time = (double)( GetRunningMicroSecs() -
m_stats_start_rendering_time ) / 1e6;
const double elapsed_time = (double)( GetRunningMicroSecs() - m_renderStartTime ) / 1e6;
aStatusReporter->Report( wxString::Format( _( "Rendering time %.3f s" ),
calculation_time ) );
aStatusReporter->Report( wxString::Format( _( "Rendering time %.3f s" ), elapsed_time ) );
}
}
void RENDER_3D_RAYTRACE::rt_render_tracing( GLubyte* ptrPBO, REPORTER* aStatusReporter )
void RENDER_3D_RAYTRACE::renderTracing( GLubyte* ptrPBO, REPORTER* aStatusReporter )
{
m_isPreview = false;
@ -377,7 +370,7 @@ void RENDER_3D_RAYTRACE::rt_render_tracing( GLubyte* ptrPBO, REPORTER* aStatusRe
{
if( !m_blockPositionsWasProcessed[iBlock] )
{
rt_render_trace_block( ptrPBO, iBlock );
renderBlockTracing( ptrPBO, iBlock );
numBlocksRendered++;
m_blockPositionsWasProcessed[iBlock] = 1;
@ -398,21 +391,21 @@ void RENDER_3D_RAYTRACE::rt_render_tracing( GLubyte* ptrPBO, REPORTER* aStatusRe
while( threadsFinished < parallelThreadCount )
std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
m_nrBlocksRenderProgress += numBlocksRendered;
m_blockRenderProgressCount += numBlocksRendered;
if( aStatusReporter )
aStatusReporter->Report( wxString::Format( _( "Rendering: %.0f %%" ),
(float) ( m_nrBlocksRenderProgress * 100 )
(float) ( m_blockRenderProgressCount * 100 )
/ (float) m_blockPositions.size() ) );
// Check if it finish the rendering and if should continue to a post processing
// or mark it as finished
if( m_nrBlocksRenderProgress >= m_blockPositions.size() )
if( m_blockRenderProgressCount >= m_blockPositions.size() )
{
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) )
m_rt_render_state = RT_RENDER_STATE_POST_PROCESS_SHADE;
m_renderState = RT_RENDER_STATE_POST_PROCESS_SHADE;
else
m_rt_render_state = RT_RENDER_STATE_FINISH;
m_renderState = RT_RENDER_STATE_FINISH;
}
}
@ -452,7 +445,7 @@ SFVEC3F ConvertSRGBToLinear( const SFVEC3F& aSRGBcolor )
#endif
void RENDER_3D_RAYTRACE::rt_final_color( GLubyte* ptrPBO, const SFVEC3F& rgbColor,
void RENDER_3D_RAYTRACE::renderFinalColor( GLubyte* ptrPBO, const SFVEC3F& rgbColor,
bool applyColorSpaceConversion )
{
SFVEC3F color = rgbColor;
@ -487,7 +480,7 @@ static void HITINFO_PACKET_init( HITINFO_PACKET* aHitPacket )
}
void RENDER_3D_RAYTRACE::rt_shades_packet( const SFVEC3F* bgColorY, const RAY* aRayPkt,
void RENDER_3D_RAYTRACE::renderRayPackets( const SFVEC3F* bgColorY, const RAY* aRayPkt,
HITINFO_PACKET* aHitPacket, bool is_testShadow,
SFVEC3F* aOutHitColor )
{
@ -509,7 +502,7 @@ void RENDER_3D_RAYTRACE::rt_shades_packet( const SFVEC3F* bgColorY, const RAY* a
}
void RENDER_3D_RAYTRACE::rt_trace_AA_packet( const SFVEC3F* aBgColorY,
void RENDER_3D_RAYTRACE::renderAnitAliasPackets( const SFVEC3F* aBgColorY,
const HITINFO_PACKET* aHitPck_X0Y0,
const HITINFO_PACKET* aHitPck_AA_X1Y1,
const RAY* aRayPck, SFVEC3F* aOutHitColor )
@ -556,6 +549,8 @@ void RENDER_3D_RAYTRACE::rt_trace_AA_packet( const SFVEC3F* aBgColorY,
&& ( ( nodex0y0 == nodex1y1 ) || ( nodex1y1 == 0 ) )
&& ( nodex0y0 == node_AA_x0y0 ) )
{
/// @todo Either get rid of the if statement above or do something with the
/// commented out code below.
// Option 1
// This option will give a very good quality on reflections (slow)
/*
@ -630,7 +625,7 @@ void RENDER_3D_RAYTRACE::rt_trace_AA_packet( const SFVEC3F* aBgColorY,
#define DISP_FACTOR 0.075f
void RENDER_3D_RAYTRACE::rt_render_trace_block( GLubyte* ptrPBO, signed int iBlock )
void RENDER_3D_RAYTRACE::renderBlockTracing( GLubyte* ptrPBO, signed int iBlock )
{
// Initialize ray packets
const SFVEC2UI& blockPos = m_blockPositions[iBlock];
@ -651,8 +646,8 @@ void RENDER_3D_RAYTRACE::rt_render_trace_block( GLubyte* ptrPBO, signed int iBlo
{
const float posYfactor = (float) ( blockPosI.y + y ) / (float) m_windowSize.y;
bgColor[y] = m_BgColorTop_LinearRGB * SFVEC3F(posYfactor) +
m_BgColorBot_LinearRGB * ( SFVEC3F(1.0f) - SFVEC3F(posYfactor) );
bgColor[y] = m_backgroundColorTop * SFVEC3F(posYfactor) +
m_backgroundColorBottom * ( SFVEC3F(1.0f) - SFVEC3F(posYfactor) );
}
// Intersect ray packets (calculate the intersection with rays and objects)
@ -669,7 +664,7 @@ void RENDER_3D_RAYTRACE::rt_render_trace_block( GLubyte* ptrPBO, signed int iBlo
for( unsigned int x = 0; x < RAYPACKET_DIM; ++x )
{
m_postshader_ssao.SetPixelData( blockPos.x + x, yBlockPos,
m_postShaderSsao.SetPixelData( blockPos.x + x, yBlockPos,
SFVEC3F( 0.0f ), outColor,
SFVEC3F( 0.0f ), 0, 1.0f );
}
@ -692,7 +687,7 @@ void RENDER_3D_RAYTRACE::rt_render_trace_block( GLubyte* ptrPBO, signed int iBlo
{
GLubyte* ptr = &ptrPBO[( yConst + x ) * 4];
rt_final_color( ptr, outColor, isFinalColor );
renderFinalColor( ptr, outColor, isFinalColor );
}
}
@ -704,7 +699,7 @@ void RENDER_3D_RAYTRACE::rt_render_trace_block( GLubyte* ptrPBO, signed int iBlo
SFVEC3F hitColor_X0Y0[RAYPACKET_RAYS_PER_PACKET];
// Shade original (0, 0) hits ("paint" the intersected objects)
rt_shades_packet( bgColor, blockPacket.m_ray, hitPacket_X0Y0,
renderRayPackets( bgColor, blockPacket.m_ray, hitPacket_X0Y0,
m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ), hitColor_X0Y0 );
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING ) )
@ -733,7 +728,7 @@ void RENDER_3D_RAYTRACE::rt_render_trace_block( GLubyte* ptrPBO, signed int iBlo
}
else
{
rt_shades_packet( bgColor, blockPacket_AA_X1Y1.m_ray, hitPacket_AA_X1Y1,
renderRayPackets( bgColor, blockPacket_AA_X1Y1.m_ray, hitPacket_AA_X1Y1,
m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ),
hitColor_AA_X1Y1 );
}
@ -768,14 +763,14 @@ void RENDER_3D_RAYTRACE::rt_render_trace_block( GLubyte* ptrPBO, signed int iBlo
m_camera, (SFVEC2F) blockPosI + SFVEC2F( 0.25f - DISP_FACTOR, 0.25f - DISP_FACTOR ),
SFVEC2F( DISP_FACTOR, DISP_FACTOR ), blockRayPck_AA_X1Y1_half );
rt_trace_AA_packet( bgColor, hitPacket_X0Y0, hitPacket_AA_X1Y1, blockRayPck_AA_X1Y0,
renderAnitAliasPackets( bgColor, hitPacket_X0Y0, hitPacket_AA_X1Y1, blockRayPck_AA_X1Y0,
hitColor_AA_X1Y0 );
rt_trace_AA_packet( bgColor, hitPacket_X0Y0, hitPacket_AA_X1Y1, blockRayPck_AA_X0Y1,
renderAnitAliasPackets( bgColor, hitPacket_X0Y0, hitPacket_AA_X1Y1, blockRayPck_AA_X0Y1,
hitColor_AA_X0Y1 );
rt_trace_AA_packet( bgColor, hitPacket_X0Y0, hitPacket_AA_X1Y1, blockRayPck_AA_X1Y1_half,
hitColor_AA_X0Y1_half );
renderAnitAliasPackets( bgColor, hitPacket_X0Y0, hitPacket_AA_X1Y1,
blockRayPck_AA_X1Y1_half, hitColor_AA_X0Y1_half );
// Average the result
for( unsigned int i = 0; i < RAYPACKET_RAYS_PER_PACKET; ++i )
@ -805,7 +800,7 @@ void RENDER_3D_RAYTRACE::rt_render_trace_block( GLubyte* ptrPBO, signed int iBlo
const SFVEC3F& hColor = hitColor_X0Y0[i];
if( hitPacket_X0Y0[i].m_hitresult == true )
m_postshader_ssao.SetPixelData( bPos.x, bPos.y,
m_postShaderSsao.SetPixelData( bPos.x, bPos.y,
hitPacket_X0Y0[i].m_HitInfo.m_HitNormal,
hColor,
blockPacket.m_ray[i].at(
@ -813,14 +808,10 @@ void RENDER_3D_RAYTRACE::rt_render_trace_block( GLubyte* ptrPBO, signed int iBlo
hitPacket_X0Y0[i].m_HitInfo.m_tHit,
hitPacket_X0Y0[i].m_HitInfo.m_ShadowFactor );
else
m_postshader_ssao.SetPixelData( bPos.x, bPos.y,
SFVEC3F( 0.0f ),
hColor,
SFVEC3F( 0.0f ),
0,
1.0f );
m_postShaderSsao.SetPixelData( bPos.x, bPos.y, SFVEC3F( 0.0f ), hColor,
SFVEC3F( 0.0f ), 0, 1.0f );
rt_final_color( ptr, hColor, false );
renderFinalColor( ptr, hColor, false );
bPos.x++;
ptr += 4;
@ -836,7 +827,7 @@ void RENDER_3D_RAYTRACE::rt_render_trace_block( GLubyte* ptrPBO, signed int iBlo
{
for( unsigned int x = 0; x < RAYPACKET_DIM; ++x, ++i )
{
rt_final_color( ptr, hitColor_X0Y0[i], true );
renderFinalColor( ptr, hitColor_X0Y0[i], true );
ptr += 4;
}
@ -846,7 +837,7 @@ void RENDER_3D_RAYTRACE::rt_render_trace_block( GLubyte* ptrPBO, signed int iBlo
}
void RENDER_3D_RAYTRACE::rt_render_post_process_shade( GLubyte* ptrPBO, REPORTER* aStatusReporter )
void RENDER_3D_RAYTRACE::postProcessShading( GLubyte* ptrPBO, REPORTER* aStatusReporter )
{
(void)ptrPBO; // unused
@ -855,7 +846,7 @@ void RENDER_3D_RAYTRACE::rt_render_post_process_shade( GLubyte* ptrPBO, REPORTER
if( aStatusReporter )
aStatusReporter->Report( _( "Rendering: Post processing shader" ) );
m_postshader_ssao.SetShadowsEnabled(
m_postShaderSsao.SetShadowsEnabled(
m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ) );
std::atomic<size_t> nextBlock( 0 );
@ -867,15 +858,14 @@ void RENDER_3D_RAYTRACE::rt_render_post_process_shade( GLubyte* ptrPBO, REPORTER
{
std::thread t = std::thread( [&]()
{
for( size_t y = nextBlock.fetch_add( 1 );
y < m_realBufferSize.y;
for( size_t y = nextBlock.fetch_add( 1 ); y < m_realBufferSize.y;
y = nextBlock.fetch_add( 1 ) )
{
SFVEC3F* ptr = &m_shaderBuffer[ y * m_realBufferSize.x ];
for( signed int x = 0; x < (int)m_realBufferSize.x; ++x )
{
*ptr = m_postshader_ssao.Shade( SFVEC2I( x, y ) );
*ptr = m_postShaderSsao.Shade( SFVEC2I( x, y ) );
ptr++;
}
}
@ -889,21 +879,20 @@ void RENDER_3D_RAYTRACE::rt_render_post_process_shade( GLubyte* ptrPBO, REPORTER
while( threadsFinished < parallelThreadCount )
std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
m_postshader_ssao.SetShadedBuffer( m_shaderBuffer );
m_postShaderSsao.SetShadedBuffer( m_shaderBuffer );
// Set next state
m_rt_render_state = RT_RENDER_STATE_POST_PROCESS_BLUR_AND_FINISH;
m_renderState = RT_RENDER_STATE_POST_PROCESS_BLUR_AND_FINISH;
}
else
{
// As this was an invalid state, set to finish
m_rt_render_state = RT_RENDER_STATE_FINISH;
m_renderState = RT_RENDER_STATE_FINISH;
}
}
void RENDER_3D_RAYTRACE::rt_render_post_process_blur_finish( GLubyte* ptrPBO,
REPORTER* aStatusReporter )
void RENDER_3D_RAYTRACE::postProcessBlurFinish( GLubyte* ptrPBO, REPORTER* aStatusReporter )
{
(void) aStatusReporter; //unused
@ -926,19 +915,19 @@ void RENDER_3D_RAYTRACE::rt_render_post_process_blur_finish( GLubyte* ptrPBO,
for( signed int x = 0; x < (int)m_realBufferSize.x; ++x )
{
const SFVEC3F bluredShadeColor = m_postshader_ssao.Blur( SFVEC2I( x, y ) );
const SFVEC3F bluredShadeColor = m_postShaderSsao.Blur( SFVEC2I( x, y ) );
#ifdef USE_SRGB_SPACE
const SFVEC3F originColor = convertLinearToSRGB(
m_postshader_ssao.GetColorAtNotProtected( SFVEC2I( x, y ) ) );
m_postShaderSsao.GetColorAtNotProtected( SFVEC2I( x, y ) ) );
#else
const SFVEC3F originColor =
m_postshader_ssao.GetColorAtNotProtected( SFVEC2I( x, y ) );
m_postShaderSsao.GetColorAtNotProtected( SFVEC2I( x, y ) );
#endif
const SFVEC3F shadedColor = m_postshader_ssao.ApplyShadeColor(
const SFVEC3F shadedColor = m_postShaderSsao.ApplyShadeColor(
SFVEC2I( x, y ), originColor, bluredShadeColor );
rt_final_color( ptr, shadedColor, false );
renderFinalColor( ptr, shadedColor, false );
ptr += 4;
}
@ -954,15 +943,15 @@ void RENDER_3D_RAYTRACE::rt_render_post_process_blur_finish( GLubyte* ptrPBO,
std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
// Debug code
//m_postshader_ssao.DebugBuffersOutputAsImages();
//m_postShaderSsao.DebugBuffersOutputAsImages();
}
// End rendering
m_rt_render_state = RT_RENDER_STATE_FINISH;
m_renderState = RT_RENDER_STATE_FINISH;
}
void RENDER_3D_RAYTRACE::render_preview( GLubyte* ptrPBO )
void RENDER_3D_RAYTRACE::renderPreview( GLubyte* ptrPBO )
{
m_isPreview = true;
@ -1515,9 +1504,10 @@ void RENDER_3D_RAYTRACE::render_preview( GLubyte* ptrPBO )
}
// Set pixel colors
GLubyte* ptr = &ptrPBO[ (4 * x + m_blockPositionsFast[iBlock].x +
m_realBufferSize.x *
(m_blockPositionsFast[iBlock].y + 4 * y)) * 4 ];
GLubyte* ptr =
&ptrPBO[( 4 * x + m_blockPositionsFast[iBlock].x
+ m_realBufferSize.x
* ( m_blockPositionsFast[iBlock].y + 4 * y ) ) * 4];
SetPixel( ptr + 0, cLT );
SetPixel( ptr + 4, BlendColor( cLT, cLRT, cLTC ) );
SetPixel( ptr + 8, cLRT );
@ -1599,14 +1589,6 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
if( m_isPreview )
colorOfLight = SFVEC3F( 1.0f );
/*
if( (!m_isPreview) &&
// Little hack to make randomness to the shading and shadows
m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) )
vectorToLight = glm::normalize( vectorToLight +
UniformRandomHemisphereDirection() * 0.1f );
*/
const float NdotL = glm::dot( aHitInfo.m_HitNormal, vectorToLight );
// Only calc shade if the normal is facing the direction of light,
@ -1637,7 +1619,7 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
{
const unsigned int shadow_number_of_samples =
m_boardAdapter.m_raytrace_nrsamples_shadows;
m_boardAdapter.m_RtShadowSampleCount;
const float shadow_inc_factor = 1.0f / (float) ( shadow_number_of_samples );
for( unsigned int i = 0; i < shadow_number_of_samples; ++i )
@ -1653,7 +1635,7 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
const SFVEC3F unifVector = UniformRandomHemisphereDirection();
const SFVEC3F disturbed_vector_to_light =
glm::normalize( vectorToLight + unifVector *
m_boardAdapter.m_raytrace_spread_shadows );
m_boardAdapter.m_RtSpreadShadows );
rayToLight.Init( hitPoint, disturbed_vector_to_light );
}
@ -1683,8 +1665,8 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
// Improvement: this is not taking in account the lightcolor
if( nr_lights_that_can_cast_shadows > 0 )
{
aHitInfo.m_ShadowFactor = glm::max( shadow_att_factor_sum /
(float)(nr_lights_that_can_cast_shadows * 1.0f), 0.0f );
aHitInfo.m_ShadowFactor = glm::max(
shadow_att_factor_sum / (float) ( nr_lights_that_can_cast_shadows * 1.0f ), 0.0f );
}
else
{
@ -1699,10 +1681,10 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
// Reflections
if( ( objMaterial->GetReflection() > 0.0f )
&& m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_REFLECTIONS )
&& ( aRecursiveLevel < objMaterial->GetReflectionsRecursiveLevel() ) )
&& ( aRecursiveLevel < objMaterial->GetReflectionRecursionCount() ) )
{
const unsigned int reflection_number_of_samples =
objMaterial->GetNrReflectionsSamples();
objMaterial->GetReflectionRayCount();
SFVEC3F sum_color = SFVEC3F( 0.0f );
@ -1723,7 +1705,7 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
const SFVEC3F random_reflectVector =
glm::normalize( reflectVector +
UniformRandomHemisphereDirection() *
m_boardAdapter.m_raytrace_spread_reflections );
m_boardAdapter.m_RtSpreadReflections );
reflectedRay.Init( hitPoint, random_reflectVector );
}
@ -1750,7 +1732,7 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
const float objTransparency = aHitInfo.pHitObject->GetModelTransparency();
if( ( objTransparency > 0.0f ) && m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_REFRACTIONS )
&& ( aRecursiveLevel < objMaterial->GetRefractionsRecursiveLevel() ) )
&& ( aRecursiveLevel < objMaterial->GetRefractionRecursionCount() ) )
{
const float airIndex = 1.000293f;
const float glassIndex = 1.49f;
@ -1770,7 +1752,7 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
0.25f );
const unsigned int refractions_number_of_samples =
objMaterial->GetNrRefractionsSamples();
objMaterial->GetRefractionRayCount();
SFVEC3F sum_color = SFVEC3F(0.0f);
@ -1788,7 +1770,7 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
const SFVEC3F randomizeRefractedVector =
glm::normalize( refractedVector +
UniformRandomHemisphereDirection() *
m_boardAdapter.m_raytrace_spread_refractions );
m_boardAdapter.m_RtSpreadRefractions );
refractedRay.Init( startPoint, randomizeRefractedVector );
}
@ -1828,27 +1810,24 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
}
}
//outColor += glm::max( -glm::dot( aHitInfo.m_HitNormal, aRay.m_Dir ), 0.0f ) *
// objMaterial->GetAmbientColor();
return outColor;
}
void RENDER_3D_RAYTRACE::initializeNewWindowSize()
{
opengl_init_pbo();
initPbo();
}
void RENDER_3D_RAYTRACE::opengl_init_pbo()
void RENDER_3D_RAYTRACE::initPbo()
{
if( GLEW_ARB_pixel_buffer_object )
{
m_opengl_support_vertex_buffer_object = true;
m_openglSupportsVertexBufferObjects = true;
// Try to delete vbo if it was already initialized
opengl_delete_pbo();
deletePbo();
// Learn about Pixel buffer objects at:
// http://www.songho.ca/opengl/gl_pbo.html
@ -1886,7 +1865,7 @@ static float distance( const SFVEC2UI& a, const SFVEC2UI& b )
}
void RENDER_3D_RAYTRACE::initialize_block_positions()
void RENDER_3D_RAYTRACE::initializeBlockPositions()
{
m_realBufferSize = SFVEC2UI( 0 );
@ -1930,8 +1909,7 @@ void RENDER_3D_RAYTRACE::initialize_block_positions()
m_xoffset = ( m_windowSize.x - m_realBufferSize.x ) / 2;
m_yoffset = ( m_windowSize.y - m_realBufferSize.y ) / 2;
m_postshader_ssao.UpdateSize( m_realBufferSize );
m_postShaderSsao.UpdateSize( m_realBufferSize );
// Calc block positions for regular rendering. Choose an 'inside out' style of rendering.
m_blockPositions.clear();
@ -1956,7 +1934,7 @@ void RENDER_3D_RAYTRACE::initialize_block_positions()
delete[] m_shaderBuffer;
m_shaderBuffer = new SFVEC3F[m_realBufferSize.x * m_realBufferSize.y];
opengl_init_pbo();
initPbo();
}

View File

@ -76,23 +76,23 @@ public:
private:
bool initializeOpenGL();
void initializeNewWindowSize();
void opengl_init_pbo();
void opengl_delete_pbo();
void initPbo();
void deletePbo();
void createItemsFromContainer( const BVH_CONTAINER_2D* aContainer2d, PCB_LAYER_ID aLayer_id,
const MATERIAL* aMaterialLayer, const SFVEC3F& aLayerColor,
float aLayerZOffset );
void restart_render_state();
void rt_render_tracing( GLubyte* ptrPBO, REPORTER* aStatusReporter );
void rt_render_post_process_shade( GLubyte* ptrPBO, REPORTER* aStatusReporter );
void rt_render_post_process_blur_finish( GLubyte* ptrPBO, REPORTER* aStatusReporter );
void rt_render_trace_block( GLubyte* ptrPBO , signed int iBlock );
void rt_final_color( GLubyte* ptrPBO, const SFVEC3F& rgbColor, bool applyColorSpaceConversion );
void restartRenderState();
void renderTracing( GLubyte* ptrPBO, REPORTER* aStatusReporter );
void postProcessShading( GLubyte* ptrPBO, REPORTER* aStatusReporter );
void postProcessBlurFinish( GLubyte* ptrPBO, REPORTER* aStatusReporter );
void renderBlockTracing( GLubyte* ptrPBO , signed int iBlock );
void renderFinalColor( GLubyte* ptrPBO, const SFVEC3F& rgbColor, bool applyColorSpaceConversion );
void rt_shades_packet( const SFVEC3F* bgColorY, const RAY* aRayPkt, HITINFO_PACKET* aHitPacket,
void renderRayPackets( const SFVEC3F* bgColorY, const RAY* aRayPkt, HITINFO_PACKET* aHitPacket,
bool is_testShadow, SFVEC3F* aOutHitColor );
void rt_trace_AA_packet( const SFVEC3F* aBgColorY, const HITINFO_PACKET* aHitPck_X0Y0,
void renderAnitAliasPackets( const SFVEC3F* aBgColorY, const HITINFO_PACKET* aHitPck_X0Y0,
const HITINFO_PACKET* aHitPck_AA_X1Y1, const RAY* aRayPck,
SFVEC3F* aOutHitColor );
@ -109,24 +109,23 @@ private:
* It tries to optimize some types of objects that will be faster to trace than the
* LAYER_ITEM object.
*/
void create_3d_object_from( CONTAINER_3D& aDstContainer, const OBJECT_2D* aObject2D,
float aZMin, float aZMax, const MATERIAL* aMaterial,
const SFVEC3F& aObjColor );
void createObject( CONTAINER_3D& aDstContainer, const OBJECT_2D* aObject2D, float aZMin,
float aZMax, const MATERIAL* aMaterial, const SFVEC3F& aObjColor );
void add_3D_vias_and_pads_to_container();
void insert3DViaHole( const VIA* aVia );
void insert3DPadHole( const PAD* aPad );
void load_3D_models( CONTAINER_3D& aDstContainer, bool aSkipMaterialInformation );
void add_3D_models( CONTAINER_3D& aDstContainer, const S3DMODEL* a3DModel,
void addPadsAndVias();
void insertHole( const VIA* aVia );
void insertHole( const PAD* aPad );
void loadModels( CONTAINER_3D& aDstContainer, bool aSkipMaterialInformation );
void addModels( CONTAINER_3D& aDstContainer, const S3DMODEL* a3DModel,
const glm::mat4& aModelMatrix, float aFPOpacity,
bool aSkipMaterialInformation, BOARD_ITEM* aBoardItem );
MODEL_MATERIALS* get_3D_model_material( const S3DMODEL* a3DModel );
MODEL_MATERIALS* getModelMaterial( const S3DMODEL* a3DModel );
void initialize_block_positions();
void initializeBlockPositions();
void render( GLubyte* ptrPBO, REPORTER* aStatusReporter );
void render_preview( GLubyte* ptrPBO );
void renderPreview( GLubyte* ptrPBO );
struct
{
@ -139,41 +138,40 @@ private:
BLINN_PHONG_MATERIAL m_Floor;
} m_materials;
BOARD_NORMAL m_board_normal_perturbator;
COPPER_NORMAL m_copper_normal_perturbator;
PLATED_COPPER_NORMAL m_platedcopper_normal_perturbator;
SOLDER_MASK_NORMAL m_solder_mask_normal_perturbator;
PLASTIC_NORMAL m_plastic_normal_perturbator;
PLASTIC_SHINE_NORMAL m_plastic_shine_normal_perturbator;
BRUSHED_METAL_NORMAL m_brushed_metal_normal_perturbator;
SILK_SCREEN_NORMAL m_silkscreen_normal_perturbator;
BOARD_NORMAL m_boardMaterial;
COPPER_NORMAL m_copperMaterial;
PLATED_COPPER_NORMAL m_platedCopperMaterial;
SOLDER_MASK_NORMAL m_solderMaskMaterial;
PLASTIC_NORMAL m_plasticMaterial;
PLASTIC_SHINE_NORMAL m_shinyPlasticMaterial;
BRUSHED_METAL_NORMAL m_brushedMetalMaterial;
SILK_SCREEN_NORMAL m_silkScreenMaterial;
bool m_isPreview;
/// State used on quality render
RT_RENDER_STATE m_rt_render_state;
RT_RENDER_STATE m_renderState;
/// Time that the render starts
unsigned long int m_stats_start_rendering_time;
unsigned long int m_renderStartTime;
/// Save the number of blocks progress of the render
size_t m_nrBlocksRenderProgress;
size_t m_blockRenderProgressCount;
POST_SHADER_SSAO m_postshader_ssao;
POST_SHADER_SSAO m_postShaderSsao;
LIGHT_SOURCES m_lights;
DIRECTIONAL_LIGHT* m_camera_light;
DIRECTIONAL_LIGHT* m_cameraLight;
bool m_opengl_support_vertex_buffer_object;
bool m_openglSupportsVertexBufferObjects;
GLuint m_pboId;
GLuint m_pboDataSize;
CONTAINER_3D m_object_container;
CONTAINER_3D m_objectContainer;
/// This will store the list of created objects special for RT,
/// that will be clear in the end
///< Store the list of created objects special for RT that will be clear in the end.
CONTAINER_2D m_containerWithObjectsToDelete;
CONTAINER_2D* m_outlineBoard2dObjects;
@ -181,21 +179,19 @@ private:
ACCELERATOR_3D* m_accelerator;
SFVEC3F m_BgColorTop_LinearRGB;
SFVEC3F m_BgColorBot_LinearRGB;
SFVEC3F m_backgroundColorTop;
SFVEC3F m_backgroundColorBottom;
// Morton codes
/// used to see if the windows size changed
///< Used to see if the windows size changed.
wxSize m_oldWindowsSize;
/// this encodes the Morton code positions
///< Encode Morton code positions.
std::vector< SFVEC2UI > m_blockPositions;
/// this flags if a position was already processed (cleared each new render)
///< Flag if a position was already processed (cleared each new render).
std::vector< int > m_blockPositionsWasProcessed;
/// this encodes the Morton code positions (on fast preview mode)
///< Encode the Morton code positions (on fast preview mode).
std::vector< SFVEC2UI > m_blockPositionsFast;
SFVEC2UI m_realBufferSize;
@ -210,11 +206,11 @@ private:
unsigned int m_yoffset;
/// Stores materials of the 3D models
MAP_MODEL_MATERIALS m_model_materials;
MAP_MODEL_MATERIALS m_modelMaterialMap;
// Statistics
unsigned int m_stats_converted_dummy_to_plane;
unsigned int m_stats_converted_roundsegment2d_to_roundsegment;
unsigned int m_convertedDummyBlockCount;
unsigned int m_converted2dRoundSegmentCount;
};
#define USE_SRGB_SPACE

View File

@ -304,7 +304,7 @@ bool BBOX_2D::Intersect( const RAY2D& aRay, float* aOutHitT0, float* aOutHitT1 )
tmin = glm::max( tmin, glm::min( ty1, ty2 ) );
tmax = glm::min( tmax, glm::max( ty1, ty2 ) );
*aOutHitT0 = (tmin > 0.0f)?tmin:0.0f;
*aOutHitT0 = ( tmin > 0.0f ) ? tmin : 0.0f;
*aOutHitT1 = tmax;
return ( tmax >= 0.0f ) && ( tmax >= tmin );

View File

@ -54,7 +54,7 @@ FILLED_CIRCLE_2D::FILLED_CIRCLE_2D( const SFVEC2F& aCenter, float aRadius,
bool FILLED_CIRCLE_2D::Overlaps( const BBOX_2D& aBBox ) const
{
// NOT IMPLEMENTED
// NOT IMPLEMENTED, why?
return false;
}
@ -85,15 +85,13 @@ bool FILLED_CIRCLE_2D::Intersect( const RAYSEG2D& aSegRay, float* aOutT, SFVEC2F
if( discriminantsqr < FLT_EPSILON )
return false;
// Otherwise check and make sure that the intersections occur on the ray (t
// > 0) and return the closer one
// Otherwise check and make sure that the intersections occur on the ray (t > 0) and
// return the closer one.
const float discriminant = sqrt( discriminantsqr );
const float t1 = ( -qd - discriminant );
const float t2 = ( -qd + discriminant );
float t;
if( ( t1 > 0.0f ) && ( t1 < aSegRay.m_Length ) )
{
t = t1;

View File

@ -70,7 +70,7 @@ bool LAYER_ITEM_2D::Intersects( const BBOX_2D& aBBox ) const
bool LAYER_ITEM_2D::Overlaps( const BBOX_2D& aBBox ) const
{
// NOT IMPLEMENTED
// NOT IMPLEMENTED, why?
return false;
}
@ -90,6 +90,7 @@ bool LAYER_ITEM_2D::Intersect( const RAYSEG2D& aSegRay, float* aOutT, SFVEC2F* a
{
//move ray point to start of main object
float tmpRayDist;
if( !m_objectA->Intersect( aSegRay, &tmpRayDist, &currentNormal ) )
return false;
@ -98,8 +99,6 @@ bool LAYER_ITEM_2D::Intersect( const RAYSEG2D& aSegRay, float* aOutT, SFVEC2F* a
currentRay = RAYSEG2D( currentRayPos, aSegRay.m_End );
}
//wxASSERT( (currentRayDist >= 0.0f) && (currentRayDist <= 1.0f) );
// move through the union of subtracted regions
if( m_objectB )
{
@ -116,6 +115,7 @@ bool LAYER_ITEM_2D::Intersect( const RAYSEG2D& aSegRay, float* aOutT, SFVEC2F* a
// subtracted region
float hitDist;
SFVEC2F tmpNormal;
if( !( (const OBJECT_2D*) ( *m_objectB )[i] )
->Intersect( currentRay, &hitDist, &tmpNormal ) )
return false; // ray hit main object but did not leave subtracted volume

View File

@ -62,7 +62,7 @@ static bool polygon_IsPointInside( const SEGMENTS& aSegments, const SFVEC2F& aPo
POLYGON_2D::POLYGON_2D( const SEGMENTS_WIDTH_NORMALS& aOpenSegmentList,
const OUTERS_AND_HOLES& aOuter_and_holes, const BOARD_ITEM& aBoardItem )
const OUTERS_AND_HOLES& aOuterAndHoles, const BOARD_ITEM& aBoardItem )
: OBJECT_2D( OBJECT_2D_TYPE::POLYGON, aBoardItem )
{
m_open_segments.resize( aOpenSegmentList.size() );
@ -71,7 +71,7 @@ POLYGON_2D::POLYGON_2D( const SEGMENTS_WIDTH_NORMALS& aOpenSegmentList,
for( unsigned int i = 0; i < aOpenSegmentList.size(); i++ )
m_open_segments[i] = aOpenSegmentList[i];
m_outers_and_holes = aOuter_and_holes;
m_outers_and_holes = aOuterAndHoles;
// Compute bounding box with the points of the polygon
m_bbox.Reset();
@ -90,11 +90,11 @@ POLYGON_2D::POLYGON_2D( const SEGMENTS_WIDTH_NORMALS& aOpenSegmentList,
wxASSERT( m_open_segments.size() > 0 );
wxASSERT( m_outers_and_holes.m_Outers.size() > 0 );
wxASSERT( m_outers_and_holes.m_Outers.size() == aOuter_and_holes.m_Outers.size() );
wxASSERT( m_outers_and_holes.m_Holes.size() == aOuter_and_holes.m_Holes.size() );
wxASSERT( m_outers_and_holes.m_Outers.size() == aOuterAndHoles.m_Outers.size() );
wxASSERT( m_outers_and_holes.m_Holes.size() == aOuterAndHoles.m_Holes.size() );
wxASSERT( m_outers_and_holes.m_Outers[0].size() >= 3 );
wxASSERT( m_outers_and_holes.m_Outers[0].size() == aOuter_and_holes.m_Outers[0].size() );
wxASSERT( m_outers_and_holes.m_Outers[0].size() == aOuterAndHoles.m_Outers[0].size() );
wxASSERT( m_bbox.IsInitialized() );
}
@ -112,7 +112,7 @@ bool POLYGON_2D::Intersects( const BBOX_2D& aBBox ) const
bool POLYGON_2D::Overlaps( const BBOX_2D& aBBox ) const
{
// NOT IMPLEMENTED
// NOT IMPLEMENTED, why?
return false;
}

View File

@ -94,8 +94,7 @@ class POLYGON_2D : public OBJECT_2D
{
public:
POLYGON_2D( const SEGMENTS_WIDTH_NORMALS& aOpenSegmentList,
const OUTERS_AND_HOLES& aOuter_and_holes,
const BOARD_ITEM& aBoardItem );
const OUTERS_AND_HOLES& aOuterAndHoles, const BOARD_ITEM& aBoardItem );
bool Overlaps( const BBOX_2D& aBBox ) const override;
bool Intersects( const BBOX_2D& aBBox ) const override;

View File

@ -142,8 +142,8 @@ bool ROUND_SEGMENT_2D::Intersect( const RAYSEG2D& aSegRay, float* aOutT, SFVEC2F
SFVEC2F farHitNormal;
float leftSegT;
const bool leftSegmentHit = aSegRay.IntersectSegment( m_leftStart, m_leftEndMinusStart,
&leftSegT );
const bool leftSegmentHit =
aSegRay.IntersectSegment( m_leftStart, m_leftEndMinusStart, &leftSegT );
if( leftSegmentHit )
{
@ -156,8 +156,8 @@ bool ROUND_SEGMENT_2D::Intersect( const RAYSEG2D& aSegRay, float* aOutT, SFVEC2F
}
float rightSegT;
const bool rightSegmentHit = aSegRay.IntersectSegment( m_rightStart, m_rightEndMinusStart,
&rightSegT );
const bool rightSegmentHit =
aSegRay.IntersectSegment( m_rightStart, m_rightEndMinusStart, &rightSegT );
if( rightSegmentHit )
{

View File

@ -87,15 +87,15 @@ void BBOX_3D::Set( const BBOX_3D& aBBox )
bool BBOX_3D::IsInitialized() const
{
return !( ( FLT_MAX == m_min.x) || ( FLT_MAX == m_min.y) || ( FLT_MAX == m_min.z) ||
(-FLT_MAX == m_max.x) || (-FLT_MAX == m_max.y) || (-FLT_MAX == m_max.z) );
return !( ( FLT_MAX == m_min.x ) || ( FLT_MAX == m_min.y ) || ( FLT_MAX == m_min.z )
|| ( -FLT_MAX == m_max.x ) || ( -FLT_MAX == m_max.y ) || ( -FLT_MAX == m_max.z ) );
}
void BBOX_3D::Reset()
{
m_min = SFVEC3F( FLT_MAX, FLT_MAX, FLT_MAX );
m_max = SFVEC3F(-FLT_MAX,-FLT_MAX,-FLT_MAX );
m_max = SFVEC3F( -FLT_MAX, -FLT_MAX, -FLT_MAX );
}
@ -138,7 +138,7 @@ SFVEC3F BBOX_3D::GetCenter() const
float BBOX_3D::GetCenter( unsigned int aAxis ) const
{
wxASSERT( aAxis < 3 );
return (m_max[aAxis] + m_min[aAxis]) * 0.5f;
return ( m_max[aAxis] + m_min[aAxis] ) * 0.5f;
}
@ -263,6 +263,7 @@ SFVEC3F BBOX_3D::Offset( const SFVEC3F& p ) const
}
/// @todo Why are we keeping both implementations of Intersect()?
// Intersection code based on the book:
// "Physical Based Ray Tracing" (by Matt Pharr and Greg Humphrey)
// https://github.com/mmp/pbrt-v2/blob/master/src/core/geometry.cpp#L68
@ -312,10 +313,10 @@ bool BBOX_3D::Intersect( const RAY& aRay, float* aOutHitt0, float* aOutHitt1 ) c
const SFVEC3F bounds[2] = {m_min, m_max};
// Check for ray intersection against x and y slabs
float tmin = (bounds[ aRay.m_dirIsNeg[0]].x - aRay.m_Origin.x) * aRay.m_InvDir.x;
float tmax = (bounds[1 - aRay.m_dirIsNeg[0]].x - aRay.m_Origin.x) * aRay.m_InvDir.x;
const float tymin = (bounds[ aRay.m_dirIsNeg[1]].y - aRay.m_Origin.y) * aRay.m_InvDir.y;
const float tymax = (bounds[1 - aRay.m_dirIsNeg[1]].y - aRay.m_Origin.y) * aRay.m_InvDir.y;
float tmin = ( bounds[aRay.m_dirIsNeg[0]].x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
float tmax = ( bounds[1 - aRay.m_dirIsNeg[0]].x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
const float tymin = ( bounds[aRay.m_dirIsNeg[1]].y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
const float tymax = ( bounds[1 - aRay.m_dirIsNeg[1]].y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
if( ( tmin > tymax ) || ( tymin > tmax ) )
return false;
@ -324,8 +325,8 @@ bool BBOX_3D::Intersect( const RAY& aRay, float* aOutHitt0, float* aOutHitt1 ) c
tmax = ( tymax < tmax ) ? tymax : tmax;
// Check for ray intersection against z slab
const float tzmin = (bounds[ aRay.m_dirIsNeg[2]].z - aRay.m_Origin.z) * aRay.m_InvDir.z;
const float tzmax = (bounds[1 - aRay.m_dirIsNeg[2]].z - aRay.m_Origin.z) * aRay.m_InvDir.z;
const float tzmin = ( bounds[aRay.m_dirIsNeg[2]].z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
const float tzmax = ( bounds[1 - aRay.m_dirIsNeg[2]].z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
if( ( tmin > tzmax ) || ( tzmin > tmax ) )
return false;

View File

@ -103,11 +103,10 @@ bool CYLINDER::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
const SFVEC2F hitPoint2D = SFVEC2F( aHitInfo.m_HitPoint.x, aHitInfo.m_HitPoint.y );
aHitInfo.m_HitNormal = SFVEC3F( -(hitPoint2D.x - m_center.x) * m_inv_radius,
-(hitPoint2D.y - m_center.y) * m_inv_radius,
0.0f );
aHitInfo.m_HitNormal = SFVEC3F( -( hitPoint2D.x - m_center.x ) * m_inv_radius,
-( hitPoint2D.y - m_center.y ) * m_inv_radius, 0.0f );
m_material->PerturbeNormal( aHitInfo.m_HitNormal, aRay, aHitInfo );
m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
aHitInfo.pHitObject = this;
}
@ -138,7 +137,7 @@ bool CYLINDER::IntersectP(const RAY& aRay , float aMaxDistance ) const
const float inv_a = 1.0 / a;
const float sdelta = sqrtf( delta );
const float t = (-b - sdelta) * inv_a;
const float t = ( -b - sdelta ) * inv_a;
const float z = aRay.m_Origin.z + t * aRay.m_Dir.z;
if( ( z >= m_bbox.Min().z ) && ( z <= m_bbox.Max().z ) )
@ -147,7 +146,7 @@ bool CYLINDER::IntersectP(const RAY& aRay , float aMaxDistance ) const
return true;
}
const float t1 = (-b + sdelta) * inv_a;
const float t1 = ( -b + sdelta ) * inv_a;
const float z1 = aRay.m_Origin.z + t1 * aRay.m_Dir.z;
if( ( z1 > m_bbox.Min().z ) && ( z1 < m_bbox.Max().z ) )

View File

@ -55,7 +55,7 @@ bool DUMMY_BLOCK::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
else
aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f,-1.0f );
m_material->PerturbeNormal( aHitInfo.m_HitNormal, aRay, aHitInfo );
m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
aHitInfo.pHitObject = this;

View File

@ -77,8 +77,8 @@ bool LAYER_ITEM::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
if( (float) fabs( aRay.m_Dir.z ) > FLT_EPSILON )
{
tBot = (m_bbox.Min().z - aRay.m_Origin.z) * aRay.m_InvDir.z;
tTop = (m_bbox.Max().z - aRay.m_Origin.z) * aRay.m_InvDir.z;
tBot = ( m_bbox.Min().z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
tTop = ( m_bbox.Max().z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
float tBBoxStartAdjusted = NextFloatUp( tBBoxStart );
@ -119,7 +119,7 @@ bool LAYER_ITEM::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, -1.0f );
aHitInfo.pHitObject = this;
m_material->PerturbeNormal( aHitInfo.m_HitNormal, aRay, aHitInfo );
m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
return true;
}
@ -138,7 +138,7 @@ bool LAYER_ITEM::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, 1.0f );
aHitInfo.pHitObject = this;
m_material->PerturbeNormal( aHitInfo.m_HitNormal, aRay, aHitInfo );
m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
return true;
}
@ -162,7 +162,7 @@ bool LAYER_ITEM::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, 1.0f );
aHitInfo.pHitObject = this;
m_material->PerturbeNormal( aHitInfo.m_HitNormal, aRay, aHitInfo );
m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
return true;
}
@ -186,7 +186,7 @@ bool LAYER_ITEM::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, -1.0f );
aHitInfo.pHitObject = this;
m_material->PerturbeNormal( aHitInfo.m_HitNormal, aRay, aHitInfo );
m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
return true;
}
@ -239,7 +239,7 @@ bool LAYER_ITEM::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
aHitInfo.pHitObject = this;
m_material->PerturbeNormal( aHitInfo.m_HitNormal, aRay, aHitInfo );
m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
return true;
}
@ -249,7 +249,7 @@ bool LAYER_ITEM::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
}
else
{
/// @todo Either fix the code below or get rid of it.
// Disabled due to refraction artifacts
// this will mostly happen inside the board body
#if 0
@ -283,7 +283,7 @@ bool LAYER_ITEM::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
else
aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, 1.0f );
m_material->PerturbeNormal( aHitInfo.m_HitNormal, aRay, aHitInfo );
m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
return true;
}
@ -307,7 +307,7 @@ bool LAYER_ITEM::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
aHitInfo.m_HitNormal = SFVEC3F( outNormal.x, outNormal.y, 0.0f );
aHitInfo.pHitObject = this;
m_material->PerturbeNormal( aHitInfo.m_HitNormal, aRay, aHitInfo );
m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
return true;
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -61,7 +61,7 @@ XY_PLANE::XY_PLANE( SFVEC3F aCenterPoint, float aXSize, float aYSize )
bool XY_PLANE::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
{
const float t = (m_centerPoint.z - aRay.m_Origin.z) * aRay.m_InvDir.z;
const float t = ( m_centerPoint.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
if( ( t < FLT_EPSILON ) || ( t >= aHitInfo.m_tHit ) )
return false;
@ -85,7 +85,7 @@ bool XY_PLANE::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
else
aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f,-1.0f );
m_material->PerturbeNormal( aHitInfo.m_HitNormal, aRay, aHitInfo );
m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
return true;
}
@ -100,7 +100,7 @@ bool XY_PLANE::IntersectP(const RAY& aRay, float aMaxDistance ) const
const float vSU = t * aRay.m_Dir.x + aRay.m_Origin.x - m_centerPoint.x;
if( (vSU < -m_xsize) || (vSU > m_xsize) )
if( ( vSU < -m_xsize ) || ( vSU > m_xsize ) )
return false;
const float vSV = t * aRay.m_Dir.y + aRay.m_Origin.y - m_centerPoint.y;

View File

@ -84,7 +84,7 @@ bool ROUND_SEGMENT::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, aRay.m_dirIsNeg[2] ? 1.0f : -1.0f );
aHitInfo.pHitObject = this;
m_material->PerturbeNormal( aHitInfo.m_HitNormal, aRay, aHitInfo );
m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
return true;
}
@ -119,7 +119,7 @@ bool ROUND_SEGMENT::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
0.0f );
aHitInfo.pHitObject = this;
m_material->PerturbeNormal( aHitInfo.m_HitNormal, aRay, aHitInfo );
m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
return true;
}
@ -156,7 +156,7 @@ bool ROUND_SEGMENT::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
0.0f );
aHitInfo.pHitObject = this;
m_material->PerturbeNormal( aHitInfo.m_HitNormal, aRay, aHitInfo );
m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
return true;
}
@ -199,14 +199,13 @@ bool ROUND_SEGMENT::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
const SFVEC2F hitPoint2D = SFVEC2F( aHitInfo.m_HitPoint.x, aHitInfo.m_HitPoint.y );
aHitInfo.m_HitNormal = SFVEC3F(
(hitPoint2D.x - m_segment.m_Start.x) * m_inv_radius,
(hitPoint2D.y - m_segment.m_Start.y) * m_inv_radius,
0.0f );
aHitInfo.m_HitNormal =
SFVEC3F( ( hitPoint2D.x - m_segment.m_Start.x ) * m_inv_radius,
( hitPoint2D.y - m_segment.m_Start.y ) * m_inv_radius, 0.0f );
aHitInfo.pHitObject = this;
m_material->PerturbeNormal( aHitInfo.m_HitNormal, aRay, aHitInfo );
m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
return true;
}
@ -242,13 +241,12 @@ bool ROUND_SEGMENT::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
const SFVEC2F hitPoint2D = SFVEC2F( aHitInfo.m_HitPoint.x, aHitInfo.m_HitPoint.y );
aHitInfo.m_HitNormal = SFVEC3F(
(hitPoint2D.x - m_segment.m_End.x) * m_inv_radius,
(hitPoint2D.y - m_segment.m_End.y) * m_inv_radius,
0.0f );
aHitInfo.m_HitNormal =
SFVEC3F( ( hitPoint2D.x - m_segment.m_End.x ) * m_inv_radius,
( hitPoint2D.y - m_segment.m_End.y ) * m_inv_radius, 0.0f );
aHitInfo.pHitObject = this;
m_material->PerturbeNormal( aHitInfo.m_HitNormal, aRay, aHitInfo );
m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
return true;
}
@ -287,6 +285,8 @@ bool ROUND_SEGMENT::IntersectP( const RAY& aRay, float aMaxDistance ) const
// Since the IntersectP is used for shadows, we are simplifying the test
// intersection and only consider the top/bottom plane of the segment
return false;
/// @todo Either fix the code below or get rid of it.
#if 0
// Test LEFT / RIGHT plane
float normal_dot_ray = glm::dot( m_plane_dir_right, aRay.m_Dir );

View File

@ -157,9 +157,7 @@ void TRIANGLE::SetColor( const SFVEC3F& aColor )
}
void TRIANGLE::SetColor( const SFVEC3F& aVC0,
const SFVEC3F& aVC1,
const SFVEC3F& aVC2 )
void TRIANGLE::SetColor( const SFVEC3F& aVC0, const SFVEC3F& aVC1, const SFVEC3F& aVC2 )
{
m_vertexColorRGBA[0] = ( (unsigned int) ( aVC0.r * 255 ) << 24 )
| ( (unsigned int) ( aVC0.g * 255 ) << 16 )
@ -212,7 +210,7 @@ bool TRIANGLE::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
const SFVEC3F& A = m_vertex[0];
const float lnd = 1.0f / (D[m_k] + m_nu * D[ku] + m_nv * D[kv]);
const float t = (m_nd - O[m_k] - m_nu * O[ku] - m_nv * O[kv]) * lnd;
const float t = ( m_nd - O[m_k] - m_nu * O[ku] - m_nv * O[kv] ) * lnd;
if( !( ( aHitInfo.m_tHit > t ) && ( t > 0.0f ) ) )
return false;
@ -242,10 +240,10 @@ bool TRIANGLE::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
aHitInfo.m_HitPoint = aRay.at( t );
// interpolate vertex normals with UVW using Gouraud's shading
aHitInfo.m_HitNormal = glm::normalize( (1.0f - u - v) * m_normal[0] + u * m_normal[1] +
v * m_normal[2] );
aHitInfo.m_HitNormal =
glm::normalize( ( 1.0f - u - v ) * m_normal[0] + u * m_normal[1] + v * m_normal[2] );
m_material->PerturbeNormal( aHitInfo.m_HitNormal, aRay, aHitInfo );
m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
aHitInfo.pHitObject = this;
@ -266,7 +264,7 @@ bool TRIANGLE::IntersectP( const RAY& aRay, float aMaxDistance ) const
const SFVEC3F A = m_vertex[0];
const float lnd = 1.0f / (D[m_k] + m_nu * D[ku] + m_nv * D[kv]);
const float t = (m_nd - O[m_k] - m_nu * O[ku] - m_nv * O[kv]) * lnd;
const float t = ( m_nd - O[m_k] - m_nu * O[ku] - m_nv * O[kv] ) * lnd;
if( !( ( aMaxDistance > t ) && ( t > 0.0f ) ) )
return false;

View File

@ -136,8 +136,7 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode )
{
const auto& mesh = a3DModel.m_Meshes[mesh_i];
// silently ignore meshes that have invalid material references
// or invalid geometry.
// silently ignore meshes that have invalid material references or invalid geometry.
if( mesh.m_MaterialIdx >= m_materials.size()
|| mesh.m_Positions == nullptr
|| mesh.m_FaceIdx == nullptr
@ -439,15 +438,15 @@ void MODEL_3D::Draw( bool aTransparent, float aOpacity, bool aUseSelectedMateria
switch( m_materialMode )
{
case MATERIAL_MODE::NORMAL:
OGL_SetMaterial( mat, aOpacity, aUseSelectedMaterial, aSelectionColor );
OglSetMaterial( mat, aOpacity, aUseSelectedMaterial, aSelectionColor );
break;
case MATERIAL_MODE::DIFFUSE_ONLY:
OGL_SetDiffuseOnlyMaterial( mat.m_Diffuse, aOpacity );
OglSetDiffuseMaterial( mat.m_Diffuse, aOpacity );
break;
case MATERIAL_MODE::CAD_MODE:
OGL_SetDiffuseOnlyMaterial( MaterialDiffuseToColorCAD( mat.m_Diffuse ), aOpacity );
OglSetDiffuseMaterial( MaterialDiffuseToColorCAD( mat.m_Diffuse ), aOpacity );
break;
default:

View File

@ -58,7 +58,6 @@ RENDER_3D_LEGACY::RENDER_3D_LEGACY( BOARD_ADAPTER& aAdapter, CAMERA& aCamera ) :
m_outerViaThroughHoles = nullptr;
m_vias = nullptr;
m_padHoles = nullptr;
m_vias_and_pad_holes_outer_contourn_and_caps = nullptr;
m_circleTexture = 0;
m_grid = 0;
@ -142,9 +141,8 @@ void RENDER_3D_LEGACY::render3dArrows()
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
const glm::mat4 TranslationMatrix = glm::translate( glm::mat4(1.0f),
SFVEC3F( 0.0f, 0.0f,
-(arrow_size * 2.75f) ) );
const glm::mat4 TranslationMatrix =
glm::translate( glm::mat4( 1.0f ), SFVEC3F( 0.0f, 0.0f, -( arrow_size * 2.75f ) ) );
const glm::mat4 ViewMatrix = TranslationMatrix * m_camera.GetRotationMatrix();
@ -336,24 +334,24 @@ void RENDER_3D_LEGACY::setLayerMaterial( PCB_LAYER_ID aLayerID )
m_materials.m_SolderMask.m_Diffuse * m_materials.m_SolderMask.m_Diffuse;
}
OGL_SetMaterial( m_materials.m_SolderMask, 1.0f );
OglSetMaterial( m_materials.m_SolderMask, 1.0f );
break;
}
case B_Paste:
case F_Paste:
m_materials.m_Paste.m_Diffuse = getLayerColor( aLayerID );
OGL_SetMaterial( m_materials.m_Paste, 1.0f );
OglSetMaterial( m_materials.m_Paste, 1.0f );
break;
case B_SilkS:
m_materials.m_SilkSBot.m_Diffuse = getLayerColor( aLayerID );
OGL_SetMaterial( m_materials.m_SilkSBot, 1.0f );
OglSetMaterial( m_materials.m_SilkSBot, 1.0f );
break;
case F_SilkS:
m_materials.m_SilkSTop.m_Diffuse = getLayerColor( aLayerID );
OGL_SetMaterial( m_materials.m_SilkSTop, 1.0f );
OglSetMaterial( m_materials.m_SilkSTop, 1.0f );
break;
case B_Adhes:
@ -380,12 +378,12 @@ void RENDER_3D_LEGACY::setLayerMaterial( PCB_LAYER_ID aLayerID )
m_materials.m_Plastic.m_Shininess = 0.078125f * 128.0f;
m_materials.m_Plastic.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
OGL_SetMaterial( m_materials.m_Plastic, 1.0f );
OglSetMaterial( m_materials.m_Plastic, 1.0f );
break;
default:
m_materials.m_Copper.m_Diffuse = getLayerColor( aLayerID );
OGL_SetMaterial( m_materials.m_Copper, 1.0f );
OglSetMaterial( m_materials.m_Copper, 1.0f );
break;
}
}
@ -497,7 +495,7 @@ void init_lights( void )
void RENDER_3D_LEGACY::setCopperMaterial()
{
OGL_SetMaterial( m_materials.m_NonPlatedCopper, 1.0f );
OglSetMaterial( m_materials.m_NonPlatedCopper, 1.0f );
}
@ -522,7 +520,7 @@ void RENDER_3D_LEGACY::renderBoardBody( bool aSkipRenderHoles )
// opacity to transparency
m_materials.m_EpoxyBoard.m_Transparency = 1.0f - m_boardAdapter.m_BoardBodyColor.a;
OGL_SetMaterial( m_materials.m_EpoxyBoard, 1.0f );
OglSetMaterial( m_materials.m_EpoxyBoard, 1.0f );
OPENGL_RENDER_LIST* ogl_disp_list = nullptr;
@ -597,10 +595,10 @@ bool RENDER_3D_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
glClearStencil( 0x00 );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
OGL_ResetTextureStateDefaults();
OglResetTextureState();
// Draw the background ( rectangle with color gradient)
OGL_DrawBackground( SFVEC3F( m_boardAdapter.m_BgColorTop ),
OglDrawBackground( SFVEC3F( m_boardAdapter.m_BgColorTop ),
SFVEC3F( m_boardAdapter.m_BgColorBot ) );
glEnable( GL_DEPTH_TEST );
@ -657,7 +655,7 @@ bool RENDER_3D_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
}
else
{
OGL_SetMaterial( m_materials.m_GrayMaterial, 1.0f );
OglSetMaterial( m_materials.m_GrayMaterial, 1.0f );
}
if( !( skipRenderVias || skipRenderHoles ) && m_vias )
@ -672,7 +670,7 @@ bool RENDER_3D_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
const PCB_LAYER_ID layer_id = ( PCB_LAYER_ID )( ii->first );
// Mask layers are not processed here because they are a special case
if( (layer_id == B_Mask) || (layer_id == F_Mask) )
if( ( layer_id == B_Mask ) || ( layer_id == F_Mask ) )
continue;
// Do not show inner layers when it is displaying the board and board body is full opaque
@ -851,8 +849,7 @@ bool RENDER_3D_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
}
else
{
if( !skipRenderHoles
&& throughHolesOuter
if( !skipRenderHoles && throughHolesOuter
&& ( layer_id == B_SilkS || layer_id == F_SilkS ) )
{
pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments, nullptr,
@ -944,7 +941,7 @@ bool RENDER_3D_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
render3dModels( true, true );
glDisable( GL_BLEND );
OGL_ResetTextureStateDefaults();
OglResetTextureState();
glDepthMask( GL_TRUE );
@ -994,13 +991,11 @@ bool RENDER_3D_LEGACY::initializeOpenGL()
circleImage->EfxFilter( circleImage_Copy, IMAGE_FILTER::BLUR_3X3 );
m_circleTexture = OGL_LoadTexture( *circleImage );
m_circleTexture = OglLoadTexture( *circleImage );
//circleImage_Copy->SaveAsPNG("circleImage.png");
delete circleImage_Copy;
circleImage_Copy = 0;
//circleImage->SaveAsPNG("circleImage_blured.png");
delete circleImage;
circleImage = 0;
@ -1112,9 +1107,6 @@ void RENDER_3D_LEGACY::freeAllLists()
delete m_padHoles;
m_padHoles = nullptr;
delete m_vias_and_pad_holes_outer_contourn_and_caps;
m_vias_and_pad_holes_outer_contourn_and_caps = nullptr;
}
@ -1153,7 +1145,6 @@ void RENDER_3D_LEGACY::renderSolderMaskLayer( PCB_LAYER_ID aLayerID, float aZPos
else
{
// This case there is no layer with mask, so we will render the full board as mask
if( m_outerViaThroughHoles )
m_outerViaThroughHoles->ApplyScalePosition( aZPosition, nonCopperThickness );
@ -1302,12 +1293,12 @@ void RENDER_3D_LEGACY::renderFootprint( const FOOTPRINT* aFootprint, bool aRende
{
modelPtr->DrawTransparent( sM.m_Opacity,
aFootprint->IsSelected() || aIsSelected,
m_boardAdapter.m_opengl_selectionColor );
m_boardAdapter.m_OpenGlSelectionColor );
}
else
{
modelPtr->DrawOpaque( aFootprint->IsSelected() || aIsSelected,
m_boardAdapter.m_opengl_selectionColor );
m_boardAdapter.m_OpenGlSelectionColor );
}
if( m_boardAdapter.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ) )
@ -1495,8 +1486,7 @@ void RENDER_3D_LEGACY::generate3dGrid( GRID3D_TYPE aGridType )
if( ii % 5 )
glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
else
glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b,
transparency );
glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b, transparency );
const double delta = ii * griSizeMM * IU_PER_MM * scale;

View File

@ -197,7 +197,6 @@ private:
OPENGL_RENDER_LIST* m_outerThroughHoles;
OPENGL_RENDER_LIST* m_outerViaThroughHoles;
OPENGL_RENDER_LIST* m_outerThroughHoleRings;
OPENGL_RENDER_LIST* m_vias_and_pad_holes_outer_contourn_and_caps;
LIST_TRIANGLES m_triangles; ///< store pointers so can be deleted latter
GLuint m_circleTexture;

View File

@ -113,9 +113,9 @@ void DIALOG_3D_VIEW_OPTIONS::OnCheckEnableAnimation( wxCommandEvent& event )
void DIALOG_3D_VIEW_OPTIONS::OnLightsResetToDefaults( wxCommandEvent& event )
{
m_settings.m_raytrace_lightColorCamera = SFVEC3F( 0.2f );
m_settings.m_raytrace_lightColorTop = SFVEC3F( 0.247f );
m_settings.m_raytrace_lightColorBottom = SFVEC3F( 0.247f );
m_settings.m_RtCameraLightColor = SFVEC3F( 0.2f );
m_settings.m_RtLightColorTop = SFVEC3F( 0.247f );
m_settings.m_RtLightColorBottom = SFVEC3F( 0.247f );
const std::vector<int> default_elevation =
{
@ -127,14 +127,14 @@ void DIALOG_3D_VIEW_OPTIONS::OnLightsResetToDefaults( wxCommandEvent& event )
45, 135, 225, 315, 45, 135, 225, 315,
};
for( size_t i = 0; i < m_settings.m_raytrace_lightSphericalCoords.size(); ++i )
for( size_t i = 0; i < m_settings.m_RtLightSphericalCoords.size(); ++i )
{
m_settings.m_raytrace_lightColor[i] = SFVEC3F( 0.168f );
m_settings.m_RtLightColor[i] = SFVEC3F( 0.168f );
m_settings.m_raytrace_lightSphericalCoords[i].x =
( (float)default_elevation[i] + 90.0f ) / 180.0f;
m_settings.m_RtLightSphericalCoords[i].x =
( (float) default_elevation[i] + 90.0f ) / 180.0f;
m_settings.m_raytrace_lightSphericalCoords[i].y = (float)default_azimuth[i] / 180.0f;
m_settings.m_RtLightSphericalCoords[i].y = (float) default_azimuth[i] / 180.0f;
}
TransferColorDataToWindow();
@ -148,55 +148,55 @@ void DIALOG_3D_VIEW_OPTIONS::TransferColorDataToWindow()
aTarget->SetColour( wxColour( aSource.r * 255, aSource.g * 255, aSource.b * 255, 255 ) );
};
Transfer_color( m_settings.m_raytrace_lightColorCamera, m_colourPickerCameraLight );
Transfer_color( m_settings.m_raytrace_lightColorTop, m_colourPickerTopLight );
Transfer_color( m_settings.m_raytrace_lightColorBottom, m_colourPickerBottomLight );
Transfer_color( m_settings.m_RtCameraLightColor, m_colourPickerCameraLight );
Transfer_color( m_settings.m_RtLightColorTop, m_colourPickerTopLight );
Transfer_color( m_settings.m_RtLightColorBottom, m_colourPickerBottomLight );
Transfer_color( m_settings.m_raytrace_lightColor[0], m_colourPickerLight1 );
Transfer_color( m_settings.m_raytrace_lightColor[1], m_colourPickerLight2 );
Transfer_color( m_settings.m_raytrace_lightColor[2], m_colourPickerLight3 );
Transfer_color( m_settings.m_raytrace_lightColor[3], m_colourPickerLight4 );
Transfer_color( m_settings.m_RtLightColor[0], m_colourPickerLight1 );
Transfer_color( m_settings.m_RtLightColor[1], m_colourPickerLight2 );
Transfer_color( m_settings.m_RtLightColor[2], m_colourPickerLight3 );
Transfer_color( m_settings.m_RtLightColor[3], m_colourPickerLight4 );
Transfer_color( m_settings.m_raytrace_lightColor[4], m_colourPickerLight5 );
Transfer_color( m_settings.m_raytrace_lightColor[5], m_colourPickerLight6 );
Transfer_color( m_settings.m_raytrace_lightColor[6], m_colourPickerLight7 );
Transfer_color( m_settings.m_raytrace_lightColor[7], m_colourPickerLight8 );
Transfer_color( m_settings.m_RtLightColor[4], m_colourPickerLight5 );
Transfer_color( m_settings.m_RtLightColor[5], m_colourPickerLight6 );
Transfer_color( m_settings.m_RtLightColor[6], m_colourPickerLight7 );
Transfer_color( m_settings.m_RtLightColor[7], m_colourPickerLight8 );
Transfer_color( m_settings.m_opengl_selectionColor, m_colourPickerSelection );
Transfer_color( m_settings.m_OpenGlSelectionColor, m_colourPickerSelection );
m_spinCtrlLightElevation1->SetValue(
(int)( m_settings.m_raytrace_lightSphericalCoords[0].x * 180.0f - 90.0f ) );
(int)( m_settings.m_RtLightSphericalCoords[0].x * 180.0f - 90.0f ) );
m_spinCtrlLightElevation2->SetValue(
(int)( m_settings.m_raytrace_lightSphericalCoords[1].x * 180.0f - 90.0f ) );
(int)( m_settings.m_RtLightSphericalCoords[1].x * 180.0f - 90.0f ) );
m_spinCtrlLightElevation3->SetValue(
(int)( m_settings.m_raytrace_lightSphericalCoords[2].x * 180.0f - 90.0f ) );
(int)( m_settings.m_RtLightSphericalCoords[2].x * 180.0f - 90.0f ) );
m_spinCtrlLightElevation4->SetValue(
(int)( m_settings.m_raytrace_lightSphericalCoords[3].x * 180.0f - 90.0f ) );
(int)( m_settings.m_RtLightSphericalCoords[3].x * 180.0f - 90.0f ) );
m_spinCtrlLightElevation5->SetValue(
(int)( m_settings.m_raytrace_lightSphericalCoords[4].x * 180.0f - 90.0f ) );
(int)( m_settings.m_RtLightSphericalCoords[4].x * 180.0f - 90.0f ) );
m_spinCtrlLightElevation6->SetValue(
(int)( m_settings.m_raytrace_lightSphericalCoords[5].x * 180.0f - 90.0f ) );
(int)( m_settings.m_RtLightSphericalCoords[5].x * 180.0f - 90.0f ) );
m_spinCtrlLightElevation7->SetValue(
(int)( m_settings.m_raytrace_lightSphericalCoords[6].x * 180.0f - 90.0f ) );
(int)( m_settings.m_RtLightSphericalCoords[6].x * 180.0f - 90.0f ) );
m_spinCtrlLightElevation8->SetValue(
(int)( m_settings.m_raytrace_lightSphericalCoords[7].x * 180.0f - 90.0f ) );
(int)( m_settings.m_RtLightSphericalCoords[7].x * 180.0f - 90.0f ) );
m_spinCtrlLightAzimuth1->SetValue(
(int)( m_settings.m_raytrace_lightSphericalCoords[0].y * 180.0f ) );
(int)( m_settings.m_RtLightSphericalCoords[0].y * 180.0f ) );
m_spinCtrlLightAzimuth2->SetValue(
(int)( m_settings.m_raytrace_lightSphericalCoords[1].y * 180.0f ) );
(int)( m_settings.m_RtLightSphericalCoords[1].y * 180.0f ) );
m_spinCtrlLightAzimuth3->SetValue(
(int)( m_settings.m_raytrace_lightSphericalCoords[2].y * 180.0f ) );
(int)( m_settings.m_RtLightSphericalCoords[2].y * 180.0f ) );
m_spinCtrlLightAzimuth4->SetValue(
(int)( m_settings.m_raytrace_lightSphericalCoords[3].y * 180.0f ) );
(int)( m_settings.m_RtLightSphericalCoords[3].y * 180.0f ) );
m_spinCtrlLightAzimuth5->SetValue(
(int)( m_settings.m_raytrace_lightSphericalCoords[4].y * 180.0f ) );
(int)( m_settings.m_RtLightSphericalCoords[4].y * 180.0f ) );
m_spinCtrlLightAzimuth6->SetValue(
(int)( m_settings.m_raytrace_lightSphericalCoords[5].y * 180.0f ) );
(int)( m_settings.m_RtLightSphericalCoords[5].y * 180.0f ) );
m_spinCtrlLightAzimuth7->SetValue(
(int)( m_settings.m_raytrace_lightSphericalCoords[6].y * 180.0f ) );
(int)( m_settings.m_RtLightSphericalCoords[6].y * 180.0f ) );
m_spinCtrlLightAzimuth8->SetValue(
(int)( m_settings.m_raytrace_lightSphericalCoords[7].y * 180.0f ) );
(int)( m_settings.m_RtLightSphericalCoords[7].y * 180.0f ) );
}
@ -249,21 +249,18 @@ bool DIALOG_3D_VIEW_OPTIONS::TransferDataToWindow()
m_checkBoxRaytracing_proceduralTextures->SetValue(
m_settings.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) );
m_spinCtrl_NrSamples_Shadows->SetValue( m_settings.m_raytrace_nrsamples_shadows );
m_spinCtrl_NrSamples_Reflections->SetValue( m_settings.m_raytrace_nrsamples_reflections );
m_spinCtrl_NrSamples_Refractions->SetValue( m_settings.m_raytrace_nrsamples_refractions );
m_spinCtrl_NrSamples_Shadows->SetValue( m_settings.m_RtShadowSampleCount );
m_spinCtrl_NrSamples_Reflections->SetValue( m_settings.m_RtReflectionSampleCount );
m_spinCtrl_NrSamples_Refractions->SetValue( m_settings.m_RtRefractionSampleCount );
m_spinCtrlDouble_SpreadFactor_Shadows->SetValue(
m_settings.m_raytrace_spread_shadows * 100.0f );
m_spinCtrlDouble_SpreadFactor_Shadows->SetValue( m_settings.m_RtSpreadShadows * 100.0f );
m_spinCtrlDouble_SpreadFactor_Reflections->SetValue(
m_settings.m_raytrace_spread_reflections * 100.0f );
m_settings.m_RtSpreadReflections * 100.0f );
m_spinCtrlDouble_SpreadFactor_Refractions->SetValue(
m_settings.m_raytrace_spread_refractions * 100.0f );
m_settings.m_RtSpreadRefractions * 100.0f );
m_spinCtrlRecursiveLevel_Reflections->SetValue(
m_settings.m_raytrace_recursivelevel_reflections );
m_spinCtrlRecursiveLevel_Refractions->SetValue(
m_settings.m_raytrace_recursivelevel_refractions );
m_spinCtrlRecursiveLevel_Reflections->SetValue( m_settings.m_RtRecursiveReflectionCount );
m_spinCtrlRecursiveLevel_Refractions->SetValue( m_settings.m_RtRecursiveRefractionCount );
TransferColorDataToWindow();
@ -335,21 +332,19 @@ bool DIALOG_3D_VIEW_OPTIONS::TransferDataFromWindow()
m_settings.SetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES,
m_checkBoxRaytracing_proceduralTextures->GetValue() );
m_settings.m_raytrace_nrsamples_shadows = m_spinCtrl_NrSamples_Shadows->GetValue();
m_settings.m_raytrace_nrsamples_reflections = m_spinCtrl_NrSamples_Reflections->GetValue();
m_settings.m_raytrace_nrsamples_refractions= m_spinCtrl_NrSamples_Refractions->GetValue();
m_settings.m_RtShadowSampleCount = m_spinCtrl_NrSamples_Shadows->GetValue();
m_settings.m_RtReflectionSampleCount = m_spinCtrl_NrSamples_Reflections->GetValue();
m_settings.m_RtRefractionSampleCount= m_spinCtrl_NrSamples_Refractions->GetValue();
m_settings.m_raytrace_spread_shadows =
m_settings.m_RtSpreadShadows =
static_cast<float>( m_spinCtrlDouble_SpreadFactor_Shadows->GetValue() ) / 100.0f;
m_settings.m_raytrace_spread_reflections =
m_settings.m_RtSpreadReflections =
static_cast<float>( m_spinCtrlDouble_SpreadFactor_Reflections->GetValue() ) / 100.0f;
m_settings.m_raytrace_spread_refractions =
m_settings.m_RtSpreadRefractions =
static_cast<float>( m_spinCtrlDouble_SpreadFactor_Refractions->GetValue() ) / 100.0f;
m_settings.m_raytrace_recursivelevel_reflections =
m_spinCtrlRecursiveLevel_Reflections->GetValue();
m_settings.m_raytrace_recursivelevel_refractions =
m_spinCtrlRecursiveLevel_Refractions->GetValue();
m_settings.m_RtRecursiveReflectionCount = m_spinCtrlRecursiveLevel_Reflections->GetValue();
m_settings.m_RtRecursiveRefractionCount = m_spinCtrlRecursiveLevel_Refractions->GetValue();
auto Transfer_color = [] ( SFVEC3F& aTarget, wxColourPickerCtrl *aSource )
{
@ -358,54 +353,54 @@ bool DIALOG_3D_VIEW_OPTIONS::TransferDataFromWindow()
aTarget = SFVEC3F( color.Red() / 255.0f, color.Green() / 255.0f, color.Blue() / 255.0f );
};
Transfer_color( m_settings.m_raytrace_lightColorCamera, m_colourPickerCameraLight );
Transfer_color( m_settings.m_raytrace_lightColorTop, m_colourPickerTopLight );
Transfer_color( m_settings.m_raytrace_lightColorBottom, m_colourPickerBottomLight );
Transfer_color( m_settings.m_RtCameraLightColor, m_colourPickerCameraLight );
Transfer_color( m_settings.m_RtLightColorTop, m_colourPickerTopLight );
Transfer_color( m_settings.m_RtLightColorBottom, m_colourPickerBottomLight );
Transfer_color( m_settings.m_raytrace_lightColor[0], m_colourPickerLight1 );
Transfer_color( m_settings.m_raytrace_lightColor[1], m_colourPickerLight2 );
Transfer_color( m_settings.m_raytrace_lightColor[2], m_colourPickerLight3 );
Transfer_color( m_settings.m_raytrace_lightColor[3], m_colourPickerLight4 );
Transfer_color( m_settings.m_raytrace_lightColor[4], m_colourPickerLight5 );
Transfer_color( m_settings.m_raytrace_lightColor[5], m_colourPickerLight6 );
Transfer_color( m_settings.m_raytrace_lightColor[6], m_colourPickerLight7 );
Transfer_color( m_settings.m_raytrace_lightColor[7], m_colourPickerLight8 );
Transfer_color( m_settings.m_RtLightColor[0], m_colourPickerLight1 );
Transfer_color( m_settings.m_RtLightColor[1], m_colourPickerLight2 );
Transfer_color( m_settings.m_RtLightColor[2], m_colourPickerLight3 );
Transfer_color( m_settings.m_RtLightColor[3], m_colourPickerLight4 );
Transfer_color( m_settings.m_RtLightColor[4], m_colourPickerLight5 );
Transfer_color( m_settings.m_RtLightColor[5], m_colourPickerLight6 );
Transfer_color( m_settings.m_RtLightColor[6], m_colourPickerLight7 );
Transfer_color( m_settings.m_RtLightColor[7], m_colourPickerLight8 );
Transfer_color( m_settings.m_opengl_selectionColor, m_colourPickerSelection );
Transfer_color( m_settings.m_OpenGlSelectionColor, m_colourPickerSelection );
m_settings.m_raytrace_lightSphericalCoords[0].x =
m_settings.m_RtLightSphericalCoords[0].x =
( m_spinCtrlLightElevation1->GetValue() + 90.0f ) / 180.0f;
m_settings.m_raytrace_lightSphericalCoords[1].x =
m_settings.m_RtLightSphericalCoords[1].x =
( m_spinCtrlLightElevation2->GetValue() + 90.0f ) / 180.0f;
m_settings.m_raytrace_lightSphericalCoords[2].x =
m_settings.m_RtLightSphericalCoords[2].x =
( m_spinCtrlLightElevation3->GetValue() + 90.0f ) / 180.0f;
m_settings.m_raytrace_lightSphericalCoords[3].x =
m_settings.m_RtLightSphericalCoords[3].x =
( m_spinCtrlLightElevation4->GetValue() + 90.0f ) / 180.0f;
m_settings.m_raytrace_lightSphericalCoords[4].x =
m_settings.m_RtLightSphericalCoords[4].x =
( m_spinCtrlLightElevation5->GetValue() + 90.0f ) / 180.0f;
m_settings.m_raytrace_lightSphericalCoords[5].x =
m_settings.m_RtLightSphericalCoords[5].x =
( m_spinCtrlLightElevation6->GetValue() + 90.0f ) / 180.0f;
m_settings.m_raytrace_lightSphericalCoords[6].x =
m_settings.m_RtLightSphericalCoords[6].x =
( m_spinCtrlLightElevation7->GetValue() + 90.0f ) / 180.0f;
m_settings.m_raytrace_lightSphericalCoords[7].x =
m_settings.m_RtLightSphericalCoords[7].x =
( m_spinCtrlLightElevation8->GetValue() + 90.0f ) / 180.0f;
m_settings.m_raytrace_lightSphericalCoords[0].y = m_spinCtrlLightAzimuth1->GetValue() / 180.0f;
m_settings.m_raytrace_lightSphericalCoords[1].y = m_spinCtrlLightAzimuth2->GetValue() / 180.0f;
m_settings.m_raytrace_lightSphericalCoords[2].y = m_spinCtrlLightAzimuth3->GetValue() / 180.0f;
m_settings.m_raytrace_lightSphericalCoords[3].y = m_spinCtrlLightAzimuth4->GetValue() / 180.0f;
m_settings.m_raytrace_lightSphericalCoords[4].y = m_spinCtrlLightAzimuth5->GetValue() / 180.0f;
m_settings.m_raytrace_lightSphericalCoords[5].y = m_spinCtrlLightAzimuth6->GetValue() / 180.0f;
m_settings.m_raytrace_lightSphericalCoords[6].y = m_spinCtrlLightAzimuth7->GetValue() / 180.0f;
m_settings.m_raytrace_lightSphericalCoords[7].y = m_spinCtrlLightAzimuth8->GetValue() / 180.0f;
m_settings.m_RtLightSphericalCoords[0].y = m_spinCtrlLightAzimuth1->GetValue() / 180.0f;
m_settings.m_RtLightSphericalCoords[1].y = m_spinCtrlLightAzimuth2->GetValue() / 180.0f;
m_settings.m_RtLightSphericalCoords[2].y = m_spinCtrlLightAzimuth3->GetValue() / 180.0f;
m_settings.m_RtLightSphericalCoords[3].y = m_spinCtrlLightAzimuth4->GetValue() / 180.0f;
m_settings.m_RtLightSphericalCoords[4].y = m_spinCtrlLightAzimuth5->GetValue() / 180.0f;
m_settings.m_RtLightSphericalCoords[5].y = m_spinCtrlLightAzimuth6->GetValue() / 180.0f;
m_settings.m_RtLightSphericalCoords[6].y = m_spinCtrlLightAzimuth7->GetValue() / 180.0f;
m_settings.m_RtLightSphericalCoords[7].y = m_spinCtrlLightAzimuth8->GetValue() / 180.0f;
for( size_t i = 0; i < m_settings.m_raytrace_lightSphericalCoords.size(); ++i )
for( size_t i = 0; i < m_settings.m_RtLightSphericalCoords.size(); ++i )
{
m_settings.m_raytrace_lightSphericalCoords[i].x =
glm::clamp( m_settings.m_raytrace_lightSphericalCoords[i].x, 0.0f, 1.0f );
m_settings.m_RtLightSphericalCoords[i].x =
glm::clamp( m_settings.m_RtLightSphericalCoords[i].x, 0.0f, 1.0f );
m_settings.m_raytrace_lightSphericalCoords[i].y =
glm::clamp( m_settings.m_raytrace_lightSphericalCoords[i].y, 0.0f, 2.0f );
m_settings.m_RtLightSphericalCoords[i].y =
glm::clamp( m_settings.m_RtLightSphericalCoords[i].y, 0.0f, 2.0f );
}
// Camera Options

View File

@ -475,20 +475,19 @@ void EDA_3D_VIEWER::LoadSettings( APP_SETTINGS_BASE *aCfg )
if( cfg )
{
m_boardAdapter.m_raytrace_lightColorCamera =
m_boardAdapter.m_RtCameraLightColor =
m_boardAdapter.GetColor( cfg->m_Render.raytrace_lightColorCamera );
m_boardAdapter.m_raytrace_lightColorTop =
m_boardAdapter.m_RtLightColorTop =
m_boardAdapter.GetColor( cfg->m_Render.raytrace_lightColorTop );
m_boardAdapter.m_raytrace_lightColorBottom =
m_boardAdapter.m_RtLightColorBottom =
m_boardAdapter.GetColor( cfg->m_Render.raytrace_lightColorBottom );
m_boardAdapter.m_raytrace_lightColor.resize( cfg->m_Render.raytrace_lightColor.size() );
m_boardAdapter.m_raytrace_lightSphericalCoords.resize(
cfg->m_Render.raytrace_lightColor.size() );
m_boardAdapter.m_RtLightColor.resize( cfg->m_Render.raytrace_lightColor.size() );
m_boardAdapter.m_RtLightSphericalCoords.resize( cfg->m_Render.raytrace_lightColor.size() );
for( size_t i = 0; i < cfg->m_Render.raytrace_lightColor.size(); ++i )
{
m_boardAdapter.m_raytrace_lightColor[i] =
m_boardAdapter.m_RtLightColor[i] =
m_boardAdapter.GetColor( cfg->m_Render.raytrace_lightColor[i] );
SFVEC2F sphericalCoord =
@ -498,7 +497,7 @@ void EDA_3D_VIEWER::LoadSettings( APP_SETTINGS_BASE *aCfg )
sphericalCoord.x = glm::clamp( sphericalCoord.x, 0.0f, 1.0f );
sphericalCoord.y = glm::clamp( sphericalCoord.y, 0.0f, 2.0f );
m_boardAdapter.m_raytrace_lightSphericalCoords[i] = sphericalCoord;
m_boardAdapter.m_RtLightSphericalCoords[i] = sphericalCoord;
}
#define TRANSFER_SETTING( flag, field ) m_boardAdapter.SetFlag( flag, cfg->m_Render.field )
@ -543,22 +542,20 @@ void EDA_3D_VIEWER::LoadSettings( APP_SETTINGS_BASE *aCfg )
m_boardAdapter.SetAntiAliasingMode(
static_cast<ANTIALIASING_MODE>( cfg->m_Render.opengl_AA_mode ) );
m_boardAdapter.m_opengl_selectionColor =
m_boardAdapter.m_OpenGlSelectionColor =
m_boardAdapter.GetColor( cfg->m_Render.opengl_selection_color );
m_boardAdapter.m_raytrace_nrsamples_shadows = cfg->m_Render.raytrace_nrsamples_shadows;
m_boardAdapter.m_raytrace_nrsamples_reflections =
cfg->m_Render.raytrace_nrsamples_reflections;
m_boardAdapter.m_raytrace_nrsamples_refractions =
cfg->m_Render.raytrace_nrsamples_refractions;
m_boardAdapter.m_RtShadowSampleCount = cfg->m_Render.raytrace_nrsamples_shadows;
m_boardAdapter.m_RtReflectionSampleCount = cfg->m_Render.raytrace_nrsamples_reflections;
m_boardAdapter.m_RtRefractionSampleCount = cfg->m_Render.raytrace_nrsamples_refractions;
m_boardAdapter.m_raytrace_spread_shadows = cfg->m_Render.raytrace_spread_shadows;
m_boardAdapter.m_raytrace_spread_reflections = cfg->m_Render.raytrace_spread_reflections;
m_boardAdapter.m_raytrace_spread_refractions = cfg->m_Render.raytrace_spread_refractions;
m_boardAdapter.m_RtSpreadShadows = cfg->m_Render.raytrace_spread_shadows;
m_boardAdapter.m_RtSpreadReflections = cfg->m_Render.raytrace_spread_reflections;
m_boardAdapter.m_RtSpreadRefractions = cfg->m_Render.raytrace_spread_refractions;
m_boardAdapter.m_raytrace_recursivelevel_refractions =
m_boardAdapter.m_RtRecursiveRefractionCount =
cfg->m_Render.raytrace_recursivelevel_refractions;
m_boardAdapter.m_raytrace_recursivelevel_reflections =
m_boardAdapter.m_RtRecursiveReflectionCount =
cfg->m_Render.raytrace_recursivelevel_reflections;
// When opening the 3D viewer, we use the opengl mode, not the ray tracing engine
@ -638,39 +635,32 @@ void EDA_3D_VIEWER::SaveSettings( APP_SETTINGS_BASE *aCfg )
aTarget = COLOR4D( aSource.r, aSource.g, aSource.b, 1.0 );
};
save_color( m_boardAdapter.m_raytrace_lightColorCamera,
cfg->m_Render.raytrace_lightColorCamera );
save_color( m_boardAdapter.m_raytrace_lightColorTop,
cfg->m_Render.raytrace_lightColorTop );
save_color( m_boardAdapter.m_raytrace_lightColorBottom,
cfg->m_Render.raytrace_lightColorBottom );
save_color( m_boardAdapter.m_RtCameraLightColor, cfg->m_Render.raytrace_lightColorCamera );
save_color( m_boardAdapter.m_RtLightColorTop, cfg->m_Render.raytrace_lightColorTop );
save_color( m_boardAdapter.m_RtLightColorBottom, cfg->m_Render.raytrace_lightColorBottom );
for( size_t i = 0; i < cfg->m_Render.raytrace_lightColor.size(); ++i )
{
save_color( m_boardAdapter.m_raytrace_lightColor[i],
cfg->m_Render.raytrace_lightColor[i] );
save_color( m_boardAdapter.m_RtLightColor[i], cfg->m_Render.raytrace_lightColor[i] );
cfg->m_Render.raytrace_lightElevation[i] =
(int)( m_boardAdapter.m_raytrace_lightSphericalCoords[i].x * 180.0f - 90.0f );
(int)( m_boardAdapter.m_RtLightSphericalCoords[i].x * 180.0f - 90.0f );
cfg->m_Render.raytrace_lightAzimuth[i] =
(int)( m_boardAdapter.m_raytrace_lightSphericalCoords[i].y * 180.0f );
(int)( m_boardAdapter.m_RtLightSphericalCoords[i].y * 180.0f );
}
cfg->m_Render.raytrace_nrsamples_shadows = m_boardAdapter.m_raytrace_nrsamples_shadows;
cfg->m_Render.raytrace_nrsamples_reflections =
m_boardAdapter.m_raytrace_nrsamples_reflections;
cfg->m_Render.raytrace_nrsamples_refractions =
m_boardAdapter.m_raytrace_nrsamples_refractions;
cfg->m_Render.raytrace_nrsamples_shadows = m_boardAdapter.m_RtShadowSampleCount;
cfg->m_Render.raytrace_nrsamples_reflections = m_boardAdapter.m_RtReflectionSampleCount;
cfg->m_Render.raytrace_nrsamples_refractions = m_boardAdapter.m_RtRefractionSampleCount;
cfg->m_Render.raytrace_spread_shadows = m_boardAdapter.m_raytrace_spread_shadows;
cfg->m_Render.raytrace_spread_reflections = m_boardAdapter.m_raytrace_spread_reflections;
cfg->m_Render.raytrace_spread_refractions = m_boardAdapter.m_raytrace_spread_refractions;
cfg->m_Render.raytrace_spread_shadows = m_boardAdapter.m_RtSpreadShadows;
cfg->m_Render.raytrace_spread_reflections = m_boardAdapter.m_RtSpreadReflections;
cfg->m_Render.raytrace_spread_refractions = m_boardAdapter.m_RtSpreadRefractions;
cfg->m_Render.raytrace_recursivelevel_refractions =
m_boardAdapter.m_raytrace_recursivelevel_refractions;
m_boardAdapter.m_RtRecursiveRefractionCount;
cfg->m_Render.raytrace_recursivelevel_reflections =
m_boardAdapter.m_raytrace_recursivelevel_reflections;
m_boardAdapter.m_RtRecursiveReflectionCount;
#define TRANSFER_SETTING( field, flag ) cfg->m_Render.field = m_boardAdapter.GetFlag( flag )
@ -679,7 +669,7 @@ void EDA_3D_VIEWER::SaveSettings( APP_SETTINGS_BASE *aCfg )
cfg->m_Render.material_mode = static_cast<int>( m_boardAdapter.GetMaterialMode() );
cfg->m_Render.opengl_AA_mode = static_cast<int>( m_boardAdapter.GetAntiAliasingMode() );
save_color( m_boardAdapter.m_opengl_selectionColor, cfg->m_Render.opengl_selection_color );
save_color( m_boardAdapter.m_OpenGlSelectionColor, cfg->m_Render.opengl_selection_color );
cfg->m_Camera.animation_enabled = m_canvas->AnimationEnabledGet();
cfg->m_Camera.moving_speed_multiplier = m_canvas->MovingSpeedMultiplierGet();

View File

@ -33,7 +33,7 @@
#include "ogl_utils.h"
void OGL_GetScreenshot( wxImage& aDstImage )
void OglGetScreenshot( wxImage& aDstImage )
{
struct viewport_params
{
@ -47,9 +47,6 @@ void OGL_GetScreenshot( wxImage& aDstImage )
unsigned char* pixelbuffer = (unsigned char*) malloc( viewport.x * viewport.y * 3 );
// Alphabuffer was causing some transparency problems on some systems (Windows)
// unsigned char* alphabuffer = (unsigned char*) malloc( viewport.x * viewport.y );
// Call glFinish before screenshot to ensure everything is fully drawn.
glFinish();
@ -59,10 +56,6 @@ void OGL_GetScreenshot( wxImage& aDstImage )
glReadPixels( viewport.originX, viewport.originY, viewport.x, viewport.y, GL_RGB,
GL_UNSIGNED_BYTE, pixelbuffer );
// glReadPixels( viewport.originX, viewport.originY,
// viewport.x, viewport.y,
// GL_ALPHA, GL_UNSIGNED_BYTE, alphabuffer );
// "Sets the image data without performing checks.
// The data given must have the size (width*height*3)
// The data must have been allocated with malloc()
@ -70,13 +63,11 @@ void OGL_GetScreenshot( wxImage& aDstImage )
// by the wxImage object, that will be responsible for deleting it."
aDstImage.SetData( pixelbuffer, viewport.x, viewport.y, false );
//aDstImage.SetAlpha( alphabuffer, false );
aDstImage = aDstImage.Mirror( false );
}
GLuint OGL_LoadTexture( const IMAGE& aImage )
GLuint OglLoadTexture( const IMAGE& aImage )
{
unsigned char* rgbaBuffer = (unsigned char*) malloc( aImage.GetWidth() *
aImage.GetHeight() * 4 );
@ -104,18 +95,9 @@ GLuint OGL_LoadTexture( const IMAGE& aImage )
glGenTextures( 1, &texture );
glBindTexture( GL_TEXTURE_2D, texture );
/*gluBuild2DMipmaps( GL_TEXTURE_2D,
GL_RGBA,
aImage.GetWidth(),
aImage.GetHeight(),
GL_RGBA,
GL_UNSIGNED_BYTE,
rgbaBuffer );*/
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, aImage.GetWidth(), aImage.GetHeight(), 0, GL_RGBA,
GL_UNSIGNED_BYTE, rgbaBuffer );
//glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
@ -133,7 +115,7 @@ GLuint OGL_LoadTexture( const IMAGE& aImage )
}
void OGL_SetMaterial( const SMATERIAL& aMaterial, float aOpacity, bool aUseSelectedMaterial,
void OglSetMaterial( const SMATERIAL& aMaterial, float aOpacity, bool aUseSelectedMaterial,
SFVEC3F aSelectionColor )
{
const SFVEC4F ambient = SFVEC4F( aMaterial.m_Ambient, 1.0f );
@ -157,7 +139,7 @@ void OGL_SetMaterial( const SMATERIAL& aMaterial, float aOpacity, bool aUseSele
}
void OGL_SetDiffuseOnlyMaterial( const SFVEC3F &aMaterialDiffuse, float aOpacity )
void OglSetDiffuseMaterial( const SFVEC3F &aMaterialDiffuse, float aOpacity )
{
const SFVEC4F ambient = SFVEC4F( 0.2f, 0.2f, 0.2f, 1.0f );
const SFVEC4F diffuse = SFVEC4F( aMaterialDiffuse, aOpacity );
@ -172,7 +154,7 @@ void OGL_SetDiffuseOnlyMaterial( const SFVEC3F &aMaterialDiffuse, float aOpacity
}
void OGL_DrawBackground( const SFVEC3F& aTopColor, const SFVEC3F& aBotColor )
void OglDrawBackground( const SFVEC3F& aTopColor, const SFVEC3F& aBotColor )
{
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
@ -201,7 +183,7 @@ void OGL_DrawBackground( const SFVEC3F& aTopColor, const SFVEC3F& aBotColor )
}
void OGL_ResetTextureStateDefaults()
void OglResetTextureState()
{
if( !glActiveTexture || !glClientActiveTexture )
throw std::runtime_error( "The OpenGL context no longer exists: unable to Reset Textures" );

View File

@ -25,7 +25,7 @@
/**
* @file ogl_utils.h
*
* Implements generic OpenGL functions that are common to any OpenGL target.
* Define generic OpenGL functions that are common to any OpenGL target.
*/
#ifndef OGL_UTILS_H_
@ -43,7 +43,7 @@
* @param aUseSelectedMaterial if material should be set for selection mode.
* @param aSelectionColor material to use for selection in case it is enabled.
*/
void OGL_SetMaterial( const SMATERIAL& aMaterial, float aOpacity,
void OglSetMaterial( const SMATERIAL& aMaterial, float aOpacity,
bool aUseSelectedMaterial = false,
SFVEC3F aSelectionColor = SFVEC3F( 0.0f ) );
@ -52,7 +52,7 @@ void OGL_SetMaterial( const SMATERIAL& aMaterial, float aOpacity,
*
* @param aMaterialDiffuse the diffuse color to assign to material properties.
*/
void OGL_SetDiffuseOnlyMaterial( const SFVEC3F& aMaterialDiffuse, float aOpacity );
void OglSetDiffuseMaterial( const SFVEC3F& aMaterialDiffuse, float aOpacity );
/**
* Generate a new OpenGL texture.
@ -60,20 +60,20 @@ void OGL_SetDiffuseOnlyMaterial( const SFVEC3F& aMaterialDiffuse, float aOpacity
* @param aImage a image to generate the texture from.
* @return the OpenGL texture index created.
*/
GLuint OGL_LoadTexture( const IMAGE& aImage );
GLuint OglLoadTexture( const IMAGE& aImage );
/**
* Get the pixel data of current OpenGL image.
*
* @param aDstImage the output image. the image must be destroyed to free the data.
*/
void OGL_GetScreenshot( wxImage& aDstImage );
void OglGetScreenshot( wxImage& aDstImage );
void OGL_DrawBackground( const SFVEC3F& aTopColor, const SFVEC3F& aBotColor );
void OglDrawBackground( const SFVEC3F& aTopColor, const SFVEC3F& aBotColor );
/**
* Reset to default state the texture settings.
*/
void OGL_ResetTextureStateDefaults();
void OglResetTextureState();
#endif // OGL_UTILS_H_