Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/20.1/forge' into 21.0/neoforge
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt committed Sep 22, 2024
2 parents a74f410 + 496c59e commit d4561aa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx3G
org.gradle.jvmargs=-Xmx1G

kotlin.code.style=official

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand Down Expand Up @@ -52,18 +49,6 @@ public class BakedQuadMixin implements BakedQuadView {
@Unique
private ModelQuadFacing normalFace;

@Inject(method = "/<init>/", 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]);
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -111,6 +115,8 @@ public static int getQuadFlags(ModelQuadView quad, Direction face) {
flags |= IS_ALIGNED;
}

flags |= IS_POPULATED;

return flags;
}
}

0 comments on commit d4561aa

Please sign in to comment.