Unravel Engine C++ Reference
Loading...
Searching...
No Matches
physics_material.h
Go to the documentation of this file.
1#pragma once
2#include <engine/engine_export.h>
3
4#include <memory>
5
6#include <type_traits>
7
8namespace unravel
9{
10
11//------------------------------------------------------------------------------
12// 1) Enum for per-body combine modes.
13// We assign explicit integer values so they map neatly into userIndex2.
14//------------------------------------------------------------------------------
15enum class combine_mode : int
16{
17 average = 0, // PhysX default: (eA + eB)/2
18 minimum = 1, // min(eA, eB)
19 multiply = 2, // Bullet default: eA * eB
20 maximum = 3, // max(eA, eB)
21 count = 4
22};
23
29{
30 using sptr = std::shared_ptr<physics_material>;
31 using wptr = std::weak_ptr<physics_material>;
32 using uptr = std::unique_ptr<physics_material>;
33
34 float restitution{0};
38
39 float friction{0.5};
44
45 float stiffness{0.5};
48
49 float damping{0.1f};
52
54
56
61 auto get_stiffness() const -> float
62 {
63 const float min_stiffness = 1e3f;
64 const float max_stiffness = 1e5f;
65 return min_stiffness + stiffness * (max_stiffness - min_stiffness);
66 }
67};
68
69} // namespace unravel
Represents the physical properties of a material.
std::weak_ptr< physics_material > wptr
Weak pointer to a physics material.
auto get_stiffness() const -> float
Converts normalized stiffness to actual stiffness.
combine_mode friction_combine
How to combine friction values.
combine_mode restitution_combine
How to combine restitution values.
std::shared_ptr< physics_material > sptr
Shared pointer to a physics material.
std::unique_ptr< physics_material > uptr
Unique pointer to a physics material.