Leviathan  0.8.0.0
Leviathan game engine
Leviathan::PhysicsMaterialManager Class Reference

#include <PhysicsMaterialManager.h>

Public Member Functions

DLLEXPORT PhysicsMaterialManager (const NewtonManager *newtoninstanced)
 
DLLEXPORT ~PhysicsMaterialManager ()
 
DLLEXPORT void LoadedMaterialAdd (std::shared_ptr< PhysicalMaterial > material)
 
DLLEXPORT int GetMaterialIDForWorld (const std::string &name, NewtonWorld *WorldPtr)
 
DLLEXPORT std::shared_ptr< PhysicalMaterialGetMaterial (const std::string &name)
 
DLLEXPORT void CreateActualMaterialsForWorld (NewtonWorld *newtonworld)
 
DLLEXPORT void DestroyActualMaterialsForWorld (NewtonWorld *world)
 Clears world from materials. More...
 

Static Public Member Functions

static DLLEXPORT PhysicsMaterialManagerGet ()
 

Detailed Description

Definition at line 11 of file PhysicsMaterialManager.h.

Constructor & Destructor Documentation

◆ PhysicsMaterialManager()

DLLEXPORT PhysicsMaterialManager::PhysicsMaterialManager ( const NewtonManager newtoninstanced)

Definition at line 6 of file PhysicsMaterialManager.cpp.

7 {
8 
9  // set static instance //
10  StaticInstance = this;
11 }

◆ ~PhysicsMaterialManager()

DLLEXPORT PhysicsMaterialManager::~PhysicsMaterialManager ( )

Definition at line 13 of file PhysicsMaterialManager.cpp.

14 {
15  StaticInstance = NULL;
16 }

Member Function Documentation

◆ CreateActualMaterialsForWorld()

DLLEXPORT void PhysicsMaterialManager::CreateActualMaterialsForWorld ( NewtonWorld *  newtonworld)

Definition at line 62 of file PhysicsMaterialManager.cpp.

63 {
64  // Call first the primitive ID list so that all materials are created before applying
65  // properties //
66  _CreatePrimitiveIDList(newtonworld);
67  _ApplyMaterialProperties(newtonworld);
68 }

◆ DestroyActualMaterialsForWorld()

DLLEXPORT void PhysicsMaterialManager::DestroyActualMaterialsForWorld ( NewtonWorld *  world)

Clears world from materials.

Definition at line 70 of file PhysicsMaterialManager.cpp.

71 {
72 
73  for(auto iter = LoadedMaterials.begin(); iter != LoadedMaterials.end(); ++iter) {
74 
75  iter->second->_ClearFromWorld(world);
76  }
77 }

◆ Get()

DLLEXPORT PhysicsMaterialManager * PhysicsMaterialManager::Get ( )
static

Definition at line 20 of file PhysicsMaterialManager.cpp.

21 {
22  return StaticInstance;
23 }

◆ GetMaterial()

DLLEXPORT std::shared_ptr< PhysicalMaterial > PhysicsMaterialManager::GetMaterial ( const std::string &  name)

Definition at line 47 of file PhysicsMaterialManager.cpp.

49 {
50  // Search for it by name //
51  auto iter = LoadedMaterials.find(name);
52 
53  if(iter != LoadedMaterials.end()) {
54 
55  return iter->second;
56  }
57 
58  // Not found //
59  return NULL;
60 }

◆ GetMaterialIDForWorld()

DLLEXPORT int PhysicsMaterialManager::GetMaterialIDForWorld ( const std::string &  name,
NewtonWorld *  WorldPtr 
)

Definition at line 32 of file PhysicsMaterialManager.cpp.

34 {
35  // Search for it by name //
36  auto iter = LoadedMaterials.find(name);
37 
38  if(iter != LoadedMaterials.end()) {
39 
40  return iter->second->GetMaterialIDIfLoaded(WorldPtr);
41  }
42 
43  // Not found //
44  return -1;
45 }

◆ LoadedMaterialAdd()

DLLEXPORT void PhysicsMaterialManager::LoadedMaterialAdd ( std::shared_ptr< PhysicalMaterial material)

This function should be called from the load physical materials callback Otherwise if the world has already built the materials then the new material won't be picked up

Definition at line 25 of file PhysicsMaterialManager.cpp.

27 {
28  // Add to the map //
29  LoadedMaterials[material->GetName()] = material;
30 }

The documentation for this class was generated from the following files: