Skip to content
Snippets Groups Projects
Commit de52447e authored by Florian Schröder's avatar Florian Schröder
Browse files

Add player position to view restriction and implement angle calculation

Player's position has been added to the view restriction in order to provide a more precise representation of the environment. A function for calculating the angle between two points has been implemented in the utils module. Changes have also been made to accommodate these new updates in the 2D visualization module.
parent e6452150
No related branches found
No related tags found
1 merge request!42Resolve "FOV of the players, fog-of-war like vision"
Pipeline #45171 passed
......@@ -92,8 +92,10 @@ class Visualizer:
)
if "view_restriction" in state and state["view_restriction"]:
direction = state["view_restriction"][0]
angel = state["view_restriction"][1]
direction = np.array(state["view_restriction"][0])
pos = np.array(state["view_restriction"][1])
angel = state["view_restriction"][2]
# rotate direction vector in both direction with the angel
# draw 2 large rect which are rotated so that one edge is the viewing border
......
......@@ -622,6 +622,7 @@ class Environment:
).total_seconds(),
"view_restriction": [
self.players[player_id].facing_direction.tolist(),
self.players[player_id].pos.tolist(),
40.0,
]
if FOG_OF_WAR
......
......@@ -100,3 +100,9 @@ def add_list_of_manager_ids_arguments(parser):
default=[uuid.uuid4().hex],
help="List of manager IDs that can create environments.",
)
def angle_between(p1, p2):
ang1 = np.arctan2(*p1[::-1])
ang2 = np.arctan2(*p2[::-1])
return np.rad2deg((ang1 - ang2) % (2 * np.pi))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment