diff --git a/gradle.properties b/gradle.properties index 3f301511c..0e53eea99 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,4 @@ -# Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx3G +org.gradle.jvmargs=-Xmx1G kotlin.code.style=official diff --git a/src/main/java/org/embeddedt/embeddium/impl/mixin/core/model/quad/BakedQuadMixin.java b/src/main/java/org/embeddedt/embeddium/impl/mixin/core/model/quad/BakedQuadMixin.java index e99105e9e..166231cbc 100644 --- a/src/main/java/org/embeddedt/embeddium/impl/mixin/core/model/quad/BakedQuadMixin.java +++ b/src/main/java/org/embeddedt/embeddium/impl/mixin/core/model/quad/BakedQuadMixin.java @@ -11,9 +11,6 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import static org.embeddedt.embeddium.impl.util.ModelQuadUtil.*; @@ -52,18 +49,6 @@ public class BakedQuadMixin implements BakedQuadView { @Unique private ModelQuadFacing normalFace; - @Inject(method = "//", at = @At("RETURN")) - private void init(CallbackInfo ci) { - if (this.normalFace != null) { - // injector already ran on other constructor, skip - return; - } - this.normal = ModelQuadUtil.calculateNormal(this); - this.normalFace = ModelQuadUtil.findNormalFace(this.normal); - - this.flags = ModelQuadFlags.getQuadFlags(this, this.direction); - } - @Override public float getX(int idx) { return Float.intBitsToFloat(this.vertices[vertexOffset(idx) + POSITION_INDEX]); @@ -111,7 +96,11 @@ public int getForgeNormal(int idx) { @Override public int getFlags() { - return this.flags; + int f = this.flags; + if (f == 0) { + this.flags = f = ModelQuadFlags.getQuadFlags(this, direction); + } + return f; } @Override @@ -126,12 +115,20 @@ public int getColorIndex() { @Override public ModelQuadFacing getNormalFace() { - return this.normalFace; + var face = this.normalFace; + if (face == null) { + this.normalFace = face = ModelQuadUtil.findNormalFace(getComputedFaceNormal()); + } + return face; } @Override public int getComputedFaceNormal() { - return this.normal; + int n = this.normal; + if (n == 0) { + this.normal = n = ModelQuadUtil.calculateNormal(this); + } + return n; } @Override diff --git a/src/main/java/org/embeddedt/embeddium/impl/model/quad/properties/ModelQuadFlags.java b/src/main/java/org/embeddedt/embeddium/impl/model/quad/properties/ModelQuadFlags.java index 768c24994..2f3ece438 100644 --- a/src/main/java/org/embeddedt/embeddium/impl/model/quad/properties/ModelQuadFlags.java +++ b/src/main/java/org/embeddedt/embeddium/impl/model/quad/properties/ModelQuadFlags.java @@ -26,6 +26,10 @@ public class ModelQuadFlags { * the normals of each vertex. */ public static final int IS_VANILLA_SHADED = 0b1000; + /** + * Indicates that the flags are populated for the quad. + */ + public static final int IS_POPULATED = (1 << 31); /** * @return True if the bit-flag of {@link ModelQuadFlags} contains the given flag @@ -111,6 +115,8 @@ public static int getQuadFlags(ModelQuadView quad, Direction face) { flags |= IS_ALIGNED; } + flags |= IS_POPULATED; + return flags; } } \ No newline at end of file