Backport normalized() method to 1.9 branch

This commit is contained in:
rdb
2016-09-08 22:52:57 +02:00
parent 4d8a9aa3a1
commit 558f84a95f
19 changed files with 133 additions and 0 deletions
+1
View File
@@ -32,6 +32,7 @@ This issue fixes several bugs that were still found in 1.9.2.
* Fix RAM caching of 2D texture arrays
* Fix Ctrl+C interrupt propagation to runtime applications
* Support for InvSphere, Box and Tube solids in bam2egg
* Add normalized() method to vectors
------------------------ RELEASE 1.9.2 ------------------------
+12
View File
@@ -186,6 +186,18 @@ operator / (FLOATTYPE scalar) const {
}
#ifndef FLOATTYPE_IS_INT
////////////////////////////////////////////////////////////////////
// Function: LPoint2::normalized
// Access: Published
// Description: Normalizes the vector and returns the normalized
// vector as a copy. If the vector was a zero-length
// vector, a zero length vector will be returned.
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(LPoint2) FLOATNAME(LPoint2)::
normalized() const {
return FLOATNAME(LVecBase2)::normalized();
}
////////////////////////////////////////////////////////////////////
// Function: LPoint2::project
// Access: Published
+1
View File
@@ -51,6 +51,7 @@ PUBLISHED:
INLINE_LINMATH FLOATNAME(LPoint2) operator / (FLOATTYPE scalar) const;
#ifndef FLOATTYPE_IS_INT
INLINE_LINMATH FLOATNAME(LPoint2) normalized() const;
INLINE_LINMATH FLOATNAME(LPoint2) project(const FLOATNAME(LVecBase2) &onto) const;
#endif
+12
View File
@@ -230,6 +230,18 @@ cross(const FLOATNAME(LVecBase3) &other) const {
}
#ifndef FLOATTYPE_IS_INT
////////////////////////////////////////////////////////////////////
// Function: LPoint3::normalized
// Access: Published
// Description: Normalizes the vector and returns the normalized
// vector as a copy. If the vector was a zero-length
// vector, a zero length vector will be returned.
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(LPoint3) FLOATNAME(LPoint3)::
normalized() const {
return FLOATNAME(LVecBase3)::normalized();
}
////////////////////////////////////////////////////////////////////
// Function: LPoint3::project
// Access: Published
+1
View File
@@ -61,6 +61,7 @@ PUBLISHED:
INLINE_LINMATH FLOATNAME(LPoint3) cross(const FLOATNAME(LVecBase3) &other) const;
#ifndef FLOATTYPE_IS_INT
INLINE_LINMATH FLOATNAME(LPoint3) normalized() const;
INLINE_LINMATH FLOATNAME(LPoint3) project(const FLOATNAME(LVecBase3) &onto) const;
#endif
+13
View File
@@ -217,6 +217,19 @@ operator / (FLOATTYPE scalar) const {
}
#ifndef FLOATTYPE_IS_INT
////////////////////////////////////////////////////////////////////
// Function: LPoint4::normalized
// Access: Published
// Description: Normalizes the vector and returns the normalized
// vector as a copy. If the vector was a zero-length
// vector, a zero length vector will be returned.
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(LPoint4) FLOATNAME(LPoint4)::
normalized() const {
return FLOATNAME(LVecBase4)::normalized();
}
////////////////////////////////////////////////////////////////////
// Function: LPoint4::project
// Access: Published
+1
View File
@@ -53,6 +53,7 @@ PUBLISHED:
INLINE_LINMATH FLOATNAME(LPoint4) operator / (FLOATTYPE scalar) const;
#ifndef FLOATTYPE_IS_INT
INLINE_LINMATH FLOATNAME(LPoint4) normalized() const;
INLINE_LINMATH FLOATNAME(LPoint4) project(const FLOATNAME(LVecBase4) &onto) const;
#endif
+16
View File
@@ -418,6 +418,22 @@ normalize() {
return true;
}
////////////////////////////////////////////////////////////////////
// Function: LVecBase2::normalized
// Access: Published
// Description: Normalizes the vector and returns the normalized
// vector as a copy. If the vector was a zero-length
// vector, a zero length vector will be returned.
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::
normalized() const {
FLOATTYPE l2 = length_squared();
if (l2 == (FLOATTYPE)0.0f) {
return FLOATNAME(LVecBase2)(0.0f);
}
return (*this) / csqrt(l2);
}
////////////////////////////////////////////////////////////////////
// Function: LVecBase2::project
// Access: Published
+1
View File
@@ -94,6 +94,7 @@ PUBLISHED:
#ifndef FLOATTYPE_IS_INT
INLINE_LINMATH FLOATTYPE length() const;
INLINE_LINMATH bool normalize();
INLINE_LINMATH FLOATNAME(LVecBase2) normalized() const;
INLINE_LINMATH FLOATNAME(LVecBase2) project(const FLOATNAME(LVecBase2) &onto) const;
#endif
+16
View File
@@ -509,6 +509,22 @@ normalize() {
return true;
}
////////////////////////////////////////////////////////////////////
// Function: LVecBase3::normalized
// Access: Published
// Description: Normalizes the vector and returns the normalized
// vector as a copy. If the vector was a zero-length
// vector, a zero length vector will be returned.
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::
normalized() const {
FLOATTYPE l2 = length_squared();
if (l2 == (FLOATTYPE)0.0f) {
return FLOATNAME(LVecBase3)(0.0f);
}
return (*this) / csqrt(l2);
}
////////////////////////////////////////////////////////////////////
// Function: LVecBase3::project
// Access: Published
+1
View File
@@ -103,6 +103,7 @@ PUBLISHED:
#ifndef FLOATTYPE_IS_INT
INLINE_LINMATH FLOATTYPE length() const;
INLINE_LINMATH bool normalize();
INLINE_LINMATH FLOATNAME(LVecBase3) normalized() const;
INLINE_LINMATH FLOATNAME(LVecBase3) project(const FLOATNAME(LVecBase3) &onto) const;
#endif
+16
View File
@@ -559,6 +559,22 @@ normalize() {
return true;
}
////////////////////////////////////////////////////////////////////
// Function: LVecBase4::normalized
// Access: Published
// Description: Normalizes the vector and returns the normalized
// vector as a copy. If the vector was a zero-length
// vector, a zero length vector will be returned.
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::
normalized() const {
FLOATTYPE l2 = length_squared();
if (l2 == (FLOATTYPE)0.0f) {
return FLOATNAME(LVecBase4)(0.0f);
}
return (*this) / csqrt(l2);
}
////////////////////////////////////////////////////////////////////
// Function: LVecBase4::project
// Access: Published
+1
View File
@@ -113,6 +113,7 @@ PUBLISHED:
#ifndef FLOATTYPE_IS_INT
INLINE_LINMATH FLOATTYPE length() const;
INLINE_LINMATH bool normalize();
INLINE_LINMATH FLOATNAME(LVecBase4) normalized() const;
INLINE_LINMATH FLOATNAME(LVecBase4) project(const FLOATNAME(LVecBase4) &onto) const;
#endif
+12
View File
@@ -175,6 +175,18 @@ operator / (FLOATTYPE scalar) const {
}
#ifndef FLOATTYPE_IS_INT
////////////////////////////////////////////////////////////////////
// Function: LVector2::normalized
// Access: Published
// Description: Normalizes the vector and returns the normalized
// vector as a copy. If the vector was a zero-length
// vector, a zero length vector will be returned.
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(LVector2) FLOATNAME(LVector2)::
normalized() const {
return FLOATNAME(LVecBase2)::normalized();
}
////////////////////////////////////////////////////////////////////
// Function: LVector2::project
// Access: Published
+1
View File
@@ -44,6 +44,7 @@ PUBLISHED:
INLINE_LINMATH FLOATNAME(LVector2) operator / (FLOATTYPE scalar) const;
#ifndef FLOATTYPE_IS_INT
INLINE_LINMATH FLOATNAME(LVector2) normalized() const;
INLINE_LINMATH FLOATNAME(LVector2) project(const FLOATNAME(LVecBase2) &onto) const;
INLINE_LINMATH FLOATTYPE signed_angle_rad(const FLOATNAME(LVector2) &other) const;
INLINE_LINMATH FLOATTYPE signed_angle_deg(const FLOATNAME(LVector2) &other) const;
+13
View File
@@ -220,6 +220,19 @@ cross(const FLOATNAME(LVecBase3) &other) const {
}
#ifndef FLOATTYPE_IS_INT
////////////////////////////////////////////////////////////////////
// Function: LVector3::normalized
// Access: Published
// Description: Normalizes the vector and returns the normalized
// vector as a copy. If the vector was a zero-length
// vector, a zero length vector will be returned.
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector3)::
normalized() const {
return FLOATNAME(LVecBase3)::normalized();
}
////////////////////////////////////////////////////////////////////
// Function: LVector3::project
// Access: Published
+1
View File
@@ -55,6 +55,7 @@ PUBLISHED:
INLINE_LINMATH FLOATNAME(LVector3) cross(const FLOATNAME(LVecBase3) &other) const;
#ifndef FLOATTYPE_IS_INT
INLINE_LINMATH FLOATNAME(LVector3) normalized() const;
INLINE_LINMATH FLOATNAME(LVector3) project(const FLOATNAME(LVecBase3) &onto) const;
INLINE_LINMATH FLOATTYPE angle_rad(const FLOATNAME(LVector3) &other) const;
INLINE_LINMATH FLOATTYPE angle_deg(const FLOATNAME(LVector3) &other) const;
+13
View File
@@ -207,6 +207,19 @@ operator / (FLOATTYPE scalar) const {
}
#ifndef FLOATTYPE_IS_INT
////////////////////////////////////////////////////////////////////
// Function: LVector4::normalized
// Access: Published
// Description: Normalizes the vector and returns the normalized
// vector as a copy. If the vector was a zero-length
// vector, a zero length vector will be returned.
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(LVector4) FLOATNAME(LVector4)::
normalized() const {
return FLOATNAME(LVecBase4)::normalized();
}
////////////////////////////////////////////////////////////////////
// Function: LVector4::project
// Access: Published
+1
View File
@@ -47,6 +47,7 @@ PUBLISHED:
INLINE_LINMATH FLOATNAME(LVector4) operator / (FLOATTYPE scalar) const;
#ifndef FLOATTYPE_IS_INT
INLINE_LINMATH FLOATNAME(LVector4) normalized() const;
INLINE_LINMATH FLOATNAME(LVector4) project(const FLOATNAME(LVecBase4) &onto) const;
#endif