Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/jolt_physics/Jolt/Physics/Collision/PhysicsMaterial.h
9912 views
1
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3
// SPDX-License-Identifier: MIT
4
5
#pragma once
6
7
#include <Jolt/Core/Reference.h>
8
#include <Jolt/Core/Color.h>
9
#include <Jolt/Core/Result.h>
10
#include <Jolt/ObjectStream/SerializableObject.h>
11
12
JPH_NAMESPACE_BEGIN
13
14
class StreamIn;
15
class StreamOut;
16
17
/// This structure describes the surface of (part of) a shape. You should inherit from it to define additional
18
/// information that is interesting for the simulation. The 2 materials involved in a contact could be used
19
/// to decide which sound or particle effects to play.
20
///
21
/// If you inherit from this material, don't forget to create a suitable default material in sDefault
22
class JPH_EXPORT PhysicsMaterial : public SerializableObject, public RefTarget<PhysicsMaterial>
23
{
24
JPH_DECLARE_SERIALIZABLE_VIRTUAL(JPH_EXPORT, PhysicsMaterial)
25
26
public:
27
/// Virtual destructor
28
virtual ~PhysicsMaterial() override = default;
29
30
/// Default material that is used when a shape has no materials defined
31
static RefConst<PhysicsMaterial> sDefault;
32
33
// Properties
34
virtual const char * GetDebugName() const { return "Unknown"; }
35
virtual Color GetDebugColor() const { return Color::sGrey; }
36
37
/// Saves the contents of the material in binary form to inStream.
38
virtual void SaveBinaryState(StreamOut &inStream) const;
39
40
using PhysicsMaterialResult = Result<Ref<PhysicsMaterial>>;
41
42
/// Creates a PhysicsMaterial of the correct type and restores its contents from the binary stream inStream.
43
static PhysicsMaterialResult sRestoreFromBinaryState(StreamIn &inStream);
44
45
protected:
46
/// This function should not be called directly, it is used by sRestoreFromBinaryState.
47
virtual void RestoreBinaryState(StreamIn &inStream);
48
};
49
50
using PhysicsMaterialList = Array<RefConst<PhysicsMaterial>>;
51
52
JPH_NAMESPACE_END
53
54