I BROKE THE OFFSETS FUCK
.
This commit is contained in:
@@ -1265,10 +1265,7 @@ final class CoolUtil
|
||||
}
|
||||
|
||||
public static function getAnimsListFromSprite(spr:FunkinSprite):Array<String> {
|
||||
if (spr.animateAtlas != null) {
|
||||
return [for (symbol => timeline in spr.animateAtlas.anim.symbolDictionary) symbol];
|
||||
} else
|
||||
return getAnimsListFromFrames(spr.frames);
|
||||
return getAnimsListFromFrames(spr.frames);
|
||||
}
|
||||
|
||||
// TODO: check this for bugs
|
||||
|
||||
@@ -34,151 +34,23 @@ final class MatrixUtil {
|
||||
//if(_height == -1) _height = sprite.height;
|
||||
if(camera == null) camera = sprite.camera;
|
||||
if(points is FlxBasePoint) points = [points];
|
||||
var isFunkinSprite = sprite is FunkinSprite;
|
||||
var funkinSprite:FunkinSprite = null;
|
||||
if(isFunkinSprite) funkinSprite = cast sprite;
|
||||
var isAnimateAtlas = isFunkinSprite && funkinSprite.animateAtlas != null;
|
||||
|
||||
var nc:FakeCamera = isAnimateAtlas ? FakeCallCamera.instance : FakeCamera.instance;
|
||||
var nc:FakeCamera = FakeCamera.instance;
|
||||
nc.zoom = camera.zoom;
|
||||
nc.scroll.set(camera.scroll.x, camera.scroll.y);
|
||||
nc.pixelPerfectRender = camera.pixelPerfectRender;
|
||||
|
||||
var points:Array<FlxPoint> = cast points;
|
||||
|
||||
if(isAnimateAtlas) {
|
||||
var cnc = FakeCallCamera.instance;
|
||||
var sprite = funkinSprite;
|
||||
var oldOnDraw = cnc.onDraw;
|
||||
|
||||
// TODO: fix rotation
|
||||
// TODO: fix skew
|
||||
|
||||
var boundsTopLeft = new FlxPoint(Math.POSITIVE_INFINITY, Math.POSITIVE_INFINITY);
|
||||
var boundsTopRight = new FlxPoint(Math.NEGATIVE_INFINITY, Math.POSITIVE_INFINITY);
|
||||
var boundsBottomLeft = new FlxPoint(Math.POSITIVE_INFINITY, Math.NEGATIVE_INFINITY);
|
||||
var boundsBottomRight = new FlxPoint(Math.NEGATIVE_INFINITY, Math.NEGATIVE_INFINITY);
|
||||
|
||||
cnc.onDraw = function(?frame:FlxFrame, ?pixels:BitmapData, matrix:FlxMatrix, ?transform:ColorTransform, ?blend:BlendMode, ?smoothing:Bool = false, ?shader:FlxShader) {
|
||||
// cnc is already perfect rn
|
||||
// so we need to manually process the limb
|
||||
var points = [
|
||||
// corners
|
||||
FlxPoint.get(0, 0),
|
||||
FlxPoint.get(1, 0),
|
||||
FlxPoint.get(0, 1),
|
||||
FlxPoint.get(1, 1)
|
||||
];
|
||||
|
||||
rawTransformPoints(points, matrix, frame.sourceSize.x, frame.sourceSize.y);
|
||||
|
||||
// sort the points, incase like they were transformed with a scale -1 matrix
|
||||
|
||||
var topLeft:FlxPoint = points[0];
|
||||
var topRight:FlxPoint = points[1];
|
||||
var bottomLeft:FlxPoint = points[2];
|
||||
var bottomRight:FlxPoint = points[3];
|
||||
|
||||
if (points[0].y > points[1].y) {
|
||||
topLeft = points[1];
|
||||
topRight = points[0];
|
||||
}
|
||||
if (points[2].y > points[3].y) {
|
||||
bottomLeft = points[3];
|
||||
bottomRight = points[2];
|
||||
}
|
||||
|
||||
if (topLeft.x > topRight.x) {
|
||||
var temp = topLeft;
|
||||
topLeft = topRight;
|
||||
topRight = temp;
|
||||
}
|
||||
|
||||
if (bottomLeft.x > bottomRight.x) {
|
||||
var temp = bottomLeft;
|
||||
bottomLeft = bottomRight;
|
||||
bottomRight = temp;
|
||||
}
|
||||
|
||||
// points should now contain the corners of the limb
|
||||
|
||||
// trace("Corners of limb: " + points);
|
||||
|
||||
// set the max bounds of each corner of the limb
|
||||
if(topLeft.x < boundsTopLeft.x) boundsTopLeft.x = topLeft.x;
|
||||
if(topLeft.y < boundsTopLeft.y) boundsTopLeft.y = topLeft.y;
|
||||
if(topRight.x > boundsTopRight.x) boundsTopRight.x = topRight.x;
|
||||
if(topRight.y < boundsTopRight.y) boundsTopRight.y = topRight.y;
|
||||
if(bottomLeft.x < boundsBottomLeft.x) boundsBottomLeft.x = bottomLeft.x;
|
||||
if(bottomLeft.y > boundsBottomLeft.y) boundsBottomLeft.y = bottomLeft.y;
|
||||
if(bottomRight.x > boundsBottomRight.x) boundsBottomRight.x = bottomRight.x;
|
||||
if(bottomRight.y > boundsBottomRight.y) boundsBottomRight.y = bottomRight.y;
|
||||
|
||||
// recycle the points
|
||||
for(point in points) point.put();
|
||||
}
|
||||
var cameras = sprite._cameras;
|
||||
var oldVisible = cnc.visible;
|
||||
cnc.visible = true;
|
||||
sprite._cameras = [cnc];
|
||||
sprite.draw();
|
||||
sprite._cameras = cameras;
|
||||
cnc.visible = oldVisible;
|
||||
cnc.onDraw = oldOnDraw;
|
||||
|
||||
// fake transform
|
||||
|
||||
//trace("");
|
||||
//trace("topLeft: " + boundsTopLeft);
|
||||
//trace("topRight: " + boundsTopRight);
|
||||
//trace("bottomLeft: " + boundsBottomLeft);
|
||||
//trace("bottomRight: " + boundsBottomRight);
|
||||
//trace("Before transform");
|
||||
//trace(points);
|
||||
|
||||
for(point in points) {
|
||||
//var x = matrix.__transformX(point.x * _width, point.y * _height);
|
||||
//var y = matrix.__transformY(point.x * _width, point.y * _height);
|
||||
// apply using boundsTopLeft, boundsTopRight, boundsBottomLeft, boundsBottomRight
|
||||
// matrix doesnt work for this
|
||||
var x = FlxMath.lerp(
|
||||
FlxMath.lerp(boundsTopLeft.x, boundsTopRight.x, point.x),
|
||||
FlxMath.lerp(boundsBottomLeft.x, boundsBottomRight.x, point.x),
|
||||
point.y
|
||||
);
|
||||
var y = FlxMath.lerp(
|
||||
FlxMath.lerp(boundsTopLeft.y, boundsTopRight.y, point.x),
|
||||
FlxMath.lerp(boundsBottomLeft.y, boundsBottomRight.y, point.x),
|
||||
point.y
|
||||
);
|
||||
|
||||
//trace("(" + point.x + ", " + point.y + ") -> (" + x + ", " + y + ")");
|
||||
|
||||
// reset to ingame coords
|
||||
x += camera.scroll.x;
|
||||
y += camera.scroll.y;
|
||||
|
||||
if(isFunkinSprite) {
|
||||
var ratio = 1 - FlxMath.lerp(1 / camera.zoom, 1, funkinSprite.zoomFactor);
|
||||
x += camera.width / 2 * ratio;
|
||||
y += camera.height / 2 * ratio;
|
||||
}
|
||||
point.set(x, y);
|
||||
}
|
||||
|
||||
//trace("After transform");
|
||||
//trace(points);
|
||||
if(sprite is IPrePostDraw) {
|
||||
var postDraw = cast(sprite, IPrePostDraw);
|
||||
postDraw.preDraw();
|
||||
sprite.drawComplex(nc);
|
||||
postDraw.postDraw();
|
||||
} else {
|
||||
if(sprite is IPrePostDraw) {
|
||||
var postDraw = cast(sprite, IPrePostDraw);
|
||||
postDraw.preDraw();
|
||||
sprite.drawComplex(nc);
|
||||
postDraw.postDraw();
|
||||
} else {
|
||||
sprite.drawComplex(nc);
|
||||
}
|
||||
transformPoints(sprite, points, sprite._matrix, camera, _width, _height);
|
||||
sprite.drawComplex(nc);
|
||||
}
|
||||
transformPoints(sprite, points, sprite._matrix, camera, _width, _height);
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import funkin.backend.scripting.ScriptPack;
|
||||
import flixel.util.typeLimit.OneOfTwo;
|
||||
import funkin.backend.system.interfaces.IOffsetCompatible;
|
||||
import haxe.xml.Access;
|
||||
import animate.FlxAnimateFrames;
|
||||
|
||||
using StringTools;
|
||||
|
||||
@@ -127,6 +128,10 @@ final class XMLUtil {
|
||||
spr.spriteAnimType = XMLAnimType.fromString(node.att.type, spr.spriteAnimType);
|
||||
}
|
||||
|
||||
if (node.has.applyStageMatrix) {
|
||||
spr.applyStageMatrix = node.att.applyStageMatrix == "true";
|
||||
}
|
||||
|
||||
if(node.has.x) {
|
||||
var x:Null<Float> = Std.parseFloat(node.att.x);
|
||||
if (x.isNotNull()) spr.x = x;
|
||||
@@ -299,11 +304,12 @@ final class XMLUtil {
|
||||
if (animData.name != null) {
|
||||
if (animData.fps <= 0 #if web || animData.fps == null #end) animData.fps = 24;
|
||||
|
||||
if (sprite is FunkinSprite && cast(sprite, FunkinSprite).animateAtlas != null) {
|
||||
var animateAnim = cast(sprite, FunkinSprite).animateAtlas.anim;
|
||||
if (sprite.frames is FlxAnimateFrames) {
|
||||
if(animData.anim == null)
|
||||
return MISSING_PROPERTY;
|
||||
|
||||
var animateAnim = cast(sprite, FunkinSprite).anim;
|
||||
|
||||
if (animData.indices != null && animData.indices.length > 0)
|
||||
animateAnim.addBySymbolIndices(animData.name, animData.anim, animData.indices, animData.fps, animData.loop);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user