SoftBodyVertex.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2023 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #pragma once
  5. #include <Jolt/Geometry/Plane.h>
  6. JPH_NAMESPACE_BEGIN
  7. /// Run time information for a single particle of a soft body
  8. /// Note that at run-time you should only modify the inverse mass and/or velocity of a vertex to control the soft body.
  9. /// Modifying the position can lead to missed collisions.
  10. /// The other members are used internally by the soft body solver.
  11. class SoftBodyVertex
  12. {
  13. public:
  14. /// Reset collision information to prepare for a new collision check
  15. inline void ResetCollision()
  16. {
  17. mLargestPenetration = -FLT_MAX;
  18. mCollidingShapeIndex = -1;
  19. mHasContact = false;
  20. }
  21. Vec3 mPreviousPosition; ///< Internal use only. Position at the previous time step
  22. Vec3 mPosition; ///< Position, relative to the center of mass of the soft body
  23. Vec3 mVelocity; ///< Velocity, relative to the center of mass of the soft body
  24. Plane mCollisionPlane; ///< Internal use only. Nearest collision plane, relative to the center of mass of the soft body
  25. int mCollidingShapeIndex; ///< Internal use only. Index in the colliding shapes list of the body we may collide with
  26. bool mHasContact; ///< True if the vertex has collided with anything in the last update
  27. float mLargestPenetration; ///< Internal use only. Used while finding the collision plane, stores the largest penetration found so far
  28. float mInvMass; ///< Inverse mass (1 / mass)
  29. };
  30. JPH_NAMESPACE_END