mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-24 18:51:25 +08:00
[libgdx] Fixed slot color. Inline setConstrained() for internal code.
This commit is contained in:
parent
913e694e22
commit
26df02443f
@ -36,14 +36,6 @@ abstract public class Posed< //
|
|||||||
return applied;
|
return applied;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setConstrained (boolean constrained) {
|
|
||||||
applied = constrained ? this.constrained : (A)pose;
|
|
||||||
}
|
|
||||||
|
|
||||||
void resetAppliedPose () {
|
|
||||||
applied.set(pose);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString () {
|
public String toString () {
|
||||||
return data.name;
|
return data.name;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -154,13 +154,19 @@ public class Skeleton {
|
|||||||
updateCache.clear();
|
updateCache.clear();
|
||||||
resetCache.clear();
|
resetCache.clear();
|
||||||
|
|
||||||
|
Slot[] slots = this.slots.items;
|
||||||
|
for (int i = 0, n = this.slots.size; i < n; i++) {
|
||||||
|
Slot slot = slots[i];
|
||||||
|
slot.applied = slot.pose;
|
||||||
|
}
|
||||||
|
|
||||||
int boneCount = bones.size;
|
int boneCount = bones.size;
|
||||||
Bone[] bones = this.bones.items;
|
Bone[] bones = this.bones.items;
|
||||||
for (int i = 0; i < boneCount; i++) {
|
for (int i = 0; i < boneCount; i++) {
|
||||||
Bone bone = bones[i];
|
Bone bone = bones[i];
|
||||||
bone.sorted = bone.data.skinRequired;
|
bone.sorted = bone.data.skinRequired;
|
||||||
bone.active = !bone.sorted;
|
bone.active = !bone.sorted;
|
||||||
bone.setConstrained(false);
|
bone.applied = (BonePose)bone.pose;
|
||||||
}
|
}
|
||||||
if (skin != null) {
|
if (skin != null) {
|
||||||
BoneData[] skinBones = skin.bones.items;
|
BoneData[] skinBones = skin.bones.items;
|
||||||
@ -176,8 +182,10 @@ public class Skeleton {
|
|||||||
|
|
||||||
Constraint[] constraints = this.constraints.items;
|
Constraint[] constraints = this.constraints.items;
|
||||||
int n = this.constraints.size;
|
int n = this.constraints.size;
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++) {
|
||||||
constraints[i].setConstrained(false);
|
Constraint constraint = constraints[i];
|
||||||
|
constraint.applied = constraint.pose;
|
||||||
|
}
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
Constraint<?, ?, ?> constraint = constraints[i];
|
Constraint<?, ?, ?> constraint = constraints[i];
|
||||||
constraint.active = constraint.isSourceActive()
|
constraint.active = constraint.isSourceActive()
|
||||||
@ -196,7 +204,7 @@ public class Skeleton {
|
|||||||
|
|
||||||
void resetCache (Posed object) {
|
void resetCache (Posed object) {
|
||||||
if (object.pose == object.applied) {
|
if (object.pose == object.applied) {
|
||||||
object.setConstrained(true);
|
object.applied = object.constrained;
|
||||||
resetCache.add(object);
|
resetCache.add(object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -228,8 +236,10 @@ public class Skeleton {
|
|||||||
update++;
|
update++;
|
||||||
|
|
||||||
Posed[] resetCache = this.resetCache.items;
|
Posed[] resetCache = this.resetCache.items;
|
||||||
for (int i = 0, n = this.resetCache.size; i < n; i++)
|
for (int i = 0, n = this.resetCache.size; i < n; i++) {
|
||||||
resetCache[i].resetAppliedPose();
|
Posed object = resetCache[i];
|
||||||
|
object.applied.set(object.pose);
|
||||||
|
}
|
||||||
|
|
||||||
Object[] updateCache = this.updateCache.items;
|
Object[] updateCache = this.updateCache.items;
|
||||||
for (int i = 0, n = this.updateCache.size; i < n; i++)
|
for (int i = 0, n = this.updateCache.size; i < n; i++)
|
||||||
@ -241,14 +251,16 @@ public class Skeleton {
|
|||||||
* <p>
|
* <p>
|
||||||
* See <a href="https://esotericsoftware.com/spine-runtime-skeletons#World-transforms">World transforms</a> in the Spine
|
* See <a href="https://esotericsoftware.com/spine-runtime-skeletons#World-transforms">World transforms</a> in the Spine
|
||||||
* Runtimes Guide. */
|
* Runtimes Guide. */
|
||||||
public void updateWorldTransform (Physics physics, BonePose parent) {
|
public void updateWorldTransform (Physics physics, BonePose parent) { // Do not port.
|
||||||
if (parent == null) throw new IllegalArgumentException("parent cannot be null.");
|
if (parent == null) throw new IllegalArgumentException("parent cannot be null.");
|
||||||
|
|
||||||
update++;
|
update++;
|
||||||
|
|
||||||
Posed[] resetCache = this.resetCache.items;
|
Posed[] resetCache = this.resetCache.items;
|
||||||
for (int i = 0, n = this.resetCache.size; i < n; i++)
|
for (int i = 0, n = this.resetCache.size; i < n; i++) {
|
||||||
resetCache[i].resetAppliedPose();
|
Posed object = resetCache[i];
|
||||||
|
object.applied.set(object.pose);
|
||||||
|
}
|
||||||
|
|
||||||
// Apply the parent bone transform to the root bone. The root bone always inherits scale, rotation and reflection.
|
// Apply the parent bone transform to the root bone. The root bone always inherits scale, rotation and reflection.
|
||||||
BonePose rootBone = getRootBone().applied;
|
BonePose rootBone = getRootBone().applied;
|
||||||
|
|||||||
@ -46,7 +46,7 @@ public class Slot extends Posed<SlotData, SlotPose, SlotPose> {
|
|||||||
bone = skeleton.bones.items[data.boneData.index];
|
bone = skeleton.bones.items[data.boneData.index];
|
||||||
if (data.setup.darkColor != null) {
|
if (data.setup.darkColor != null) {
|
||||||
pose.darkColor = new Color();
|
pose.darkColor = new Color();
|
||||||
applied.darkColor = new Color();
|
constrained.darkColor = new Color();
|
||||||
}
|
}
|
||||||
setupPose();
|
setupPose();
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ public class Slot extends Posed<SlotData, SlotPose, SlotPose> {
|
|||||||
this.skeleton = skeleton;
|
this.skeleton = skeleton;
|
||||||
if (data.setup.darkColor != null) {
|
if (data.setup.darkColor != null) {
|
||||||
pose.darkColor = new Color();
|
pose.darkColor = new Color();
|
||||||
applied.darkColor = new Color();
|
constrained.darkColor = new Color();
|
||||||
}
|
}
|
||||||
pose.set(slot.pose);
|
pose.set(slot.pose);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -97,7 +97,7 @@ public class TransformConstraint extends Constraint<TransformConstraint, Transfo
|
|||||||
}
|
}
|
||||||
if (localTarget)
|
if (localTarget)
|
||||||
bone.updateWorldTransform(skeleton);
|
bone.updateWorldTransform(skeleton);
|
||||||
else
|
else
|
||||||
bone.localDirty = true;
|
bone.localDirty = true;
|
||||||
bone.bone.resetUpdate(skeleton);
|
bone.bone.resetUpdate(skeleton);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user