diff options
Diffstat (limited to 'core/math')
-rw-r--r-- | core/math/math_2d.cpp | 16 | ||||
-rw-r--r-- | core/math/math_2d.h | 32 | ||||
-rw-r--r-- | core/math/octree.h | 12 | ||||
-rw-r--r-- | core/math/plane.cpp | 4 | ||||
-rw-r--r-- | core/math/plane.h | 4 | ||||
-rw-r--r-- | core/math/rect3.h | 42 | ||||
-rw-r--r-- | core/math/vector3.h | 22 |
7 files changed, 66 insertions, 66 deletions
diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp index 52e240ed47..956cfe5258 100644 --- a/core/math/math_2d.cpp +++ b/core/math/math_2d.cpp @@ -281,22 +281,22 @@ Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, c } // slide returns the component of the vector along the given plane, specified by its normal vector. -Vector2 Vector2::slide(const Vector2 &p_n) const { +Vector2 Vector2::slide(const Vector2 &p_normal) const { #ifdef MATH_CHECKS - ERR_FAIL_COND_V(p_n.is_normalized() == false, Vector2()); + ERR_FAIL_COND_V(p_normal.is_normalized() == false, Vector2()); #endif - return *this - p_n * this->dot(p_n); + return *this - p_normal * this->dot(p_normal); } -Vector2 Vector2::bounce(const Vector2 &p_n) const { - return -reflect(p_n); +Vector2 Vector2::bounce(const Vector2 &p_normal) const { + return -reflect(p_normal); } -Vector2 Vector2::reflect(const Vector2 &p_n) const { +Vector2 Vector2::reflect(const Vector2 &p_normal) const { #ifdef MATH_CHECKS - ERR_FAIL_COND_V(p_n.is_normalized() == false, Vector2()); + ERR_FAIL_COND_V(p_normal.is_normalized() == false, Vector2()); #endif - return 2.0 * p_n * this->dot(p_n) - *this; + return 2.0 * p_normal * this->dot(p_normal) - *this; } 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 601ab91b9f..6fea6c8adb 100644 --- a/core/math/math_2d.h +++ b/core/math/math_2d.h @@ -115,9 +115,9 @@ struct Vector2 { Vector2 cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const; Vector2 cubic_interpolate_soft(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const; - Vector2 slide(const Vector2 &p_vec) const; - Vector2 bounce(const Vector2 &p_vec) const; - Vector2 reflect(const Vector2 &p_vec) const; + Vector2 slide(const Vector2 &p_normal) const; + Vector2 bounce(const Vector2 &p_normal) const; + Vector2 reflect(const Vector2 &p_normal) const; Vector2 operator+(const Vector2 &p_v) const; void operator+=(const Vector2 &p_v); @@ -629,9 +629,9 @@ struct Transform2D { void affine_invert(); Transform2D affine_inverse() const; - void set_rotation(real_t p_phi); + void set_rotation(real_t p_rot); real_t get_rotation() const; - _FORCE_INLINE_ void set_rotation_and_scale(real_t p_phi, const Size2 &p_scale); + _FORCE_INLINE_ void set_rotation_and_scale(real_t p_rot, const Size2 &p_scale); void rotate(real_t p_phi); void scale(const Size2 &p_scale); @@ -668,8 +668,8 @@ struct Transform2D { _FORCE_INLINE_ Vector2 basis_xform_inv(const Vector2 &p_vec) const; _FORCE_INLINE_ Vector2 xform(const Vector2 &p_vec) const; _FORCE_INLINE_ Vector2 xform_inv(const Vector2 &p_vec) const; - _FORCE_INLINE_ Rect2 xform(const Rect2 &p_vec) const; - _FORCE_INLINE_ Rect2 xform_inv(const Rect2 &p_vec) const; + _FORCE_INLINE_ Rect2 xform(const Rect2 &p_rect) const; + _FORCE_INLINE_ Rect2 xform_inv(const Rect2 &p_rect) const; operator String() const; @@ -841,25 +841,25 @@ next4: return true; } -Vector2 Transform2D::basis_xform(const Vector2 &v) const { +Vector2 Transform2D::basis_xform(const Vector2 &p_vec) const { return Vector2( - tdotx(v), - tdoty(v)); + tdotx(p_vec), + tdoty(p_vec)); } -Vector2 Transform2D::basis_xform_inv(const Vector2 &v) const { +Vector2 Transform2D::basis_xform_inv(const Vector2 &p_vec) const { return Vector2( - elements[0].dot(v), - elements[1].dot(v)); + elements[0].dot(p_vec), + elements[1].dot(p_vec)); } -Vector2 Transform2D::xform(const Vector2 &v) const { +Vector2 Transform2D::xform(const Vector2 &p_vec) const { return Vector2( - tdotx(v), - tdoty(v)) + + tdotx(p_vec), + tdoty(p_vec)) + elements[2]; } Vector2 Transform2D::xform_inv(const Vector2 &p_vec) const { diff --git a/core/math/octree.h b/core/math/octree.h index 010c1b18f7..2e37056030 100644 --- a/core/math/octree.h +++ b/core/math/octree.h @@ -351,7 +351,7 @@ private: }; void _cull_convex(Octant *p_octant, _CullConvexData *p_cull); - void _cull_AABB(Octant *p_octant, const Rect3 &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask); + void _cull_aabb(Octant *p_octant, const Rect3 &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask); void _cull_segment(Octant *p_octant, const Vector3 &p_from, const Vector3 &p_to, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask); void _cull_point(Octant *p_octant, const Vector3 &p_point, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask); @@ -380,7 +380,7 @@ public: int get_subindex(OctreeElementID p_id) const; int cull_convex(const Vector<Plane> &p_convex, T **p_result_array, int p_result_max, uint32_t p_mask = 0xFFFFFFFF); - int cull_AABB(const Rect3 &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF); + int cull_aabb(const Rect3 &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF); int cull_segment(const Vector3 &p_from, const Vector3 &p_to, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF); int cull_point(const Vector3 &p_point, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF); @@ -1095,7 +1095,7 @@ void Octree<T, use_pairs, AL>::_cull_convex(Octant *p_octant, _CullConvexData *p } template <class T, bool use_pairs, class AL> -void Octree<T, use_pairs, AL>::_cull_AABB(Octant *p_octant, const Rect3 &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask) { +void Octree<T, use_pairs, AL>::_cull_aabb(Octant *p_octant, const Rect3 &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask) { if (*p_result_idx == p_result_max) return; //pointless @@ -1160,7 +1160,7 @@ void Octree<T, use_pairs, AL>::_cull_AABB(Octant *p_octant, const Rect3 &p_aabb, for (int i = 0; i < 8; i++) { if (p_octant->children[i] && p_octant->children[i]->aabb.intersects_inclusive(p_aabb)) { - _cull_AABB(p_octant->children[i], p_aabb, p_result_array, p_result_idx, p_result_max, p_subindex_array, p_mask); + _cull_aabb(p_octant->children[i], p_aabb, p_result_array, p_result_idx, p_result_max, p_subindex_array, p_mask); } } } @@ -1336,14 +1336,14 @@ int Octree<T, use_pairs, AL>::cull_convex(const Vector<Plane> &p_convex, T **p_r } template <class T, bool use_pairs, class AL> -int Octree<T, use_pairs, AL>::cull_AABB(const Rect3 &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array, uint32_t p_mask) { +int Octree<T, use_pairs, AL>::cull_aabb(const Rect3 &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array, uint32_t p_mask) { if (!root) return 0; int result_count = 0; pass++; - _cull_AABB(root, p_aabb, p_result_array, &result_count, p_result_max, p_subindex_array, p_mask); + _cull_aabb(root, p_aabb, p_result_array, &result_count, p_result_max, p_subindex_array, p_mask); return result_count; } diff --git a/core/math/plane.cpp b/core/math/plane.cpp index f5e92866c4..17928d07c3 100644 --- a/core/math/plane.cpp +++ b/core/math/plane.cpp @@ -103,7 +103,7 @@ bool Plane::intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r return true; } -bool Plane::intersects_ray(Vector3 p_from, Vector3 p_dir, Vector3 *p_intersection) const { +bool Plane::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *p_intersection) const { Vector3 segment = p_dir; real_t den = normal.dot(segment); @@ -128,7 +128,7 @@ bool Plane::intersects_ray(Vector3 p_from, Vector3 p_dir, Vector3 *p_intersectio return true; } -bool Plane::intersects_segment(Vector3 p_begin, Vector3 p_end, Vector3 *p_intersection) const { +bool Plane::intersects_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 *p_intersection) const { Vector3 segment = p_begin - p_end; real_t den = normal.dot(segment); diff --git a/core/math/plane.h b/core/math/plane.h index 92ebcd8024..73d584e553 100644 --- a/core/math/plane.h +++ b/core/math/plane.h @@ -56,8 +56,8 @@ public: /* intersections */ bool intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r_result = 0) const; - bool intersects_ray(Vector3 p_from, Vector3 p_dir, Vector3 *p_intersection) const; - bool intersects_segment(Vector3 p_begin, Vector3 p_end, Vector3 *p_intersection) const; + bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *p_intersection) const; + bool intersects_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 *p_intersection) const; _FORCE_INLINE_ Vector3 project(const Vector3 &p_point) const { diff --git a/core/math/rect3.h b/core/math/rect3.h index e5d7462009..7c971f5ac7 100644 --- a/core/math/rect3.h +++ b/core/math/rect3.h @@ -72,9 +72,9 @@ public: Rect3 intersection(const Rect3 &p_aabb) const; ///get box where two intersect, empty if no intersection occurs bool intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip = NULL, Vector3 *r_normal = NULL) const; bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip = NULL, Vector3 *r_normal = NULL) const; - _FORCE_INLINE_ bool smits_intersect_ray(const Vector3 &from, const Vector3 &p_dir, real_t t0, real_t t1) const; + _FORCE_INLINE_ bool smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const; - _FORCE_INLINE_ bool intersects_convex_shape(const Plane *p_plane, int p_plane_count) const; + _FORCE_INLINE_ bool intersects_convex_shape(const Plane *p_planes, int p_plane_count) const; bool intersects_plane(const Plane &p_plane) const; _FORCE_INLINE_ bool has_point(const Vector3 &p_point) const; @@ -326,27 +326,27 @@ inline real_t Rect3::get_shortest_axis_size() const { return max_size; } -bool Rect3::smits_intersect_ray(const Vector3 &from, const Vector3 &dir, real_t t0, real_t t1) const { +bool Rect3::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const { - real_t divx = 1.0 / dir.x; - real_t divy = 1.0 / dir.y; - real_t divz = 1.0 / dir.z; + real_t divx = 1.0 / p_dir.x; + real_t divy = 1.0 / p_dir.y; + real_t divz = 1.0 / p_dir.z; Vector3 upbound = position + size; real_t tmin, tmax, tymin, tymax, tzmin, tzmax; - if (dir.x >= 0) { - tmin = (position.x - from.x) * divx; - tmax = (upbound.x - from.x) * divx; + if (p_dir.x >= 0) { + tmin = (position.x - p_from.x) * divx; + tmax = (upbound.x - p_from.x) * divx; } else { - tmin = (upbound.x - from.x) * divx; - tmax = (position.x - from.x) * divx; + tmin = (upbound.x - p_from.x) * divx; + tmax = (position.x - p_from.x) * divx; } - if (dir.y >= 0) { - tymin = (position.y - from.y) * divy; - tymax = (upbound.y - from.y) * divy; + if (p_dir.y >= 0) { + tymin = (position.y - p_from.y) * divy; + tymax = (upbound.y - p_from.y) * divy; } else { - tymin = (upbound.y - from.y) * divy; - tymax = (position.y - from.y) * divy; + tymin = (upbound.y - p_from.y) * divy; + tymax = (position.y - p_from.y) * divy; } if ((tmin > tymax) || (tymin > tmax)) return false; @@ -354,12 +354,12 @@ bool Rect3::smits_intersect_ray(const Vector3 &from, const Vector3 &dir, real_t tmin = tymin; if (tymax < tmax) tmax = tymax; - if (dir.z >= 0) { - tzmin = (position.z - from.z) * divz; - tzmax = (upbound.z - from.z) * divz; + if (p_dir.z >= 0) { + tzmin = (position.z - p_from.z) * divz; + tzmax = (upbound.z - p_from.z) * divz; } else { - tzmin = (upbound.z - from.z) * divz; - tzmax = (position.z - from.z) * divz; + tzmin = (upbound.z - p_from.z) * divz; + tzmax = (position.z - p_from.z) * divz; } if ((tmin > tzmax) || (tzmin > tmax)) return false; diff --git a/core/math/vector3.h b/core/math/vector3.h index 6a7974681e..c58a86fbdb 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -108,9 +108,9 @@ struct Vector3 { _FORCE_INLINE_ real_t angle_to(const Vector3 &p_b) const; - _FORCE_INLINE_ Vector3 slide(const Vector3 &p_vec) const; - _FORCE_INLINE_ Vector3 bounce(const Vector3 &p_vec) const; - _FORCE_INLINE_ Vector3 reflect(const Vector3 &p_vec) const; + _FORCE_INLINE_ Vector3 slide(const Vector3 &p_normal) const; + _FORCE_INLINE_ Vector3 bounce(const Vector3 &p_normal) const; + _FORCE_INLINE_ Vector3 reflect(const Vector3 &p_normal) const; /* Operators */ @@ -410,22 +410,22 @@ void Vector3::zero() { } // slide returns the component of the vector along the given plane, specified by its normal vector. -Vector3 Vector3::slide(const Vector3 &p_n) const { +Vector3 Vector3::slide(const Vector3 &p_normal) const { #ifdef MATH_CHECKS - ERR_FAIL_COND_V(p_n.is_normalized() == false, Vector3()); + ERR_FAIL_COND_V(p_normal.is_normalized() == false, Vector3()); #endif - return *this - p_n * this->dot(p_n); + return *this - p_normal * this->dot(p_normal); } -Vector3 Vector3::bounce(const Vector3 &p_n) const { - return -reflect(p_n); +Vector3 Vector3::bounce(const Vector3 &p_normal) const { + return -reflect(p_normal); } -Vector3 Vector3::reflect(const Vector3 &p_n) const { +Vector3 Vector3::reflect(const Vector3 &p_normal) const { #ifdef MATH_CHECKS - ERR_FAIL_COND_V(p_n.is_normalized() == false, Vector3()); + ERR_FAIL_COND_V(p_normal.is_normalized() == false, Vector3()); #endif - return 2.0 * p_n * this->dot(p_n) - *this; + return 2.0 * p_normal * this->dot(p_normal) - *this; } #endif |