From 586c25f864f9b8c06b84462bf2a80895a657331e Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 23 Sep 2013 14:48:46 +0200 Subject: [PATCH] When clearing the dynmat, should clear all of them. Also fixes a crash. --HG-- branch : gsoc2013-dfighter --- code/nel/include/nel/3d/material.h | 3 +++ code/nel/src/3d/material.cpp | 13 +++++++++---- .../src/plugins/material_editor/nel3d_interface.cpp | 4 +++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/code/nel/include/nel/3d/material.h b/code/nel/include/nel/3d/material.h index a1670b5ea..97759ef58 100644 --- a/code/nel/include/nel/3d/material.h +++ b/code/nel/include/nel/3d/material.h @@ -706,6 +706,9 @@ public: /// Create the dynamic material from the current material parameters void createDynMat(); + /// Creates a clean dynamic material instance + void createCleanDynMat(); + // Private. For Driver only. CSmartPtr _Textures[IDRV_MAT_MAXTEXTURES]; uint8 _TexAddrMode[IDRV_MAT_MAXTEXTURES]; // texture addressing enum packed as bytes diff --git a/code/nel/src/3d/material.cpp b/code/nel/src/3d/material.cpp index cf0dc3701..76cc363f0 100644 --- a/code/nel/src/3d/material.cpp +++ b/code/nel/src/3d/material.cpp @@ -652,10 +652,7 @@ bool CMaterial::isSupportedByDriver(IDriver &drv, bool forceBaseCaps) const void CMaterial::createDynMat() { - if( dynMat == NULL ) - dynMat = new CDynMaterial(); - else - dynMat->reconstruct(); + createCleanDynMat(); SRenderPass *p = dynMat->getPass( 0 ); @@ -862,5 +859,13 @@ void CMaterial::createDynMat() } } +void CMaterial::createCleanDynMat() +{ + if( dynMat == NULL ) + dynMat = new CDynMaterial(); + else + dynMat->reconstruct(); +} + } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/nel3d_interface.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/nel3d_interface.cpp index 056591b02..bf13b08a3 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/nel3d_interface.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/nel3d_interface.cpp @@ -299,7 +299,9 @@ namespace MaterialEditor { if( currentShape.empty() ) return; - currentShape.getMaterial( 0 ).getObjectPtr()->getDynMat()->clear(); + + for( int i = 0; i < currentShape.getNumMaterials(); i++ ) + currentShape.getMaterial( i ).getObjectPtr()->createCleanDynMat(); } bool CNel3DInterface::selectSubMaterial( int id )