Small Issues & Maintenance

-=-=-=-=-=-=-=-=-=-=-=-=-=

-Begin work on Navigation Meshes (simple pathfinding for now, will improve soon)
-More doc on theme overriding
-Upgraded OpenSSL to version without bugs
-Misc bugfixes
This commit is contained in:
Juan Linietsky 2014-08-01 22:10:38 -03:00
parent 9ff6d55822
commit 678948068b
1323 changed files with 11564 additions and 39728 deletions

View file

@ -356,4 +356,100 @@ void Face3::get_support(const Vector3& p_normal,const Transform& p_transform,Vec
}
Vector3 Face3::get_closest_point_to(const Vector3& p_point) const {
Vector3 edge0 = vertex[1] - vertex[0];
Vector3 edge1 = vertex[2] - vertex[0];
Vector3 v0 = vertex[0] - p_point;
float a = edge0.dot( edge0 );
float b = edge0.dot( edge1 );
float c = edge1.dot( edge1 );
float d = edge0.dot( v0 );
float e = edge1.dot( v0 );
float det = a*c - b*b;
float s = b*e - c*d;
float t = b*d - a*e;
if ( s + t < det )
{
if ( s < 0.f )
{
if ( t < 0.f )
{
if ( d < 0.f )
{
s = CLAMP( -d/a, 0.f, 1.f );
t = 0.f;
}
else
{
s = 0.f;
t = CLAMP( -e/c, 0.f, 1.f );
}
}
else
{
s = 0.f;
t = CLAMP( -e/c, 0.f, 1.f );
}
}
else if ( t < 0.f )
{
s = CLAMP( -d/a, 0.f, 1.f );
t = 0.f;
}
else
{
float invDet = 1.f / det;
s *= invDet;
t *= invDet;
}
}
else
{
if ( s < 0.f )
{
float tmp0 = b+d;
float tmp1 = c+e;
if ( tmp1 > tmp0 )
{
float numer = tmp1 - tmp0;
float denom = a-2*b+c;
s = CLAMP( numer/denom, 0.f, 1.f );
t = 1-s;
}
else
{
t = CLAMP( -e/c, 0.f, 1.f );
s = 0.f;
}
}
else if ( t < 0.f )
{
if ( a+d > b+e )
{
float numer = c+e-b-d;
float denom = a-2*b+c;
s = CLAMP( numer/denom, 0.f, 1.f );
t = 1-s;
}
else
{
s = CLAMP( -e/c, 0.f, 1.f );
t = 0.f;
}
}
else
{
float numer = c+e-b-d;
float denom = a-2*b+c;
s = CLAMP( numer/denom, 0.f, 1.f );
t = 1.f - s;
}
}
return vertex[0] + s * edge0 + t * edge1;
}

View file

@ -68,6 +68,7 @@ public:
real_t get_area() const;
Vector3 get_median_point() const;
Vector3 get_closest_point_to(const Vector3& p_point) const;
bool intersects_ray(const Vector3& p_from,const Vector3& p_dir,Vector3 * p_intersection=0) const;
bool intersects_segment(const Vector3& p_from,const Vector3& p_dir,Vector3 * p_intersection=0) const;

View file

@ -77,6 +77,11 @@ float Vector2::angle_to(const Vector2& p_vector2) const {
return Math::atan2( tangent().dot(p_vector2), dot(p_vector2) );
}
float Vector2::angle_to_point(const Vector2& p_vector2) const {
return Math::atan2( x-p_vector2.x, y - p_vector2.y );
}
float Vector2::dot(const Vector2& p_other) const {
return x*p_other.x + y*p_other.y;

View file

@ -90,7 +90,8 @@ struct Vector2 {
float distance_to(const Vector2& p_vector2) const;
float distance_squared_to(const Vector2& p_vector2) const;
float angle_to(const Vector2& p_vector2) const;
float angle_to_point(const Vector2& p_vector2) const;
float dot(const Vector2& p_other) const;
float cross(const Vector2& p_other) const;
Vector2 cross(real_t p_other) const;