This commit is contained in:
blueloveTH 2024-01-11 13:21:44 +08:00
parent d06a146fb2
commit 8e41139616
2 changed files with 5 additions and 3 deletions

View File

@ -112,8 +112,8 @@ static Vec2 SmoothDamp(Vec2 current, Vec2 target, PyVec2& currentVelocity, float
// @staticmethod // @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){ 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]); Vec2 current = CAST(Vec2, args[0]);
PyVec2 target = CAST(PyVec2, args[1]); Vec2 target = CAST(Vec2, args[1]);
PyVec2& current_velocity = CAST(PyVec2&, args[2]); PyVec2& current_velocity = CAST(PyVec2&, args[2]);
float smooth_time = CAST_F(args[3]); float smooth_time = CAST_F(args[3]);
float max_speed = CAST_F(args[4]); float max_speed = CAST_F(args[4]);

View File

@ -41,8 +41,10 @@ test_vec2_copy = rotated_vec2(test_vec2_copy, radians)
assert test_vec2.rotate(radians).__dict__ == test_vec2_copy.__dict__ assert test_vec2.rotate(radians).__dict__ == test_vec2_copy.__dict__
# test smooth_damp # 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 isinstance(ret, vec2)
assert vel.length() > 0
# test vec3-------------------------------------------------------------------- # test vec3--------------------------------------------------------------------
# 生成随机测试目标 # 生成随机测试目标