Closed semihbkgr closed 2 months ago
Thanks for the report, that definitely sounds wrong. I think I can see what the problem is in the implementation, I'll look at fixing that soon.
I've sent a draft PR for the f32 Vec2 method. If it looks good, I can update the other methods afterward.
Looking into this some more, I think part of the issue is negative values probably shouldn't be allowed with this function. Basically vector length cannot be less than zero, the clamp
function makes sure then length is no less than the given min
, but the doesn't really make sense if min
(or max
for that matter are negative. What should probably happen here is that the docs should say that min and max must be positive and we could add some glam_assets
to check the inputs.
I agree. It's much better
@bitshifter length shouldn't be zero either, else we'd be dividing by zero which results in NaN values, should prob add check for that in clamp_length & clamp_length_min
The
clamp_length
method in theVec2
incorrectly alters the vector components when the vector's length is within the specifiedmin
andmax
range. This behavior deviates from the expected functionality where the vector should remain unchanged if its length falls within the specified bounds.While it is possible that this behavior is intentional in the current implementation, it seems counterintuitive for the method to alter the vector when its length is already within the specified range. Clarification on whether this is the expected behavior would be appreciated.