You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-15 13:51:40 +00:00
Bring that Whole New World to the Old Continent too
Applies the clang-format style to the 2.1 branch as done for master in
5dbf1809c6.
This commit is contained in:
@@ -33,20 +33,20 @@
|
||||
#define _PLANE_EQ_DOT_EPSILON 0.999
|
||||
#define _PLANE_EQ_D_EPSILON 0.0001
|
||||
|
||||
void Plane::set_normal(const Vector3& p_normal) {
|
||||
void Plane::set_normal(const Vector3 &p_normal) {
|
||||
|
||||
normal=p_normal;
|
||||
normal = p_normal;
|
||||
}
|
||||
|
||||
void Plane::normalize() {
|
||||
|
||||
real_t l = normal.length();
|
||||
if (l==0) {
|
||||
*this=Plane(0,0,0,0);
|
||||
if (l == 0) {
|
||||
*this = Plane(0, 0, 0, 0);
|
||||
return;
|
||||
}
|
||||
normal/=l;
|
||||
d/=l;
|
||||
normal /= l;
|
||||
d /= l;
|
||||
}
|
||||
|
||||
Plane Plane::normalized() const {
|
||||
@@ -58,21 +58,21 @@ Plane Plane::normalized() const {
|
||||
|
||||
Vector3 Plane::get_any_point() const {
|
||||
|
||||
return get_normal()*d;
|
||||
return get_normal() * d;
|
||||
}
|
||||
|
||||
Vector3 Plane::get_any_perpendicular_normal() const {
|
||||
|
||||
static const Vector3 p1 = Vector3(1,0,0);
|
||||
static const Vector3 p2 = Vector3(0,1,0);
|
||||
static const Vector3 p1 = Vector3(1, 0, 0);
|
||||
static const Vector3 p2 = Vector3(0, 1, 0);
|
||||
Vector3 p;
|
||||
|
||||
if (ABS(normal.dot(p1)) > 0.99) // if too similar to p1
|
||||
p=p2; // use p2
|
||||
p = p2; // use p2
|
||||
else
|
||||
p=p1; // use p1
|
||||
p = p1; // use p1
|
||||
|
||||
p-=normal * normal.dot(p);
|
||||
p -= normal * normal.dot(p);
|
||||
p.normalize();
|
||||
|
||||
return p;
|
||||
@@ -82,71 +82,71 @@ Vector3 Plane::get_any_perpendicular_normal() const {
|
||||
|
||||
bool Plane::intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r_result) const {
|
||||
|
||||
const Plane &p_plane0=*this;
|
||||
Vector3 normal0=p_plane0.normal;
|
||||
Vector3 normal1=p_plane1.normal;
|
||||
Vector3 normal2=p_plane2.normal;
|
||||
const Plane &p_plane0 = *this;
|
||||
Vector3 normal0 = p_plane0.normal;
|
||||
Vector3 normal1 = p_plane1.normal;
|
||||
Vector3 normal2 = p_plane2.normal;
|
||||
|
||||
real_t denom=vec3_cross(normal0,normal1).dot(normal2);
|
||||
real_t denom = vec3_cross(normal0, normal1).dot(normal2);
|
||||
|
||||
if (ABS(denom)<=CMP_EPSILON)
|
||||
if (ABS(denom) <= CMP_EPSILON)
|
||||
return false;
|
||||
|
||||
if (r_result) {
|
||||
*r_result = ( (vec3_cross(normal1, normal2) * p_plane0.d) +
|
||||
(vec3_cross(normal2, normal0) * p_plane1.d) +
|
||||
(vec3_cross(normal0, normal1) * p_plane2.d) )/denom;
|
||||
}
|
||||
if (r_result) {
|
||||
*r_result = ((vec3_cross(normal1, normal2) * p_plane0.d) +
|
||||
(vec3_cross(normal2, normal0) * p_plane1.d) +
|
||||
(vec3_cross(normal0, normal1) * p_plane2.d)) /
|
||||
denom;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Plane::intersects_ray(Vector3 p_from, Vector3 p_dir, Vector3 *p_intersection) const {
|
||||
|
||||
bool Plane::intersects_ray(Vector3 p_from, Vector3 p_dir, Vector3* p_intersection) const {
|
||||
|
||||
Vector3 segment=p_dir;
|
||||
real_t den=normal.dot( segment );
|
||||
Vector3 segment = p_dir;
|
||||
real_t den = normal.dot(segment);
|
||||
|
||||
//printf("den is %i\n",den);
|
||||
if (Math::abs(den)<=CMP_EPSILON) {
|
||||
if (Math::abs(den) <= CMP_EPSILON) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
real_t dist=(normal.dot( p_from ) - d) / den;
|
||||
real_t dist = (normal.dot(p_from) - d) / den;
|
||||
//printf("dist is %i\n",dist);
|
||||
|
||||
if (dist>CMP_EPSILON) { //this is a ray, before the emiting pos (p_from) doesnt exist
|
||||
if (dist > CMP_EPSILON) { //this is a ray, before the emiting pos (p_from) doesnt exist
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
dist=-dist;
|
||||
dist = -dist;
|
||||
*p_intersection = p_from + segment * dist;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Plane::intersects_segment(Vector3 p_begin, Vector3 p_end, Vector3* p_intersection) const {
|
||||
bool Plane::intersects_segment(Vector3 p_begin, Vector3 p_end, Vector3 *p_intersection) const {
|
||||
|
||||
Vector3 segment= p_begin - p_end;
|
||||
real_t den=normal.dot( segment );
|
||||
Vector3 segment = p_begin - p_end;
|
||||
real_t den = normal.dot(segment);
|
||||
|
||||
//printf("den is %i\n",den);
|
||||
if (Math::abs(den)<=CMP_EPSILON) {
|
||||
if (Math::abs(den) <= CMP_EPSILON) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
real_t dist=(normal.dot( p_begin ) - d) / den;
|
||||
real_t dist = (normal.dot(p_begin) - d) / den;
|
||||
//printf("dist is %i\n",dist);
|
||||
|
||||
if (dist<-CMP_EPSILON || dist > (1.0 +CMP_EPSILON)) {
|
||||
if (dist < -CMP_EPSILON || dist > (1.0 + CMP_EPSILON)) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
dist=-dist;
|
||||
dist = -dist;
|
||||
*p_intersection = p_begin + segment * dist;
|
||||
|
||||
return true;
|
||||
@@ -154,12 +154,11 @@ bool Plane::intersects_segment(Vector3 p_begin, Vector3 p_end, Vector3* p_inters
|
||||
|
||||
/* misc */
|
||||
|
||||
bool Plane::is_almost_like(const Plane& p_plane) const {
|
||||
bool Plane::is_almost_like(const Plane &p_plane) const {
|
||||
|
||||
return (normal.dot( p_plane.normal ) > _PLANE_EQ_DOT_EPSILON && Math::absd(d-p_plane.d) < _PLANE_EQ_D_EPSILON);
|
||||
return (normal.dot(p_plane.normal) > _PLANE_EQ_DOT_EPSILON && Math::absd(d - p_plane.d) < _PLANE_EQ_D_EPSILON);
|
||||
}
|
||||
|
||||
|
||||
Plane::operator String() const {
|
||||
|
||||
return normal.operator String() + ", " + rtos(d);
|
||||
|
||||
Reference in New Issue
Block a user