1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#include "Physics/BsPhysicsManager.h"
4#include "Utility/BsDynLibManager.h"
5#include "Utility/BsDynLib.h"
6
7namespace bs
8{
9 PhysicsManager::PhysicsManager(const String& pluginName, bool cooking)
10 :mPlugin(nullptr), mFactory(nullptr)
11 {
12 mPlugin = DynLibManager::instance().load(pluginName);
13
14 if(mPlugin != nullptr)
15 {
16 typedef PhysicsFactory* (*LoadPluginFunc)();
17
18 LoadPluginFunc loadPluginFunc = (LoadPluginFunc)mPlugin->getSymbol("loadPlugin");
19 mFactory = loadPluginFunc();
20
21 if (mFactory != nullptr)
22 mFactory->startUp(cooking);
23 }
24 }
25
26 PhysicsManager::~PhysicsManager()
27 {
28 if (mPlugin != nullptr)
29 {
30 if (mFactory != nullptr)
31 {
32 typedef void (*UnloadPluginFunc)(PhysicsFactory*);
33
34 UnloadPluginFunc unloadPluginFunc = (UnloadPluginFunc)mPlugin->getSymbol("unloadPlugin");
35
36 mFactory->shutDown();
37 unloadPluginFunc(mFactory);
38 }
39
40 DynLibManager::instance().unload(mPlugin);
41 }
42 }
43}