PhysicsMaterialSimple.h 1.2 KB

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