Skip to content
0.2.0-dev Download ZIP
37 lines ·1.3 KB Raw
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/Physics/Collision/PhysicsMaterial.h>
8
9JPH_NAMESPACE_BEGIN
10
11/// Sample implementation of PhysicsMaterial that just holds the needed properties directly
12class JPH_EXPORT PhysicsMaterialSimple : public PhysicsMaterial
13{
14 JPH_DECLARE_SERIALIZABLE_VIRTUAL(JPH_EXPORT, PhysicsMaterialSimple)
15
16public:
17 /// Constructor
18 PhysicsMaterialSimple() = default;
19 PhysicsMaterialSimple(const string_view &inName, ColorArg inColor) : mDebugName(inName), mDebugColor(inColor) { }
20
21 // Properties
22 virtual const char * GetDebugName() const override { return mDebugName.c_str(); }
23 virtual Color GetDebugColor() const override { return mDebugColor; }
24
25 // See: PhysicsMaterial::SaveBinaryState
26 virtual void SaveBinaryState(StreamOut &inStream) const override;
27
28protected:
29 // See: PhysicsMaterial::RestoreBinaryState
30 virtual void RestoreBinaryState(StreamIn &inStream) override;
31
32private:
33 String mDebugName; ///< Name of the material, used for debugging purposes
34 Color mDebugColor = Color::sGrey; ///< Color of the material, used to render the shapes
35};
36
37JPH_NAMESPACE_END