Skip to content

Commit

Permalink
[libgdx] Added worldToParent and parentToWorld so application code do…
Browse files Browse the repository at this point in the history
…esn't need to check the parent for null (when it is the root).
  • Loading branch information
NathanSweet committed Jul 26, 2023
1 parent 55e8cf5 commit d65311d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Bone.java
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,18 @@ public Vector2 localToWorld (Vector2 local) {
return local;
}

/** Transforms a point from world coordinates to the parent bone's local coordinates. */
public Vector2 worldToParent (Vector2 world) {
if (world == null) throw new IllegalArgumentException("world cannot be null.");
return parent == null ? world : parent.worldToLocal(world);
}

/** Transforms a point from the parent bone's coordinates to world coordinates. */
public Vector2 parentToWorld (Vector2 world) {
if (world == null) throw new IllegalArgumentException("world cannot be null.");
return parent == null ? world : parent.localToWorld(world);
}

/** Transforms a world rotation to a local rotation. */
public float worldToLocalRotation (float worldRotation) {
worldRotation *= degRad;
Expand Down

0 comments on commit d65311d

Please sign in to comment.