@@ -146,10 +146,7 @@ public void computeTileVisibilityMaps(int minHeight, int maxHeight, int width, i
146
146
for (int pitch = 128 ; pitch <= 384 ; pitch += 32 ) {
147
147
// Iterating over different camera yaw angles (from 0 to 2048)
148
148
for (int yaw = 0 ; yaw < 2048 ; yaw += 64 ) {
149
- currentPitchSine = Model .SINE [pitch ];
150
- currentPitchCosine = Model .COSINE [pitch ];
151
- currentYawSine = Model .SINE [yaw ];
152
- currentYawCosine = Model .COSINE [yaw ];
149
+ CameraRotation camera = new CameraRotation (yaw , pitch );
153
150
154
151
int pitchIndex = (pitch - 128 ) / 32 ;
155
152
int yawIndex = yaw / 64 ;
@@ -163,7 +160,7 @@ public void computeTileVisibilityMaps(int minHeight, int maxHeight, int width, i
163
160
164
161
// Checking visibility at different heights
165
162
for (int h = -minHeight ; h <= maxHeight ; h += 128 ) {
166
- if (isPointVisibleOnScreen (absoluteTileX , arg0 [pitchIndex ] + h , absoluteTileY )) {
163
+ if (isPointVisibleOnScreen (absoluteTileX , arg0 [pitchIndex ] + h , absoluteTileY , camera )) {
167
164
isVisible = true ;
168
165
break ;
169
166
}
@@ -234,14 +231,14 @@ public static int adjustLightness(int hsl, int lightness) {
234
231
* @param z The z-coordinate of the point in 3D space.
235
232
* @return Returns true if the projected point falls within the screen boundaries; otherwise false.
236
233
*/
237
- public boolean isPointVisibleOnScreen (int x , int y , int z ) {
234
+ public boolean isPointVisibleOnScreen (int x , int y , int z , CameraRotation cameraRotation ) {
238
235
// Rotate around the X axis
239
- int rotatedX = z * currentYawSine + x * currentYawCosine >> 16 ;
240
- int rotatedZ = z * currentYawCosine - x * currentYawSine >> 16 ;
236
+ int rotatedX = z * cameraRotation . yawSine + x * cameraRotation . yawCosine >> 16 ;
237
+ int rotatedZ = z * cameraRotation . yawCosine - x * cameraRotation . yawSine >> 16 ;
241
238
242
239
// Rotate around the Y axis
243
- int rotatedY = y * currentPitchSine + rotatedZ * currentPitchCosine >> 16 ;
244
- int finalZ = y * currentPitchCosine - rotatedZ * currentPitchSine >> 16 ;
240
+ int rotatedY = y * cameraRotation . pitchSine + rotatedZ * cameraRotation . pitchCosine >> 16 ;
241
+ int finalZ = y * cameraRotation . pitchCosine - rotatedZ * cameraRotation . pitchSine >> 16 ;
245
242
246
243
// Check if the point is behind the near clipping plane (too close to the camera)
247
244
if (rotatedY < 50 /* || rotatedY > 3500*/ ) {
0 commit comments