Leviathan  0.8.0.0
Leviathan game engine
Leviathan::PhysicsMaterialManager Class Reference

Contains a material list for applying automatic properties to PhysicsBody and collision callbacks. More...

#include <PhysicsMaterialManager.h>

Public Member Functions

DLLEXPORT void LoadedMaterialAdd (std::unique_ptr< PhysicalMaterial > &&material)
 Adds a physics material. This now takes effect instantly and all worlds using this material manager will see the change on next physics update. This will set the material ID. More...
 
DLLEXPORT int GetMaterialID (const std::string &name)
 Gets the ID of a material based on name. More...
 
DLLEXPORT PhysicalMaterialGetMaterial (const std::string &name)
 Accesses material based on name. More...
 
DLLEXPORT PhysicalMaterialGetMaterial (int id)
 Accesses material by ID. More...
 

Detailed Description

Contains a material list for applying automatic properties to PhysicsBody and collision callbacks.

Todo:
file loading function

Definition at line 13 of file PhysicsMaterialManager.h.

Member Function Documentation

◆ GetMaterial() [1/2]

DLLEXPORT PhysicalMaterial * PhysicsMaterialManager::GetMaterial ( const std::string &  name)

Accesses material based on name.

Note
If you modify the material only new physics bodies will get the changed properties

Definition at line 32 of file PhysicsMaterialManager.cpp.

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

◆ GetMaterial() [2/2]

DLLEXPORT PhysicalMaterial * PhysicsMaterialManager::GetMaterial ( int  id)

Accesses material by ID.

Definition at line 46 of file PhysicsMaterialManager.cpp.

47 {
48  auto iter = LoadedMaterialsByID.find(id);
49 
50  if(iter != LoadedMaterialsByID.end()) {
51 
52  return iter->second;
53  }
54 
55  // Not found //
56  return nullptr;
57 }

◆ GetMaterialID()

DLLEXPORT int PhysicsMaterialManager::GetMaterialID ( const std::string &  name)

Gets the ID of a material based on name.

Definition at line 18 of file PhysicsMaterialManager.cpp.

19 {
20  // Search for it by name //
21  auto iter = LoadedMaterials.find(name);
22 
23  if(iter != LoadedMaterials.end()) {
24 
25  return iter->second->GetID();
26  }
27 
28  // Not found //
29  return -1;
30 }

◆ LoadedMaterialAdd()

DLLEXPORT void PhysicsMaterialManager::LoadedMaterialAdd ( std::unique_ptr< PhysicalMaterial > &&  material)

Adds a physics material. This now takes effect instantly and all worlds using this material manager will see the change on next physics update. This will set the material ID.

Definition at line 6 of file PhysicsMaterialManager.cpp.

8 {
9  if(!material)
10  return;
11 
12  // Add to the map //
13  PhysicalMaterial* ptr = material.get();
14  LoadedMaterials[material->GetName()] = std::move(material);
15  LoadedMaterialsByID[ptr->GetID()] = ptr;
16 }
DLLEXPORT std::string GetName() const

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