Skip to content

Commit

Permalink
fix: Build model once instead of per-frame in Playground
Browse files Browse the repository at this point in the history
  • Loading branch information
Pazaz committed Nov 24, 2024
1 parent 57a965d commit d9e701a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions client/src/main/java/Playground.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ public URL getCodeBase() {
int eyeYaw = 0;

int modifier = 2;
int model = 0;

Model model = null;
int modelId = 0;
int modelX = 0;
int modelY = 0;
int modelZ = 420;
Expand Down Expand Up @@ -155,6 +157,9 @@ protected void load() {

this.drawArea.bind();
Pix3D.init2D();

this.model = new Model(this.modelId);
this.model.calculateNormals(64, 850, -30, -50, -30, true);
} catch (Exception e) {
e.printStackTrace();
}
Expand All @@ -169,9 +174,7 @@ protected void draw() {
Pix2D.clear();
Pix2D.fillRect(0, 0, 0x555555, this.screenWidth, this.screenHeight);

Model model = new Model(this.model);
model.calculateNormals(64, 850, -30, -50, -30, true);
model.draw(this.modelYaw, Pix3D.sinTable[this.eyePitch], Pix3D.cosTable[this.eyePitch], Pix3D.sinTable[this.eyeYaw], Pix3D.cosTable[this.eyeYaw], this.modelX - this.eyeX, this.modelY - this.eyeY, this.modelZ - this.eyeZ, 0);
this.model.draw(this.modelYaw, Pix3D.sinTable[this.eyePitch], Pix3D.cosTable[this.eyePitch], Pix3D.sinTable[this.eyeYaw], Pix3D.cosTable[this.eyeYaw], this.modelX - this.eyeX, this.modelY - this.eyeY, this.modelZ - this.eyeZ, 0);

this.fontBold12.drawStringRight(this.screenWidth, this.fontBold12.height, "FPS: " + super.fps, 0xFFFF00, true);

Expand Down

0 comments on commit d9e701a

Please sign in to comment.