From 793fe57e7d861562f67fb21062f2987127530a30 Mon Sep 17 00:00:00 2001 From: annieisawesome2 Date: Thu, 25 Jun 2026 22:05:23 -0700 Subject: [PATCH 1/2] Fix mirrored ball kick velocity on inverted fullsystem tab --- .../thunderscope/gl/layers/gl_world_layer.py | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/software/thunderscope/gl/layers/gl_world_layer.py b/src/software/thunderscope/gl/layers/gl_world_layer.py index aed25404fd..ecd6debb48 100644 --- a/src/software/thunderscope/gl/layers/gl_world_layer.py +++ b/src/software/thunderscope/gl/layers/gl_world_layer.py @@ -291,8 +291,9 @@ def mouse_in_scene_released(self, event: MouseInSceneEvent) -> None: if not self.point_in_scene_picked or not self.ball_velocity_vector: return + ball_velocity = self.ball_velocity_vector if self._should_invert_coordinate_frame(): - self.ball_velocity_vector = -self.ball_velocity_vector + ball_velocity = -ball_velocity # Send a command to the simulator to give the ball the specified # velocity (i.e. kick it) @@ -305,8 +306,8 @@ def mouse_in_scene_released(self, event: MouseInSceneEvent) -> None: y_meters=self.point_in_scene_picked.y(), ), global_velocity=Vector( - x_component_meters=self.ball_velocity_vector.x(), - y_component_meters=self.ball_velocity_vector.y(), + x_component_meters=ball_velocity.x(), + y_component_meters=ball_velocity.y(), ), ) ) @@ -681,7 +682,9 @@ def __update_speed_line_graphics(self) -> None: # as a speed line if self.ball_velocity_vector: ball_state = self.cached_world.ball.current_state - velocity = self.ball_velocity_vector * SPEED_SEGMENT_SCALE + velocity = self._invert_vector_if_defending_negative_half( + self.ball_velocity_vector * SPEED_SEGMENT_SCALE + ) self.ball_kick_velocity_graphic.show() self.ball_kick_velocity_graphic.set_points( @@ -758,3 +761,15 @@ def _invert_position_if_defending_negative_half( if self._should_invert_coordinate_frame(): return QtGui.QVector3D(-point[0], -point[1], point[2]) return point + + def _invert_vector_if_defending_negative_half( + self, vector: QtGui.QVector3D + ) -> QtGui.QVector3D: + """Convert a simulator-space vector to display-space for rendering. + + :param vector: The vector in simulator coordinates + :return: The vector in display coordinates (if needed to be inverted) + """ + if self._should_invert_coordinate_frame(): + return QtGui.QVector3D(-vector.x(), -vector.y(), vector.z()) + return vector From 8efad53c9dc9f6866bdfbfecd29f9007b47981f3 Mon Sep 17 00:00:00 2001 From: annieisawesome2 Date: Sat, 4 Jul 2026 07:40:21 -0700 Subject: [PATCH 2/2] velocity in direction of magnitude of mouse drag --- .../thunderscope/gl/layers/gl_world_layer.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/software/thunderscope/gl/layers/gl_world_layer.py b/src/software/thunderscope/gl/layers/gl_world_layer.py index ecd6debb48..b36a89a06a 100644 --- a/src/software/thunderscope/gl/layers/gl_world_layer.py +++ b/src/software/thunderscope/gl/layers/gl_world_layer.py @@ -265,13 +265,10 @@ def mouse_in_scene_dragged(self, event: MouseInSceneEvent) -> None: if not self.point_in_scene_picked: return - # User picked a point in the 3D scene and is now dragging it across the scene - # to apply a velocity on the ball (i.e. kick it). - # We create a velocity vector that is proportional to the distance the - # mouse has moved away from the ball. + # Velocity is in the direction and magnitude of the mouse drag. self.ball_velocity_vector = ( - self.point_in_scene_picked - - self._invert_position_if_defending_negative_half(event.point_in_scene) + self._invert_position_if_defending_negative_half(event.point_in_scene) + - self.point_in_scene_picked ) # Cap the maximum kick speed @@ -291,10 +288,6 @@ def mouse_in_scene_released(self, event: MouseInSceneEvent) -> None: if not self.point_in_scene_picked or not self.ball_velocity_vector: return - ball_velocity = self.ball_velocity_vector - if self._should_invert_coordinate_frame(): - ball_velocity = -ball_velocity - # Send a command to the simulator to give the ball the specified # velocity (i.e. kick it) @@ -306,8 +299,8 @@ def mouse_in_scene_released(self, event: MouseInSceneEvent) -> None: y_meters=self.point_in_scene_picked.y(), ), global_velocity=Vector( - x_component_meters=ball_velocity.x(), - y_component_meters=ball_velocity.y(), + x_component_meters=self.ball_velocity_vector.x(), + y_component_meters=self.ball_velocity_vector.y(), ), ) )