aboutsummaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
authorJuan Linietsky2014-09-02 23:13:40 -0300
committerJuan Linietsky2014-09-02 23:13:40 -0300
commit1a2cb755e2d8b9d59178f36702f6dff7235b9088 (patch)
tree4a88f47c8b984522e36ac973accb34bdcb00363b /core/math
parent89fa70706f9166765c3ac3f799225a467800f065 (diff)
downloadgodot-1a2cb755e2d8b9d59178f36702f6dff7235b9088.tar.gz
godot-1a2cb755e2d8b9d59178f36702f6dff7235b9088.tar.zst
godot-1a2cb755e2d8b9d59178f36702f6dff7235b9088.zip
3D Physics and Other Stuff
-=-=-=-=-=-=-=-=-=-=-=-=-= -New Vehicle (Based on Bullet's RaycastVehicle) - Vehiclebody/VehicleWheel. Demo will come soon, old vehicle (CarBody) will go away soon too. -A lot of fixes to the 3D physics engine -Added KinematicBody with demo -Fixed the space query API for 2D (demo will come soon). 3D is WIP. -Fixed long-standing bug with body_enter/body_exit for Area and Area2D -Performance variables now includes physics (active bodies, collision pairs and islands) -Ability to see what's inside of instanced scenes! -Fixed Blend Shapes (no bs+skeleton yet) -Added an Android JavaClassWrapper singleton for using Android native classes directly from GDScript. This is very Alpha!
Diffstat (limited to 'core/math')
-rw-r--r--core/math/vector3.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/core/math/vector3.h b/core/math/vector3.h
index 959f7cd0a..d2f240882 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -111,6 +111,12 @@ struct Vector3 {
_FORCE_INLINE_ real_t distance_to(const Vector3& p_b) const;
_FORCE_INLINE_ real_t distance_squared_to(const Vector3& p_b) const;
+
+
+ _FORCE_INLINE_ Vector3 slide(const Vector3& p_vec) const;
+ _FORCE_INLINE_ Vector3 reflect(const Vector3& p_vec) const;
+
+
/* Operators */
_FORCE_INLINE_ Vector3& operator+=(const Vector3& p_v);
@@ -368,6 +374,16 @@ void Vector3::zero() {
x=y=z=0;
}
+Vector3 Vector3::slide(const Vector3& p_vec) const {
+
+ return p_vec - *this * this->dot(p_vec);
+}
+Vector3 Vector3::reflect(const Vector3& p_vec) const {
+
+ return p_vec - *this * this->dot(p_vec) * 2.0;
+
+}
+
#endif
#endif // VECTOR3_H