Skip to content

Commit bd20d8f

Browse files
committed
godot-core: src: builtin: changed Plane function to be more accurate in respect to their Godot equivalent
1 parent 43ce5c5 commit bd20d8f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

godot-core/src/builtin/plane.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,20 @@ impl Plane {
214214
self.normal.dot(point) > self.d
215215
}
216216

217-
/// Returns a normalized copy of the plane.
217+
/// Returns a copy of the plane with its `normal` and `d` scaled to the unit length.
218+
///
219+
/// A `normal` length of `0.0` would return a plane with its `normal` and `d` being `Vector3::ZERO`
220+
/// and `0.0` respectively.
218221
#[inline]
219222
pub fn normalized(self) -> Self {
220-
Plane::new(self.normal.normalized(), self.d)
223+
let length: real = self.normal.length();
224+
if length == 0.0 {
225+
return Plane {
226+
normal: Vector3::ZERO,
227+
d: 0.0,
228+
};
229+
}
230+
Plane::new(self.normal.normalized(), self.d / length)
221231
}
222232

223233
/// Returns the orthogonal projection of `point` to the plane.

0 commit comments

Comments
 (0)