From b846574445ac7c7b2eeda80d98e6c9cbcc0f49ac Mon Sep 17 00:00:00 2001
From: Dominik Rausch <dominik.rausch@rwth-aachen.de>
Date: Tue, 9 Aug 2016 14:21:33 +0200
Subject: [PATCH] Revert "Fixed OpenSGMultiMaterial bug with native pipeline"

This reverts commit c02f0df167e21914d6c9ba8f4c0314dd456c5e80.
---
 .../VistaOpenSGMultiMaterial.cpp              | 53 ++++++++++++++++---
 1 file changed, 46 insertions(+), 7 deletions(-)

diff --git a/VistaCoreLibs/VistaKernelOpenSGExt/VistaOpenSGMultiMaterial.cpp b/VistaCoreLibs/VistaKernelOpenSGExt/VistaOpenSGMultiMaterial.cpp
index c62cfb80c..7e0afe77c 100644
--- a/VistaCoreLibs/VistaKernelOpenSGExt/VistaOpenSGMultiMaterial.cpp
+++ b/VistaCoreLibs/VistaKernelOpenSGExt/VistaOpenSGMultiMaterial.cpp
@@ -22,6 +22,8 @@
 /*============================================================================*/
 
 
+
+
 #include "VistaOpenSGMultiMaterial.h"
 
 #include "VistaKernel/DisplayManager/VistaDisplayManager.h"
@@ -100,6 +102,7 @@ public:
 		beginEditCP( m_pMaterial );
 			m_pMaterial->addChunk( m_pMaterialChunk );
 			m_pMaterial->addChunk( m_pPolygonChunk );
+			m_pMaterial->addChunk( m_pShaderUniforms );
 		endEditCP( m_pMaterial );
 
 		UpdateFogParameter();
@@ -135,11 +138,9 @@ public:
 		{
 			if( m_pCurrentShader != osg::NullFC )
 			{
-				beginEditCP( m_pMaterial );
-					m_pMaterial->subChunk( m_pShaderUniforms );
-					m_pMaterial->subChunk( m_pCurrentShader );
-					m_pCurrentShader = osg::NullFC;
-				endEditCP( m_pMaterial );
+				m_pMaterial->subChunk( m_pShaderUniforms );
+				m_pMaterial->subChunk( m_pCurrentShader );
+				m_pCurrentShader = osg::NullFC;
 			}		
 		}
 		else
@@ -152,7 +153,7 @@ public:
 			}
 			m_pCurrentShader = GetShader();
 
-			beginEditCP( m_pShaderUniforms );
+			beginEditCP( m_pShaderUniforms, osg::SHLParameterChunk::SHLChunkFieldMask );
 			m_pShaderUniforms->setSHLChunk( m_pCurrentShader );
 			//m_pShaderUniforms->clearUniformParameters();
 			m_pShaderUniforms->subUniformParameter( "nReflectionFactor" );
@@ -160,7 +161,7 @@ public:
 			m_pShaderUniforms->subUniformParameter( "nFogType" );
 			m_pShaderUniforms->subUniformParameter( "u_v4TexCoordScale" );
 			m_pShaderUniforms->subUniformParameter( "nBlendFactor" );
-			endEditCP( m_pShaderUniforms );
+			endEditCP( m_pShaderUniforms, osg::SHLParameterChunk::SHLChunkFieldMask );
 
 			m_pMaterial->addChunk( m_pCurrentShader );
 			m_pMaterial->addChunk( m_pShaderUniforms );
@@ -1197,6 +1198,44 @@ bool VistaOpenSGMultiMaterial::ApplyTo( osg::GeometryPtr pGeometry, const bool b
 
 	if( bReplaceVertexColors )
 	{
+		//beginEditCP( pGeometry );
+		//	osg::MFUInt16& vecGeoIndices = pGeometry->getIndexMapping();
+		//	std::size_t nColorIndex = -1;
+		//	std::size_t nTotalIndices = vecGeoIndices.size();
+		//	for( int i = 0; i < vecGeoIndices.size(); ++i )
+		//	{
+		//		if( vecGeoIndices[i] == osg::Geometry::MapNormal )
+		//		{
+		//			vecGeoIndices.erase( vecGeoIndices.begin() + i );
+		//			nColorIndex = 1;
+		//			break;
+		//		}
+		//	}
+		//	if( nColorIndex >= 0 )
+		//	{
+		//		osg::GeoIndicesPtr pIndices = pGeometry->editIndices();
+		//		beginEditCP( pIndices );
+		//		{
+		//			// indices for the polygon
+		//			for( i = 0; i < n; ++i )
+		//			{
+		//				if( vFormat.coordinate == VistaVertexFormat::COORDINATE )
+		//					indices->push_back(vertices[i].GetCoordinateIndex());
+
+		//				if( vFormat.color ==  VistaVertexFormat::COLOR_RGB )
+		//					indices->push_back(vertices[i].GetColorIndex());
+
+		//				if( vFormat.normal == VistaVertexFormat::NORMAL )
+		//					indices->push_back(vertices[i].GetNormalIndex());
+
+		//				if( vFormat.textureCoord == VistaVertexFormat::TEXTURE_COORD_2D    )
+		//					indices->push_back(vertices[i].GetTextureCoordinateIndex());
+		//			}
+		//		}
+		//		endEditCP( pIndices );
+		//	}
+		//endEditCP( pGeometry );
+		
 		beginEditCP( pGeometry );
 		osg::Color4f oFullColor = m_pInternals->m_pMaterialChunk->getDiffuse();
 		osg::GeoColorsPtr pColors = pGeometry->getColors();
-- 
GitLab