Skip to content

Commit

Permalink
Render Fix
Browse files Browse the repository at this point in the history
- fixed the render of 2D shapeboxes while still supporting the shadow fix. We love multiple hours of debugging \o/.
  • Loading branch information
broscolotos committed Nov 23, 2024
1 parent adb33db commit f5b1c3d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main/java/fexcraft/tmt/slim/ModelRendererTurbo.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ public ModelRendererTurbo(ModelBase modelbase, int textureX, int textureY, int t
private TexturedPolygon textureQuad(TexturedVertex vert1, TexturedVertex vert2, TexturedVertex vert3, TexturedVertex vert4, float f, float g, float h, float j){
List<TexturedVertex> verts = new ArrayList<>();
//casting to int will floor the input, this SHOULD fix the pixel offsets in weird shapeboxes
verts.add(vert1.setTexturePosition((int)h / textureWidth, (int)g / textureHeight));
verts.add(vert2.setTexturePosition((int)f / textureWidth, (int)g / textureHeight));
verts.add(vert3.setTexturePosition((int)f / textureWidth, (int)j / textureHeight));
verts.add(vert4.setTexturePosition((int)h / textureWidth, (int)j / textureHeight));
verts.add(vert1.setTexturePosition(h / textureWidth, g / textureHeight));
verts.add(vert2.setTexturePosition(f / textureWidth, g / textureHeight));
verts.add(vert3.setTexturePosition(f / textureWidth, j / textureHeight));
verts.add(vert4.setTexturePosition(h / textureWidth, j / textureHeight));
return new TexturedPolygon(verts);
}

Expand Down Expand Up @@ -164,13 +164,13 @@ public ModelRendererTurbo addRectShape(float[] v, float[] v1, float[] v2, float[
TexturedVertex vert7 = new TexturedVertex(v7[0], v7[1], v7[2], 8.0F, 0.0F);

if(w % 1 != 0){
w = w < 1 ? 1 : (int)w + (w % 1 > 0.5f ? 1 : 0);
w = w < 1 ? w % 1 < 0.5f ? 0 : 1 : (int)w + (w % 1 >= 0.5f ? 1 : 0);
}
if(h % 1 != 0){
h = h < 1 ? 1 : (int)h + (h % 1 > 0.5f ? 1 : 0);
h = h < 1 ? h % 1 < 0.5f ? 0 : 1 : (int)h + (h % 1 >= 0.5f ? 1 : 0);
}
if(d % 1 != 0){
d = d < 1 ? 1 : (int)d + (d % 1 > 0.5f ? 1 : 0);
d = d < 1 ? d % 1 < 0.5f ? 0 : 1 : (int)d + (d % 1 >= 0.5f ? 1 : 0);
}
if(sides == null){
poly.add(textureQuad(vert5, vert1, vert2, vert6, textureOffsetX + d + w, textureOffsetY + d, textureOffsetX + d + w + d, textureOffsetY + d + h));
Expand Down

0 comments on commit f5b1c3d

Please sign in to comment.