[libgdx] Allow ClippingAttachment endSlot to be null, @Null annotations on fields, improved javadocs, removed extraneous parenthesis.

This commit is contained in:
Nathan Sweet 2020-05-18 21:37:58 +02:00
parent 0bcd19ef55
commit 75aba023c3
17 changed files with 56 additions and 53 deletions

View File

@ -871,8 +871,8 @@ public class AnimationState {
* References to a track entry must not be kept after the {@link AnimationStateListener#dispose(TrackEntry)} event occurs. */ * References to a track entry must not be kept after the {@link AnimationStateListener#dispose(TrackEntry)} event occurs. */
static public class TrackEntry implements Poolable { static public class TrackEntry implements Poolable {
Animation animation; Animation animation;
TrackEntry next, mixingFrom, mixingTo; @Null TrackEntry next, mixingFrom, mixingTo;
AnimationStateListener listener; @Null AnimationStateListener listener;
int trackIndex; int trackIndex;
boolean loop, holdPrevious, reverse; boolean loop, holdPrevious, reverse;
float eventThreshold, attachmentThreshold, drawOrderThreshold; float eventThreshold, attachmentThreshold, drawOrderThreshold;

View File

@ -47,7 +47,7 @@ import com.esotericsoftware.spine.BoneData.TransformMode;
public class Bone implements Updatable { public class Bone implements Updatable {
final BoneData data; final BoneData data;
final Skeleton skeleton; final Skeleton skeleton;
final Bone parent; @Null final Bone parent;
final Array<Bone> children = new Array(); final Array<Bone> children = new Array();
float x, y, rotation, scaleX, scaleY, shearX, shearY; float x, y, rotation, scaleX, scaleY, shearX, shearY;
float ax, ay, arotation, ascaleX, ascaleY, ashearX, ashearY; float ax, ay, arotation, ascaleX, ascaleY, ashearX, ashearY;
@ -66,7 +66,7 @@ public class Bone implements Updatable {
setToSetupPose(); setToSetupPose();
} }
/** Copy constructor. Does not copy the children bones. */ /** Copy constructor. Does not copy the {@link #getChildren()} bones. */
public Bone (Bone bone, Skeleton skeleton, @Null Bone parent) { public Bone (Bone bone, Skeleton skeleton, @Null Bone parent) {
if (bone == null) throw new IllegalArgumentException("bone cannot be null."); if (bone == null) throw new IllegalArgumentException("bone cannot be null.");
if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null."); if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null.");

View File

@ -36,7 +36,7 @@ import com.badlogic.gdx.utils.Null;
public class BoneData { public class BoneData {
final int index; final int index;
final String name; final String name;
final BoneData parent; @Null final BoneData parent;
float length; float length;
float x, y, rotation, scaleX = 1, scaleY = 1, shearX, shearY; float x, y, rotation, scaleX = 1, scaleY = 1, shearX, shearY;
TransformMode transformMode = TransformMode.normal; TransformMode transformMode = TransformMode.normal;
@ -187,7 +187,7 @@ public class BoneData {
this.skinRequired = skinRequired; this.skinRequired = skinRequired;
} }
/** The color of the bone as it was in Spine. Available only when nonessential data was exported. Bones are not usually /** The color of the bone as it was in Spine, or a default color if nonessential data was not exported. Bones are not usually
* rendered at runtime. */ * rendered at runtime. */
public Color getColor () { public Color getColor () {
return color; return color;

View File

@ -57,7 +57,7 @@ public class Skeleton {
final Array<PathConstraint> pathConstraints; final Array<PathConstraint> pathConstraints;
final Array<Updatable> updateCache = new Array(); final Array<Updatable> updateCache = new Array();
final Array<Bone> updateCacheReset = new Array(); final Array<Bone> updateCacheReset = new Array();
Skin skin; @Null Skin skin;
final Color color; final Color color;
float time; float time;
float scaleX = 1, scaleY = 1; float scaleX = 1, scaleY = 1;

View File

@ -37,22 +37,22 @@ import com.badlogic.gdx.utils.Null;
* See <a href="http://esotericsoftware.com/spine-runtime-architecture#Data-objects">Data objects</a> in the Spine Runtimes * See <a href="http://esotericsoftware.com/spine-runtime-architecture#Data-objects">Data objects</a> in the Spine Runtimes
* Guide. */ * Guide. */
public class SkeletonData { public class SkeletonData {
String name; @Null String name;
final Array<BoneData> bones = new Array(); // Ordered parents first. final Array<BoneData> bones = new Array(); // Ordered parents first.
final Array<SlotData> slots = new Array(); // Setup pose draw order. final Array<SlotData> slots = new Array(); // Setup pose draw order.
final Array<Skin> skins = new Array(); final Array<Skin> skins = new Array();
Skin defaultSkin; @Null Skin defaultSkin;
final Array<EventData> events = new Array(); final Array<EventData> events = new Array();
final Array<Animation> animations = new Array(); final Array<Animation> animations = new Array();
final Array<IkConstraintData> ikConstraints = new Array(); final Array<IkConstraintData> ikConstraints = new Array();
final Array<TransformConstraintData> transformConstraints = new Array(); final Array<TransformConstraintData> transformConstraints = new Array();
final Array<PathConstraintData> pathConstraints = new Array(); final Array<PathConstraintData> pathConstraints = new Array();
float x, y, width, height; float x, y, width, height;
String version, hash; @Null String version, hash;
// Nonessential. // Nonessential.
float fps = 30; float fps = 30;
String imagesPath, audioPath; @Null String imagesPath, audioPath;
// --- Bones. // --- Bones.
@ -217,7 +217,8 @@ public class SkeletonData {
// --- // ---
/** The skeleton's name, which by default is the name of the skeleton data file, if possible. */ /** The skeleton's name, which by default is the name of the skeleton data file when possible, or null when a name hasn't been
* set. */
public @Null String getName () { public @Null String getName () {
return name; return name;
} }
@ -280,7 +281,7 @@ public class SkeletonData {
this.hash = hash; this.hash = hash;
} }
/** The path to the images directory as defined in Spine. Available only when nonessential data was exported. */ /** The path to the images directory as defined in Spine, or null if nonessential data was not exported. */
public @Null String getImagesPath () { public @Null String getImagesPath () {
return imagesPath; return imagesPath;
} }
@ -289,7 +290,7 @@ public class SkeletonData {
this.imagesPath = imagesPath; this.imagesPath = imagesPath;
} }
/** The path to the audio directory as defined in Spine. Available only when nonessential data was exported. */ /** The path to the audio directory as defined in Spine, or null if nonessential data was not exported. */
public @Null String getAudioPath () { public @Null String getAudioPath () {
return audioPath; return audioPath;
} }
@ -298,7 +299,7 @@ public class SkeletonData {
this.audioPath = audioPath; this.audioPath = audioPath;
} }
/** The dopesheet FPS in Spine. Available only when nonessential data was exported. */ /** The dopesheet FPS in Spine, or zero if nonessential data was not exported. */
public float getFps () { public float getFps () {
return fps; return fps;
} }

View File

@ -53,7 +53,7 @@ public class SkeletonRenderer {
private boolean premultipliedAlpha; private boolean premultipliedAlpha;
private final FloatArray vertices = new FloatArray(32); private final FloatArray vertices = new FloatArray(32);
private final SkeletonClipping clipper = new SkeletonClipping(); private final SkeletonClipping clipper = new SkeletonClipping();
private VertexEffect vertexEffect; private @Null VertexEffect vertexEffect;
private final Vector2 temp = new Vector2(); private final Vector2 temp = new Vector2();
private final Vector2 temp2 = new Vector2(); private final Vector2 temp2 = new Vector2();
private final Color temp3 = new Color(); private final Color temp3 = new Color();
@ -110,9 +110,9 @@ public class SkeletonRenderer {
batch.setBlendFunction(blendMode.getSource(premultipliedAlpha), blendMode.getDest()); batch.setBlendFunction(blendMode.getSource(premultipliedAlpha), blendMode.getDest());
} }
float c = NumberUtils.intToFloatColor(((int)alpha << 24) // float c = NumberUtils.intToFloatColor((int)alpha << 24 //
| ((int)(b * slotColor.b * color.b * multiplier) << 16) // | (int)(b * slotColor.b * color.b * multiplier) << 16 //
| ((int)(g * slotColor.g * color.g * multiplier) << 8) // | (int)(g * slotColor.g * color.g * multiplier) << 8 //
| (int)(r * slotColor.r * color.r * multiplier)); | (int)(r * slotColor.r * color.r * multiplier));
float[] uvs = region.getUVs(); float[] uvs = region.getUVs();
for (int u = 0, v = 2; u < 8; u += 2, v += 5) { for (int u = 0, v = 2; u < 8; u += 2, v += 5) {
@ -219,9 +219,9 @@ public class SkeletonRenderer {
batch.setBlendFunction(blendMode.getSource(premultipliedAlpha), blendMode.getDest()); batch.setBlendFunction(blendMode.getSource(premultipliedAlpha), blendMode.getDest());
} }
float c = NumberUtils.intToFloatColor(((int)alpha << 24) // float c = NumberUtils.intToFloatColor((int)alpha << 24 //
| ((int)(b * slotColor.b * color.b * multiplier) << 16) // | (int)(b * slotColor.b * color.b * multiplier) << 16 //
| ((int)(g * slotColor.g * color.g * multiplier) << 8) // | (int)(g * slotColor.g * color.g * multiplier) << 8 //
| (int)(r * slotColor.r * color.r * multiplier)); | (int)(r * slotColor.r * color.r * multiplier));
if (clipper.isClipping()) { if (clipper.isClipping()) {
@ -345,9 +345,9 @@ public class SkeletonRenderer {
float red = r * color.r * multiplier; float red = r * color.r * multiplier;
float green = g * color.g * multiplier; float green = g * color.g * multiplier;
float blue = b * color.b * multiplier; float blue = b * color.b * multiplier;
float light = NumberUtils.intToFloatColor(((int)alpha << 24) // float light = NumberUtils.intToFloatColor((int)alpha << 24 //
| ((int)(blue * lightColor.b) << 16) // | (int)(blue * lightColor.b) << 16 //
| ((int)(green * lightColor.g) << 8) // | (int)(green * lightColor.g) << 8 //
| (int)(red * lightColor.r)); | (int)(red * lightColor.r));
Color darkColor = slot.getDarkColor(); Color darkColor = slot.getDarkColor();
float dark = darkColor == null ? 0 float dark = darkColor == null ? 0

View File

@ -160,7 +160,7 @@ public class Skin {
static public class SkinEntry { static public class SkinEntry {
int slotIndex; int slotIndex;
String name; String name;
Attachment attachment; @Null Attachment attachment;
private int hashCode; private int hashCode;
SkinEntry (int slotIndex, String name, @Null Attachment attachment) { SkinEntry (int slotIndex, String name, @Null Attachment attachment) {

View File

@ -43,8 +43,9 @@ import com.esotericsoftware.spine.attachments.VertexAttachment;
public class Slot { public class Slot {
final SlotData data; final SlotData data;
final Bone bone; final Bone bone;
final Color color = new Color(), darkColor; final Color color = new Color();
Attachment attachment; @Null final Color darkColor;
@Null Attachment attachment;
private float attachmentTime; private float attachmentTime;
private FloatArray deform = new FloatArray(); private FloatArray deform = new FloatArray();

View File

@ -38,8 +38,8 @@ public class SlotData {
final String name; final String name;
final BoneData boneData; final BoneData boneData;
final Color color = new Color(1, 1, 1, 1); final Color color = new Color(1, 1, 1, 1);
Color darkColor; @Null Color darkColor;
String attachmentName; @Null String attachmentName;
BlendMode blendMode; BlendMode blendMode;
public SlotData (int index, String name, BoneData boneData) { public SlotData (int index, String name, BoneData boneData) {

View File

@ -41,7 +41,7 @@ public interface AttachmentLoader {
/** @return May be null to not load the attachment. */ /** @return May be null to not load the attachment. */
public @Null RegionAttachment newRegionAttachment (Skin skin, String name, String path); public @Null RegionAttachment newRegionAttachment (Skin skin, String name, String path);
/** @return May be null to not load the attachment. */ /** @return May be null to not load the attachment. In that case null should also be returned for child meshes. */
public @Null MeshAttachment newMeshAttachment (Skin skin, String name, String path); public @Null MeshAttachment newMeshAttachment (Skin skin, String name, String path);
/** @return May be null to not load the attachment. */ /** @return May be null to not load the attachment. */

View File

@ -46,8 +46,8 @@ public class BoundingBoxAttachment extends VertexAttachment {
super(name); super(name);
} }
/** The color of the bounding box as it was in Spine. Available only when nonessential data was exported. Bounding boxes are /** The color of the bounding box as it was in Spine, or a default color if nonessential data was not exported. Bounding boxes
* not usually rendered at runtime. */ * are not usually rendered at runtime. */
public Color getColor () { public Color getColor () {
return color; return color;
} }

View File

@ -30,12 +30,13 @@
package com.esotericsoftware.spine.attachments; package com.esotericsoftware.spine.attachments;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.utils.Null;
import com.esotericsoftware.spine.SlotData; import com.esotericsoftware.spine.SlotData;
/** An attachment with vertices that make up a polygon used for clipping the rendering of other attachments. */ /** An attachment with vertices that make up a polygon used for clipping the rendering of other attachments. */
public class ClippingAttachment extends VertexAttachment { public class ClippingAttachment extends VertexAttachment {
SlotData endSlot; @Null SlotData endSlot;
// Nonessential. // Nonessential.
final Color color = new Color(0.2275f, 0.2275f, 0.8078f, 1); // ce3a3aff final Color color = new Color(0.2275f, 0.2275f, 0.8078f, 1); // ce3a3aff
@ -44,18 +45,18 @@ public class ClippingAttachment extends VertexAttachment {
super(name); super(name);
} }
/** Clipping is performed between the clipping polygon's slot and the end slot. Returns -1 if clipping is done until the end of /** Clipping is performed between the clipping attachment's slot and the end slot. If null clipping is done until the end of
* the skeleton's rendering. */ * the skeleton's rendering. */
public SlotData getEndSlot () { public @Null SlotData getEndSlot () {
return endSlot; return endSlot;
} }
public void setEndSlot (SlotData endSlot) { public void setEndSlot (@Null SlotData endSlot) {
this.endSlot = endSlot; this.endSlot = endSlot;
} }
/** The color of the clipping polygon as it was in Spine. Available only when nonessential data was exported. Clipping polygons /** The color of the clipping attachment as it was in Spine, or a default color if nonessential data was not exported. Clipping
* are not usually rendered at runtime. */ * attachments are not usually rendered at runtime. */
public Color getColor () { public Color getColor () {
return color; return color;
} }

View File

@ -47,10 +47,10 @@ public class MeshAttachment extends VertexAttachment {
private short[] triangles; private short[] triangles;
private final Color color = new Color(1, 1, 1, 1); private final Color color = new Color(1, 1, 1, 1);
private int hullLength; private int hullLength;
private MeshAttachment parentMesh; private @Null MeshAttachment parentMesh;
// Nonessential. // Nonessential.
private short[] edges; private @Null short[] edges;
private float width, height; private float width, height;
public MeshAttachment (String name) { public MeshAttachment (String name) {
@ -188,13 +188,13 @@ public class MeshAttachment extends VertexAttachment {
this.edges = edges; this.edges = edges;
} }
/** Vertex index pairs describing edges for controling triangulation. Mesh triangles will never cross edges. Only available if /** Vertex index pairs describing edges for controlling triangulation, or be null if nonessential data was not exported. Mesh
* nonessential data was exported. Triangulation is not performed at runtime. */ * triangles will never cross edges. Triangulation is not performed at runtime. */
public short[] getEdges () { public @Null short[] getEdges () {
return edges; return edges;
} }
/** The width of the mesh's image. Available only when nonessential data was exported. */ /** The width of the mesh's image, or zero if nonessential data was not exported. */
public float getWidth () { public float getWidth () {
return width; return width;
} }
@ -203,7 +203,7 @@ public class MeshAttachment extends VertexAttachment {
this.width = width; this.width = width;
} }
/** The height of the mesh's image. Available only when nonessential data was exported. */ /** The height of the mesh's image, or zero if nonessential data was not exported. */
public float getHeight () { public float getHeight () {
return height; return height;
} }
@ -215,7 +215,7 @@ public class MeshAttachment extends VertexAttachment {
/** The parent mesh if this is a linked mesh, else null. A linked mesh shares the {@link #bones}, {@link #vertices}, /** The parent mesh if this is a linked mesh, else null. A linked mesh shares the {@link #bones}, {@link #vertices},
* {@link #regionUVs}, {@link #triangles}, {@link #hullLength}, {@link #edges}, {@link #width}, and {@link #height} with the * {@link #regionUVs}, {@link #triangles}, {@link #hullLength}, {@link #edges}, {@link #width}, and {@link #height} with the
* parent mesh, but may have a different {@link #name} or {@link #path} (and therefore a different texture). */ * parent mesh, but may have a different {@link #name} or {@link #path} (and therefore a different texture). */
public MeshAttachment getParentMesh () { public @Null MeshAttachment getParentMesh () {
return parentMesh; return parentMesh;
} }

View File

@ -77,7 +77,7 @@ public class PathAttachment extends VertexAttachment {
this.lengths = lengths; this.lengths = lengths;
} }
/** The color of the path as it was in Spine. Available only when nonessential data was exported. Paths are not usually /** The color of the path as it was in Spine, or a default color if nonessential data was not exported. Paths are not usually
* rendered at runtime. */ * rendered at runtime. */
public Color getColor () { public Color getColor () {
return color; return color;

View File

@ -75,8 +75,8 @@ public class PointAttachment extends Attachment {
this.rotation = rotation; this.rotation = rotation;
} }
/** The color of the point attachment as it was in Spine. Available only when nonessential data was exported. Point attachments /** The color of the point attachment as it was in Spine, or a default clor if nonessential data was not exported. Point
* are not usually rendered at runtime. */ * attachments are not usually rendered at runtime. */
public Color getColor () { public Color getColor () {
return color; return color;
} }

View File

@ -35,7 +35,7 @@ import com.esotericsoftware.spine.Skeleton;
/** Attachment that displays a skeleton. */ /** Attachment that displays a skeleton. */
public class SkeletonAttachment extends Attachment { public class SkeletonAttachment extends Attachment {
private Skeleton skeleton; private @Null Skeleton skeleton;
public SkeletonAttachment (String name) { public SkeletonAttachment (String name) {
super(name); super(name);

View File

@ -44,10 +44,10 @@ abstract public class VertexAttachment extends Attachment {
static private int nextID; static private int nextID;
private final int id = nextID(); private final int id = nextID();
int[] bones; @Null int[] bones;
float[] vertices; float[] vertices;
int worldVerticesLength; int worldVerticesLength;
VertexAttachment deformAttachment = this; @Null VertexAttachment deformAttachment = this;
public VertexAttachment (String name) { public VertexAttachment (String name) {
super(name); super(name);