From 80bcf2026ab0853c0f16a7147b4cc0953869bb94 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 20 Jul 2013 22:45:17 +0200 Subject: [PATCH] If dynamic material already exists, simply just reinitialize it. --HG-- branch : gsoc2013-dfighter --- code/nel/include/nel/3d/dynamic_material.h | 1 + code/nel/src/3d/dynamic_material.cpp | 12 +++++++++--- code/nel/src/3d/material.cpp | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/code/nel/include/nel/3d/dynamic_material.h b/code/nel/include/nel/3d/dynamic_material.h index 4e07443d3..bc89a88a2 100644 --- a/code/nel/include/nel/3d/dynamic_material.h +++ b/code/nel/include/nel/3d/dynamic_material.h @@ -81,6 +81,7 @@ namespace NL3D public: CDynMaterial(); ~CDynMaterial(); + void reconstruct(); void clear(); void serial( NLMISC::IStream &f ); std::string getClassName(){ return "CDynMaterial"; } diff --git a/code/nel/src/3d/dynamic_material.cpp b/code/nel/src/3d/dynamic_material.cpp index 3ef282b26..7202f9a05 100644 --- a/code/nel/src/3d/dynamic_material.cpp +++ b/code/nel/src/3d/dynamic_material.cpp @@ -150,9 +150,7 @@ namespace NL3D CDynMaterial::CDynMaterial() { - SRenderPass *p = new SRenderPass(); - p->setName( "pass1" ); - passes.push_back( p ); + reconstruct(); } CDynMaterial::~CDynMaterial() @@ -160,6 +158,14 @@ namespace NL3D clear(); } + void CDynMaterial::reconstruct() + { + clear(); + SRenderPass *p = new SRenderPass(); + p->setName( "pass1" ); + passes.push_back( p ); + } + void CDynMaterial::clear() { std::vector< SRenderPass* >::iterator itr = passes.begin(); diff --git a/code/nel/src/3d/material.cpp b/code/nel/src/3d/material.cpp index deb447d2c..0a16687c8 100644 --- a/code/nel/src/3d/material.cpp +++ b/code/nel/src/3d/material.cpp @@ -641,6 +641,8 @@ void CMaterial::createDynMat() { if( dynMat == NULL ) dynMat = new CDynMaterial(); + else + dynMat->reconstruct(); SRenderPass *p = dynMat->getPass( 0 );