From edbba88c7cde14dbd3ef03d684e846b24fae109e Mon Sep 17 00:00:00 2001 From: Moxie <124418090+moxie-coder@users.noreply.github.com> Date: Wed, 11 Dec 2024 08:45:03 -0500 Subject: [PATCH 1/2] fixed it crashing (altho this requires my fork of Away3D since it contains an band-aid solution) --- hmm.json | 7 +++++++ source/editors/BenchmarkState.hx | 36 +++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/hmm.json b/hmm.json index af91dc69a97..e12854fa0fa 100644 --- a/hmm.json +++ b/hmm.json @@ -86,6 +86,13 @@ "dir": null, "ref": "cbf91e2180fd2e374924fe74844086aab7891666", "url": "https://gitlab.com/haxe-grig/grig.audio.git" + }, + { + "name": "away3d", + "type": "git", + "dir": null, + "ref": "master", + "url": "https://github.com/moxie-coder/away3d" } ] } diff --git a/source/editors/BenchmarkState.hx b/source/editors/BenchmarkState.hx index 9c802b41f15..1604b67eda2 100644 --- a/source/editors/BenchmarkState.hx +++ b/source/editors/BenchmarkState.hx @@ -3,6 +3,8 @@ package editors; import flixel.FlxG; import flixel.FlxState; import model.objects.flixel.Flixel; +import flx3D.Flx3DUtil; +import flixel.util.FlxDestroyUtil; class BenchmarkState extends FlxState { @@ -23,7 +25,39 @@ class BenchmarkState extends FlxState override function destroy() { - if (daFlixelLogo != null) daFlixelLogo.destroy(); + if (daFlixelLogo != null) { + @:privateAccess { + for (mesh in daFlixelLogo.meshs) { + if (mesh != null) { + // Dispose material first, as it may rely on geometry + if (mesh.material != null) { + mesh.material.dispose(); + mesh.material = null; + } + + // Dispose geometry next + if (mesh.geometry != null) { + mesh.geometry.dispose(); + mesh.geometry = null; + } + + // Finally, dispose of the mesh itself + mesh.dispose(); + mesh = null; + } + } + + // Dispose the 3D view (if it exists) + if (daFlixelLogo.view != null) { + daFlixelLogo.view.dispose(); + daFlixelLogo.view = null; + } + } + + // Destroy the Flixel object + daFlixelLogo = FlxDestroyUtil.destroy(daFlixelLogo); + } + super.destroy(); } override function update(elapsed:Float) From 57cd7faada14910683cd984c7fb27fdc6df2ce3a Mon Sep 17 00:00:00 2001 From: Moxie <124418090+moxie-coder@users.noreply.github.com> Date: Wed, 11 Dec 2024 09:20:56 -0500 Subject: [PATCH 2/2] Update BenchmarkState.hx --- source/editors/BenchmarkState.hx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/editors/BenchmarkState.hx b/source/editors/BenchmarkState.hx index 1604b67eda2..8decea7292b 100644 --- a/source/editors/BenchmarkState.hx +++ b/source/editors/BenchmarkState.hx @@ -3,7 +3,7 @@ package editors; import flixel.FlxG; import flixel.FlxState; import model.objects.flixel.Flixel; -import flx3D.Flx3DUtil; +import flixel.text.FlxText; import flixel.util.FlxDestroyUtil; class BenchmarkState extends FlxState @@ -19,6 +19,15 @@ class BenchmarkState extends FlxState { super.create(); + // TODO: add debug info and such + final text:FlxText = new FlxText(); + text.text = 'Press ESCAPE to leave.'; + text.screenCenter(X); + text.y = FlxG.height * 0.89; + text.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, CENTER, OUTLINE, FlxColor.BLACK); + text.borderSize = 2; + add(text); + daFlixelLogo = new Flixel(); add(daFlixelLogo); }