diff --git a/docs/modules/linalg.md b/docs/modules/linalg.md index 6056ff10..a53fb378 100644 --- a/docs/modules/linalg.md +++ b/docs/modules/linalg.md @@ -47,7 +47,7 @@ class vec2(_StructLike['vec2']): """ @staticmethod - def smooth_damp(current: vec2, target: vec2, current_velocity_: vec2, smooth_time: float, max_speed: float, delta_time: float) -> vec2: + def smooth_damp(current: vec2, target: vec2, current_velocity: vec2, smooth_time: float, max_speed: float, delta_time: float) -> tuple[vec2, vec2]: ... class vec3(_StructLike['vec3']): diff --git a/include/typings/linalg.pyi b/include/typings/linalg.pyi index 3927adf0..79ff5f58 100644 --- a/include/typings/linalg.pyi +++ b/include/typings/linalg.pyi @@ -38,8 +38,11 @@ class vec2(_StructLike['vec2']): """ @staticmethod - def smooth_damp(current: vec2, target: vec2, current_velocity_: vec2, smooth_time: float, max_speed: float, delta_time: float) -> vec2: - ... + def smooth_damp(current: vec2, target: vec2, current_velocity: vec2, smooth_time: float, max_speed: float, delta_time: float) -> tuple[vec2, vec2]: + """Smoothly changes a vector towards a desired goal over time. + + Returns a new value that is closer to the target and current velocity. + """ class vec3(_StructLike['vec3']): x: float diff --git a/src/linalg.cpp b/src/linalg.cpp index e007e172..6dbab5d6 100644 --- a/src/linalg.cpp +++ b/src/linalg.cpp @@ -130,12 +130,12 @@ static Vec2 SmoothDamp(Vec2 current, Vec2 target, Vec2& currentVelocity, float s 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){ Vec2 current = CAST(Vec2, args[0]); Vec2 target = CAST(Vec2, args[1]); - Vec2& current_velocity_ = CAST(Vec2&, args[2]); + Vec2 current_velocity_ = CAST(Vec2, args[2]); float smooth_time = CAST_F(args[3]); float max_speed = CAST_F(args[4]); float delta_time = CAST_F(args[5]); Vec2 ret = SmoothDamp(current, target, current_velocity_, smooth_time, max_speed, delta_time); - return VAR(ret); + return VAR(Tuple(VAR(ret), VAR(current_velocity_))); }, {}, BindType::STATICMETHOD); // @staticmethod diff --git a/tests/80_linalg.py b/tests/80_linalg.py index 495fec29..1eaca454 100644 --- a/tests/80_linalg.py +++ b/tests/80_linalg.py @@ -42,7 +42,7 @@ assert test_vec2.rotate(radians) == test_vec2_copy # test smooth_damp vel = vec2(0, 0) -ret = vec2.smooth_damp(vec2(1, 2), vec2(3, 4), vel, 0.2, 0.001, 0.05) +ret, vel = vec2.smooth_damp(vec2(1, 2), vec2(3, 4), vel, 0.2, 0.001, 0.05) assert isinstance(ret, vec2) assert vel.length() > 0 @@ -463,14 +463,6 @@ assert mymat3x3().f() # test assign -a = vec2(1, 2) -assert a.copy_(vec2(3, 4)) is None -assert a == vec2(3, 4) - -b = vec3(1, 2, 3) -assert b.copy_(vec3(4, 5, 6)) is None -assert b == vec3(4, 5, 6) - c = vec4(1, 2, 3, 4) assert c.copy_(vec4(5, 6, 7, 8)) is None assert c == vec4(5, 6, 7, 8)