[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. */
static public class TrackEntry implements Poolable {
Animation animation;
TrackEntry next, mixingFrom, mixingTo;
AnimationStateListener listener;
@Null TrackEntry next, mixingFrom, mixingTo;
@Null AnimationStateListener listener;
int trackIndex;
boolean loop, holdPrevious, reverse;
float eventThreshold, attachmentThreshold, drawOrderThreshold;

View File

@ -47,7 +47,7 @@ import com.esotericsoftware.spine.BoneData.TransformMode;
public class Bone implements Updatable {
final BoneData data;
final Skeleton skeleton;
final Bone parent;
@Null final Bone parent;
final Array<Bone> children = new Array();
float x, y, rotation, scaleX, scaleY, shearX, shearY;
float ax, ay, arotation, ascaleX, ascaleY, ashearX, ashearY;
@ -66,7 +66,7 @@ public class Bone implements Updatable {
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) {
if (bone == null) throw new IllegalArgumentException("bone 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 {
final int index;
final String name;
final BoneData parent;
@Null final BoneData parent;
float length;
float x, y, rotation, scaleX = 1, scaleY = 1, shearX, shearY;
TransformMode transformMode = TransformMode.normal;
@ -187,7 +187,7 @@ public class BoneData {
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. */
public Color getColor () {
return color;

View File

@ -57,7 +57,7 @@ public class Skeleton {
final Array<PathConstraint> pathConstraints;
final Array<Updatable> updateCache = new Array();
final Array<Bone> updateCacheReset = new Array();
Skin skin;
@Null Skin skin;
final Color color;
float time;
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
* Guide. */
public class SkeletonData {
String name;
@Null String name;
final Array<BoneData> bones = new Array(); // Ordered parents first.
final Array<SlotData> slots = new Array(); // Setup pose draw order.
final Array<Skin> skins = new Array();
Skin defaultSkin;
@Null Skin defaultSkin;
final Array<EventData> events = new Array();
final Array<Animation> animations = new Array();
final Array<IkConstraintData> ikConstraints = new Array();
final Array<TransformConstraintData> transformConstraints = new Array();
final Array<PathConstraintData> pathConstraints = new Array();
float x, y, width, height;
String version, hash;
@Null String version, hash;
// Nonessential.
float fps = 30;
String imagesPath, audioPath;
@Null String imagesPath, audioPath;
// --- 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 () {
return name;
}
@ -280,7 +281,7 @@ public class SkeletonData {
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 () {
return imagesPath;
}
@ -289,7 +290,7 @@ public class SkeletonData {
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 () {
return audioPath;
}
@ -298,7 +299,7 @@ public class SkeletonData {
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 () {
return fps;
}

View File

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

View File

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

View File

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

View File

@ -38,8 +38,8 @@ public class SlotData {
final String name;
final BoneData boneData;
final Color color = new Color(1, 1, 1, 1);
Color darkColor;
String attachmentName;
@Null Color darkColor;
@Null String attachmentName;
BlendMode blendMode;
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. */
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);
/** @return May be null to not load the attachment. */

View File

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

View File

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

View File

@ -47,10 +47,10 @@ public class MeshAttachment extends VertexAttachment {
private short[] triangles;
private final Color color = new Color(1, 1, 1, 1);
private int hullLength;
private MeshAttachment parentMesh;
private @Null MeshAttachment parentMesh;
// Nonessential.
private short[] edges;
private @Null short[] edges;
private float width, height;
public MeshAttachment (String name) {
@ -188,13 +188,13 @@ public class MeshAttachment extends VertexAttachment {
this.edges = edges;
}
/** Vertex index pairs describing edges for controling triangulation. Mesh triangles will never cross edges. Only available if
* nonessential data was exported. Triangulation is not performed at runtime. */
public short[] getEdges () {
/** Vertex index pairs describing edges for controlling triangulation, or be null if nonessential data was not exported. Mesh
* triangles will never cross edges. Triangulation is not performed at runtime. */
public @Null short[] getEdges () {
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 () {
return width;
}
@ -203,7 +203,7 @@ public class MeshAttachment extends VertexAttachment {
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 () {
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},
* {@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). */
public MeshAttachment getParentMesh () {
public @Null MeshAttachment getParentMesh () {
return parentMesh;
}

View File

@ -77,7 +77,7 @@ public class PathAttachment extends VertexAttachment {
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. */
public Color getColor () {
return color;

View File

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

View File

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

View File

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