diff --git a/src/linalg.cpp b/src/linalg.cpp index 897165f2..8c937dee 100644 --- a/src/linalg.cpp +++ b/src/linalg.cpp @@ -112,8 +112,8 @@ static Vec2 SmoothDamp(Vec2 current, Vec2 target, PyVec2& currentVelocity, float // @staticmethod vm->bind(type, "smooth_damp(current: vec2, target: vec2, current_velocity: vec2, smooth_time: float, max_speed: float, delta_time: float) -> vec2", [](VM* vm, ArgsView args){ - PyVec2 current = CAST(PyVec2, args[0]); - PyVec2 target = CAST(PyVec2, args[1]); + Vec2 current = CAST(Vec2, args[0]); + Vec2 target = CAST(Vec2, args[1]); PyVec2& current_velocity = CAST(PyVec2&, args[2]); float smooth_time = CAST_F(args[3]); float max_speed = CAST_F(args[4]); diff --git a/tests/80_linalg.py b/tests/80_linalg.py index b9781aab..f3b6c4ff 100644 --- a/tests/80_linalg.py +++ b/tests/80_linalg.py @@ -41,8 +41,10 @@ test_vec2_copy = rotated_vec2(test_vec2_copy, radians) assert test_vec2.rotate(radians).__dict__ == test_vec2_copy.__dict__ # test smooth_damp -ret = vec2.smooth_damp(vec2(1, 2), vec2(3, 4), vec2(5, 6), 7, 8, 9) +vel = vec2(0, 0) +ret = vec2.smooth_damp(vec2(1, 2), vec2(3, 4), vel, 7, 8, 9) assert isinstance(ret, vec2) +assert vel.length() > 0 # test vec3-------------------------------------------------------------------- # 生成随机测试目标