mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 12:00:18 +00:00
some fix
This commit is contained in:
parent
a09def4ec3
commit
e19c2ccf96
@ -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']):
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user