Просмотр исходного кода

Merge pull request #747 from raheelx/FlipInfacingNormals

Flip infacing normals
JoshEngebretson 9 лет назад
Родитель
Сommit
fe0077d566

+ 42 - 140
Source/Atomic/Engine/EngineConfig.cpp

@@ -31,38 +31,7 @@
 namespace Atomic
 {
 
-VariantMap EngineConfig::engineConfig_;
-String EngineConfig::engineConfigFilename_;
-
-bool EngineConfig::GetBoolValue(const JSONValue& jvalue, bool defaultValue)
-{
-    bool value = defaultValue;
-
-    if (jvalue.IsBool())
-        value = jvalue.GetBool();
-
-    return value;
-}
-
-int EngineConfig::GetIntValue(const JSONValue& jvalue, int defaultValue)
-{
-    int value = defaultValue;
-
-    if (jvalue.IsNumber())
-        value = jvalue.GetInt();
-
-    return value;
-}
-
-String EngineConfig::GetStringValue(const JSONValue& jvalue, const String& defaultValue)
-{
-    String value = defaultValue;
-
-    if (jvalue.IsString())
-        value = jvalue.GetString();
-
-    return value;
-}
+EngineConfig EngineConfig::engineConfig_;
 
 bool EngineConfig::LoadEngineConfig(const JSONValue& jengine)
 {
@@ -75,11 +44,11 @@ bool EngineConfig::LoadEngineConfig(const JSONValue& jengine)
         const JSONValue& jvalue = i->second_;
 
         if (key == "workerthreads")
-            engineConfig_["WorkerThreads"] = GetBoolValue(jvalue, true);
+            valueMap_["WorkerThreads"] = GetBoolValue(jvalue, true);
         else if (key == "logquiet")
-            engineConfig_["LogQuiet"] = GetBoolValue(jvalue, false);
+            valueMap_["LogQuiet"] = GetBoolValue(jvalue, false);
         else if (key == "loglevel")
-            engineConfig_["LogLevel"] = GetIntValue(jvalue, 1);
+            valueMap_["LogLevel"] = GetIntValue(jvalue, 1);
     }
 
     return true;
@@ -96,74 +65,74 @@ bool EngineConfig::LoadGraphicsConfig(const JSONValue& jgraphics)
         const JSONValue& jvalue = i->second_;
 
         if (key == "headless")
-            engineConfig_["Headless"] = GetBoolValue(jvalue, false);
+            valueMap_["Headless"] = GetBoolValue(jvalue, false);
         else if (key == "framelimiter")
-            engineConfig_["FrameLimiter"] = GetBoolValue(jvalue, true);
+            valueMap_["FrameLimiter"] = GetBoolValue(jvalue, true);
         else if (key == "flushgpu")
-            engineConfig_["FlushGPU"] = GetBoolValue(jvalue, false);
+            valueMap_["FlushGPU"] = GetBoolValue(jvalue, false);
         else if (key == "forcegl2")
-            engineConfig_["ForceGL2"] = GetBoolValue(jvalue, false);
+            valueMap_["ForceGL2"] = GetBoolValue(jvalue, false);
         else if (key == "orientations")
-            engineConfig_["Orientations"] = GetStringValue(jvalue, "LandscapeLeft LandscapeRight");
+            valueMap_["Orientations"] = GetStringValue(jvalue, "LandscapeLeft LandscapeRight");
         else if (key == "vsync")
-            engineConfig_["VSync"] = GetBoolValue(jvalue, false);
+            valueMap_["VSync"] = GetBoolValue(jvalue, false);
         else if (key == "triplebuffer")
-            engineConfig_["TripleBuffer"] = GetBoolValue(jvalue, false);
+            valueMap_["TripleBuffer"] = GetBoolValue(jvalue, false);
         else if (key == "multisample")
-            engineConfig_["Multisample"] = GetIntValue(jvalue, 1);
+            valueMap_["Multisample"] = GetIntValue(jvalue, 1);
         else if (key == "renderpath")
         {
             String renderPath = GetStringValue(jvalue, "forward").ToLower();
 
             if (renderPath == "forward")
-                engineConfig_["RenderPath"] = "RenderPaths/Forward.xml";
+                valueMap_["RenderPath"] = "RenderPaths/Forward.xml";
             else if (renderPath == "prepass")
-                engineConfig_["RenderPath"] = "RenderPaths/Prepass.xml";
+                valueMap_["RenderPath"] = "RenderPaths/Prepass.xml";
             else if (renderPath == "deferred")
-                engineConfig_["RenderPath"] = "RenderPaths/Deferred.xml";
+                valueMap_["RenderPath"] = "RenderPaths/Deferred.xml";
         }
         else if (key == "shadows")
-            engineConfig_["Shadows"] = GetBoolValue(jvalue, true);
+            valueMap_["Shadows"] = GetBoolValue(jvalue, true);
         else if (key == "lowqualityshadows")
-            engineConfig_["LowQualityShadows"] = GetBoolValue(jvalue, false);
+            valueMap_["LowQualityShadows"] = GetBoolValue(jvalue, false);
         else if (key == "materialquality")
         {
             String quality = GetStringValue(jvalue, "high").ToLower();
 
             if (quality == "high")
-                engineConfig_["MaterialQuality"] = QUALITY_HIGH;
+                valueMap_["MaterialQuality"] = QUALITY_HIGH;
             else if (quality == "medium")
-                engineConfig_["MaterialQuality"] = QUALITY_MEDIUM;
+                valueMap_["MaterialQuality"] = QUALITY_MEDIUM;
             else if (quality == "low")
-                engineConfig_["MaterialQuality"] = QUALITY_LOW;
+                valueMap_["MaterialQuality"] = QUALITY_LOW;
         }
         else if (key == "texturequality")
         {
             String quality = GetStringValue(jvalue, "high").ToLower();
 
             if (quality == "high")
-                engineConfig_["TextureQuality"] = QUALITY_HIGH;
+                valueMap_["TextureQuality"] = QUALITY_HIGH;
             else if (quality == "medium")
-                engineConfig_["TextureQuality"] = QUALITY_MEDIUM;
+                valueMap_["TextureQuality"] = QUALITY_MEDIUM;
             else if (quality == "low")
-                engineConfig_["TextureQuality"] = QUALITY_LOW;
+                valueMap_["TextureQuality"] = QUALITY_LOW;
         }
         else if (key == "texturefiltermode")
         {
             String mode = GetStringValue(jvalue, "trilinear").ToLower();
 
             if (mode == "trilinear")
-                engineConfig_["TextureFilterMode"] = FILTER_TRILINEAR;
+                valueMap_["TextureFilterMode"] = FILTER_TRILINEAR;
             else if (mode == "bilinear")
-                engineConfig_["TextureFilterMode"] = FILTER_BILINEAR;
+                valueMap_["TextureFilterMode"] = FILTER_BILINEAR;
             else if (mode == "nearest")
-                engineConfig_["TextureFilterMode"] = FILTER_NEAREST;
+                valueMap_["TextureFilterMode"] = FILTER_NEAREST;
             else if (mode == "anisotropic")
-                engineConfig_["TextureFilterMode"] = FILTER_ANISOTROPIC;
+                valueMap_["TextureFilterMode"] = FILTER_ANISOTROPIC;
         }
         else if (key == "textureanisotropy")
         {
-            engineConfig_["TextureAnisotropy"] = GetIntValue(jvalue, 4);
+            valueMap_["TextureAnisotropy"] = GetIntValue(jvalue, 4);
         }
 
 
@@ -183,21 +152,21 @@ bool EngineConfig::LoadWindowConfig(const JSONValue& jwindow)
         const JSONValue& jvalue = i->second_;
 
         if (key == "title")
-            engineConfig_["WindowTitle"] = GetStringValue(jvalue, "Atomic");
+            valueMap_["WindowTitle"] = GetStringValue(jvalue, "Atomic");
         else if (key == "fullscreen")
-            engineConfig_["FullScreen"] = GetBoolValue(jvalue, false);
+            valueMap_["FullScreen"] = GetBoolValue(jvalue, false);
         else if (key == "borderless")
-            engineConfig_["Borderless"] = GetBoolValue(jvalue, false);
+            valueMap_["Borderless"] = GetBoolValue(jvalue, false);
         else if (key == "resizable")
-            engineConfig_["WindowResizable"] = GetBoolValue(jvalue, false);
+            valueMap_["WindowResizable"] = GetBoolValue(jvalue, false);
         else if (key == "width")
-            engineConfig_["WindowWidth"] = GetIntValue(jvalue, false);
+            valueMap_["WindowWidth"] = GetIntValue(jvalue, false);
         else if (key == "height")
-            engineConfig_["WindowHeight"] = GetIntValue(jvalue, false);
+            valueMap_["WindowHeight"] = GetIntValue(jvalue, false);
         else if (key == "positionx")
-            engineConfig_["WindowPositionX"] = GetIntValue(jvalue, false);
+            valueMap_["WindowPositionX"] = GetIntValue(jvalue, false);
         else if (key == "positiony")
-            engineConfig_["WindowPositionY"] = GetIntValue(jvalue, false);
+            valueMap_["WindowPositionY"] = GetIntValue(jvalue, false);
 
     }
 
@@ -216,15 +185,15 @@ bool EngineConfig::LoadSoundConfig(const JSONValue& jsound)
         const JSONValue& jvalue = i->second_;
 
         if (key == "enabled")
-            engineConfig_["Sound"] = GetBoolValue(jvalue, true);
+            valueMap_["Sound"] = GetBoolValue(jvalue, true);
         else if (key == "interpolation")
-            engineConfig_["SoundInterpolation"] = GetBoolValue(jvalue, true);
+            valueMap_["SoundInterpolation"] = GetBoolValue(jvalue, true);
         else if (key == "stereo")
-            engineConfig_["SoundStereo"] = GetBoolValue(jvalue, true);
+            valueMap_["SoundStereo"] = GetBoolValue(jvalue, true);
         else if (key == "bufferms")
-            engineConfig_["SoundBuffer"] = GetIntValue(jvalue, 100);
+            valueMap_["SoundBuffer"] = GetIntValue(jvalue, 100);
         else if (key == "mixrate")
-            engineConfig_["SoundMixRate"] = GetIntValue(jvalue, 44100);
+            valueMap_["SoundMixRate"] = GetIntValue(jvalue, 44100);
 
     }
 
@@ -243,7 +212,7 @@ bool EngineConfig::LoadInputConfig(const JSONValue& jinput)
         const JSONValue& jvalue = i->second_;
 
         if (key == "touchemulation")
-            engineConfig_["TouchEmulation"] = GetBoolValue(jvalue, false);
+            valueMap_["TouchEmulation"] = GetBoolValue(jvalue, false);
     }
 
     return true;
@@ -281,71 +250,4 @@ bool EngineConfig::LoadDesktopConfig(JSONValue root)
     return true;
 }
 
-bool EngineConfig::LoadFromJSON(const String& json)
-{
-    engineConfig_.Clear();
-
-    JSONValue jroot;
-
-    if (!JSONFile::ParseJSON(json, jroot))
-    {
-        LOGERRORF("EngineConfig::LoadFromJSON - Unable to parse config file JSON: %s", engineConfigFilename_.CString());
-        return false;
-    }
-
-    if (!jroot.IsObject())
-        return false;
-
-    if (!LoadDesktopConfig(jroot))
-        return false;
-
-    return true;
-}
-
-bool EngineConfig::LoadFromFile(Context *context, const String& filename)
-{
-
-    FileSystem* fileSystem = context->GetSubsystem<FileSystem>();
-
-    if (!fileSystem->FileExists(filename))
-        return false;
-
-    engineConfigFilename_ = filename;
-
-    SharedPtr<File> file(new File(context));
-
-    if (!file->Open(filename))
-    {
-        LOGERRORF("EngineConfig::LoadFromFile - Unable to open config file %s", filename.CString());
-        return false;
-    }
-
-    String json;
-    file->ReadText(json);
-
-    return LoadFromJSON(json);
-}
-
-void EngineConfig::ApplyConfig(VariantMap& settings, bool overwrite)
-{
-    VariantMap::ConstIterator itr = engineConfig_.Begin();
-    if (overwrite)
-    { 
-        while (itr != engineConfig_.End())
-        {
-            settings[itr->first_] = itr->second_;
-            itr++;
-        }
-    }
-    else
-    {
-        while (itr != engineConfig_.End())
-        {
-            settings.InsertNew(itr->first_, itr->second_);
-            itr++;
-        }
-    }
-
-}
-
 }

+ 13 - 19
Source/Atomic/Engine/EngineConfig.h

@@ -24,6 +24,7 @@
 
 #include "../Core/Variant.h"
 #include "../Resource/JSONValue.h"
+#include "../Resource/Configuration.h"
 
 namespace Atomic
 {
@@ -31,36 +32,29 @@ namespace Atomic
 class Context;
 
 /// Atomic engine configuration
-class EngineConfig
+class EngineConfig :
+    Configuration
 {
 
 public:
 
-    static bool LoadFromFile(Context* context, const String& filename);
-    static bool LoadFromJSON(const String& json);
+    static bool LoadFromFile(Context* context, const String& filename) { return engineConfig_.Configuration::LoadFromFile(context, filename); }
+    static bool LoadFromJSON(const String& json) { return engineConfig_.Configuration::LoadFromJSON(json); }
 
     /// Apply the configuration to a setting variant map, values that exist will not be overriden
-    static void ApplyConfig(VariantMap& settings, bool overwrite = false);
-
-    static const VariantMap& GetConfig() { return engineConfig_; }
+    static void ApplyConfig(VariantMap& settings, bool overwrite = false) { return engineConfig_.Configuration::ApplyConfig(settings, overwrite); }
 
 private:
 
-    static bool LoadDesktopConfig(JSONValue root);
-    static bool LoadGraphicsConfig(const JSONValue& jgraphics);
-    static bool LoadWindowConfig(const JSONValue& jwindow);
-    static bool LoadSoundConfig(const JSONValue& jsound);
-    static bool LoadInputConfig(const JSONValue& jinput);
-
-    static bool GetBoolValue(const JSONValue& jvalue, bool defaultValue);
-    static int GetIntValue(const JSONValue& jvalue, int defaultValue);
-    static String GetStringValue(const JSONValue& jvalue, const String& defaultValue);
-
-    static bool LoadEngineConfig(const JSONValue& jengine);
+    virtual bool LoadDesktopConfig(JSONValue root);
+    bool LoadGraphicsConfig(const JSONValue& jgraphics);
+    bool LoadWindowConfig(const JSONValue& jwindow);
+    bool LoadSoundConfig(const JSONValue& jsound);
+    bool LoadInputConfig(const JSONValue& jinput);
 
-    static VariantMap engineConfig_;
-    static String engineConfigFilename_;
+    bool LoadEngineConfig(const JSONValue& jengine);
 
+    static EngineConfig engineConfig_;
 };
 
 }

+ 133 - 0
Source/Atomic/Resource/Configuration.cpp

@@ -0,0 +1,133 @@
+//
+// Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+
+#include "../Core/Context.h"
+#include "../IO/Log.h"
+#include "../IO/File.h"
+#include "../IO/FileSystem.h"
+#include "../Resource/JSONFile.h"
+#include "../Graphics/GraphicsDefs.h"
+#include "Configuration.h"
+
+namespace Atomic
+{
+
+    bool Configuration::GetBoolValue(const JSONValue& jvalue, bool defaultValue)
+    {
+        bool value = defaultValue;
+
+        if (jvalue.IsBool())
+            value = jvalue.GetBool();
+
+        return value;
+    }
+
+    int Configuration::GetIntValue(const JSONValue& jvalue, int defaultValue)
+    {
+        int value = defaultValue;
+
+        if (jvalue.IsNumber())
+            value = jvalue.GetInt();
+
+        return value;
+    }
+
+    String Configuration::GetStringValue(const JSONValue& jvalue, const String& defaultValue)
+    {
+        String value = defaultValue;
+
+        if (jvalue.IsString())
+            value = jvalue.GetString();
+
+        return value;
+    }
+
+
+    bool Configuration::LoadFromFile(Context *context, const String& filename)
+    {
+
+        FileSystem* fileSystem = context->GetSubsystem<FileSystem>();
+
+        if (!fileSystem->FileExists(filename))
+            return false;
+
+        filename_ = filename;
+
+        SharedPtr<File> file(new File(context));
+
+        if (!file->Open(filename))
+        {
+            LOGERRORF("Configuration::LoadFromFile - Unable to open config file %s", filename.CString());
+            return false;
+        }
+
+        String json;
+        file->ReadText(json);
+
+        return LoadFromJSON(json);
+    }
+
+    void Configuration::ApplyConfig(VariantMap& settings, bool overwrite)
+    {
+        VariantMap::ConstIterator itr = valueMap_.Begin();
+        if (overwrite)
+        {
+            while (itr != valueMap_.End())
+            {
+                settings[itr->first_] = itr->second_;
+                itr++;
+            }
+        }
+        else
+        {
+            while (itr != valueMap_.End())
+            {
+                settings.InsertNew(itr->first_, itr->second_);
+                itr++;
+            }
+        }
+
+    }
+
+    bool Configuration::LoadFromJSON(const String& json)
+    {
+        valueMap_.Clear();
+
+        JSONValue jroot;
+
+        if (!JSONFile::ParseJSON(json, jroot))
+        {
+            LOGERRORF("Configuration::LoadFromJSON - Unable to parse config file JSON: %s", filename_.CString());
+            return false;
+        }
+
+        if (!jroot.IsObject())
+            return false;
+
+        if (!LoadDesktopConfig(jroot))
+            return false;
+
+        return true;
+    }
+
+}

+ 60 - 0
Source/Atomic/Resource/Configuration.h

@@ -0,0 +1,60 @@
+//
+// Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#pragma once
+
+#include "../Core/Variant.h"
+#include "JSONValue.h"
+
+namespace Atomic
+{
+
+class Context;
+
+class Configuration
+{
+public:
+
+    bool LoadFromFile(Context* context, const String& filename);
+    bool LoadFromJSON(const String& json);
+
+    /// Apply the configuration to a setting variant map, values that exist will not be overriden
+    void ApplyConfig(VariantMap& settings, bool overwrite = false);
+
+    const VariantMap& GetConfig() { return valueMap_; }
+
+protected:
+    static bool GetBoolValue(const JSONValue& jvalue, bool defaultValue);
+    static int GetIntValue(const JSONValue& jvalue, int defaultValue);
+    static String GetStringValue(const JSONValue& jvalue, const String& defaultValue);
+
+    virtual bool LoadDesktopConfig(JSONValue root) { return true; };
+
+    VariantMap valueMap_;
+
+private:
+    String filename_;
+};
+}
+
+
+

+ 89 - 0
Source/ToolCore/Import/ImportConfig.cpp

@@ -0,0 +1,89 @@
+//
+// Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#include "../../Atomic/Core/Context.h"
+#include "../../Atomic/IO/Log.h"
+#include "../../Atomic/IO/File.h"
+#include "../../Atomic/IO/FileSystem.h"
+#include "../Atomic/Resource/JSONFile.h"
+#include "../../Atomic/Graphics/GraphicsDefs.h"
+#include "ImportConfig.h"
+
+namespace Atomic
+{
+
+ImportConfig ImportConfig::importConfig_;
+
+bool ImportConfig::LoadAIFlagsDefaultConfig(const JSONValue& jflags)
+{
+    if (!jflags.IsObject())
+        return false;
+
+    for (JSONObject::ConstIterator i = jflags.Begin(); i != jflags.End(); ++i)
+    {
+        String key = i->first_;
+        const JSONValue& jvalue = i->second_;
+
+        if (key == "convertToLeftHanded")
+            valueMap_["aiProcess_ConvertToLeftHanded"] = GetBoolValue(jvalue, true);
+        else if (key == "joinIdenticalVertices")
+            valueMap_["aiProcess_JoinIdenticalVertices"] = GetBoolValue(jvalue, true);
+        else if (key == "triangulate")
+            valueMap_["aiProcess_Triangulate"] = GetBoolValue(jvalue, true);
+        else if (key == "genSmoothNormals")
+            valueMap_["aiProcess_GenSmoothNormals"] = GetBoolValue(jvalue, true);
+        else if (key == "limitBoneWeights")
+            valueMap_["aiProcess_LimitBoneWeights"] = GetBoolValue(jvalue, true);
+        else if (key == "improveCacheLocality")
+            valueMap_["aiProcess_ImproveCacheLocality"] = GetBoolValue(jvalue, true);
+        else if (key == "fixInFacingNormals")
+            valueMap_["aiProcess_FixInfacingNormals"] = GetBoolValue(jvalue, true);
+        else if (key == "fixInfacingNormals")
+            valueMap_["aiProcess_FixInfacingNormals"] = GetBoolValue(jvalue, true);
+        else if (key == "findInvalidData")
+            valueMap_["aiProcess_FindInvalidData"] = GetBoolValue(jvalue, true);
+        else if (key == "genUVCoords")
+            valueMap_["aiProcess_GenUVCoords"] = GetBoolValue(jvalue, true);
+        else if (key == "findInstances")
+            valueMap_["aiProcess_FindInstances"] = GetBoolValue(jvalue, true);
+        else if (key == "optimizeMeshes")
+            valueMap_["aiProcess_OptimizeMeshes"] = GetBoolValue(jvalue, true);
+    }
+
+    return true;
+}
+
+bool ImportConfig::LoadDesktopConfig(JSONValue root)
+{
+    const JSONValue& jdesktop = root["desktop"];
+
+    if (!jdesktop.IsObject())
+        return false;
+
+    const JSONValue& jflags = jdesktop["aiFlagsDefault"];
+    if (jflags.IsObject())
+        LoadAIFlagsDefaultConfig(jflags);
+ 
+    return true;
+}
+
+}

+ 54 - 0
Source/ToolCore/Import/ImportConfig.h

@@ -0,0 +1,54 @@
+//
+// Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#pragma once
+
+#include "../../Atomic/Core/Variant.h"
+#include "../../Atomic/Resource/JSONValue.h"
+#include "../../Atomic/Resource/Configuration.h"
+
+namespace Atomic
+{
+
+class Context;
+
+class ImportConfig :
+    Configuration
+{
+
+public:
+
+    static bool LoadFromFile(Context* context, const String& filename) { return importConfig_.Configuration::LoadFromFile(context, filename); }
+    static bool LoadFromJSON(const String& json) { return importConfig_.Configuration::LoadFromJSON(json); }
+
+    /// Apply the configuration to a setting variant map, values that exist will not be overriden
+    static void ApplyConfig(VariantMap& settings, bool overwrite = false) { return importConfig_.Configuration::ApplyConfig(settings, overwrite); }
+
+private:
+
+    virtual bool LoadDesktopConfig(JSONValue root);
+    bool LoadAIFlagsDefaultConfig(const JSONValue& jflags);
+
+    static ImportConfig importConfig_;
+};
+
+}

+ 70 - 0
Source/ToolCore/Import/OpenAssetImporter.cpp

@@ -27,6 +27,7 @@
 #include <Atomic/IO/Log.h>
 #include <Atomic/IO/File.h>
 #include <Atomic/IO/FileSystem.h>
+#include <ToolCore/Import/ImportConfig.h>
 
 #include <Atomic/Resource/XMLFile.h>
 #include <Atomic/Resource/ResourceCache.h>
@@ -40,6 +41,9 @@
 #include <Atomic/Graphics/VertexBuffer.h>
 #include <Atomic/Graphics/Material.h>
 
+#include <ToolCore/Project/Project.h>
+#include <ToolCore/ToolSystem.h>
+
 #include "OpenAssetImporter.h"
 
 namespace ToolCore
@@ -86,6 +90,8 @@ OpenAssetImporter::OpenAssetImporter(Context* context) : Object(context) ,
         aiProcess_FindInstances |
         aiProcess_OptimizeMeshes;
 
+    ReadImportConfig();
+
     // TODO:  make this an option on importer
 
     aiFlagsDefault_ |= aiProcess_CalcTangentSpace;
@@ -860,6 +866,70 @@ void OpenAssetImporter::CollectAnimations(OutModel* model)
     /// \todo Vertex morphs are ignored for now
 }
 
+void OpenAssetImporter::ApplyFlag(int flag, bool active)
+{
+    aiFlagsDefault_ &= ~flag;
+    if (active)
+        aiFlagsDefault_ |= flag;
+}
+
+void OpenAssetImporter::SetOveriddenFlags(VariantMap& aiFlagParameters)
+{
+
+    VariantMap::ConstIterator itr = aiFlagParameters.Begin();
+
+    while (itr != aiFlagParameters.End())
+    {
+        if (itr->first_ == "aiProcess_ConvertToLeftHanded")
+            ApplyFlag(aiProcess_ConvertToLeftHanded, itr->second_.GetBool());
+        else if (itr->first_ == "aiProcess_JoinIdenticalVertices")
+            ApplyFlag(aiProcess_JoinIdenticalVertices, itr->second_.GetBool());
+        else if (itr->first_ == "aiProcess_Triangulate")
+            ApplyFlag(aiProcess_Triangulate, itr->second_.GetBool());
+        else if (itr->first_ == "aiProcess_GenSmoothNormals")
+            ApplyFlag(aiProcess_GenSmoothNormals, itr->second_.GetBool());
+        else if (itr->first_ == "aiProcess_LimitBoneWeights")
+            ApplyFlag(aiProcess_LimitBoneWeights, itr->second_.GetBool());
+        else if (itr->first_ == "aiProcess_ImproveCacheLocality")
+            ApplyFlag(aiProcess_ImproveCacheLocality, itr->second_.GetBool());
+        else if (itr->first_ == "aiProcess_FixInfacingNormals")
+            ApplyFlag(aiProcess_FixInfacingNormals, itr->second_.GetBool());
+        else if (itr->first_ == "aiProcess_FindInvalidData")
+            ApplyFlag(aiProcess_FindInvalidData, itr->second_.GetBool());
+        else if (itr->first_ == "aiProcess_GenUVCoords")
+            ApplyFlag(aiProcess_GenUVCoords, itr->second_.GetBool());
+        else if (itr->first_ == "aiProcess_FindInstances")
+            ApplyFlag(aiProcess_FindInstances, itr->second_.GetBool());
+        else if (itr->first_ == "aiProcess_OptimizeMeshes")
+            ApplyFlag(aiProcess_OptimizeMeshes, itr->second_.GetBool());
+
+        itr++;
+    }
+
+}
+
+void OpenAssetImporter::ReadImportConfig()
+{
+    ToolSystem* tsystem = GetSubsystem<ToolSystem>();
+    Project* project = tsystem->GetProject();
+
+    String projectPath = project->GetProjectPath();
+
+    String filename = projectPath + "Settings/Import.json";
+
+    FileSystem* fileSystem = GetSubsystem<FileSystem>();
+    if (!fileSystem->FileExists(filename))
+        return;
+
+    if (ImportConfig::LoadFromFile(context_, filename))
+    {
+        VariantMap aiFlagParameters;
+        ImportConfig::ApplyConfig(aiFlagParameters);
+        SetOveriddenFlags(aiFlagParameters);
+    }
+
+}
+
 void OpenAssetImporter::BuildBoneCollisionInfo(OutModel& model)
 {
     for (unsigned i = 0; i < model.meshes_.Size(); ++i)

+ 4 - 0
Source/ToolCore/Import/OpenAssetImporter.h

@@ -82,6 +82,10 @@ private:
     void BuildBoneCollisionInfo(OutModel& model);
     void CollectAnimations(OutModel* model = 0);
 
+    void ReadImportConfig();
+    void SetOveriddenFlags(VariantMap& aiFlagParameters);
+    void ApplyFlag(int processStep, bool active);
+
     String GetMeshMaterialName(aiMesh* mesh);
     String GenerateMaterialName(aiMaterial* material);
     String GetMaterialTextureName(const String& nameIn);