From 4961a2af79b7050944ffd606731efb8dc83480b8 Mon Sep 17 00:00:00 2001 From: FalsePattern <30945458+FalsePattern@users.noreply.github.com> Date: Wed, 19 Jan 2022 14:32:16 +0100 Subject: [PATCH] Use different triangle vertex order permutations, cutting down overhead on the array manipulation logic --- .../mixin/mixins/client/TessellatorMixin.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/falsepattern/triangulator/mixin/mixins/client/TessellatorMixin.java b/src/main/java/com/falsepattern/triangulator/mixin/mixins/client/TessellatorMixin.java index 5fb2b6ee..7901ca59 100644 --- a/src/main/java/com/falsepattern/triangulator/mixin/mixins/client/TessellatorMixin.java +++ b/src/main/java/com/falsepattern/triangulator/mixin/mixins/client/TessellatorMixin.java @@ -81,19 +81,15 @@ private void hackVertex(CallbackInfo ci) { } //Current vertex layout: ABCD if (alternativeTriangulation) { - //Target vertex layout: BCDBDA - System.arraycopy(rawBuffer, rawBufferIndex - 32, rawBuffer, rawBufferIndex + 8, 8); - System.arraycopy(rawBuffer, rawBufferIndex - 8, rawBuffer, rawBufferIndex, 8); - System.arraycopy(rawBuffer, rawBufferIndex - 24, rawBuffer, rawBufferIndex - 8, 8); - System.arraycopy(rawBuffer, rawBufferIndex - 24, rawBuffer, rawBufferIndex - 32, 8); - System.arraycopy(rawBuffer, rawBufferIndex - 16, rawBuffer, rawBufferIndex - 24, 8); - System.arraycopy(rawBuffer, rawBufferIndex, rawBuffer, rawBufferIndex - 16, 8); + //Target vertex layout: ABD DBC + System.arraycopy(rawBuffer, rawBufferIndex - 16, rawBuffer, rawBufferIndex + 8, 8); + System.arraycopy(rawBuffer, rawBufferIndex - 24, rawBuffer, rawBufferIndex, 8); + System.arraycopy(rawBuffer, rawBufferIndex - 8, rawBuffer, rawBufferIndex - 16, 8); alternativeTriangulation = false; } else { - //Target vertex layout: ABCACD - System.arraycopy(rawBuffer, rawBufferIndex - 8, rawBuffer, rawBufferIndex + 8, 8); - System.arraycopy(rawBuffer, rawBufferIndex - 16, rawBuffer, rawBufferIndex, 8); - System.arraycopy(rawBuffer, rawBufferIndex - 32, rawBuffer, rawBufferIndex - 8, 8); + //Target vertex layout: ABC DAC + System.arraycopy(rawBuffer, rawBufferIndex - 32, rawBuffer, rawBufferIndex, 8); + System.arraycopy(rawBuffer, rawBufferIndex - 16, rawBuffer, rawBufferIndex + 8, 8); } vertexCount += 2; rawBufferIndex += 16;