/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #include "stdafx.h" #include #include #include #include #include #include // Hack to force loading of FbxSceneBuilder library at load time // Must be DLL_EXPORT to ensure it's not stripped by the linker AZ_DLL_EXPORT void* DoNotCall() { AZ_Assert(false, "This function should never be called. It exists only to force the loading of the FbxSceneBuilder."); return new AZ::SceneAPI::FbxSceneSystem(); } namespace AZ { namespace RC { SceneConfig::SceneConfig() { #if !defined(AZ_PLATFORM_LINUX) LoadSceneLibrary("SceneCore"); LoadSceneLibrary("FbxSceneBuilder"); // Still needs to be explicitly loaded in order to be able to get the supported file extensions. #else AZ::SceneAPI::SceneCore::Initialize(); AZ::SceneAPI::FbxSceneBuilder::Initialize(); #endif // !defined(AZ_PLATFORM_LINUX) } SceneConfig::~SceneConfig() { // Explicitly uninitialize all modules. Because we loaded them twice, we need to explicitly uninit them. for (AZStd::unique_ptr& module : m_modules) { auto uninit = module->GetFunction(UninitializeDynamicModuleFunctionName); if (uninit) { (*uninit)(); } } #if defined(AZ_PLATFORM_LINUX) AZ::SceneAPI::FbxSceneBuilder::Uninitialize(); AZ::SceneAPI::SceneCore::Uninitialize(); #endif // defined(AZ_PLATFORM_LINUX) } void SceneConfig::LoadSceneLibrary(const char* name) { AZStd::unique_ptr module = AZ::DynamicModuleHandle::Create(name); AZ_Assert(module, "Failed to initialize library '%s'", name); if (!module) { return; } module->Load(false); // Explicitly initialize all modules. Because we're loading them twice (link time, and now-time), we need to explicitly uninit them. auto init = module->GetFunction(InitializeDynamicModuleFunctionName); if (init) { (*init)(AZ::Environment::GetInstance()); } m_modules.push_back(AZStd::move(module)); } size_t SceneConfig::GetErrorCount() const { return traceHook.GetErrorCount(); } } // namespace RC } // namespace AZ