Class WorldHandler
java.lang.Object
de.pirckheimer_gymnasium.engine_pi.physics.WorldHandler
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final double -
Constructor Summary
ConstructorsConstructorDescriptionWorldHandler(Layer layer) Erstellt eine neue standardisierte Physik ohne Schwerkraft. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddContactToBlacklist(org.jbox2d.dynamics.contacts.Contact contact) Fügt einenKontaktder Blacklist hinzu.static voidaddGenericCollisionListener(CollisionListener<Actor> listener, Actor actor) Meldet einen allgemeinen Kollisionsbeobachter in der Physics-Welt an.addMountListener(Actor a, Actor b, Consumer<WorldHandler> runnable) static <E extends Actor>
voidaddSpecificCollisionListener(Actor actor, E collider, CollisionListener<E> listener) Meldet ein spezifisches CollisionListener-Interface in dieser Physics-Welt an.voidAssertion-Methode, die sicherstellt, dass die (JBox2D-)World der gerade nicht im World-Step ist.voidbeginContact(org.jbox2d.dynamics.contacts.Contact contact) Called when two fixtures begin to touch.org.jbox2d.dynamics.BodycreateBody(org.jbox2d.dynamics.BodyDef bd, Actor actor) Erstellt einenBodyund mappt ihn intern zum analogenActor-Objekt.static <JointType extends org.jbox2d.dynamics.joints.Joint,Wrapper extends Joint<JointType>>
WrappercreateJoint(Actor a, Actor b, JointBuilder<JointType> jointBuilder, Wrapper wrapper) voidendContact(org.jbox2d.dynamics.contacts.Contact contact) Called when two fixtures cease to touch.getLayer()org.jbox2d.dynamics.WorldgetWorld()Gibt den World-Parameter der Physics aus.static booleanisBodyCollision(org.jbox2d.dynamics.Body a, org.jbox2d.dynamics.Body b) booleanvoidpostSolve(org.jbox2d.dynamics.contacts.Contact contact, org.jbox2d.callbacks.ContactImpulse contactImpulse) This lets you inspect a contact after the solver is finished.voidpreSolve(org.jbox2d.dynamics.contacts.Contact contact, org.jbox2d.collision.Manifold manifold) This is called after a contact is updated.org.jbox2d.dynamics.Fixture[]queryAABB(org.jbox2d.collision.AABB aabb) voidremoveAllInternalReferences(org.jbox2d.dynamics.Body body) Entfernt alle internen Referenzen auf einenKörperund das zugehörigeActor-Objekt.voidsetWorldPaused(boolean worldPaused) voidstep(double pastTime)
-
Field Details
-
CATEGORY_PASSIVE
public static final int CATEGORY_PASSIVE- See Also:
-
CATEGORY_STATIC
public static final int CATEGORY_STATIC- See Also:
-
CATEGORY_KINEMATIC
public static final int CATEGORY_KINEMATIC- See Also:
-
CATEGORY_DYNAMIC
public static final int CATEGORY_DYNAMIC- See Also:
-
CATEGORY_PARTICLE
public static final int CATEGORY_PARTICLE- See Also:
-
STEP_TIME
public static final double STEP_TIME- See Also:
-
-
Constructor Details
-
WorldHandler
Erstellt eine neue standardisierte Physik ohne Schwerkraft.
-
-
Method Details
-
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
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
Erstellt einenBodyund mappt ihn intern zum analogenActor-Objekt.- Parameters:
bd- Exakte Beschreibung des Bodies.actor-Actor-Objekt, das ab sofort zu dem Body gehört.- Returns:
- Der
Body, der aus derBodyDefgeneriert wurde. Er liegt in der Game-World dieses Handlers.
-
removeAllInternalReferences
Entfernt alle internen Referenzen auf einenKörperund das zugehörigeActor-Objekt.- Parameters:
body- Der zu entfernendeKörper.
-
addContactToBlacklist
Fügt einenKontaktder 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.ContactListenerCalled when two fixtures begin to touch.- Specified by:
beginContactin interfaceorg.jbox2d.callbacks.ContactListener
-
endContact
public void endContact(org.jbox2d.dynamics.contacts.Contact contact) Description copied from interface:org.jbox2d.callbacks.ContactListenerCalled when two fixtures cease to touch.- Specified by:
endContactin interfaceorg.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.ContactListenerThis 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:
preSolvein interfaceorg.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.ContactListenerThis 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:
postSolvein interfaceorg.jbox2d.callbacks.ContactListenercontactImpulse- this is usually a pooled variable, so it will be modified after this call
-
getLayer
-
queryAABB
-
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 Kollisionsbeobachteractor- Kollisionsbeobachter wird informiert falls diesesActor-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. -
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
-