diff --git a/modchart/backend/graphics/CtxRenderer.hx b/modchart/backend/graphics/CtxRenderer.hx index 0b96e1e..d0417a9 100644 --- a/modchart/backend/graphics/CtxRenderer.hx +++ b/modchart/backend/graphics/CtxRenderer.hx @@ -172,16 +172,18 @@ class CtxRenderer { while (i < count) { var item = queue[i]; for (camera in item.cameras) { - var dc = camera.startTrianglesBatch(item.graphic, item.antialiasing, item.isColored, item.blend, item.hasColorOffsets, item.shader); @:privateAccess final cameraBounds = camera._bounds.set(camera.viewMarginLeft, camera.viewMarginTop, camera.viewWidth, camera.viewHeight); final point = FlxPoint.weak(camera.scroll.x * -item.parent.scrollFactor.x, camera.scroll.y * -item.parent.scrollFactor.y); - if (item.color != null) - dc.addTriangles(item.vertices.toFloatFlash(), item.indices.toIntFlash(), item.uvs.toFloatFlash(), emptyVec, point, cameraBounds, - item.color); - else if (item.colors != null) - dc.addGradientTriangles(item.vertices.toFloatFlash(), item.indices.toIntFlash(), item.uvs.toFloatFlash(), point, cameraBounds, item.colors); + final drawItem:FlxDrawTrianglesItem = camera.startTrianglesBatch(item.graphic, item.antialiasing, item.isColored, item.blend, item.hasColorOffsets, item.shader); + + if (item.color != null){ + drawItem.addTriangles(item.vertices.toFloatFlash(), item.indices.toIntFlash(), item.uvs.toFloatFlash(), null, point, cameraBounds, item.color); + } else if (item.colors != null){ + drawItem.addColoredTriangles(item.vertices.toFloatFlash(), item.indices.toIntFlash(), item.uvs.toFloatFlash(), null, point, cameraBounds, item.colors); + } + } i++; } diff --git a/modchart/backend/graphics/DrawCommand.hx b/modchart/backend/graphics/DrawCommand.hx index bfd079f..0837187 100644 --- a/modchart/backend/graphics/DrawCommand.hx +++ b/modchart/backend/graphics/DrawCommand.hx @@ -27,7 +27,7 @@ class DrawCommand { // each has a different use var color:Null = null; - var colors:Null> = null; + var colors:Null> = null; var zIndex:Int = 0; } diff --git a/modchart/backend/graphics/renderers/ArrowRenderer.hx b/modchart/backend/graphics/renderers/ArrowRenderer.hx index 1794e1b..88003da 100644 --- a/modchart/backend/graphics/renderers/ArrowRenderer.hx +++ b/modchart/backend/graphics/renderers/ArrowRenderer.hx @@ -184,19 +184,15 @@ final class ArrowRenderer extends BaseRenderer { // top left uvData[k++] = uvRectangle.left; uvData[k++] = uvRectangle.top; - uvData[k++] = 1 / projectionZ[0]; // top right uvData[k++] = uvRectangle.right; uvData[k++] = uvRectangle.top; - uvData[k++] = 1 / projectionZ[1]; // bottom left uvData[k++] = uvRectangle.left; uvData[k++] = uvRectangle.bottom; - uvData[k++] = 1 / projectionZ[2]; // bottom right uvData[k++] = uvRectangle.right; uvData[k++] = uvRectangle.bottom; - uvData[k++] = 1 / projectionZ[3]; #else // top left uvData[k++] = uvRectangle.x; diff --git a/modchart/backend/graphics/renderers/HoldRenderer.hx b/modchart/backend/graphics/renderers/HoldRenderer.hx index 2180b34..0595ee4 100644 --- a/modchart/backend/graphics/renderers/HoldRenderer.hx +++ b/modchart/backend/graphics/renderers/HoldRenderer.hx @@ -204,7 +204,7 @@ final class HoldRenderer extends BaseRenderer { basePos.y += Adapter.instance.getDefaultReceptorY(lane, player); var vertices = new NativeVector(8 * HOLD_SUBDIVISIONS); - var transfTotal = new NativeVector(HOLD_SUBDIVISIONS); + var transfTotal:Array = []; var tID = 0; var lastData:ArrowData = null; @@ -299,8 +299,12 @@ final class HoldRenderer extends BaseRenderer { var ctr:ColorTransform; - transfTotal[tID++] = ctr = new ColorTransform(negGlow, negGlow, negGlow, out1.visuals.alpha * item.alpha, - Math.round(out1.visuals.glowR * absGlow), Math.round(out1.visuals.glowG * absGlow), Math.round(out1.visuals.glowB * absGlow)); + ctr = new ColorTransform(negGlow, negGlow, negGlow, out1.visuals.alpha * item.alpha, + Math.round(out1.visuals.glowR * absGlow), Math.round(out1.visuals.glowG * absGlow), Math.round(out1.visuals.glowB * absGlow)); + + for(i in 0...HOLD_SUBDIVISIONS){ + transfTotal.push(ctr); + } if (ctr.hasRGBMultipliers() || ctr.alphaMultiplier != 1) hasC = true; diff --git a/modchart/backend/graphics/renderers/PathRenderer.hx b/modchart/backend/graphics/renderers/PathRenderer.hx index edab21f..3496025 100644 --- a/modchart/backend/graphics/renderers/PathRenderer.hx +++ b/modchart/backend/graphics/renderers/PathRenderer.hx @@ -22,14 +22,13 @@ final class PathRenderer extends BaseRenderer { public function updateTris(divisions:Int) { if (divisions != __lastDivisions) { - uvt = new NativeVector(divisions * 12); + uvt = new NativeVector(divisions * 9); indices = new NativeVector(divisions * 6); var ui = 0, ii = 0, vertCount = 0; for (div in 0...divisions) { for (_ in 0...4) { uvt.set(ui++, 0); uvt.set(ui++, 0); - uvt.set(ui++, 1); } // indices @@ -93,7 +92,7 @@ final class PathRenderer extends BaseRenderer { final colored = Config.ARROW_PATHS_CONFIG.APPLY_COLOR; final applyAlpha = Config.ARROW_PATHS_CONFIG.APPLY_ALPHA; - final transforms = new NativeVector(segs); + final transforms:Array = []; var tID:Int = 0; var hasC = false; @@ -156,8 +155,8 @@ final class PathRenderer extends BaseRenderer { var ctr:ColorTransform; - transforms[tID++] = ctr = new ColorTransform(negGlow, negGlow, negGlow, fAlpha * pathAlpha, Math.round(p0.visuals.glowR * absGlow), - Math.round(p0.visuals.glowG * absGlow), Math.round(p0.visuals.glowB * absGlow)); + transforms.push(ctr = new ColorTransform(negGlow, negGlow, negGlow, fAlpha * pathAlpha, Math.round(p0.visuals.glowR * absGlow), + Math.round(p0.visuals.glowG * absGlow), Math.round(p0.visuals.glowB * absGlow))); if (ctr.hasRGBMultipliers() || ctr.alphaMultiplier != 1) hasC = true; diff --git a/modchart/backend/util/ModchartUtil.hx b/modchart/backend/util/ModchartUtil.hx index ab85171..d277417 100644 --- a/modchart/backend/util/ModchartUtil.hx +++ b/modchart/backend/util/ModchartUtil.hx @@ -144,19 +144,19 @@ using StringTools; inline static public function getHoldUVT(arrow:FlxSprite, subs:Int):Vector { var frameAngle = -ModchartUtil.getFrameAngle(arrow); - var uv = new Vector(12 * subs); + var uv = new Vector(8 * subs); - // i think this solution is a lot better -swordcube - // and yes i tested to make sure it works -swordcube again - var frameUV:FlxRect = cast arrow.frame.uv; + var frameUV = arrow.frame.uv; - var left = frameUV.x; - var right = frameUV.y; - var top = frameUV.width; - var bottom = frameUV.height; + // i do not like this + // but i was suggested to do this instead by theo -swordcube + var left = #if (flixel >= "6.1.0") frameUV.left #else frameUV.x #end; + var right = #if (flixel >= "6.1.0") frameUV.right #else frameUV.y #end; + var top = #if (flixel >= "6.1.0") frameUV.top #else frameUV.width #end; + var bottom = #if (flixel >= "6.1.0") frameUV.bottom #else frameUV.height #end; - var frameWidth = top - left; - var frameHeight = bottom - right; + var frameWidth = right - left; + var frameHeight = bottom - top; var subDivided = 1.0 / subs; @@ -164,23 +164,19 @@ using StringTools; if ((frameAngle % 360) == 0) { for (curSub in 0...subs) { var uvOffset = subDivided * curSub; - var subIndex = curSub * 12; + var subIndex = curSub * 8; uv[subIndex] = left; // U - uv[subIndex + 1] = right + uvOffset * frameHeight; // V - uv[subIndex + 2] = 1; // T + uv[subIndex + 1] = top + frameHeight * uvOffset; // V - uv[subIndex + 3] = top; - uv[subIndex + 4] = right + uvOffset * frameHeight; - uv[subIndex + 5] = 1; + uv[subIndex + 2] = right; + uv[subIndex + 3] = top + frameHeight * uvOffset; - uv[subIndex + 6] = left; - uv[subIndex + 7] = right + (uvOffset + subDivided) * frameHeight; - uv[subIndex + 8] = 1; + uv[subIndex + 4] = left; + uv[subIndex + 5] = bottom - frameHeight * ((1.0 - subDivided) - uvOffset); - uv[subIndex + 9] = top; - uv[subIndex + 10] = right + (uvOffset + subDivided) * frameHeight; - uv[subIndex + 11] = 1; + uv[subIndex + 6] = right; + uv[subIndex + 7] = bottom - frameHeight * ((1.0 - subDivided) - uvOffset); } return uv; } @@ -190,7 +186,7 @@ using StringTools; var sinA = ModchartUtil.sin(angleRad); var uCenter = left + frameWidth * .5; - var vCenter = right + frameHeight * .5; + var vCenter = top + frameHeight * .5; // my brain is not braining anymore // i give up @@ -200,10 +196,10 @@ using StringTools; // uv coords before rotation var uvCoords = [ - [left, right + uvOffset * frameHeight], // tl - [top, right + uvOffset * frameHeight], // tr - [left, right + (uvOffset + subDivided) * frameHeight], // bl - [top, right + (uvOffset + subDivided) * frameHeight] // br + [left, top], // tl + [top, top], // tr + [left, bottom], // bl + [right, bottom] // br ]; // apply rotation @@ -214,11 +210,10 @@ using StringTools; var uRot = u * cosA - v * sinA; var vRot = u * sinA + v * cosA; - var base = subIndex + i * 3; + var base = subIndex + i * 2; uv[base] = uRot + uCenter; // U uv[base + 1] = vRot + vCenter; // V - uv[base + 2] = 1; // T } }