mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-09 16:48:43 +08:00
Formatting.
This commit is contained in:
parent
083a842c97
commit
ec70e3438d
@ -421,33 +421,30 @@ public class Animation {
|
||||
|
||||
Color color = skeleton.slots.get(slotIndex).color;
|
||||
|
||||
if (time >= frames[frames.length - 5]) { // Time is after last frame.
|
||||
float r, g, b, a;
|
||||
if (time >= frames[frames.length - 5]) {
|
||||
// Time is after last frame.
|
||||
int i = frames.length - 1;
|
||||
float r = frames[i - 3];
|
||||
float g = frames[i - 2];
|
||||
float b = frames[i - 1];
|
||||
float a = frames[i];
|
||||
if (alpha < 1)
|
||||
color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
|
||||
else
|
||||
color.set(r, g, b, a);
|
||||
return;
|
||||
r = frames[i - 3];
|
||||
g = frames[i - 2];
|
||||
b = frames[i - 1];
|
||||
a = frames[i];
|
||||
} else {
|
||||
// Interpolate between the previous frame and the current frame.
|
||||
int frameIndex = binarySearch(frames, time, 5);
|
||||
float prevFrameR = frames[frameIndex - 4];
|
||||
float prevFrameG = frames[frameIndex - 3];
|
||||
float prevFrameB = frames[frameIndex - 2];
|
||||
float prevFrameA = frames[frameIndex - 1];
|
||||
float frameTime = frames[frameIndex];
|
||||
float percent = MathUtils.clamp(1 - (time - frameTime) / (frames[frameIndex + PREV_FRAME_TIME] - frameTime), 0, 1);
|
||||
percent = getCurvePercent(frameIndex / 5 - 1, percent);
|
||||
|
||||
r = prevFrameR + (frames[frameIndex + FRAME_R] - prevFrameR) * percent;
|
||||
g = prevFrameG + (frames[frameIndex + FRAME_G] - prevFrameG) * percent;
|
||||
b = prevFrameB + (frames[frameIndex + FRAME_B] - prevFrameB) * percent;
|
||||
a = prevFrameA + (frames[frameIndex + FRAME_A] - prevFrameA) * percent;
|
||||
}
|
||||
|
||||
// Interpolate between the previous frame and the current frame.
|
||||
int frameIndex = binarySearch(frames, time, 5);
|
||||
float prevFrameR = frames[frameIndex - 4];
|
||||
float prevFrameG = frames[frameIndex - 3];
|
||||
float prevFrameB = frames[frameIndex - 2];
|
||||
float prevFrameA = frames[frameIndex - 1];
|
||||
float frameTime = frames[frameIndex];
|
||||
float percent = MathUtils.clamp(1 - (time - frameTime) / (frames[frameIndex + PREV_FRAME_TIME] - frameTime), 0, 1);
|
||||
percent = getCurvePercent(frameIndex / 5 - 1, percent);
|
||||
|
||||
float r = prevFrameR + (frames[frameIndex + FRAME_R] - prevFrameR) * percent;
|
||||
float g = prevFrameG + (frames[frameIndex + FRAME_G] - prevFrameG) * percent;
|
||||
float b = prevFrameB + (frames[frameIndex + FRAME_B] - prevFrameB) * percent;
|
||||
float a = prevFrameA + (frames[frameIndex + FRAME_A] - prevFrameA) * percent;
|
||||
if (alpha < 1)
|
||||
color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
|
||||
else
|
||||
|
||||
@ -170,10 +170,11 @@ public class SkeletonJson {
|
||||
private Attachment readAttachment (Skin skin, String name, JsonValue map) {
|
||||
float scale = this.scale;
|
||||
name = map.getString("name", name);
|
||||
String path = map.getString("path", name);
|
||||
|
||||
switch (AttachmentType.valueOf(map.getString("type", AttachmentType.region.name()))) {
|
||||
case region:
|
||||
RegionAttachment region = attachmentLoader.newRegionAttachment(skin, name, map.getString("path", name));
|
||||
RegionAttachment region = attachmentLoader.newRegionAttachment(skin, name, path);
|
||||
if (region == null) return null;
|
||||
region.setX(map.getFloat("x", 0) * scale);
|
||||
region.setY(map.getFloat("y", 0) * scale);
|
||||
@ -200,7 +201,7 @@ public class SkeletonJson {
|
||||
return box;
|
||||
}
|
||||
case mesh: {
|
||||
MeshAttachment mesh = attachmentLoader.newMeshAttachment(skin, name, map.getString("path", name));
|
||||
MeshAttachment mesh = attachmentLoader.newMeshAttachment(skin, name, path);
|
||||
if (mesh == null) return null;
|
||||
float[] uvs = map.require("uvs").asFloatArray();
|
||||
short[] triangles = map.require("triangles").asShortArray();
|
||||
@ -219,7 +220,7 @@ public class SkeletonJson {
|
||||
return mesh;
|
||||
}
|
||||
case skinnedmesh: {
|
||||
SkinnedMeshAttachment mesh = attachmentLoader.newSkinnedMeshAttachment(skin, name, map.getString("path", name));
|
||||
SkinnedMeshAttachment mesh = attachmentLoader.newSkinnedMeshAttachment(skin, name, path);
|
||||
if (mesh == null) return null;
|
||||
float[] uvs = map.require("uvs").asFloatArray();
|
||||
short[] triangles = map.require("triangles").asShortArray();
|
||||
|
||||
@ -44,31 +44,30 @@ public class AtlasAttachmentLoader implements AttachmentLoader {
|
||||
}
|
||||
|
||||
public RegionAttachment newRegionAttachment (Skin skin, String name, String path) {
|
||||
RegionAttachment attachment = new RegionAttachment(name);
|
||||
attachment.setPath(path);
|
||||
AtlasRegion region = atlas.findRegion(path);
|
||||
if (region == null)
|
||||
throw new RuntimeException("Region not found in atlas: " + attachment + " (region attachment: " + name + ")");
|
||||
throw new RuntimeException("Region not found in atlas: " + path + " (region attachment: " + name + ")");
|
||||
RegionAttachment attachment = new RegionAttachment(name);
|
||||
attachment.setPath(path);
|
||||
attachment.setRegion(region);
|
||||
return attachment;
|
||||
}
|
||||
|
||||
public MeshAttachment newMeshAttachment (Skin skin, String name, String path) {
|
||||
AtlasRegion region = atlas.findRegion(path);
|
||||
if (region == null) throw new RuntimeException("Region not found in atlas: " + path + " (mesh attachment: " + name + ")");
|
||||
MeshAttachment attachment = new MeshAttachment(name);
|
||||
attachment.setPath(path);
|
||||
AtlasRegion region = atlas.findRegion(path);
|
||||
if (region == null)
|
||||
throw new RuntimeException("Region not found in atlas: " + attachment + " (mesh attachment: " + name + ")");
|
||||
attachment.setRegion(region);
|
||||
return attachment;
|
||||
}
|
||||
|
||||
public SkinnedMeshAttachment newSkinnedMeshAttachment (Skin skin, String name, String path) {
|
||||
SkinnedMeshAttachment attachment = new SkinnedMeshAttachment(name);
|
||||
attachment.setPath(path);
|
||||
AtlasRegion region = atlas.findRegion(path);
|
||||
if (region == null)
|
||||
throw new RuntimeException("Region not found in atlas: " + attachment + " (skinned mesh attachment: " + name + ")");
|
||||
throw new RuntimeException("Region not found in atlas: " + path + " (skinned mesh attachment: " + name + ")");
|
||||
SkinnedMeshAttachment attachment = new SkinnedMeshAttachment(name);
|
||||
attachment.setPath(path);
|
||||
attachment.setRegion(region);
|
||||
return attachment;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user