Class PhysicsBodyStateUpdater

java.lang.Object
com.hypixel.hytale.server.core.modules.physics.util.PhysicsBodyStateUpdater
Direct Known Subclasses:
PhysicsBodyStateUpdaterMidpoint, PhysicsBodyStateUpdaterRK4, PhysicsBodyStateUpdaterSymplecticEuler

public class PhysicsBodyStateUpdater extends Object
Base class for updating position and velocity of a physics body over time step.

The updater numerically integrates applied forces over the time step to derive acceleration used to compute new position and velocity.

This implementation uses explicit Euler method for integration and is O(dt). See https://en.wikipedia.org/wiki/Euler_method.

Since:
2020-03-06
  • Constructor Details

    • PhysicsBodyStateUpdater

      public PhysicsBodyStateUpdater()
  • Method Details

    • update

      public void update(@Nonnull PhysicsBodyState before, @Nonnull PhysicsBodyState after, double mass, double dt, boolean onGround, @Nonnull ForceProvider[] forceProvider)
      Compute new position and velocity for a body over a time interval.
      Parameters:
      before - Provided position and velocity at start of interval
      after - Resulting position and velocity at end of interval
      mass - Mass of body
      dt - Time step/interval
      onGround - Whether body is on ground
      forceProvider - Array of force provider used to compute forces applied to body