7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-11 14:50:11 +00:00

Fix an issue causing "zbot < ztop" assert in 3D viewer on multilayer boards.

This commit is contained in:
Alex Shvartzkop 2024-09-19 10:07:32 +05:00
parent 4002058774
commit 05b4aace38
2 changed files with 20 additions and 6 deletions

View File

@ -642,6 +642,24 @@ inline bool IsBackLayer( PCB_LAYER_ID aLayerId )
}
/**
* Returns true if copper aLayerA is placed lower than aLayerB, false otherwise.
*/
inline bool IsCopperLayerLowerThan( PCB_LAYER_ID aLayerA, PCB_LAYER_ID aLayerB )
{
if( aLayerA == aLayerB )
return false;
if( aLayerA == B_Cu )
return true;
if( aLayerB == B_Cu )
return false;
return aLayerA > aLayerB;
}
/**
* @return the layer number after flipping an item
* some (not all) layers: external copper, and paired layers( Mask, Paste, solder ... )

View File

@ -983,7 +983,7 @@ void PCB_VIA::LayerPair( PCB_LAYER_ID* top_layer, PCB_LAYER_ID* bottom_layer ) c
b_layer = Padstack().Drill().end;
t_layer = Padstack().Drill().start;
if( b_layer < t_layer )
if( !IsCopperLayerLowerThan( b_layer, t_layer ) )
std::swap( b_layer, t_layer );
}
@ -1015,11 +1015,7 @@ void PCB_VIA::SanitizeLayers()
Padstack().Drill().end = B_Cu;
}
if( Padstack().Drill().end < Padstack().Drill().start )
std::swap( Padstack().Drill().end, Padstack().Drill().start );
// Ensure B_Cu is never the first layer
if( Padstack().Drill().start == B_Cu )
if( !IsCopperLayerLowerThan( Padstack().Drill().end, Padstack().Drill().start) )
std::swap( Padstack().Drill().end, Padstack().Drill().start );
}