mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Renamed visible to active. Added isActive to Updatable/bones/constraints.
This commit is contained in:
parent
b3c2170ed2
commit
b71970afa6
@ -349,7 +349,7 @@ public class Animation {
|
|||||||
MixDirection direction) {
|
MixDirection direction) {
|
||||||
|
|
||||||
Bone bone = skeleton.bones.get(boneIndex);
|
Bone bone = skeleton.bones.get(boneIndex);
|
||||||
if (!bone.visible) return;
|
if (!bone.active) return;
|
||||||
float[] frames = this.frames;
|
float[] frames = this.frames;
|
||||||
if (time < frames[0]) { // Time is before first frame.
|
if (time < frames[0]) { // Time is before first frame.
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
@ -447,7 +447,7 @@ public class Animation {
|
|||||||
MixDirection direction) {
|
MixDirection direction) {
|
||||||
|
|
||||||
Bone bone = skeleton.bones.get(boneIndex);
|
Bone bone = skeleton.bones.get(boneIndex);
|
||||||
if (!bone.visible) return;
|
if (!bone.active) return;
|
||||||
float[] frames = this.frames;
|
float[] frames = this.frames;
|
||||||
if (time < frames[0]) { // Time is before first frame.
|
if (time < frames[0]) { // Time is before first frame.
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
@ -509,7 +509,7 @@ public class Animation {
|
|||||||
MixDirection direction) {
|
MixDirection direction) {
|
||||||
|
|
||||||
Bone bone = skeleton.bones.get(boneIndex);
|
Bone bone = skeleton.bones.get(boneIndex);
|
||||||
if (!bone.visible) return;
|
if (!bone.active) return;
|
||||||
float[] frames = this.frames;
|
float[] frames = this.frames;
|
||||||
if (time < frames[0]) { // Time is before first frame.
|
if (time < frames[0]) { // Time is before first frame.
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
@ -612,7 +612,7 @@ public class Animation {
|
|||||||
MixDirection direction) {
|
MixDirection direction) {
|
||||||
|
|
||||||
Bone bone = skeleton.bones.get(boneIndex);
|
Bone bone = skeleton.bones.get(boneIndex);
|
||||||
if (!bone.visible) return;
|
if (!bone.active) return;
|
||||||
float[] frames = this.frames;
|
float[] frames = this.frames;
|
||||||
if (time < frames[0]) { // Time is before first frame.
|
if (time < frames[0]) { // Time is before first frame.
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
|
|||||||
@ -348,7 +348,7 @@ public class AnimationState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bone bone = skeleton.bones.get(timeline.boneIndex);
|
Bone bone = skeleton.bones.get(timeline.boneIndex);
|
||||||
if (!bone.visible) return;
|
if (!bone.active) return;
|
||||||
float[] frames = timeline.frames;
|
float[] frames = timeline.frames;
|
||||||
float r1, r2;
|
float r1, r2;
|
||||||
if (time < frames[0]) { // Time is before first frame.
|
if (time < frames[0]) { // Time is before first frame.
|
||||||
|
|||||||
@ -54,7 +54,7 @@ public class Bone implements Updatable {
|
|||||||
float a, b, worldX;
|
float a, b, worldX;
|
||||||
float c, d, worldY;
|
float c, d, worldY;
|
||||||
|
|
||||||
boolean sorted, visible;
|
boolean sorted, active;
|
||||||
|
|
||||||
/** @param parent May be null. */
|
/** @param parent May be null. */
|
||||||
public Bone (BoneData data, Skeleton skeleton, Bone parent) {
|
public Bone (BoneData data, Skeleton skeleton, Bone parent) {
|
||||||
@ -235,6 +235,12 @@ public class Bone implements Updatable {
|
|||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns false when the bone has not been computed because {@link BoneData#getSkinRequired()} is true and the
|
||||||
|
* {@link Skeleton#getSkin() active skin} does not {@link Skin#getBones() contain} this bone. */
|
||||||
|
public boolean isActive () {
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
// -- Local transform
|
// -- Local transform
|
||||||
|
|
||||||
/** The local x translation. */
|
/** The local x translation. */
|
||||||
|
|||||||
@ -45,6 +45,8 @@ public class IkConstraint implements Updatable {
|
|||||||
boolean compress, stretch;
|
boolean compress, stretch;
|
||||||
float mix = 1;
|
float mix = 1;
|
||||||
|
|
||||||
|
boolean active;
|
||||||
|
|
||||||
public IkConstraint (IkConstraintData data, Skeleton skeleton) {
|
public IkConstraint (IkConstraintData data, Skeleton skeleton) {
|
||||||
if (data == null) throw new IllegalArgumentException("data cannot be null.");
|
if (data == null) throw new IllegalArgumentException("data cannot be null.");
|
||||||
if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null.");
|
if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null.");
|
||||||
@ -144,6 +146,10 @@ public class IkConstraint implements Updatable {
|
|||||||
this.stretch = stretch;
|
this.stretch = stretch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isActive () {
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
/** The IK constraint's setup pose data. */
|
/** The IK constraint's setup pose data. */
|
||||||
public IkConstraintData getData () {
|
public IkConstraintData getData () {
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
@ -51,6 +51,8 @@ public class PathConstraint implements Updatable {
|
|||||||
Slot target;
|
Slot target;
|
||||||
float position, spacing, rotateMix, translateMix;
|
float position, spacing, rotateMix, translateMix;
|
||||||
|
|
||||||
|
boolean active;
|
||||||
|
|
||||||
private final FloatArray spaces = new FloatArray(), positions = new FloatArray();
|
private final FloatArray spaces = new FloatArray(), positions = new FloatArray();
|
||||||
private final FloatArray world = new FloatArray(), curves = new FloatArray(), lengths = new FloatArray();
|
private final FloatArray world = new FloatArray(), curves = new FloatArray(), lengths = new FloatArray();
|
||||||
private final float[] segments = new float[10];
|
private final float[] segments = new float[10];
|
||||||
@ -498,6 +500,10 @@ public class PathConstraint implements Updatable {
|
|||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isActive () {
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
/** The path constraint's setup pose data. */
|
/** The path constraint's setup pose data. */
|
||||||
public PathConstraintData getData () {
|
public PathConstraintData getData () {
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
@ -166,7 +166,7 @@ public class Skeleton {
|
|||||||
for (int i = 0; i < boneCount; i++) {
|
for (int i = 0; i < boneCount; i++) {
|
||||||
Bone bone = (Bone)bones[i];
|
Bone bone = (Bone)bones[i];
|
||||||
bone.sorted = bone.data.skinRequired;
|
bone.sorted = bone.data.skinRequired;
|
||||||
bone.visible = !bone.sorted;
|
bone.active = !bone.sorted;
|
||||||
}
|
}
|
||||||
if (skin != null) {
|
if (skin != null) {
|
||||||
Object[] skinBones = skin.bones.items;
|
Object[] skinBones = skin.bones.items;
|
||||||
@ -174,7 +174,7 @@ public class Skeleton {
|
|||||||
Bone bone = (Bone)bones[((BoneData)skinBones[i]).index];
|
Bone bone = (Bone)bones[((BoneData)skinBones[i]).index];
|
||||||
do {
|
do {
|
||||||
bone.sorted = false;
|
bone.sorted = false;
|
||||||
bone.visible = true;
|
bone.active = true;
|
||||||
bone = bone.parent;
|
bone = bone.parent;
|
||||||
} while (bone != null);
|
} while (bone != null);
|
||||||
}
|
}
|
||||||
@ -215,7 +215,8 @@ public class Skeleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sortIkConstraint (IkConstraint constraint) {
|
private void sortIkConstraint (IkConstraint constraint) {
|
||||||
if (constraint.data.skinRequired && (skin == null || !skin.constraints.contains(constraint.data, true))) return;
|
constraint.active = !constraint.data.skinRequired || (skin != null && skin.constraints.contains(constraint.data, true));
|
||||||
|
if (!constraint.active) return;
|
||||||
|
|
||||||
Bone target = constraint.target;
|
Bone target = constraint.target;
|
||||||
sortBone(target);
|
sortBone(target);
|
||||||
@ -236,7 +237,8 @@ public class Skeleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sortPathConstraint (PathConstraint constraint) {
|
private void sortPathConstraint (PathConstraint constraint) {
|
||||||
if (constraint.data.skinRequired && (skin == null || !skin.constraints.contains(constraint.data, true))) return;
|
constraint.active = !constraint.data.skinRequired || (skin != null && skin.constraints.contains(constraint.data, true));
|
||||||
|
if (!constraint.active) return;
|
||||||
|
|
||||||
Slot slot = constraint.target;
|
Slot slot = constraint.target;
|
||||||
int slotIndex = slot.getData().index;
|
int slotIndex = slot.getData().index;
|
||||||
@ -262,7 +264,8 @@ public class Skeleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sortTransformConstraint (TransformConstraint constraint) {
|
private void sortTransformConstraint (TransformConstraint constraint) {
|
||||||
if (constraint.data.skinRequired && (skin == null || !skin.constraints.contains(constraint.data, true))) return;
|
constraint.active = !constraint.data.skinRequired || (skin != null && skin.constraints.contains(constraint.data, true));
|
||||||
|
if (!constraint.active) return;
|
||||||
|
|
||||||
sortBone(constraint.target);
|
sortBone(constraint.target);
|
||||||
|
|
||||||
@ -319,7 +322,7 @@ public class Skeleton {
|
|||||||
private void sortReset (Array<Bone> bones) {
|
private void sortReset (Array<Bone> bones) {
|
||||||
for (int i = 0, n = bones.size; i < n; i++) {
|
for (int i = 0, n = bones.size; i < n; i++) {
|
||||||
Bone bone = bones.get(i);
|
Bone bone = bones.get(i);
|
||||||
if (!bone.visible) continue;
|
if (!bone.active) continue;
|
||||||
if (bone.sorted) sortReset(bone.children);
|
if (bone.sorted) sortReset(bone.children);
|
||||||
bone.sorted = false;
|
bone.sorted = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,7 +88,7 @@ public class SkeletonRenderer {
|
|||||||
Array<Slot> drawOrder = skeleton.drawOrder;
|
Array<Slot> drawOrder = skeleton.drawOrder;
|
||||||
for (int i = 0, n = drawOrder.size; i < n; i++) {
|
for (int i = 0, n = drawOrder.size; i < n; i++) {
|
||||||
Slot slot = drawOrder.get(i);
|
Slot slot = drawOrder.get(i);
|
||||||
if (!slot.bone.visible) continue;
|
if (!slot.bone.active) continue;
|
||||||
Attachment attachment = slot.attachment;
|
Attachment attachment = slot.attachment;
|
||||||
if (attachment instanceof RegionAttachment) {
|
if (attachment instanceof RegionAttachment) {
|
||||||
RegionAttachment region = (RegionAttachment)attachment;
|
RegionAttachment region = (RegionAttachment)attachment;
|
||||||
@ -167,7 +167,7 @@ public class SkeletonRenderer {
|
|||||||
Array<Slot> drawOrder = skeleton.drawOrder;
|
Array<Slot> drawOrder = skeleton.drawOrder;
|
||||||
for (int i = 0, n = drawOrder.size; i < n; i++) {
|
for (int i = 0, n = drawOrder.size; i < n; i++) {
|
||||||
Slot slot = drawOrder.get(i);
|
Slot slot = drawOrder.get(i);
|
||||||
if (!slot.bone.visible) continue;
|
if (!slot.bone.active) continue;
|
||||||
Texture texture = null;
|
Texture texture = null;
|
||||||
int vertexSize = clipper.isClipping() ? 2 : 5;
|
int vertexSize = clipper.isClipping() ? 2 : 5;
|
||||||
Attachment attachment = slot.attachment;
|
Attachment attachment = slot.attachment;
|
||||||
@ -291,7 +291,7 @@ public class SkeletonRenderer {
|
|||||||
Array<Slot> drawOrder = skeleton.drawOrder;
|
Array<Slot> drawOrder = skeleton.drawOrder;
|
||||||
for (int i = 0, n = drawOrder.size; i < n; i++) {
|
for (int i = 0, n = drawOrder.size; i < n; i++) {
|
||||||
Slot slot = drawOrder.get(i);
|
Slot slot = drawOrder.get(i);
|
||||||
if (!slot.bone.visible) continue;
|
if (!slot.bone.active) continue;
|
||||||
Texture texture = null;
|
Texture texture = null;
|
||||||
int vertexSize = clipper.isClipping() ? 2 : 6;
|
int vertexSize = clipper.isClipping() ? 2 : 6;
|
||||||
Attachment attachment = slot.attachment;
|
Attachment attachment = slot.attachment;
|
||||||
|
|||||||
@ -84,7 +84,7 @@ public class SkeletonRendererDebug {
|
|||||||
if (drawBones) {
|
if (drawBones) {
|
||||||
for (int i = 0, n = bones.size; i < n; i++) {
|
for (int i = 0, n = bones.size; i < n; i++) {
|
||||||
Bone bone = bones.get(i);
|
Bone bone = bones.get(i);
|
||||||
if (bone.parent == null || !bone.visible) continue;
|
if (bone.parent == null || !bone.active) continue;
|
||||||
float length = bone.data.length, width = boneWidth;
|
float length = bone.data.length, width = boneWidth;
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
length = 8;
|
length = 8;
|
||||||
@ -239,7 +239,7 @@ public class SkeletonRendererDebug {
|
|||||||
shapes.setColor(boneOriginColor);
|
shapes.setColor(boneOriginColor);
|
||||||
for (int i = 0, n = bones.size; i < n; i++) {
|
for (int i = 0, n = bones.size; i < n; i++) {
|
||||||
Bone bone = bones.get(i);
|
Bone bone = bones.get(i);
|
||||||
if (!bone.visible) continue;
|
if (!bone.active) continue;
|
||||||
shapes.circle(bone.worldX, bone.worldY, 3 * scale, 8);
|
shapes.circle(bone.worldX, bone.worldY, 3 * scale, 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,6 +43,8 @@ public class TransformConstraint implements Updatable {
|
|||||||
final Array<Bone> bones;
|
final Array<Bone> bones;
|
||||||
Bone target;
|
Bone target;
|
||||||
float rotateMix, translateMix, scaleMix, shearMix;
|
float rotateMix, translateMix, scaleMix, shearMix;
|
||||||
|
|
||||||
|
boolean active;
|
||||||
final Vector2 temp = new Vector2();
|
final Vector2 temp = new Vector2();
|
||||||
|
|
||||||
public TransformConstraint (TransformConstraintData data, Skeleton skeleton) {
|
public TransformConstraint (TransformConstraintData data, Skeleton skeleton) {
|
||||||
@ -338,6 +340,10 @@ public class TransformConstraint implements Updatable {
|
|||||||
this.shearMix = shearMix;
|
this.shearMix = shearMix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isActive () {
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
/** The transform constraint's setup pose data. */
|
/** The transform constraint's setup pose data. */
|
||||||
public TransformConstraintData getData () {
|
public TransformConstraintData getData () {
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
@ -29,6 +29,13 @@
|
|||||||
|
|
||||||
package com.esotericsoftware.spine;
|
package com.esotericsoftware.spine;
|
||||||
|
|
||||||
|
/** The interface for items updated by {@link Skeleton#updateWorldTransform()}. */
|
||||||
public interface Updatable {
|
public interface Updatable {
|
||||||
public void update ();
|
public void update ();
|
||||||
|
|
||||||
|
/** Returns false when this item has not been updated because a skine is required and the {@link Skeleton#getSkin() active
|
||||||
|
* skin} does not contain this item.
|
||||||
|
* @see Skin#getBones()
|
||||||
|
* @see Skin#getConstraints() */
|
||||||
|
public boolean isActive ();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user