PhysicsMaterialSimple.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #pragma once
  5. #include <Jolt/Physics/Collision/PhysicsMaterial.h>
  6. JPH_NAMESPACE_BEGIN
  7. /// Sample implementation of PhysicsMaterial that just holds the needed properties directly
  8. class JPH_EXPORT PhysicsMaterialSimple : public PhysicsMaterial
  9. {
  10. public:
  11. JPH_DECLARE_SERIALIZABLE_VIRTUAL(JPH_EXPORT, PhysicsMaterialSimple)
  12. /// Constructor
  13. PhysicsMaterialSimple() = default;
  14. PhysicsMaterialSimple(const string_view &inName, ColorArg inColor) : mDebugName(inName), mDebugColor(inColor) { }
  15. // Properties
  16. virtual const char * GetDebugName() const override { return mDebugName.c_str(); }
  17. virtual Color GetDebugColor() const override { return mDebugColor; }
  18. // See: PhysicsMaterial::SaveBinaryState
  19. virtual void SaveBinaryState(StreamOut &inStream) const override;
  20. protected:
  21. // See: PhysicsMaterial::RestoreBinaryState
  22. virtual void RestoreBinaryState(StreamIn &inStream) override;
  23. private:
  24. String mDebugName; ///< Name of the material, used for debugging purposes
  25. Color mDebugColor = Color::sGrey; ///< Color of the material, used to render the shapes
  26. };
  27. JPH_NAMESPACE_END