CharacterBase.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #include <Jolt/Jolt.h>
  4. #include <Jolt/Physics/Character/CharacterBase.h>
  5. #include <Jolt/Physics/StateRecorder.h>
  6. JPH_NAMESPACE_BEGIN
  7. CharacterBase::CharacterBase(const CharacterBaseSettings *inSettings, PhysicsSystem *inSystem) :
  8. mSystem(inSystem),
  9. mShape(inSettings->mShape),
  10. mUp(inSettings->mUp),
  11. mSupportingVolume(inSettings->mSupportingVolume)
  12. {
  13. // Initialize max slope angle
  14. SetMaxSlopeAngle(inSettings->mMaxSlopeAngle);
  15. }
  16. void CharacterBase::SaveState(StateRecorder &inStream) const
  17. {
  18. inStream.Write(mGroundState);
  19. inStream.Write(mGroundBodyID);
  20. inStream.Write(mGroundBodySubShapeID);
  21. inStream.Write(mGroundPosition);
  22. inStream.Write(mGroundNormal);
  23. inStream.Write(mGroundVelocity);
  24. // Can't save or restore user data (may be a pointer) and material
  25. }
  26. void CharacterBase::RestoreState(StateRecorder &inStream)
  27. {
  28. inStream.Read(mGroundState);
  29. inStream.Read(mGroundBodyID);
  30. inStream.Read(mGroundBodySubShapeID);
  31. inStream.Read(mGroundPosition);
  32. inStream.Read(mGroundNormal);
  33. inStream.Read(mGroundVelocity);
  34. }
  35. JPH_NAMESPACE_END