From 6eb05b27ab4b42dccc85f2b99828a91c351e8949 Mon Sep 17 00:00:00 2001 From: Roz K Date: Tue, 20 Dec 2022 15:39:38 +0100 Subject: [PATCH] Bump engine submodule and use new math functions. --- engine | 2 +- game/game.py | 51 ++++++++++++++++++++++++++++----------------------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/engine b/engine index abf1e87..ccce6c5 160000 --- a/engine +++ b/engine @@ -1 +1 @@ -Subproject commit abf1e87a3677cc01543f295df588cfa5c54db4e4 +Subproject commit ccce6c5d83deb260d06bc525721e31c7c4edcabe diff --git a/game/game.py b/game/game.py index ff4c63b..b917848 100644 --- a/game/game.py +++ b/game/game.py @@ -148,9 +148,10 @@ def main(): tests_environment_inputs = environment.resolve_inputs(tests_shader) sky_environment_inputs = environment.resolve_inputs(sky_shader) - _rotation = mat3() - _origin = vec3() - _lookat = vec3() + blob_translation = tests_batch.params[blob_id].translation + cube_translation = tests_batch.params[cube_id].translation + cube_orientation = tests_batch.params[cube_id].orientation + clouds_orientation = tests_batch.params[clouds_id].orientation print("Running...") start_time = time.monotonic() @@ -169,18 +170,19 @@ def main(): begin_frame() frame_begin = time.thread_time() - mat3_rotation(_rotation, vec3_up, (current_time * 0.21) % tau) - mat3_mul_vec3(tests_batch.params[blob_id].translation, _rotation, blob_spawn_translation) - mat3_mul_vec3(tests_batch.params[cube_id].translation, _rotation, cube_spawn_translation) - mat3_rotation(_rotation, vec3_up, (current_time * 0.43) % tau) - mat3_mul_vec3(tests_batch.params[cube_id].orientation, _rotation, vec3_forward) - mat3_rotation(_rotation, vec3_up, (current_time * -0.037) % tau) - mat3_mul_vec3(tests_batch.params[clouds_id].orientation, _rotation, vec3_forward) + rotation = mat3() + mat3_rotation(rotation, vec3_up, (current_time * 0.21) % tau) + mat3_mul_vec3(blob_translation, rotation, blob_spawn_translation) + mat3_mul_vec3(cube_translation, rotation, cube_spawn_translation) + vec3_rotate(cube_orientation, vec3_forward, vec3_up, (current_time * 0.43) % tau) + vec3_rotate(clouds_orientation, vec3_forward, vec3_up, (current_time * -0.037) % tau) - mat3_rotation(_rotation, vec3_up, (current_time * 0.05) % tau) - mat3_mul_vec3(_origin, _rotation, vec3(*camera_origin)) - mat3_mul_vec3(_lookat, _rotation, vec3(*camera_lookat)) - camera.set_view(_origin, _lookat) + origin = vec3() + lookat = vec3() + mat3_rotation(rotation, vec3_up, (current_time * 0.05) % tau) + mat3_mul_vec3(origin, rotation, vec3(*camera_origin)) + mat3_mul_vec3(lookat, rotation, vec3(*camera_lookat)) + camera.set_view(origin, lookat) environment.from_sun(camera.view, sun_direction, sun_power) select_shader(terrain_shader) @@ -213,9 +215,12 @@ def main(): unselect_texture(2, normalmap) unselect_shader(tests_shader) - camera.set_view( - vec3(_origin.x * 0.001, _origin.y * 0.001, _origin.z * 0.001), - vec3(_lookat.x * 0.001, _lookat.y * 0.001, _lookat.z * 0.001)) + m2km = vec3(0.001, 0.001, 0.001) + origin_km = vec3() + lookat_km = vec3() + vec3_mul_vec3(origin_km, origin, m2km) + vec3_mul_vec3(lookat_km, lookat, m2km) + camera.set_view(origin_km, lookat_km) select_shader(sky_shader) camera.update_inputs(sky_camera_inputs) @@ -260,13 +265,13 @@ def main(): # for x in range(10000) # current_time = 0 - # Draw * 9999 : min = 0.21 , max = 2.16 , avg = 0.27 ms - # Draw * 9999 : min = 0.20 , max = 1.96 , avg = 0.27 ms - # Draw * 9999 : min = 0.20 , max = 2.43 , avg = 0.27 ms + # Draw * 9999 : min = 0.2 , max = 2.31 , avg = 0.27 ms + # Draw * 9999 : min = 0.2 , max = 2.41 , avg = 0.27 ms + # Draw * 9999 : min = 0.2 , max = 2.73 , avg = 0.27 ms - # Frame * 9999 : min = 0.27 , max = 2.29 , avg = 0.38 ms - # Frame * 9999 : min = 0.26 , max = 2.08 , avg = 0.37 ms - # Frame * 9999 : min = 0.26 , max = 2.59 , avg = 0.38 ms + # Frame * 9999 : min = 0.26 , max = 2.44 , avg = 0.38 ms + # Frame * 9999 : min = 0.26 , max = 2.54 , avg = 0.37 ms + # Frame * 9999 : min = 0.26 , max = 2.90 , avg = 0.38 ms print("Quitting...") del tests_batch