Skip to content

Commit f98b9aa

Browse files
committed
Add missing functions to Python extension and bootstrap process
1 parent d240f60 commit f98b9aa

File tree

2 files changed

+45
-6
lines changed

2 files changed

+45
-6
lines changed

python/arcade_accelerate/__init__.py

+29
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,38 @@ def patch_spritelist_collision(patches):
3434

3535
def patch_math(patches):
3636
patches["arcade.math"].rotate_point = arcade_accelerate.rotate_point
37+
patches["arcade.math"].clamp = arcade_accelerate.clamp
38+
patches["arcade.math"].lerp = arcade_accelerate.lerp
39+
patches["arcade.math"].lerp_vec = arcade_accelerate.lerp_vec
40+
patches["arcade.math"].lerp_angle = arcade_accelerate.lerp_angle
41+
patches["arcade.math"].get_distance = arcade_accelerate.get_distance
42+
patches["arcade.math"].get_angle_degrees = arcade_accelerate.get_angle_degrees
43+
patches["arcade.math"].get_angle_radians = arcade_accelerate.get_angle_radians
44+
patches["arcade.math"].rand_in_rect = arcade_accelerate.rand_in_rect
45+
patches["arcade.math"].rand_in_circle = arcade_accelerate.rand_in_circle
46+
patches["arcade.math"].rand_on_circle = arcade_accelerate.rand_on_circle
47+
patches["arcade.math"].rand_on_line = arcade_accelerate.rand_on_line
48+
patches["arcade.math"].rand_angle_360_deg = arcade_accelerate.rand_angle_360_deg
49+
patches["arcade.math"].rand_angle_spread_deg = (
50+
arcade_accelerate.rand_angle_spread_deg
51+
)
52+
patches["arcade.math"].rand_vec_degree_spread = (
53+
arcade_accelerate.rand_vec_degree_spread
54+
)
55+
patches["arcade.math"].rand_vec_magnitude = arcade_accelerate.rand_vec_magnitude
3756

3857

3958
def patch_geometry(patches):
4059
patches["arcade.geometry"].are_polygons_intersecting = (
4160
arcade_accelerate.are_polygons_intersecting
4261
)
62+
patches["arcade.geometry"].is_point_in_box = arcade_accelerate.is_point_in_box
63+
patches["arcade.geometry"].get_triangle_orientation = (
64+
arcade_accelerate.get_triangle_orientation
65+
)
66+
patches["arcade.geometry"].are_lines_intersecting = (
67+
arcade_accelerate.are_lines_intersecting
68+
)
69+
patches["arcade.geometry"].is_point_in_polygon = (
70+
arcade_accelerate.is_point_in_polygon
71+
)

src/lib.rs

+16-6
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ pub use sprite_list::*;
1515
/// A Python module implemented in Rust.
1616
#[pymodule]
1717
fn arcade_accelerate(_py: Python, m: &PyModule) -> PyResult<()> {
18-
m.add_class::<HitBox>()?;
19-
m.add_class::<RotatableHitBox>()?;
18+
m.add_class::<hitbox::HitBox>()?;
19+
m.add_class::<hitbox::RotatableHitBox>()?;
2020
m.add_function(wrap_pyfunction!(math::rotate_point, m)?)?;
2121
m.add_function(wrap_pyfunction!(math::clamp, m)?)?;
2222
m.add_function(wrap_pyfunction!(math::lerp, m)?)?;
@@ -33,9 +33,19 @@ fn arcade_accelerate(_py: Python, m: &PyModule) -> PyResult<()> {
3333
m.add_function(wrap_pyfunction!(math::rand_angle_spread_deg, m)?)?;
3434
m.add_function(wrap_pyfunction!(math::rand_vec_degree_spread, m)?)?;
3535
m.add_function(wrap_pyfunction!(math::rand_vec_magnitude, m)?)?;
36-
m.add_function(wrap_pyfunction!(are_polygons_intersecting, m)?)?;
37-
m.add_function(wrap_pyfunction!(check_for_collision_with_list, m)?)?;
38-
m.add_function(wrap_pyfunction!(check_for_collision_with_lists, m)?)?;
39-
m.add_function(wrap_pyfunction!(is_point_in_polygon, m)?)?;
36+
m.add_function(wrap_pyfunction!(geometry::are_polygons_intersecting, m)?)?;
37+
m.add_function(wrap_pyfunction!(geometry::is_point_in_polygon, m)?)?;
38+
m.add_function(wrap_pyfunction!(geometry::is_point_in_box, m)?)?;
39+
m.add_function(wrap_pyfunction!(geometry::get_triangle_orientation, m)?)?;
40+
m.add_function(wrap_pyfunction!(geometry::are_lines_intersecting, m)?)?;
41+
m.add_function(wrap_pyfunction!(
42+
sprite_list::check_for_collision_with_list,
43+
m
44+
)?)?;
45+
m.add_function(wrap_pyfunction!(
46+
sprite_list::check_for_collision_with_lists,
47+
m
48+
)?)?;
49+
4050
Ok(())
4151
}

0 commit comments

Comments
 (0)