Skip to content

Commit 5c5b981

Browse files
committed
refactor: remove stored sin/cos x/y values from Scene (store CameraRotation instead)
1 parent 09536c4 commit 5c5b981

File tree

3 files changed

+67
-51
lines changed

3 files changed

+67
-51
lines changed

src/main/java/org/runejs/client/media/renderable/Model.java

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.runejs.client.media.VertexNormal;
1010
import org.runejs.client.Class40_Sub5_Sub15;
1111
import org.runejs.OldEngine.ModelLoader;
12+
import org.runejs.client.scene.camera.CameraRotation;
1213

1314
public class Model extends Renderable {
1415
public static Model aClass40_Sub5_Sub17_Sub5_3170 = new Model();
@@ -734,17 +735,23 @@ public void method799() {
734735
}
735736
}
736737

737-
public void renderAtPoint(int arg0, int arg1, int arg2, int arg3, int arg4, int x, int z, int y, int arg8) {
738+
public void renderAtPoint(int arg0, CameraRotation cameraRotation, int x, int z, int y, int arg8) {
738739
if(anInt3169 != 1)
739740
method799();
740-
int i = y * arg4 - x * arg3 >> 16;
741-
int i_4_ = z * arg1 + i * arg2 >> 16;
742-
int i_5_ = diagonal2DAboveOrigin * arg2 >> 16;
741+
742+
int yawSine = cameraRotation.yawSine;
743+
int yawCosine = cameraRotation.yawCosine;
744+
int pitchSine = cameraRotation.pitchSine;
745+
int pitchCosine = cameraRotation.pitchCosine;
746+
747+
int i = y * yawCosine - x * yawSine >> 16;
748+
int i_4_ = z * pitchSine + i * pitchCosine >> 16;
749+
int i_5_ = diagonal2DAboveOrigin * pitchCosine >> 16;
743750
int i_6_ = i_4_ + i_5_;
744751
if(i_6_ <= 50/* || i_4_ >= 3500*/) {
745752
return;
746753
}
747-
int i_7_ = y * arg3 + x * arg4 >> 16;
754+
int i_7_ = y * yawSine + x * yawCosine >> 16;
748755
int i_8_ = i_7_ - diagonal2DAboveOrigin << 9;
749756
if(i_8_ / i_6_ >= Rasterizer3D.anInt2934) {
750757
return;
@@ -753,18 +760,18 @@ public void renderAtPoint(int arg0, int arg1, int arg2, int arg3, int arg4, int
753760
if(i_9_ / i_6_ <= Rasterizer3D.anInt2942) {
754761
return;
755762
}
756-
int i_10_ = z * arg2 - i * arg1 >> 16;
757-
int i_11_ = diagonal2DAboveOrigin * arg1 >> 16;
763+
int i_10_ = z * pitchCosine - i * pitchSine >> 16;
764+
int i_11_ = diagonal2DAboveOrigin * pitchSine >> 16;
758765
int i_12_ = i_10_ + i_11_ << 9;
759766
if(i_12_ / i_6_ <= Rasterizer3D.anInt2935) {
760767
return;
761768
}
762-
int i_13_ = i_11_ + (modelHeight * arg2 >> 16);
769+
int i_13_ = i_11_ + (modelHeight * pitchCosine >> 16);
763770
int i_14_ = i_10_ - i_13_ << 9;
764771
if(i_14_ / i_6_ >= Rasterizer3D.anInt2941) {
765772
return;
766773
}
767-
int i_15_ = i_5_ + (modelHeight * arg1 >> 16);
774+
int i_15_ = i_5_ + (modelHeight * pitchSine >> 16);
768775
boolean bool = false;
769776
boolean bool_16_ = false;
770777
if(i_4_ - i_15_ <= 50)
@@ -818,11 +825,11 @@ public void renderAtPoint(int arg0, int arg1, int arg2, int arg3, int arg4, int
818825
i_27_ += x;
819826
i_28_ += z;
820827
i_29_ += y;
821-
int i_31_ = i_29_ * arg3 + i_27_ * arg4 >> 16;
822-
i_29_ = i_29_ * arg4 - i_27_ * arg3 >> 16;
828+
int i_31_ = i_29_ * yawSine + i_27_ * yawCosine >> 16;
829+
i_29_ = i_29_ * yawCosine - i_27_ * yawSine >> 16;
823830
i_27_ = i_31_;
824-
i_31_ = i_28_ * arg2 - i_29_ * arg1 >> 16;
825-
i_29_ = i_28_ * arg1 + i_29_ * arg2 >> 16;
831+
i_31_ = i_28_ * pitchCosine - i_29_ * pitchSine >> 16;
832+
i_29_ = i_28_ * pitchSine + i_29_ * pitchCosine >> 16;
826833
i_28_ = i_31_;
827834
vertexScreenZ[i_26_] = i_29_ - i_4_;
828835
if(i_29_ >= 50) {

src/main/java/org/runejs/client/media/renderable/Renderable.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
package org.runejs.client.media.renderable;
22

33
import org.runejs.client.node.CachedNode;
4+
import org.runejs.client.scene.camera.CameraRotation;
45

56
public abstract class Renderable extends CachedNode {
67
public int modelHeight = 1000;
78

8-
public void renderAtPoint(int arg0, int arg1, int arg2, int arg3, int arg4, int x, int z, int y, int arg8) {
9+
public void renderAtPoint(int arg0, CameraRotation cameraRotation, int x, int z, int y, int arg8) {
910
Model class40_sub5_sub17_sub5 = getRotatedModel();
1011
if(class40_sub5_sub17_sub5 != null) {
1112
modelHeight = class40_sub5_sub17_sub5.modelHeight;
12-
class40_sub5_sub17_sub5.renderAtPoint(arg0, arg1, arg2, arg3, arg4, x, z, y, arg8);
13+
class40_sub5_sub17_sub5.renderAtPoint(arg0, cameraRotation, x, z, y, arg8);
1314
}
1415
}
1516

0 commit comments

Comments
 (0)