blueloveTH 2 lat temu
rodzic
commit
8e41139616
2 zmienionych plików z 5 dodań i 3 usunięć
  1. 2 2
      src/linalg.cpp
  2. 3 1
      tests/80_linalg.py

+ 2 - 2
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]);

+ 3 - 1
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--------------------------------------------------------------------
 # 生成随机测试目标