Visibility
This module contains functions for calculating visibility in Counter-Strike 2 demos.
awpy.visibility
Module for calculating visibility.
Reference: https://github.com/AtomicBool/cs2-map-parser
- class awpy.visibility.AABB(min_point: Vector3, max_point: Vector3)[source]
Bases:
objectAxis-Aligned Bounding Box for efficient collision detection.
- classmethod from_triangle(triangle: Triangle) AABB[source]
Create an AABB from a triangle.
- Parameters:
triangle (Triangle) – Triangle to create the AABB from.
- Returns:
Axis-Aligned Bounding Box encompassing the triangle.
- Return type:
- intersects_ray(ray_origin: Vector3, ray_direction: Vector3) bool[source]
Check if a ray intersects with the AABB.
- Parameters:
ray_origin (awpy.vector.Vector3) – Ray origin point.
ray_direction (awpy.vector.Vector3) – Ray direction vector.
- Returns:
True if the ray intersects with the AABB, False otherwise.
- Return type:
bool
- class awpy.visibility.BVHNode(aabb: AABB, triangle: Triangle | None = None, left: BVHNode | None = None, right: BVHNode | None = None)[source]
Bases:
objectNode in the Bounding Volume Hierarchy tree.
- class awpy.visibility.KV3Parser[source]
Bases:
objectParser for KV3 format files used in Source 2 engine.
This class provides functionality to parse KV3 files, which are used to store various game data including physics collision meshes.
- content
Raw content of the KV3 file.
- index
Current parsing position in the content.
- parsed_data
Resulting parsed data structure.
- class awpy.visibility.VisibilityChecker(path: Path | None = None, triangles: list[Triangle] | None = None)[source]
Bases:
objectClass for visibility checking in 3D space using a BVH structure.
- is_visible(start: Vector3 | tuple | list, end: Vector3 | tuple | list) bool[source]
Check if a line segment is visible in the 3D space.
- Parameters:
start (awpy.vector.Vector3 | tuple | list) – Start point of the line segment.
end (awpy.vector.Vector3 | tuple | list) – End point of the line segment.
- Returns:
True if the line segment is visible, False otherwise.
- Return type:
bool
- class awpy.visibility.VphysParser(vphys_file: str | Path)[source]
Bases:
objectParser for VPhys collision files.
- This class extracts and processes collision geometry data
from VPhys files, converting it into a set of triangles.
- vphys_file
Path to the VPhys file.
- Type:
Path
- triangles
List of parsed triangles from the VPhys file.
- Type:
list[Triangle]
- static bytes_to_vec(byte_str: str, element_type: Literal['uint8', 'int32']) list[int][source]
- static bytes_to_vec(byte_str: str, element_type: Literal['float']) list[float]
Converts a space-separated string of byte values into a list of numbers.
- Parameters:
byte_str (str) – Space-separated string of hexadecimal byte values.
element_type (int) – Types represented by the bytes (uint8, int32, float).
- Returns:
- List of converted values (integers for
uint8, floats for size 4).
- Return type:
list[int | float]
- get_collision_attribute_indices_for_default_group() list[str][source]
Get collision attribute indices for the default group.
- Returns:
List of collision attribute indices for the default group.
- Return type:
list[int]