Path: blob/master/thirdparty/jolt_physics/Jolt/Physics/Collision/PhysicsMaterial.h
22413 views
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)1// SPDX-FileCopyrightText: 2021 Jorrit Rouwe2// SPDX-License-Identifier: MIT34#pragma once56#include <Jolt/Core/Reference.h>7#include <Jolt/Core/Color.h>8#include <Jolt/Core/Result.h>9#include <Jolt/ObjectStream/SerializableObject.h>1011JPH_NAMESPACE_BEGIN1213class StreamIn;14class StreamOut;1516/// This structure describes the surface of (part of) a shape. You should inherit from it to define additional17/// information that is interesting for the simulation. The 2 materials involved in a contact could be used18/// to decide which sound or particle effects to play.19///20/// If you inherit from this material, don't forget to create a suitable default material in sDefault21class JPH_EXPORT PhysicsMaterial : public SerializableObject, public RefTarget<PhysicsMaterial>22{23JPH_DECLARE_SERIALIZABLE_VIRTUAL(JPH_EXPORT, PhysicsMaterial)2425public:26/// Constructor27PhysicsMaterial() = default;28virtual ~PhysicsMaterial() override = default;2930/// Default material that is used when a shape has no materials defined31static RefConst<PhysicsMaterial> sDefault;3233// Properties34virtual const char * GetDebugName() const { return "Unknown"; }35virtual Color GetDebugColor() const { return Color::sGrey; }3637/// Saves the contents of the material in binary form to inStream.38virtual void SaveBinaryState(StreamOut &inStream) const;3940using PhysicsMaterialResult = Result<Ref<PhysicsMaterial>>;4142/// Creates a PhysicsMaterial of the correct type and restores its contents from the binary stream inStream.43static PhysicsMaterialResult sRestoreFromBinaryState(StreamIn &inStream);4445protected:46/// Don't allow copy constructing this base class, but allow derived classes to copy themselves47PhysicsMaterial(const PhysicsMaterial &) = default;48PhysicsMaterial & operator = (const PhysicsMaterial &) = default;4950/// This function should not be called directly, it is used by sRestoreFromBinaryState.51virtual void RestoreBinaryState(StreamIn &inStream);52};5354using PhysicsMaterialList = Array<RefConst<PhysicsMaterial>>;5556JPH_NAMESPACE_END575859