123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
- // SPDX-License-Identifier: MIT
- #pragma once
- #include <Core/Reference.h>
- #include <Core/Color.h>
- #include <Core/Result.h>
- #include <ObjectStream/SerializableObject.h>
- namespace JPH {
- class StreamIn;
- class StreamOut;
- /// This structure describes the surface of (part of) a shape. You should inherit from it to define additional
- /// information that is interesting for the simulation. The 2 materials involved in a contact could be used
- /// to decide which sound or particle effects to play.
- ///
- /// If you inherit from this material, don't forget to create a suitable default material in sDefault
- class PhysicsMaterial : public SerializableObject, public RefTarget<PhysicsMaterial>
- {
- public:
- JPH_DECLARE_SERIALIZABLE_VIRTUAL(PhysicsMaterial)
- /// Virtual destructor
- virtual ~PhysicsMaterial() override = default;
- /// Default material that is used when a shape has no materials defined
- static RefConst<PhysicsMaterial> sDefault;
- // Properties
- virtual const char * GetDebugName() const { return "Unknown"; }
- virtual ColorArg GetDebugColor() const { return Color::sGrey; }
- /// Saves the contents of the material in binary form to inStream.
- virtual void SaveBinaryState(StreamOut &inStream) const;
- using PhysicsMaterialResult = Result<Ref<PhysicsMaterial>>;
- /// Creates a PhysicsMaterial of the correct type and restores its contents from the binary stream inStream.
- static PhysicsMaterialResult sRestoreFromBinaryState(StreamIn &inStream);
- protected:
- /// This function should not be called directly, it is used by sRestoreFromBinaryState.
- virtual void RestoreBinaryState(StreamIn &inStream);
- };
- using PhysicsMaterialList = vector<RefConst<PhysicsMaterial>>;
- } // JPH
|