diff options
author | lawnjelly <lawnjelly@gmail.com> | 2022-02-06 11:14:58 +0000 |
---|---|---|
committer | lawnjelly <lawnjelly@gmail.com> | 2022-02-10 18:43:19 +0000 |
commit | 5298e16e80e032a7ff0c6a661b826859e5aeccd0 (patch) | |
tree | 71d1a20724bd477e59f2051d4f7c62dd4df5757b /core/math/aabb.h | |
parent | 38c851a3fa14983e60f74703fea2178d52358b92 (diff) |
Float literals - fix main primitives to use .f
Converts float literals from double format (e.g. 0.0) to float format (e.g. 0.0f) where appropriate for 32 bit calculations.
Diffstat (limited to 'core/math/aabb.h')
-rw-r--r-- | core/math/aabb.h | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/core/math/aabb.h b/core/math/aabb.h index cb6f05e9ea..e88ba33531 100644 --- a/core/math/aabb.h +++ b/core/math/aabb.h @@ -119,7 +119,7 @@ struct _NO_DISCARD_ AABB { } _FORCE_INLINE_ Vector3 get_center() const { - return position + (size * 0.5); + return position + (size * 0.5f); } operator String() const; @@ -208,7 +208,7 @@ inline bool AABB::encloses(const AABB &p_aabb) const { } Vector3 AABB::get_support(const Vector3 &p_normal) const { - Vector3 half_extents = size * 0.5; + Vector3 half_extents = size * 0.5f; Vector3 ofs = position + half_extents; return Vector3( @@ -242,7 +242,7 @@ Vector3 AABB::get_endpoint(int p_point) const { } bool AABB::intersects_convex_shape(const Plane *p_planes, int p_plane_count, const Vector3 *p_points, int p_point_count) const { - Vector3 half_extents = size * 0.5; + Vector3 half_extents = size * 0.5f; Vector3 ofs = position + half_extents; for (int i = 0; i < p_plane_count; i++) { @@ -284,7 +284,7 @@ bool AABB::intersects_convex_shape(const Plane *p_planes, int p_plane_count, con } bool AABB::inside_convex_shape(const Plane *p_planes, int p_plane_count) const { - Vector3 half_extents = size * 0.5; + Vector3 half_extents = size * 0.5f; Vector3 ofs = position + half_extents; for (int i = 0; i < p_plane_count; i++) { @@ -364,7 +364,7 @@ inline void AABB::expand_to(const Vector3 &p_vector) { } void AABB::project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const { - Vector3 half_extents(size.x * 0.5, size.y * 0.5, size.z * 0.5); + Vector3 half_extents(size.x * 0.5f, size.y * 0.5f, size.z * 0.5f); Vector3 center(position.x + half_extents.x, position.y + half_extents.y, position.z + half_extents.z); real_t length = p_plane.normal.abs().dot(half_extents); @@ -407,9 +407,9 @@ bool AABB::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real ERR_PRINT("AABB size is negative, this is not supported. Use AABB.abs() to get an AABB with a positive size."); } #endif - real_t divx = 1.0 / p_dir.x; - real_t divy = 1.0 / p_dir.y; - real_t divz = 1.0 / p_dir.z; + real_t divx = 1.0f / p_dir.x; + real_t divy = 1.0f / p_dir.y; + real_t divz = 1.0f / p_dir.z; Vector3 upbound = position + size; real_t tmin, tmax, tymin, tymax, tzmin, tzmax; @@ -459,9 +459,9 @@ void AABB::grow_by(real_t p_amount) { position.x -= p_amount; position.y -= p_amount; position.z -= p_amount; - size.x += 2.0 * p_amount; - size.y += 2.0 * p_amount; - size.z += 2.0 * p_amount; + size.x += 2.0f * p_amount; + size.y += 2.0f * p_amount; + size.z += 2.0f * p_amount; } void AABB::quantize(real_t p_unit) { |