Class WorldHandler

java.lang.Object
de.pirckheimer_gymnasium.engine_pi.physics.WorldHandler
All Implemented Interfaces:
org.jbox2d.callbacks.ContactListener

public class WorldHandler extends Object implements org.jbox2d.callbacks.ContactListener
Die WorldHandler-Klasse ist die (nicht objektgebundene) Middleware zwischen der JBox2D Engine und der Engine Omage. Sie ist verantwortlich für:
  • Den globalen "World"-Parameter aus der JBox2D Engine.
  • Übersetzung zwischen JB2D-Vektoren (SI-Basiseinheiten) und denen der Engine (Zeichengrößen)
  • Field Details

  • Constructor Details

    • WorldHandler

      @Internal public WorldHandler(Layer layer)
      Erstellt eine neue standardisierte Physik ohne Schwerkraft.
  • Method Details

    • getWorld

      @Internal public org.jbox2d.dynamics.World getWorld()
      Gibt den World-Parameter der Physics aus.
      Returns:
      Der JB2D-World-Parameter der Welt.
    • setWorldPaused

      public void setWorldPaused(boolean worldPaused)
    • isWorldPaused

      public boolean isWorldPaused()
    • assertNoWorldStep

      @Internal public void assertNoWorldStep()
      Assertion-Methode, die sicherstellt, dass die (JBox2D-)World der gerade nicht im World-Step ist. Dies ist wichtig für die Manipulation von Actors (Manipulation vieler physikalischen Eigenschaften während des World-Steps führt zu Inkonsistenzen).
      Throws:
      RuntimeException - Wenn die World sich gerade im World-Step befindet. Ist dies nicht der Fall, passiert nichts (und es wird keine Exception geworfen).
    • step

      public void step(double pastTime)
    • createBody

      public org.jbox2d.dynamics.Body createBody(org.jbox2d.dynamics.BodyDef bd, Actor actor)
      Erstellt einen Body und mappt ihn intern zum analogen Actor-Objekt.
      Parameters:
      bd - Exakte Beschreibung des Bodies.
      actor - Actor-Objekt, das ab sofort zu dem Body gehört.
      Returns:
      Der Body, der aus der BodyDef generiert wurde. Er liegt in der Game-World dieses Handlers.
    • removeAllInternalReferences

      @Internal public void removeAllInternalReferences(org.jbox2d.dynamics.Body body)
      Entfernt alle internen Referenzen auf einen Körper und das zugehörige Actor-Objekt.
      Parameters:
      body - Der zu entfernende Körper.
    • addContactToBlacklist

      @Internal public void addContactToBlacklist(org.jbox2d.dynamics.contacts.Contact contact)
      Fügt einen Kontakt der Blacklist hinzu. Kontakte in der Blacklist werden bis zur Trennung nicht aufgelöst. Der Kontakt wird nach endContact wieder entfernt.
    • beginContact

      public void beginContact(org.jbox2d.dynamics.contacts.Contact contact)
      Description copied from interface: org.jbox2d.callbacks.ContactListener
      Called when two fixtures begin to touch.
      Specified by:
      beginContact in interface org.jbox2d.callbacks.ContactListener
    • endContact

      public void endContact(org.jbox2d.dynamics.contacts.Contact contact)
      Description copied from interface: org.jbox2d.callbacks.ContactListener
      Called when two fixtures cease to touch.
      Specified by:
      endContact in interface org.jbox2d.callbacks.ContactListener
    • preSolve

      public void preSolve(org.jbox2d.dynamics.contacts.Contact contact, org.jbox2d.collision.Manifold manifold)
      Description copied from interface: org.jbox2d.callbacks.ContactListener
      This is called after a contact is updated. This allows you to inspect a contact before it goes to the solver. If you are careful, you can modify the contact manifold (e.g. disable contact). A copy of the old manifold is provided so that you can detect changes. Note: this is called only for awake bodies. Note: this is called even when the number of contact points is zero. Note: this is not called for sensors. Note: if you set the number of contact points to zero, you will not get an EndContact callback. However, you may get a BeginContact callback the next step. Note: the oldManifold parameter is pooled, so it will be the same object for every callback for each thread.
      Specified by:
      preSolve in interface org.jbox2d.callbacks.ContactListener
    • postSolve

      public void postSolve(org.jbox2d.dynamics.contacts.Contact contact, org.jbox2d.callbacks.ContactImpulse contactImpulse)
      Description copied from interface: org.jbox2d.callbacks.ContactListener
      This lets you inspect a contact after the solver is finished. This is useful for inspecting impulses. Note: the contact manifold does not include time of impact impulses, which can be arbitrarily large if the sub-step is small. Hence the impulse is provided explicitly in a separate data structure. Note: this is only called for contacts that are touching, solid, and awake.
      Specified by:
      postSolve in interface org.jbox2d.callbacks.ContactListener
      contactImpulse - this is usually a pooled variable, so it will be modified after this call
    • getLayer

      public Layer getLayer()
    • queryAABB

      @Internal public org.jbox2d.dynamics.Fixture[] queryAABB(org.jbox2d.collision.AABB aabb)
    • isBodyCollision

      @Internal public static boolean isBodyCollision(org.jbox2d.dynamics.Body a, org.jbox2d.dynamics.Body b)
    • addGenericCollisionListener

      @Internal public static void addGenericCollisionListener(CollisionListener<Actor> listener, Actor actor)
      Meldet einen allgemeinen Kollisionsbeobachter in der Physics-Welt an.
      Parameters:
      listener - Das anzumeldende Kollisionsbeobachter
      actor - Kollisionsbeobachter wird informiert falls dieses Actor-Objekt mit einem anderen Objekt kollidiert.
    • addSpecificCollisionListener

      @Internal public static <E extends Actor> void addSpecificCollisionListener(Actor actor, E collider, CollisionListener<E> listener)
      Meldet ein spezifisches CollisionListener-Interface in dieser Physics-Welt an.
      Type Parameters:
      E - Der Type des Colliders.
      Parameters:
      listener - Das anzumeldende KR Interface
      actor - Der Actor (Haupt-Actor-Objekt)
      collider - Der Collider (zweites Actor-Objekt)
    • createJoint

      @Internal public static <JointType extends org.jbox2d.dynamics.joints.Joint, Wrapper extends Joint<JointType>> Wrapper createJoint(Actor a, Actor b, JointBuilder<JointType> jointBuilder, Wrapper wrapper)
    • addMountListener

      @Internal public static List<Runnable> addMountListener(Actor a, Actor b, Consumer<WorldHandler> runnable)