From d7d65fa2f2b51d03f7bdfcbceedca99188ce979c Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Wed, 19 Feb 2014 11:57:14 -0300 Subject: -improved physics ccd -html5 exporter works again -disable repeat on image loader by default -can change shape offset en tileset, texture offset was broken --- core/math/math_2d.cpp | 10 ++++++++++ core/math/math_2d.h | 2 ++ 2 files changed, 12 insertions(+) (limited to 'core/math') diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp index dbeaea6e75..acaaa327f3 100644 --- a/core/math/math_2d.cpp +++ b/core/math/math_2d.cpp @@ -255,6 +255,16 @@ Vector2 Vector2::cubic_interpolate(const Vector2& p_b,const Vector2& p_pre_a, co } +Vector2 Vector2::slide(const Vector2& p_vec) const { + + return p_vec - *this * this->dot(p_vec); +} +Vector2 Vector2::reflect(const Vector2& p_vec) const { + + return p_vec - *this * this->dot(p_vec) * 2.0; + +} + bool Rect2::intersects_segment(const Point2& p_from, const Point2& p_to, Point2* r_pos,Point2* r_normal) const { diff --git a/core/math/math_2d.h b/core/math/math_2d.h index 212d848bcb..1f45036409 100644 --- a/core/math/math_2d.h +++ b/core/math/math_2d.h @@ -105,6 +105,8 @@ struct Vector2 { Vector2 cubic_interpolate(const Vector2& p_b,const Vector2& p_pre_a, const Vector2& p_post_b,float p_t) const; Vector2 cubic_interpolate_soft(const Vector2& p_b,const Vector2& p_pre_a, const Vector2& p_post_b,float p_t) const; + Vector2 slide(const Vector2& p_vec) const; + Vector2 reflect(const Vector2& p_vec) const; Vector2 operator+(const Vector2& p_v) const; void operator+=(const Vector2& p_v); -- cgit v1.2.3