leave lvecbase2/3 and lmatrix3 unaligned; it's so much cleaner

This commit is contained in:
David Rose 2011-12-19 14:17:26 +00:00
parent 66a52cb6a3
commit 42e8f806f1
60 changed files with 163 additions and 854 deletions

View File

@ -407,7 +407,7 @@ write_datagram(BamWriter *manager, Datagram &me) {
// Now, write out the joint angles. For these we need to build up
// a HPR array.
pvector<UnalignedLVecBase3> hprs;
pvector<LVecBase3> hprs;
int hprs_length = max(max(_tables[6].size(), _tables[7].size()), _tables[8].size());
hprs.reserve(hprs_length);
for (i = 0; i < hprs_length; i++) {
@ -416,7 +416,7 @@ write_datagram(BamWriter *manager, Datagram &me) {
PN_stdfloat r = _tables[8].empty() ? 0.0f : _tables[8][i % _tables[8].size()];
hprs.push_back(LVecBase3(h, p, r));
}
const UnalignedLVecBase3 *hprs_array = NULL;
const LVecBase3 *hprs_array = NULL;
if (hprs_length != 0) {
hprs_array = &hprs[0];
}
@ -518,7 +518,7 @@ fillin(DatagramIterator &scan, BamReader *manager) {
}
// Read in the HPR array and store it back in the joint angles.
pvector<UnalignedLVecBase3> hprs;
pvector<LVecBase3> hprs;
compressor.read_hprs(scan, hprs, new_hpr);
PTA_stdfloat h_table = PTA_stdfloat::empty_array(hprs.size(), get_class_type());
PTA_stdfloat p_table = PTA_stdfloat::empty_array(hprs.size(), get_class_type());

View File

@ -51,6 +51,7 @@ PUBLISHED:
INLINE LPoint3 get_point(int n) const;
MAKE_SEQ(get_points, get_num_points, get_point);
INLINE static bool verify_points(const LPoint3 &a, const LPoint3 &b,
const LPoint3 &c);
INLINE static bool verify_points(const LPoint3 &a, const LPoint3 &b,

View File

@ -1328,7 +1328,7 @@ compare_collider_to_geom(CollisionEntry &entry, const Geom *geom,
// Indexed case.
GeomVertexReader index(tris->get_vertices(), 0);
while (!index.is_at_end()) {
UnalignedLVecBase3 v[3];
LPoint3 v[3];
vertex.set_row_unsafe(index.get_data1i());
v[0] = vertex.get_data3();
@ -1339,7 +1339,7 @@ compare_collider_to_geom(CollisionEntry &entry, const Geom *geom,
// Generate a temporary CollisionGeom on the fly for each
// triangle in the Geom.
if (CollisionPolygon::verify_points(LVecBase3(v[0]), LVecBase3(v[1]), LVecBase3(v[2]))) {
if (CollisionPolygon::verify_points(v[0], v[1], v[2])) {
bool within_solid_bounds = true;
if (from_node_gbv != (GeometricBoundingVolume *)NULL) {
PT(BoundingSphere) sphere = new BoundingSphere;
@ -1361,7 +1361,7 @@ compare_collider_to_geom(CollisionEntry &entry, const Geom *geom,
vertex.set_row_unsafe(primitive->get_first_vertex());
int num_vertices = primitive->get_num_vertices();
for (int i = 0; i < num_vertices; i += 3) {
UnalignedLVecBase3 v[3];
LPoint3 v[3];
v[0] = vertex.get_data3();
v[1] = vertex.get_data3();
@ -1369,7 +1369,7 @@ compare_collider_to_geom(CollisionEntry &entry, const Geom *geom,
// Generate a temporary CollisionGeom on the fly for each
// triangle in the Geom.
if (CollisionPolygon::verify_points(LVecBase3(v[0]), LVecBase3(v[1]), LVecBase3(v[2]))) {
if (CollisionPolygon::verify_points(v[0], v[1], v[2])) {
bool within_solid_bounds = true;
if (from_node_gbv != (GeometricBoundingVolume *)NULL) {
PT(BoundingSphere) sphere = new BoundingSphere;

View File

@ -132,7 +132,7 @@ compute_internal_bounds() const {
if (vec.normalize()) {
// The bounding volume includes both endpoints, plus a little
// bit more to include the radius in both directions.
UnalignedLVecBase3 points[2];
LPoint3 points[2];
points[0] = _a - vec * _radius;
points[1] = _b + vec * _radius;

View File

@ -140,7 +140,7 @@ public:
MesherStatus _status;
bool _planar;
UnalignedLVecBase3d _plane_normal;
LNormald _plane_normal;
PN_stdfloat _plane_offset;
int _row_id, _row_distance;
MesherOrigin _origin;

View File

@ -281,7 +281,9 @@ ConfigVariableInt vertex_column_alignment
"alignment requirements on a per-column basis as you construct a "
"GeomVertexFormat. Setting this value globally could result in "
"much needless wasted space in all vertex data objects, but it "
"could be useful for simple experiments."));
"could be useful for simple experiments. Also see "
"egg-vertex-animation-align-16 for a variable that controls "
"this alignment for the vertex-animation columns only."));
ConfigVariableEnum<AutoTextureScale> textures_power_2
("textures-power-2", ATS_down,

View File

@ -120,10 +120,7 @@ typedef LTexCoord3f LTexCoord3;
typedef LColorf LColor;
typedef LRGBColorf LRGBColor;
typedef UnalignedLVecBase2f UnalignedLVecBase2;
typedef UnalignedLVecBase3f UnalignedLVecBase3;
typedef UnalignedLVecBase4f UnalignedLVecBase4;
typedef UnalignedLMatrix3f UnalignedLMatrix3;
typedef UnalignedLMatrix4f UnalignedLMatrix4;
// Bogus typedefs for interrogate and legacy Python code.
@ -167,10 +164,7 @@ typedef LTexCoord3d LTexCoord3;
typedef LColord LColor;
typedef LRGBColord LRGBColor;
typedef UnalignedLVecBase2d UnalignedLVecBase2;
typedef UnalignedLVecBase3d UnalignedLVecBase3;
typedef UnalignedLVecBase4d UnalignedLVecBase4;
typedef UnalignedLMatrix3d UnalignedLMatrix3;
typedef UnalignedLMatrix4d UnalignedLMatrix4;
// Bogus typedefs for interrogate and legacy Python code.

View File

@ -71,10 +71,7 @@ init_liblinmath() {
LPoint4f::init_type();
LMatrix3f::init_type();
LMatrix4f::init_type();
UnalignedLVecBase2f::init_type();
UnalignedLVecBase3f::init_type();
UnalignedLVecBase4f::init_type();
UnalignedLMatrix3f::init_type();
UnalignedLMatrix4f::init_type();
LVecBase2d::init_type();
@ -88,10 +85,7 @@ init_liblinmath() {
LPoint4d::init_type();
LMatrix3d::init_type();
LMatrix4d::init_type();
UnalignedLVecBase2d::init_type();
UnalignedLVecBase3d::init_type();
UnalignedLVecBase4d::init_type();
UnalignedLMatrix3d::init_type();
UnalignedLMatrix4d::init_type();
LQuaternionf::init_type();

View File

@ -115,16 +115,6 @@ INLINE_LINMATH FLOATNAME(LMatrix3)::
FLOATNAME(LMatrix3)(const FLOATNAME(LMatrix3) &copy) : _m(copy._m) {
}
////////////////////////////////////////////////////////////////////
// Function: LMatrix3::Copy Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(LMatrix3)::
FLOATNAME(LMatrix3)(const FLOATNAME(UnalignedLMatrix3) &copy) {
operator = (copy);
}
////////////////////////////////////////////////////////////////////
// Function: LMatrix3::Copy Assignment Operator
// Access: Published
@ -138,19 +128,6 @@ operator = (const FLOATNAME(LMatrix3) &copy) {
return *this;
}
////////////////////////////////////////////////////////////////////
// Function: LMatrix3::Copy Assignment Operator
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3)::
operator = (const FLOATNAME(UnalignedLMatrix3) &copy) {
TAU_PROFILE("void LMatrix3::operator = (const UnalignedLMatrix3 &)", " ", TAU_USER);
memcpy(&_m(0, 0), copy.get_data(), sizeof(FLOATTYPE) * get_num_components());
return *this;
}
////////////////////////////////////////////////////////////////////
// Function: LMatrix3::Fill Assignment Operator
// Access: Published
@ -1517,134 +1494,3 @@ invert(const FLOATNAME(LMatrix3) &a) {
#endif
return result;
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLMatrix3::Default Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(UnalignedLMatrix3)::
FLOATNAME(UnalignedLMatrix3)() {
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLMatrix3::Copy Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(UnalignedLMatrix3)::
FLOATNAME(UnalignedLMatrix3)(const FLOATNAME(LMatrix3) &copy) {
operator = (copy);
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLMatrix3::Copy Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(UnalignedLMatrix3)::
FLOATNAME(UnalignedLMatrix3)(const FLOATNAME(UnalignedLMatrix3) &copy) : _m(copy._m) {
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLMatrix3::Copy Assignment Operator
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(UnalignedLMatrix3) &FLOATNAME(UnalignedLMatrix3)::
operator = (const FLOATNAME(LMatrix3) &copy) {
memcpy(&_m(0, 0), copy.get_data(), sizeof(FLOATTYPE) * get_num_components());
return *this;
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLMatrix3::Copy Assignment Operator
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(UnalignedLMatrix3) &FLOATNAME(UnalignedLMatrix3)::
operator = (const FLOATNAME(UnalignedLMatrix3) &copy) {
TAU_PROFILE("void UnalignedLMatrix3::operator =(UnalignedLMatrix3 &)", " ", TAU_USER);
_m = copy._m;
return *this;
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLMatrix3::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(UnalignedLMatrix3)::
FLOATNAME(UnalignedLMatrix3)(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02,
FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12,
FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22) {
TAU_PROFILE("UnalignedLMatrix3::UnalignedLMatrix3(FLOATTYPE, ...)", " ", TAU_USER);
set(e00, e01, e02,
e10, e11, e12,
e20, e21, e22);
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLMatrix3::set
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH void FLOATNAME(UnalignedLMatrix3)::
set(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02,
FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12,
FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22) {
TAU_PROFILE("void UnalignedLMatrix3::set()", " ", TAU_USER);
_m(0, 0) = e00;
_m(0, 1) = e01;
_m(0, 2) = e02;
_m(1, 0) = e10;
_m(1, 1) = e11;
_m(1, 2) = e12;
_m(2, 0) = e20;
_m(2, 1) = e21;
_m(2, 2) = e22;
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLMatrix3::Indexing operator
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATTYPE &FLOATNAME(UnalignedLMatrix3)::
operator () (int row, int col) {
nassertr(row >= 0 && row < 3 && col >= 0 && col < 3, _m(0, 0));
return _m(row, col);
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLMatrix3::Indexing operator
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATTYPE FLOATNAME(UnalignedLMatrix3)::
operator () (int row, int col) const {
nassertr(row >= 0 && row < 3 && col >= 0 && col < 3, 0.0);
return _m(row, col);
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLMatrix3::get_data
// Access: Published
// Description: 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(UnalignedLMatrix3)::
get_data() const {
return &_m(0, 0);
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLMatrix3::get_num_components
// Access: Published
// Description: Returns the number of elements in the matrix, nine.
////////////////////////////////////////////////////////////////////
INLINE_LINMATH int FLOATNAME(UnalignedLMatrix3)::
get_num_components() const {
return 9;
}

View File

@ -13,7 +13,6 @@
////////////////////////////////////////////////////////////////////
TypeHandle FLOATNAME(LMatrix3)::_type_handle;
TypeHandle FLOATNAME(UnalignedLMatrix3)::_type_handle;
const FLOATNAME(LMatrix3) FLOATNAME(LMatrix3)::_ident_mat =
FLOATNAME(LMatrix3)(1.0f, 0.0f, 0.0f,
@ -515,18 +514,3 @@ init_type() {
register_type(_type_handle, name);
}
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLMatrix3::init_type
// Access: Published, Static
// Description:
////////////////////////////////////////////////////////////////////
void FLOATNAME(UnalignedLMatrix3)::
init_type() {
if (_type_handle == TypeHandle::none()) {
// Format a string to describe the type.
string name = "UnalignedLMatrix3";
name += FLOATTOKEN;
register_type(_type_handle, name);
}
}

View File

@ -13,7 +13,6 @@
////////////////////////////////////////////////////////////////////
class FLOATNAME(LMatrix4);
class FLOATNAME(UnalignedLMatrix3);
////////////////////////////////////////////////////////////////////
// Class : LMatrix3
@ -23,7 +22,7 @@ class FLOATNAME(UnalignedLMatrix3);
// (rotation, scale, translation) in 2-d, e.g. for a
// texture matrix.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_LINMATH ALIGN_LINMATH FLOATNAME(LMatrix3) {
class EXPCL_PANDA_LINMATH FLOATNAME(LMatrix3) {
public:
typedef const FLOATTYPE *iterator;
typedef const FLOATTYPE *const_iterator;
@ -55,11 +54,8 @@ PUBLISHED:
INLINE_LINMATH FLOATNAME(LMatrix3)();
INLINE_LINMATH FLOATNAME(LMatrix3)(const FLOATNAME(LMatrix3) &other);
INLINE_LINMATH FLOATNAME(LMatrix3)(const FLOATNAME(UnalignedLMatrix3) &other);
INLINE_LINMATH FLOATNAME(LMatrix3) &operator = (
const FLOATNAME(LMatrix3) &other);
INLINE_LINMATH FLOATNAME(LMatrix3) &operator = (
const FLOATNAME(UnalignedLMatrix3) &other);
INLINE_LINMATH FLOATNAME(LMatrix3) &operator = (FLOATTYPE fill_value);
INLINE_LINMATH FLOATNAME(LMatrix3)(
FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02,
@ -300,7 +296,10 @@ PUBLISHED:
public:
// The underlying implementation is via the Eigen library, if available.
typedef LINMATH_MATRIX(FLOATTYPE, 3, 3) EMatrix3;
// We don't bother to align LMatrix3, since it won't benefit from
// SSE2 optimizations anyway (it's an add number of floats).
typedef UNALIGNED_LINMATH_MATRIX(FLOATTYPE, 3, 3) EMatrix3;
EMatrix3 _m;
INLINE_LINMATH FLOATNAME(LMatrix3)(const EMatrix3 &m) : _m(m) { }
@ -324,54 +323,6 @@ private:
static TypeHandle _type_handle;
};
////////////////////////////////////////////////////////////////////
// Class : UnalignedLMatrix3
// Description : This is an "unaligned" LMatrix3. 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
// LMatrix3 class.
//
// Use it only when you need to pack numbers tightly
// without respect to alignment, and then copy it to a
// proper LMatrix3 to get actual use from it.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_LINMATH FLOATNAME(UnalignedLMatrix3) {
PUBLISHED:
INLINE_LINMATH FLOATNAME(UnalignedLMatrix3)();
INLINE_LINMATH FLOATNAME(UnalignedLMatrix3)(const FLOATNAME(LMatrix3) &copy);
INLINE_LINMATH FLOATNAME(UnalignedLMatrix3)(const FLOATNAME(UnalignedLMatrix3) &copy);
INLINE_LINMATH FLOATNAME(UnalignedLMatrix3) &operator = (const FLOATNAME(LMatrix3) &copy);
INLINE_LINMATH FLOATNAME(UnalignedLMatrix3) &operator = (const FLOATNAME(UnalignedLMatrix3) &copy);
INLINE_LINMATH FLOATNAME(UnalignedLMatrix3)(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02,
FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12,
FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22);
INLINE_LINMATH void set(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02,
FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12,
FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22);
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;
public:
typedef SIMPLE_MATRIX(FLOATTYPE, 3, 3) UMatrix3;
UMatrix3 _m;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type();
private:
static TypeHandle _type_handle;
};
INLINE ostream &operator << (ostream &out, const FLOATNAME(LMatrix3) &mat) {
mat.output(out);
return out;

View File

@ -263,6 +263,11 @@ PUBLISHED:
public:
// The underlying implementation is via the Eigen library, if available.
// Unlike LMatrix3, we fully align LMatrix4 to 16-byte boundaries,
// to take advantage of SSE2 optimizations when available.
// Sometimes this alignment requirement is inconvenient, so we also
// provide UnalignedLMatrix4, below.
typedef LINMATH_MATRIX(FLOATTYPE, 4, 4) EMatrix4;
EMatrix4 _m;
@ -328,7 +333,7 @@ PUBLISHED:
INLINE_LINMATH int get_num_components() const;
public:
typedef SIMPLE_MATRIX(FLOATTYPE, 4, 4) UMatrix4;
typedef UNALIGNED_LINMATH_MATRIX(FLOATTYPE, 4, 4) UMatrix4;
UMatrix4 _m;
public:

View File

@ -18,7 +18,7 @@ class FLOATNAME(LRotation);
// Class : LOrientation
// Description : This is a unit quaternion representing an orientation.
////////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_LINMATH ALIGN_LINMATH FLOATNAME(LOrientation) : public FLOATNAME(LQuaternion) {
class EXPCL_PANDA_LINMATH FLOATNAME(LOrientation) : public FLOATNAME(LQuaternion) {
PUBLISHED:
INLINE_LINMATH FLOATNAME(LOrientation)();
INLINE_LINMATH FLOATNAME(LOrientation)(const FLOATNAME(LQuaternion)&);

View File

@ -17,7 +17,7 @@
// Class : LPoint2
// Description : This is a two-component point in space.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_LINMATH ALIGN_LINMATH FLOATNAME(LPoint2) : public FLOATNAME(LVecBase2) {
class EXPCL_PANDA_LINMATH FLOATNAME(LPoint2) : public FLOATNAME(LVecBase2) {
PUBLISHED:
INLINE_LINMATH FLOATNAME(LPoint2)();
INLINE_LINMATH FLOATNAME(LPoint2)(const FLOATNAME(LVecBase2) &copy);

View File

@ -22,7 +22,7 @@
// vector, while addition of a vector and a point yields
// a point.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_LINMATH ALIGN_LINMATH FLOATNAME(LPoint3) : public FLOATNAME(LVecBase3) {
class EXPCL_PANDA_LINMATH FLOATNAME(LPoint3) : public FLOATNAME(LVecBase3) {
PUBLISHED:
INLINE_LINMATH FLOATNAME(LPoint3)();
INLINE_LINMATH FLOATNAME(LPoint3)(const FLOATNAME(LVecBase3) &copy);

View File

@ -16,7 +16,7 @@
// Class : LPoint4
// Description : This is a four-component point in space.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_LINMATH ALIGN_LINMATH FLOATNAME(LPoint4) : public FLOATNAME(LVecBase4) {
class EXPCL_PANDA_LINMATH FLOATNAME(LPoint4) : public FLOATNAME(LVecBase4) {
PUBLISHED:
INLINE_LINMATH FLOATNAME(LPoint4)();
INLINE_LINMATH FLOATNAME(LPoint4)(const FLOATNAME(LVecBase4) &copy);

View File

@ -16,7 +16,7 @@
// Class : FLOATNAME(LQuaternion)
// Description : This is the base quaternion class
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_LINMATH ALIGN_LINMATH FLOATNAME(LQuaternion) : public FLOATNAME(LVecBase4) {
class EXPCL_PANDA_LINMATH FLOATNAME(LQuaternion) : public FLOATNAME(LVecBase4) {
PUBLISHED:
INLINE_LINMATH FLOATNAME(LQuaternion)();
INLINE_LINMATH FLOATNAME(LQuaternion)(const FLOATNAME(LVecBase4) &copy);

View File

@ -16,7 +16,7 @@
// Class : LRotation
// Description : This is a unit quaternion representing a rotation.
////////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_LINMATH ALIGN_LINMATH FLOATNAME(LRotation) : public FLOATNAME(LQuaternion) {
class EXPCL_PANDA_LINMATH FLOATNAME(LRotation) : public FLOATNAME(LQuaternion) {
PUBLISHED:
INLINE_LINMATH FLOATNAME(LRotation)();
INLINE_LINMATH FLOATNAME(LRotation)(const FLOATNAME(LQuaternion) &);

View File

@ -47,18 +47,19 @@ private:
// Now, do we actually use LSimpleMatrix, or do we use Eigen::Matrix?
#ifdef HAVE_EIGEN
#define UNALIGNED_LINMATH_MATRIX(FloatType, NumRows, NumCols) Eigen::Matrix<FloatType, NumRows, NumCols, Eigen::DontAlign | Eigen::RowMajor>
#ifdef LINMATH_ALIGN
#define LINMATH_MATRIX(FloatType, NumRows, NumCols) Eigen::Matrix<FloatType, NumRows, NumCols, Eigen::RowMajor>
#else // LINMATH_ALIGN
#define LINMATH_MATRIX(FloatType, NumRows, NumCols) Eigen::Matrix<FloatType, NumRows, NumCols, Eigen::DontAlign | Eigen::RowMajor>
#define LINMATH_MATRIX(FloatType, NumRows, NumCols) UNALIGNED_LINMATH_MATRIX(FloatType, NumRows, NumCols)
#endif // LINMATH_ALIGN
#else // HAVE_EIGEN
#define LINMATH_MATRIX(FloatType, NumRows, NumCols) LSimpleMatrix<FloatType, NumRows, NumCols>
#define UNALIGNED_LINMATH_MATRIX(FloatType, NumRows, NumCols) LSimpleMatrix<FloatType, NumRows, NumCols>
#define LINMATH_MATRIX(FloatType, NumRows, NumCols) UNALIGNED_LINMATH_MATRIX(FloatType, NumRows, NumCols)
#endif // HAVE_EIGEN
#define SIMPLE_MATRIX(FloatType, NumRows, NumCols) LSimpleMatrix<FloatType, NumRows, NumCols>
// This is as good a place as any to define this alignment macro.
#ifdef LINMATH_ALIGN
#define ALIGN_LINMATH ALIGN_16BYTE

View File

@ -187,14 +187,3 @@ __setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
return 0;
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase2::__setitem__
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE void EXT_METHOD_ARGS(FLOATNAME(UnalignedLVecBase2),
__setitem__, int i, FLOATTYPE v) {
nassertv(i >= 0 && i < 2);
this->_v(i) = v;
}

View File

@ -31,16 +31,6 @@ INLINE_LINMATH FLOATNAME(LVecBase2)::
FLOATNAME(LVecBase2)(const FLOATNAME(LVecBase2) &copy) : _v(copy._v) {
}
////////////////////////////////////////////////////////////////////
// Function: LVecBase2::Copy Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(LVecBase2)::
FLOATNAME(LVecBase2)(const FLOATNAME(UnalignedLVecBase2) &copy) {
set(copy[0], copy[1]);
}
////////////////////////////////////////////////////////////////////
// Function: LVecBase2::Copy Assignment Operator
// Access: Published
@ -53,17 +43,6 @@ operator = (const FLOATNAME(LVecBase2) &copy) {
return *this;
}
////////////////////////////////////////////////////////////////////
// Function: LVecBase2::Copy Assignment Operator
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(LVecBase2) &FLOATNAME(LVecBase2)::
operator = (const FLOATNAME(UnalignedLVecBase2) &copy) {
set(copy[0], copy[1]);
return *this;
}
////////////////////////////////////////////////////////////////////
// Function: LVecBase2::Fill Assignment Operator
// Access: Published
@ -837,131 +816,3 @@ read_datagram(DatagramIterator &source) {
_v(0) = source.get_stdfloat();
_v(1) = source.get_stdfloat();
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase2::Default Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(UnalignedLVecBase2)::
FLOATNAME(UnalignedLVecBase2)() {
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase2::Copy Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(UnalignedLVecBase2)::
FLOATNAME(UnalignedLVecBase2)(const FLOATNAME(LVecBase2) &copy) {
set(copy[0], copy[1]);
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase2::Copy Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(UnalignedLVecBase2)::
FLOATNAME(UnalignedLVecBase2)(const FLOATNAME(UnalignedLVecBase2) &copy) : _v(copy._v) {
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase2::Copy Assignment Operator
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(UnalignedLVecBase2) &FLOATNAME(UnalignedLVecBase2)::
operator = (const FLOATNAME(LVecBase2) &copy) {
set(copy[0], copy[1]);
return *this;
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase2::Copy Assignment Operator
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(UnalignedLVecBase2) &FLOATNAME(UnalignedLVecBase2)::
operator = (const FLOATNAME(UnalignedLVecBase2) &copy) {
TAU_PROFILE("void UnalignedLVecBase2::operator =(UnalignedLVecBase2 &)", " ", TAU_USER);
_v = copy._v;
return *this;
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase2::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(UnalignedLVecBase2)::
FLOATNAME(UnalignedLVecBase2)(FLOATTYPE x, FLOATTYPE y) {
TAU_PROFILE("UnalignedLVecBase2::UnalignedLVecBase2(FLOATTYPE, ...)", " ", TAU_USER);
set(x, y);
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase2::set
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH void FLOATNAME(UnalignedLVecBase2)::
set(FLOATTYPE x, FLOATTYPE y) {
TAU_PROFILE("void UnalignedLVecBase2::set()", " ", TAU_USER);
_v(0) = x;
_v(1) = y;
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase2::Indexing Operator
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATTYPE FLOATNAME(UnalignedLVecBase2)::
operator [](int i) const {
nassertr(i >= 0 && i < 2, 0.0);
return _v(i);
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase2::Indexing Operator
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATTYPE &FLOATNAME(UnalignedLVecBase2)::
operator [](int i) {
nassertr(i >= 0 && i < 2, _v(0));
return _v(i);
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase2::size
// Access: Public, Static
// Description: Returns 2: the number of components of a LVecBase2.
////////////////////////////////////////////////////////////////////
INLINE_LINMATH int FLOATNAME(UnalignedLVecBase2)::
size() {
return 2;
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase2::get_data
// Access: Public
// Description: 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(UnalignedLVecBase2)::
get_data() const {
return &_v(0);
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase2::get_num_components
// Access: Public
// Description: Returns the number of elements in the vector, 2.
////////////////////////////////////////////////////////////////////
INLINE_LINMATH int FLOATNAME(UnalignedLVecBase2)::
get_num_components() const {
return 2;
}

View File

@ -13,7 +13,6 @@
////////////////////////////////////////////////////////////////////
TypeHandle FLOATNAME(LVecBase2)::_type_handle;
TypeHandle FLOATNAME(UnalignedLVecBase2)::_type_handle;
const FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::_zero =
FLOATNAME(LVecBase2)(0.0f, 0.0f);
@ -36,19 +35,3 @@ init_type() {
register_type(_type_handle, name);
}
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase2::init_type
// Access: Public, Static
// Description:
////////////////////////////////////////////////////////////////////
void FLOATNAME(UnalignedLVecBase2)::
init_type() {
if (_type_handle == TypeHandle::none()) {
// Format a string to describe the type.
string name = "UnalignedLVecBase2";
name += FLOATTOKEN;
register_type(_type_handle, name);
}
}

View File

@ -13,23 +13,19 @@
////////////////////////////////////////////////////////////////////
class FLOATNAME(UnalignedLVecBase2);
////////////////////////////////////////////////////////////////////
// Class : LVecBase2
// Description : This is the base class for all two-component
// vectors and points.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_LINMATH ALIGN_LINMATH FLOATNAME(LVecBase2) {
class EXPCL_PANDA_LINMATH FLOATNAME(LVecBase2) {
PUBLISHED:
typedef const FLOATTYPE *iterator;
typedef const FLOATTYPE *const_iterator;
INLINE_LINMATH FLOATNAME(LVecBase2)();
INLINE_LINMATH FLOATNAME(LVecBase2)(const FLOATNAME(LVecBase2) &copy);
INLINE_LINMATH FLOATNAME(LVecBase2)(const FLOATNAME(UnalignedLVecBase2) &copy);
INLINE_LINMATH FLOATNAME(LVecBase2) &operator = (const FLOATNAME(LVecBase2) &copy);
INLINE_LINMATH FLOATNAME(LVecBase2) &operator = (const FLOATNAME(UnalignedLVecBase2) &copy);
INLINE_LINMATH FLOATNAME(LVecBase2) &operator = (FLOATTYPE fill_value);
INLINE_LINMATH FLOATNAME(LVecBase2)(FLOATTYPE fill_value);
INLINE_LINMATH FLOATNAME(LVecBase2)(FLOATTYPE x, FLOATTYPE y);
@ -138,7 +134,15 @@ PUBLISHED:
public:
// The underlying implementation is via the Eigen library, if available.
typedef LINMATH_MATRIX(FLOATTYPE, 1, 2) EVector2;
// We don't bother to align LVecBase2. The float version is too
// small to benefit from SSE2 optimizations. The double version
// *would* benefit, but we use this class infrequently throughout
// the Panda codebase, and the nuisance value of maintaining aligned
// and unaligned versions of this class outweighs the benefits of
// having SSE2 optimizations in the stdfloat-double compilation
// mode.
typedef UNALIGNED_LINMATH_MATRIX(FLOATTYPE, 1, 2) EVector2;
EVector2 _v;
INLINE_LINMATH FLOATNAME(LVecBase2)(const EVector2 &v) : _v(v) { }
@ -158,53 +162,6 @@ private:
static TypeHandle _type_handle;
};
////////////////////////////////////////////////////////////////////
// Class : UnalignedLVecBase2
// Description : This is an "unaligned" LVecBase2. 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
// LVecBase2 class.
//
// Use it only when you need to pack numbers tightly
// without respect to alignment, and then copy it to a
// proper LVecBase2 to get actual use from it.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_LINMATH FLOATNAME(UnalignedLVecBase2) {
PUBLISHED:
INLINE_LINMATH FLOATNAME(UnalignedLVecBase2)();
INLINE_LINMATH FLOATNAME(UnalignedLVecBase2)(const FLOATNAME(LVecBase2) &copy);
INLINE_LINMATH FLOATNAME(UnalignedLVecBase2)(const FLOATNAME(UnalignedLVecBase2) &copy);
INLINE_LINMATH FLOATNAME(UnalignedLVecBase2) &operator = (const FLOATNAME(LVecBase2) &copy);
INLINE_LINMATH FLOATNAME(UnalignedLVecBase2) &operator = (const FLOATNAME(UnalignedLVecBase2) &copy);
INLINE_LINMATH FLOATNAME(UnalignedLVecBase2)(FLOATTYPE x, FLOATTYPE y);
INLINE_LINMATH void set(FLOATTYPE x, FLOATTYPE y);
INLINE_LINMATH FLOATTYPE operator [](int i) const;
INLINE_LINMATH FLOATTYPE &operator [](int i);
EXTENSION(INLINE_LINMATH void __setitem__(int i, FLOATTYPE v));
INLINE_LINMATH static int size();
INLINE_LINMATH const FLOATTYPE *get_data() const;
INLINE_LINMATH int get_num_components() const;
public:
typedef SIMPLE_MATRIX(FLOATTYPE, 1, 2) UVector2;
UVector2 _v;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type();
private:
static TypeHandle _type_handle;
};
INLINE ostream &operator << (ostream &out, const FLOATNAME(LVecBase2) &vec) {
vec.output(out);
return out;

View File

@ -189,14 +189,3 @@ __setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
return 0;
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase3::__setitem__
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE void EXT_METHOD_ARGS(FLOATNAME(UnalignedLVecBase3),
__setitem__, int i, FLOATTYPE v) {
nassertv(i >= 0 && i < 3);
this->_v(i) = v;
}

View File

@ -30,16 +30,6 @@ INLINE_LINMATH FLOATNAME(LVecBase3)::
FLOATNAME(LVecBase3)(const FLOATNAME(LVecBase3) &copy) : _v(copy._v) {
}
////////////////////////////////////////////////////////////////////
// Function: LVecBase3::Copy Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(LVecBase3)::
FLOATNAME(LVecBase3)(const FLOATNAME(UnalignedLVecBase3) &copy) {
set(copy[0], copy[1], copy[2]);
}
////////////////////////////////////////////////////////////////////
// Function: LVecBase3::Copy Assignment Operator
// Access: Public
@ -52,17 +42,6 @@ operator = (const FLOATNAME(LVecBase3) &copy) {
return *this;
}
////////////////////////////////////////////////////////////////////
// Function: LVecBase3::Copy Assignment Operator
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(LVecBase3) &FLOATNAME(LVecBase3)::
operator = (const FLOATNAME(UnalignedLVecBase3) &copy) {
set(copy[0], copy[1], copy[2]);
return *this;
}
////////////////////////////////////////////////////////////////////
// Function: LVecBase3::Fill Assignment Operator
// Access: Public
@ -1016,132 +995,3 @@ read_datagram(DatagramIterator &source) {
_v(1) = source.get_stdfloat();
_v(2) = source.get_stdfloat();
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase3::Default Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(UnalignedLVecBase3)::
FLOATNAME(UnalignedLVecBase3)() {
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase3::Copy Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(UnalignedLVecBase3)::
FLOATNAME(UnalignedLVecBase3)(const FLOATNAME(LVecBase3) &copy) {
set(copy[0], copy[1], copy[2]);
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase3::Copy Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(UnalignedLVecBase3)::
FLOATNAME(UnalignedLVecBase3)(const FLOATNAME(UnalignedLVecBase3) &copy) : _v(copy._v) {
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase3::Copy Assignment Operator
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(UnalignedLVecBase3) &FLOATNAME(UnalignedLVecBase3)::
operator = (const FLOATNAME(LVecBase3) &copy) {
set(copy[0], copy[1], copy[2]);
return *this;
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase3::Copy Assignment Operator
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(UnalignedLVecBase3) &FLOATNAME(UnalignedLVecBase3)::
operator = (const FLOATNAME(UnalignedLVecBase3) &copy) {
TAU_PROFILE("void UnalignedLVecBase3::operator =(UnalignedLVecBase3 &)", " ", TAU_USER);
_v = copy._v;
return *this;
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase3::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(UnalignedLVecBase3)::
FLOATNAME(UnalignedLVecBase3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) {
TAU_PROFILE("UnalignedLVecBase3::UnalignedLVecBase3(FLOATTYPE, ...)", " ", TAU_USER);
set(x, y, z);
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase3::set
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH void FLOATNAME(UnalignedLVecBase3)::
set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) {
TAU_PROFILE("void UnalignedLVecBase3::set()", " ", TAU_USER);
_v(0) = x;
_v(1) = y;
_v(2) = z;
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase3::Indexing Operator
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATTYPE FLOATNAME(UnalignedLVecBase3)::
operator [](int i) const {
nassertr(i >= 0 && i < 3, 0.0);
return _v(i);
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase3::Indexing Operator
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATTYPE &FLOATNAME(UnalignedLVecBase3)::
operator [](int i) {
nassertr(i >= 0 && i < 3, _v(0));
return _v(i);
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase3::size
// Access: Public, Static
// Description: Returns 3: the number of components of a LVecBase3.
////////////////////////////////////////////////////////////////////
INLINE_LINMATH int FLOATNAME(UnalignedLVecBase3)::
size() {
return 3;
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase3::get_data
// Access: Public
// Description: 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(UnalignedLVecBase3)::
get_data() const {
return &_v(0);
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase3::get_num_components
// Access: Public
// Description: Returns the number of elements in the vector, 3.
////////////////////////////////////////////////////////////////////
INLINE_LINMATH int FLOATNAME(UnalignedLVecBase3)::
get_num_components() const {
return 3;
}

View File

@ -14,7 +14,6 @@
TypeHandle FLOATNAME(LVecBase3)::_type_handle;
TypeHandle FLOATNAME(UnalignedLVecBase3)::_type_handle;
const FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::_zero =
FLOATNAME(LVecBase3)(0.0f, 0.0f, 0.0f);
@ -40,19 +39,3 @@ init_type() {
}
}
////////////////////////////////////////////////////////////////////
// Function: UnalignedLVecBase3::init_type
// Access: Public, Static
// Description:
////////////////////////////////////////////////////////////////////
void FLOATNAME(UnalignedLVecBase3)::
init_type() {
if (_type_handle == TypeHandle::none()) {
// Format a string to describe the type.
string name = "UnalignedLVecBase3";
name += FLOATTOKEN;
register_type(_type_handle, name);
}
}

View File

@ -13,23 +13,19 @@
////////////////////////////////////////////////////////////////////
class FLOATNAME(UnalignedLVecBase3);
////////////////////////////////////////////////////////////////////
// Class : LVecBase3
// Description : This is the base class for all three-component
// vectors and points.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_LINMATH ALIGN_LINMATH FLOATNAME(LVecBase3) {
class EXPCL_PANDA_LINMATH FLOATNAME(LVecBase3) {
PUBLISHED:
typedef const FLOATTYPE *iterator;
typedef const FLOATTYPE *const_iterator;
INLINE_LINMATH FLOATNAME(LVecBase3)();
INLINE_LINMATH FLOATNAME(LVecBase3)(const FLOATNAME(LVecBase3) &copy);
INLINE_LINMATH FLOATNAME(LVecBase3)(const FLOATNAME(UnalignedLVecBase3) &copy);
INLINE_LINMATH FLOATNAME(LVecBase3) &operator = (const FLOATNAME(LVecBase3) &copy);
INLINE_LINMATH FLOATNAME(LVecBase3) &operator = (const FLOATNAME(UnalignedLVecBase3) &copy);
INLINE_LINMATH FLOATNAME(LVecBase3) &operator = (FLOATTYPE fill_value);
INLINE_LINMATH FLOATNAME(LVecBase3)(FLOATTYPE fill_value);
INLINE_LINMATH FLOATNAME(LVecBase3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z);
@ -151,7 +147,10 @@ PUBLISHED:
public:
// The underlying implementation is via the Eigen library, if available.
typedef LINMATH_MATRIX(FLOATTYPE, 1, 3) EVector3;
// We don't bother to align LVecBase3, since it won't benefit from
// SSE2 optimizations anyway (it's an add number of floats).
typedef UNALIGNED_LINMATH_MATRIX(FLOATTYPE, 1, 3) EVector3;
EVector3 _v;
INLINE_LINMATH FLOATNAME(LVecBase3)(const EVector3 &v) : _v(v) { }
@ -173,53 +172,6 @@ private:
};
////////////////////////////////////////////////////////////////////
// Class : UnalignedLVecBase3
// Description : This is an "unaligned" LVecBase3. 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
// LVecBase3 class.
//
// Use it only when you need to pack numbers tightly
// without respect to alignment, and then copy it to a
// proper LVecBase3 to get actual use from it.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_LINMATH FLOATNAME(UnalignedLVecBase3) {
PUBLISHED:
INLINE_LINMATH FLOATNAME(UnalignedLVecBase3)();
INLINE_LINMATH FLOATNAME(UnalignedLVecBase3)(const FLOATNAME(LVecBase3) &copy);
INLINE_LINMATH FLOATNAME(UnalignedLVecBase3)(const FLOATNAME(UnalignedLVecBase3) &copy);
INLINE_LINMATH FLOATNAME(UnalignedLVecBase3) &operator = (const FLOATNAME(LVecBase3) &copy);
INLINE_LINMATH FLOATNAME(UnalignedLVecBase3) &operator = (const FLOATNAME(UnalignedLVecBase3) &copy);
INLINE_LINMATH FLOATNAME(UnalignedLVecBase3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z);
INLINE_LINMATH void set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z);
INLINE_LINMATH FLOATTYPE operator [](int i) const;
INLINE_LINMATH FLOATTYPE &operator [](int i);
EXTENSION(INLINE_LINMATH void __setitem__(int i, FLOATTYPE v));
INLINE_LINMATH static int size();
INLINE_LINMATH const FLOATTYPE *get_data() const;
INLINE_LINMATH int get_num_components() const;
public:
typedef SIMPLE_MATRIX(FLOATTYPE, 1, 3) UVector3;
UVector3 _v;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type();
private:
static TypeHandle _type_handle;
};
INLINE ostream &operator << (ostream &out, const FLOATNAME(LVecBase3) &vec) {
vec.output(out);
return out;

View File

@ -147,6 +147,11 @@ PUBLISHED:
public:
// The underlying implementation is via the Eigen library, if available.
// Unlike LVecBase2 and LVecBase3, we fully align LVecBase4 to
// 16-byte 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;
EVector4 _v;
@ -202,7 +207,7 @@ PUBLISHED:
INLINE_LINMATH int get_num_components() const;
public:
typedef SIMPLE_MATRIX(FLOATTYPE, 1, 4) UVector4;
typedef UNALIGNED_LINMATH_MATRIX(FLOATTYPE, 1, 4) UVector4;
UVector4 _v;
public:

View File

@ -16,7 +16,7 @@
// Class : LVector2
// Description : This is a two-component vector offset.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_LINMATH ALIGN_LINMATH FLOATNAME(LVector2) : public FLOATNAME(LVecBase2) {
class EXPCL_PANDA_LINMATH FLOATNAME(LVector2) : public FLOATNAME(LVecBase2) {
PUBLISHED:
INLINE_LINMATH FLOATNAME(LVector2)();
INLINE_LINMATH FLOATNAME(LVector2)(const FLOATNAME(LVecBase2) &copy);

View File

@ -22,7 +22,7 @@
// vector, while addition of a vector and a point yields
// a point.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_LINMATH ALIGN_LINMATH FLOATNAME(LVector3) : public FLOATNAME(LVecBase3) {
class EXPCL_PANDA_LINMATH FLOATNAME(LVector3) : public FLOATNAME(LVecBase3) {
PUBLISHED:
INLINE_LINMATH FLOATNAME(LVector3)();
INLINE_LINMATH FLOATNAME(LVector3)(const FLOATNAME(LVecBase3) &copy);

View File

@ -16,7 +16,7 @@
// Class : LVector4
// Description : This is a four-component vector distance.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_LINMATH ALIGN_LINMATH FLOATNAME(LVector4) : public FLOATNAME(LVecBase4) {
class EXPCL_PANDA_LINMATH FLOATNAME(LVector4) : public FLOATNAME(LVecBase4) {
PUBLISHED:
INLINE_LINMATH FLOATNAME(LVector4)();
INLINE_LINMATH FLOATNAME(LVector4)(const FLOATNAME(LVecBase4) &copy);

View File

@ -284,16 +284,16 @@ extend_by_finite(const FiniteBoundingVolume *volume) {
// Description:
////////////////////////////////////////////////////////////////////
bool BoundingBox::
around_points(const UnalignedLVecBase3 *first, const UnalignedLVecBase3 *last) {
around_points(const LPoint3 *first, const LPoint3 *last) {
nassertr(first != last, false);
// Get the minmax of all the points to construct a bounding box.
const UnalignedLVecBase3 *p = first;
const LPoint3 *p = first;
#ifndef NDEBUG
// Skip any NaN points.
int skipped_nan = 0;
while (p != last && LPoint3(*p).is_nan()) {
while (p != last && (*p).is_nan()) {
++p;
++skipped_nan;
}
@ -310,7 +310,7 @@ around_points(const UnalignedLVecBase3 *first, const UnalignedLVecBase3 *last) {
#ifndef NDEBUG
// Skip more NaN points.
while (p != last && LPoint3(*p).is_nan()) {
while (p != last && (*p).is_nan()) {
++p;
++skipped_nan;
}
@ -319,7 +319,7 @@ around_points(const UnalignedLVecBase3 *first, const UnalignedLVecBase3 *last) {
while (p != last) {
#ifndef NDEBUG
// Skip more NaN points.
if (LPoint3(*p).is_nan()) {
if ((*p).is_nan()) {
++skipped_nan;
} else
#endif

View File

@ -76,8 +76,8 @@ protected:
virtual bool extend_by_hexahedron(const BoundingHexahedron *hexahedron);
bool extend_by_finite(const FiniteBoundingVolume *volume);
virtual bool around_points(const UnalignedLVecBase3 *first,
const UnalignedLVecBase3 *last);
virtual bool around_points(const LPoint3 *first,
const LPoint3 *last);
virtual bool around_spheres(const BoundingVolume **first,
const BoundingVolume **last);
virtual bool around_boxes(const BoundingVolume **first,

View File

@ -297,17 +297,17 @@ extend_by_finite(const FiniteBoundingVolume *volume) {
// Description:
////////////////////////////////////////////////////////////////////
bool BoundingSphere::
around_points(const UnalignedLVecBase3 *first, const UnalignedLVecBase3 *last) {
around_points(const LPoint3 *first, const LPoint3 *last) {
nassertr(first != last, false);
// First, get the box of all the points to construct a bounding
// box.
const UnalignedLVecBase3 *p = first;
const LPoint3 *p = first;
#ifndef NDEBUG
// Skip any NaN points.
int skipped_nan = 0;
while (p != last && LPoint3(*p).is_nan()) {
while (p != last && (*p).is_nan()) {
++p;
++skipped_nan;
}
@ -324,7 +324,7 @@ around_points(const UnalignedLVecBase3 *first, const UnalignedLVecBase3 *last) {
#ifndef NDEBUG
// Skip more NaN points.
while (p != last && LPoint3(*p).is_nan()) {
while (p != last && (*p).is_nan()) {
++p;
++skipped_nan;
}
@ -342,7 +342,7 @@ around_points(const UnalignedLVecBase3 *first, const UnalignedLVecBase3 *last) {
while (p != last) {
#ifndef NDEBUG
// Skip more NaN points.
if (LPoint3(*p).is_nan()) {
if ((*p).is_nan()) {
++skipped_nan;
} else
#endif
@ -363,7 +363,7 @@ around_points(const UnalignedLVecBase3 *first, const UnalignedLVecBase3 *last) {
// Now walk back through to get the max distance from center.
PN_stdfloat max_dist2 = 0.0f;
for (p = first; p != last; ++p) {
LVector3 v = LPoint3(*p) - _center;
LVector3 v = (*p) - _center;
PN_stdfloat dist2 = dot(v, v);
max_dist2 = max(max_dist2, dist2);
}

View File

@ -64,8 +64,8 @@ protected:
virtual bool extend_by_hexahedron(const BoundingHexahedron *hexahedron);
bool extend_by_finite(const FiniteBoundingVolume *volume);
virtual bool around_points(const UnalignedLVecBase3 *first,
const UnalignedLVecBase3 *last);
virtual bool around_points(const LPoint3 *first,
const LPoint3 *last);
virtual bool around_spheres(const BoundingVolume **first,
const BoundingVolume **last);
virtual bool around_boxes(const BoundingVolume **first,

View File

@ -7,8 +7,8 @@ forcetype PointerToArrayBase<UnalignedLMatrix4f>
forcetype PTA_LMatrix4f
forcetype CPTA_LMatrix4f
forcetype PointerToBase<ReferenceCountedVector<UnalignedLMatrix3f> >
forcetype PointerToArrayBase<UnalignedLMatrix3f>
forcetype PointerToBase<ReferenceCountedVector<LMatrix3f> >
forcetype PointerToArrayBase<LMatrix3f>
forcetype PTA_LMatrix3f
forcetype CPTA_LMatrix3f
@ -17,13 +17,13 @@ forcetype PointerToArrayBase<UnalignedLVecBase4f>
forcetype PTA_LVecBase4f
forcetype CPTA_LVecBase4f
forcetype PointerToBase<ReferenceCountedVector<UnalignedLVecBase3f> >
forcetype PointerToArrayBase<UnalignedLVecBase3f>
forcetype PointerToBase<ReferenceCountedVector<LVecBase3f> >
forcetype PointerToArrayBase<LVecBase3f>
forcetype PTA_LVecBase3f
forcetype CPTA_LVecBase3f
forcetype PointerToBase<ReferenceCountedVector<UnalignedLVecBase2f> >
forcetype PointerToArrayBase<UnalignedLVecBase2f>
forcetype PointerToBase<ReferenceCountedVector<LVecBase2f> >
forcetype PointerToArrayBase<LVecBase2f>
forcetype PTA_LVecBase2f
forcetype CPTA_LVecBase2f
@ -32,8 +32,8 @@ forcetype PointerToArrayBase<UnalignedLMatrix4d>
forcetype PTA_LMatrix4d
forcetype CPTA_LMatrix4d
forcetype PointerToBase<ReferenceCountedVector<UnalignedLMatrix3d> >
forcetype PointerToArrayBase<UnalignedLMatrix3d>
forcetype PointerToBase<ReferenceCountedVector<LMatrix3d> >
forcetype PointerToArrayBase<LMatrix3d>
forcetype PTA_LMatrix3d
forcetype CPTA_LMatrix3d
@ -42,12 +42,12 @@ forcetype PointerToArrayBase<UnalignedLVecBase4d>
forcetype PTA_LVecBase4d
forcetype CPTA_LVecBase4d
forcetype PointerToBase<ReferenceCountedVector<UnalignedLVecBase3d> >
forcetype PointerToArrayBase<UnalignedLVecBase3d>
forcetype PointerToBase<ReferenceCountedVector<LVecBase3d> >
forcetype PointerToArrayBase<LVecBase3d>
forcetype PTA_LVecBase3d
forcetype CPTA_LVecBase3d
forcetype PointerToBase<ReferenceCountedVector<UnalignedLVecBase2d> >
forcetype PointerToArrayBase<UnalignedLVecBase2d>
forcetype PointerToBase<ReferenceCountedVector<LVecBase2d> >
forcetype PointerToArrayBase<LVecBase2d>
forcetype PTA_LVecBase2d
forcetype CPTA_LVecBase2d

View File

@ -389,7 +389,7 @@ write_reals(Datagram &datagram, const PN_stdfloat *array, int length) {
// datagram.
////////////////////////////////////////////////////////////////////
void FFTCompressor::
write_hprs(Datagram &datagram, const UnalignedLVecBase3 *array, int length) {
write_hprs(Datagram &datagram, const LVecBase3 *array, int length) {
#ifndef NDEBUG
if (_quality >= 104) {
// If quality level is at least 104, we don't even convert hpr at
@ -689,7 +689,7 @@ read_reals(DatagramIterator &di, vector_stdfloat &array) {
// calculation. See temp_hpr_fix.
////////////////////////////////////////////////////////////////////
bool FFTCompressor::
read_hprs(DatagramIterator &di, pvector<UnalignedLVecBase3> &array, bool new_hpr) {
read_hprs(DatagramIterator &di, pvector<LVecBase3> &array, bool new_hpr) {
#ifndef NDEBUG
if (_quality >= 104) {
// If quality level is at least 104, we don't even convert hpr to
@ -819,7 +819,7 @@ read_hprs(DatagramIterator &di, pvector<UnalignedLVecBase3> &array, bool new_hpr
// ensure that the array is initially empty.
////////////////////////////////////////////////////////////////////
bool FFTCompressor::
read_hprs(DatagramIterator &di, pvector<UnalignedLVecBase3> &array) {
read_hprs(DatagramIterator &di, pvector<LVecBase3> &array) {
return read_hprs(di, array, temp_hpr_fix);
}

View File

@ -59,13 +59,13 @@ public:
void write_header(Datagram &datagram);
void write_reals(Datagram &datagram, const PN_stdfloat *array, int length);
void write_hprs(Datagram &datagram, const UnalignedLVecBase3 *array, int length);
void write_hprs(Datagram &datagram, const LVecBase3 *array, int length);
bool read_header(DatagramIterator &di, int bam_minor_version);
bool read_reals(DatagramIterator &di, vector_stdfloat &array);
bool read_hprs(DatagramIterator &di, pvector<UnalignedLVecBase3> &array,
bool read_hprs(DatagramIterator &di, pvector<LVecBase3> &array,
bool new_hpr);
bool read_hprs(DatagramIterator &di, pvector<UnalignedLVecBase3> &array);
bool read_hprs(DatagramIterator &di, pvector<LVecBase3> &array);
static void free_storage();

View File

@ -63,7 +63,7 @@ around(const GeometricBoundingVolume **first,
// indicated.
////////////////////////////////////////////////////////////////////
INLINE_MATHUTIL bool GeometricBoundingVolume::
around(const UnalignedLVecBase3 *first, const UnalignedLVecBase3 *last) {
around(const LPoint3 *first, const LPoint3 *last) {
_flags = F_empty;
if (first != last) {
return around_points(first, last);

View File

@ -47,7 +47,7 @@ extend_by_point(const LPoint3 &) {
// identified by an STL-style begin/end list.
////////////////////////////////////////////////////////////////////
bool GeometricBoundingVolume::
around_points(const UnalignedLVecBase3 *, const UnalignedLVecBase3 *) {
around_points(const LPoint3 *, const LPoint3 *) {
_flags = F_empty;
return false;
}

View File

@ -41,8 +41,7 @@ PUBLISHED:
// impossible for virtual functions.
INLINE_MATHUTIL bool around(const GeometricBoundingVolume **first,
const GeometricBoundingVolume **last);
INLINE_MATHUTIL bool around(const UnalignedLVecBase3 *first,
const UnalignedLVecBase3 *last);
INLINE_MATHUTIL bool around(const LPoint3 *first, const LPoint3 *last);
INLINE_MATHUTIL int contains(const GeometricBoundingVolume *vol) const;
INLINE_MATHUTIL int contains(const LPoint3 &point) const;
@ -59,8 +58,8 @@ protected:
// operations on points in 3-d space.
virtual bool extend_by_point(const LPoint3 &point);
virtual bool around_points(const UnalignedLVecBase3 *first,
const UnalignedLVecBase3 *last);
virtual bool around_points(const LPoint3 *first,
const LPoint3 *last);
virtual int contains_point(const LPoint3 &point) const;
virtual int contains_lineseg(const LPoint3 &a, const LPoint3 &b) const;

View File

@ -139,7 +139,7 @@ extend_by_hexahedron(const BoundingHexahedron *) {
// Description:
////////////////////////////////////////////////////////////////////
bool OmniBoundingVolume::
around_points(const UnalignedLVecBase3 *, const UnalignedLVecBase3 *) {
around_points(const LPoint3 *, const LPoint3 *) {
return true;
}

View File

@ -49,8 +49,8 @@ protected:
virtual bool extend_by_box(const BoundingBox *box);
virtual bool extend_by_hexahedron(const BoundingHexahedron *hexahedron);
virtual bool around_points(const UnalignedLVecBase3 *first,
const UnalignedLVecBase3 *last);
virtual bool around_points(const LPoint3 *first,
const LPoint3 *last);
virtual bool around_spheres(const BoundingVolume **first,
const BoundingVolume **last);
virtual bool around_boxes(const BoundingVolume **first,

View File

@ -26,19 +26,15 @@
// to use a pta of this type (whether they need to
// export it or not) should include this header file,
// rather than defining the pta again.
//
// We actually wrap UnalignedLMatrix3f, in case we are
// building with SSE2 and LMatrix3f requires strict
// alignment.
////////////////////////////////////////////////////////////////////
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase<ReferenceCountedVector<UnalignedLMatrix3f> >)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase<UnalignedLMatrix3f>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArray<UnalignedLMatrix3f>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerToArray<UnalignedLMatrix3f>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase<ReferenceCountedVector<LMatrix3f> >)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase<LMatrix3f>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArray<LMatrix3f>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerToArray<LMatrix3f>)
typedef PointerToArray<UnalignedLMatrix3f> PTA_LMatrix3f;
typedef ConstPointerToArray<UnalignedLMatrix3f> CPTA_LMatrix3f;
typedef PointerToArray<LMatrix3f> PTA_LMatrix3f;
typedef ConstPointerToArray<LMatrix3f> CPTA_LMatrix3f;
////////////////////////////////////////////////////////////////////
// Class : PTA_LMatrix3d
@ -47,19 +43,15 @@ typedef ConstPointerToArray<UnalignedLMatrix3f> CPTA_LMatrix3f;
// to use a pta of this type (whether they need to
// export it or not) should include this header file,
// rather than defining the pta again.
//
// We actually wrap UnalignedLMatrix3d, in case we are
// building with SSE2 and LMatrix3d requires strict
// alignment.
////////////////////////////////////////////////////////////////////
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase<ReferenceCountedVector<UnalignedLMatrix3d> >)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase<UnalignedLMatrix3d>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArray<UnalignedLMatrix3d>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerToArray<UnalignedLMatrix3d>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase<ReferenceCountedVector<LMatrix3d> >)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase<LMatrix3d>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArray<LMatrix3d>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerToArray<LMatrix3d>)
typedef PointerToArray<UnalignedLMatrix3d> PTA_LMatrix3d;
typedef ConstPointerToArray<UnalignedLMatrix3d> CPTA_LMatrix3d;
typedef PointerToArray<LMatrix3d> PTA_LMatrix3d;
typedef ConstPointerToArray<LMatrix3d> CPTA_LMatrix3d;
#ifndef STDFLOAT_DOUBLE
typedef PTA_LMatrix3f PTA_LMatrix3;

View File

@ -26,19 +26,15 @@
// to use a pta of this type (whether they need to
// export it or not) should include this header file,
// rather than defining the pta again.
//
// We actually wrap UnalignedLVecBase2f, in case we are
// building with SSE2 and LVecBase2f requires strict
// alignment.
////////////////////////////////////////////////////////////////////
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase<ReferenceCountedVector<UnalignedLVecBase2f> >)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase<UnalignedLVecBase2f>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArray<UnalignedLVecBase2f>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerToArray<UnalignedLVecBase2f>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase<ReferenceCountedVector<LVecBase2f> >)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase<LVecBase2f>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArray<LVecBase2f>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerToArray<LVecBase2f>)
typedef PointerToArray<UnalignedLVecBase2f> PTA_LVecBase2f;
typedef ConstPointerToArray<UnalignedLVecBase2f> CPTA_LVecBase2f;
typedef PointerToArray<LVecBase2f> PTA_LVecBase2f;
typedef ConstPointerToArray<LVecBase2f> CPTA_LVecBase2f;
////////////////////////////////////////////////////////////////////
// Class : PTA_LVecBase2d
@ -47,19 +43,15 @@ typedef ConstPointerToArray<UnalignedLVecBase2f> CPTA_LVecBase2f;
// to use a pta of this type (whether they need to
// export it or not) should include this header file,
// rather than defining the pta again.
//
// We actually wrap UnalignedLVecBase2d, in case we are
// building with SSE2 and LVecBase2d requires strict
// alignment.
////////////////////////////////////////////////////////////////////
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase<ReferenceCountedVector<UnalignedLVecBase2d> >)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase<UnalignedLVecBase2d>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArray<UnalignedLVecBase2d>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerToArray<UnalignedLVecBase2d>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase<ReferenceCountedVector<LVecBase2d> >)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase<LVecBase2d>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArray<LVecBase2d>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerToArray<LVecBase2d>)
typedef PointerToArray<UnalignedLVecBase2d> PTA_LVecBase2d;
typedef ConstPointerToArray<UnalignedLVecBase2d> CPTA_LVecBase2d;
typedef PointerToArray<LVecBase2d> PTA_LVecBase2d;
typedef ConstPointerToArray<LVecBase2d> CPTA_LVecBase2d;
#ifndef STDFLOAT_DOUBLE
typedef PTA_LVecBase2f PTA_LVecBase2;

View File

@ -26,19 +26,15 @@
// to use a pta of this type (whether they need to
// export it or not) should include this header file,
// rather than defining the pta again.
//
// We actually wrap UnalignedLVecBase3f, in case we are
// building with SSE2 and LVecBase3f requires strict
// alignment.
////////////////////////////////////////////////////////////////////
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase<ReferenceCountedVector<UnalignedLVecBase3f> >)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase<UnalignedLVecBase3f>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArray<UnalignedLVecBase3f>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerToArray<UnalignedLVecBase3f>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase<ReferenceCountedVector<LVecBase3f> >)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase<LVecBase3f>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArray<LVecBase3f>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerToArray<LVecBase3f>)
typedef PointerToArray<UnalignedLVecBase3f> PTA_LVecBase3f;
typedef ConstPointerToArray<UnalignedLVecBase3f> CPTA_LVecBase3f;
typedef PointerToArray<LVecBase3f> PTA_LVecBase3f;
typedef ConstPointerToArray<LVecBase3f> CPTA_LVecBase3f;
////////////////////////////////////////////////////////////////////
// Class : PTA_LVecBase3d
@ -47,19 +43,15 @@ typedef ConstPointerToArray<UnalignedLVecBase3f> CPTA_LVecBase3f;
// to use a pta of this type (whether they need to
// export it or not) should include this header file,
// rather than defining the pta again.
//
// We actually wrap UnalignedLVecBase3d, in case we are
// building with SSE2 and LVecBase3d requires strict
// alignment.
////////////////////////////////////////////////////////////////////
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase<ReferenceCountedVector<UnalignedLVecBase3d> >)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase<UnalignedLVecBase3d>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArray<UnalignedLVecBase3d>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerToArray<UnalignedLVecBase3d>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase<ReferenceCountedVector<LVecBase3d> >)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase<LVecBase3d>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArray<LVecBase3d>)
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerToArray<LVecBase3d>)
typedef PointerToArray<UnalignedLVecBase3d> PTA_LVecBase3d;
typedef ConstPointerToArray<UnalignedLVecBase3d> CPTA_LVecBase3d;
typedef PointerToArray<LVecBase3d> PTA_LVecBase3d;
typedef ConstPointerToArray<LVecBase3d> CPTA_LVecBase3d;
#ifndef STDFLOAT_DOUBLE
typedef PTA_LVecBase3f PTA_LVecBase3;

View File

@ -43,10 +43,10 @@ get_num_vertices() const {
// Access: Published
// Description: Returns the nth vertex.
////////////////////////////////////////////////////////////////////
INLINE LPoint2d Triangulator::
INLINE const LPoint2d &Triangulator::
get_vertex(int n) const {
nassertr(n >= 0 && n < (int)_vertices.size(), LPoint2d::zero());
return LPoint2d(_vertices[n]);
return _vertices[n];
}
////////////////////////////////////////////////////////////////////

View File

@ -333,8 +333,8 @@ check_left_winding(const vector_int &range) const {
double area = 0.0;
size_t j = range.size() - 1;
for (size_t i = 0; i < range.size(); ++i) {
const UnalignedLVecBase2d &p0 = _vertices[range[j]];
const UnalignedLVecBase2d &p1 = _vertices[range[i]];
const LPoint2d &p0 = _vertices[range[j]];
const LPoint2d &p1 = _vertices[range[i]];
area += p0[0] * p1[1] - p0[1] * p1[0];
j = i;
}

View File

@ -44,7 +44,7 @@ PUBLISHED:
INLINE int add_vertex(double x, double y);
INLINE int get_num_vertices() const;
INLINE LPoint2d get_vertex(int n) const;
INLINE const LPoint2d &get_vertex(int n) const;
MAKE_SEQ(get_vertices, get_num_vertices, get_vertex);
void clear_polygon();
@ -62,7 +62,7 @@ PUBLISHED:
int get_triangle_v2(int n) const;
private:
typedef pvector<UnalignedLVecBase2d> Vertices;
typedef pvector<LPoint2d> Vertices;
Vertices _vertices;
vector_int _polygon;

View File

@ -82,7 +82,7 @@ PUBLISHED:
public:
typedef epvector<LVecBase4> Vert4Array;
typedef pvector<UnalignedLVecBase3> Vert3Array;
typedef pvector<LPoint3> Vert3Array;
void get_vertices(Vert4Array &verts, const NodePath &rel_to) const;
void get_vertices(Vert3Array &verts, const NodePath &rel_to) const;

View File

@ -84,7 +84,7 @@ PUBLISHED:
public:
typedef epvector<LVecBase4> Vert4Array;
typedef pvector<UnalignedLVecBase3> Vert3Array;
typedef pvector<LPoint3> Vert3Array;
void get_vertices(Vert4Array &verts, const NodePath &rel_to) const;
void get_vertices(Vert3Array &verts, const NodePath &rel_to) const;

View File

@ -47,7 +47,7 @@ get_num_vertices() const {
// Access: Published
// Description: Returns the nth vertex of the occluder polygon.
////////////////////////////////////////////////////////////////////
INLINE LPoint3 OccluderNode::
INLINE const LPoint3 &OccluderNode::
get_vertex(int n) const {
nassertr(n >= 0 && n < (int)_vertices.size(), LPoint3::zero());
return LPoint3(_vertices[n]);

View File

@ -131,7 +131,7 @@ xform(const LMatrix4 &mat) {
for (Vertices::iterator vi = _vertices.begin();
vi != _vertices.end();
++vi) {
(*vi) = LPoint3(*vi) * mat;
(*vi) = (*vi) * mat;
}
}
@ -233,8 +233,8 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds,
// Now actually compute the bounding volume by putting it around all
// of our vertices.
if (!_vertices.empty()) {
const UnalignedLVecBase3 *vertices_begin = &_vertices[0];
const UnalignedLVecBase3 *vertices_end = vertices_begin + _vertices.size();
const LPoint3 *vertices_begin = &_vertices[0];
const LPoint3 *vertices_end = vertices_begin + _vertices.size();
gbv->around(vertices_begin, vertices_end);
}
@ -262,10 +262,7 @@ get_occluder_viz(CullTraverser *trav, CullTraverserData &data) {
(get_name(), GeomVertexFormat::get_v3n3t2(), Geom::UH_static);
// Compute the polygon normal from the first three vertices.
LPoint3 a(_vertices[0]);
LPoint3 b(_vertices[1]);
LPoint3 c(_vertices[2]);
LPlane plane(a, b, c);
LPlane plane(_vertices[0], _vertices[1], _vertices[2]);
LVector3 poly_normal = plane.get_normal();
GeomVertexWriter vertex(vdata, InternalName::get_vertex());
@ -391,7 +388,7 @@ write_datagram(BamWriter *manager, Datagram &dg) {
for (Vertices::const_iterator vi = _vertices.begin();
vi != _vertices.end();
++vi) {
LPoint3(*vi).write_datagram(dg);
(*vi).write_datagram(dg);
}
}

View File

@ -58,7 +58,7 @@ PUBLISHED:
INLINE void set_vertices(const LPoint3 &v0, const LPoint3 &v1,
const LPoint3 &v2, const LPoint3 &v3);
INLINE int get_num_vertices() const;
INLINE LPoint3 get_vertex(int n) const;
INLINE const LPoint3 &get_vertex(int n) const;
MAKE_SEQ(get_vertices, get_num_vertices, get_vertex);
protected:
@ -73,7 +73,7 @@ protected:
private:
bool _double_sided;
PN_stdfloat _min_coverage;
typedef pvector<UnalignedLVecBase3> Vertices;
typedef pvector<LPoint3> Vertices;
Vertices _vertices;
PT(Geom) _occluder_viz, _frame_viz;

View File

@ -158,7 +158,7 @@ get_num_vertices() const {
// Access: Published
// Description: Returns the nth vertex of the portal polygon.
////////////////////////////////////////////////////////////////////
INLINE LPoint3 PortalNode::
INLINE const LPoint3 &PortalNode::
get_vertex(int n) const {
nassertr(n >= 0 && n < (int)_vertices.size(), LPoint3::zero());
return LPoint3(_vertices[n]);

View File

@ -62,7 +62,7 @@ PortalNode(const string &name) :
// to create an arbitrary portal and setup from Python
////////////////////////////////////////////////////////////////////
PortalNode::
PortalNode(const string &name, const LPoint3 &pos, PN_stdfloat scale) :
PortalNode(const string &name, LPoint3 pos, PN_stdfloat scale) :
PandaNode(name),
_from_portal_mask(PortalMask::all_on()),
_into_portal_mask(PortalMask::all_on()),
@ -394,8 +394,8 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds,
// Now actually compute the bounding volume by putting it around all
// of our vertices.
const UnalignedLVecBase3 *vertices_begin = &_vertices[0];
const UnalignedLVecBase3 *vertices_end = vertices_begin + _vertices.size();
const LPoint3 *vertices_begin = &_vertices[0];
const LPoint3 *vertices_end = vertices_begin + _vertices.size();
// Now actually compute the bounding volume by putting it around all
gbv->around(vertices_begin, vertices_end);
@ -452,7 +452,7 @@ write_datagram(BamWriter *manager, Datagram &dg) {
for (Vertices::const_iterator vi = _vertices.begin();
vi != _vertices.end();
++vi) {
LPoint3(*vi).write_datagram(dg);
(*vi).write_datagram(dg);
}
}

View File

@ -34,7 +34,7 @@
class EXPCL_PANDA_PGRAPH PortalNode : public PandaNode {
PUBLISHED:
PortalNode(const string &name);
PortalNode(const string &name, const LPoint3 &pos, PN_stdfloat scale=10.0);
PortalNode(const string &name, LPoint3 pos, PN_stdfloat scale=10.0);
protected:
PortalNode(const PortalNode &copy);
@ -67,7 +67,7 @@ PUBLISHED:
INLINE void add_vertex(const LPoint3 &vertex);
INLINE int get_num_vertices() const;
INLINE LPoint3 get_vertex(int n) const;
INLINE const LPoint3 &get_vertex(int n) const;
MAKE_SEQ(get_vertices, get_num_vertices, get_vertex);
INLINE void set_cell_in(const NodePath &cell);
@ -111,7 +111,7 @@ private:
};
int _flags;
typedef pvector<UnalignedLVecBase3> Vertices;
typedef pvector<LPoint3> Vertices;
Vertices _vertices;
NodePath _cell_in; // This is the cell it resides in

View File

@ -201,7 +201,7 @@ private:
PN_stdfloat &largest_area,
const LVecBase4 *new_frame);
typedef pvector<UnalignedLVecBase2> ClipPoints;
typedef pvector<LVecBase2> ClipPoints;
bool clip_frame(ClipPoints &source_points, const LPlane &plane) const;
protected:

View File

@ -732,7 +732,7 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds,
// measured it.
check_measure();
UnalignedLVecBase3 vertices[8];
LPoint3 vertices[8];
vertices[0].set(_ul3d[0], _ul3d[1], _ul3d[2]);
vertices[1].set(_ul3d[0], _ul3d[1], _lr3d[2]);
vertices[2].set(_ul3d[0], _lr3d[1], _ul3d[2]);

View File

@ -199,7 +199,7 @@ score_reparent_to(EggJointData *new_parent, EggCharacterDb &db) {
// would receive in all frames of all models, were it reparented to
// the indicated joint.
vector_stdfloat i, j, k, a, b, c, x, y, z;
pvector<UnalignedLVecBase3> hprs;
pvector<LVecBase3> hprs;
int num_rows = 0;
int num_models = get_num_models();