EgtGeomKernel 1.5e1 :

- in TriMesh migliorato lo smooth delle normali
- in TriMesh aggiunta generazione per rivoluzione
- migliorati gestione e aggiornamento materiali.
This commit is contained in:
Dario Sassi
2014-05-02 06:57:24 +00:00
parent e080543b97
commit 1b767fe58e
12 changed files with 621 additions and 110 deletions
+17 -7
View File
@@ -1408,7 +1408,7 @@ GeomDB::SetMaterial( GdbObj* pGdbObj, const string& sMatName)
// recupero il materiale per assegnare anche il colore
Material mMat ;
GetMaterial( nIdMat, mMat) ;
GetMaterialData( nIdMat, mMat) ;
// assegno il materiale tramite indice
return ( pGdbObj->SetMaterial( mMat.GetDiffuse()) &&
@@ -1580,7 +1580,7 @@ GeomDB::UsedMaterialInGroup( int nMat, const GdbGroup* pGdbGroup) const
//----------------------------------------------------------------------------
bool
GeomDB::NotifyObjectsWithMaterialInGroup( int nMat, bool bByParent, GdbGroup* pGdbGroup)
GeomDB::NotifyObjectsWithMaterialInGroup( int nMat, Color cCol, bool bByParent, GdbGroup* pGdbGroup)
{
// verifico se il gruppo utilizza direttamente il materiale
int nObjMat ;
@@ -1589,6 +1589,11 @@ GeomDB::NotifyObjectsWithMaterialInGroup( int nMat, bool bByParent, GdbGroup* pG
nObjMat = GDB_MT_PARENT ;
// se il materiale è usato dal gruppo
bByParent = ( nObjMat == nMat || ( nObjMat == GDB_MT_PARENT && bByParent)) ;
// eventuale aggiornamento del colore
if ( nObjMat == nMat) {
pGdbGroup->SetMaterial( cCol) ;
pGdbGroup->SetMaterial( nMat) ;
}
// scandisco il gruppo
bool bOk = true ;
for ( GdbObj* pGdbObj = pGdbGroup->GetFirstObj() ;
@@ -1597,7 +1602,7 @@ GeomDB::NotifyObjectsWithMaterialInGroup( int nMat, bool bByParent, GdbGroup* pG
// se sottogruppo, devo cercare nei suoi figli
GdbGroup* pGdbSubGrp ;
if ( ( pGdbSubGrp = ::GetGdbGroup( pGdbObj)) != nullptr) {
if ( ! NotifyObjectsWithMaterialInGroup( nMat, bByParent, pGdbSubGrp))
if ( ! NotifyObjectsWithMaterialInGroup( nMat, cCol, bByParent, pGdbSubGrp))
bOk = false ;
}
// altrimenti oggetto
@@ -1611,6 +1616,11 @@ GeomDB::NotifyObjectsWithMaterialInGroup( int nMat, bool bByParent, GdbGroup* pG
if ( ! pGdbObj->OnSetMaterial())
bOk = false ;
}
// eventuale aggiornamento del colore
if ( nObjMat == nMat) {
pGdbObj->SetMaterial( cCol) ;
pGdbObj->SetMaterial( nMat) ;
}
}
}
@@ -1739,7 +1749,7 @@ GeomDB::EraseMaterial( int nMat, bool& bInUse)
bool
GeomDB::GetMaterialData( int nMat, Material& matM) const
{
return m_MatManager.GetMaterial( nMat, matM) ;
return m_MatManager.GetMaterialData( nMat, matM) ;
}
//----------------------------------------------------------------------------
@@ -1774,10 +1784,10 @@ GeomDB::IsCustomMaterial( int nMat, bool& bCustom) const
bool
GeomDB::ModifyMaterialData( int nMat, const Material& matM)
{
if ( ! m_MatManager.ModifyMaterial( nMat, matM))
if ( ! m_MatManager.ModifyMaterialData( nMat, matM))
return false ;
// notifico gli oggetti che usano questo materiale
NotifyObjectsWithMaterialInGroup( nMat, false, &m_GrpRadix) ;
// notifico gli oggetti che usano questo materiale (e gli aggiorno il colore)
NotifyObjectsWithMaterialInGroup( nMat, matM.GetDiffuse(), false, &m_GrpRadix) ;
return true ;
}