Replace "unaligned" linear algebra classes with simple typedefs
This commit is contained in:
parent
eacbc4f89a
commit
87b5aa9d1f
|
|
@ -59,6 +59,13 @@ typedef LPoint3d LTexCoord3d;
|
||||||
typedef LVecBase4d LColord;
|
typedef LVecBase4d LColord;
|
||||||
typedef LVecBase3d LRGBColord;
|
typedef LVecBase3d LRGBColord;
|
||||||
|
|
||||||
|
// These used to be separate classes, but now they're just typedefs.
|
||||||
|
typedef LVecBase4f UnalignedLVecBase4f;
|
||||||
|
typedef LVecBase4d UnalignedLVecBase4d;
|
||||||
|
typedef LVecBase4i UnalignedLVecBase4i;
|
||||||
|
typedef LMatrix4f UnalignedLMatrix4f;
|
||||||
|
typedef LMatrix4d UnalignedLMatrix4d;
|
||||||
|
|
||||||
// The following names are only for legacy Python code. These aren't real
|
// The following names are only for legacy Python code. These aren't real
|
||||||
// typedefs; they're just commands to interrogate.
|
// typedefs; they're just commands to interrogate.
|
||||||
#ifdef CPPPARSER
|
#ifdef CPPPARSER
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,6 @@ init_liblinmath() {
|
||||||
LPoint4f::init_type();
|
LPoint4f::init_type();
|
||||||
LMatrix3f::init_type();
|
LMatrix3f::init_type();
|
||||||
LMatrix4f::init_type();
|
LMatrix4f::init_type();
|
||||||
UnalignedLVecBase4f::init_type();
|
|
||||||
UnalignedLMatrix4f::init_type();
|
|
||||||
|
|
||||||
LVecBase2d::init_type();
|
LVecBase2d::init_type();
|
||||||
LVecBase3d::init_type();
|
LVecBase3d::init_type();
|
||||||
|
|
@ -79,8 +77,6 @@ init_liblinmath() {
|
||||||
LPoint4d::init_type();
|
LPoint4d::init_type();
|
||||||
LMatrix3d::init_type();
|
LMatrix3d::init_type();
|
||||||
LMatrix4d::init_type();
|
LMatrix4d::init_type();
|
||||||
UnalignedLVecBase4d::init_type();
|
|
||||||
UnalignedLMatrix4d::init_type();
|
|
||||||
|
|
||||||
LVecBase2i::init_type();
|
LVecBase2i::init_type();
|
||||||
LVecBase3i::init_type();
|
LVecBase3i::init_type();
|
||||||
|
|
@ -91,7 +87,6 @@ init_liblinmath() {
|
||||||
LPoint2i::init_type();
|
LPoint2i::init_type();
|
||||||
LPoint3i::init_type();
|
LPoint3i::init_type();
|
||||||
LPoint4i::init_type();
|
LPoint4i::init_type();
|
||||||
UnalignedLVecBase4i::init_type();
|
|
||||||
|
|
||||||
LQuaternionf::init_type();
|
LQuaternionf::init_type();
|
||||||
LRotationf::init_type();
|
LRotationf::init_type();
|
||||||
|
|
|
||||||
|
|
@ -111,25 +111,6 @@ zeros_mat() {
|
||||||
return _zeros_mat;
|
return _zeros_mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH FLOATNAME(LMatrix4)::
|
|
||||||
FLOATNAME(LMatrix4)(const FLOATNAME(UnalignedLMatrix4) ©) {
|
|
||||||
operator = (copy);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4)::
|
|
||||||
operator = (const FLOATNAME(UnalignedLMatrix4) ©) {
|
|
||||||
TAU_PROFILE("void LMatrix4::operator = (const UnalignedLMatrix4 &)", " ", TAU_USER);
|
|
||||||
|
|
||||||
memcpy(&_m(0, 0), copy.get_data(), sizeof(FLOATTYPE) * num_components);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
@ -1602,117 +1583,3 @@ invert(const FLOATNAME(LMatrix4) &a) {
|
||||||
#endif
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH FLOATNAME(UnalignedLMatrix4)::
|
|
||||||
FLOATNAME(UnalignedLMatrix4)(const FLOATNAME(LMatrix4) ©) {
|
|
||||||
operator = (copy);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH FLOATNAME(UnalignedLMatrix4) &FLOATNAME(UnalignedLMatrix4)::
|
|
||||||
operator = (const FLOATNAME(LMatrix4) ©) {
|
|
||||||
memcpy(&_m(0, 0), copy.get_data(), sizeof(FLOATTYPE) * num_components);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH FLOATNAME(UnalignedLMatrix4)::
|
|
||||||
FLOATNAME(UnalignedLMatrix4)(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e03,
|
|
||||||
FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12, FLOATTYPE e13,
|
|
||||||
FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22, FLOATTYPE e23,
|
|
||||||
FLOATTYPE e30, FLOATTYPE e31, FLOATTYPE e32, FLOATTYPE e33) {
|
|
||||||
TAU_PROFILE("UnalignedLMatrix4::UnalignedLMatrix4(FLOATTYPE, ...)", " ", TAU_USER);
|
|
||||||
set(e00, e01, e02, e03,
|
|
||||||
e10, e11, e12, e13,
|
|
||||||
e20, e21, e22, e23,
|
|
||||||
e30, e31, e32, e33);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH void FLOATNAME(UnalignedLMatrix4)::
|
|
||||||
set(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e03,
|
|
||||||
FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12, FLOATTYPE e13,
|
|
||||||
FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22, FLOATTYPE e23,
|
|
||||||
FLOATTYPE e30, FLOATTYPE e31, FLOATTYPE e32, FLOATTYPE e33) {
|
|
||||||
TAU_PROFILE("void UnalignedLMatrix4::set()", " ", TAU_USER);
|
|
||||||
|
|
||||||
_m(0, 0) = e00;
|
|
||||||
_m(0, 1) = e01;
|
|
||||||
_m(0, 2) = e02;
|
|
||||||
_m(0, 3) = e03;
|
|
||||||
|
|
||||||
_m(1, 0) = e10;
|
|
||||||
_m(1, 1) = e11;
|
|
||||||
_m(1, 2) = e12;
|
|
||||||
_m(1, 3) = e13;
|
|
||||||
|
|
||||||
_m(2, 0) = e20;
|
|
||||||
_m(2, 1) = e21;
|
|
||||||
_m(2, 2) = e22;
|
|
||||||
_m(2, 3) = e23;
|
|
||||||
|
|
||||||
_m(3, 0) = e30;
|
|
||||||
_m(3, 1) = e31;
|
|
||||||
_m(3, 2) = e32;
|
|
||||||
_m(3, 3) = e33;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH FLOATTYPE &FLOATNAME(UnalignedLMatrix4)::
|
|
||||||
operator () (int row, int col) {
|
|
||||||
nassertr(row >= 0 && row < 4 && col >= 0 && col < 4, _m(0, 0));
|
|
||||||
return _m(row, col);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH FLOATTYPE FLOATNAME(UnalignedLMatrix4)::
|
|
||||||
operator () (int row, int col) const {
|
|
||||||
nassertr(row >= 0 && row < 4 && col >= 0 && col < 4, 0.0);
|
|
||||||
return _m(row, col);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the address of the first of the nine data elements in the matrix.
|
|
||||||
* The remaining elements occupy the next eight positions in row-major order.
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH const FLOATTYPE *FLOATNAME(UnalignedLMatrix4)::
|
|
||||||
get_data() const {
|
|
||||||
return &_m(0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the number of elements in the matrix, sixteen.
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH int FLOATNAME(UnalignedLMatrix4)::
|
|
||||||
get_num_components() const {
|
|
||||||
return 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH bool FLOATNAME(UnalignedLMatrix4)::
|
|
||||||
operator == (const FLOATNAME(UnalignedLMatrix4) &other) const {
|
|
||||||
return memcmp(get_data(), other.get_data(), sizeof(FLOATTYPE) * 16) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH bool FLOATNAME(UnalignedLMatrix4)::
|
|
||||||
operator != (const FLOATNAME(UnalignedLMatrix4) &other) const {
|
|
||||||
return !operator == (other);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TypeHandle FLOATNAME(LMatrix4)::_type_handle;
|
TypeHandle FLOATNAME(LMatrix4)::_type_handle;
|
||||||
TypeHandle FLOATNAME(UnalignedLMatrix4)::_type_handle;
|
|
||||||
|
|
||||||
const FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::_ident_mat =
|
const FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::_ident_mat =
|
||||||
FLOATNAME(LMatrix4)(1.0f, 0.0f, 0.0f, 0.0f,
|
FLOATNAME(LMatrix4)(1.0f, 0.0f, 0.0f, 0.0f,
|
||||||
|
|
@ -557,14 +556,3 @@ init_type() {
|
||||||
register_type(_type_handle, FLOATNAME_STR(LMatrix4));
|
register_type(_type_handle, FLOATNAME_STR(LMatrix4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void FLOATNAME(UnalignedLMatrix4)::
|
|
||||||
init_type() {
|
|
||||||
if (_type_handle == TypeHandle::none()) {
|
|
||||||
// Format a string to describe the type.
|
|
||||||
register_type(_type_handle, FLOATNAME_STR(UnalignedLMatrix4));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,6 @@
|
||||||
* @date 1999-01-15
|
* @date 1999-01-15
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class FLOATNAME(UnalignedLMatrix4);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a 4-by-4 transform matrix.
|
* This is a 4-by-4 transform matrix.
|
||||||
*/
|
*/
|
||||||
|
|
@ -55,11 +53,8 @@ PUBLISHED:
|
||||||
|
|
||||||
INLINE_LINMATH FLOATNAME(LMatrix4)() = default;
|
INLINE_LINMATH FLOATNAME(LMatrix4)() = default;
|
||||||
INLINE_LINMATH FLOATNAME(LMatrix4)(const FLOATNAME(LMatrix4) &other) = default;
|
INLINE_LINMATH FLOATNAME(LMatrix4)(const FLOATNAME(LMatrix4) &other) = default;
|
||||||
INLINE_LINMATH FLOATNAME(LMatrix4)(const FLOATNAME(UnalignedLMatrix4) &other);
|
|
||||||
INLINE_LINMATH FLOATNAME(LMatrix4) &operator = (
|
INLINE_LINMATH FLOATNAME(LMatrix4) &operator = (
|
||||||
const FLOATNAME(LMatrix4) &other) = default;
|
const FLOATNAME(LMatrix4) &other) = default;
|
||||||
INLINE_LINMATH FLOATNAME(LMatrix4) &operator = (
|
|
||||||
const FLOATNAME(UnalignedLMatrix4) &other);
|
|
||||||
INLINE_LINMATH FLOATNAME(LMatrix4) &operator = (FLOATTYPE fill_value);
|
INLINE_LINMATH FLOATNAME(LMatrix4) &operator = (FLOATTYPE fill_value);
|
||||||
|
|
||||||
INLINE_LINMATH FLOATNAME(LMatrix4)(FLOATTYPE, FLOATTYPE, FLOATTYPE, FLOATTYPE,
|
INLINE_LINMATH FLOATNAME(LMatrix4)(FLOATTYPE, FLOATTYPE, FLOATTYPE, FLOATTYPE,
|
||||||
|
|
@ -287,8 +282,7 @@ public:
|
||||||
// The underlying implementation is via the Eigen library, if available.
|
// The underlying implementation is via the Eigen library, if available.
|
||||||
|
|
||||||
// Unlike LMatrix3, we fully align LMatrix4 to 16-byte boundaries, to take
|
// Unlike LMatrix3, we fully align LMatrix4 to 16-byte boundaries, to take
|
||||||
// advantage of SSE2 optimizations when available. Sometimes this alignment
|
// advantage of SSE2 optimizations when available.
|
||||||
// requirement is inconvenient, so we also provide UnalignedLMatrix4, below.
|
|
||||||
typedef LINMATH_MATRIX(FLOATTYPE, 4, 4) EMatrix4;
|
typedef LINMATH_MATRIX(FLOATTYPE, 4, 4) EMatrix4;
|
||||||
EMatrix4 _m;
|
EMatrix4 _m;
|
||||||
|
|
||||||
|
|
@ -318,59 +312,6 @@ private:
|
||||||
static TypeHandle _type_handle;
|
static TypeHandle _type_handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* This is an "unaligned" LMatrix4. It has no functionality other than to
|
|
||||||
* store numbers, and it will pack them in as tightly as possible, avoiding
|
|
||||||
* any SSE2 alignment requirements shared by the primary LMatrix4 class.
|
|
||||||
*
|
|
||||||
* Use it only when you need to pack numbers tightly without respect to
|
|
||||||
* alignment, and then copy it to a proper LMatrix4 to get actual use from it.
|
|
||||||
*/
|
|
||||||
class EXPCL_PANDA_LINMATH FLOATNAME(UnalignedLMatrix4) {
|
|
||||||
PUBLISHED:
|
|
||||||
enum {
|
|
||||||
num_components = 16
|
|
||||||
};
|
|
||||||
|
|
||||||
INLINE_LINMATH FLOATNAME(UnalignedLMatrix4)() = default;
|
|
||||||
INLINE_LINMATH FLOATNAME(UnalignedLMatrix4)(const FLOATNAME(LMatrix4) ©);
|
|
||||||
INLINE_LINMATH FLOATNAME(UnalignedLMatrix4)(const FLOATNAME(UnalignedLMatrix4) ©) = default;
|
|
||||||
INLINE_LINMATH FLOATNAME(UnalignedLMatrix4) &operator = (const FLOATNAME(LMatrix4) ©);
|
|
||||||
INLINE_LINMATH FLOATNAME(UnalignedLMatrix4) &operator = (const FLOATNAME(UnalignedLMatrix4) ©) = default;
|
|
||||||
INLINE_LINMATH FLOATNAME(UnalignedLMatrix4)(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e03,
|
|
||||||
FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12, FLOATTYPE e13,
|
|
||||||
FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22, FLOATTYPE e23,
|
|
||||||
FLOATTYPE e30, FLOATTYPE e31, FLOATTYPE e32, FLOATTYPE e33);
|
|
||||||
|
|
||||||
INLINE_LINMATH void set(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e03,
|
|
||||||
FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12, FLOATTYPE e13,
|
|
||||||
FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22, FLOATTYPE e23,
|
|
||||||
FLOATTYPE e30, FLOATTYPE e31, FLOATTYPE e32, FLOATTYPE e33);
|
|
||||||
|
|
||||||
INLINE_LINMATH FLOATTYPE &operator () (int row, int col);
|
|
||||||
INLINE_LINMATH FLOATTYPE operator () (int row, int col) const;
|
|
||||||
|
|
||||||
INLINE_LINMATH const FLOATTYPE *get_data() const;
|
|
||||||
INLINE_LINMATH int get_num_components() const;
|
|
||||||
|
|
||||||
INLINE_LINMATH bool operator == (const FLOATNAME(UnalignedLMatrix4) &other) const;
|
|
||||||
INLINE_LINMATH bool operator != (const FLOATNAME(UnalignedLMatrix4) &other) const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
typedef UNALIGNED_LINMATH_MATRIX(FLOATTYPE, 4, 4) UMatrix4;
|
|
||||||
UMatrix4 _m;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static TypeHandle get_class_type() {
|
|
||||||
return _type_handle;
|
|
||||||
}
|
|
||||||
static void init_type();
|
|
||||||
|
|
||||||
private:
|
|
||||||
static TypeHandle _type_handle;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
INLINE std::ostream &operator << (std::ostream &out, const FLOATNAME(LMatrix4) &mat) {
|
INLINE std::ostream &operator << (std::ostream &out, const FLOATNAME(LMatrix4) &mat) {
|
||||||
mat.output(out);
|
mat.output(out);
|
||||||
return out;
|
return out;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
INLINE_LINMATH FLOATNAME(LVecBase4)::
|
INLINE_LINMATH FLOATNAME(LVecBase4)::
|
||||||
FLOATNAME(LVecBase4)(const FLOATNAME(UnalignedLVecBase4) ©) {
|
FLOATNAME(LVecBase4)(const FLOATNAME(LVecBase4) ©) {
|
||||||
set(copy[0], copy[1], copy[2], copy[3]);
|
set(copy[0], copy[1], copy[2], copy[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -894,99 +894,3 @@ read_datagram(DatagramIterator &source) {
|
||||||
_v(3) = source.get_stdfloat();
|
_v(3) = source.get_stdfloat();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH FLOATNAME(UnalignedLVecBase4)::
|
|
||||||
FLOATNAME(UnalignedLVecBase4)(const FLOATNAME(LVecBase4) ©) {
|
|
||||||
set(copy[0], copy[1], copy[2], copy[3]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH FLOATNAME(UnalignedLVecBase4)::
|
|
||||||
FLOATNAME(UnalignedLVecBase4)(FLOATTYPE fill_value) {
|
|
||||||
fill(fill_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH FLOATNAME(UnalignedLVecBase4)::
|
|
||||||
FLOATNAME(UnalignedLVecBase4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w) {
|
|
||||||
TAU_PROFILE("UnalignedLVecBase4::UnalignedLVecBase4(FLOATTYPE, ...)", " ", TAU_USER);
|
|
||||||
set(x, y, z, w);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets each element of the vector to the indicated fill_value. This is
|
|
||||||
* particularly useful for initializing to zero.
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH void FLOATNAME(UnalignedLVecBase4)::
|
|
||||||
fill(FLOATTYPE fill_value) {
|
|
||||||
TAU_PROFILE("void UnalignedLVecBase4::fill()", " ", TAU_USER);
|
|
||||||
_v(0) = fill_value;
|
|
||||||
_v(1) = fill_value;
|
|
||||||
_v(2) = fill_value;
|
|
||||||
_v(3) = fill_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH void FLOATNAME(UnalignedLVecBase4)::
|
|
||||||
set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w) {
|
|
||||||
TAU_PROFILE("void UnalignedLVecBase4::set()", " ", TAU_USER);
|
|
||||||
_v(0) = x;
|
|
||||||
_v(1) = y;
|
|
||||||
_v(2) = z;
|
|
||||||
_v(3) = w;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH FLOATTYPE FLOATNAME(UnalignedLVecBase4)::
|
|
||||||
operator [](int i) const {
|
|
||||||
nassertr(i >= 0 && i < 4, 0);
|
|
||||||
return _v(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH FLOATTYPE &FLOATNAME(UnalignedLVecBase4)::
|
|
||||||
operator [](int i) {
|
|
||||||
nassertr(i >= 0 && i < 4, _v(0));
|
|
||||||
return _v(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the address of the first of the three data elements in the vector.
|
|
||||||
* The remaining elements occupy the next positions consecutively in memory.
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH const FLOATTYPE *FLOATNAME(UnalignedLVecBase4)::
|
|
||||||
get_data() const {
|
|
||||||
return &_v(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH bool FLOATNAME(UnalignedLVecBase4)::
|
|
||||||
operator == (const FLOATNAME(UnalignedLVecBase4) &other) const {
|
|
||||||
return (_v(0) == other._v(0) &&
|
|
||||||
_v(1) == other._v(1) &&
|
|
||||||
_v(2) == other._v(2) &&
|
|
||||||
_v(3) == other._v(3));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
INLINE_LINMATH bool FLOATNAME(UnalignedLVecBase4)::
|
|
||||||
operator != (const FLOATNAME(UnalignedLVecBase4) &other) const {
|
|
||||||
return !operator == (other);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TypeHandle FLOATNAME(LVecBase4)::_type_handle;
|
TypeHandle FLOATNAME(LVecBase4)::_type_handle;
|
||||||
TypeHandle FLOATNAME(UnalignedLVecBase4)::_type_handle;
|
|
||||||
|
|
||||||
const FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::_zero =
|
const FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::_zero =
|
||||||
FLOATNAME(LVecBase4)(0, 0, 0, 0);
|
FLOATNAME(LVecBase4)(0, 0, 0, 0);
|
||||||
|
|
@ -35,15 +34,3 @@ init_type() {
|
||||||
register_type(_type_handle, FLOATNAME_STR(LVecBase4));
|
register_type(_type_handle, FLOATNAME_STR(LVecBase4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void FLOATNAME(UnalignedLVecBase4)::
|
|
||||||
init_type() {
|
|
||||||
if (_type_handle == TypeHandle::none()) {
|
|
||||||
// Format a string to describe the type.
|
|
||||||
register_type(_type_handle, FLOATNAME_STR(UnalignedLVecBase4));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ class FLOATNAME(LVecBase2);
|
||||||
class FLOATNAME(LVecBase3);
|
class FLOATNAME(LVecBase3);
|
||||||
class FLOATNAME(LPoint3);
|
class FLOATNAME(LPoint3);
|
||||||
class FLOATNAME(LVector3);
|
class FLOATNAME(LVector3);
|
||||||
class FLOATNAME(UnalignedLVecBase4);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the base class for all three-component vectors and points.
|
* This is the base class for all three-component vectors and points.
|
||||||
|
|
@ -39,7 +38,7 @@ PUBLISHED:
|
||||||
INLINE_LINMATH FLOATNAME(LVecBase4)() = default;
|
INLINE_LINMATH FLOATNAME(LVecBase4)() = default;
|
||||||
INLINE_LINMATH FLOATNAME(LVecBase4)(FLOATTYPE fill_value);
|
INLINE_LINMATH FLOATNAME(LVecBase4)(FLOATTYPE fill_value);
|
||||||
INLINE_LINMATH FLOATNAME(LVecBase4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w);
|
INLINE_LINMATH FLOATNAME(LVecBase4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w);
|
||||||
INLINE_LINMATH FLOATNAME(LVecBase4)(const FLOATNAME(UnalignedLVecBase4) ©);
|
INLINE_LINMATH FLOATNAME(LVecBase4)(const FLOATNAME(LVecBase4) ©);
|
||||||
INLINE_LINMATH explicit FLOATNAME(LVecBase4)(const FLOATNAME(LVecBase3) ©, FLOATTYPE w);
|
INLINE_LINMATH explicit FLOATNAME(LVecBase4)(const FLOATNAME(LVecBase3) ©, FLOATTYPE w);
|
||||||
INLINE_LINMATH FLOATNAME(LVecBase4)(const FLOATNAME(LPoint3) &point);
|
INLINE_LINMATH FLOATNAME(LVecBase4)(const FLOATNAME(LPoint3) &point);
|
||||||
INLINE_LINMATH FLOATNAME(LVecBase4)(const FLOATNAME(LVector3) &vector);
|
INLINE_LINMATH FLOATNAME(LVecBase4)(const FLOATNAME(LVector3) &vector);
|
||||||
|
|
@ -194,8 +193,6 @@ public:
|
||||||
|
|
||||||
// Unlike LVecBase2 and LVecBase3, we fully align LVecBase4 to 16-byte
|
// Unlike LVecBase2 and LVecBase3, we fully align LVecBase4 to 16-byte
|
||||||
// boundaries, to take advantage of SSE2 optimizations when available.
|
// boundaries, to take advantage of SSE2 optimizations when available.
|
||||||
// Sometimes this alignment requirement is inconvenient, so we also provide
|
|
||||||
// UnalignedLVecBase4, below.
|
|
||||||
typedef LINMATH_MATRIX(FLOATTYPE, 1, 4) EVector4;
|
typedef LINMATH_MATRIX(FLOATTYPE, 1, 4) EVector4;
|
||||||
EVector4 _v;
|
EVector4 _v;
|
||||||
|
|
||||||
|
|
@ -218,60 +215,6 @@ private:
|
||||||
static TypeHandle _type_handle;
|
static TypeHandle _type_handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* This is an "unaligned" LVecBase4. It has no functionality other than to
|
|
||||||
* store numbers, and it will pack them in as tightly as possible, avoiding
|
|
||||||
* any SSE2 alignment requirements shared by the primary LVecBase4 class.
|
|
||||||
*
|
|
||||||
* Use it only when you need to pack numbers tightly without respect to
|
|
||||||
* alignment, and then copy it to a proper LVecBase4 to get actual use from
|
|
||||||
* it.
|
|
||||||
*/
|
|
||||||
class EXPCL_PANDA_LINMATH FLOATNAME(UnalignedLVecBase4) {
|
|
||||||
PUBLISHED:
|
|
||||||
enum {
|
|
||||||
num_components = 4,
|
|
||||||
|
|
||||||
#ifdef FLOATTYPE_IS_INT
|
|
||||||
is_int = 1
|
|
||||||
#else
|
|
||||||
is_int = 0
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
INLINE_LINMATH FLOATNAME(UnalignedLVecBase4)() = default;
|
|
||||||
INLINE_LINMATH FLOATNAME(UnalignedLVecBase4)(const FLOATNAME(LVecBase4) ©);
|
|
||||||
INLINE_LINMATH FLOATNAME(UnalignedLVecBase4)(FLOATTYPE fill_value);
|
|
||||||
INLINE_LINMATH FLOATNAME(UnalignedLVecBase4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w);
|
|
||||||
|
|
||||||
INLINE_LINMATH void fill(FLOATTYPE fill_value);
|
|
||||||
INLINE_LINMATH void set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w);
|
|
||||||
|
|
||||||
INLINE_LINMATH FLOATTYPE operator [](int i) const;
|
|
||||||
INLINE_LINMATH FLOATTYPE &operator [](int i);
|
|
||||||
constexpr static int size() { return 4; }
|
|
||||||
|
|
||||||
INLINE_LINMATH const FLOATTYPE *get_data() const;
|
|
||||||
constexpr static int get_num_components() { return 4; }
|
|
||||||
|
|
||||||
INLINE_LINMATH bool operator == (const FLOATNAME(UnalignedLVecBase4) &other) const;
|
|
||||||
INLINE_LINMATH bool operator != (const FLOATNAME(UnalignedLVecBase4) &other) const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
typedef FLOATTYPE numeric_type;
|
|
||||||
typedef UNALIGNED_LINMATH_MATRIX(FLOATTYPE, 1, 4) UVector4;
|
|
||||||
UVector4 _v;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static TypeHandle get_class_type() {
|
|
||||||
return _type_handle;
|
|
||||||
}
|
|
||||||
static void init_type();
|
|
||||||
|
|
||||||
private:
|
|
||||||
static TypeHandle _type_handle;
|
|
||||||
};
|
|
||||||
|
|
||||||
INLINE std::ostream &operator << (std::ostream &out, const FLOATNAME(LVecBase4) &vec) {
|
INLINE std::ostream &operator << (std::ostream &out, const FLOATNAME(LVecBase4) &vec) {
|
||||||
vec.output(out);
|
vec.output(out);
|
||||||
return out;
|
return out;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue