File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
gdnative-core/src/core_types Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ pub trait Vector2Godot {
30
30
/// This method runs faster than distance_to, so prefer it if you need to compare vectors or
31
31
/// need the squared distance for some formula.
32
32
fn distance_squared_to ( self , other : Vector2 ) -> f32 ;
33
+ /// Returns the vector with a maximum length by limiting its length to `length`.
34
+ fn clamped ( self , length : f32 ) -> Self ;
33
35
/// Internal API for converting to `sys` representation. Makes it possible to remove
34
36
/// `transmute`s elsewhere.
35
37
#[ doc( hidden) ]
@@ -125,6 +127,11 @@ impl Vector2Godot for Vector2 {
125
127
( other - self ) . square_length ( )
126
128
}
127
129
130
+ #[ inline]
131
+ fn clamped ( self , length : f32 ) -> Self {
132
+ self . clamp_length ( 0.0 , length)
133
+ }
134
+
128
135
#[ inline]
129
136
fn to_sys ( self ) -> sys:: godot_vector2 {
130
137
unsafe { std:: mem:: transmute ( self ) }
You can’t perform that action at this time.
0 commit comments