diff --git a/assets/preload/data/characters/pico-speaker.hx b/assets/preload/data/characters/pico-speaker.hx index 6b77bb48..998b1bb5 100644 --- a/assets/preload/data/characters/pico-speaker.hx +++ b/assets/preload/data/characters/pico-speaker.hx @@ -1,10 +1,12 @@ import funkin.util.song.Song; var speaker; -var picoNotes_ = []; var hasLayer = false; var layer; +var picoIndex = 0; +var picoNotes = []; + function createChar() { ScriptChar.x += 120; speaker = new FlxSpriteExt(ScriptChar.x - 190, ScriptChar.y + 305.5); @@ -21,8 +23,8 @@ function createChar() { } function createPost() { - if (Paths.exists(Paths.chart(PlayState.SONG.song, 'picospeaker'), "TEXT")) { - picoNotes_ = Song.getSongNotes('picospeaker', PlayState.SONG.song); + if (Song.existsChart('picospeaker', PlayState.SONG.song)) { + picoNotes = Song.getSongNotes('picospeaker', PlayState.SONG.song); initTankmen(); } } @@ -33,9 +35,12 @@ function beatHit() function startTimer() speaker.playAnim('speakers', true); -function stepHit() { - if (picoNotes_.length <= 0) return; - var topNote = picoNotes_[0]; +function stepHit() +{ + if (picoIndex >= picoNotes.length) + return; + + var topNote = picoNotes[picoIndex]; if(Conductor.songPosition > topNote[0]) { var shootAnim = 1; if (topNote[1] >= 2) shootAnim = 3; @@ -44,7 +49,7 @@ function stepHit() { ScriptChar.playAnim('shoot' + shootAnim, true); ScriptChar.specialAnim = true; ScriptChar.forceDance = false; - picoNotes_.shift(); + picoIndex++; } } @@ -58,12 +63,12 @@ function initTankmen() { if (hasLayer) { layer = getLayer("tankmenRun"); - for (i in 0...picoNotes_.length) { + for (i in 0...picoNotes.length) { if (FlxG.random.bool(16)) { var spritePath = 'stress/tankmenShot' + (getPref('naughty') ? '' : '-censor'); var tankman = new FlxSpriteExt(500, 180 + FlxG.random.int(50, 100)).loadImage(spritePath); - tankman.flipX = picoNotes_[i][1] > 2; + tankman.flipX = picoNotes[i][1] > 2; tankman.scrollFactor.set(0.9, 0.9); tankman.setScale(0.8); @@ -72,7 +77,7 @@ function initTankmen() { tankman.playAnim('run', true, false, FlxG.random.int(0, 10)); var tankClass = tankman._dynamic; - tankClass.strumTime = picoNotes_[i][0]; + tankClass.strumTime = picoNotes[i][0]; tankClass.endingOffset = FlxG.random.float(50, 200); tankClass.tankSpeed = FlxG.random.float(0.6, 1); layer.add(tankman); diff --git a/source/funkin/objects/Character.hx b/source/funkin/objects/Character.hx index 33fc5c2b..720c80c8 100644 --- a/source/funkin/objects/Character.hx +++ b/source/funkin/objects/Character.hx @@ -189,7 +189,6 @@ class Character extends FlxSpriteExt public function flipCharOffsets():Void { flippedOffsets = true; - camOffsets.x = -camOffsets.x; if (!debugMode) { // Switch anims switchAnim('danceLeft', 'danceRight'); for (i in animOffsets.keys()) { @@ -231,10 +230,15 @@ class Character extends FlxSpriteExt __superUpdate(elapsed); } - public function prepareCamPoint(?point:Null, ?bounds:Array) { + public function prepareCamPoint(?point:Null, ?bounds:Array) + { point = getMidpoint(point); - point.subtract(camOffsets.x, camOffsets.y); - point.subtract(flippedOffsets ? -stageCamOffsets.x : stageCamOffsets.x, stageCamOffsets.y); + + point.subtract(camOffsets.x * (flippedOffsets ? -1 : 1), camOffsets.y); + point.subtract(stageCamOffsets.x, stageCamOffsets.y); + + if (flippedOffsets) + point.add((width * (isPlayerJson ? 0.25 : -(0.25 / 2))), 0); if (bounds != null) { point.x = FlxMath.bound(point.x, bounds[0], bounds[2]); diff --git a/source/funkin/objects/RatingGroup.hx b/source/funkin/objects/RatingGroup.hx index 65301891..e05fe00f 100644 --- a/source/funkin/objects/RatingGroup.hx +++ b/source/funkin/objects/RatingGroup.hx @@ -2,15 +2,37 @@ package funkin.objects; class RatingGroup extends TypedSpriteGroup { - public var targetSpr:FlxObject = null; + public var targetSpr(default, set):FlxObject; public var _offset:FlxPoint; - public function new(?targetSpr:FlxSprite):Void { + function set_targetSpr(obj:FlxObject) + { + if (obj != null) + { + if (obj is FlxSprite) + { + if (obj is Character) + { + var char = cast(obj, Character); + char.prepareCamPoint(_offset).subtract(char.x, char.y); + } + else + { + var spr = cast(obj, FlxSprite); + _offset.set(spr.frameWidth * spr.scale.x * 0.5, spr.frameHeight * spr.scale.y * 0.5); + } + } + } + + return targetSpr = obj; + } + + public function new(?targetSpr:FlxObject):Void + { super(); - this.targetSpr = targetSpr; + _offset = FlxPoint.get(); - if (targetSpr is FlxSprite) - _offset.set(targetSpr.frameWidth * targetSpr.scale.x, targetSpr.frameHeight * targetSpr.scale.y); + this.targetSpr = targetSpr; // Cache default ratings add(new JudgeRating()); @@ -31,7 +53,7 @@ class RatingGroup extends TypedSpriteGroup override public function update(elapsed:Float):Void { super.update(elapsed); if (targetSpr != null) { - setPosition(targetSpr.x - _offset.x * 0.5, targetSpr.y - _offset.y * 0.5); + setPosition(targetSpr.x - _offset.x, targetSpr.y - _offset.y); } } diff --git a/source/funkin/util/Paths.hx b/source/funkin/util/Paths.hx index 106adc51..69ef1ef6 100644 --- a/source/funkin/util/Paths.hx +++ b/source/funkin/util/Paths.hx @@ -1,5 +1,6 @@ package funkin.util; +import moonchart.formats.fnf.FNFMaru; import openfl.media.Sound; import haxe.io.Path; import flixel.graphics.frames.FlxAtlasFrames; @@ -174,7 +175,7 @@ class Paths **/ inline static public function songAudioAssetPath(song:String, asset:String, ?globalAsset:Bool):String { - var songKey = Song.formatSongFolder(song) + '/audio/$asset'; + var songKey = FNFMaru.formatTitle(song) + '/audio/$asset'; var diffPath = getPath('$songKey-${PlayState.curDifficulty}.$SOUND_EXT', MUSIC, 'songs', globalAsset); if (exists(diffPath, MUSIC)) return diffPath; @@ -200,7 +201,12 @@ class Paths return AssetManager.cacheSoundPath(instPath, false, null, stream); } - inline static public function chart(song:String, diff:String, ext:String = 'json'):String { + inline static public function chartFolder(title:String, ?allowMods:Bool):String + { + return getPath(title + "/charts", BINARY, "songs", false, allowMods); + } + + /*inline static public function chart(song:String, diff:String, ext:String = 'json'):String { if (!ext.startsWith('/')) ext = '.$ext'; @@ -209,7 +215,7 @@ class Paths inline static public function songMeta(song:String) { return getPath(Song.formatSongFolder(song) + '/charts/songMeta.json', TEXT, 'songs'); - } + }*/ /* * GRAPHICS diff --git a/source/funkin/util/song/Highscore.hx b/source/funkin/util/song/Highscore.hx index b2cb5dc5..653e9de5 100644 --- a/source/funkin/util/song/Highscore.hx +++ b/source/funkin/util/song/Highscore.hx @@ -82,10 +82,10 @@ class Highscore { } public static final ratingMap:Map = [ - "sick" => new Rating(350, 1, 0), - "good" => new Rating(200, 0.8, 0), - "bad" => new Rating(100, 0.5, 0.06), - "shit" => new Rating(50, 0.25, 0.1) + "sick" => new Rating(350, 1, 0), + "good" => new Rating(200, 0.8, 0), + "bad" => new Rating(100, 0.5, 0.06), + "shit" => new Rating(50, 0.25, 0.1) ]; } diff --git a/source/funkin/util/song/Song.hx b/source/funkin/util/song/Song.hx index 49efd971..65648d8c 100644 --- a/source/funkin/util/song/Song.hx +++ b/source/funkin/util/song/Song.hx @@ -1,7 +1,6 @@ package funkin.util.song; import moonchart.backend.Optimizer; -import haxe.Json; import flixel.util.FlxSort; import moonchart.backend.FormatDetector; @@ -16,59 +15,81 @@ typedef EventJson = FNFMaruEvent; class Song { - public static function loadFromFile(diff:String, folder:String):SongJson + public static function existsChart(diff:String, title:String):Bool { - folder = formatSongFolder(folder); + title = FNFMaru.formatTitle(title); - var formats:Array = []; - - @:privateAccess - for (format => data in FormatDetector.formatMap) + try { - if (formats.indexOf(data.extension) == -1) - formats.push(data.extension); + FormatDetector.findInFolder(Paths.chartFolder(title), title, diff); + return true; } - - formats.fastForEach((format, i) -> + catch (e) { - var chartPath:String = Paths.chart(folder, diff, format); + return false; + } - if (Paths.exists(chartPath, TEXT)) { + return false; + } - var format = FormatDetector.findFormat([chartPath]); - var maru:FNFMaru = new FNFMaru(); + public static function loadFromFile(diff:String, title:String):SongJson + { + title = FNFMaru.formatTitle(title); + + var folder:String = ""; + var foundFormat:DetectedFormatFiles = null; - switch (format) + try // Try finding in the current mod folder + { + folder = Paths.chartFolder(title, true); + foundFormat = FormatDetector.findInFolder(folder, title, diff); + } + catch (e) + { + try // If that failed then force it to be on assets + { + folder = Paths.chartFolder(title, false); + foundFormat = FormatDetector.findInFolder(folder, title, diff); + } + catch (e) + { + if (title == "tutorial" && diff == "hard") // Couldnt even find tutorial { - case FNF_MARU: - maru.fromFile(chartPath); - case _: - var chart = FormatDetector.createFormatInstance(format); - chart.fromFile(chartPath); - maru.fromFormat(chart); + throw 'Failed loading chart: ' + Std.string(e); + return null; + } + else // Fail safe to tutorial + { + trace('$folder$title-$diff CHART NOT FOUND'); + return loadFromFile('hard', 'tutorial'); } - - trace("LOADED CHART FROM FORMAT: " + format); - return maru.data.song; } - }); - - // Couldnt even find tutorial safe fail - if (folder == "tutorial") if (diff == "hard") + } + + var format = foundFormat.format; + var files = foundFormat.files; + var maru:FNFMaru = new FNFMaru(); + + switch (format) { - throw 'Failed loading chart.'; - return null; + case FNF_MARU: + maru.fromFile(files[0], files[1]); + case _: + var chart = FormatDetector.createFormatInstance(format); + chart.fromFile(files[0], files[1]); + maru.fromFormat(chart); } - - trace('$folder-$diff CHART NOT FOUND'); - return loadFromFile('hard', 'tutorial'); - } - public static function getSongMeta(song:String):Null { - var meta = CoolUtil.getFileContent(Paths.songMeta(song)); - return meta.length > 0 ? cast Json.parse(meta) : null; + trace('\nLOADED CHART SUCCESSFULLY.\nFROM FORMAT: $format\nFROM FILES: $files'); + return maru.data.song; } + //public static function getSongMeta(song:String):Null { + //var meta = CoolUtil.getFileContent(Paths.songMeta(song)); + //return meta.length > 0 ? cast Json.parse(meta) : null; + // return null; + //} + public static function getSectionTime(song:SongJson, section:Int = 0):Float { var crochet:Float = (60000 / song.bpm); var time:Float = 0; @@ -166,7 +187,7 @@ class Song final notes:Array = []; loadFromFile(diff, song).notes.fastForEach((s, i) -> { - if (s.sectionNotes != null) { + if (s.sectionNotes != null) if (s.sectionNotes.length > 0) { s.sectionNotes.fastForEach((n, i) -> { notes.push(n); }); @@ -177,24 +198,20 @@ class Song return notes; } - private static inline function sortNotes(note1:NoteJson, note2:NoteJson):Int { + private static inline function sortNotes(note1:NoteJson, note2:NoteJson):Int + { return FlxSort.byValues(FlxSort.ASCENDING, note1.time, note2.time); } - public static function formatSongFolder(songName:String):String { - var folder:String = ""; - songName.split("").fastForEach((char, i) -> { - switch (char) { - case "." | "?" | "*" | '"' | "'": - case " " | ":": folder = (folder + "-"); - default: folder = (folder + char.toLowerCase()); - } - }); - return folder; + public static inline function formatSongFolder(title:String):String + { + return FNFMaru.formatTitle(title); } - inline public static function getDefaultSong():SongJson { - return { + inline public static function getDefaultSong():SongJson + { + return + { song: 'Test', notes: [], bpm: 150, diff --git a/source/funkin/util/song/WeekSetup.hx b/source/funkin/util/song/WeekSetup.hx index 5dc5f048..873fb2ea 100644 --- a/source/funkin/util/song/WeekSetup.hx +++ b/source/funkin/util/song/WeekSetup.hx @@ -174,14 +174,15 @@ class WeekSetup return weekMap.get(week); } - public static function setupSong(weekName:String, songName:String, songDiff:String, storyMode:Bool):Void { - final _modFolder = weekMap.get(weekName)?.modFolder; - if (_modFolder == null) { // Base game + public static function setupSong(weekName:String, songName:String, songDiff:String, storyMode:Bool):Void + { + final modFolder = weekMap.get(weekName)?.modFolder; + if (modFolder == null) { // Base game ModdingUtil.curModFolder = ""; } - else if (ModdingUtil.modsMap.exists(_modFolder)) { // Mods - trace("Selected Mod folder " + _modFolder); - ModdingUtil.curModFolder = _modFolder; + else if (ModdingUtil.modsMap.exists(modFolder)) { // Mods + trace("Selected Mod folder " + modFolder); + ModdingUtil.curModFolder = modFolder; } PlayState.storyWeek = weekName; @@ -230,9 +231,8 @@ class WeekSetup Conductor.stop(); - if (FlxG.sound.music != null) { + if (FlxG.sound.music != null) FlxG.sound.music.fadeOut(0.333); - } CoolUtil.switchState(loadScreen, skipTrans, true); } diff --git a/source/openfl/display/_internal/Context3DGraphics.hx b/source/openfl/display/_internal/Context3DGraphics.hx index 3c255a10..57860ae1 100644 --- a/source/openfl/display/_internal/Context3DGraphics.hx +++ b/source/openfl/display/_internal/Context3DGraphics.hx @@ -20,6 +20,8 @@ import openfl.display._internal.stats.Context3DStats; import openfl.display._internal.stats.DrawCallContext; #end +using macros.FastArray; + #if !openfl_debug @:fileXml('tags="haxe,release"') @:noDebug @@ -41,7 +43,6 @@ class Context3DGraphics private static function buildBuffer(graphics:Graphics, renderer:OpenGLRenderer):Void { var quadBufferPosition = 0; - var triangleIndexBufferPosition = 0; var vertexBufferPosition = 0; var vertexBufferPositionUVT = 0; @@ -94,59 +95,32 @@ class Context3DGraphics { var c = data.readDrawQuads(); + #if cpp + var rects:Array = untyped __cpp__('c2->buffer->o->__unsafe_get(c2->oPos).StaticCast<::openfl::_Vector::FloatVector>()->_hx___array'); + var transforms:Array = untyped __cpp__('c2->buffer->o->__unsafe_get(c2->oPos + 2).StaticCast<::openfl::_Vector::FloatVector>()->_hx___array'); + #else var rects = c.rects; - var indices = c.indices; var transforms = c.transforms; - - #if cpp - var rects:Array = rects == null ? null : untyped __cpp__('({0})->_hx___array', rects); - var indices:Array = indices == null ? null : untyped __cpp__('({0})->_hx___array', indices); - var transforms:Array = transforms == null ? null :untyped __cpp__('({0})->_hx___array', transforms); #end - - var hasIndices = (indices != null); - var transformABCD = false, transformXY = false; - - var length = hasIndices ? indices.length : Math.floor(rects.length * 0.25); - if (length == 0) return; - - if (transforms != null) - { - if (transforms.length >= length * 6) - { - transformABCD = true; - transformXY = true; - } - else if (transforms.length >= length * 4) - { - transformABCD = true; - } - else if (transforms.length >= length * 2) - { - transformXY = true; - } - } - - var dataPerVertex = 4; - var stride = dataPerVertex * 4; + + var length = Math.floor(rects.length * 0.25); + if (length == 0) + return; if (graphics.__quadBuffer == null) { - graphics.__quadBuffer = new Context3DBuffer(context, QUADS, length, dataPerVertex); + graphics.__quadBuffer = new Context3DBuffer(context, QUADS, length, 4); } else { - graphics.__quadBuffer.resize(quadBufferPosition + length, dataPerVertex); + graphics.__quadBuffer.resize(quadBufferPosition + length, 4); } - var vertexOffset, alpha = 1.0, tileData, id; - var bitmapWidth, - bitmapHeight, - tileWidth:Float, - tileHeight:Float; + var vertexOffset:Int; + var bitmapWidth:Int, bitmapHeight:Int, tileWidth:Float, tileHeight:Float; var uvX, uvY, uvWidth, uvHeight; var x, y, x2, y2, x3, y3, x4, y4; - var ri, ti; + var ri:Int, ti:Int; var vertexBufferData = graphics.__quadBuffer.vertexBufferData; @@ -166,54 +140,46 @@ class Context3DGraphics bitmapHeight = bitmap.height; #end - // var sourceRect = bitmap.rect; - - for (i in 0...length) + var i = -1; + while (i < length) { - vertexOffset = (quadBufferPosition + i) * stride; - - ri = (hasIndices ? (indices[i] * 4) : i * 4); - if (ri < 0) continue; - tileRect.setTo(rects[ri], rects[ri + 1], rects[ri + 2], rects[ri + 3]); + i++; + vertexOffset = (quadBufferPosition + i) * 16; + ri = i * 4; + + if (ri < 0) + continue; + + tileRect.setTo( + rects[ri], + rects[ri + 1], + rects[ri + 2], + rects[ri + 3] + ); tileWidth = tileRect.width; tileHeight = tileRect.height; if (tileWidth <= 0 || tileHeight <= 0) - { continue; - } - if (transformABCD && transformXY) - { - ti = i * 6; - tileTransform.setTo(transforms[ti], transforms[ti + 1], transforms[ti + 2], transforms[ti + 3], transforms[ti + 4], - transforms[ti + 5]); - } - else if (transformABCD) - { - ti = i * 4; - tileTransform.setTo(transforms[ti], transforms[ti + 1], transforms[ti + 2], transforms[ti + 3], tileRect.x, tileRect.y); - } - else if (transformXY) - { - ti = i * 2; - tileTransform.tx = transforms[ti]; - tileTransform.ty = transforms[ti + 1]; - } - else - { - tileTransform.tx = tileRect.x; - tileTransform.ty = tileRect.y; - } + ti = i * 6; + tileTransform.setTo( + transforms[ti], + transforms[ti + 1], + transforms[ti + 2], + transforms[ti + 3], + transforms[ti + 4], + transforms[ti + 5] + ); uvX = tileRect.x / bitmapWidth; uvY = tileRect.y / bitmapHeight; uvWidth = tileRect.right / bitmapWidth; uvHeight = tileRect.bottom / bitmapHeight; - x = tileTransform.tx; // tileTransform.__transformX(0, 0); - y = tileTransform.ty; // tileTransform.__transformY(0, 0); + x = tileTransform.tx; + y = tileTransform.ty; x2 = tileTransform.__transformX(tileWidth, 0); y2 = tileTransform.__transformY(tileWidth, 0); x3 = tileTransform.__transformX(0, tileHeight); @@ -226,20 +192,20 @@ class Context3DGraphics vertexBufferData[vertexOffset + 2] = uvX; vertexBufferData[vertexOffset + 3] = uvY; - vertexBufferData[vertexOffset + dataPerVertex + 0] = x2; - vertexBufferData[vertexOffset + dataPerVertex + 1] = y2; - vertexBufferData[vertexOffset + dataPerVertex + 2] = uvWidth; - vertexBufferData[vertexOffset + dataPerVertex + 3] = uvY; + vertexBufferData[vertexOffset + (4 + 0)] = x2; + vertexBufferData[vertexOffset + (4 + 1)] = y2; + vertexBufferData[vertexOffset + (4 + 2)] = uvWidth; + vertexBufferData[vertexOffset + (4 + 3)] = uvY; - vertexBufferData[vertexOffset + (dataPerVertex * 2) + 0] = x3; - vertexBufferData[vertexOffset + (dataPerVertex * 2) + 1] = y3; - vertexBufferData[vertexOffset + (dataPerVertex * 2) + 2] = uvX; - vertexBufferData[vertexOffset + (dataPerVertex * 2) + 3] = uvHeight; + vertexBufferData[vertexOffset + (4 * 2) + 0] = x3; + vertexBufferData[vertexOffset + (4 * 2) + 1] = y3; + vertexBufferData[vertexOffset + (4 * 2) + 2] = uvX; + vertexBufferData[vertexOffset + (4 * 2) + 3] = uvHeight; - vertexBufferData[vertexOffset + (dataPerVertex * 3) + 0] = x4; - vertexBufferData[vertexOffset + (dataPerVertex * 3) + 1] = y4; - vertexBufferData[vertexOffset + (dataPerVertex * 3) + 2] = uvWidth; - vertexBufferData[vertexOffset + (dataPerVertex * 3) + 3] = uvHeight; + vertexBufferData[vertexOffset + (4 * 3) + 0] = x4; + vertexBufferData[vertexOffset + (4 * 3) + 1] = y4; + vertexBufferData[vertexOffset + (4 * 3) + 2] = uvWidth; + vertexBufferData[vertexOffset + (4 * 3) + 3] = uvHeight; } quadBufferPosition += length; @@ -265,8 +231,6 @@ class Context3DGraphics var vertexOffset = hasUVTData ? vertexBufferPositionUVT : vertexBufferPosition; // TODO: Use index buffer for indexed render - - // if (hasIndices) resizeIndexBuffer (graphics, false, triangleIndexBufferPosition + length); resizeVertexBuffer(graphics, hasUVTData, vertexOffset + (length * dataPerVertex)); // var indexBufferData = graphics.__triangleIndexBufferData; @@ -279,8 +243,6 @@ class Context3DGraphics vertOffset = hasIndices ? indices[i] * 2 : i * 2; uvOffset = hasIndices ? indices[i] * uvStride : i * uvStride; - // if (hasIndices) indexBufferData[triangleIndexBufferPosition + i] = indices[i]; - if (hasUVTData) { t = uvtData[uvOffset + 2]; @@ -300,7 +262,6 @@ class Context3DGraphics vertexBufferData[offset + vertLength + 1] = hasUVData ? uvtData[uvOffset + 1] : 0; } - // if (hasIndices) triangleIndexBufferPosition += length; if (hasUVTData) { vertexBufferPositionUVT += length * dataPerVertex; @@ -325,20 +286,6 @@ class Context3DGraphics graphics.__quadBuffer.flushVertexBufferData(); } - if (triangleIndexBufferPosition > 0) - { - var buffer = graphics.__triangleIndexBuffer; - - if (buffer == null || triangleIndexBufferPosition > graphics.__triangleIndexBufferCount) - { - buffer = context.createIndexBuffer(triangleIndexBufferPosition, DYNAMIC_DRAW); - graphics.__triangleIndexBuffer = buffer; - graphics.__triangleIndexBufferCount = triangleIndexBufferPosition; - } - - buffer.uploadFromTypedArray(graphics.__triangleIndexBufferData); - } - if (vertexBufferPosition > 0) { var buffer = graphics.__vertexBuffer; @@ -550,12 +497,19 @@ class Context3DGraphics var quadBufferPosition = 0; var shaderBufferOffset = 0; - var triangleIndexBufferPosition = 0; + var vertexBufferPosition = 0; var vertexBufferPositionUVT = 0; - for (type in graphics.__commands.types) + var t = 0; + final types = graphics.__commands.types; + final l = types.length; + + while (t < l) { + final type = types.unsafeGet(t); + t++; + switch (type) { case BEGIN_BITMAP_FILL: @@ -595,27 +549,13 @@ class Context3DGraphics if (bitmap != null) { var c = data.readDrawQuads(); - var indices = c.indices; - - var length:Int; - - if (indices != null) - { - length = #if cpp - untyped __cpp__('({0})->_hx___array->length', indices); - #else indices.length; - #end - } - else - { - var rects = c.rects; - length = Math.floor( - #if cpp untyped __cpp__('({0})->_hx___array->length', rects) - #else rects.length - #end * 0.25 - ); - } - + + var length = Math.floor( + #if cpp untyped __cpp__('c3->buffer->o->__unsafe_get(c3->oPos).StaticCast<::openfl::_Vector::FloatVector>()->_hx___array->length') + #else c.rects.length #end + * 0.25 + ); + var uMatrix = renderer.__getMatrix(graphics.__owner.__renderTransform, AUTO); var updateBuffer = shaderBuffer != null && !maskRender; var shader; @@ -789,17 +729,8 @@ class Context3DGraphics default: } - // if (hasIndices) { - - // context.drawTriangles (graphics.__triangleIndexBuffer, triangleIndexBufferPosition, Math.floor (length / 3)); - // triangleIndexBufferPosition += length; - - // } else { - context.__drawTriangles(0, length); - // } - shaderBufferOffset += length; if (hasUVTData) { diff --git a/source/openfl/display/_internal/DrawCommandReader.hx b/source/openfl/display/_internal/DrawCommandReader.hx index 8213928a..c72d206f 100644 --- a/source/openfl/display/_internal/DrawCommandReader.hx +++ b/source/openfl/display/_internal/DrawCommandReader.hx @@ -13,6 +13,8 @@ import openfl.display.TriangleCulling; import openfl.geom.Matrix; import openfl.Vector; +using macros.FastArray; + #if !openfl_debug @:fileXml('tags="haxe,release"') @:noDebug @@ -162,7 +164,7 @@ class DrawCommandReader @SuppressWarnings("checkstyle:Dynamic") private inline function obj(index:Int):Dynamic { - return buffer.o[oPos + index]; + return buffer.o.unsafeGet(oPos + index); } public inline function readBeginBitmapFill():BeginBitmapFillView diff --git a/source/openfl/display/_internal/DrawCommandType.hx b/source/openfl/display/_internal/DrawCommandType.hx index aa0d62c2..6386626f 100644 --- a/source/openfl/display/_internal/DrawCommandType.hx +++ b/source/openfl/display/_internal/DrawCommandType.hx @@ -1,6 +1,6 @@ package openfl.display._internal; -enum abstract DrawCommandType(Int) +enum abstract DrawCommandType(#if cpp cpp.UInt8 #else Int #end) { var BEGIN_BITMAP_FILL; var BEGIN_FILL;