Skip to content

Commit 920782c

Browse files
committed
Small update to raytracing
Mouse is free when camera movement is set to false
1 parent 230573a commit 920782c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

raytracing.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88

99
# Global Variables
1010
NUM_CPU_CORES = multiprocessing.cpu_count() - 1
11-
MAX_BOUNCES = 3
11+
MAX_BOUNCES = 6
1212
focal_length = 800.0
1313
WINDOW_HEIGHT = 600
1414
WINDOW_WIDTH = int(WINDOW_HEIGHT * 1.5)
1515
RENDER_HEIGHT = 150
1616
RENDER_WIDTH = int(RENDER_HEIGHT * 1.5)
17+
18+
1719
cam_pos = np.array([150, 97, -800], dtype=np.float32)
1820
cam_yaw = 0.0
1921
cam_pitch = 0.0
@@ -218,7 +220,15 @@ def render_full(cam_pos, cam_yaw, cam_pitch, add_jitter=False):
218220
running = False
219221
elif event.key == pygame.K_SPACE:
220222
camera_movement_enabled = not camera_movement_enabled
221-
223+
224+
# Update mouse visibility and grab state based on camera_movement_enabled
225+
if camera_movement_enabled:
226+
pygame.mouse.set_visible(False)
227+
pygame.event.set_grab(True)
228+
else:
229+
pygame.mouse.set_visible(True)
230+
pygame.event.set_grab(False)
231+
222232
# Camera Rotation and Movement
223233
mouse_dx, mouse_dy = pygame.mouse.get_rel()
224234
if camera_movement_enabled:

0 commit comments

Comments
 (0)