Toast Engine
Loading...
Searching...
No Matches
destruction_material.hpp
Go to the documentation of this file.
1
8
9#pragma once
10#include "fracture_pattern.hpp"
11#include "fracture_profile.hpp"
12
13#include <toast/assets/data.hpp>
15
16namespace assets {
17
18class TOAST_API DestructionMaterial : public Data {
19public:
20 explicit DestructionMaterial(const toml::table& table, Handle<Schema> schema = {});
21
22 [[nodiscard]]
23 auto type() const -> std::string_view override {
24 return "destruction_material";
25 }
26
27 [[nodiscard]]
28 auto get() const -> toml::table;
29
31 [[nodiscard]]
32 auto density() const noexcept -> float;
33
35 [[nodiscard]]
36 auto toughness() const noexcept -> float;
37
39 [[nodiscard]]
40 auto hardness() const noexcept -> physics::Hardness;
41
42 [[nodiscard]]
43 auto fracturePatterh() const noexcept -> physics::FracturePattern;
44
45 [[nodiscard]]
46 auto fractureProfile() const noexcept -> physics::PackedFractureProfile;
47
49 [[nodiscard]]
50 auto structuralStrength() const noexcept -> float;
51
53 [[nodiscard]]
54 auto destructible() const noexcept -> bool;
55
56 [[nodiscard]]
57 auto flammable() const noexcept -> bool;
58
59 [[nodiscard]]
60 auto burnRate() const noexcept -> float;
61
62protected:
63 void onReloaded() override;
64
65private:
66 void readFields();
67
68 float m_density = 0.0f;
69 float m_toughness = 0.0f;
70 physics::Hardness m_hardness = physics::Hardness::medium;
71 physics::FracturePattern m_fracture_pattern = physics::FracturePattern::brittle;
72 physics::FractureValues m_fracture_values;
73 float m_structural_strength = 0.0f;
74 bool m_destructible = true;
75 bool m_flammable = false;
76 float m_burn_rate = 0.0f;
77};
78
79}
auto hardness() const noexcept -> physics::Hardness
Damage that breaks only softer tiers never breaks this material.
Definition destruction_material.cpp:115
auto density() const noexcept -> float
kg/m3; drives voxel mass through massPerVoxel()
Definition destruction_material.cpp:107
auto destructible() const noexcept -> bool
False means voxels of this material never break, whatever hits them.
Definition destruction_material.cpp:131
auto structuralStrength() const noexcept -> float
Pascals.
Definition destruction_material.cpp:127
auto toughness() const noexcept -> float
kJ/m3 it takes to break the material
Definition destruction_material.cpp:111
Type-safe smart pointer for assets.
Definition core_types.hpp:149
Typed data asset backed by schema-driven TOML.
How a material breaks: how the energy of a hit is spent and how coarse its cracks are.
Tiers of how hard a material is to break.
Definition fracture_profile.hpp:17
Definition fracture_profile.hpp:49