Skip to content

Commit

Permalink
Uberstate ready
Browse files Browse the repository at this point in the history
- Fix material state sorting/equality functions
  • Loading branch information
Jozufozu committed Sep 22, 2024
1 parent ff73e78 commit 897c350
Showing 1 changed file with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
public final class MaterialRenderState {
public static final Comparator<Material> COMPARATOR = Comparator.comparing((Material m) -> m.light()
.source())
.thenComparing(material -> material.cutout()
.source())
.thenComparing(material -> material.shaders()
.vertexSource())
.thenComparing(material -> material.shaders()
.fragmentSource())
.thenComparing(Material::texture)
.thenComparing(Material::blur)
.thenComparing(Material::mipmap)
Expand Down Expand Up @@ -185,12 +191,21 @@ public static boolean materialEquals(Material lhs, Material rhs) {
return true;
}

// Not here because ubershader: useLight, useOverlay, diffuse, shaders, fog shader, and cutout shader
// Not here because ubershader: useLight, useOverlay, diffuse, fog shader
// Everything in the comparator should be here.
return lhs.blur() == rhs.blur() && lhs.mipmap() == rhs.mipmap() && lhs.backfaceCulling() == rhs.backfaceCulling() && lhs.polygonOffset() == rhs.polygonOffset() && lhs.light()
.source()
.equals(rhs.light()
.source()) && lhs.texture()
.equals(rhs.texture()) && lhs.depthTest() == rhs.depthTest() && lhs.transparency() == rhs.transparency() && lhs.writeMask() == rhs.writeMask();
// @formatter:off
return lhs.blur() == rhs.blur()
&& lhs.mipmap() == rhs.mipmap()
&& lhs.backfaceCulling() == rhs.backfaceCulling()
&& lhs.polygonOffset() == rhs.polygonOffset()
&& lhs.depthTest() == rhs.depthTest()
&& lhs.transparency() == rhs.transparency()
&& lhs.writeMask() == rhs.writeMask()
&& lhs.light().source().equals(rhs.light().source())
&& lhs.texture().equals(rhs.texture())
&& lhs.cutout().source().equals(rhs.cutout().source())
&& lhs.shaders().fragmentSource().equals(rhs.shaders().fragmentSource())
&& lhs.shaders().vertexSource().equals(rhs.shaders().vertexSource());
// @formatter:on
}
}

0 comments on commit 897c350

Please sign in to comment.