From 3c173e19651a944df76650de7c116e603e1dbc68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= <moebius@cs.rwth-aachen.de> Date: Thu, 23 Apr 2009 13:04:06 +0000 Subject: [PATCH] Make texture mode setting more stable ( string parser ) git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5773 383ad7c9-94d9-4d36-a494-682f7c89f535 --- TextureControl.cc | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/TextureControl.cc b/TextureControl.cc index d79a7fb..1abacaf 100644 --- a/TextureControl.cc +++ b/TextureControl.cc @@ -561,12 +561,20 @@ void TextureControlPlugin::slotSetTextureMode(QString _textureName ,QString _mod // ================================================================================ Texture& texture = globalTextures_.texture(_textureName); + // Cleanup representation + _mode = _mode.toLower(); + int i = 0; QString nextString = _mode.section(',',i,i); while ( nextString != "" ) { QString sectionName = nextString.section('=',0,0); QString value = nextString.section('=',1,1); + + // Cleanup representation + value = value.trimmed(); + sectionName = sectionName.trimmed(); + if ( sectionName == "clamp" ) { texture.parameters.clamp = StringToBool(value); } else @@ -591,8 +599,11 @@ void TextureControlPlugin::slotSetTextureMode(QString _textureName ,QString _mod if ( sectionName == "type" ) { if (value == "halfedgebased") { texture.type( HALFEDGEBASED ); - } else { + } else if ( value == "vertexbased") + { texture.type( VERTEXBASED ); + } else { + emit log(LOGERR,"Unknown texture type : " + value + " for texture: " + _textureName); } } else emit log(LOGERR,"Unknown texture mode : " + sectionName); @@ -701,6 +712,8 @@ void TextureControlPlugin::slotSetTextureMode(QString _textureName, QString _mod // ================================================================================ Texture& texture = texData->texture(_textureName); + _mode = _mode.toLower(); + bool changed = false; int i = 0; @@ -709,6 +722,10 @@ void TextureControlPlugin::slotSetTextureMode(QString _textureName, QString _mod QString sectionName = nextString.section('=',0,0); QString value = nextString.section('=',1,1); + // Cleanup representation + value = value.trimmed(); + sectionName = sectionName.trimmed(); + if ( sectionName == "clamp" ) { if ( StringToBool(value) != texture.parameters.clamp ) { texture.parameters.clamp = StringToBool(value); @@ -750,12 +767,14 @@ void TextureControlPlugin::slotSetTextureMode(QString _textureName, QString _mod changed = true; } } else if ( sectionName == "type" ) { - if (value == "halfedgebased") { + if ( ( value == "halfedgebased" ) && ( texture.type() != HALFEDGEBASED ) ) { texture.type( HALFEDGEBASED ); changed = true; - } else { + } else if ( (value == "vertexbased") && (texture.type() != HALFEDGEBASED) ) { texture.type( VERTEXBASED ); changed = true; + } else { + emit log(LOGERR,"Unknown texture type : " + value + " for texture: " + _textureName); } } else emit log(LOGERR,"Unknown texture mode : " + sectionName); -- GitLab