mirror of
https://github.com/panda3d/panda3d.git
synced 2026-05-22 23:58:48 -05:00
Backport normalized() method to 1.9 branch
This commit is contained in:
@@ -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 ------------------------
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user