7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-03-30 05:26:55 +00:00

Include folder and 3D viewer code housekeeping.

This commit is contained in:
Wayne Stambaugh 2025-01-10 20:30:25 -05:00
parent 30d43c30b7
commit 42a1d1cf0b
54 changed files with 767 additions and 593 deletions

View File

@ -211,7 +211,8 @@ SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, const wxString& aBasePa
}
SCENEGRAPH* S3D_CACHE::Load( const wxString& aModelFile, const wxString& aBasePath, const EMBEDDED_FILES* aEmbeddedFiles )
SCENEGRAPH* S3D_CACHE::Load( const wxString& aModelFile, const wxString& aBasePath,
const EMBEDDED_FILES* aEmbeddedFiles )
{
return load( aModelFile, aBasePath, nullptr, aEmbeddedFiles );
}
@ -612,4 +613,4 @@ void S3D_CACHE::CleanCacheDir( int aNumDaysOld )
}
}
}
}
}

View File

@ -63,7 +63,7 @@ public:
}
/**
* Sets the configuration directory to be used by the model manager for storing 3D
* Set the configuration directory to be used by the model manager for storing 3D
* model manager configuration data and the model cache.
*
* The config directory may only be set once in the lifetime of the object.
@ -98,7 +98,8 @@ public:
* @param aEmbeddedFiles is a pointer to the embedded files list.
* @return true if the model was successfully loaded, otherwise false.
*/
SCENEGRAPH* Load( const wxString& aModelFile, const wxString& aBasePath, const EMBEDDED_FILES* aEmbeddedFiles );
SCENEGRAPH* Load( const wxString& aModelFile, const wxString& aBasePath,
const EMBEDDED_FILES* aEmbeddedFiles );
FILENAME_RESOLVER* GetResolver() noexcept;
@ -130,7 +131,8 @@ public:
* @param aEmbeddedFiles is a pointer to the embedded files list.
* @return is a pointer to the render data or NULL if not available.
*/
S3DMODEL* GetModel( const wxString& aModelFileName, const wxString& aBasePath, const EMBEDDED_FILES* aEmbeddedFiles );
S3DMODEL* GetModel( const wxString& aModelFileName, const wxString& aBasePath,
const EMBEDDED_FILES* aEmbeddedFiles );
/**
* Delete up old cache files in cache directory.
@ -172,12 +174,12 @@ private:
// the real load function (can supply a cache entry pointer to member functions)
SCENEGRAPH* load( const wxString& aModelFile, const wxString& aBasePath,
S3D_CACHE_ENTRY** aCachePtr = nullptr,
const EMBEDDED_FILES* aEmbeddedFiles = nullptr );
const EMBEDDED_FILES* aEmbeddedFiles = nullptr );
/// cache entries
/// Cache entries.
std::list< S3D_CACHE_ENTRY* > m_CacheList;
/// mapping of file names to cache names and data
/// Mapping of file names to cache names and data.
std::map< wxString, S3D_CACHE_ENTRY*, rsort_wxString > m_CacheMap;
FILENAME_RESOLVER* m_FNResolver;
@ -186,7 +188,7 @@ private:
PROJECT* m_project;
wxString m_CacheDir;
wxString m_ConfigDir; /// base configuration path for 3D items
wxString m_ConfigDir; ///< base configuration path for 3D items.
};
#endif // CACHE_3D_H

View File

@ -444,7 +444,8 @@ SCENEGRAPH* S3D_PLUGIN_MANAGER::Load3DModel( const wxString& aFileName, std::str
ext_to_find.MakeLower();
#endif
// .gz files are compressed versions that may have additional information in the previous extension
// .gz files are compressed versions that may have additional information in the previous
// extension.
if( ext_to_find == wxT( "gz" ) )
{
wxFileName second( raw.GetName() );
@ -518,8 +519,7 @@ bool S3D_PLUGIN_MANAGER::CheckTag( const char* aTag )
ptag.clear();
(*pS)->GetPluginInfo( ptag );
// if the plugin name matches then the version
// must also match
// if the plugin name matches then the version must also match
if( !ptag.compare( 0, pname.size(), pname ) )
{
if( ptag.compare( tname ) )

View File

@ -374,7 +374,8 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
m_nonCopperLayerThickness3DU = DEFAULT_TECH_LAYER_THICKNESS * m_biuTo3Dunits;
m_solderPasteLayerThickness3DU = SOLDERPASTE_LAYER_THICKNESS * m_biuTo3Dunits;
g_BevelThickness3DU = pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_3DRT_BevelHeight_um / 1000.0 ) * m_biuTo3Dunits;
g_BevelThickness3DU = pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_3DRT_BevelHeight_um / 1000.0 )
* m_biuTo3Dunits;
if( m_board )
{
@ -395,9 +396,10 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
case BS_ITEM_TYPE_COPPER:
{
// The copper thickness must be > 0 to avoid draw issues (divide by 0 for instance)
// We use a minimal arbitrary value = 1 micrometer here:
int copper_thickness = std::max( item->GetThickness(), pcbIUScale.mmToIU( 0.001 ) );
// The copper thickness must be > 0 to avoid draw issues (divide by 0 for
// instance). We use a minimal arbitrary value = 1 micrometer here:
int copper_thickness = std::max( item->GetThickness(),
pcbIUScale.mmToIU( 0.001 ) );
if( item->GetBrdLayerId() == F_Cu )
m_frontCopperThickness3DU = copper_thickness * m_biuTo3Dunits;
@ -419,8 +421,10 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
// Init Z position of each layer
// calculate z position for each copper layer
// Zstart = -m_epoxyThickness / 2.0 is the z position of the back (bottom layer) (layer id = B_Cu)
// Zstart = +m_epoxyThickness / 2.0 is the z position of the front (top layer) (layer id = F_Cu)
// Zstart = -m_epoxyThickness / 2.0 is the z position of the back (bottom layer)
// (layer id = B_Cu)
// Zstart = +m_epoxyThickness / 2.0 is the z position of the front (top layer)
// (layer id = F_Cu)
// ____==__________==________==______ <- Bottom = +m_epoxyThickness / 2.0,
// | | Top = Bottom + m_copperThickness
@ -470,12 +474,14 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
continue;
m_layerZcoordBottom[(PCB_LAYER_ID)layer_id] = zpos_copperTop_back - 2.0f * zpos_offset;
m_layerZcoordTop[(PCB_LAYER_ID)layer_id] = m_layerZcoordBottom[(PCB_LAYER_ID)layer_id] - m_backCopperThickness3DU;
m_layerZcoordTop[(PCB_LAYER_ID) layer_id] =
m_layerZcoordBottom[(PCB_LAYER_ID) layer_id] - m_backCopperThickness3DU;
}
// calculate z position for each technical layer
// Solder mask and Solder paste have the same Z position
for( PCB_LAYER_ID layer_id : { B_Adhes, B_Mask, B_Paste, F_Adhes, F_Mask, F_Paste, B_SilkS, F_SilkS } )
for( PCB_LAYER_ID layer_id :
{ B_Adhes, B_Mask, B_Paste, F_Adhes, F_Mask, F_Paste, B_SilkS, F_SilkS } )
{
float zposTop = 0.0;
float zposBottom = 0.0;
@ -641,7 +647,8 @@ std::map<int, COLOR4D> BOARD_ADAPTER::GetLayerColors() const
// Can't do a const KIGFX::COLOR4D& return type here because there are temporary variables
auto findColor =
[]( const wxString& aColorName, const CUSTOM_COLORS_LIST& aColorSet ) -> const KIGFX::COLOR4D
[]( const wxString& aColorName,
const CUSTOM_COLORS_LIST& aColorSet ) -> const KIGFX::COLOR4D
{
if( aColorName.StartsWith( wxT( "#" ) ) )
{

View File

@ -140,7 +140,7 @@ public:
double BiuTo3dUnits() const noexcept { return m_biuTo3Dunits; }
/**
* Get the board outling bounding box.
* Get the board outline bounding box.
*
* @return the board bounding box in 3D units.
*/
@ -352,8 +352,16 @@ public:
*/
const MAP_POLY& GetPolyMap() const noexcept { return m_layers_poly; }
const SHAPE_POLY_SET* GetFrontPlatedPadAndGraphicPolys() { return m_frontPlatedPadAndGraphicPolys; }
const SHAPE_POLY_SET* GetBackPlatedPadAndGraphicPolys() { return m_backPlatedPadAndGraphicPolys; }
const SHAPE_POLY_SET* GetFrontPlatedPadAndGraphicPolys()
{
return m_frontPlatedPadAndGraphicPolys;
}
const SHAPE_POLY_SET* GetBackPlatedPadAndGraphicPolys()
{
return m_backPlatedPadAndGraphicPolys;
}
const MAP_POLY& GetHoleIdPolysMap() const noexcept { return m_layerHoleIdPolys; }
const MAP_POLY& GetHoleOdPolysMap() const noexcept { return m_layerHoleOdPolys; }
@ -403,8 +411,8 @@ private:
PCB_LAYER_ID aLayerId );
void createArcSegments( const VECTOR2I& aCentre, const VECTOR2I& aStart,
const EDA_ANGLE& aArcAngle, int aCircleToSegmentsCount, int aWidth,
CONTAINER_2D_BASE* aContainer, const BOARD_ITEM& aOwner );
const EDA_ANGLE& aArcAngle, int aCircleToSegmentsCount, int aWidth,
CONTAINER_2D_BASE* aContainer, const BOARD_ITEM& aOwner );
void buildPadOutlineAsSegments( const PAD* aPad, PCB_LAYER_ID aLayer,
CONTAINER_2D_BASE* aDstContainer, int aWidth );

View File

@ -219,9 +219,11 @@ void BOARD_ADAPTER::addFootprintShapes( const FOOTPRINT* aFootprint, CONTAINER_2
{
if( !aVisibilityFlags.test( LAYER_FP_TEXT ) )
continue;
else if( text->GetText() == wxT( "${REFERENCE}" ) && !aVisibilityFlags.test( LAYER_FP_REFERENCES ) )
else if( text->GetText() == wxT( "${REFERENCE}" )
&& !aVisibilityFlags.test( LAYER_FP_REFERENCES ) )
continue;
else if( text->GetText() == wxT( "${VALUE}" ) && !aVisibilityFlags.test( LAYER_FP_VALUES ) )
else if( text->GetText() == wxT( "${VALUE}" )
&& !aVisibilityFlags.test( LAYER_FP_VALUES ) )
continue;
addText( text, aContainer, text );
@ -396,7 +398,8 @@ void BOARD_ADAPTER::createPadWithMargin( const PAD* aPad, CONTAINER_2D_BASE* aCo
}
else
{
auto padShapes = std::static_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape( aLayer ) );
auto padShapes =
std::static_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape( aLayer ) );
for( const SHAPE* shape : padShapes->Shapes() )
{
@ -483,7 +486,7 @@ void BOARD_ADAPTER::createPadWithMargin( const PAD* aPad, CONTAINER_2D_BASE* aCo
void BOARD_ADAPTER::createPadWithHole( const PAD* aPad, CONTAINER_2D_BASE* aDstContainer,
int aInflateValue )
int aInflateValue )
{
if( !aPad->HasHole() )
{
@ -706,7 +709,7 @@ void BOARD_ADAPTER::addShape( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aConta
ERROR_INSIDE );
// Some polygons can be a bit complex (especially when coming from a
// picture ot a text converted to a polygon
// picture of a text converted to a polygon
// So call Simplify before calling ConvertPolygonToTriangles, just in case.
polyList.Simplify();

View File

@ -348,7 +348,8 @@ void EDA_3D_CANVAS::DisplayStatus()
m_parentStatusBar->SetStatusText( msg, static_cast<int>( EDA_3D_VIEWER_STATUSBAR::Y_POS ) );
msg.Printf( wxT( "zoom %3.2f" ), 1 / m_camera.GetZoom() );
m_parentStatusBar->SetStatusText( msg, static_cast<int>( EDA_3D_VIEWER_STATUSBAR::ZOOM_LEVEL ) );
m_parentStatusBar->SetStatusText( msg,
static_cast<int>( EDA_3D_VIEWER_STATUSBAR::ZOOM_LEVEL ) );
}
}
@ -479,7 +480,7 @@ void EDA_3D_CANVAS::DoRePaint()
if( m_camera_is_moving )
{
const int64_t curtime_delta = GetRunningMicroSecs() - m_strtime_camera_movement;
curtime_delta_s = (curtime_delta / 1e6) * m_camera_moving_speed;
curtime_delta_s = ( curtime_delta / 1e6 ) * m_camera_moving_speed;
m_camera.Interpolate( curtime_delta_s );
if( curtime_delta_s > 1.0f )

View File

@ -109,16 +109,16 @@ public:
void RenderRaytracingRequest();
/**
* Request a screenshot and output it to the \a aDstImage
* Request a screenshot and output it to the \a aDstImage.
*
* @param aDstImage - Screenshot destination image
* @param aDstImage - Screenshot destination image.
*/
void GetScreenshot( wxImage& aDstImage );
/**
* Select a specific 3D view or operation
* Select a specific 3D view or operation.
*
* @param aRequestedView the view to move to
* @param aRequestedView the view to move to.
* @return true if the view request was handled, false if no command found for this view.
*/
bool SetView3D( VIEW3D_TYPE aRequestedView );
@ -331,7 +331,7 @@ private:
bool m_render3dmousePivot = false; // Render the 3dmouse pivot
SFVEC3F m_3dmousePivotPos; // The position of the 3dmouse pivot
///< Used to track gesture events.
/// Used to track gesture events.
double m_gestureLastZoomFactor = 1.0;
double m_gestureLastAngle = 0.0;

View File

@ -44,8 +44,8 @@
#include <macros.h>
/**
* Scale conversion from 3d model units to pcb units
*/
* Scale conversion from 3d model units to pcb units
*/
#define UNITS3D_TO_UNITSPCB ( pcbIUScale.IU_PER_MM )
/**

View File

@ -24,7 +24,7 @@
#include <3d-viewer/3d_rendering/track_ball.h>
#include <3d-viewer/3d_canvas/eda_3d_canvas.h>
// KiCAD includes
// KiCad includes
#include <tool/action_manager.h>
#include <tool/tool_manager.h>
#include <tool/tools_holder.h>
@ -73,7 +73,8 @@ bool equals( glm::mat<L, C, T, Q> const& aFirst, glm::mat<L, C, T, Q> const& aSe
}
NL_3D_VIEWER_PLUGIN_IMPL::NL_3D_VIEWER_PLUGIN_IMPL( EDA_3D_CANVAS* aCanvas, const std::string& aProfileHint ) :
NL_3D_VIEWER_PLUGIN_IMPL::NL_3D_VIEWER_PLUGIN_IMPL( EDA_3D_CANVAS* aCanvas,
const std::string& aProfileHint ) :
NAV_3D( false, false ),
m_canvas( aCanvas ),
m_capIsMoving( false ),
@ -111,15 +112,7 @@ void NL_3D_VIEWER_PLUGIN_IMPL::Connect()
exportCommandsAndImages();
}
/**
* Add a category to the store.
*
* The function adds category paths of the format "A.B" where B is a sub-category of A.
*
* @param aCategoryPath is the std::string representation of the category.
* @param aCategoryStore is the CATEGORY_STORE instance to add to.
* @return a CATEGORY_STORE::iterator where the category was added.
*/
CATEGORY_STORE::iterator add_category( std::string aCategoryPath, CATEGORY_STORE& aCategoryStore )
{
using TDx::SpaceMouse::CCategory;
@ -192,7 +185,7 @@ void NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages()
std::string name = action->GetName();
// Do no export commands for the pcbnew app.
// Do no export commands for the Pcbnew app.
if( name.rfind( "pcbnew.", 0 ) == 0 )
{
continue;

View File

@ -29,7 +29,7 @@
// TDxWare SDK.
#include <SpaceMouse/CNavigation3D.hpp>
// KiCAD
// KiCad
#include <include/plugins/3dapi/xv3d_types.h>
// wx
@ -45,6 +45,15 @@ class TRACK_BALL;
// temporary store for the categories
typedef std::map<std::string, TDx::CCommandTreeNode*> CATEGORY_STORE;
/**
* Add a category to the store.
*
* The function adds category paths of the format "A.B" where B is a sub-category of A.
*
* @param aCategoryPath is the std::string representation of the category.
* @param aCategoryStore is the CATEGORY_STORE instance to add to.
* @return a CATEGORY_STORE::iterator where the category was added.
*/
CATEGORY_STORE::iterator add_category( std::string aCategoryPath, CATEGORY_STORE& aCategoryStore );
// Convenience typedef.

View File

@ -31,13 +31,14 @@
#include <SpaceMouse/CNavigation3D.hpp>
/**
* The class that adjusts NL_3D_VIEWER_PLUGIN_IMPL implementation for 3D Model preview in footprint properties dialog.
* The class that adjusts NL_3D_VIEWER_PLUGIN_IMPL implementation for 3D Model preview in
* footprint properties dialog.
*/
class NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL : public NL_3D_VIEWER_PLUGIN_IMPL
{
public:
/**
* Initializes a new instance of the NL_FOOTPRINT_PROPERTIES_PLUGIN.
* Initialize a new instance of the NL_FOOTPRINT_PROPERTIES_PLUGIN.
*
* @param aCanvas is the viewport to be navigated.
*/
@ -60,8 +61,8 @@ private:
/**
* Trace mask used to enable or disable the trace output of this class.
* The debug output can be turned on by setting the WXTRACE environment variable to
* "KI_TRACE_NL_FOOTPRINT_PROPERTIES_PLUGIN". See the wxWidgets documentation on wxLogTrace for
* more information.
* "KI_TRACE_NL_FOOTPRINT_PROPERTIES_PLUGIN". See the wxWidgets documentation on
* wxLogTrace for more information.
*/
static const wxChar* m_logTrace;
};

View File

@ -98,8 +98,8 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode )
/**
* WARNING: Horrible hack here!
* Somehow, buffer values are being shared between pcbnew and the 3d viewer, which then frees
* the buffer, resulting in errors in pcbnew. To resolve this temporarily, we generate
* Somehow, buffer values are being shared between Pcbnew and the 3d viewer, which then frees
* the buffer, resulting in errors in Pcbnew. To resolve this temporarily, we generate
* extra buffers in 3dviewer and use the higher numbers. These are freed on close.
* todo: Correctly separate the OpenGL contexts to prevent overlapping buffer vals
*/
@ -332,7 +332,8 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode )
// temporary index buffer which will contain either GLushort or GLuint
// type indices. allocate with a bit of meadow at the end.
auto tmp_idx = std::make_unique<GLuint[]>( ( idx_size * total_index_count + 8 ) / sizeof( GLuint ) );
auto tmp_idx =
std::make_unique<GLuint[]>( ( idx_size * total_index_count + 8 ) / sizeof( GLuint ) );
unsigned int prev_vtx_count = 0;
unsigned int idx_offset = 0;
@ -507,9 +508,9 @@ void MODEL_3D::Draw( bool aTransparent, float aOpacity, bool aUseSelectedMateria
{
for( const MODEL_3D::MATERIAL& mat : m_materials )
{
// There is at least one default material created in case a mesh has no declared materials.
// Most meshes have a material, so usually the first material will have nothing to render and is skip.
// See S3D::GetModel for more details.
// There is at least one default material created in case a mesh has no declared
// materials. Most meshes have a material, so usually the first material will have
// nothing to render and is skip. See S3D::GetModel for more details.
if( mat.m_render_idx_count == 0 )
{
continue;
@ -535,7 +536,8 @@ void MODEL_3D::Draw( bool aTransparent, float aOpacity, bool aUseSelectedMateria
break;
case MATERIAL_MODE::DIFFUSE_ONLY:
OglSetDiffuseMaterial( mat->m_Diffuse, aOpacity, aUseSelectedMaterial, aSelectionColor );
OglSetDiffuseMaterial( mat->m_Diffuse, aOpacity, aUseSelectedMaterial,
aSelectionColor );
break;
case MATERIAL_MODE::CAD_MODE:

View File

@ -146,7 +146,8 @@ private:
unsigned int m_render_idx_buffer_offset = 0;
unsigned int m_render_idx_count = 0;
BBOX_3D m_bbox; ///< bounding box for this material group, used for transparent material ordering
BBOX_3D m_bbox; ///< bounding box for this material group, used for transparent
///< material ordering.
MATERIAL( const SMATERIAL& aOther ) : SMATERIAL( aOther ) { }
bool IsTransparent() const { return m_Transparency > FLT_EPSILON; }

View File

@ -607,8 +607,10 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
if( m_boardAdapter.m_Cfg->m_Render.DifferentiatePlatedCopper() )
{
const SHAPE_POLY_SET* frontPlatedPadAndGraphicPolys = m_boardAdapter.GetFrontPlatedPadAndGraphicPolys();
const SHAPE_POLY_SET* backPlatedPadAndGraphicPolys = m_boardAdapter.GetBackPlatedPadAndGraphicPolys();
const SHAPE_POLY_SET* frontPlatedPadAndGraphicPolys =
m_boardAdapter.GetFrontPlatedPadAndGraphicPolys();
const SHAPE_POLY_SET* backPlatedPadAndGraphicPolys =
m_boardAdapter.GetBackPlatedPadAndGraphicPolys();
if( frontPlatedPadAndGraphicPolys )
{
@ -617,7 +619,8 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
poly.BooleanSubtract( m_boardAdapter.GetTH_ODPolys() );
poly.BooleanSubtract( m_boardAdapter.GetNPTH_ODPolys() );
m_platedPadsFront = generateLayerList( m_boardAdapter.GetPlatedPadsFront(), &poly, F_Cu );
m_platedPadsFront = generateLayerList( m_boardAdapter.GetPlatedPadsFront(), &poly,
F_Cu );
// An entry for F_Cu must exist in m_layers or we'll never look at m_platedPadsFront
if( m_layers.count( F_Cu ) == 0 )
@ -965,7 +968,9 @@ void RENDER_3D_OPENGL::load3dModels( REPORTER* aStatusReporter )
{
// It is not present, try get it from cache
const S3DMODEL* modelPtr =
m_boardAdapter.Get3dCacheManager()->GetModel( fp_model.m_Filename, footprintBasePath, footprint );
m_boardAdapter.Get3dCacheManager()->GetModel( fp_model.m_Filename,
footprintBasePath,
footprint );
// only add it if the return is not NULL
if( modelPtr )

View File

@ -129,7 +129,7 @@ void TRIANGLE_DISPLAY_LIST::AddToMiddleContourns( const std::vector< SFVEC2F >&
{
if( aContournPoints.size() >= 4 )
{
// Calculate normals of each segment of the contourn
// Calculate normals of each segment of the contour
std::vector< SFVEC2F > contournNormals;
contournNormals.clear();
@ -245,7 +245,7 @@ void TRIANGLE_DISPLAY_LIST::AddToMiddleContourns( const SHAPE_LINE_CHAIN& outlin
}
}
// Add first position fo the list to close the path
// Add first position of the list to close the path.
if( lastV != contournPoints[0] )
contournPoints.push_back( contournPoints[0] );
@ -472,10 +472,10 @@ void OPENGL_RENDER_LIST::DrawAll( bool aDrawMiddle ) const
void OPENGL_RENDER_LIST::DrawCulled( bool aDrawMiddle,
const OPENGL_RENDER_LIST* aSubtractList,
const OPENGL_RENDER_LIST* bSubtractList,
const OPENGL_RENDER_LIST* cSubtractList,
const OPENGL_RENDER_LIST* dSubtractList ) const
const OPENGL_RENDER_LIST* aSubtractList,
const OPENGL_RENDER_LIST* bSubtractList,
const OPENGL_RENDER_LIST* cSubtractList,
const OPENGL_RENDER_LIST* dSubtractList ) const
{
glClearStencil( 0x00 );
glClear( GL_STENCIL_BUFFER_BIT );
@ -502,8 +502,8 @@ void OPENGL_RENDER_LIST::DrawCulled( bool aDrawMiddle,
if( dSubtractList )
dSubtractList->DrawBot();
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glEnable( GL_DEPTH_TEST );
glDepthMask( GL_TRUE );
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
glStencilFunc( GL_EQUAL, 0, 1 );
@ -529,8 +529,8 @@ void OPENGL_RENDER_LIST::DrawCulled( bool aDrawMiddle,
if( dSubtractList )
dSubtractList->DrawTop();
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glEnable( GL_DEPTH_TEST );
glDepthMask( GL_TRUE );
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
glStencilFunc( GL_NOTEQUAL, 2, 0x03 );
glStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
@ -584,11 +584,11 @@ void OPENGL_RENDER_LIST::SetItIsTransparent( bool aSetTransparent )
GLuint OPENGL_RENDER_LIST::generate_top_or_bot_seg_ends(
const TRIANGLE_LIST* aTriangleContainer, bool aIsNormalUp, GLuint aTextureId ) const
{
wxASSERT( aTriangleContainer != nullptr );
wxCHECK( aTriangleContainer != nullptr, 0 );
wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 );
// Top and Bot dont have normals array stored in container
// Top and Bot don't have normals array stored in container
wxASSERT( aTriangleContainer->GetNormalsSize() == 0 );
if( ( aTriangleContainer->GetVertexSize() > 0 )
@ -651,11 +651,11 @@ GLuint OPENGL_RENDER_LIST::generate_top_or_bot_seg_ends(
GLuint OPENGL_RENDER_LIST::generate_top_or_bot_triangles( const TRIANGLE_LIST* aTriangleContainer,
bool aIsNormalUp ) const
{
wxASSERT( aTriangleContainer != nullptr );
wxCHECK( aTriangleContainer != nullptr, 0 );
wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 );
// Top and Bot dont have normals array stored in container
// Top and Bot dint have normals array stored in container
wxASSERT( aTriangleContainer->GetNormalsSize() == 0 );
if( ( aTriangleContainer->GetVertexSize() > 0 )
@ -695,7 +695,7 @@ GLuint OPENGL_RENDER_LIST::generate_top_or_bot_triangles( const TRIANGLE_LIST* a
GLuint OPENGL_RENDER_LIST::generate_middle_triangles(
const TRIANGLE_LIST* aTriangleContainer ) const
{
wxASSERT( aTriangleContainer != nullptr );
wxCHECK( aTriangleContainer != nullptr, 0 );
// We expect that it is a multiple of 3 vertex
wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 );
@ -767,3 +767,5 @@ void OPENGL_RENDER_LIST::beginTransformation() const
glScalef( 1.0f, 1.0f, m_zScaleTransformation );
}
}
// LocalWords: EDA Luzeiro txt MERCHANTABILITY wxASSERT normals fo

View File

@ -605,7 +605,7 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
if( layerFlags.test( LAYER_3D_BOARD ) && m_boardAdapter.m_BoardBodyColor.a > opacity_min )
{
// generating internal copper layers is time consumming. so skip them
// generating internal copper layers is time consuming. so skip them
// if the board body is masking them (i.e. if the opacity is near 1.0)
// B_Cu is layer 2 and all inner layers are higher values
if( layer > B_Cu && IsCopperLayer( layer ) )
@ -716,7 +716,8 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
renderBoardBody( skipRenderHoles );
// Display transparent mask layers
if( layerFlags.test( LAYER_3D_SOLDERMASK_TOP ) || layerFlags.test( LAYER_3D_SOLDERMASK_BOTTOM ) )
if( layerFlags.test( LAYER_3D_SOLDERMASK_TOP )
|| layerFlags.test( LAYER_3D_SOLDERMASK_BOTTOM ) )
{
// add a depth buffer offset, it will help to hide some artifacts
// on silkscreen where the SolderMask is removed
@ -766,7 +767,9 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
// Enables Texture Env so it can combine model transparency with each footprint opacity
glEnable( GL_TEXTURE_2D );
glActiveTexture( GL_TEXTURE0 );
glBindTexture( GL_TEXTURE_2D, m_circleTexture ); // Uses an existent texture so the glTexEnv operations will work
// Uses an existent texture so the glTexEnv operations will work.
glBindTexture( GL_TEXTURE_2D, m_circleTexture );
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE );
@ -985,7 +988,8 @@ void RENDER_3D_OPENGL::get3dModelsSelected( std::list<MODELTORENDER> &aDstRender
const bool isFlipped = fp->IsFlipped();
if( aGetTop == !isFlipped || aGetBot == isFlipped )
get3dModelsFromFootprint( aDstRenderList, fp, aRenderTransparentOnly, highlight );
get3dModelsFromFootprint( aDstRenderList, fp, aRenderTransparentOnly,
highlight );
}
}
}
@ -1046,7 +1050,8 @@ void RENDER_3D_OPENGL::get3dModelsFromFootprint( std::list<MODELTORENDER> &aDstR
glm::mat4 modelworldMatrix = fpMatrix;
const SFVEC3F offset = SFVEC3F( sM.m_Offset.x, sM.m_Offset.y, sM.m_Offset.z );
const SFVEC3F rotation = SFVEC3F( sM.m_Rotation.x, sM.m_Rotation.y, sM.m_Rotation.z );
const SFVEC3F rotation = SFVEC3F( sM.m_Rotation.x, sM.m_Rotation.y,
sM.m_Rotation.z );
const SFVEC3F scale = SFVEC3F( sM.m_Scale.x, sM.m_Scale.y, sM.m_Scale.z );
std::vector<float> key = { offset.x, offset.y, offset.z,

View File

@ -848,7 +848,7 @@ BVHBuildNode *BVH_PBRT::emitLBVH( BVHBuildNode* &buildNodes,
while( searchStart + 1 != searchEnd )
{
wxASSERT(searchStart != searchEnd);
wxASSERT( searchStart != searchEnd );
const int mid = ( searchStart + searchEnd ) / 2;

View File

@ -67,18 +67,22 @@ static float TransparencyControl( float aGrayColorValue, float aTransparency )
}
/**
* Scale conversion from 3d model units to pcb units
*/
* Scale conversion from 3d model units to pcb units
*/
#define UNITS3D_TO_UNITSPCB ( pcbIUScale.IU_PER_MM )
void RENDER_3D_RAYTRACE_BASE::setupMaterials()
{
MATERIAL::SetDefaultRefractionRayCount( m_boardAdapter.m_Cfg->m_Render.raytrace_nrsamples_refractions );
MATERIAL::SetDefaultReflectionRayCount( m_boardAdapter.m_Cfg->m_Render.raytrace_nrsamples_reflections );
MATERIAL::SetDefaultRefractionRayCount(
m_boardAdapter.m_Cfg->m_Render.raytrace_nrsamples_refractions );
MATERIAL::SetDefaultReflectionRayCount(
m_boardAdapter.m_Cfg->m_Render.raytrace_nrsamples_reflections );
MATERIAL::SetDefaultRefractionRecursionCount( m_boardAdapter.m_Cfg->m_Render.raytrace_recursivelevel_refractions );
MATERIAL::SetDefaultReflectionRecursionCount( m_boardAdapter.m_Cfg->m_Render.raytrace_recursivelevel_reflections );
MATERIAL::SetDefaultRefractionRecursionCount(
m_boardAdapter.m_Cfg->m_Render.raytrace_recursivelevel_refractions );
MATERIAL::SetDefaultReflectionRecursionCount(
m_boardAdapter.m_Cfg->m_Render.raytrace_recursivelevel_reflections );
double mmTo3Dunits = pcbIUScale.IU_PER_MM * m_boardAdapter.BiuTo3dUnits();
@ -177,8 +181,8 @@ void RENDER_3D_RAYTRACE_BASE::setupMaterials()
void RENDER_3D_RAYTRACE_BASE::createObject( CONTAINER_3D& aDstContainer, const OBJECT_2D* aObject2D,
float aZMin, float aZMax, const MATERIAL* aMaterial,
const SFVEC3F& aObjColor )
float aZMin, float aZMax, const MATERIAL* aMaterial,
const SFVEC3F& aObjColor )
{
switch( aObject2D->GetObjectType() )
{
@ -541,7 +545,8 @@ void RENDER_3D_RAYTRACE_BASE::Reload( REPORTER* aStatusReporter, REPORTER* aWarn
radius );
objPtr->SetMaterial( &m_materials.m_EpoxyBoard );
objPtr->SetColor( ConvertSRGBToLinear( m_boardAdapter.m_BoardBodyColor ) );
objPtr->SetColor(
ConvertSRGBToLinear( m_boardAdapter.m_BoardBodyColor ) );
m_objectContainer.Add( objPtr );
}
@ -560,7 +565,8 @@ void RENDER_3D_RAYTRACE_BASE::Reload( REPORTER* aStatusReporter, REPORTER* aWarn
aStatusReporter->Report( _( "Load Raytracing: layers" ) );
// Add layers maps (except B_Mask and F_Mask)
for( const std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& entry : m_boardAdapter.GetLayerMap() )
for( const std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& entry :
m_boardAdapter.GetLayerMap() )
{
const PCB_LAYER_ID layer_id = entry.first;
const BVH_CONTAINER_2D* container2d = entry.second;
@ -667,7 +673,8 @@ void RENDER_3D_RAYTRACE_BASE::Reload( REPORTER* aStatusReporter, REPORTER* aWarn
{
const MATERIAL* materialLayer = &m_materials.m_SolderMask;
for( const std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& entry : m_boardAdapter.GetLayerMap() )
for( const std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& entry :
m_boardAdapter.GetLayerMap() )
{
const PCB_LAYER_ID layer_id = entry.first;
const BVH_CONTAINER_2D* container2d = entry.second;
@ -1193,7 +1200,8 @@ void RENDER_3D_RAYTRACE_BASE::addPadsAndVias()
}
void RENDER_3D_RAYTRACE_BASE::load3DModels( CONTAINER_3D& aDstContainer, bool aSkipMaterialInformation )
void RENDER_3D_RAYTRACE_BASE::load3DModels( CONTAINER_3D& aDstContainer,
bool aSkipMaterialInformation )
{
if( !m_boardAdapter.GetBoard() )
return;
@ -1249,6 +1257,7 @@ void RENDER_3D_RAYTRACE_BASE::load3DModels( CONTAINER_3D& aDstContainer, bool aS
wxString libraryName = fp->GetFPID().GetLibNickname();
wxString footprintBasePath = wxEmptyString;
if( m_boardAdapter.GetBoard()->GetProject() )
{
try
@ -1409,8 +1418,8 @@ MODEL_MATERIALS* RENDER_3D_RAYTRACE_BASE::getModelMaterial( const S3DMODEL* a3DM
void RENDER_3D_RAYTRACE_BASE::addModels( CONTAINER_3D& aDstContainer, const S3DMODEL* a3DModel,
const glm::mat4& aModelMatrix, float aFPOpacity,
bool aSkipMaterialInformation, BOARD_ITEM* aBoardItem )
const glm::mat4& aModelMatrix, float aFPOpacity,
bool aSkipMaterialInformation, BOARD_ITEM* aBoardItem )
{
// Validate a3DModel pointers
wxASSERT( a3DModel != nullptr );

View File

@ -345,22 +345,22 @@ protected:
SFVEC3F m_specularColor;
float m_reflectivity;
///< 1.0 is completely transparent, 0.0 completely opaque.
/// 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_castShadows; ///< true if this object will block the light.
///< Number of rays that will be interpolated for this material if it is transparent.
/// 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.
/// Number of rays that will be interpolated for this material if it is reflective.
unsigned int m_reflectionRayCount;
///< Number of levels it allows for refraction recursiveness.
/// Number of levels it allows for refraction recursiveness.
unsigned int m_refractionRecursionCount;
///< Number of levels it allows for reflection recursiveness.
/// Number of levels it allows for reflection recursiveness.
unsigned int m_reflectionRecursionCount;
const MATERIAL_GENERATOR* m_generator;

View File

@ -256,6 +256,7 @@ static SFVEC3F convertLinearToSRGB( const SFVEC3F& aRGBcolor )
glm::lessThan( clampedColor, SFVEC3F(0.0031308f) ) );
}
static SFVEC4F convertLinearToSRGBA( const SFVEC4F& aRGBAcolor )
{
return SFVEC4F( convertLinearToSRGB( SFVEC3F( aRGBAcolor ) ), aRGBAcolor.a );
@ -275,6 +276,7 @@ SFVEC3F ConvertSRGBToLinear( const SFVEC3F& aSRGBcolor )
glm::lessThanEqual( aSRGBcolor, SFVEC3F( 0.04045f ) ) );
}
SFVEC4F ConvertSRGBAToLinear( const SFVEC4F& aSRGBAcolor )
{
return SFVEC4F( ConvertSRGBToLinear( SFVEC3F( aSRGBAcolor ) ), aSRGBAcolor.a );
@ -319,8 +321,8 @@ static void HITINFO_PACKET_init( HITINFO_PACKET* aHitPacket )
void RENDER_3D_RAYTRACE_BASE::renderRayPackets( const SFVEC4F* bgColorY, const RAY* aRayPkt,
HITINFO_PACKET* aHitPacket, bool is_testShadow,
SFVEC4F* aOutHitColor )
HITINFO_PACKET* aHitPacket, bool is_testShadow,
SFVEC4F* aOutHitColor )
{
for( unsigned int y = 0, i = 0; y < RAYPACKET_DIM; ++y )
{
@ -341,9 +343,9 @@ void RENDER_3D_RAYTRACE_BASE::renderRayPackets( const SFVEC4F* bgColorY, const R
void RENDER_3D_RAYTRACE_BASE::renderAntiAliasPackets( const SFVEC4F* aBgColorY,
const HITINFO_PACKET* aHitPck_X0Y0,
const HITINFO_PACKET* aHitPck_AA_X1Y1,
const RAY* aRayPck, SFVEC4F* aOutHitColor )
const HITINFO_PACKET* aHitPck_X0Y0,
const HITINFO_PACKET* aHitPck_AA_X1Y1,
const RAY* aRayPck, SFVEC4F* aOutHitColor )
{
const bool is_testShadow = m_boardAdapter.m_Cfg->m_Render.raytrace_shadows;
@ -368,8 +370,8 @@ void RENDER_3D_RAYTRACE_BASE::renderAntiAliasPackets( const SFVEC4F* aBgColorY,
unsigned int nodex1y0 = 0;
if( x < (RAYPACKET_DIM - 1) )
nodex1y0 = aHitPck_X0Y0[ i + 1 ].m_HitInfo.m_acc_node_info;
if( x < ( RAYPACKET_DIM - 1 ) )
nodex1y0 = aHitPck_X0Y0[i + 1].m_HitInfo.m_acc_node_info;
unsigned int nodex0y1 = 0;
@ -503,9 +505,9 @@ void RENDER_3D_RAYTRACE_BASE::renderBlockTracing( uint8_t* ptrPBO, signed int iB
for( unsigned int x = 0; x < RAYPACKET_DIM; ++x )
{
m_postShaderSsao.SetPixelData( blockPos.x + x, yBlockPos,
SFVEC3F( 0.0f ), outColor,
SFVEC3F( 0.0f ), 0, 1.0f );
m_postShaderSsao.SetPixelData( blockPos.x + x, yBlockPos,
SFVEC3F( 0.0f ), outColor,
SFVEC3F( 0.0f ), 0, 1.0f );
}
}
}
@ -727,7 +729,8 @@ void RENDER_3D_RAYTRACE_BASE::postProcessShading( uint8_t* /* ptrPBO */, REPORTE
}
void RENDER_3D_RAYTRACE_BASE::postProcessBlurFinish( uint8_t* ptrPBO, REPORTER* /* aStatusReporter */ )
void RENDER_3D_RAYTRACE_BASE::postProcessBlurFinish( uint8_t* ptrPBO,
REPORTER* /* aStatusReporter */ )
{
if( m_boardAdapter.m_Cfg->m_Render.raytrace_post_processing )
{
@ -854,9 +857,9 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
hitColorShading[i] = bhColorY;
}
COLOR_RGBA cLRB_old[(RAYPACKET_DIM - 1)];
COLOR_RGBA cLRB_old[( RAYPACKET_DIM - 1 )];
for( unsigned int y = 0; y < (RAYPACKET_DIM - 1); ++y )
for( unsigned int y = 0; y < ( RAYPACKET_DIM - 1 ); ++y )
{
const SFVEC4F bgColorY = bgColor[y];
const COLOR_RGBA bgColorYRGB = COLOR_RGBA( bgColorY );
@ -981,11 +984,12 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
hitInfoLRT.m_tHit = ( hitPacket[ iLT ].m_HitInfo.m_tHit +
hitPacket[ iRT ].m_HitInfo.m_tHit ) * 0.5f;
hitInfoLRT.m_HitNormal =
glm::normalize( ( hitPacket[ iLT ].m_HitInfo.m_HitNormal +
hitPacket[ iRT ].m_HitInfo.m_HitNormal ) * 0.5f );
glm::normalize( ( hitPacket[iLT].m_HitInfo.m_HitNormal
+ hitPacket[iRT].m_HitInfo.m_HitNormal )
* 0.5f );
cLRT = COLOR_RGBA( shadeHit( bgColorY, rayLRT, hitInfoLRT, false,
0, false ) );
0, false ) );
cLRT = BlendColor( cLRT, BlendColor( cLT, cRT ) );
}
else
@ -1017,8 +1021,8 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
if( m_accelerator->Intersect( rayLRT,hitInfoLRT ) )
cLRT = COLOR_RGBA( shadeHit( bgColorY, rayLRT,
hitInfoLRT, false,
0, false ) );
hitInfoLRT, false,
0, false ) );
}
}
}
@ -1039,7 +1043,7 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
// Trace the center ray
RAY rayLTB;
rayLTB.Init( ( oriLT + oriLB ) * 0.5f,
glm::normalize( ( dirLT + dirLB ) * 0.5f ) );
glm::normalize( ( dirLT + dirLB ) * 0.5f ) );
HITINFO hitInfoLTB;
hitInfoLTB.m_tHit = std::numeric_limits<float>::infinity();
@ -1052,10 +1056,11 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
hitInfoLTB.m_tHit = ( hitPacket[ iLT ].m_HitInfo.m_tHit +
hitPacket[ iLB ].m_HitInfo.m_tHit ) * 0.5f;
hitInfoLTB.m_HitNormal =
glm::normalize( ( hitPacket[ iLT ].m_HitInfo.m_HitNormal +
hitPacket[ iLB ].m_HitInfo.m_HitNormal ) * 0.5f );
cLTB = COLOR_RGBA( shadeHit( bgColorY, rayLTB, hitInfoLTB, false,
0, false ) );
glm::normalize( ( hitPacket[iLT].m_HitInfo.m_HitNormal
+ hitPacket[iLB].m_HitInfo.m_HitNormal )
* 0.5f );
cLTB = COLOR_RGBA(
shadeHit( bgColorY, rayLTB, hitInfoLTB, false, 0, false ) );
cLTB = BlendColor( cLTB, BlendColor( cLT, cLB) );
}
else
@ -1080,15 +1085,15 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
if( hittedLTB )
cLTB = COLOR_RGBA( shadeHit( bgColorY, rayLTB, hitInfoLTB,
false, 0, false ) );
false, 0, false ) );
else
{
hitInfoLTB.m_tHit = std::numeric_limits<float>::infinity();
if( m_accelerator->Intersect( rayLTB, hitInfoLTB ) )
cLTB = COLOR_RGBA( shadeHit( bgColorY, rayLTB,
hitInfoLTB, false,
0, false ) );
hitInfoLTB, false,
0, false ) );
}
}
}
@ -1119,11 +1124,12 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
hitPacket[ iRB ].m_HitInfo.m_tHit ) * 0.5f;
hitInfoRTB.m_HitNormal =
glm::normalize( ( hitPacket[ iRT ].m_HitInfo.m_HitNormal +
hitPacket[ iRB ].m_HitInfo.m_HitNormal ) * 0.5f );
glm::normalize( ( hitPacket[iRT].m_HitInfo.m_HitNormal
+ hitPacket[iRB].m_HitInfo.m_HitNormal )
* 0.5f );
cRTB = COLOR_RGBA( shadeHit( bgColorY, rayRTB, hitInfoRTB, false, 0,
false ) );
false ) );
cRTB = BlendColor( cRTB, BlendColor( cRT, cRB ) );
}
else
@ -1149,7 +1155,7 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
if( hittedRTB )
{
cRTB = COLOR_RGBA( shadeHit( bgColorY, rayRTB, hitInfoRTB,
false, 0, false) );
false, 0, false) );
}
else
{
@ -1157,7 +1163,7 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
if( m_accelerator->Intersect( rayRTB, hitInfoRTB ) )
cRTB = COLOR_RGBA( shadeHit( bgColorY, rayRTB, hitInfoRTB,
false, 0, false ) );
false, 0, false ) );
}
}
}
@ -1188,11 +1194,12 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
hitPacket[ iRB ].m_HitInfo.m_tHit ) * 0.5f;
hitInfoLRB.m_HitNormal =
glm::normalize( ( hitPacket[ iLB ].m_HitInfo.m_HitNormal +
hitPacket[ iRB ].m_HitInfo.m_HitNormal ) * 0.5f );
glm::normalize( ( hitPacket[iLB].m_HitInfo.m_HitNormal
+ hitPacket[iRB].m_HitInfo.m_HitNormal )
* 0.5f );
cLRB = COLOR_RGBA( shadeHit( bgColorY, rayLRB, hitInfoLRB, false, 0,
false ) );
false ) );
cLRB = BlendColor( cLRB, BlendColor( cLB, cRB ) );
}
else
@ -1218,7 +1225,7 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
if( hittedLRB )
{
cLRB = COLOR_RGBA( shadeHit( bgColorY, rayLRB, hitInfoLRB,
false, 0, false ) );
false, 0, false ) );
}
else
{
@ -1226,7 +1233,7 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
if( m_accelerator->Intersect( rayLRB, hitInfoLRB ) )
cLRB = COLOR_RGBA( shadeHit( bgColorY, rayLRB, hitInfoLRB,
false, 0, false ) );
false, 0, false ) );
}
}
}
@ -1257,7 +1264,7 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
if( hitted )
cLTC = COLOR_RGBA( shadeHit( bgColorY, rayLTC, hitInfoLTC, false,
0, false ) );
0, false ) );
}
// Trace and shade cRTC
@ -1278,12 +1285,12 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
if( hittedC )
hitted = centerHitInfo.pHitObject->Intersect( rayRTC, hitInfoRTC );
else if( hitPacket[ iRT ].m_hitresult )
hitted = hitPacket[ iRT ].m_HitInfo.pHitObject->Intersect( rayRTC,
hitInfoRTC );
hitted = hitPacket[iRT].m_HitInfo.pHitObject->Intersect(
rayRTC, hitInfoRTC );
if( hitted )
cRTC = COLOR_RGBA( shadeHit( bgColorY, rayRTC, hitInfoRTC, false,
0, false ) );
0, false ) );
}
// Trace and shade cLBC
@ -1304,12 +1311,12 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
if( hittedC )
hitted = centerHitInfo.pHitObject->Intersect( rayLBC, hitInfoLBC );
else if( hitPacket[ iLB ].m_hitresult )
hitted = hitPacket[ iLB ].m_HitInfo.pHitObject->Intersect( rayLBC,
hitInfoLBC );
hitted = hitPacket[iLB].m_HitInfo.pHitObject->Intersect(
rayLBC, hitInfoLBC );
if( hitted )
cLBC = COLOR_RGBA( shadeHit( bgColorY, rayLBC, hitInfoLBC, false,
0, false ) );
0, false ) );
}
// Trace and shade cRBC
@ -1330,12 +1337,12 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
if( hittedC )
hitted = centerHitInfo.pHitObject->Intersect( rayRBC, hitInfoRBC );
else if( hitPacket[ iRB ].m_hitresult )
hitted = hitPacket[ iRB ].m_HitInfo.pHitObject->Intersect( rayRBC,
hitInfoRBC );
hitted = hitPacket[iRB].m_HitInfo.pHitObject->Intersect(
rayRBC, hitInfoRBC );
if( hitted )
cRBC = COLOR_RGBA( shadeHit( bgColorY, rayRBC, hitInfoRBC, false,
0, false ) );
0, false ) );
}
// Set pixel colors
@ -1382,9 +1389,9 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
#define USE_EXPERIMENTAL_SOFT_SHADOWS 1
SFVEC4F RENDER_3D_RAYTRACE_BASE::shadeHit( const SFVEC4F& aBgColor, const RAY& aRay, HITINFO& aHitInfo,
bool aIsInsideObject, unsigned int aRecursiveLevel,
bool is_testShadow ) const
SFVEC4F RENDER_3D_RAYTRACE_BASE::shadeHit( const SFVEC4F& aBgColor, const RAY& aRay,
HITINFO& aHitInfo, bool aIsInsideObject,
unsigned int aRecursiveLevel, bool is_testShadow ) const
{
const MATERIAL* objMaterial = aHitInfo.pHitObject->GetMaterial();
wxASSERT( objMaterial != nullptr );
@ -1536,9 +1543,10 @@ SFVEC4F RENDER_3D_RAYTRACE_BASE::shadeHit( const SFVEC4F& aBgColor, const RAY& a
{
// Apply some randomize to the reflected vector
const SFVEC3F random_reflectVector =
glm::normalize( reflectVector +
UniformRandomHemisphereDirection() *
m_boardAdapter.m_Cfg->m_Render.raytrace_spread_reflections );
glm::normalize( reflectVector
+ UniformRandomHemisphereDirection()
* m_boardAdapter.m_Cfg->m_Render
.raytrace_spread_reflections );
reflectedRay.Init( hitPoint, random_reflectVector );
}
@ -1548,13 +1556,14 @@ SFVEC4F RENDER_3D_RAYTRACE_BASE::shadeHit( const SFVEC4F& aBgColor, const RAY& a
if( m_accelerator->Intersect( reflectedRay, reflectedHit ) )
{
SFVEC4F add = ( diffuseColorObj + SFVEC4F( objMaterial->GetSpecularColor(), 1.0f ) ) *
shadeHit( aBgColor, reflectedRay, reflectedHit, false,
aRecursiveLevel + 1, is_testShadow ) *
SFVEC4F( objMaterial->GetReflection() *
// Falloff factor
(1.0f / ( 1.0f + 0.75f * reflectedHit.m_tHit *
reflectedHit.m_tHit) ) );
SFVEC4F add = ( diffuseColorObj + SFVEC4F( objMaterial->GetSpecularColor(),
1.0f ) ) *
shadeHit( aBgColor, reflectedRay, reflectedHit, false,
aRecursiveLevel + 1, is_testShadow ) *
SFVEC4F( objMaterial->GetReflection() *
// Falloff factor
(1.0f / ( 1.0f + 0.75f * reflectedHit.m_tHit *
reflectedHit.m_tHit) ) );
sum_color += add;
}

View File

@ -35,10 +35,10 @@
#include <map>
/// Vector of materials
/// Vector of materials.
typedef std::vector< BLINN_PHONG_MATERIAL > MODEL_MATERIALS;
/// Maps a S3DMODEL pointer with a created BLINN_PHONG_MATERIAL vector
/// Maps a #S3DMODEL pointer with a created BLINN_PHONG_MATERIAL vector.
typedef std::map< const S3DMODEL* , MODEL_MATERIALS > MAP_MODEL_MATERIALS;
typedef enum
@ -167,7 +167,7 @@ protected:
CONTAINER_3D m_objectContainer;
///< 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;
@ -178,16 +178,16 @@ protected:
SFVEC4F m_backgroundColorTop;
SFVEC4F m_backgroundColorBottom;
///< Used to see if the windows size changed.
/// Used to see if the windows size changed.
wxSize m_oldWindowsSize;
///< Encode Morton code positions.
/// Encode Morton code positions.
std::vector< SFVEC2UI > m_blockPositions;
///< Flag 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;
///< Encode 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;

View File

@ -36,7 +36,8 @@
#include <wx/log.h>
RENDER_3D_RAYTRACE_GL::RENDER_3D_RAYTRACE_GL( EDA_3D_CANVAS* aCanvas, BOARD_ADAPTER& aAdapter, CAMERA& aCamera ) :
RENDER_3D_RAYTRACE_GL::RENDER_3D_RAYTRACE_GL( EDA_3D_CANVAS* aCanvas, BOARD_ADAPTER& aAdapter,
CAMERA& aCamera ) :
RENDER_3D_RAYTRACE_BASE( aAdapter, aCamera )
{
wxLogTrace( m_logTrace, wxT( "RENDER_3D_RAYTRACE_GL::RENDER_3D_RAYTRACE_GL" ) );
@ -79,7 +80,7 @@ void RENDER_3D_RAYTRACE_GL::SetCurWindowSize( const wxSize& aSize )
bool RENDER_3D_RAYTRACE_GL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
REPORTER* aWarningReporter )
REPORTER* aWarningReporter )
{
bool requestRedraw = false;

View File

@ -268,20 +268,20 @@ bool BBOX_2D::Intersect( const RAY2D& aRay, float* t ) const
else
*t = tmax;
return (tmax >= 0.0f) && (tmax >= tmin);
return ( tmax >= 0.0f ) && ( tmax >= tmin );
}
bool BBOX_2D::Intersect( const RAYSEG2D& aRaySeg ) const
{
const float tx1 = (m_min.x - aRaySeg.m_Start.x) * aRaySeg.m_InvDir.x;
const float tx2 = (m_max.x - aRaySeg.m_Start.x) * aRaySeg.m_InvDir.x;
const float tx1 = ( m_min.x - aRaySeg.m_Start.x ) * aRaySeg.m_InvDir.x;
const float tx2 = ( m_max.x - aRaySeg.m_Start.x ) * aRaySeg.m_InvDir.x;
float tmin = glm::min( tx1, tx2 );
float tmax = glm::max( tx1, tx2 );
const float ty1 = (m_min.y - aRaySeg.m_Start.y) * aRaySeg.m_InvDir.y;
const float ty2 = (m_max.y - aRaySeg.m_Start.y) * aRaySeg.m_InvDir.y;
const float ty1 = ( m_min.y - aRaySeg.m_Start.y ) * aRaySeg.m_InvDir.y;
const float ty2 = ( m_max.y - aRaySeg.m_Start.y ) * aRaySeg.m_InvDir.y;
tmin = glm::max( tmin, glm::min( ty1, ty2 ) );
tmax = glm::min( tmax, glm::max( ty1, ty2 ) );

View File

@ -291,10 +291,10 @@ bool BBOX_3D::Intersect( const RAY& aRay, float* aOutHitt0, float* aOutHitt1 ) c
if( ( tmin > tzmax ) || ( tzmin > tmax ) )
return false;
tmin = (tzmin > tmin)? tzmin : tmin;
tmin = ( tmin < 0.0f)? 0.0f : tmin;
tmin = ( tzmin > tmin ) ? tzmin : tmin;
tmin = ( tmin < 0.0f ) ? 0.0f : tmin;
tmax = (tzmax < tmax)? tzmax : tmax;
tmax = ( tzmax < tmax ) ? tzmax : tmax;
*aOutHitt0 = tmin;
*aOutHitt1 = tmax;

Some files were not shown because too many files have changed in this diff Show More