Browse Source

integrate Eigen

David Rose 14 years ago
parent
commit
33b9a1e1cf
77 changed files with 2127 additions and 1603 deletions
  1. 14 0
      dtool/Config.pp
  2. 14 0
      dtool/LocalSetup.pp
  3. 3 0
      dtool/Package.pp
  4. 5 2
      dtool/pptempl/Global.pp
  5. 2 2
      dtool/src/dtoolbase/deletedBufferChain.I
  6. 9 4
      dtool/src/dtoolbase/deletedBufferChain.cxx
  7. 6 0
      dtool/src/dtoolbase/deletedBufferChain.h
  8. 7 0
      dtool/src/dtoolbase/dlmalloc_src.cxx
  9. 9 0
      dtool/src/dtoolbase/dtoolbase.h
  10. 36 4
      dtool/src/dtoolbase/memoryHook.I
  11. 3 0
      dtool/src/dtoolbase/memoryHook.cxx
  12. 4 0
      dtool/src/dtoolbase/memoryHook.h
  13. 1 1
      dtool/src/dtoolbase/neverFreeMemory.cxx
  14. 7 4
      dtool/src/dtoolbase/pallocator.T
  15. 6 0
      dtool/src/dtoolbase/ptmalloc2_smp_src.cxx
  16. 6 0
      dtool/src/parser-inc/Dense
  17. 1 1
      dtool/src/parser-inc/Sources.pp
  18. 1 1
      panda/src/audio/audioManager.h
  19. 1 19
      panda/src/char/jointVertexTransform.cxx
  20. 20 20
      panda/src/gobj/shader.I
  21. 1 4
      panda/src/gobj/transformBlend.cxx
  22. 1 20
      panda/src/gobj/vertexTransform.cxx
  23. 10 4
      panda/src/linmath/Sources.pp
  24. 1 0
      panda/src/linmath/aa_luse.h
  25. 28 36
      panda/src/linmath/compose_matrix_src.cxx
  26. 1 0
      panda/src/linmath/config_linmath.h
  27. 29 0
      panda/src/linmath/deg_2_rad.I
  28. 6 4
      panda/src/linmath/deg_2_rad.h
  29. 6 0
      panda/src/linmath/lmat_ops_src.h
  30. 12 12
      panda/src/linmath/lmatrix3_ext_src.I
  31. 289 217
      panda/src/linmath/lmatrix3_src.I
  32. 75 69
      panda/src/linmath/lmatrix3_src.cxx
  33. 7 17
      panda/src/linmath/lmatrix3_src.h
  34. 20 20
      panda/src/linmath/lmatrix4_ext_src.I
  35. 370 288
      panda/src/linmath/lmatrix4_src.I
  36. 75 73
      panda/src/linmath/lmatrix4_src.cxx
  37. 9 13
      panda/src/linmath/lmatrix4_src.h
  38. 1 1
      panda/src/linmath/lorientation_src.h
  39. 5 5
      panda/src/linmath/lpoint2_ext_src.I
  40. 1 1
      panda/src/linmath/lpoint2_src.h
  41. 9 9
      panda/src/linmath/lpoint3_ext_src.I
  42. 3 3
      panda/src/linmath/lpoint3_src.I
  43. 1 1
      panda/src/linmath/lpoint3_src.h
  44. 15 15
      panda/src/linmath/lpoint4_ext_src.I
  45. 1 1
      panda/src/linmath/lpoint4_src.h
  46. 38 38
      panda/src/linmath/lquaternion_src.I
  47. 32 32
      panda/src/linmath/lquaternion_src.cxx
  48. 2 2
      panda/src/linmath/lquaternion_src.h
  49. 1 1
      panda/src/linmath/lrotation_src.h
  50. 91 0
      panda/src/linmath/lsimpleMatrix.I
  51. 69 0
      panda/src/linmath/lsimpleMatrix.h
  52. 15 15
      panda/src/linmath/lvecBase2_ext_src.I
  53. 117 79
      panda/src/linmath/lvecBase2_src.I
  54. 7 8
      panda/src/linmath/lvecBase2_src.h
  55. 16 16
      panda/src/linmath/lvecBase3_ext_src.I
  56. 159 119
      panda/src/linmath/lvecBase3_src.I
  57. 8 7
      panda/src/linmath/lvecBase3_src.h
  58. 18 18
      panda/src/linmath/lvecBase4_ext_src.I
  59. 173 143
      panda/src/linmath/lvecBase4_src.I
  60. 7 6
      panda/src/linmath/lvecBase4_src.h
  61. 12 12
      panda/src/linmath/lvector2_ext_src.I
  62. 1 1
      panda/src/linmath/lvector2_src.I
  63. 1 1
      panda/src/linmath/lvector2_src.h
  64. 13 13
      panda/src/linmath/lvector3_ext_src.I
  65. 4 4
      panda/src/linmath/lvector3_src.I
  66. 1 1
      panda/src/linmath/lvector3_src.h
  67. 15 15
      panda/src/linmath/lvector4_ext_src.I
  68. 1 1
      panda/src/linmath/lvector4_src.h
  69. 121 111
      panda/src/linmath/test_math.cxx
  70. 13 25
      panda/src/mathutil/boundingSphere.cxx
  71. 2 2
      panda/src/mathutil/perlinNoise2.cxx
  72. 3 3
      panda/src/mathutil/perlinNoise3.cxx
  73. 18 18
      panda/src/mathutil/plane_src.I
  74. 20 20
      panda/src/mathutil/plane_src.cxx
  75. 4 7
      panda/src/ode/odeBody.I
  76. 9 9
      panda/src/ode/odeGeom.I
  77. 5 5
      panda/src/ode/odeMass.I

+ 14 - 0
dtool/Config.pp

@@ -317,6 +317,20 @@
 // What is the name of the C# compiler binary?
 // What is the name of the C# compiler binary?
 #define CSHARP csc
 #define CSHARP csc
 
 
+// This defines the include path to the Eigen linear algebra library.
+// If this is provided, Panda will use this library as the fundamental
+// implementation of its own linmath library; otherwise, it will use
+// its own internal implementation.  The primary advantage of using
+// Eigen is SSE2 support, which is only activated if LINMATH_VECTORIZE
+// is also enabled.  (However, activating LINMATH_VECTORIZE does
+// constrain most objects in Panda to 16-byte alignment, which could
+// impact memory usage on very-low-memory platforms.)  Currently
+// experimental.
+#define EIGEN_IPATH 
+#define EIGEN_CFLAGS
+#define HAVE_EIGEN
+#define LINMATH_VECTORIZE 1
+
 // Is Python installed, and should Python interfaces be generated?  If
 // Is Python installed, and should Python interfaces be generated?  If
 // Python is installed, which directory is it in?
 // Python is installed, which directory is it in?
 #define PYTHON_IPATH /usr/include/python2.6
 #define PYTHON_IPATH /usr/include/python2.6

+ 14 - 0
dtool/LocalSetup.pp

@@ -11,6 +11,16 @@
 
 
 #print
 #print
 #print Configuring support for the following optional third-party packages:
 #print Configuring support for the following optional third-party packages:
+#if $[HAVE_EIGEN]
+#print + Eigen linear algebra library
+#if $[LINMATH_VECTORIZE]
+#print +   (vectorization enabled in build)
+#else
+#print -   (vectorization NOT enabled in build)
+#endif
+#else
+#print - Did not find Eigen linear algebra library
+#endif
 #if $[HAVE_OPENSSL]
 #if $[HAVE_OPENSSL]
 #print + OpenSSL
 #print + OpenSSL
 #else
 #else
@@ -262,6 +272,10 @@
 $[cdefine _DEBUG]
 $[cdefine _DEBUG]
 $[cdefine NDEBUG]
 $[cdefine NDEBUG]
 
 
+/* Define if we have Eigen available. */
+$[cdefine HAVE_EIGEN]
+$[cdefine LINMATH_VECTORIZE]
+
 /* Define if we have Python installed.  */
 /* Define if we have Python installed.  */
 $[cdefine HAVE_PYTHON]
 $[cdefine HAVE_PYTHON]
 $[cdefine USE_DEBUG_PYTHON]
 $[cdefine USE_DEBUG_PYTHON]

+ 3 - 0
dtool/Package.pp

@@ -125,6 +125,9 @@
 
 
 // Now evaluate all of our deferred variable definitions from
 // Now evaluate all of our deferred variable definitions from
 // Config.pp.
 // Config.pp.
+#set EIGEN_IPATH $[unixfilename $[EIGEN_IPATH]]
+#set HAVE_EIGEN $[HAVE_EIGEN]
+
 #set PYTHON_IPATH $[unixfilename $[PYTHON_IPATH]]
 #set PYTHON_IPATH $[unixfilename $[PYTHON_IPATH]]
 #set PYTHON_LPATH $[unixfilename $[PYTHON_LPATH]]
 #set PYTHON_LPATH $[unixfilename $[PYTHON_LPATH]]
 #set PYTHON_FPATH $[unixfilename $[PYTHON_FPATH]]
 #set PYTHON_FPATH $[unixfilename $[PYTHON_FPATH]]

+ 5 - 2
dtool/pptempl/Global.pp

@@ -73,6 +73,9 @@
 #define stl_cflags $[STL_CFLAGS]
 #define stl_cflags $[STL_CFLAGS]
 #define stl_libs $[STL_LIBS]
 #define stl_libs $[STL_LIBS]
 
 
+#define eigen_ipath $[wildcard $[EIGEN_IPATH]]
+#define eigen_cflags $[EIGEN_CFLAGS]
+
 #if $[HAVE_PYTHON]
 #if $[HAVE_PYTHON]
   #define python_ipath $[wildcard $[PYTHON_IPATH]]
   #define python_ipath $[wildcard $[PYTHON_IPATH]]
   #define python_lpath $[wildcard $[PYTHON_LPATH]]
   #define python_lpath $[wildcard $[PYTHON_LPATH]]
@@ -672,7 +675,7 @@
 // require.
 // require.
 #defun get_cflags
 #defun get_cflags
   // hack to add stl,python.  should be removed
   // hack to add stl,python.  should be removed
-  #define alt_cflags $[if $[IGNORE_LIB_DEFAULTS_HACK],,$[stl_cflags] $[python_cflags]]
+  #define alt_cflags $[if $[IGNORE_LIB_DEFAULTS_HACK],,$[stl_cflags] $[python_cflags] $[if $[HAVE_EIGEN],$[eigen_cflags]]]
 
 
   #foreach package $[use_packages]
   #foreach package $[use_packages]
     #set alt_cflags $[alt_cflags] $[$[package]_cflags]
     #set alt_cflags $[alt_cflags] $[$[package]_cflags]
@@ -701,7 +704,7 @@
 // names only; the -I switch is not included here.
 // names only; the -I switch is not included here.
 #defun get_ipath
 #defun get_ipath
   // hack to add stl,python.  should be removed
   // hack to add stl,python.  should be removed
-  #define alt_ipath $[if $[IGNORE_LIB_DEFAULTS_HACK],,$[stl_ipath] $[python_ipath] $[tau_ipath]]
+  #define alt_ipath $[if $[IGNORE_LIB_DEFAULTS_HACK],,$[stl_ipath] $[python_ipath] $[tau_ipath] $[if $[HAVE_EIGEN],$[eigen_ipath]]]
 
 
   #foreach package $[use_packages]
   #foreach package $[use_packages]
     #set alt_ipath $[alt_ipath] $[$[package]_ipath]
     #set alt_ipath $[alt_ipath] $[$[package]_ipath]

+ 2 - 2
dtool/src/dtoolbase/deletedBufferChain.I

@@ -59,7 +59,7 @@ node_to_buffer(DeletedBufferChain::ObjectNode *node) {
 #if defined(USE_DELETEDCHAINFLAG) && defined(USE_DELETED_CHAIN)
 #if defined(USE_DELETEDCHAINFLAG) && defined(USE_DELETED_CHAIN)
   // In development mode, we increment the pointer so that the
   // In development mode, we increment the pointer so that the
   // returned data does not overlap our _flag member.
   // returned data does not overlap our _flag member.
-  return (void *)(((AtomicAdjust::Integer *)node) + 1);
+  return (void *)(((char *)node) + _flag_reserved_bytes);
 #else
 #else
   return (void *)node;
   return (void *)node;
 #endif  // NDEBUG
 #endif  // NDEBUG
@@ -75,7 +75,7 @@ buffer_to_node(void *ptr) {
 #if defined(USE_DELETEDCHAINFLAG) && defined(USE_DELETED_CHAIN)
 #if defined(USE_DELETEDCHAINFLAG) && defined(USE_DELETED_CHAIN)
   // In development mode, we decrement the pointer to undo the
   // In development mode, we decrement the pointer to undo the
   // increment we did above.
   // increment we did above.
-  return (ObjectNode *)(((AtomicAdjust::Integer *)ptr) - 1);
+  return (ObjectNode *)(((char *)ptr) - _flag_reserved_bytes);
 #else
 #else
   return (ObjectNode *)ptr;
   return (ObjectNode *)ptr;
 #endif  // NDEBUG
 #endif  // NDEBUG

+ 9 - 4
dtool/src/dtoolbase/deletedBufferChain.cxx

@@ -13,6 +13,11 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
 #include "deletedBufferChain.h"
 #include "deletedBufferChain.h"
+#include "memoryHook.h"
+
+#ifdef USE_DELETEDCHAINFLAG
+size_t DeletedBufferChain::_flag_reserved_bytes = max(MemoryHook::get_memory_alignment(), (size_t)sizeof(AtomicAdjust::Integer));
+#endif  // USE_DELETEDCHAINFLAG
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: DeletedBufferChain::Constructor
 //     Function: DeletedBufferChain::Constructor
@@ -28,8 +33,8 @@ DeletedBufferChain(size_t buffer_size) {
 
 
 #ifdef USE_DELETEDCHAINFLAG
 #ifdef USE_DELETEDCHAINFLAG
   // In development mode, we also need to reserve space for _flag.
   // In development mode, we also need to reserve space for _flag.
-  _alloc_size += sizeof(AtomicAdjust::Integer);
-#endif  // NDEBUG
+  _alloc_size += _flag_reserved_bytes;
+#endif  // USE_DELETEDCHAINFLAG
 
 
   // We must allocate at least this much space for bookkeeping
   // We must allocate at least this much space for bookkeeping
   // reasons.
   // reasons.
@@ -61,7 +66,7 @@ allocate(size_t size, TypeHandle type_handle) {
 #ifdef USE_DELETEDCHAINFLAG
 #ifdef USE_DELETEDCHAINFLAG
     assert(obj->_flag == (AtomicAdjust::Integer)DCF_deleted);
     assert(obj->_flag == (AtomicAdjust::Integer)DCF_deleted);
     obj->_flag = DCF_alive;
     obj->_flag = DCF_alive;
-#endif  // NDEBUG
+#endif  // USE_DELETEDCHAINFLAG
 
 
     void *ptr = node_to_buffer(obj);
     void *ptr = node_to_buffer(obj);
 
 
@@ -125,7 +130,7 @@ deallocate(void *ptr, TypeHandle type_handle) {
   // If this assertion is triggered, you tried to delete an object
   // If this assertion is triggered, you tried to delete an object
   // that was never allocated, or you have heap corruption.
   // that was never allocated, or you have heap corruption.
   assert(orig_flag == (AtomicAdjust::Integer)DCF_alive);
   assert(orig_flag == (AtomicAdjust::Integer)DCF_alive);
-#endif  // NDEBUG
+#endif  // USE_DELETEDCHAINFLAG
 
 
   _lock.acquire();
   _lock.acquire();
 
 

+ 6 - 0
dtool/src/dtoolbase/deletedBufferChain.h

@@ -100,6 +100,12 @@ private:
   size_t _buffer_size;
   size_t _buffer_size;
   size_t _alloc_size;
   size_t _alloc_size;
 
 
+#ifdef USE_DELETEDCHAINFLAG
+  // The number of extra bytes reserved at the beginning of each
+  // buffer for the _flag, above.
+  static size_t _flag_reserved_bytes;
+#endif
+
   friend class MemoryHook;
   friend class MemoryHook;
 };
 };
 
 

+ 7 - 0
dtool/src/dtoolbase/dlmalloc_src.cxx

@@ -449,6 +449,13 @@ DEFAULT_MMAP_THRESHOLD       default: 256K
 
 
 */
 */
 
 
+#ifdef LINMATH_VECTORIZE
+// drose: We require 16-byte alignment of certain structures, to
+// support SSE2.  We don't strictly have to align *everything*, but
+// it's just easier to do so.
+#define MALLOC_ALIGNMENT ((size_t)16U)
+#endif
+
 #ifndef WIN32
 #ifndef WIN32
 #ifdef _WIN32
 #ifdef _WIN32
 #define WIN32 1
 #define WIN32 1

+ 9 - 0
dtool/src/dtoolbase/dtoolbase.h

@@ -109,6 +109,11 @@
 #include "pyconfig.h"
 #include "pyconfig.h"
 #endif
 #endif
 
 
+#ifndef HAVE_EIGEN
+// If we don't have the Eigen library, don't define LINMATH_VECTORIZE.
+#undef LINMATH_VECTORIZE
+#endif
+
 #include "dtoolsymbols.h"
 #include "dtoolsymbols.h"
 
 
 // always include assert.h until drose unbreaks it for opt4
 // always include assert.h until drose unbreaks it for opt4
@@ -316,15 +321,19 @@
 #ifdef CPPPARSER
 #ifdef CPPPARSER
 #define ALIGN_4BYTE
 #define ALIGN_4BYTE
 #define ALIGN_8BYTE
 #define ALIGN_8BYTE
+#define ALIGN_16BYTE
 #elif defined(WIN32_VC)
 #elif defined(WIN32_VC)
 #define ALIGN_4BYTE __declspec(align(4))
 #define ALIGN_4BYTE __declspec(align(4))
 #define ALIGN_8BYTE __declspec(align(8))
 #define ALIGN_8BYTE __declspec(align(8))
+#define ALIGN_16BYTE __declspec(align(16))
 #elif defined(__GNUC__)
 #elif defined(__GNUC__)
 #define ALIGN_4BYTE __attribute__ ((aligned (4)))
 #define ALIGN_4BYTE __attribute__ ((aligned (4)))
 #define ALIGN_8BYTE __attribute__ ((aligned (8)))
 #define ALIGN_8BYTE __attribute__ ((aligned (8)))
+#define ALIGN_16BYTE __attribute__ ((aligned (16)))
 #else
 #else
 #define ALIGN_4BYTE
 #define ALIGN_4BYTE
 #define ALIGN_8BYTE
 #define ALIGN_8BYTE
+#define ALIGN_16BYTE
 #endif
 #endif
 
 
 
 

+ 36 - 4
dtool/src/dtoolbase/memoryHook.I

@@ -42,6 +42,39 @@ dec_heap(size_t size) {
 #endif  // DO_MEMORY_USAGE
 #endif  // DO_MEMORY_USAGE
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: MemoryHook::get_memory_alignment
+//       Access: Public, Static
+//  Description: Returns the global memory alignment.  This is the
+//               number of bytes at which each allocated memory
+//               pointer will be aligned.
+////////////////////////////////////////////////////////////////////
+INLINE size_t MemoryHook::
+get_memory_alignment() {
+#ifdef LINMATH_VECTORIZE
+  // We require 16-byte alignment of certain structures, to support
+  // SSE2.  We don't strictly have to align *everything*, but it's just
+  // easier to do so.
+  const size_t alignment_size = 16;
+#else
+  // Otherwise, use word alignment.
+  const size_t alignment_size = sizeof(void *);
+#endif
+  return alignment_size;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: MemoryHook::get_header_reserved_bytes
+//       Access: Public, Static
+//  Description: Returns the number of additional bytes that are
+//               reserved at the beginning of every allocated block to
+//               store a size_t.
+////////////////////////////////////////////////////////////////////
+INLINE size_t MemoryHook::
+get_header_reserved_bytes() {
+  return _header_reserved_bytes;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: MemoryHook::get_page_size
 //     Function: MemoryHook::get_page_size
 //       Access: Public
 //       Access: Public
@@ -76,7 +109,7 @@ round_up_to_page_size(size_t size) const {
 INLINE size_t MemoryHook::
 INLINE size_t MemoryHook::
 inflate_size(size_t size) {
 inflate_size(size_t size) {
 #ifdef DO_MEMORY_USAGE
 #ifdef DO_MEMORY_USAGE
-  return size + sizeof(size_t);
+  return size + _header_reserved_bytes;
 #else
 #else
   return size;
   return size;
 #endif  // DO_MEMORY_USAGE
 #endif  // DO_MEMORY_USAGE
@@ -94,7 +127,7 @@ alloc_to_ptr(void *alloc, size_t size) {
 #ifdef DO_MEMORY_USAGE
 #ifdef DO_MEMORY_USAGE
   size_t *root = (size_t *)alloc;
   size_t *root = (size_t *)alloc;
   root[0] = size;
   root[0] = size;
-  return (void *)(root + 1);
+  return (void *)((char *)root + _header_reserved_bytes);
 #else
 #else
   return alloc;
   return alloc;
 #endif  // DO_MEMORY_USAGE
 #endif  // DO_MEMORY_USAGE
@@ -110,8 +143,7 @@ alloc_to_ptr(void *alloc, size_t size) {
 INLINE void *MemoryHook::
 INLINE void *MemoryHook::
 ptr_to_alloc(void *ptr, size_t &size) {
 ptr_to_alloc(void *ptr, size_t &size) {
 #ifdef DO_MEMORY_USAGE
 #ifdef DO_MEMORY_USAGE
-  size_t *root = (size_t *)ptr;
-  root -= 1;
+  size_t *root = (size_t *)((char *)ptr - _header_reserved_bytes);
   size = root[0];
   size = root[0];
   return (void *)root;
   return (void *)root;
 #else
 #else

+ 3 - 0
dtool/src/dtoolbase/memoryHook.cxx

@@ -107,6 +107,9 @@
 
 
 #endif  // USE_MEMORY_*
 #endif  // USE_MEMORY_*
 
 
+// Reserve enough bytes at the beginning of each allocated record to
+// store its allocated size.
+size_t MemoryHook::_header_reserved_bytes = max(MemoryHook::get_memory_alignment(), (size_t)sizeof(size_t));
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: MemoryHook::Constructor
 //     Function: MemoryHook::Constructor

+ 4 - 0
dtool/src/dtoolbase/memoryHook.h

@@ -58,6 +58,9 @@ public:
 
 
   bool heap_trim(size_t pad);
   bool heap_trim(size_t pad);
 
 
+  INLINE static size_t get_memory_alignment();
+  INLINE static size_t get_header_reserved_bytes();
+
   virtual void *mmap_alloc(size_t size, bool allow_exec);
   virtual void *mmap_alloc(size_t size, bool allow_exec);
   virtual void mmap_free(void *ptr, size_t size);
   virtual void mmap_free(void *ptr, size_t size);
   INLINE size_t get_page_size() const;
   INLINE size_t get_page_size() const;
@@ -89,6 +92,7 @@ protected:
 #endif  // DO_MEMORY_USAGE
 #endif  // DO_MEMORY_USAGE
 
 
 private:
 private:
+  static size_t _header_reserved_bytes;
   size_t _page_size;
   size_t _page_size;
 
 
   typedef map<size_t, DeletedBufferChain *> DeletedChains;
   typedef map<size_t, DeletedBufferChain *> DeletedChains;

+ 1 - 1
dtool/src/dtoolbase/neverFreeMemory.cxx

@@ -27,7 +27,7 @@ static const size_t min_page_size = 128 * 1024;  // 128K
 
 
 // We always allocate integer multiples of this many bytes, to
 // We always allocate integer multiples of this many bytes, to
 // guarantee this minimum alignment.
 // guarantee this minimum alignment.
-static const size_t alignment_size = sizeof(void *);
+static const size_t alignment_size = MemoryHook::get_memory_alignment();
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: NeverFreeMemory::Constructor
 //     Function: NeverFreeMemory::Constructor

+ 7 - 4
dtool/src/dtoolbase/pallocator.T

@@ -47,13 +47,14 @@ INLINE TYPENAME pallocator_array<Type>::pointer pallocator_array<Type>::
 allocate(TYPENAME pallocator_array<Type>::size_type n, TYPENAME allocator<void>::const_pointer) {
 allocate(TYPENAME pallocator_array<Type>::size_type n, TYPENAME allocator<void>::const_pointer) {
   TAU_PROFILE("pallocator_array:allocate()", " ", TAU_USER);
   TAU_PROFILE("pallocator_array:allocate()", " ", TAU_USER);
 #ifdef DO_MEMORY_USAGE
 #ifdef DO_MEMORY_USAGE
+  const size_t header_reserved_bytes = MemoryHook::get_header_reserved_bytes();
   size_t alloc_size = n * sizeof(Type);
   size_t alloc_size = n * sizeof(Type);
   // We also need to store the total number of bytes we allocated.
   // We also need to store the total number of bytes we allocated.
-  alloc_size += sizeof(size_t);
+  alloc_size += header_reserved_bytes;
   _type_handle.inc_memory_usage(TypeHandle::MC_array, (int)alloc_size);
   _type_handle.inc_memory_usage(TypeHandle::MC_array, (int)alloc_size);
   void *ptr = (TYPENAME pallocator_array<Type>::pointer)PANDA_MALLOC_ARRAY(alloc_size);
   void *ptr = (TYPENAME pallocator_array<Type>::pointer)PANDA_MALLOC_ARRAY(alloc_size);
   *((size_t *)ptr) = alloc_size;
   *((size_t *)ptr) = alloc_size;
-  return (TYPENAME pallocator_array<Type>::pointer)(((size_t *)ptr) + 1);
+  return (TYPENAME pallocator_array<Type>::pointer)(((char *)ptr) + header_reserved_bytes);
 #else
 #else
   return (TYPENAME pallocator_array<Type>::pointer)malloc(n * sizeof(Type));
   return (TYPENAME pallocator_array<Type>::pointer)malloc(n * sizeof(Type));
 #endif  // DO_MEMORY_USAGE
 #endif  // DO_MEMORY_USAGE
@@ -65,9 +66,11 @@ deallocate(TYPENAME pallocator_array<Type>::pointer p, TYPENAME pallocator_array
   TAU_PROFILE("pallocator_array:deallocate()", " ", TAU_USER);
   TAU_PROFILE("pallocator_array:deallocate()", " ", TAU_USER);
 #ifdef DO_MEMORY_USAGE
 #ifdef DO_MEMORY_USAGE
   // Now we need to recover the total number of bytes.
   // Now we need to recover the total number of bytes.
-  size_t alloc_size = *(((size_t *)p) - 1);
+  const size_t header_reserved_bytes = MemoryHook::get_header_reserved_bytes();
+  void *ptr = (void *)((char *)p - header_reserved_bytes);
+  size_t alloc_size = *((size_t *)ptr);
   _type_handle.dec_memory_usage(TypeHandle::MC_array, (int)alloc_size);
   _type_handle.dec_memory_usage(TypeHandle::MC_array, (int)alloc_size);
-  PANDA_FREE_ARRAY(((size_t *)p) - 1);
+  PANDA_FREE_ARRAY(ptr);
 #else
 #else
   free(p);
   free(p);
 #endif  // DO_MEMORY_USAGE
 #endif  // DO_MEMORY_USAGE

+ 6 - 0
dtool/src/dtoolbase/ptmalloc2_smp_src.cxx

@@ -749,6 +749,12 @@ extern "C" {
   are optimized for the case of 8-byte alignment.
   are optimized for the case of 8-byte alignment.
 */
 */
 
 
+#ifdef LINMATH_VECTORIZE
+// drose: We require 16-byte alignment of certain structures, to
+// support SSE2.  We don't strictly have to align *everything*, but
+// it's just easier to do so.
+#define MALLOC_ALIGNMENT ((size_t)16U)
+#endif
 
 
 #ifndef MALLOC_ALIGNMENT
 #ifndef MALLOC_ALIGNMENT
 #define MALLOC_ALIGNMENT       (2 * SIZE_SZ)
 #define MALLOC_ALIGNMENT       (2 * SIZE_SZ)

+ 6 - 0
dtool/src/parser-inc/Dense

@@ -0,0 +1,6 @@
+namespace Eigen {
+   template <class type, int rows, int cols>
+   class Matrix {
+   };
+};
+

+ 1 - 1
dtool/src/parser-inc/Sources.pp

@@ -25,6 +25,6 @@
     WebCore.h WebView.h WebViewListener.h \
     WebCore.h WebView.h WebViewListener.h \
     Core/Core.h Forest/Forest.h Renderers/OpenGL/OpenGLRenderer.h \
     Core/Core.h Forest/Forest.h Renderers/OpenGL/OpenGLRenderer.h \
     Renderers/DirectX9/DirectX9Renderer.h \
     Renderers/DirectX9/DirectX9Renderer.h \
-    glew/glew.h
+    glew/glew.h Eigen/Dense
 
 
 
 

+ 1 - 1
panda/src/audio/audioManager.h

@@ -18,7 +18,7 @@
 
 
 #include "config_audio.h"
 #include "config_audio.h"
 #include "audioSound.h"
 #include "audioSound.h"
-#include "lvecBase3.h"
+#include "luse.h"
 #include "filterProperties.h"
 #include "filterProperties.h"
 #include "movieAudio.h"
 #include "movieAudio.h"
 #include "atomicAdjust.h"
 #include "atomicAdjust.h"

+ 1 - 19
panda/src/char/jointVertexTransform.cxx

@@ -100,25 +100,7 @@ void JointVertexTransform::
 accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const {
 accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const {
   check_matrix();
   check_matrix();
 
 
-  accum._m.m._00 += _matrix._m.m._00 * weight;
-  accum._m.m._01 += _matrix._m.m._01 * weight;
-  accum._m.m._02 += _matrix._m.m._02 * weight;
-  accum._m.m._03 += _matrix._m.m._03 * weight;
-  
-  accum._m.m._10 += _matrix._m.m._10 * weight;
-  accum._m.m._11 += _matrix._m.m._11 * weight;
-  accum._m.m._12 += _matrix._m.m._12 * weight;
-  accum._m.m._13 += _matrix._m.m._13 * weight;
-  
-  accum._m.m._20 += _matrix._m.m._20 * weight;
-  accum._m.m._21 += _matrix._m.m._21 * weight;
-  accum._m.m._22 += _matrix._m.m._22 * weight;
-  accum._m.m._23 += _matrix._m.m._23 * weight;
-  
-  accum._m.m._30 += _matrix._m.m._30 * weight;
-  accum._m.m._31 += _matrix._m.m._31 * weight;
-  accum._m.m._32 += _matrix._m.m._32 * weight;
-  accum._m.m._33 += _matrix._m.m._33 * weight;
+  accum.accumulate(_matrix, weight);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 20 - 20
panda/src/gobj/shader.I

@@ -281,8 +281,8 @@ ShaderPtrData(const LVecBase4f &vec) :
   PTA_float pta = PTA_float::empty_array(4);
   PTA_float pta = PTA_float::empty_array(4);
   _pta = pta.v0();
   _pta = pta.v0();
   _ptr = pta.p();
   _ptr = pta.p();
-  nassertv(sizeof(vec._v.data) == pta.size() * sizeof(pta[0]));
-  memcpy(_ptr, vec._v.data, sizeof(vec._v.data));
+  nassertv(sizeof(vec[0]) * vec.size() == pta.size() * sizeof(pta[0]));
+  memcpy(_ptr, vec.get_data(), sizeof(vec[0]) * vec.size());
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -299,8 +299,8 @@ ShaderPtrData(const LVecBase3f &vec) :
   PTA_float pta = PTA_float::empty_array(3);
   PTA_float pta = PTA_float::empty_array(3);
   _pta = pta.v0();
   _pta = pta.v0();
   _ptr = pta.p();
   _ptr = pta.p();
-  nassertv(sizeof(vec._v.data) == pta.size() * sizeof(pta[0]));
-  memcpy(_ptr, vec._v.data, sizeof(vec._v.data));
+  nassertv(sizeof(vec[0]) * vec.size() == pta.size() * sizeof(pta[0]));
+  memcpy(_ptr, vec.get_data(), sizeof(vec[0]) * vec.size());
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -317,8 +317,8 @@ ShaderPtrData(const LVecBase2f &vec) :
   PTA_float pta = PTA_float::empty_array(2);
   PTA_float pta = PTA_float::empty_array(2);
   _pta = pta.v0();
   _pta = pta.v0();
   _ptr = pta.p();
   _ptr = pta.p();
-  nassertv(sizeof(vec._v.data) == pta.size() * sizeof(pta[0]));
-  memcpy(_ptr, vec._v.data, sizeof(vec._v.data));
+  nassertv(sizeof(vec[0]) * vec.size() == pta.size() * sizeof(pta[0]));
+  memcpy(_ptr, vec.get_data(), sizeof(vec[0]) * vec.size());
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -335,8 +335,8 @@ ShaderPtrData(const LMatrix4f &mat) :
   PTA_float pta = PTA_float::empty_array(16);
   PTA_float pta = PTA_float::empty_array(16);
   _pta = pta.v0();
   _pta = pta.v0();
   _ptr = pta.p();
   _ptr = pta.p();
-  nassertv(sizeof(mat._m.data) == pta.size() * sizeof(pta[0]));
-  memcpy(_ptr, mat._m.data, sizeof(mat._m.data));
+  nassertv(sizeof(mat(0, 0)) * mat.size() == pta.size() * sizeof(pta[0]));
+  memcpy(_ptr, mat.get_data(), sizeof(mat(0, 0)) * mat.size());
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -353,8 +353,8 @@ ShaderPtrData(const LMatrix3f &mat) :
   PTA_float pta = PTA_float::empty_array(9);
   PTA_float pta = PTA_float::empty_array(9);
   _pta = pta.v0();
   _pta = pta.v0();
   _ptr = pta.p();
   _ptr = pta.p();
-  nassertv(sizeof(mat._m.data) == pta.size() * sizeof(pta[0]));
-  memcpy(_ptr, mat._m.data, sizeof(mat._m.data));
+  nassertv(sizeof(mat(0, 0)) * mat.size() == pta.size() * sizeof(pta[0]));
+  memcpy(_ptr, mat.get_data(), sizeof(mat(0, 0)) * mat.size());
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -461,8 +461,8 @@ ShaderPtrData(const LVecBase4d &vec) :
   PTA_double pta = PTA_double::empty_array(4);
   PTA_double pta = PTA_double::empty_array(4);
   _pta = pta.v0();
   _pta = pta.v0();
   _ptr = pta.p();
   _ptr = pta.p();
-  nassertv(sizeof(vec._v.data) == pta.size() * sizeof(pta[0]));
-  memcpy(_ptr, vec._v.data, sizeof(vec._v.data));
+  nassertv(sizeof(vec[0]) * vec.size() == pta.size() * sizeof(pta[0]));
+  memcpy(_ptr, vec.get_data(), sizeof(vec[0]) * vec.size());
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -479,8 +479,8 @@ ShaderPtrData(const LVecBase3d &vec) :
   PTA_double pta = PTA_double::empty_array(3);
   PTA_double pta = PTA_double::empty_array(3);
   _pta = pta.v0();
   _pta = pta.v0();
   _ptr = pta.p();
   _ptr = pta.p();
-  nassertv(sizeof(vec._v.data) == pta.size() * sizeof(pta[0]));
-  memcpy(_ptr, vec._v.data, sizeof(vec._v.data));
+  nassertv(sizeof(vec[0]) * vec.size() == pta.size() * sizeof(pta[0]));
+  memcpy(_ptr, vec.get_data(), sizeof(vec[0]) * vec.size());
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -497,8 +497,8 @@ ShaderPtrData(const LVecBase2d &vec) :
   PTA_double pta = PTA_double::empty_array(2);
   PTA_double pta = PTA_double::empty_array(2);
   _pta = pta.v0();
   _pta = pta.v0();
   _ptr = pta.p();
   _ptr = pta.p();
-  nassertv(sizeof(vec._v.data) == pta.size() * sizeof(pta[0]));
-  memcpy(_ptr, vec._v.data, sizeof(vec._v.data));
+  nassertv(sizeof(vec[0]) * vec.size() == pta.size() * sizeof(pta[0]));
+  memcpy(_ptr, vec.get_data(), sizeof(vec[0]) * vec.size());
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -515,8 +515,8 @@ ShaderPtrData(const LMatrix4d &mat) :
   PTA_double pta = PTA_double::empty_array(16);
   PTA_double pta = PTA_double::empty_array(16);
   _pta = pta.v0();
   _pta = pta.v0();
   _ptr = pta.p();
   _ptr = pta.p();
-  nassertv(sizeof(mat._m.data) == pta.size() * sizeof(pta[0]));
-  memcpy(_ptr, mat._m.data, sizeof(mat._m.data));
+  nassertv(sizeof(mat(0, 0)) * mat.size() == pta.size() * sizeof(pta[0]));
+  memcpy(_ptr, mat.get_data(), sizeof(mat(0, 0)) * mat.size());
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -533,6 +533,6 @@ ShaderPtrData(const LMatrix3d &mat) :
   PTA_double pta = PTA_double::empty_array(9);
   PTA_double pta = PTA_double::empty_array(9);
   _pta = pta.v0();
   _pta = pta.v0();
   _ptr = pta.p();
   _ptr = pta.p();
-  nassertv(sizeof(mat._m.data) == pta.size() * sizeof(pta[0]));
-  memcpy(_ptr, mat._m.data, sizeof(mat._m.data));
+  nassertv(sizeof(mat(0, 0)) * mat.size() == pta.size() * sizeof(pta[0]));
+  memcpy(_ptr, mat.get_data(), sizeof(mat(0, 0)) * mat.size());
 }
 }

+ 1 - 4
panda/src/gobj/transformBlend.cxx

@@ -251,10 +251,7 @@ recompute_result(CData *cdata, Thread *current_thread) {
     // We do need to recompute.
     // We do need to recompute.
     cdata->_modified = seq;
     cdata->_modified = seq;
 
 
-    cdata->_result.set(0.0f, 0.0f, 0.0f, 0.0f,
-                       0.0f, 0.0f, 0.0f, 0.0f,
-                       0.0f, 0.0f, 0.0f, 0.0f,
-                       0.0f, 0.0f, 0.0f, 0.0f);
+    cdata->_result = LMatrix4::zeros_mat();
     for (ei = _entries.begin(); ei != _entries.end(); ++ei) {
     for (ei = _entries.begin(); ei != _entries.end(); ++ei) {
       (*ei)._transform->accumulate_matrix(cdata->_result, (*ei)._weight);
       (*ei)._transform->accumulate_matrix(cdata->_result, (*ei)._weight);
     }
     }

+ 1 - 20
panda/src/gobj/vertexTransform.cxx

@@ -74,26 +74,7 @@ void VertexTransform::
 accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const {
 accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const {
   LMatrix4 me;
   LMatrix4 me;
   get_matrix(me);
   get_matrix(me);
-  
-  accum._m.m._00 += me._m.m._00 * weight;
-  accum._m.m._01 += me._m.m._01 * weight;
-  accum._m.m._02 += me._m.m._02 * weight;
-  accum._m.m._03 += me._m.m._03 * weight;
-  
-  accum._m.m._10 += me._m.m._10 * weight;
-  accum._m.m._11 += me._m.m._11 * weight;
-  accum._m.m._12 += me._m.m._12 * weight;
-  accum._m.m._13 += me._m.m._13 * weight;
-  
-  accum._m.m._20 += me._m.m._20 * weight;
-  accum._m.m._21 += me._m.m._21 * weight;
-  accum._m.m._22 += me._m.m._22 * weight;
-  accum._m.m._23 += me._m.m._23 * weight;
-  
-  accum._m.m._30 += me._m.m._30 * weight;
-  accum._m.m._31 += me._m.m._31 * weight;
-  accum._m.m._32 += me._m.m._32 * weight;
-  accum._m.m._33 += me._m.m._33 * weight;
+  accum.accumulate(me, weight);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 10 - 4
panda/src/linmath/Sources.pp

@@ -12,7 +12,8 @@
      aa_luse.h \
      aa_luse.h \
      compose_matrix.h compose_matrix_src.I  \
      compose_matrix.h compose_matrix_src.I  \
      compose_matrix_src.cxx compose_matrix_src.h config_linmath.h  \
      compose_matrix_src.cxx compose_matrix_src.h config_linmath.h  \
-     coordinateSystem.h dbl2fltnames.h dblnames.h deg_2_rad.h  \
+     coordinateSystem.h dbl2fltnames.h dblnames.h \
+     deg_2_rad.h deg_2_rad.I \
      flt2dblnames.h fltnames.h lcast_to.h lcast_to_src.h  \
      flt2dblnames.h fltnames.h lcast_to.h lcast_to_src.h  \
      lcast_to_src.I lmatrix.h lmatrix_ext.I lmatrix3_src.I  \
      lcast_to_src.I lmatrix.h lmatrix_ext.I lmatrix3_src.I  \
      lmatrix3_src.cxx lmatrix3_src.h lmatrix4_src.I  \
      lmatrix3_src.cxx lmatrix3_src.h lmatrix4_src.I  \
@@ -23,7 +24,9 @@
      lpoint4.h lpoint4_src.I lpoint4_src.cxx lpoint4_src.h  \
      lpoint4.h lpoint4_src.I lpoint4_src.cxx lpoint4_src.h  \
      lquaternion.h lquaternion_src.I lquaternion_src.cxx  \
      lquaternion.h lquaternion_src.I lquaternion_src.cxx  \
      lquaternion_src.h lrotation.h lrotation_src.I  \
      lquaternion_src.h lrotation.h lrotation_src.I  \
-     lrotation_src.cxx lrotation_src.h luse.I luse.N luse.h  \
+     lrotation_src.cxx lrotation_src.h \
+     lsimpleMatrix.h lsimpleMatrix.I \
+     luse.I luse.N luse.h  \
      lvec2_ops.h lvec2_ops_src.I lvec2_ops_src.h lvec3_ops.h  \
      lvec2_ops.h lvec2_ops_src.I lvec2_ops_src.h lvec3_ops.h  \
      lvec3_ops_src.I lvec3_ops_src.h lvec4_ops.h lvec4_ops_src.I  \
      lvec3_ops_src.I lvec3_ops_src.h lvec4_ops.h lvec4_ops_src.I  \
      lvec4_ops_src.h \
      lvec4_ops_src.h \
@@ -51,7 +54,8 @@
     aa_luse.h \
     aa_luse.h \
     compose_matrix.h compose_matrix_src.I \
     compose_matrix.h compose_matrix_src.I \
     compose_matrix_src.h config_linmath.h coordinateSystem.h \
     compose_matrix_src.h config_linmath.h coordinateSystem.h \
-    dbl2fltnames.h dblnames.h deg_2_rad.h \
+    dbl2fltnames.h dblnames.h \
+    deg_2_rad.h deg_2_rad.I \
     flt2dblnames.h fltnames.h lcast_to.h lcast_to_src.I lcast_to_src.h \
     flt2dblnames.h fltnames.h lcast_to.h lcast_to_src.I lcast_to_src.h \
     lmat_ops.h lmat_ops_src.I lmat_ops_src.h lmatrix.h \
     lmat_ops.h lmat_ops_src.I lmat_ops_src.h lmatrix.h \
     lmatrix3_src.I lmatrix3_src.h lmatrix4_src.I \
     lmatrix3_src.I lmatrix3_src.h lmatrix4_src.I \
@@ -59,7 +63,9 @@
     lorientation_src.h lpoint2.h lpoint2_src.I lpoint2_src.h lpoint3.h \
     lorientation_src.h lpoint2.h lpoint2_src.I lpoint2_src.h lpoint3.h \
     lpoint3_src.I lpoint3_src.h lpoint4.h lpoint4_src.I lpoint4_src.h \
     lpoint3_src.I lpoint3_src.h lpoint4.h lpoint4_src.I lpoint4_src.h \
     lquaternion.h lquaternion_src.I lquaternion_src.h lrotation.h \
     lquaternion.h lquaternion_src.I lquaternion_src.h lrotation.h \
-    lrotation_src.I lrotation_src.h luse.I luse.h lvec2_ops.h \
+    lrotation_src.I lrotation_src.h \
+    lsimpleMatrix.I lsimpleMatrix.h \
+    luse.I luse.h lvec2_ops.h \
     lvec2_ops_src.I lvec2_ops_src.h lvec3_ops.h lvec3_ops_src.I \
     lvec2_ops_src.I lvec2_ops_src.h lvec3_ops.h lvec3_ops_src.I \
     lvec3_ops_src.h lvec4_ops.h lvec4_ops_src.I lvec4_ops_src.h \
     lvec3_ops_src.h lvec4_ops.h lvec4_ops_src.I lvec4_ops_src.h \
     lvecBase2.h lvecBase2_src.I lvecBase2_src.h lvecBase3.h \
     lvecBase2.h lvecBase2_src.I lvecBase2_src.h lvecBase3.h \

+ 1 - 0
panda/src/linmath/aa_luse.h

@@ -23,6 +23,7 @@
 
 
 #include "pandabase.h"
 #include "pandabase.h"
 
 
+#include "lsimpleMatrix.h"
 #include "stl_compares.h"
 #include "stl_compares.h"
 #include "lvec2_ops.h"
 #include "lvec2_ops.h"
 #include "lvec3_ops.h"
 #include "lvec3_ops.h"

+ 28 - 36
panda/src/linmath/compose_matrix_src.cxx

@@ -45,8 +45,6 @@ static void
 unwind_yup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) {
 unwind_yup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) {
   TAU_PROFILE("void unwind_yup_rotation_old_hpr(LMatrix3 &, LVecBase3 &)", " ", TAU_USER);
   TAU_PROFILE("void unwind_yup_rotation_old_hpr(LMatrix3 &, LVecBase3 &)", " ", TAU_USER);
 
 
-  typedef FLOATNAME(LMatrix3) Matrix;
-
   // Extract the axes from the matrix.
   // Extract the axes from the matrix.
   FLOATNAME(LVector3) x, y, z;
   FLOATNAME(LVector3) x, y, z;
   mat.get_row(x,0);
   mat.get_row(x,0);
@@ -61,7 +59,7 @@ unwind_yup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
   FLOATTYPE roll = rad_2_deg(((FLOATTYPE)catan2(xy[1], xy[0])));
   FLOATTYPE roll = rad_2_deg(((FLOATTYPE)catan2(xy[1], xy[0])));
   
   
   // Unwind the roll from the axes, and continue.
   // Unwind the roll from the axes, and continue.
-  Matrix rot_z;
+  FLOATNAME(LMatrix3) rot_z;
   rot_z.set_rotate_mat_normaxis(-roll, FLOATNAME(LVector3)(0.0f, 0.0f, 1.0f),
   rot_z.set_rotate_mat_normaxis(-roll, FLOATNAME(LVector3)(0.0f, 0.0f, 1.0f),
                                 CS_yup_right);
                                 CS_yup_right);
   
   
@@ -78,7 +76,7 @@ unwind_yup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
   FLOATTYPE heading = rad_2_deg(((FLOATTYPE)-catan2(xz[1], xz[0])));
   FLOATTYPE heading = rad_2_deg(((FLOATTYPE)-catan2(xz[1], xz[0])));
   
   
   // Unwind the heading, and continue.
   // Unwind the heading, and continue.
-  Matrix rot_y;
+  FLOATNAME(LMatrix3) rot_y;
   rot_y.set_rotate_mat_normaxis(-heading, FLOATNAME(LVector3)(0.0f, 1.0f, 0.0f),
   rot_y.set_rotate_mat_normaxis(-heading, FLOATNAME(LVector3)(0.0f, 1.0f, 0.0f),
                                 CS_yup_right);
                                 CS_yup_right);
   
   
@@ -94,7 +92,7 @@ unwind_yup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
   FLOATTYPE pitch = rad_2_deg(((FLOATTYPE)-catan2(yz[0], yz[1])));
   FLOATTYPE pitch = rad_2_deg(((FLOATTYPE)-catan2(yz[0], yz[1])));
   
   
   // Unwind the pitch.
   // Unwind the pitch.
-  Matrix rot_x;
+  FLOATNAME(LMatrix3) rot_x;
   rot_x.set_rotate_mat_normaxis(-pitch, FLOATNAME(LVector3)(1.0f, 0.0f, 0.0f),
   rot_x.set_rotate_mat_normaxis(-pitch, FLOATNAME(LVector3)(1.0f, 0.0f, 0.0f),
                                 CS_yup_right);
                                 CS_yup_right);
   
   
@@ -125,8 +123,6 @@ unwind_yup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
 static void
 static void
 unwind_zup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) {
 unwind_zup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) {
   TAU_PROFILE("void unwind_zup_rotation_old_hpr(LMatrix3 &, LVecBase3 &)", " ", TAU_USER);
   TAU_PROFILE("void unwind_zup_rotation_old_hpr(LMatrix3 &, LVecBase3 &)", " ", TAU_USER);
-  typedef FLOATNAME(LMatrix3) Matrix;
-  
   // Extract the axes from the matrix.
   // Extract the axes from the matrix.
   FLOATNAME(LVector3) x, y, z;
   FLOATNAME(LVector3) x, y, z;
   mat.get_row(x,0);
   mat.get_row(x,0);
@@ -150,7 +146,7 @@ unwind_zup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
   }
   }
   
   
   // Unwind the roll from the axes, and continue.
   // Unwind the roll from the axes, and continue.
-  Matrix rot_y;
+  FLOATNAME(LMatrix3) rot_y;
   rot_y.set_rotate_mat_normaxis(roll, FLOATNAME(LVector3)(0.0f, 1.0f, 0.0f),
   rot_y.set_rotate_mat_normaxis(roll, FLOATNAME(LVector3)(0.0f, 1.0f, 0.0f),
                                 CS_zup_right);
                                 CS_zup_right);
   
   
@@ -167,7 +163,7 @@ unwind_zup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
   FLOATTYPE heading = rad_2_deg(((FLOATTYPE)catan2(xy[1], xy[0])));
   FLOATTYPE heading = rad_2_deg(((FLOATTYPE)catan2(xy[1], xy[0])));
   
   
   // Unwind the heading, and continue.
   // Unwind the heading, and continue.
-  Matrix rot_z;
+  FLOATNAME(LMatrix3) rot_z;
   rot_z.set_rotate_mat_normaxis(-heading, FLOATNAME(LVector3)(0.0f, 0.0f, 1.0f),
   rot_z.set_rotate_mat_normaxis(-heading, FLOATNAME(LVector3)(0.0f, 0.0f, 1.0f),
                                 CS_zup_right);
                                 CS_zup_right);
   
   
@@ -183,7 +179,7 @@ unwind_zup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
   FLOATTYPE pitch = rad_2_deg(((FLOATTYPE)catan2(yz[1], yz[0])));
   FLOATTYPE pitch = rad_2_deg(((FLOATTYPE)catan2(yz[1], yz[0])));
   
   
   // Unwind the pitch.
   // Unwind the pitch.
-  Matrix rot_x;
+  FLOATNAME(LMatrix3) rot_x;
   rot_x.set_rotate_mat_normaxis(-pitch, FLOATNAME(LVector3)(1.0f, 0.0f, 0.0f),
   rot_x.set_rotate_mat_normaxis(-pitch, FLOATNAME(LVector3)(1.0f, 0.0f, 0.0f),
                                 CS_zup_right);
                                 CS_zup_right);
   
   
@@ -246,10 +242,10 @@ decompose_matrix_old_hpr(const FLOATNAME(LMatrix3) &mat,
 
 
   case CS_zup_left:
   case CS_zup_left:
     {
     {
-      new_mat._m.m._02 = -new_mat._m.m._02;
-      new_mat._m.m._12 = -new_mat._m.m._12;
-      new_mat._m.m._20 = -new_mat._m.m._20;
-      new_mat._m.m._21 = -new_mat._m.m._21;
+      new_mat._m(0, 2) = -new_mat._m(0, 2);
+      new_mat._m(1, 2) = -new_mat._m(1, 2);
+      new_mat._m(2, 0) = -new_mat._m(2, 0);
+      new_mat._m(2, 1) = -new_mat._m(2, 1);
       /*
       /*
         FLOATNAME(LMatrix3) lm(mat(0, 0), mat(0, 1), -mat(0, 2),
         FLOATNAME(LMatrix3) lm(mat(0, 0), mat(0, 1), -mat(0, 2),
         mat(1, 0), mat(1, 1), -mat(1, 2),
         mat(1, 0), mat(1, 1), -mat(1, 2),
@@ -263,10 +259,10 @@ decompose_matrix_old_hpr(const FLOATNAME(LMatrix3) &mat,
 
 
   case CS_yup_left:
   case CS_yup_left:
     {
     {
-      new_mat._m.m._02 = -new_mat._m.m._02;
-      new_mat._m.m._12 = -new_mat._m.m._12;
-      new_mat._m.m._20 = -new_mat._m.m._20;
-      new_mat._m.m._21 = -new_mat._m.m._21;
+      new_mat._m(0, 2) = -new_mat._m(0, 2);
+      new_mat._m(1, 2) = -new_mat._m(1, 2);
+      new_mat._m(2, 0) = -new_mat._m(2, 0);
+      new_mat._m(2, 1) = -new_mat._m(2, 1);
       /*
       /*
         FLOATNAME(LMatrix3) lm(mat(0, 0), mat(0, 1), -mat(0, 2),
         FLOATNAME(LMatrix3) lm(mat(0, 0), mat(0, 1), -mat(0, 2),
         mat(1, 0), mat(1, 1), -mat(1, 2),
         mat(1, 0), mat(1, 1), -mat(1, 2),
@@ -355,8 +351,6 @@ static void
 unwind_yup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) {
 unwind_yup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) {
   TAU_PROFILE("void unwind_yup_rotation_new_hpr(LMatrix3 &, LVecBase3 &)", " ", TAU_USER);
   TAU_PROFILE("void unwind_yup_rotation_new_hpr(LMatrix3 &, LVecBase3 &)", " ", TAU_USER);
 
 
-  typedef FLOATNAME(LMatrix3) Matrix;
-
   // Extract the axes from the matrix.
   // Extract the axes from the matrix.
   FLOATNAME(LVector3) x, y, z;
   FLOATNAME(LVector3) x, y, z;
   mat.get_row(x,0);
   mat.get_row(x,0);
@@ -372,7 +366,7 @@ unwind_yup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
   FLOATTYPE heading = rad_2_deg(((FLOATTYPE)catan2(xz[0], xz[1])));
   FLOATTYPE heading = rad_2_deg(((FLOATTYPE)catan2(xz[0], xz[1])));
   
   
   // Unwind the heading, and continue.
   // Unwind the heading, and continue.
-  Matrix rot_y;
+  FLOATNAME(LMatrix3) rot_y;
   rot_y.set_rotate_mat_normaxis(-heading, FLOATNAME(LVector3)(0.0f, 1.0f, 0.0f),
   rot_y.set_rotate_mat_normaxis(-heading, FLOATNAME(LVector3)(0.0f, 1.0f, 0.0f),
                                 CS_yup_right);
                                 CS_yup_right);
   
   
@@ -388,7 +382,7 @@ unwind_yup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
   FLOATTYPE pitch = rad_2_deg((FLOATTYPE)(-catan2(yz[0], yz[1])));
   FLOATTYPE pitch = rad_2_deg((FLOATTYPE)(-catan2(yz[0], yz[1])));
   
   
   // Unwind the pitch.
   // Unwind the pitch.
-  Matrix rot_x;
+  FLOATNAME(LMatrix3) rot_x;
   rot_x.set_rotate_mat_normaxis(-pitch, FLOATNAME(LVector3)(1.0f, 0.0f, 0.0f),
   rot_x.set_rotate_mat_normaxis(-pitch, FLOATNAME(LVector3)(1.0f, 0.0f, 0.0f),
                                 CS_yup_right);
                                 CS_yup_right);
   
   
@@ -404,7 +398,7 @@ unwind_yup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
   FLOATTYPE roll = -rad_2_deg(((FLOATTYPE)catan2(xy[1], xy[0])));
   FLOATTYPE roll = -rad_2_deg(((FLOATTYPE)catan2(xy[1], xy[0])));
   
   
   // Unwind the roll from the axes, and continue.
   // Unwind the roll from the axes, and continue.
-  Matrix rot_z;
+  FLOATNAME(LMatrix3) rot_z;
   rot_z.set_rotate_mat_normaxis(roll, FLOATNAME(LVector3)(0.0f, 0.0f, 1.0f),
   rot_z.set_rotate_mat_normaxis(roll, FLOATNAME(LVector3)(0.0f, 0.0f, 1.0f),
                                 CS_yup_right);
                                 CS_yup_right);
   
   
@@ -435,8 +429,6 @@ unwind_yup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
 static void
 static void
 unwind_zup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) {
 unwind_zup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) {
   TAU_PROFILE("void unwind_zup_rotation_new_hpr(LMatrix3 &, LVecBase3 &)", " ", TAU_USER);
   TAU_PROFILE("void unwind_zup_rotation_new_hpr(LMatrix3 &, LVecBase3 &)", " ", TAU_USER);
-  typedef FLOATNAME(LMatrix3) Matrix;
-
   // Extract the axes from the matrix.
   // Extract the axes from the matrix.
   FLOATNAME(LVector3) x, y, z;
   FLOATNAME(LVector3) x, y, z;
   mat.get_row(x,0);
   mat.get_row(x,0);
@@ -452,7 +444,7 @@ unwind_zup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
   FLOATTYPE heading = -rad_2_deg(((FLOATTYPE)catan2(xy[0], xy[1])));
   FLOATTYPE heading = -rad_2_deg(((FLOATTYPE)catan2(xy[0], xy[1])));
   
   
   // Unwind the heading, and continue.
   // Unwind the heading, and continue.
-  Matrix rot_z;
+  FLOATNAME(LMatrix3) rot_z;
   rot_z.set_rotate_mat_normaxis(-heading, FLOATNAME(LVector3)(0.0f, 0.0f, 1.0f),
   rot_z.set_rotate_mat_normaxis(-heading, FLOATNAME(LVector3)(0.0f, 0.0f, 1.0f),
                                 CS_zup_right);
                                 CS_zup_right);
   
   
@@ -468,7 +460,7 @@ unwind_zup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
   FLOATTYPE pitch = rad_2_deg(((FLOATTYPE)catan2(yz[1], yz[0])));
   FLOATTYPE pitch = rad_2_deg(((FLOATTYPE)catan2(yz[1], yz[0])));
   
   
   // Unwind the pitch.
   // Unwind the pitch.
-  Matrix rot_x;
+  FLOATNAME(LMatrix3) rot_x;
   rot_x.set_rotate_mat_normaxis(-pitch, FLOATNAME(LVector3)(1.0f, 0.0f, 0.0f),
   rot_x.set_rotate_mat_normaxis(-pitch, FLOATNAME(LVector3)(1.0f, 0.0f, 0.0f),
                                 CS_zup_right);
                                 CS_zup_right);
   
   
@@ -484,7 +476,7 @@ unwind_zup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
   FLOATTYPE roll = -rad_2_deg(((FLOATTYPE)catan2(xz[1], xz[0])));
   FLOATTYPE roll = -rad_2_deg(((FLOATTYPE)catan2(xz[1], xz[0])));
   
   
   // Unwind the roll from the axes, and continue.
   // Unwind the roll from the axes, and continue.
-  Matrix rot_y;
+  FLOATNAME(LMatrix3) rot_y;
   rot_y.set_rotate_mat_normaxis(-roll, FLOATNAME(LVector3)(0.0f, 1.0f, 0.0f),
   rot_y.set_rotate_mat_normaxis(-roll, FLOATNAME(LVector3)(0.0f, 1.0f, 0.0f),
                                 CS_zup_right);
                                 CS_zup_right);
   
   
@@ -547,10 +539,10 @@ decompose_matrix_new_hpr(const FLOATNAME(LMatrix3) &mat,
 
 
   case CS_zup_left:
   case CS_zup_left:
     {
     {
-      new_mat._m.m._02 = -new_mat._m.m._02;
-      new_mat._m.m._12 = -new_mat._m.m._12;
-      new_mat._m.m._20 = -new_mat._m.m._20;
-      new_mat._m.m._21 = -new_mat._m.m._21;
+      new_mat._m(0, 2) = -new_mat._m(0, 2);
+      new_mat._m(1, 2) = -new_mat._m(1, 2);
+      new_mat._m(2, 0) = -new_mat._m(2, 0);
+      new_mat._m(2, 1) = -new_mat._m(2, 1);
       /*
       /*
         FLOATNAME(LMatrix3) lm(mat(0, 0), mat(0, 1), -mat(0, 2),
         FLOATNAME(LMatrix3) lm(mat(0, 0), mat(0, 1), -mat(0, 2),
         mat(1, 0), mat(1, 1), -mat(1, 2),
         mat(1, 0), mat(1, 1), -mat(1, 2),
@@ -564,10 +556,10 @@ decompose_matrix_new_hpr(const FLOATNAME(LMatrix3) &mat,
 
 
   case CS_yup_left:
   case CS_yup_left:
     {
     {
-      new_mat._m.m._02 = -new_mat._m.m._02;
-      new_mat._m.m._12 = -new_mat._m.m._12;
-      new_mat._m.m._20 = -new_mat._m.m._20;
-      new_mat._m.m._21 = -new_mat._m.m._21;
+      new_mat._m(0, 2) = -new_mat._m(0, 2);
+      new_mat._m(1, 2) = -new_mat._m(1, 2);
+      new_mat._m(2, 0) = -new_mat._m(2, 0);
+      new_mat._m(2, 1) = -new_mat._m(2, 1);
       /*
       /*
         FLOATNAME(LMatrix3) lm(mat(0, 0), mat(0, 1), -mat(0, 2),
         FLOATNAME(LMatrix3) lm(mat(0, 0), mat(0, 1), -mat(0, 2),
         mat(1, 0), mat(1, 1), -mat(1, 2),
         mat(1, 0), mat(1, 1), -mat(1, 2),

+ 1 - 0
panda/src/linmath/config_linmath.h

@@ -18,6 +18,7 @@
 #include "pandabase.h"
 #include "pandabase.h"
 #include "notifyCategoryProxy.h"
 #include "notifyCategoryProxy.h"
 #include "configVariableBool.h"
 #include "configVariableBool.h"
+#include "lsimpleMatrix.h"
 
 
 NotifyCategoryDecl(linmath, EXPCL_PANDA_LINMATH, EXPTP_PANDA_LINMATH);
 NotifyCategoryDecl(linmath, EXPCL_PANDA_LINMATH, EXPTP_PANDA_LINMATH);
 
 

+ 29 - 0
panda/src/linmath/deg_2_rad.I

@@ -0,0 +1,29 @@
+// Filename: deg_2_rad.I
+// Created by:  drose (14Dec11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+INLINE_LINMATH double deg_2_rad(double f) { 
+  return f * MathNumbers::deg_2_rad_d; 
+}
+
+INLINE_LINMATH double rad_2_deg(double f) { 
+  return f * MathNumbers::rad_2_deg_d; 
+}
+
+INLINE_LINMATH float deg_2_rad(float f) { 
+  return f * MathNumbers::deg_2_rad_f; 
+}
+
+INLINE_LINMATH float rad_2_deg(float f) { 
+  return f * MathNumbers::rad_2_deg_f; 
+}

+ 6 - 4
panda/src/linmath/deg_2_rad.h

@@ -20,12 +20,14 @@
 #include "mathNumbers.h"
 #include "mathNumbers.h"
 
 
 BEGIN_PUBLISH
 BEGIN_PUBLISH
-INLINE_LINMATH double deg_2_rad( double f ) { return f * MathNumbers::deg_2_rad_d; }
-INLINE_LINMATH double rad_2_deg( double f ) { return f * MathNumbers::rad_2_deg_d; }
+INLINE_LINMATH double deg_2_rad(double f);
+INLINE_LINMATH double rad_2_deg(double f);
 
 
-INLINE_LINMATH float deg_2_rad( float f ) { return f * MathNumbers::deg_2_rad_f; }
-INLINE_LINMATH float rad_2_deg( float f ) { return f * MathNumbers::rad_2_deg_f; }
+INLINE_LINMATH float deg_2_rad(float f);
+INLINE_LINMATH float rad_2_deg(float f);
 END_PUBLISH
 END_PUBLISH
 
 
+#include "deg_2_rad.I"
+
 #endif
 #endif
 
 

+ 6 - 0
panda/src/linmath/lmat_ops_src.h

@@ -19,6 +19,12 @@ BEGIN_PUBLISH
 INLINE_LINMATH FLOATNAME(LVecBase3)
 INLINE_LINMATH FLOATNAME(LVecBase3)
 operator * (const FLOATNAME(LVecBase3) &v, const FLOATNAME(LMatrix3) &m);
 operator * (const FLOATNAME(LVecBase3) &v, const FLOATNAME(LMatrix3) &m);
 
 
+INLINE_LINMATH FLOATNAME(LVector3)
+operator * (const FLOATNAME(LVector3) &v, const FLOATNAME(LMatrix3) &m);
+
+INLINE_LINMATH FLOATNAME(LPoint3)
+operator * (const FLOATNAME(LPoint3) &v, const FLOATNAME(LMatrix3) &m);
+
 INLINE_LINMATH FLOATNAME(LVector2)
 INLINE_LINMATH FLOATNAME(LVector2)
 operator * (const FLOATNAME(LVector2) &v, const FLOATNAME(LMatrix3) &m);
 operator * (const FLOATNAME(LVector2) &v, const FLOATNAME(LMatrix3) &m);
 
 

+ 12 - 12
panda/src/linmath/lmatrix3_ext_src.I

@@ -42,9 +42,9 @@ __reduce__, PyObject *self) {
   }
   }
 
 
   PyObject *result = Py_BuildValue("(O(fffffffff))", this_class, 
   PyObject *result = Py_BuildValue("(O(fffffffff))", this_class, 
-    this->_m.m._00, this->_m.m._01, this->_m.m._02,
-    this->_m.m._10, this->_m.m._11, this->_m.m._12,
-    this->_m.m._20, this->_m.m._21, this->_m.m._22);
+    this->_m(0, 0), this->_m(0, 1), this->_m(0, 2),
+    this->_m(1, 0), this->_m(1, 1), this->_m(1, 2),
+    this->_m(2, 0), this->_m(2, 1), this->_m(2, 2));
 
 
   Py_DECREF(this_class);
   Py_DECREF(this_class);
   return result;
   return result;
@@ -58,16 +58,16 @@ __reduce__, PyObject *self) {
 void EXT_CONST_METHOD_ARGS(FLOATNAME(LMatrix3),
 void EXT_CONST_METHOD_ARGS(FLOATNAME(LMatrix3),
 python_repr, ostream &out, const string &class_name) {
 python_repr, ostream &out, const string &class_name) {
   out << class_name << "(" 
   out << class_name << "(" 
-      << MAYBE_ZERO(this->_m.m._00) << ", "
-      << MAYBE_ZERO(this->_m.m._01) << ", "
-      << MAYBE_ZERO(this->_m.m._02) << ", "
+      << MAYBE_ZERO(this->_m(0, 0)) << ", "
+      << MAYBE_ZERO(this->_m(0, 1)) << ", "
+      << MAYBE_ZERO(this->_m(0, 2)) << ", "
 
 
-      << MAYBE_ZERO(this->_m.m._10) << ", "
-      << MAYBE_ZERO(this->_m.m._11) << ", "
-      << MAYBE_ZERO(this->_m.m._12) << ", "
+      << MAYBE_ZERO(this->_m(1, 0)) << ", "
+      << MAYBE_ZERO(this->_m(1, 1)) << ", "
+      << MAYBE_ZERO(this->_m(1, 2)) << ", "
 
 
-      << MAYBE_ZERO(this->_m.m._20) << ", "
-      << MAYBE_ZERO(this->_m.m._21) << ", "
-      << MAYBE_ZERO(this->_m.m._22) << ")";
+      << MAYBE_ZERO(this->_m(2, 0)) << ", "
+      << MAYBE_ZERO(this->_m(2, 1)) << ", "
+      << MAYBE_ZERO(this->_m(2, 2)) << ")";
 }
 }
 
 

+ 289 - 217
panda/src/linmath/lmatrix3_src.I

@@ -112,10 +112,7 @@ FLOATNAME(LMatrix3)() {
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LMatrix3)::
 INLINE_LINMATH FLOATNAME(LMatrix3)::
-FLOATNAME(LMatrix3)(const FLOATNAME(LMatrix3) &copy) {
-  TAU_PROFILE("LMatrix3::LMatrix3(const LMatrix3 &)", " ", TAU_USER);
-  
-  memcpy(_m.data, copy._m.data, sizeof(_m.data));
+FLOATNAME(LMatrix3)(const FLOATNAME(LMatrix3) &copy) : _m(copy._m) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -127,7 +124,7 @@ INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3)::
 operator = (const FLOATNAME(LMatrix3) &copy) {
 operator = (const FLOATNAME(LMatrix3) &copy) {
   TAU_PROFILE("void LMatrix3::operator = (const LMatrix3 &)", " ", TAU_USER);
   TAU_PROFILE("void LMatrix3::operator = (const LMatrix3 &)", " ", TAU_USER);
 
 
-  memcpy(_m.data, copy._m.data, sizeof(_m.data));
+  _m = copy._m;
   return *this;
   return *this;
 }
 }
 
 
@@ -152,15 +149,15 @@ FLOATNAME(LMatrix3)(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02,
                     FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12,
                     FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12,
                     FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22) {
                     FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22) {
   TAU_PROFILE("LMatrix3::LMatrix3(FLOATTYPE, ...)", " ", TAU_USER);
   TAU_PROFILE("LMatrix3::LMatrix3(FLOATTYPE, ...)", " ", TAU_USER);
-  _m.m._00 = e00;
-  _m.m._01 = e01;
-  _m.m._02 = e02;
-  _m.m._10 = e10;
-  _m.m._11 = e11;
-  _m.m._12 = e12;
-  _m.m._20 = e20;
-  _m.m._21 = e21;
-  _m.m._22 = e22;
+  _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;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -173,15 +170,15 @@ set(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02,
     FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12,
     FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12,
     FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22) {
     FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22) {
   TAU_PROFILE("void LMatrix3::set(FLOATTYPE, ...)", " ", TAU_USER);
   TAU_PROFILE("void LMatrix3::set(FLOATTYPE, ...)", " ", TAU_USER);
-  _m.m._00 = e00;
-  _m.m._01 = e01;
-  _m.m._02 = e02;
-  _m.m._10 = e10;
-  _m.m._11 = e11;
-  _m.m._12 = e12;
-  _m.m._20 = e20;
-  _m.m._21 = e21;
-  _m.m._22 = e22;
+  _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;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -192,9 +189,13 @@ set(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02,
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LMatrix3)::
 INLINE_LINMATH void FLOATNAME(LMatrix3)::
 set_row(int row, const FLOATNAME(LVecBase3) &v) {
 set_row(int row, const FLOATNAME(LVecBase3) &v) {
-  (*this)(row, 0) = v._v.v._0;
-  (*this)(row, 1) = v._v.v._1;
-  (*this)(row, 2) = v._v.v._2;
+#ifdef HAVE_EIGEN
+  _m.row(row) = v._v;
+#else
+  (*this)(row, 0) = v._v(0);
+  (*this)(row, 1) = v._v(1);
+  (*this)(row, 2) = v._v(2);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -205,9 +206,13 @@ set_row(int row, const FLOATNAME(LVecBase3) &v) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LMatrix3)::
 INLINE_LINMATH void FLOATNAME(LMatrix3)::
 set_col(int col, const FLOATNAME(LVecBase3) &v) {
 set_col(int col, const FLOATNAME(LVecBase3) &v) {
-  (*this)(0, col) = v._v.v._0;
-  (*this)(1, col) = v._v.v._1;
-  (*this)(2, col) = v._v.v._2;
+#ifdef HAVE_EIGEN
+  _m.col(col) = v._v;
+#else
+  (*this)(0, col) = v._v(0);
+  (*this)(1, col) = v._v(1);
+  (*this)(2, col) = v._v(2);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -218,8 +223,12 @@ set_col(int col, const FLOATNAME(LVecBase3) &v) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LMatrix3)::
 INLINE_LINMATH void FLOATNAME(LMatrix3)::
 set_row(int row, const FLOATNAME(LVecBase2) &v) {
 set_row(int row, const FLOATNAME(LVecBase2) &v) {
-  (*this)(row, 0) = v._v.v._0;
-  (*this)(row, 1) = v._v.v._1;
+#ifdef HAVE_EIGEN
+  _m.block<1, 2>(row, 0) = v._v;
+#else
+  (*this)(row, 0) = v._v(0);
+  (*this)(row, 1) = v._v(1);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -230,8 +239,12 @@ set_row(int row, const FLOATNAME(LVecBase2) &v) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LMatrix3)::
 INLINE_LINMATH void FLOATNAME(LMatrix3)::
 set_col(int col, const FLOATNAME(LVecBase2) &v) {
 set_col(int col, const FLOATNAME(LVecBase2) &v) {
-  (*this)(0, col) = v._v.v._0;
-  (*this)(1, col) = v._v.v._1;
+#ifdef HAVE_EIGEN
+  _m.block<2, 1>(0, col) = v._v;
+#else
+  (*this)(0, col) = v._v(0);
+  (*this)(1, col) = v._v(1);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -242,14 +255,28 @@ set_col(int col, const FLOATNAME(LVecBase2) &v) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix3)::
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix3)::
 get_row(int row) const {
 get_row(int row) const {
+#ifdef HAVE_EIGEN  
+  return FLOATNAME(LVecBase3)(_m.row(row));
+#else
   return FLOATNAME(LVecBase3)((*this)(row, 0), (*this)(row, 1), (*this)(row, 2));
   return FLOATNAME(LVecBase3)((*this)(row, 0), (*this)(row, 1), (*this)(row, 2));
+#endif  // HAVE_EIGEN
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: LMatrix3::get_row
+//       Access: Published
+//  Description: Stores the indicated row of the matrix as a
+//               three-component vector.
+////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LMatrix3)::
 INLINE_LINMATH void FLOATNAME(LMatrix3)::
 get_row(FLOATNAME(LVecBase3) &result_vec,int row) const {
 get_row(FLOATNAME(LVecBase3) &result_vec,int row) const {
-  result_vec._v.v._0 = (*this)(row, 0);
-  result_vec._v.v._1 = (*this)(row, 1);
-  result_vec._v.v._2 = (*this)(row, 2);
+#ifdef HAVE_EIGEN  
+  result_vec._v = _m.row(row);
+#else
+  result_vec._v(0) = (*this)(row, 0);
+  result_vec._v(1) = (*this)(row, 1);
+  result_vec._v(2) = (*this)(row, 2);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -260,7 +287,11 @@ get_row(FLOATNAME(LVecBase3) &result_vec,int row) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix3)::
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix3)::
 get_col(int col) const {
 get_col(int col) const {
+#ifdef HAVE_EIGEN  
+  return FLOATNAME(LVecBase3)(_m.col(col));
+#else
   return FLOATNAME(LVecBase3)((*this)(0, col), (*this)(1, col), (*this)(2, col));
   return FLOATNAME(LVecBase3)((*this)(0, col), (*this)(1, col), (*this)(2, col));
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -292,8 +323,8 @@ get_col2(int col) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE &FLOATNAME(LMatrix3)::
 INLINE_LINMATH FLOATTYPE &FLOATNAME(LMatrix3)::
 operator () (int row, int col) {
 operator () (int row, int col) {
-  nassertr(row >= 0 && row < 3 && col >= 0 && col < 3, _m.data[0]);
-  return _m.data[row * 3 + col];
+  nassertr(row >= 0 && row < 3 && col >= 0 && col < 3, _m(0, 0));
+  return _m(row, col);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -304,7 +335,7 @@ operator () (int row, int col) {
 INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix3)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix3)::
 operator () (int row, int col) const {
 operator () (int row, int col) const {
   nassertr(row >= 0 && row < 3 && col >= 0 && col < 3, 0.0);
   nassertr(row >= 0 && row < 3 && col >= 0 && col < 3, 0.0);
-  return _m.data[row * 3 + col];
+  return _m(row, col);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -314,8 +345,8 @@ operator () (int row, int col) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LMatrix3)::CRow FLOATNAME(LMatrix3)::
 INLINE_LINMATH FLOATNAME(LMatrix3)::CRow FLOATNAME(LMatrix3)::
 operator [](int i) const {
 operator [](int i) const {
-  nassertr(i >= 0 && i < 3, CRow(&_m.data[0]));
-  return CRow(&_m.data[i * 3]);
+  nassertr(i >= 0 && i < 3, CRow(&_m(0, 0)));
+  return CRow(&_m(i, 0));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -325,8 +356,8 @@ operator [](int i) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LMatrix3)::Row FLOATNAME(LMatrix3)::
 INLINE_LINMATH FLOATNAME(LMatrix3)::Row FLOATNAME(LMatrix3)::
 operator [](int i) {
 operator [](int i) {
-  nassertr(i >= 0 && i < 3, Row(&_m.data[0]));
-  return Row(&_m.data[i * 3]);
+  nassertr(i >= 0 && i < 3, Row(&_m(0, 0)));
+  return Row(&_m(i, 0));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -349,9 +380,9 @@ INLINE_LINMATH bool FLOATNAME(LMatrix3)::
 is_nan() const {
 is_nan() const {
   TAU_PROFILE("bool LMatrix3::is_nan()", " ", TAU_USER);
   TAU_PROFILE("bool LMatrix3::is_nan()", " ", TAU_USER);
   return
   return
-    cnan(_m.data[0]) || cnan(_m.data[1]) || cnan(_m.data[2]) ||
-    cnan(_m.data[3]) || cnan(_m.data[4]) || cnan(_m.data[5]) ||
-    cnan(_m.data[6]) || cnan(_m.data[7]) || cnan(_m.data[8]);
+    cnan(_m(0, 0)) || cnan(_m(0, 1)) || cnan(_m(0, 2)) ||
+    cnan(_m(1, 0)) || cnan(_m(1, 1)) || cnan(_m(1, 2)) ||
+    cnan(_m(2, 0)) || cnan(_m(2, 1)) || cnan(_m(2, 2));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -362,7 +393,7 @@ is_nan() const {
 INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix3)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix3)::
 get_cell(int row, int col) const {
 get_cell(int row, int col) const {
   nassertr(row >= 0 && row < 3 && col >= 0 && col < 3, 0.0);
   nassertr(row >= 0 && row < 3 && col >= 0 && col < 3, 0.0);
-  return _m.data[row * 3 + col];
+  return _m(row, col);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -373,7 +404,7 @@ get_cell(int row, int col) const {
 INLINE_LINMATH void FLOATNAME(LMatrix3)::
 INLINE_LINMATH void FLOATNAME(LMatrix3)::
 set_cell(int row, int col, FLOATTYPE value) {
 set_cell(int row, int col, FLOATTYPE value) {
   nassertv(row >= 0 && row < 3 && col >= 0 && col < 3);
   nassertv(row >= 0 && row < 3 && col >= 0 && col < 3);
-  _m.data[row * 3 + col] = value;
+  _m(row, col) = value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -385,7 +416,7 @@ set_cell(int row, int col, FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH const FLOATTYPE *FLOATNAME(LMatrix3)::
 INLINE_LINMATH const FLOATTYPE *FLOATNAME(LMatrix3)::
 get_data() const {
 get_data() const {
-  return _m.data;
+  return &_m(0, 0);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -406,7 +437,7 @@ get_num_components() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LMatrix3)::iterator FLOATNAME(LMatrix3)::
 INLINE_LINMATH FLOATNAME(LMatrix3)::iterator FLOATNAME(LMatrix3)::
 begin() {
 begin() {
-  return _m.data;
+  return &_m(0, 0);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -428,7 +459,7 @@ end() {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LMatrix3)::const_iterator FLOATNAME(LMatrix3)::
 INLINE_LINMATH FLOATNAME(LMatrix3)::const_iterator FLOATNAME(LMatrix3)::
 begin() const {
 begin() const {
-  return _m.data;
+  return &_m(0, 0);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -527,25 +558,25 @@ add_hash(size_t hash, FLOATTYPE threshold) const {
   TAU_PROFILE("size_t LMatrix3::add_hash(size_t, FLOATTYPE)", " ", TAU_USER);
   TAU_PROFILE("size_t LMatrix3::add_hash(size_t, FLOATTYPE)", " ", TAU_USER);
   float_hash fhasher(threshold);
   float_hash fhasher(threshold);
 
 
-  hash = fhasher.add_hash(hash, _m.m._00);
-  hash = fhasher.add_hash(hash, _m.m._01);
-  hash = fhasher.add_hash(hash, _m.m._02);
+  hash = fhasher.add_hash(hash, _m(0, 0));
+  hash = fhasher.add_hash(hash, _m(0, 1));
+  hash = fhasher.add_hash(hash, _m(0, 2));
 
 
-  hash = fhasher.add_hash(hash, _m.m._10);
-  hash = fhasher.add_hash(hash, _m.m._11);
-  hash = fhasher.add_hash(hash, _m.m._12);
+  hash = fhasher.add_hash(hash, _m(1, 0));
+  hash = fhasher.add_hash(hash, _m(1, 1));
+  hash = fhasher.add_hash(hash, _m(1, 2));
 
 
-  hash = fhasher.add_hash(hash, _m.m._20);
-  hash = fhasher.add_hash(hash, _m.m._21);
-  hash = fhasher.add_hash(hash, _m.m._22);
+  hash = fhasher.add_hash(hash, _m(2, 0));
+  hash = fhasher.add_hash(hash, _m(2, 1));
+  hash = fhasher.add_hash(hash, _m(2, 2));
 
 
   return hash;
   return hash;
 }
 }
 
 
 #define VECTOR3_MATRIX3_PRODUCT(v_res, v, mat)                                              \
 #define VECTOR3_MATRIX3_PRODUCT(v_res, v, mat)                                              \
-v_res._v.v._0 = v._v.v._0*mat._m.m._00 + v._v.v._1*mat._m.m._10 + v._v.v._2*mat._m.m._20;   \
-v_res._v.v._1 = v._v.v._0*mat._m.m._01 + v._v.v._1*mat._m.m._11 + v._v.v._2*mat._m.m._21;   \
-v_res._v.v._2 = v._v.v._0*mat._m.m._02 + v._v.v._1*mat._m.m._12 + v._v.v._2*mat._m.m._22;
+v_res._v(0) = v._v(0)*mat._m(0, 0) + v._v(1)*mat._m(1, 0) + v._v(2)*mat._m(2, 0);   \
+v_res._v(1) = v._v(0)*mat._m(0, 1) + v._v(1)*mat._m(1, 1) + v._v(2)*mat._m(2, 1);   \
+v_res._v(2) = v._v(0)*mat._m(0, 2) + v._v(1)*mat._m(1, 2) + v._v(2)*mat._m(2, 2);
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: LMatrix3::xform
 //     Function: LMatrix3::xform
@@ -556,7 +587,11 @@ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix3)::
 xform(const FLOATNAME(LVecBase3) &v) const {
 xform(const FLOATNAME(LVecBase3) &v) const {
   TAU_PROFILE("LVecBase3 LMatrix3::xform(const LVecBase3 &)", " ", TAU_USER);
   TAU_PROFILE("LVecBase3 LMatrix3::xform(const LVecBase3 &)", " ", TAU_USER);
   FLOATNAME(LVecBase3) v_res;
   FLOATNAME(LVecBase3) v_res;
+#ifdef HAVE_EIGEN
+  v_res._v.noalias() = v._v * _m;
+#else  
   VECTOR3_MATRIX3_PRODUCT(v_res, v,(*this));
   VECTOR3_MATRIX3_PRODUCT(v_res, v,(*this));
+#endif  // HAVE_EIGEN
   
   
   return v_res;
   return v_res;
 }
 }
@@ -573,10 +608,14 @@ xform_point(const FLOATNAME(LVecBase2) &v) const {
   TAU_PROFILE("LVecBase3 LMatrix3::xform_point(const LVecBase3 &)", " ", TAU_USER);
   TAU_PROFILE("LVecBase3 LMatrix3::xform_point(const LVecBase3 &)", " ", TAU_USER);
   FLOATNAME(LVecBase2) v_res;
   FLOATNAME(LVecBase2) v_res;
 
 
-  // v._v.v._2 == 1.0f for this case
+  // v._v(2) == 1.0f for this case
   
   
-  v_res._v.v._0 = v._v.v._0*_m.m._00 + v._v.v._1*_m.m._10 + _m.m._20;
-  v_res._v.v._1 = v._v.v._0*_m.m._01 + v._v.v._1*_m.m._11 + _m.m._21;
+#ifdef HAVE_EIGEN
+  v_res._v.noalias() = v._v * _m.block<2, 2>(0, 0) + _m.block<1, 2>(2, 0);
+#else  
+  v_res._v(0) = v._v(0)*_m(0, 0) + v._v(1)*_m(1, 0) + _m(2, 0);
+  v_res._v(1) = v._v(0)*_m(0, 1) + v._v(1)*_m(1, 1) + _m(2, 1);
+#endif  // HAVE_EIGEN
   
   
   return v_res;
   return v_res;
 }
 }
@@ -594,15 +633,16 @@ xform_vec(const FLOATNAME(LVecBase2) &v) const {
 
 
   FLOATNAME(LVecBase2) v_res;
   FLOATNAME(LVecBase2) v_res;
 
 
-  // v._v.v._2 == 0.0f for this case
+  // v._v(2) == 0.0f for this case
   
   
-  v_res._v.v._0 = v._v.v._0*_m.m._00 + v._v.v._1*_m.m._10;
-  v_res._v.v._1 = v._v.v._0*_m.m._01 + v._v.v._1*_m.m._11;
+#ifdef HAVE_EIGEN
+  v_res._v.noalias() = v._v * _m.block<2, 2>(0, 0);
+#else  
+  v_res._v(0) = v._v(0)*_m(0, 0) + v._v(1)*_m(1, 0);
+  v_res._v(1) = v._v(0)*_m(0, 1) + v._v(1)*_m(1, 1);
+#endif  // HAVE_EIGEN
   
   
   return v_res;
   return v_res;
-  
-//  return FLOATNAME(LVecBase2)(v.dot(get_col2(0)),
-//                          v.dot(get_col2(1)));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -617,15 +657,7 @@ xform_vec(const FLOATNAME(LVecBase2) &v) const {
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix3)::
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix3)::
 xform_vec(const FLOATNAME(LVecBase3) &v) const {
 xform_vec(const FLOATNAME(LVecBase3) &v) const {
   TAU_PROFILE("LVecBase3 LMatrix3::xform_vec(const LVecBase3 &)", " ", TAU_USER);
   TAU_PROFILE("LVecBase3 LMatrix3::xform_vec(const LVecBase3 &)", " ", TAU_USER);
-  FLOATNAME(LVecBase3) v_res;
-  
-  // v._v.v._3 == 0.0f for this case
-  
-  v_res._v.v._0 = v._v.v._0*_m.m._00 + v._v.v._1*_m.m._10 + v._v.v._2*_m.m._20;
-  v_res._v.v._1 = v._v.v._0*_m.m._01 + v._v.v._1*_m.m._11 + v._v.v._2*_m.m._21;
-  v_res._v.v._2 = v._v.v._0*_m.m._02 + v._v.v._1*_m.m._12 + v._v.v._2*_m.m._22;
-  
-  return v_res;
+  return xform(v);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -638,34 +670,26 @@ xform_vec(const FLOATNAME(LVecBase3) &v) const {
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix3)::
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix3)::
 xform_vec_general(const FLOATNAME(LVecBase3) &v) const {
 xform_vec_general(const FLOATNAME(LVecBase3) &v) const {
   TAU_PROFILE("LVecBase3 LMatrix3::xform_vec_general(const LVecBase3 &)", " ", TAU_USER);
   TAU_PROFILE("LVecBase3 LMatrix3::xform_vec_general(const LVecBase3 &)", " ", TAU_USER);
+#ifdef HAVE_EIGEN
+  return FLOATNAME(LVecBase3)(v._v * _m.inverse().transpose());
+#else
   FLOATNAME(LMatrix3) i;
   FLOATNAME(LMatrix3) i;
   i.invert_transpose_from(*this);
   i.invert_transpose_from(*this);
 
 
   return i.xform(v);
   return i.xform(v);
+#endif  // HAVE_EIGEN
 }
 }
 
 
-////////////////////////////////////////////////////////////////////
-//     Function: LMatrix3::mult_cel
-//       Access: Private
-//  Description: Returns one cell of the result of a matrix-matrix
-//               multiplication operation.
-////////////////////////////////////////////////////////////////////
-INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix3)::
-mult_cel(const FLOATNAME(LMatrix3) &other, int row, int col) const {
-  return get_row(row).dot(other.get_col(col));
-}
-
-
 #define MATRIX3_PRODUCT(res, a, b)                   \
 #define MATRIX3_PRODUCT(res, a, b)                   \
-res._m.m._00 = a._m.m._00*b._m.m._00 + a._m.m._01*b._m.m._10 + a._m.m._02*b._m.m._20;   \
-res._m.m._01 = a._m.m._00*b._m.m._01 + a._m.m._01*b._m.m._11 + a._m.m._02*b._m.m._21;   \
-res._m.m._02 = a._m.m._00*b._m.m._02 + a._m.m._01*b._m.m._12 + a._m.m._02*b._m.m._22;   \
-res._m.m._10 = a._m.m._10*b._m.m._00 + a._m.m._11*b._m.m._10 + a._m.m._12*b._m.m._20;   \
-res._m.m._11 = a._m.m._10*b._m.m._01 + a._m.m._11*b._m.m._11 + a._m.m._12*b._m.m._21;   \
-res._m.m._12 = a._m.m._10*b._m.m._02 + a._m.m._11*b._m.m._12 + a._m.m._12*b._m.m._22;   \
-res._m.m._20 = a._m.m._20*b._m.m._00 + a._m.m._21*b._m.m._10 + a._m.m._22*b._m.m._20;   \
-res._m.m._21 = a._m.m._20*b._m.m._01 + a._m.m._21*b._m.m._11 + a._m.m._22*b._m.m._21;   \
-res._m.m._22 = a._m.m._20*b._m.m._02 + a._m.m._21*b._m.m._12 + a._m.m._22*b._m.m._22;
+res._m(0, 0) = a._m(0, 0)*b._m(0, 0) + a._m(0, 1)*b._m(1, 0) + a._m(0, 2)*b._m(2, 0);   \
+res._m(0, 1) = a._m(0, 0)*b._m(0, 1) + a._m(0, 1)*b._m(1, 1) + a._m(0, 2)*b._m(2, 1);   \
+res._m(0, 2) = a._m(0, 0)*b._m(0, 2) + a._m(0, 1)*b._m(1, 2) + a._m(0, 2)*b._m(2, 2);   \
+res._m(1, 0) = a._m(1, 0)*b._m(0, 0) + a._m(1, 1)*b._m(1, 0) + a._m(1, 2)*b._m(2, 0);   \
+res._m(1, 1) = a._m(1, 0)*b._m(0, 1) + a._m(1, 1)*b._m(1, 1) + a._m(1, 2)*b._m(2, 1);   \
+res._m(1, 2) = a._m(1, 0)*b._m(0, 2) + a._m(1, 1)*b._m(1, 2) + a._m(1, 2)*b._m(2, 2);   \
+res._m(2, 0) = a._m(2, 0)*b._m(0, 0) + a._m(2, 1)*b._m(1, 0) + a._m(2, 2)*b._m(2, 0);   \
+res._m(2, 1) = a._m(2, 0)*b._m(0, 1) + a._m(2, 1)*b._m(1, 1) + a._m(2, 2)*b._m(2, 1);   \
+res._m(2, 2) = a._m(2, 0)*b._m(0, 2) + a._m(2, 1)*b._m(1, 2) + a._m(2, 2)*b._m(2, 2);
 
 
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -703,17 +727,17 @@ operator * (FLOATTYPE scalar) const {
   TAU_PROFILE("LMatrix3 operator *(const LMatrix3 &, FLOATTYPE)", " ", TAU_USER);
   TAU_PROFILE("LMatrix3 operator *(const LMatrix3 &, FLOATTYPE)", " ", TAU_USER);
   FLOATNAME(LMatrix3) t;
   FLOATNAME(LMatrix3) t;
 
 
-  t._m.m._00 = _m.m._00 * scalar;
-  t._m.m._01 = _m.m._01 * scalar;
-  t._m.m._02 = _m.m._02 * scalar;
+  t._m(0, 0) = _m(0, 0) * scalar;
+  t._m(0, 1) = _m(0, 1) * scalar;
+  t._m(0, 2) = _m(0, 2) * scalar;
 
 
-  t._m.m._10 = _m.m._10 * scalar;
-  t._m.m._11 = _m.m._11 * scalar;
-  t._m.m._12 = _m.m._12 * scalar;
+  t._m(1, 0) = _m(1, 0) * scalar;
+  t._m(1, 1) = _m(1, 1) * scalar;
+  t._m(1, 2) = _m(1, 2) * scalar;
 
 
-  t._m.m._20 = _m.m._20 * scalar;
-  t._m.m._21 = _m.m._21 * scalar;
-  t._m.m._22 = _m.m._22 * scalar;
+  t._m(2, 0) = _m(2, 0) * scalar;
+  t._m(2, 1) = _m(2, 1) * scalar;
+  t._m(2, 2) = _m(2, 2) * scalar;
 
 
   return t;
   return t;
 }
 }
@@ -737,17 +761,17 @@ operator / (FLOATTYPE scalar) const {
 INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3)::
 INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3)::
 operator += (const FLOATNAME(LMatrix3) &other) {
 operator += (const FLOATNAME(LMatrix3) &other) {
   TAU_PROFILE("LMatrix3 LMatrix3::operator +=(const LMatrix3 &)", " ", TAU_USER);
   TAU_PROFILE("LMatrix3 LMatrix3::operator +=(const LMatrix3 &)", " ", TAU_USER);
-  _m.m._00 += other._m.m._00;
-  _m.m._01 += other._m.m._01;
-  _m.m._02 += other._m.m._02;
+  _m(0, 0) += other._m(0, 0);
+  _m(0, 1) += other._m(0, 1);
+  _m(0, 2) += other._m(0, 2);
 
 
-  _m.m._10 += other._m.m._10;
-  _m.m._11 += other._m.m._11;
-  _m.m._12 += other._m.m._12;
+  _m(1, 0) += other._m(1, 0);
+  _m(1, 1) += other._m(1, 1);
+  _m(1, 2) += other._m(1, 2);
 
 
-  _m.m._20 += other._m.m._20;
-  _m.m._21 += other._m.m._21;
-  _m.m._22 += other._m.m._22;
+  _m(2, 0) += other._m(2, 0);
+  _m(2, 1) += other._m(2, 1);
+  _m(2, 2) += other._m(2, 2);
 
 
   return *this;
   return *this;
 }
 }
@@ -760,17 +784,17 @@ operator += (const FLOATNAME(LMatrix3) &other) {
 INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3)::
 INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3)::
 operator -= (const FLOATNAME(LMatrix3) &other) {
 operator -= (const FLOATNAME(LMatrix3) &other) {
   TAU_PROFILE("LMatrix3 LMatrix3::operator -=(const LMatrix3 &)", " ", TAU_USER);
   TAU_PROFILE("LMatrix3 LMatrix3::operator -=(const LMatrix3 &)", " ", TAU_USER);
-  _m.m._00 -= other._m.m._00;
-  _m.m._01 -= other._m.m._01;
-  _m.m._02 -= other._m.m._02;
+  _m(0, 0) -= other._m(0, 0);
+  _m(0, 1) -= other._m(0, 1);
+  _m(0, 2) -= other._m(0, 2);
 
 
-  _m.m._10 -= other._m.m._10;
-  _m.m._11 -= other._m.m._11;
-  _m.m._12 -= other._m.m._12;
+  _m(1, 0) -= other._m(1, 0);
+  _m(1, 1) -= other._m(1, 1);
+  _m(1, 2) -= other._m(1, 2);
 
 
-  _m.m._20 -= other._m.m._20;
-  _m.m._21 -= other._m.m._21;
-  _m.m._22 -= other._m.m._22;
+  _m(2, 0) -= other._m(2, 0);
+  _m(2, 1) -= other._m(2, 1);
+  _m(2, 2) -= other._m(2, 2);
 
 
   return *this;
   return *this;
 }
 }
@@ -797,17 +821,17 @@ operator *= (const FLOATNAME(LMatrix3) &other) {
 INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3)::
 INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3)::
 operator *= (FLOATTYPE scalar) {
 operator *= (FLOATTYPE scalar) {
   TAU_PROFILE("LMatrix3 LMatrix3::operator *=(FLOATTYPE)", " ", TAU_USER);
   TAU_PROFILE("LMatrix3 LMatrix3::operator *=(FLOATTYPE)", " ", TAU_USER);
-  _m.m._00 *= scalar;
-  _m.m._01 *= scalar;
-  _m.m._02 *= scalar;
+  _m(0, 0) *= scalar;
+  _m(0, 1) *= scalar;
+  _m(0, 2) *= scalar;
 
 
-  _m.m._10 *= scalar;
-  _m.m._11 *= scalar;
-  _m.m._12 *= scalar;
+  _m(1, 0) *= scalar;
+  _m(1, 1) *= scalar;
+  _m(1, 2) *= scalar;
 
 
-  _m.m._20 *= scalar;
-  _m.m._21 *= scalar;
-  _m.m._22 *= scalar;
+  _m(2, 0) *= scalar;
+  _m(2, 1) *= scalar;
+  _m(2, 2) *= scalar;
 
 
   return *this;
   return *this;
 }
 }
@@ -821,17 +845,17 @@ INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3)::
 operator /= (FLOATTYPE scalar) {
 operator /= (FLOATTYPE scalar) {
   TAU_PROFILE("LMatrix3 LMatrix3::operator /=(FLOATTYPE)", " ", TAU_USER);
   TAU_PROFILE("LMatrix3 LMatrix3::operator /=(FLOATTYPE)", " ", TAU_USER);
   FLOATTYPE recip_scalar = 1.0f/scalar;
   FLOATTYPE recip_scalar = 1.0f/scalar;
-  _m.m._00 *= recip_scalar;
-  _m.m._01 *= recip_scalar;
-  _m.m._02 *= recip_scalar;
+  _m(0, 0) *= recip_scalar;
+  _m(0, 1) *= recip_scalar;
+  _m(0, 2) *= recip_scalar;
 
 
-  _m.m._10 *= recip_scalar;
-  _m.m._11 *= recip_scalar;
-  _m.m._12 *= recip_scalar;
+  _m(1, 0) *= recip_scalar;
+  _m(1, 1) *= recip_scalar;
+  _m(1, 2) *= recip_scalar;
 
 
-  _m.m._20 *= recip_scalar;
-  _m.m._21 *= recip_scalar;
-  _m.m._22 *= recip_scalar;
+  _m(2, 0) *= recip_scalar;
+  _m(2, 1) *= recip_scalar;
+  _m(2, 2) *= recip_scalar;
 
 
   return *this;
   return *this;
 }
 }
@@ -844,17 +868,17 @@ operator /= (FLOATTYPE scalar) {
 INLINE_LINMATH void FLOATNAME(LMatrix3)::
 INLINE_LINMATH void FLOATNAME(LMatrix3)::
 transpose_from(const FLOATNAME(LMatrix3) &other) {
 transpose_from(const FLOATNAME(LMatrix3) &other) {
   TAU_PROFILE("LMatrix3 LMatrix3::transpose_from(const LMatrix3 &other)", " ", TAU_USER);
   TAU_PROFILE("LMatrix3 LMatrix3::transpose_from(const LMatrix3 &other)", " ", TAU_USER);
-  _m.m._00 = other._m.m._00;
-  _m.m._01 = other._m.m._10;
-  _m.m._02 = other._m.m._20;
+  _m(0, 0) = other._m(0, 0);
+  _m(0, 1) = other._m(1, 0);
+  _m(0, 2) = other._m(2, 0);
 
 
-  _m.m._10 = other._m.m._01;
-  _m.m._11 = other._m.m._11;
-  _m.m._12 = other._m.m._21;
+  _m(1, 0) = other._m(0, 1);
+  _m(1, 1) = other._m(1, 1);
+  _m(1, 2) = other._m(2, 1);
 
 
-  _m.m._20 = other._m.m._02;
-  _m.m._21 = other._m.m._12;
-  _m.m._22 = other._m.m._22;
+  _m(2, 0) = other._m(0, 2);
+  _m(2, 1) = other._m(1, 2);
+  _m(2, 2) = other._m(2, 2);
 }
 }
 
 
 
 
@@ -868,9 +892,9 @@ transpose_in_place() {
   TAU_PROFILE("void LMatrix3::transpose_in_place()", " ", TAU_USER);
   TAU_PROFILE("void LMatrix3::transpose_in_place()", " ", TAU_USER);
 
 
   #define SWAP__(x,y) { FLOATTYPE temp = (x);  (x) = (y);  (y) = temp;}
   #define SWAP__(x,y) { FLOATTYPE temp = (x);  (x) = (y);  (y) = temp;}
-  SWAP__(_m.m._01,_m.m._10);
-  SWAP__(_m.m._02,_m.m._20);
-  SWAP__(_m.m._12,_m.m._21);
+  SWAP__(_m(0, 1),_m(1, 0));
+  SWAP__(_m(0, 2),_m(2, 0));
+  SWAP__(_m(1, 2),_m(2, 1));
   #undef SWAP__
   #undef SWAP__
 }
 }
 
 
@@ -879,21 +903,9 @@ transpose_in_place() {
 // don't trust compilers to inline these
 // don't trust compilers to inline these
 #define DET2(E00,E01,E10,E11) ((E00)*(E11) - (E10)*(E01))
 #define DET2(E00,E01,E10,E11) ((E00)*(E11) - (E10)*(E01))
 #define MATRIX3_DETERMINANT(mat)                                  \
 #define MATRIX3_DETERMINANT(mat)                                  \
-   ( (mat)._00 * DET2((mat)._11,(mat)._12,(mat)._21,(mat)._22)    \
-    -(mat)._01 * DET2((mat)._10,(mat)._12,(mat)._20,(mat)._22)    \
-    +(mat)._02 * DET2((mat)._10,(mat)._11,(mat)._20,(mat)._21))
-
-
-////////////////////////////////////////////////////////////////////
-//     Function: LMatrix3::det2
-//       Access: Private, Static
-//  Description: Returns the determinant of a 2x2 matrix.
-////////////////////////////////////////////////////////////////////
-INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix3)::
-det2(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e10, FLOATTYPE e11) const {
-  TAU_PROFILE("FLOATTYPE LMatrix3::det2()", " ", TAU_USER);
-  return DET2(e00, e01, e10, e11);
-}
+   ( (mat)(0, 0) * DET2((mat)(1, 1),(mat)(1, 2),(mat)(2, 1),(mat)(2, 2))    \
+    -(mat)(0, 1) * DET2((mat)(1, 0),(mat)(1, 2),(mat)(2, 0),(mat)(2, 2))    \
+    +(mat)(0, 2) * DET2((mat)(1, 0),(mat)(1, 1),(mat)(2, 0),(mat)(2, 1)))
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: LMatrix3::determinant
 //     Function: LMatrix3::determinant
@@ -904,7 +916,11 @@ INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix3)::
 determinant() const {
 determinant() const {
   TAU_PROFILE("FLOATTYPE LMatrix3::determinant()", " ", TAU_USER);
   TAU_PROFILE("FLOATTYPE LMatrix3::determinant()", " ", TAU_USER);
 
 
- return MATRIX3_DETERMINANT(_m.m);
+#ifdef HAVE_EIGEN
+  return _m.determinant();
+#else
+ return MATRIX3_DETERMINANT(_m);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -927,7 +943,23 @@ INLINE_LINMATH bool FLOATNAME(LMatrix3)::
 invert_from(const FLOATNAME(LMatrix3) &other) {
 invert_from(const FLOATNAME(LMatrix3) &other) {
   TAU_PROFILE("bool LMatrix3::invert_from(const LMatrix3 &)", " ", TAU_USER);
   TAU_PROFILE("bool LMatrix3::invert_from(const LMatrix3 &)", " ", TAU_USER);
 
 
-  FLOATTYPE other_det = MATRIX3_DETERMINANT(other._m.m);
+#ifdef HAVE_EIGEN
+  bool invertible;
+  other._m.computeInverseWithCheck(_m, invertible);
+
+  if (!invertible) {
+#ifdef NDEBUG
+    linmath_cat.warning() << "Tried to invert singular LMatrix3.\n";
+#endif
+    (*this) = ident_mat();
+    nassertr(!no_singular_invert, false);
+  }
+
+  return invertible;
+
+#else  // HAVE_EIGEN
+
+  FLOATTYPE other_det = MATRIX3_DETERMINANT(other._m);
 
 
   // We throw the value out only if it's smaller than our "small"
   // We throw the value out only if it's smaller than our "small"
   // threshold squared.  This helps reduce overly-sensitive
   // threshold squared.  This helps reduce overly-sensitive
@@ -943,19 +975,20 @@ invert_from(const FLOATNAME(LMatrix3) &other) {
   }
   }
 
 
   other_det = 1.0f / other_det;
   other_det = 1.0f / other_det;
-  _m.m._00 =  other_det * DET2(other._m.m._11, other._m.m._12, other._m.m._21, other._m.m._22);
-  _m.m._10 = -other_det * DET2(other._m.m._10, other._m.m._12, other._m.m._20, other._m.m._22);
-  _m.m._20 =  other_det * DET2(other._m.m._10, other._m.m._11, other._m.m._20, other._m.m._21);
+  _m(0, 0) =  other_det * DET2(other._m(1, 1), other._m(1, 2), other._m(2, 1), other._m(2, 2));
+  _m(1, 0) = -other_det * DET2(other._m(1, 0), other._m(1, 2), other._m(2, 0), other._m(2, 2));
+  _m(2, 0) =  other_det * DET2(other._m(1, 0), other._m(1, 1), other._m(2, 0), other._m(2, 1));
 
 
-  _m.m._01 = -other_det * DET2(other._m.m._01, other._m.m._02, other._m.m._21, other._m.m._22);
-  _m.m._11 =  other_det * DET2(other._m.m._00, other._m.m._02, other._m.m._20, other._m.m._22);
-  _m.m._21 = -other_det * DET2(other._m.m._00, other._m.m._01, other._m.m._20, other._m.m._21);
+  _m(0, 1) = -other_det * DET2(other._m(0, 1), other._m(0, 2), other._m(2, 1), other._m(2, 2));
+  _m(1, 1) =  other_det * DET2(other._m(0, 0), other._m(0, 2), other._m(2, 0), other._m(2, 2));
+  _m(2, 1) = -other_det * DET2(other._m(0, 0), other._m(0, 1), other._m(2, 0), other._m(2, 1));
 
 
-  _m.m._02 =  other_det * DET2(other._m.m._01, other._m.m._02, other._m.m._11, other._m.m._12);
-  _m.m._12 = -other_det * DET2(other._m.m._00, other._m.m._02, other._m.m._10, other._m.m._12);
-  _m.m._22 =  other_det * DET2(other._m.m._00, other._m.m._01, other._m.m._10, other._m.m._11);
+  _m(0, 2) =  other_det * DET2(other._m(0, 1), other._m(0, 2), other._m(1, 1), other._m(1, 2));
+  _m(1, 2) = -other_det * DET2(other._m(0, 0), other._m(0, 2), other._m(1, 0), other._m(1, 2));
+  _m(2, 2) =  other_det * DET2(other._m(0, 0), other._m(0, 1), other._m(1, 0), other._m(1, 1));
 
 
   return true;
   return true;
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -982,30 +1015,49 @@ INLINE_LINMATH bool FLOATNAME(LMatrix3)::
 invert_transpose_from(const FLOATNAME(LMatrix3) &other) {
 invert_transpose_from(const FLOATNAME(LMatrix3) &other) {
   TAU_PROFILE("bool LMatrix3::invert_transpose_from(const LMatrix3 &)", " ", TAU_USER);
   TAU_PROFILE("bool LMatrix3::invert_transpose_from(const LMatrix3 &)", " ", TAU_USER);
 
 
-  FLOATTYPE other_det = MATRIX3_DETERMINANT(other._m.m);
+#ifdef HAVE_EIGEN
+  bool invertible;
+  EMatrix3 temp;
+  other._m.computeInverseWithCheck(temp, invertible);
+
+  if (!invertible) {
+#ifdef NDEBUG
+    linmath_cat.warning() << "Tried to invert singular LMatrix3.\n";
+#endif
+    (*this) = ident_mat();
+    nassertr(!no_singular_invert, false);
+  }
+
+  _m = temp.transpose();
+  return true;
+
+#else  // HAVE_EIGEN
+  FLOATTYPE other_det = MATRIX3_DETERMINANT(other._m);
 
 
   if (IS_THRESHOLD_ZERO(other_det, (NEARLY_ZERO(FLOATTYPE) * NEARLY_ZERO(FLOATTYPE)))) {
   if (IS_THRESHOLD_ZERO(other_det, (NEARLY_ZERO(FLOATTYPE) * NEARLY_ZERO(FLOATTYPE)))) {
 #ifdef NOTIFY_DEBUG
 #ifdef NOTIFY_DEBUG
     linmath_cat.warning() << "Tried to invert singular LMatrix3.\n";
     linmath_cat.warning() << "Tried to invert singular LMatrix3.\n";
 #endif
 #endif
     (*this) = ident_mat();
     (*this) = ident_mat();
+    nassertr(!no_singular_invert, false);
     return false;
     return false;
   }
   }
 
 
   other_det = 1.0f / other_det;
   other_det = 1.0f / other_det;
-  _m.m._00 =  other_det * DET2(other._m.m._11, other._m.m._12, other._m.m._21, other._m.m._22);
-  _m.m._01 = -other_det * DET2(other._m.m._10, other._m.m._12, other._m.m._20, other._m.m._22);
-  _m.m._02 =  other_det * DET2(other._m.m._10, other._m.m._11, other._m.m._20, other._m.m._21);
+  _m(0, 0) =  other_det * DET2(other._m(1, 1), other._m(1, 2), other._m(2, 1), other._m(2, 2));
+  _m(0, 1) = -other_det * DET2(other._m(1, 0), other._m(1, 2), other._m(2, 0), other._m(2, 2));
+  _m(0, 2) =  other_det * DET2(other._m(1, 0), other._m(1, 1), other._m(2, 0), other._m(2, 1));
 
 
-  _m.m._10 = -other_det * DET2(other._m.m._01, other._m.m._02, other._m.m._21, other._m.m._22);
-  _m.m._11 =  other_det * DET2(other._m.m._00, other._m.m._02, other._m.m._20, other._m.m._22);
-  _m.m._12 = -other_det * DET2(other._m.m._00, other._m.m._01, other._m.m._20, other._m.m._21);
+  _m(1, 0) = -other_det * DET2(other._m(0, 1), other._m(0, 2), other._m(2, 1), other._m(2, 2));
+  _m(1, 1) =  other_det * DET2(other._m(0, 0), other._m(0, 2), other._m(2, 0), other._m(2, 2));
+  _m(1, 2) = -other_det * DET2(other._m(0, 0), other._m(0, 1), other._m(2, 0), other._m(2, 1));
 
 
-  _m.m._20 =  other_det * DET2(other._m.m._01, other._m.m._02, other._m.m._11, other._m.m._12);
-  _m.m._21 = -other_det * DET2(other._m.m._00, other._m.m._02, other._m.m._10, other._m.m._12);
-  _m.m._22 =  other_det * DET2(other._m.m._00, other._m.m._01, other._m.m._10, other._m.m._11);
+  _m(2, 0) =  other_det * DET2(other._m(0, 1), other._m(0, 2), other._m(1, 1), other._m(1, 2));
+  _m(2, 1) = -other_det * DET2(other._m(0, 0), other._m(0, 2), other._m(1, 0), other._m(1, 2));
+  _m(2, 2) =  other_det * DET2(other._m(0, 0), other._m(0, 1), other._m(1, 0), other._m(1, 1));
 
 
   return true;
   return true;
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -1018,30 +1070,50 @@ INLINE_LINMATH bool FLOATNAME(LMatrix3)::
 invert_transpose_from(const FLOATNAME(LMatrix4) &other) {
 invert_transpose_from(const FLOATNAME(LMatrix4) &other) {
   TAU_PROFILE("bool LMatrix3::invert_transpose_from(const LMatrix4 &)", " ", TAU_USER);
   TAU_PROFILE("bool LMatrix3::invert_transpose_from(const LMatrix4 &)", " ", TAU_USER);
 
 
-  FLOATTYPE other_det = MATRIX3_DETERMINANT(other._m.m);
+#ifdef HAVE_EIGEN
+  bool invertible;
+  EMatrix3 temp;
+  other._m.block<3, 3>(0, 0).computeInverseWithCheck(temp, invertible);
+
+  if (!invertible) {
+#ifdef NDEBUG
+    linmath_cat.warning() << "Tried to invert singular LMatrix3.\n";
+#endif
+    (*this) = ident_mat();
+    nassertr(!no_singular_invert, false);
+  }
+
+  _m = temp.transpose();
+  return true;
+
+#else  // HAVE_EIGEN
+
+  FLOATTYPE other_det = MATRIX3_DETERMINANT(other._m);
 
 
   if (IS_THRESHOLD_ZERO(other_det, (NEARLY_ZERO(FLOATTYPE) * NEARLY_ZERO(FLOATTYPE)))) {
   if (IS_THRESHOLD_ZERO(other_det, (NEARLY_ZERO(FLOATTYPE) * NEARLY_ZERO(FLOATTYPE)))) {
 #ifdef NOTIFY_DEBUG
 #ifdef NOTIFY_DEBUG
     linmath_cat.warning() << "Tried to invert singular LMatrix4.\n";
     linmath_cat.warning() << "Tried to invert singular LMatrix4.\n";
 #endif
 #endif
     (*this) = ident_mat();
     (*this) = ident_mat();
+    nassertr(!no_singular_invert, false);
     return false;
     return false;
   }
   }
 
 
   other_det = 1.0f / other_det;
   other_det = 1.0f / other_det;
-  _m.m._00 =  other_det * DET2(other._m.m._11, other._m.m._12, other._m.m._21, other._m.m._22);
-  _m.m._01 = -other_det * DET2(other._m.m._10, other._m.m._12, other._m.m._20, other._m.m._22);
-  _m.m._02 =  other_det * DET2(other._m.m._10, other._m.m._11, other._m.m._20, other._m.m._21);
+  _m(0, 0) =  other_det * DET2(other._m(1, 1), other._m(1, 2), other._m(2, 1), other._m(2, 2));
+  _m(0, 1) = -other_det * DET2(other._m(1, 0), other._m(1, 2), other._m(2, 0), other._m(2, 2));
+  _m(0, 2) =  other_det * DET2(other._m(1, 0), other._m(1, 1), other._m(2, 0), other._m(2, 1));
 
 
-  _m.m._10 = -other_det * DET2(other._m.m._01, other._m.m._02, other._m.m._21, other._m.m._22);
-  _m.m._11 =  other_det * DET2(other._m.m._00, other._m.m._02, other._m.m._20, other._m.m._22);
-  _m.m._12 = -other_det * DET2(other._m.m._00, other._m.m._01, other._m.m._20, other._m.m._21);
+  _m(1, 0) = -other_det * DET2(other._m(0, 1), other._m(0, 2), other._m(2, 1), other._m(2, 2));
+  _m(1, 1) =  other_det * DET2(other._m(0, 0), other._m(0, 2), other._m(2, 0), other._m(2, 2));
+  _m(1, 2) = -other_det * DET2(other._m(0, 0), other._m(0, 1), other._m(2, 0), other._m(2, 1));
 
 
-  _m.m._20 =  other_det * DET2(other._m.m._01, other._m.m._02, other._m.m._11, other._m.m._12);
-  _m.m._21 = -other_det * DET2(other._m.m._00, other._m.m._02, other._m.m._10, other._m.m._12);
-  _m.m._22 =  other_det * DET2(other._m.m._00, other._m.m._01, other._m.m._10, other._m.m._11);
+  _m(2, 0) =  other_det * DET2(other._m(0, 1), other._m(0, 2), other._m(1, 1), other._m(1, 2));
+  _m(2, 1) = -other_det * DET2(other._m(0, 0), other._m(0, 2), other._m(1, 0), other._m(1, 2));
+  _m(2, 2) =  other_det * DET2(other._m(0, 0), other._m(0, 1), other._m(1, 0), other._m(1, 1));
 
 
   return true;
   return true;
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -1054,7 +1126,7 @@ INLINE_LINMATH void FLOATNAME(LMatrix3)::
 set_translate_mat(const FLOATNAME(LVecBase2) &trans) {
 set_translate_mat(const FLOATNAME(LVecBase2) &trans) {
   set(1.0f, 0.0f, 0.0f,
   set(1.0f, 0.0f, 0.0f,
       0.0f, 1.0f, 0.0f,
       0.0f, 1.0f, 0.0f,
-      trans._v.v._0, trans._v.v._1, 1.0f);
+      trans._v(0), trans._v(1), 1.0f);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -1082,8 +1154,8 @@ set_rotate_mat(FLOATTYPE angle) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LMatrix3)::
 INLINE_LINMATH void FLOATNAME(LMatrix3)::
 set_scale_mat(const FLOATNAME(LVecBase2) &scale) {
 set_scale_mat(const FLOATNAME(LVecBase2) &scale) {
-  set(scale._v.v._0, 0.0f, 0.0f,
-      0.0f, scale._v.v._1, 0.0f,
+  set(scale._v(0), 0.0f, 0.0f,
+      0.0f, scale._v(1), 0.0f,
       0.0f, 0.0f, 1.0f);
       0.0f, 0.0f, 1.0f);
 }
 }
 
 
@@ -1097,7 +1169,7 @@ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3)::
 translate_mat(const FLOATNAME(LVecBase2) &trans) {
 translate_mat(const FLOATNAME(LVecBase2) &trans) {
   return FLOATNAME(LMatrix3)(1.0f, 0.0f, 0.0f,
   return FLOATNAME(LMatrix3)(1.0f, 0.0f, 0.0f,
                              0.0f, 1.0f, 0.0f,
                              0.0f, 1.0f, 0.0f,
-                             trans._v.v._0, trans._v.v._1, 1.0f);
+                             trans._v(0), trans._v(1), 1.0f);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -1134,8 +1206,8 @@ rotate_mat(FLOATTYPE angle) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3)::
 INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3)::
 scale_mat(const FLOATNAME(LVecBase2) &scale) {
 scale_mat(const FLOATNAME(LVecBase2) &scale) {
-  return FLOATNAME(LMatrix3)(scale._v.v._0, 0.0f, 0.0f,
-                             0.0f, scale._v.v._1, 0.0f,
+  return FLOATNAME(LMatrix3)(scale._v(0), 0.0f, 0.0f,
+                             0.0f, scale._v(1), 0.0f,
                              0.0f, 0.0f, 1.0f);
                              0.0f, 0.0f, 1.0f);
 }
 }
 
 
@@ -1189,9 +1261,9 @@ rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis,
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LMatrix3)::
 INLINE_LINMATH void FLOATNAME(LMatrix3)::
 set_scale_mat(const FLOATNAME(LVecBase3) &scale) {
 set_scale_mat(const FLOATNAME(LVecBase3) &scale) {
-  set(scale._v.v._0, 0.0f, 0.0f,
-      0.0f, scale._v.v._1, 0.0f,
-      0.0f, 0.0f, scale._v.v._2);
+  set(scale._v(0), 0.0f, 0.0f,
+      0.0f, scale._v(1), 0.0f,
+      0.0f, 0.0f, scale._v(2));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -1202,9 +1274,9 @@ set_scale_mat(const FLOATNAME(LVecBase3) &scale) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3)::
 INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3)::
 scale_mat(const FLOATNAME(LVecBase3) &scale) {
 scale_mat(const FLOATNAME(LVecBase3) &scale) {
-  return FLOATNAME(LMatrix3)(scale._v.v._0, 0.0f, 0.0f,
-                             0.0f, scale._v.v._1, 0.0f,
-                             0.0f, 0.0f, scale._v.v._2);
+  return FLOATNAME(LMatrix3)(scale._v(0), 0.0f, 0.0f,
+                             0.0f, scale._v(1), 0.0f,
+                             0.0f, 0.0f, scale._v(2));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 75 - 69
panda/src/linmath/lmatrix3_src.cxx

@@ -68,49 +68,49 @@ set_scale_shear_mat(const FLOATNAME(LVecBase3) &scale,
   switch (cs) {
   switch (cs) {
   case CS_zup_right:
   case CS_zup_right:
     if (temp_hpr_fix) {
     if (temp_hpr_fix) {
-      set(scale._v.v._0, shear._v.v._0 * scale._v.v._0, 0.0f,
-          0.0f, scale._v.v._1, 0.0f,
-          shear._v.v._1 * scale._v.v._2, shear._v.v._2 * scale._v.v._2, scale._v.v._2);
+      set(scale._v(0), shear._v(0) * scale._v(0), 0.0f,
+          0.0f, scale._v(1), 0.0f,
+          shear._v(1) * scale._v(2), shear._v(2) * scale._v(2), scale._v(2));
     } else {
     } else {
-      set(scale._v.v._0, 0.0f, 0.0f,
-          shear._v.v._0 * scale._v.v._1, scale._v.v._1, 0.0f,
-          shear._v.v._1 * scale._v.v._2, shear._v.v._2 * scale._v.v._2, scale._v.v._2);
+      set(scale._v(0), 0.0f, 0.0f,
+          shear._v(0) * scale._v(1), scale._v(1), 0.0f,
+          shear._v(1) * scale._v(2), shear._v(2) * scale._v(2), scale._v(2));
     }
     }
     break;
     break;
     
     
   case CS_zup_left:
   case CS_zup_left:
     if (temp_hpr_fix) {
     if (temp_hpr_fix) {
-      set(scale._v.v._0, shear._v.v._0 * scale._v.v._0, 0.0f,
-          0.0f, scale._v.v._1, 0.0f,
-          -shear._v.v._1 * scale._v.v._2, -shear._v.v._2 * scale._v.v._2, scale._v.v._2);
+      set(scale._v(0), shear._v(0) * scale._v(0), 0.0f,
+          0.0f, scale._v(1), 0.0f,
+          -shear._v(1) * scale._v(2), -shear._v(2) * scale._v(2), scale._v(2));
     } else {
     } else {
-      set(scale._v.v._0, 0.0f, 0.0f,
-          shear._v.v._0 * scale._v.v._1, scale._v.v._1, 0.0f,
-          -shear._v.v._1 * scale._v.v._2, -shear._v.v._2 * scale._v.v._2, scale._v.v._2);
+      set(scale._v(0), 0.0f, 0.0f,
+          shear._v(0) * scale._v(1), scale._v(1), 0.0f,
+          -shear._v(1) * scale._v(2), -shear._v(2) * scale._v(2), scale._v(2));
     }
     }
     break;
     break;
     
     
   case CS_yup_right:
   case CS_yup_right:
     if (temp_hpr_fix) {
     if (temp_hpr_fix) {
-      set(scale._v.v._0, 0.0f, shear._v.v._1 * scale._v.v._0,
-          shear._v.v._0 * scale._v.v._1, scale._v.v._1, shear._v.v._2 * scale._v.v._1,
-          0.0f, 0.0f, scale._v.v._2);
+      set(scale._v(0), 0.0f, shear._v(1) * scale._v(0),
+          shear._v(0) * scale._v(1), scale._v(1), shear._v(2) * scale._v(1),
+          0.0f, 0.0f, scale._v(2));
     } else {
     } else {
-      set(scale._v.v._0, 0.0f, 0.0f,
-          shear._v.v._0 * scale._v.v._1, scale._v.v._1, shear._v.v._2 * scale._v.v._1,
-          shear._v.v._1 * scale._v.v._2, 0.0f, scale._v.v._2);
+      set(scale._v(0), 0.0f, 0.0f,
+          shear._v(0) * scale._v(1), scale._v(1), shear._v(2) * scale._v(1),
+          shear._v(1) * scale._v(2), 0.0f, scale._v(2));
     }
     }
     break;
     break;
     
     
   case CS_yup_left:
   case CS_yup_left:
     if (temp_hpr_fix) {
     if (temp_hpr_fix) {
-      set(scale._v.v._0, 0.0f, -shear._v.v._1 * scale._v.v._0,
-          shear._v.v._0 * scale._v.v._1, scale._v.v._1, -shear._v.v._2 * scale._v.v._1,
-          0.0f, 0.0f, scale._v.v._2);
+      set(scale._v(0), 0.0f, -shear._v(1) * scale._v(0),
+          shear._v(0) * scale._v(1), scale._v(1), -shear._v(2) * scale._v(1),
+          0.0f, 0.0f, scale._v(2));
     } else {
     } else {
-      set(scale._v.v._0, 0.0f, 0.0f,
-          shear._v.v._0 * scale._v.v._1, scale._v.v._1, -shear._v.v._2 * scale._v.v._1,
-          -shear._v.v._1 * scale._v.v._2, 0.0f, scale._v.v._2);
+      set(scale._v(0), 0.0f, 0.0f,
+          shear._v(0) * scale._v(1), scale._v(1), -shear._v(2) * scale._v(1),
+          -shear._v(1) * scale._v(2), 0.0f, scale._v(2));
     }
     }
     break;
     break;
     
     
@@ -199,9 +199,13 @@ convert_mat(CoordinateSystem from, CoordinateSystem to) {
 void FLOATNAME(LMatrix3)::
 void FLOATNAME(LMatrix3)::
 fill(FLOATTYPE fill_value) {
 fill(FLOATTYPE fill_value) {
   TAU_PROFILE("void LMatrix3::fill(FLOATTYPE)", " ", TAU_USER);
   TAU_PROFILE("void LMatrix3::fill(FLOATTYPE)", " ", TAU_USER);
+#ifdef HAVE_EIGEN
+  _m = EMatrix3::Constant(fill_value);
+#else
   set(fill_value, fill_value, fill_value,
   set(fill_value, fill_value, fill_value,
       fill_value, fill_value, fill_value,
       fill_value, fill_value, fill_value,
       fill_value, fill_value, fill_value);
       fill_value, fill_value, fill_value);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -216,9 +220,11 @@ fill(FLOATTYPE fill_value) {
 int FLOATNAME(LMatrix3)::
 int FLOATNAME(LMatrix3)::
 compare_to(const FLOATNAME(LMatrix3) &other, FLOATTYPE threshold) const {
 compare_to(const FLOATNAME(LMatrix3) &other, FLOATTYPE threshold) const {
   TAU_PROFILE("int LMatrix3::compare_to(const LMatrix3 &, FLOATTYPE)", " ", TAU_USER);
   TAU_PROFILE("int LMatrix3::compare_to(const LMatrix3 &, FLOATTYPE)", " ", TAU_USER);
-  for (int i = 0; i < 9; i++) {
-    if (!IS_THRESHOLD_COMPEQ(_m.data[i], other._m.data[i], threshold)) {
-      return (_m.data[i] < other._m.data[i]) ? -1 : 1;
+  for (int r = 0; r < 3; ++r) {
+    for (int c = 0; c < 3; ++c) {
+      if (!IS_THRESHOLD_COMPEQ(_m(r, c), other._m(r, c), threshold)) {
+        return (_m(r, c) < other._m(r, c)) ? -1 : 1;
+      }
     }
     }
   }
   }
   return 0;
   return 0;
@@ -245,9 +251,9 @@ set_rotate_mat(FLOATTYPE angle, FLOATNAME(LVecBase3) axis,
     angle = -angle;
     angle = -angle;
   }
   }
 
 
-  FLOATTYPE axis_0 = axis._v.v._0;
-  FLOATTYPE axis_1 = axis._v.v._1;
-  FLOATTYPE axis_2 = axis._v.v._2;
+  FLOATTYPE axis_0 = axis._v(0);
+  FLOATTYPE axis_1 = axis._v(1);
+  FLOATTYPE axis_2 = axis._v(2);
 
 
   // Normalize the axis.
   // Normalize the axis.
   FLOATTYPE length_sq = axis_0 * axis_0 + axis_1 * axis_1 + axis_2 * axis_2;
   FLOATTYPE length_sq = axis_0 * axis_0 + axis_1 * axis_1 + axis_2 * axis_2;
@@ -272,17 +278,17 @@ set_rotate_mat(FLOATTYPE angle, FLOATNAME(LVecBase3) axis,
   s1 = s * axis_1;
   s1 = s * axis_1;
   s2 = s * axis_2;
   s2 = s * axis_2;
 
 
-  _m.m._00 = t0 * axis_0 + c;
-  _m.m._01 = t0 * axis_1 + s2;
-  _m.m._02 = t0 * axis_2 - s1;
+  _m(0, 0) = t0 * axis_0 + c;
+  _m(0, 1) = t0 * axis_1 + s2;
+  _m(0, 2) = t0 * axis_2 - s1;
 
 
-  _m.m._10 = t1 * axis_0 - s2;
-  _m.m._11 = t1 * axis_1 + c;
-  _m.m._12 = t1 * axis_2 + s0;
+  _m(1, 0) = t1 * axis_0 - s2;
+  _m(1, 1) = t1 * axis_1 + c;
+  _m(1, 2) = t1 * axis_2 + s0;
 
 
-  _m.m._20 = t2 * axis_0 + s1;
-  _m.m._21 = t2 * axis_1 - s0;
-  _m.m._22 = t2 * axis_2 + c;
+  _m(2, 0) = t2 * axis_0 + s1;
+  _m(2, 1) = t2 * axis_1 - s0;
+  _m(2, 2) = t2 * axis_2 + c;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -306,9 +312,9 @@ set_rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis,
     angle = -angle;
     angle = -angle;
   }
   }
 
 
-  FLOATTYPE axis_0 = axis._v.v._0;
-  FLOATTYPE axis_1 = axis._v.v._1;
-  FLOATTYPE axis_2 = axis._v.v._2;
+  FLOATTYPE axis_0 = axis._v(0);
+  FLOATTYPE axis_1 = axis._v(1);
+  FLOATTYPE axis_2 = axis._v(2);
 
 
   FLOATTYPE angle_rad = deg_2_rad(angle);
   FLOATTYPE angle_rad = deg_2_rad(angle);
   FLOATTYPE s, c;
   FLOATTYPE s, c;
@@ -324,17 +330,17 @@ set_rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis,
   s1 = s * axis_1;
   s1 = s * axis_1;
   s2 = s * axis_2;
   s2 = s * axis_2;
 
 
-  _m.m._00 = t0 * axis_0 + c;
-  _m.m._01 = t0 * axis_1 + s2;
-  _m.m._02 = t0 * axis_2 - s1;
+  _m(0, 0) = t0 * axis_0 + c;
+  _m(0, 1) = t0 * axis_1 + s2;
+  _m(0, 2) = t0 * axis_2 - s1;
 
 
-  _m.m._10 = t1 * axis_0 - s2;
-  _m.m._11 = t1 * axis_1 + c;
-  _m.m._12 = t1 * axis_2 + s0;
+  _m(1, 0) = t1 * axis_0 - s2;
+  _m(1, 1) = t1 * axis_1 + c;
+  _m(1, 2) = t1 * axis_2 + s0;
 
 
-  _m.m._20 = t2 * axis_0 + s1;
-  _m.m._21 = t2 * axis_1 - s0;
-  _m.m._22 = t2 * axis_2 + c;
+  _m(2, 0) = t2 * axis_0 + s1;
+  _m(2, 1) = t2 * axis_1 - s0;
+  _m(2, 2) = t2 * axis_2 + c;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -366,17 +372,17 @@ almost_equal(const FLOATNAME(LMatrix3) &other, FLOATTYPE threshold) const {
 void FLOATNAME(LMatrix3)::
 void FLOATNAME(LMatrix3)::
 output(ostream &out) const {
 output(ostream &out) const {
   out << "[ "
   out << "[ "
-      << MAYBE_ZERO(_m.m._00) << " "
-      << MAYBE_ZERO(_m.m._01) << " "
-      << MAYBE_ZERO(_m.m._02)
+      << MAYBE_ZERO(_m(0, 0)) << " "
+      << MAYBE_ZERO(_m(0, 1)) << " "
+      << MAYBE_ZERO(_m(0, 2))
       << " ] [ "
       << " ] [ "
-      << MAYBE_ZERO(_m.m._10) << " "
-      << MAYBE_ZERO(_m.m._11) << " "
-      << MAYBE_ZERO(_m.m._12)
+      << MAYBE_ZERO(_m(1, 0)) << " "
+      << MAYBE_ZERO(_m(1, 1)) << " "
+      << MAYBE_ZERO(_m(1, 2))
       << " ] [ "
       << " ] [ "
-      << MAYBE_ZERO(_m.m._20) << " "
-      << MAYBE_ZERO(_m.m._21) << " "
-      << MAYBE_ZERO(_m.m._22)
+      << MAYBE_ZERO(_m(2, 0)) << " "
+      << MAYBE_ZERO(_m(2, 1)) << " "
+      << MAYBE_ZERO(_m(2, 2))
       << " ]";
       << " ]";
 }
 }
 
 
@@ -388,19 +394,19 @@ output(ostream &out) const {
 void FLOATNAME(LMatrix3)::
 void FLOATNAME(LMatrix3)::
 write(ostream &out, int indent_level) const {
 write(ostream &out, int indent_level) const {
   indent(out, indent_level)
   indent(out, indent_level)
-    << MAYBE_ZERO(_m.m._00) << " "
-    << MAYBE_ZERO(_m.m._01) << " "
-    << MAYBE_ZERO(_m.m._02)
+    << MAYBE_ZERO(_m(0, 0)) << " "
+    << MAYBE_ZERO(_m(0, 1)) << " "
+    << MAYBE_ZERO(_m(0, 2))
     << "\n";
     << "\n";
   indent(out, indent_level)
   indent(out, indent_level)
-    << MAYBE_ZERO(_m.m._10) << " "
-    << MAYBE_ZERO(_m.m._11) << " "
-    << MAYBE_ZERO(_m.m._12)
+    << MAYBE_ZERO(_m(1, 0)) << " "
+    << MAYBE_ZERO(_m(1, 1)) << " "
+    << MAYBE_ZERO(_m(1, 2))
     << "\n";
     << "\n";
   indent(out, indent_level)
   indent(out, indent_level)
-    << MAYBE_ZERO(_m.m._20) << " "
-    << MAYBE_ZERO(_m.m._21) << " "
-    << MAYBE_ZERO(_m.m._22)
+    << MAYBE_ZERO(_m(2, 0)) << " "
+    << MAYBE_ZERO(_m(2, 1)) << " "
+    << MAYBE_ZERO(_m(2, 2))
     << "\n";
     << "\n";
 }
 }
 
 

+ 7 - 17
panda/src/linmath/lmatrix3_src.h

@@ -22,7 +22,7 @@ class FLOATNAME(LMatrix4);
 //               (rotation, scale, translation) in 2-d, e.g. for a
 //               (rotation, scale, translation) in 2-d, e.g. for a
 //               texture matrix.
 //               texture matrix.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDA_LINMATH FLOATNAME(LMatrix3) {
+class EXPCL_PANDA_LINMATH LINMATH_ALIGN FLOATNAME(LMatrix3) {
 public:
 public:
   typedef const FLOATTYPE *iterator;
   typedef const FLOATTYPE *iterator;
   typedef const FLOATTYPE *const_iterator;
   typedef const FLOATTYPE *const_iterator;
@@ -280,22 +280,13 @@ PUBLISHED:
   void read_datagram(DatagramIterator &source);
   void read_datagram(DatagramIterator &source);
 
 
 public:
 public:
-  union {
-    struct {
-      FLOATTYPE  _00, _01, _02;
-      FLOATTYPE  _10, _11, _12;
-      FLOATTYPE  _20, _21, _22;
-    } m;
-    
-    FLOATTYPE data[3 * 3];
-  } _m;
+  // The underlying implementation is via the Eigen library, if available.
+  typedef LINMATH_MATRIX(FLOATTYPE, 3, 3) EMatrix3;
+  EMatrix3 _m;
 
 
-private:
-  INLINE_LINMATH FLOATTYPE mult_cel(
-    const FLOATNAME(LMatrix3) &other, int x, int y) const;
-  INLINE_LINMATH FLOATTYPE det2(
-    FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e10, FLOATTYPE e11) const;
+  INLINE_LINMATH FLOATNAME(LMatrix3)(const EMatrix3 &m) : _m(m) { }
 
 
+private:
   static const FLOATNAME(LMatrix3) _ident_mat;
   static const FLOATNAME(LMatrix3) _ident_mat;
   static const FLOATNAME(LMatrix3) _y_to_z_up_mat;
   static const FLOATNAME(LMatrix3) _y_to_z_up_mat;
   static const FLOATNAME(LMatrix3) _z_to_y_up_mat;
   static const FLOATNAME(LMatrix3) _z_to_y_up_mat;
@@ -315,8 +306,7 @@ private:
 };
 };
 
 
 
 
-INLINE_LINMATH ostream &operator << (
-    ostream &out, const FLOATNAME(LMatrix3) &mat) {
+INLINE ostream &operator << (ostream &out, const FLOATNAME(LMatrix3) &mat) {
   mat.output(out);
   mat.output(out);
   return out;
   return out;
 }
 }

+ 20 - 20
panda/src/linmath/lmatrix4_ext_src.I

@@ -42,10 +42,10 @@ __reduce__, PyObject *self) {
   }
   }
 
 
   PyObject *result = Py_BuildValue("(O(ffffffffffffffff))", this_class, 
   PyObject *result = Py_BuildValue("(O(ffffffffffffffff))", this_class, 
-    this->_m.m._00, this->_m.m._01, this->_m.m._02, this->_m.m._03,
-    this->_m.m._10, this->_m.m._11, this->_m.m._12, this->_m.m._13,
-    this->_m.m._20, this->_m.m._21, this->_m.m._22, this->_m.m._23,
-    this->_m.m._30, this->_m.m._31, this->_m.m._32, this->_m.m._33);
+    this->_m(0, 0), this->_m(0, 1), this->_m(0, 2), this->_m(0, 3),
+    this->_m(1, 0), this->_m(1, 1), this->_m(1, 2), this->_m(1, 3),
+    this->_m(2, 0), this->_m(2, 1), this->_m(2, 2), this->_m(2, 3),
+    this->_m(3, 0), this->_m(3, 1), this->_m(3, 2), this->_m(3, 3));
 
 
   Py_DECREF(this_class);
   Py_DECREF(this_class);
   return result;
   return result;
@@ -59,24 +59,24 @@ __reduce__, PyObject *self) {
 void EXT_CONST_METHOD_ARGS(FLOATNAME(LMatrix4),
 void EXT_CONST_METHOD_ARGS(FLOATNAME(LMatrix4),
 python_repr, ostream &out, const string &class_name) {
 python_repr, ostream &out, const string &class_name) {
   out << class_name << "(" 
   out << class_name << "(" 
-      << MAYBE_ZERO(this->_m.m._00) << ", "
-      << MAYBE_ZERO(this->_m.m._01) << ", "
-      << MAYBE_ZERO(this->_m.m._02) << ", "
-      << MAYBE_ZERO(this->_m.m._03) << ", "
+      << MAYBE_ZERO(this->_m(0, 0)) << ", "
+      << MAYBE_ZERO(this->_m(0, 1)) << ", "
+      << MAYBE_ZERO(this->_m(0, 2)) << ", "
+      << MAYBE_ZERO(this->_m(0, 3)) << ", "
 
 
-      << MAYBE_ZERO(this->_m.m._10) << ", "
-      << MAYBE_ZERO(this->_m.m._11) << ", "
-      << MAYBE_ZERO(this->_m.m._12) << ", "
-      << MAYBE_ZERO(this->_m.m._13) << ", "
+      << MAYBE_ZERO(this->_m(1, 0)) << ", "
+      << MAYBE_ZERO(this->_m(1, 1)) << ", "
+      << MAYBE_ZERO(this->_m(1, 2)) << ", "
+      << MAYBE_ZERO(this->_m(1, 3)) << ", "
 
 
-      << MAYBE_ZERO(this->_m.m._20) << ", "
-      << MAYBE_ZERO(this->_m.m._21) << ", "
-      << MAYBE_ZERO(this->_m.m._22) << ", "
-      << MAYBE_ZERO(this->_m.m._23) << ", "
+      << MAYBE_ZERO(this->_m(2, 0)) << ", "
+      << MAYBE_ZERO(this->_m(2, 1)) << ", "
+      << MAYBE_ZERO(this->_m(2, 2)) << ", "
+      << MAYBE_ZERO(this->_m(2, 3)) << ", "
 
 
-      << MAYBE_ZERO(this->_m.m._30) << ", "
-      << MAYBE_ZERO(this->_m.m._31) << ", "
-      << MAYBE_ZERO(this->_m.m._32) << ", "
-      << MAYBE_ZERO(this->_m.m._33) << ")";
+      << MAYBE_ZERO(this->_m(3, 0)) << ", "
+      << MAYBE_ZERO(this->_m(3, 1)) << ", "
+      << MAYBE_ZERO(this->_m(3, 2)) << ", "
+      << MAYBE_ZERO(this->_m(3, 3)) << ")";
 }
 }
 
 

File diff suppressed because it is too large
+ 370 - 288
panda/src/linmath/lmatrix4_src.I


+ 75 - 73
panda/src/linmath/lmatrix4_src.cxx

@@ -141,9 +141,11 @@ compare_to(const FLOATNAME(LMatrix4) &other, FLOATTYPE threshold) const {
   TAU_PROFILE("int LMatrix4::compare_to(const LMatrix4 &, FLOATTYPE)", " ", TAU_USER);
   TAU_PROFILE("int LMatrix4::compare_to(const LMatrix4 &, FLOATTYPE)", " ", TAU_USER);
   // We compare values in reverse order, since the last row of the
   // We compare values in reverse order, since the last row of the
   // matrix is most likely to be different between different matrices.
   // matrix is most likely to be different between different matrices.
-  for (int i = 15; i >= 0; i--) {
-    if (!IS_THRESHOLD_COMPEQ(_m.data[i], other._m.data[i], threshold)) {
-      return (_m.data[i] < other._m.data[i]) ? -1 : 1;
+  for (int r = 3; r >= 0; --r) {
+    for (int c = 0; c < 4; ++c) {
+      if (!IS_THRESHOLD_COMPEQ(_m(r, c), other._m(r, c), threshold)) {
+        return (_m(r, c) < other._m(r, c)) ? -1 : 1;
+      }
     }
     }
   }
   }
   return 0;
   return 0;
@@ -171,9 +173,9 @@ set_rotate_mat(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis,
     angle = -angle;
     angle = -angle;
   }
   }
 
 
-  FLOATTYPE axis_0 = axis._v.v._0;
-  FLOATTYPE axis_1 = axis._v.v._1;
-  FLOATTYPE axis_2 = axis._v.v._2;
+  FLOATTYPE axis_0 = axis._v(0);
+  FLOATTYPE axis_1 = axis._v(1);
+  FLOATTYPE axis_2 = axis._v(2);
 
 
   // Normalize the axis.
   // Normalize the axis.
   FLOATTYPE length_sq = axis_0 * axis_0 + axis_1 * axis_1 + axis_2 * axis_2;
   FLOATTYPE length_sq = axis_0 * axis_0 + axis_1 * axis_1 + axis_2 * axis_2;
@@ -198,26 +200,26 @@ set_rotate_mat(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis,
   s1 = s * axis_1;
   s1 = s * axis_1;
   s2 = s * axis_2;
   s2 = s * axis_2;
 
 
-  _m.m._00 = t0 * axis_0 + c;
-  _m.m._01 = t0 * axis_1 + s2;
-  _m.m._02 = t0 * axis_2 - s1;
+  _m(0, 0) = t0 * axis_0 + c;
+  _m(0, 1) = t0 * axis_1 + s2;
+  _m(0, 2) = t0 * axis_2 - s1;
 
 
-  _m.m._10 = t1 * axis_0 - s2;
-  _m.m._11 = t1 * axis_1 + c;
-  _m.m._12 = t1 * axis_2 + s0;
+  _m(1, 0) = t1 * axis_0 - s2;
+  _m(1, 1) = t1 * axis_1 + c;
+  _m(1, 2) = t1 * axis_2 + s0;
 
 
-  _m.m._20 = t2 * axis_0 + s1;
-  _m.m._21 = t2 * axis_1 - s0;
-  _m.m._22 = t2 * axis_2 + c;
+  _m(2, 0) = t2 * axis_0 + s1;
+  _m(2, 1) = t2 * axis_1 - s0;
+  _m(2, 2) = t2 * axis_2 + c;
 
 
-  _m.m._03 = 0.0f;
-  _m.m._13 = 0.0f;
-  _m.m._23 = 0.0f;
+  _m(0, 3) = 0.0f;
+  _m(1, 3) = 0.0f;
+  _m(2, 3) = 0.0f;
 
 
-  _m.m._30 = 0.0f;
-  _m.m._31 = 0.0f;
-  _m.m._32 = 0.0f;
-  _m.m._33 = 1.0f;
+  _m(3, 0) = 0.0f;
+  _m(3, 1) = 0.0f;
+  _m(3, 2) = 0.0f;
+  _m(3, 3) = 1.0f;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -241,9 +243,9 @@ set_rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis,
     angle = -angle;
     angle = -angle;
   }
   }
 
 
-  FLOATTYPE axis_0 = axis._v.v._0;
-  FLOATTYPE axis_1 = axis._v.v._1;
-  FLOATTYPE axis_2 = axis._v.v._2;
+  FLOATTYPE axis_0 = axis._v(0);
+  FLOATTYPE axis_1 = axis._v(1);
+  FLOATTYPE axis_2 = axis._v(2);
 
 
   FLOATTYPE angle_rad=deg_2_rad(angle);
   FLOATTYPE angle_rad=deg_2_rad(angle);
   FLOATTYPE s,c;
   FLOATTYPE s,c;
@@ -259,26 +261,26 @@ set_rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis,
   s1 = s * axis_1;
   s1 = s * axis_1;
   s2 = s * axis_2;
   s2 = s * axis_2;
 
 
-  _m.m._00 = t0 * axis_0 + c;
-  _m.m._01 = t0 * axis_1 + s2;
-  _m.m._02 = t0 * axis_2 - s1;
+  _m(0, 0) = t0 * axis_0 + c;
+  _m(0, 1) = t0 * axis_1 + s2;
+  _m(0, 2) = t0 * axis_2 - s1;
 
 
-  _m.m._10 = t1 * axis_0 - s2;
-  _m.m._11 = t1 * axis_1 + c;
-  _m.m._12 = t1 * axis_2 + s0;
+  _m(1, 0) = t1 * axis_0 - s2;
+  _m(1, 1) = t1 * axis_1 + c;
+  _m(1, 2) = t1 * axis_2 + s0;
 
 
-  _m.m._20 = t2 * axis_0 + s1;
-  _m.m._21 = t2 * axis_1 - s0;
-  _m.m._22 = t2 * axis_2 + c;
+  _m(2, 0) = t2 * axis_0 + s1;
+  _m(2, 1) = t2 * axis_1 - s0;
+  _m(2, 2) = t2 * axis_2 + c;
 
 
-  _m.m._03 = 0.0f;
-  _m.m._13 = 0.0f;
-  _m.m._23 = 0.0f;
+  _m(0, 3) = 0.0f;
+  _m(1, 3) = 0.0f;
+  _m(2, 3) = 0.0f;
 
 
-  _m.m._30 = 0.0f;
-  _m.m._31 = 0.0f;
-  _m.m._32 = 0.0f;
-  _m.m._33 = 1.0f;
+  _m(3, 0) = 0.0f;
+  _m(3, 1) = 0.0f;
+  _m(3, 2) = 0.0f;
+  _m(3, 3) = 1.0f;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -317,25 +319,25 @@ almost_equal(const FLOATNAME(LMatrix4) &other, FLOATTYPE threshold) const {
 void FLOATNAME(LMatrix4)::
 void FLOATNAME(LMatrix4)::
 output(ostream &out) const {
 output(ostream &out) const {
   out << "[ "
   out << "[ "
-      << MAYBE_ZERO(_m.m._00) << " "
-      << MAYBE_ZERO(_m.m._01) << " "
-      << MAYBE_ZERO(_m.m._02) << " "
-      << MAYBE_ZERO(_m.m._03)
+      << MAYBE_ZERO(_m(0, 0)) << " "
+      << MAYBE_ZERO(_m(0, 1)) << " "
+      << MAYBE_ZERO(_m(0, 2)) << " "
+      << MAYBE_ZERO(_m(0, 3))
       << " ] [ "
       << " ] [ "
-      << MAYBE_ZERO(_m.m._10) << " "
-      << MAYBE_ZERO(_m.m._11) << " "
-      << MAYBE_ZERO(_m.m._12) << " "
-      << MAYBE_ZERO(_m.m._13)
+      << MAYBE_ZERO(_m(1, 0)) << " "
+      << MAYBE_ZERO(_m(1, 1)) << " "
+      << MAYBE_ZERO(_m(1, 2)) << " "
+      << MAYBE_ZERO(_m(1, 3))
       << " ] [ "
       << " ] [ "
-      << MAYBE_ZERO(_m.m._20) << " "
-      << MAYBE_ZERO(_m.m._21) << " "
-      << MAYBE_ZERO(_m.m._22) << " "
-      << MAYBE_ZERO(_m.m._23)
+      << MAYBE_ZERO(_m(2, 0)) << " "
+      << MAYBE_ZERO(_m(2, 1)) << " "
+      << MAYBE_ZERO(_m(2, 2)) << " "
+      << MAYBE_ZERO(_m(2, 3))
       << " ] [ "
       << " ] [ "
-      << MAYBE_ZERO(_m.m._30) << " "
-      << MAYBE_ZERO(_m.m._31) << " "
-      << MAYBE_ZERO(_m.m._32) << " "
-      << MAYBE_ZERO(_m.m._33)
+      << MAYBE_ZERO(_m(3, 0)) << " "
+      << MAYBE_ZERO(_m(3, 1)) << " "
+      << MAYBE_ZERO(_m(3, 2)) << " "
+      << MAYBE_ZERO(_m(3, 3))
       << " ]";
       << " ]";
 }
 }
 
 
@@ -347,28 +349,28 @@ output(ostream &out) const {
 void FLOATNAME(LMatrix4)::
 void FLOATNAME(LMatrix4)::
 write(ostream &out, int indent_level) const {
 write(ostream &out, int indent_level) const {
   indent(out, indent_level)
   indent(out, indent_level)
-    << MAYBE_ZERO(_m.m._00) << " "
-    << MAYBE_ZERO(_m.m._01) << " "
-    << MAYBE_ZERO(_m.m._02) << " "
-    << MAYBE_ZERO(_m.m._03)
+    << MAYBE_ZERO(_m(0, 0)) << " "
+    << MAYBE_ZERO(_m(0, 1)) << " "
+    << MAYBE_ZERO(_m(0, 2)) << " "
+    << MAYBE_ZERO(_m(0, 3))
     << "\n";
     << "\n";
   indent(out, indent_level)
   indent(out, indent_level)
-    << MAYBE_ZERO(_m.m._10) << " "
-    << MAYBE_ZERO(_m.m._11) << " "
-    << MAYBE_ZERO(_m.m._12) << " "
-    << MAYBE_ZERO(_m.m._13)
+    << MAYBE_ZERO(_m(1, 0)) << " "
+    << MAYBE_ZERO(_m(1, 1)) << " "
+    << MAYBE_ZERO(_m(1, 2)) << " "
+    << MAYBE_ZERO(_m(1, 3))
     << "\n";
     << "\n";
   indent(out, indent_level)
   indent(out, indent_level)
-    << MAYBE_ZERO(_m.m._20) << " "
-    << MAYBE_ZERO(_m.m._21) << " "
-    << MAYBE_ZERO(_m.m._22) << " "
-    << MAYBE_ZERO(_m.m._23)
+    << MAYBE_ZERO(_m(2, 0)) << " "
+    << MAYBE_ZERO(_m(2, 1)) << " "
+    << MAYBE_ZERO(_m(2, 2)) << " "
+    << MAYBE_ZERO(_m(2, 3))
     << "\n";
     << "\n";
   indent(out, indent_level)
   indent(out, indent_level)
-    << MAYBE_ZERO(_m.m._30) << " "
-    << MAYBE_ZERO(_m.m._31) << " "
-    << MAYBE_ZERO(_m.m._32) << " "
-    << MAYBE_ZERO(_m.m._33)
+    << MAYBE_ZERO(_m(3, 0)) << " "
+    << MAYBE_ZERO(_m(3, 1)) << " "
+    << MAYBE_ZERO(_m(3, 2)) << " "
+    << MAYBE_ZERO(_m(3, 3))
     << "\n";
     << "\n";
 }
 }
 
 

+ 9 - 13
panda/src/linmath/lmatrix4_src.h

@@ -17,7 +17,7 @@
 //       Class : LMatrix4
 //       Class : LMatrix4
 // Description : This is a 4-by-4 transform matrix.
 // Description : This is a 4-by-4 transform matrix.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDA_LINMATH FLOATNAME(LMatrix4) {
+class EXPCL_PANDA_LINMATH LINMATH_ALIGN FLOATNAME(LMatrix4) {
 public:
 public:
   typedef const FLOATTYPE *iterator;
   typedef const FLOATTYPE *iterator;
   typedef const FLOATTYPE *const_iterator;
   typedef const FLOATTYPE *const_iterator;
@@ -161,6 +161,8 @@ PUBLISHED:
   INLINE_LINMATH bool invert_affine_from(const FLOATNAME(LMatrix4) &other);
   INLINE_LINMATH bool invert_affine_from(const FLOATNAME(LMatrix4) &other);
   INLINE_LINMATH bool invert_in_place();
   INLINE_LINMATH bool invert_in_place();
 
 
+  INLINE_LINMATH void accumulate(const FLOATNAME(LMatrix4) &other, FLOATTYPE weight);
+
   INLINE_LINMATH static const FLOATNAME(LMatrix4) &ident_mat();
   INLINE_LINMATH static const FLOATNAME(LMatrix4) &ident_mat();
   INLINE_LINMATH static const FLOATNAME(LMatrix4) &ones_mat();
   INLINE_LINMATH static const FLOATNAME(LMatrix4) &ones_mat();
   INLINE_LINMATH static const FLOATNAME(LMatrix4) &zeros_mat();
   INLINE_LINMATH static const FLOATNAME(LMatrix4) &zeros_mat();
@@ -243,19 +245,13 @@ PUBLISHED:
   void read_datagram(DatagramIterator &source);
   void read_datagram(DatagramIterator &source);
 
 
 public:
 public:
-  union {
-    struct {
-      FLOATTYPE  _00, _01, _02, _03;
-      FLOATTYPE  _10, _11, _12, _13;
-      FLOATTYPE  _20, _21, _22, _23;
-      FLOATTYPE  _30, _31, _32, _33;
-    } m;
-    
-    FLOATTYPE data[4 * 4];
-  } _m;
+  // The underlying implementation is via the Eigen library, if available.
+  typedef LINMATH_MATRIX(FLOATTYPE, 4, 4) EMatrix4;
+  EMatrix4 _m;
+
+  INLINE_LINMATH FLOATNAME(LMatrix4)(const EMatrix4 &m) : _m(m) { }
 
 
 private:
 private:
-  INLINE_LINMATH FLOATTYPE mult_cel(const FLOATNAME(LMatrix4) &other, int x, int y) const;
   bool decompose_mat(int index[4]);
   bool decompose_mat(int index[4]);
   bool back_sub_mat(int index[4], FLOATNAME(LMatrix4) &inv, int row) const;
   bool back_sub_mat(int index[4], FLOATNAME(LMatrix4) &inv, int row) const;
 
 
@@ -280,7 +276,7 @@ private:
 };
 };
 
 
 
 
-INLINE_LINMATH ostream &operator << (ostream &out, const FLOATNAME(LMatrix4) &mat) {
+INLINE ostream &operator << (ostream &out, const FLOATNAME(LMatrix4) &mat) {
   mat.output(out);
   mat.output(out);
   return out;
   return out;
 }
 }

+ 1 - 1
panda/src/linmath/lorientation_src.h

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

+ 5 - 5
panda/src/linmath/lpoint2_ext_src.I

@@ -25,8 +25,8 @@ IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint2);
 INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LPoint2),
 INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LPoint2),
 python_repr, ostream &out, const string &class_name) {
 python_repr, ostream &out, const string &class_name) {
   out << class_name << "("
   out << class_name << "("
-      << MAYBE_ZERO(this->_v.v._0) << ", "
-      << MAYBE_ZERO(this->_v.v._1) << ")";
+      << MAYBE_ZERO(this->_v(0)) << ", "
+      << MAYBE_ZERO(this->_v(1)) << ")";
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -44,12 +44,12 @@ __getattr__, const string &attr_name) {
   }
   }
 
 
   if (attr_name.size() == 1) {
   if (attr_name.size() == 1) {
-    return PyFloat_FromDouble(this->_v.data[attr_name[0] - 'x']);
+    return PyFloat_FromDouble(this->_v(attr_name[0] - 'x'));
 
 
   } else if (attr_name.size() == 2) {
   } else if (attr_name.size() == 2) {
     FLOATNAME(LPoint2) *vec = new FLOATNAME(LPoint2);
     FLOATNAME(LPoint2) *vec = new FLOATNAME(LPoint2);
-    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
+    vec->_v(0) = this->_v(attr_name[0] - 'x');
+    vec->_v(1) = this->_v(attr_name[1] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint2), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint2), true, false);
   }
   }
 
 

+ 1 - 1
panda/src/linmath/lpoint2_src.h

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

+ 9 - 9
panda/src/linmath/lpoint3_ext_src.I

@@ -26,9 +26,9 @@ IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint3);
 INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LPoint3),
 INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LPoint3),
 python_repr, ostream &out, const string &class_name) {
 python_repr, ostream &out, const string &class_name) {
   out << class_name << "("
   out << class_name << "("
-      << MAYBE_ZERO(this->_v.v._0) << ", "
-      << MAYBE_ZERO(this->_v.v._1) << ", "
-      << MAYBE_ZERO(this->_v.v._2) << ")";
+      << MAYBE_ZERO(this->_v(0)) << ", "
+      << MAYBE_ZERO(this->_v(1)) << ", "
+      << MAYBE_ZERO(this->_v(2)) << ")";
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -46,19 +46,19 @@ __getattr__, const string &attr_name) {
   }
   }
 
 
   if (attr_name.size() == 1) {
   if (attr_name.size() == 1) {
-    return PyFloat_FromDouble(this->_v.data[attr_name[0] - 'x']);
+    return PyFloat_FromDouble(this->_v(attr_name[0] - 'x'));
 
 
   } else if (attr_name.size() == 2) {
   } else if (attr_name.size() == 2) {
     FLOATNAME(LPoint2) *vec = new FLOATNAME(LPoint2);
     FLOATNAME(LPoint2) *vec = new FLOATNAME(LPoint2);
-    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
+    vec->_v(0) = this->_v(attr_name[0] - 'x');
+    vec->_v(1) = this->_v(attr_name[1] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint2), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint2), true, false);
 
 
   } else if (attr_name.size() == 3) {
   } else if (attr_name.size() == 3) {
     FLOATNAME(LPoint3) *vec = new FLOATNAME(LPoint3);
     FLOATNAME(LPoint3) *vec = new FLOATNAME(LPoint3);
-    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
-    vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
+    vec->_v(0) = this->_v(attr_name[0] - 'x');
+    vec->_v(1) = this->_v(attr_name[1] - 'x');
+    vec->_v(2) = this->_v(attr_name[2] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint3), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint3), true, false);
   }
   }
 
 

+ 3 - 3
panda/src/linmath/lpoint3_src.I

@@ -123,7 +123,7 @@ unit_z() {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LPoint2) FLOATNAME(LPoint3)::
 INLINE_LINMATH FLOATNAME(LPoint2) FLOATNAME(LPoint3)::
 get_xy() const {
 get_xy() const {
-  return FLOATNAME(LPoint2)(_v.v._0, _v.v._1);
+  return FLOATNAME(LPoint2)(_v(0), _v(1));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -134,7 +134,7 @@ get_xy() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LPoint2) FLOATNAME(LPoint3)::
 INLINE_LINMATH FLOATNAME(LPoint2) FLOATNAME(LPoint3)::
 get_xz() const {
 get_xz() const {
-  return FLOATNAME(LPoint2)(_v.v._0, _v.v._2);
+  return FLOATNAME(LPoint2)(_v(0), _v(2));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -145,7 +145,7 @@ get_xz() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LPoint2) FLOATNAME(LPoint3)::
 INLINE_LINMATH FLOATNAME(LPoint2) FLOATNAME(LPoint3)::
 get_yz() const {
 get_yz() const {
-  return FLOATNAME(LPoint2)(_v.v._1, _v.v._2);
+  return FLOATNAME(LPoint2)(_v(1), _v(2));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 1 - 1
panda/src/linmath/lpoint3_src.h

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

+ 15 - 15
panda/src/linmath/lpoint4_ext_src.I

@@ -27,10 +27,10 @@ IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint4);
 INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LPoint4),
 INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LPoint4),
 python_repr, ostream &out, const string &class_name) {
 python_repr, ostream &out, const string &class_name) {
   out << class_name << "("
   out << class_name << "("
-      << MAYBE_ZERO(this->_v.v._0) << ", "
-      << MAYBE_ZERO(this->_v.v._1) << ", "
-      << MAYBE_ZERO(this->_v.v._2) << ", "
-      << MAYBE_ZERO(this->_v.v._3) << ")";
+      << MAYBE_ZERO(this->_v(0)) << ", "
+      << MAYBE_ZERO(this->_v(1)) << ", "
+      << MAYBE_ZERO(this->_v(2)) << ", "
+      << MAYBE_ZERO(this->_v(3)) << ")";
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -49,30 +49,30 @@ __getattr__, const string &attr_name) {
 
 
   if (attr_name.size() == 1) {
   if (attr_name.size() == 1) {
     if (attr_name[0] == 'w') {
     if (attr_name[0] == 'w') {
-      return PyFloat_FromDouble(this->_v.data[3]);
+      return PyFloat_FromDouble(this->_v(3));
     } else {
     } else {
-      return PyFloat_FromDouble(this->_v.data[attr_name[0] - 'x']);
+      return PyFloat_FromDouble(this->_v(attr_name[0] - 'x'));
     }
     }
 
 
   } else if (attr_name.size() == 2) {
   } else if (attr_name.size() == 2) {
     FLOATNAME(LPoint2) *vec = new FLOATNAME(LPoint2);
     FLOATNAME(LPoint2) *vec = new FLOATNAME(LPoint2);
-    vec->_v.v._0 = this->_v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
+    vec->_v(0) = this->_v((attr_name[0] == 'w') ? 3 : attr_name[0] - 'x');
+    vec->_v(1) = this->_v((attr_name[1] == 'w') ? 3 : attr_name[1] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint2), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint2), true, false);
 
 
   } else if (attr_name.size() == 3) {
   } else if (attr_name.size() == 3) {
     FLOATNAME(LPoint3) *vec = new FLOATNAME(LPoint3);
     FLOATNAME(LPoint3) *vec = new FLOATNAME(LPoint3);
-    vec->_v.v._0 = this->_v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
-    vec->_v.v._2 = this->_v.data[(attr_name[2] == 'w') ? 3 : attr_name[2] - 'x'];
+    vec->_v(0) = this->_v((attr_name[0] == 'w') ? 3 : attr_name[0] - 'x');
+    vec->_v(1) = this->_v((attr_name[1] == 'w') ? 3 : attr_name[1] - 'x');
+    vec->_v(2) = this->_v((attr_name[2] == 'w') ? 3 : attr_name[2] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint3), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint3), true, false);
 
 
   } else if (attr_name.size() == 4) {
   } else if (attr_name.size() == 4) {
     FLOATNAME(LPoint4) *vec = new FLOATNAME(LPoint4);
     FLOATNAME(LPoint4) *vec = new FLOATNAME(LPoint4);
-    vec->_v.v._0 = this->_v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
-    vec->_v.v._2 = this->_v.data[(attr_name[2] == 'w') ? 3 : attr_name[2] - 'x'];
-    vec->_v.v._3 = this->_v.data[(attr_name[3] == 'w') ? 3 : attr_name[3] - 'x'];
+    vec->_v(0) = this->_v((attr_name[0] == 'w') ? 3 : attr_name[0] - 'x');
+    vec->_v(1) = this->_v((attr_name[1] == 'w') ? 3 : attr_name[1] - 'x');
+    vec->_v(2) = this->_v((attr_name[2] == 'w') ? 3 : attr_name[2] - 'x');
+    vec->_v(3) = this->_v((attr_name[3] == 'w') ? 3 : attr_name[3] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint4), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint4), true, false);
   }
   }
 
 

+ 1 - 1
panda/src/linmath/lpoint4_src.h

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

+ 38 - 38
panda/src/linmath/lquaternion_src.I

@@ -62,7 +62,7 @@ xform(const FLOATNAME(LVecBase3) &v) const {
   FLOATNAME(LQuaternion) v_quat(0.0f, v[0], v[1], v[2]);
   FLOATNAME(LQuaternion) v_quat(0.0f, v[0], v[1], v[2]);
 
 
   FLOATNAME(LQuaternion) conjugate(
   FLOATNAME(LQuaternion) conjugate(
-    _v.data[0], -_v.data[1], -_v.data[2], -_v.data[3]);
+    _v(0), -_v(1), -_v(2), -_v(3));
   v_quat = conjugate * v_quat * (*this);
   v_quat = conjugate * v_quat * (*this);
 
 
   return FLOATNAME(LVecBase3)(v_quat[1], v_quat[2], v_quat[3]);
   return FLOATNAME(LVecBase3)(v_quat[1], v_quat[2], v_quat[3]);
@@ -78,7 +78,7 @@ xform(const FLOATNAME(LVecBase4) &v) const {
   FLOATNAME(LQuaternion) v_quat(v[0], v[1], v[2], v[3]);
   FLOATNAME(LQuaternion) v_quat(v[0], v[1], v[2], v[3]);
 
 
   FLOATNAME(LQuaternion) conjugate(
   FLOATNAME(LQuaternion) conjugate(
-    _v.data[0], -_v.data[1], -_v.data[2], -_v.data[3]);
+    _v(0), -_v(1), -_v(2), -_v(3));
   v_quat = conjugate * v_quat * (*this);
   v_quat = conjugate * v_quat * (*this);
 
 
   return FLOATNAME(LVecBase4)(v_quat);
   return FLOATNAME(LVecBase4)(v_quat);
@@ -91,10 +91,10 @@ xform(const FLOATNAME(LVecBase4) &v) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LQuaternion) FLOATNAME(LQuaternion)::
 INLINE_LINMATH FLOATNAME(LQuaternion) FLOATNAME(LQuaternion)::
 multiply(const FLOATNAME(LQuaternion) &rhs) const {
 multiply(const FLOATNAME(LQuaternion) &rhs) const {
-  FLOATTYPE r = (rhs._v.v._0 * _v.v._0) - (rhs._v.v._1 * _v.v._1) - (rhs._v.v._2 * _v.v._2) - (rhs._v.v._3 * _v.v._3);
-  FLOATTYPE i = (rhs._v.v._1 * _v.v._0) + (rhs._v.v._0 * _v.v._1) - (rhs._v.v._3 * _v.v._2) + (rhs._v.v._2 * _v.v._3);
-  FLOATTYPE j = (rhs._v.v._2 * _v.v._0) + (rhs._v.v._3 * _v.v._1) + (rhs._v.v._0 * _v.v._2) - (rhs._v.v._1 * _v.v._3);
-  FLOATTYPE k = (rhs._v.v._3 * _v.v._0) - (rhs._v.v._2 * _v.v._1) + (rhs._v.v._1 * _v.v._2) + (rhs._v.v._0 * _v.v._3);
+  FLOATTYPE r = (rhs._v(0) * _v(0)) - (rhs._v(1) * _v(1)) - (rhs._v(2) * _v(2)) - (rhs._v(3) * _v(3));
+  FLOATTYPE i = (rhs._v(1) * _v(0)) + (rhs._v(0) * _v(1)) - (rhs._v(3) * _v(2)) + (rhs._v(2) * _v(3));
+  FLOATTYPE j = (rhs._v(2) * _v(0)) + (rhs._v(3) * _v(1)) + (rhs._v(0) * _v(2)) - (rhs._v(1) * _v(3));
+  FLOATTYPE k = (rhs._v(3) * _v(0)) - (rhs._v(2) * _v(1)) + (rhs._v(1) * _v(2)) + (rhs._v(0) * _v(3));
 
 
   return FLOATNAME(LQuaternion)(r, i, j, k);
   return FLOATNAME(LQuaternion)(r, i, j, k);
 }
 }
@@ -245,10 +245,10 @@ almost_equal(const FLOATNAME(LQuaternion) &other) const {
 INLINE_LINMATH bool FLOATNAME(LQuaternion)::
 INLINE_LINMATH bool FLOATNAME(LQuaternion)::
 almost_equal(const FLOATNAME(LQuaternion) &other,
 almost_equal(const FLOATNAME(LQuaternion) &other,
              FLOATTYPE threshold) const {
              FLOATTYPE threshold) const {
-  return (IS_THRESHOLD_EQUAL(_v.data[0], other._v.data[0], threshold) &&
-          IS_THRESHOLD_EQUAL(_v.data[1], other._v.data[1], threshold) &&
-          IS_THRESHOLD_EQUAL(_v.data[2], other._v.data[2], threshold) &&
-          IS_THRESHOLD_EQUAL(_v.data[3], other._v.data[3], threshold));
+  return (IS_THRESHOLD_EQUAL(_v(0), other._v(0), threshold) &&
+          IS_THRESHOLD_EQUAL(_v(1), other._v(1), threshold) &&
+          IS_THRESHOLD_EQUAL(_v(2), other._v(2), threshold) &&
+          IS_THRESHOLD_EQUAL(_v(3), other._v(3), threshold));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -282,10 +282,10 @@ almost_same_direction(const FLOATNAME(LQuaternion) &other,
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LQuaternion)::
 INLINE_LINMATH void FLOATNAME(LQuaternion)::
 output(ostream& os) const {
 output(ostream& os) const {
-  os << MAYBE_ZERO(_v.data[0]) << " + "
-     << MAYBE_ZERO(_v.data[1]) << "i + "
-     << MAYBE_ZERO(_v.data[2]) << "j + "
-     << MAYBE_ZERO(_v.data[3]) << "k";
+  os << MAYBE_ZERO(_v(0)) << " + "
+     << MAYBE_ZERO(_v(1)) << "i + "
+     << MAYBE_ZERO(_v(2)) << "j + "
+     << MAYBE_ZERO(_v(3)) << "k";
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -308,7 +308,7 @@ set_from_matrix(const FLOATNAME(LMatrix4) &m) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LQuaternion)::
 INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LQuaternion)::
 get_axis() const {
 get_axis() const {
-  return FLOATNAME(LVector3)(_v.data[1], _v.data[2], _v.data[3]);
+  return FLOATNAME(LVector3)(_v(1), _v(2), _v(3));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -339,7 +339,7 @@ get_axis_normalized() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE FLOATNAME(LQuaternion)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LQuaternion)::
 get_angle_rad() const {
 get_angle_rad() const {
-  return acos(_v.data[0]) * 2.0;
+  return acos(_v(0)) * 2.0;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -369,10 +369,10 @@ INLINE_LINMATH void FLOATNAME(LQuaternion)::
 set_from_axis_angle_rad(FLOATTYPE angle_rad, const FLOATNAME(LVector3) &axis) {
 set_from_axis_angle_rad(FLOATTYPE angle_rad, const FLOATNAME(LVector3) &axis) {
   nassertv(IS_THRESHOLD_EQUAL(axis.length(), 1.0f, 0.001f));
   nassertv(IS_THRESHOLD_EQUAL(axis.length(), 1.0f, 0.001f));
   FLOATTYPE sinHalfAngle = sin(angle_rad * 0.5);
   FLOATTYPE sinHalfAngle = sin(angle_rad * 0.5);
-  _v.data[0] = cos(angle_rad * 0.5);
-  _v.data[1] = axis[0] * sinHalfAngle;
-  _v.data[2] = axis[1] * sinHalfAngle;
-  _v.data[3] = axis[2] * sinHalfAngle;
+  _v(0) = cos(angle_rad * 0.5);
+  _v(1) = axis[0] * sinHalfAngle;
+  _v(2) = axis[1] * sinHalfAngle;
+  _v(3) = axis[2] * sinHalfAngle;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -427,7 +427,7 @@ get_forward(CoordinateSystem cs) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE FLOATNAME(LQuaternion)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LQuaternion)::
 get_r() const {
 get_r() const {
-  return _v.data[0];
+  return _v(0);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -437,7 +437,7 @@ get_r() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE FLOATNAME(LQuaternion)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LQuaternion)::
 get_i() const {
 get_i() const {
-  return _v.data[1];
+  return _v(1);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -447,7 +447,7 @@ get_i() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE FLOATNAME(LQuaternion)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LQuaternion)::
 get_j() const {
 get_j() const {
-  return _v.data[2];
+  return _v(2);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -457,7 +457,7 @@ get_j() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE FLOATNAME(LQuaternion)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LQuaternion)::
 get_k() const {
 get_k() const {
-  return _v.data[3];
+  return _v(3);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -467,7 +467,7 @@ get_k() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LQuaternion)::
 INLINE_LINMATH void FLOATNAME(LQuaternion)::
 set_r(FLOATTYPE r) {
 set_r(FLOATTYPE r) {
-  _v.data[0] = r;
+  _v(0) = r;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -477,7 +477,7 @@ set_r(FLOATTYPE r) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LQuaternion)::
 INLINE_LINMATH void FLOATNAME(LQuaternion)::
 set_i(FLOATTYPE i) {
 set_i(FLOATTYPE i) {
-  _v.data[1] = i;
+  _v(1) = i;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -487,7 +487,7 @@ set_i(FLOATTYPE i) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LQuaternion)::
 INLINE_LINMATH void FLOATNAME(LQuaternion)::
 set_j(FLOATTYPE j) {
 set_j(FLOATTYPE j) {
-  _v.data[2] = j;
+  _v(2) = j;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -497,7 +497,7 @@ set_j(FLOATTYPE j) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LQuaternion)::
 INLINE_LINMATH void FLOATNAME(LQuaternion)::
 set_k(FLOATTYPE k) {
 set_k(FLOATTYPE k) {
-  _v.data[3] = k;
+  _v(3) = k;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -524,7 +524,7 @@ normalize() {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LQuaternion) FLOATNAME(LQuaternion)::
 INLINE_LINMATH FLOATNAME(LQuaternion) FLOATNAME(LQuaternion)::
 conjugate() const {
 conjugate() const {
-  return FLOATNAME(LQuaternion)(_v.v._0, -_v.v._1, -_v.v._2, -_v.v._3);
+  return FLOATNAME(LQuaternion)(_v(0), -_v(1), -_v(2), -_v(3));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -545,7 +545,7 @@ conjugate() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH bool FLOATNAME(LQuaternion)::
 INLINE_LINMATH bool FLOATNAME(LQuaternion)::
 conjugate_from(const FLOATNAME(LQuaternion) &other) {
 conjugate_from(const FLOATNAME(LQuaternion) &other) {
-  set(other._v.v._0, -other._v.v._1, -other._v.v._2, -other._v.v._3);
+  set(other._v(0), -other._v(1), -other._v(2), -other._v(3));
   return true;
   return true;
 }
 }
 
 
@@ -558,10 +558,10 @@ conjugate_from(const FLOATNAME(LQuaternion) &other) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH bool FLOATNAME(LQuaternion)::
 INLINE_LINMATH bool FLOATNAME(LQuaternion)::
 conjugate_in_place() {
 conjugate_in_place() {
-  // _v.v._0 = _v.v._0;
-  _v.v._1 = -_v.v._1;
-  _v.v._2 = -_v.v._2;
-  _v.v._3 = -_v.v._3;
+  // _v(0) = _v(0);
+  _v(1) = -_v(1);
+  _v(2) = -_v(2);
+  _v(3) = -_v(3);
   return true;
   return true;
 }
 }
 
 
@@ -583,7 +583,7 @@ conjugate_in_place() {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH bool FLOATNAME(LQuaternion)::
 INLINE_LINMATH bool FLOATNAME(LQuaternion)::
 invert_from(const FLOATNAME(LQuaternion) &other) {
 invert_from(const FLOATNAME(LQuaternion) &other) {
-  set(-other._v.v._0, other._v.v._1, other._v.v._2, other._v.v._3);
+  set(-other._v(0), other._v(1), other._v(2), other._v(3));
   return true;
   return true;
 }
 }
 
 
@@ -596,7 +596,7 @@ invert_from(const FLOATNAME(LQuaternion) &other) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH bool FLOATNAME(LQuaternion)::
 INLINE_LINMATH bool FLOATNAME(LQuaternion)::
 invert_in_place() {
 invert_in_place() {
-  _v.v._0 = -_v.v._0;
+  _v(0) = -_v(0);
   return true;
   return true;
 }
 }
 
 
@@ -619,8 +619,8 @@ is_identity() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH bool FLOATNAME(LQuaternion)::
 INLINE_LINMATH bool FLOATNAME(LQuaternion)::
 is_almost_identity(FLOATTYPE tolerance) const {
 is_almost_identity(FLOATTYPE tolerance) const {
-  return (IS_THRESHOLD_EQUAL(_v.v._0, -1.0f, tolerance) || 
-          IS_THRESHOLD_EQUAL(_v.v._0, 1.0f, tolerance));
+  return (IS_THRESHOLD_EQUAL(_v(0), -1.0f, tolerance) || 
+          IS_THRESHOLD_EQUAL(_v(0), 1.0f, tolerance));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 32 - 32
panda/src/linmath/lquaternion_src.cxx

@@ -42,10 +42,10 @@ extract_to_matrix(FLOATNAME(LMatrix3) &m) const {
   FLOATTYPE s = (N == 0.0f) ? 0.0f : (2.0f / N);
   FLOATTYPE s = (N == 0.0f) ? 0.0f : (2.0f / N);
   FLOATTYPE xs, ys, zs, wx, wy, wz, xx, xy, xz, yy, yz, zz;
   FLOATTYPE xs, ys, zs, wx, wy, wz, xx, xy, xz, yy, yz, zz;
 
 
-  xs = _v.data[1] * s;   ys = _v.data[2] * s;   zs = _v.data[3] * s;
-  wx = _v.data[0] * xs;  wy = _v.data[0] * ys;  wz = _v.data[0] * zs;
-  xx = _v.data[1] * xs;  xy = _v.data[1] * ys;  xz = _v.data[1] * zs;
-  yy = _v.data[2] * ys;  yz = _v.data[2] * zs;  zz = _v.data[3] * zs;
+  xs = _v(1) * s;   ys = _v(2) * s;   zs = _v(3) * s;
+  wx = _v(0) * xs;  wy = _v(0) * ys;  wz = _v(0) * zs;
+  xx = _v(1) * xs;  xy = _v(1) * ys;  xz = _v(1) * zs;
+  yy = _v(2) * ys;  yz = _v(2) * zs;  zz = _v(3) * zs;
 
 
   m.set((1.0f - (yy + zz)), (xy + wz), (xz - wy),
   m.set((1.0f - (yy + zz)), (xy + wz), (xz - wy),
         (xy - wz), (1.0f - (xx + zz)), (yz + wx),
         (xy - wz), (1.0f - (xx + zz)), (yz + wx),
@@ -63,10 +63,10 @@ extract_to_matrix(FLOATNAME(LMatrix4) &m) const {
   FLOATTYPE s = (N == 0.0f) ? 0.0f : (2.0f / N);
   FLOATTYPE s = (N == 0.0f) ? 0.0f : (2.0f / N);
   FLOATTYPE xs, ys, zs, wx, wy, wz, xx, xy, xz, yy, yz, zz;
   FLOATTYPE xs, ys, zs, wx, wy, wz, xx, xy, xz, yy, yz, zz;
 
 
-  xs = _v.data[1] * s;   ys = _v.data[2] * s;   zs = _v.data[3] * s;
-  wx = _v.data[0] * xs;  wy = _v.data[0] * ys;  wz = _v.data[0] * zs;
-  xx = _v.data[1] * xs;  xy = _v.data[1] * ys;  xz = _v.data[1] * zs;
-  yy = _v.data[2] * ys;  yz = _v.data[2] * zs;  zz = _v.data[3] * zs;
+  xs = _v(1) * s;   ys = _v(2) * s;   zs = _v(3) * s;
+  wx = _v(0) * xs;  wy = _v(0) * ys;  wz = _v(0) * zs;
+  xx = _v(1) * xs;  xy = _v(1) * ys;  xz = _v(1) * zs;
+  yy = _v(2) * ys;  yz = _v(2) * zs;  zz = _v(3) * zs;
 
 
   m.set((1.0f - (yy + zz)), (xy + wz), (xz - wy), 0.0f,
   m.set((1.0f - (yy + zz)), (xy + wz), (xz - wy), 0.0f,
         (xy - wz), (1.0f - (xx + zz)), (yz + wx), 0.0f,
         (xy - wz), (1.0f - (xx + zz)), (yz + wx), 0.0f,
@@ -154,18 +154,18 @@ get_hpr(CoordinateSystem cs) const {
 
 
   if (cs == CS_zup_right) {
   if (cs == CS_zup_right) {
     FLOATTYPE N =
     FLOATTYPE N =
-        (_v.data[0] * _v.data[0]) +
-        (_v.data[1] * _v.data[1]) +
-        (_v.data[2] * _v.data[2]) +
-        (_v.data[3] * _v.data[3]);
+        (_v(0) * _v(0)) +
+        (_v(1) * _v(1)) +
+        (_v(2) * _v(2)) +
+        (_v(3) * _v(3));
     FLOATTYPE s = (N == 0.0f) ? 0.0f : (2.0f / N);
     FLOATTYPE s = (N == 0.0f) ? 0.0f : (2.0f / N);
     FLOATTYPE xs, ys, zs, wx, wy, wz, xx, xy, xz, yy, yz, zz, c1, c2, c3, c4;
     FLOATTYPE xs, ys, zs, wx, wy, wz, xx, xy, xz, yy, yz, zz, c1, c2, c3, c4;
     FLOATTYPE cr, sr, cp, sp, ch, sh;
     FLOATTYPE cr, sr, cp, sp, ch, sh;
     
     
-    xs = _v.data[1] * s;   ys = _v.data[2] * s;   zs = _v.data[3] * s;
-    wx = _v.data[0] * xs;  wy = _v.data[0] * ys;  wz = _v.data[0] * zs;
-    xx = _v.data[1] * xs;  xy = _v.data[1] * ys;  xz = _v.data[1] * zs;
-    yy = _v.data[2] * ys;  yz = _v.data[2] * zs;  zz = _v.data[3] * zs;
+    xs = _v(1) * s;   ys = _v(2) * s;   zs = _v(3) * s;
+    wx = _v(0) * xs;  wy = _v(0) * ys;  wz = _v(0) * zs;
+    xx = _v(1) * xs;  xy = _v(1) * ys;  xz = _v(1) * zs;
+    yy = _v(2) * ys;  yz = _v(2) * zs;  zz = _v(3) * zs;
     c1 = xz - wy;
     c1 = xz - wy;
     c2 = 1.0f - (xx + yy);
     c2 = 1.0f - (xx + yy);
     c3 = 1.0f - (yy + zz);
     c3 = 1.0f - (yy + zz);
@@ -254,11 +254,11 @@ set_from_matrix(const FLOATNAME(LMatrix3) &m) {
   if (trace > 0.0f) {
   if (trace > 0.0f) {
     // The easy case.
     // The easy case.
     FLOATTYPE S = csqrt(trace + 1.0f);
     FLOATTYPE S = csqrt(trace + 1.0f);
-    _v.data[0] = S * 0.5f;
+    _v(0) = S * 0.5f;
     S = 0.5f / S;
     S = 0.5f / S;
-    _v.data[1] = (m12 - m21) * S;
-    _v.data[2] = (m20 - m02) * S;
-    _v.data[3] = (m01 - m10) * S;
+    _v(1) = (m12 - m21) * S;
+    _v(2) = (m20 - m02) * S;
+    _v(3) = (m01 - m10) * S;
 
 
   } else {
   } else {
     // The harder case.  First, figure out which column to take as
     // The harder case.  First, figure out which column to take as
@@ -279,33 +279,33 @@ set_from_matrix(const FLOATNAME(LMatrix3) &m) {
       FLOATTYPE S = 1.0f + m00 - (m11 + m22);
       FLOATTYPE S = 1.0f + m00 - (m11 + m22);
       nassertv(S > 0.0f);
       nassertv(S > 0.0f);
       S = csqrt(S);
       S = csqrt(S);
-      _v.data[1] = S * 0.5f;
+      _v(1) = S * 0.5f;
       S = 0.5f / S;
       S = 0.5f / S;
-      _v.data[2] = (m01 + m10) * S;
-      _v.data[3] = (m02 + m20) * S;
-      _v.data[0] = (m12 - m21) * S;
+      _v(2) = (m01 + m10) * S;
+      _v(3) = (m02 + m20) * S;
+      _v(0) = (m12 - m21) * S;
 
 
     } else if (m11 > m22) {
     } else if (m11 > m22) {
       // m11 is larger than m00 and m22.
       // m11 is larger than m00 and m22.
       FLOATTYPE S = 1.0f + m11 - (m22 + m00);
       FLOATTYPE S = 1.0f + m11 - (m22 + m00);
       nassertv(S > 0.0f);
       nassertv(S > 0.0f);
       S = csqrt(S);
       S = csqrt(S);
-      _v.data[2] = S * 0.5f;
+      _v(2) = S * 0.5f;
       S = 0.5f / S;
       S = 0.5f / S;
-      _v.data[3] = (m12 + m21) * S;
-      _v.data[1] = (m10 + m01) * S;
-      _v.data[0] = (m20 - m02) * S;
+      _v(3) = (m12 + m21) * S;
+      _v(1) = (m10 + m01) * S;
+      _v(0) = (m20 - m02) * S;
 
 
     } else {
     } else {
       // m22 is larger than m00 and m11.
       // m22 is larger than m00 and m11.
       FLOATTYPE S = 1.0f + m22 - (m00 + m11);
       FLOATTYPE S = 1.0f + m22 - (m00 + m11);
       nassertv(S > 0.0f);
       nassertv(S > 0.0f);
       S = csqrt(S);
       S = csqrt(S);
-      _v.data[3] = S * 0.5f;
+      _v(3) = S * 0.5f;
       S = 0.5f / S;
       S = 0.5f / S;
-      _v.data[1] = (m20 + m02) * S;
-      _v.data[2] = (m21 + m12) * S;
-      _v.data[0] = (m01 - m10) * S;
+      _v(1) = (m20 + m02) * S;
+      _v(2) = (m21 + m12) * S;
+      _v(0) = (m01 - m10) * S;
     }
     }
   }
   }
 }
 }

+ 2 - 2
panda/src/linmath/lquaternion_src.h

@@ -16,7 +16,7 @@
 //       Class : FLOATNAME(LQuaternion)
 //       Class : FLOATNAME(LQuaternion)
 // Description : This is the base quaternion class
 // Description : This is the base quaternion class
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDA_LINMATH FLOATNAME(LQuaternion) : public FLOATNAME(LVecBase4) {
+class EXPCL_PANDA_LINMATH LINMATH_ALIGN FLOATNAME(LQuaternion) : public FLOATNAME(LVecBase4) {
 PUBLISHED:
 PUBLISHED:
   INLINE_LINMATH FLOATNAME(LQuaternion)();
   INLINE_LINMATH FLOATNAME(LQuaternion)();
   INLINE_LINMATH FLOATNAME(LQuaternion)(const FLOATNAME(LVecBase4) &copy);
   INLINE_LINMATH FLOATNAME(LQuaternion)(const FLOATNAME(LVecBase4) &copy);
@@ -127,7 +127,7 @@ private:
 };
 };
 
 
 
 
-INLINE_LINMATH ostream& operator<<(ostream& os, const FLOATNAME(LQuaternion)& q) {
+INLINE ostream& operator<<(ostream& os, const FLOATNAME(LQuaternion)& q) {
   q.output(os);
   q.output(os);
   return os;
   return os;
 }
 }

+ 1 - 1
panda/src/linmath/lrotation_src.h

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

+ 91 - 0
panda/src/linmath/lsimpleMatrix.I

@@ -0,0 +1,91 @@
+// Filename: lsimpleMatrix.I
+// Created by:  drose (15Dec11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: LSimpleMatrix::Constructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+template <class FloatType, int NumRows, int NumCols>
+INLINE LSimpleMatrix<FloatType, NumRows, NumCols>::
+LSimpleMatrix() {
+  // No default initialization.
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LSimpleMatrix::Copy Constructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+template <class FloatType, int NumRows, int NumCols>
+INLINE LSimpleMatrix<FloatType, NumRows, NumCols>::
+LSimpleMatrix(const LSimpleMatrix<FloatType, NumRows, NumCols> &copy) {
+  memcpy(_array, copy._array, sizeof(_array));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LSimpleMatrix::Copy Assignment Operator
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+template <class FloatType, int NumRows, int NumCols>
+INLINE void LSimpleMatrix<FloatType, NumRows, NumCols>::
+operator = (const LSimpleMatrix<FloatType, NumRows, NumCols> &copy) {
+  memcpy(_array, copy._array, sizeof(_array));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LSimpleMatrix::operator ()
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+template <class FloatType, int NumRows, int NumCols>
+INLINE const FloatType &LSimpleMatrix<FloatType, NumRows, NumCols>::
+operator () (int row, int col) const {
+  return _array[row][col];
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LSimpleMatrix::operator ()
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+template <class FloatType, int NumRows, int NumCols>
+INLINE FloatType &LSimpleMatrix<FloatType, NumRows, NumCols>::
+operator () (int row, int col) {
+  return _array[row][col];
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LSimpleMatrix::operator ()
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+template <class FloatType, int NumRows, int NumCols>
+INLINE const FloatType &LSimpleMatrix<FloatType, NumRows, NumCols>::
+operator () (int col) const {
+  return _array[0][col];
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LSimpleMatrix::operator ()
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+template <class FloatType, int NumRows, int NumCols>
+INLINE FloatType &LSimpleMatrix<FloatType, NumRows, NumCols>::
+operator () (int col) {
+  return _array[0][col];
+}

+ 69 - 0
panda/src/linmath/lsimpleMatrix.h

@@ -0,0 +1,69 @@
+// Filename: lsimpleMatrix.h
+// Created by:  drose (15Dec11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef LSIMPLEMATRIX_H
+#define LSIMPLEMATRIX_H
+
+#include "pandabase.h"
+
+#ifdef HAVE_EIGEN
+#include <Eigen/Dense>
+#endif
+
+////////////////////////////////////////////////////////////////////
+//       Class : LSimpleMatrix
+// Description : This class provides an underlying storage of the
+//               various linear-algebra classes (e.g. LVecBase3,
+//               LMatrix4) in the absence of the Eigen linear algebra
+//               library.
+////////////////////////////////////////////////////////////////////
+template <class FloatType, int NumRows, int NumCols>
+class LSimpleMatrix {
+public:
+  INLINE LSimpleMatrix();
+  INLINE LSimpleMatrix(const LSimpleMatrix<FloatType, NumRows, NumCols> &copy);
+  INLINE void operator = (const LSimpleMatrix<FloatType, NumRows, NumCols> &copy);
+  INLINE const FloatType &operator () (int row, int col) const;
+  INLINE FloatType &operator () (int row, int col);
+  INLINE const FloatType &operator () (int col) const;
+  INLINE FloatType &operator () (int col);
+
+private:
+  FloatType _array[NumRows][NumCols];
+};
+
+#include "lsimpleMatrix.I"
+
+// Now, do we actually use LSimpleMatrix, or do we use Eigen::Matrix?
+#ifdef HAVE_EIGEN
+#ifdef LINMATH_VECTORIZE
+#define LINMATH_MATRIX(FloatType, NumRows, NumCols) Eigen::Matrix<FloatType, NumRows, NumCols, Eigen::RowMajor>
+#else  // LINMATH_VECTORIZE
+#define LINMATH_MATRIX(FloatType, NumRows, NumCols) Eigen::Matrix<FloatType, NumRows, NumCols, Eigen::DontAlign | Eigen::RowMajor>
+#endif  // LINMATH_VECTORIZE
+
+#else  // HAVE_EIGEN
+#define LINMATH_MATRIX(FloatType, NumRows, NumCols) LSimpleMatrix<FloatType, NumRows, NumCols>
+#endif  // HAVE_EIGEN
+
+// This is as good a place as any to define this alignment macro.
+#ifdef LINMATH_VECTORIZE
+#define LINMATH_ALIGN ALIGN_16BYTE
+#else
+#define LINMATH_ALIGN 
+#endif  // LINMATH_VECTORIZE
+
+#endif
+
+  

+ 15 - 15
panda/src/linmath/lvecBase2_ext_src.I

@@ -27,7 +27,7 @@ IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase4);
 INLINE void EXT_METHOD_ARGS(FLOATNAME(LVecBase2),
 INLINE void EXT_METHOD_ARGS(FLOATNAME(LVecBase2),
 __setitem__, int i, FLOATTYPE v) {
 __setitem__, int i, FLOATTYPE v) {
   nassertv(i >= 0 && i < 2);
   nassertv(i >= 0 && i < 2);
-  this->_v.data[i] = v;
+  this->_v(i) = v;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -38,8 +38,8 @@ __setitem__, int i, FLOATTYPE v) {
 INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LVecBase2),
 INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LVecBase2),
 python_repr, ostream &out, const string &class_name) {
 python_repr, ostream &out, const string &class_name) {
   out << class_name << "("
   out << class_name << "("
-      << MAYBE_ZERO(this->_v.v._0) << ", "
-      << MAYBE_ZERO(this->_v.v._1) << ")";
+      << MAYBE_ZERO(this->_v(0)) << ", "
+      << MAYBE_ZERO(this->_v(1)) << ")";
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -80,27 +80,27 @@ __getattr__, const string &attr_name) {
   }
   }
 
 
   if (attr_name.size() == 1) {
   if (attr_name.size() == 1) {
-    return PyFloat_FromDouble(this->_v.data[attr_name[0] - 'x']);
+    return PyFloat_FromDouble(this->_v(attr_name[0] - 'x'));
 
 
   } else if (attr_name.size() == 2) {
   } else if (attr_name.size() == 2) {
     FLOATNAME(LVecBase2) *vec = new FLOATNAME(LVecBase2);
     FLOATNAME(LVecBase2) *vec = new FLOATNAME(LVecBase2);
-    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
+    vec->_v(0) = this->_v(attr_name[0] - 'x');
+    vec->_v(1) = this->_v(attr_name[1] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase2), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase2), true, false);
 
 
   } else if (attr_name.size() == 3) {
   } else if (attr_name.size() == 3) {
     FLOATNAME(LVecBase3) *vec = new FLOATNAME(LVecBase3);
     FLOATNAME(LVecBase3) *vec = new FLOATNAME(LVecBase3);
-    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
-    vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
+    vec->_v(0) = this->_v(attr_name[0] - 'x');
+    vec->_v(1) = this->_v(attr_name[1] - 'x');
+    vec->_v(2) = this->_v(attr_name[2] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase3), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase3), true, false);
 
 
   } else if (attr_name.size() == 4) {
   } else if (attr_name.size() == 4) {
     FLOATNAME(LVecBase4) *vec = new FLOATNAME(LVecBase4);
     FLOATNAME(LVecBase4) *vec = new FLOATNAME(LVecBase4);
-    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
-    vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
-    vec->_v.v._3 = this->_v.data[attr_name[3] - 'x'];
+    vec->_v(0) = this->_v(attr_name[0] - 'x');
+    vec->_v(1) = this->_v(attr_name[1] - 'x');
+    vec->_v(2) = this->_v(attr_name[2] - 'x');
+    vec->_v(3) = this->_v(attr_name[3] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase4), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase4), true, false);
   }
   }
 
 
@@ -156,7 +156,7 @@ __setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
       double value = PyFloat_AS_DOUBLE(fl);
       double value = PyFloat_AS_DOUBLE(fl);
       Py_DECREF(fl);
       Py_DECREF(fl);
 
 
-      this->_v.data[attr_name[i] - 'x'] = value;
+      this->_v(attr_name[i] - 'x') = value;
     }
     }
 
 
     Py_DECREF(fast);
     Py_DECREF(fast);
@@ -181,7 +181,7 @@ __setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
     // Loop through the components in the attribute name,
     // Loop through the components in the attribute name,
     // and assign the floating-point value to every one of them.
     // and assign the floating-point value to every one of them.
     for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
     for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
-      this->_v.data[(*it) - 'x'] = value;
+      this->_v((*it) - 'x') = value;
     }
     }
   }
   }
 
 

+ 117 - 79
panda/src/linmath/lvecBase2_src.I

@@ -28,11 +28,7 @@ FLOATNAME(LVecBase2)() {
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATNAME(LVecBase2)::
-FLOATNAME(LVecBase2)(const FLOATNAME(LVecBase2) &copy) {
-  TAU_PROFILE("LVecBase2::LVecBase2(LVecBase2 &)", " ", TAU_USER);
-  _v.v._0 = copy._v.v._0;
-  _v.v._1 = copy._v.v._1;
-//  (*this) = copy;
+FLOATNAME(LVecBase2)(const FLOATNAME(LVecBase2) &copy) : _v(copy._v) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -43,9 +39,7 @@ FLOATNAME(LVecBase2)(const FLOATNAME(LVecBase2) &copy) {
 INLINE_LINMATH FLOATNAME(LVecBase2) &FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATNAME(LVecBase2) &FLOATNAME(LVecBase2)::
 operator = (const FLOATNAME(LVecBase2) &copy) {
 operator = (const FLOATNAME(LVecBase2) &copy) {
   TAU_PROFILE("void LVecBase2::operator = (LVecBase2 &)", " ", TAU_USER);
   TAU_PROFILE("void LVecBase2::operator = (LVecBase2 &)", " ", TAU_USER);
-  _v.v._0 = copy._v.v._0;
-  _v.v._1 = copy._v.v._1;
-//  set(copy[0], copy[1]);
+  _v = copy._v;
   return *this;
   return *this;
 }
 }
 
 
@@ -77,9 +71,9 @@ FLOATNAME(LVecBase2)(FLOATTYPE fill_value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATNAME(LVecBase2)::
 FLOATNAME(LVecBase2)(FLOATTYPE x, FLOATTYPE y) {
 FLOATNAME(LVecBase2)(FLOATTYPE x, FLOATTYPE y) {
-  TAU_PROFILE("void LVecBase2::operator = (FLOATTYPE, ...)", " ", TAU_USER);
-  _v.v._0 = x;
-  _v.v._1 = y;
+  TAU_PROFILE("LVecBase2::LVecBase2(FLOATTYPE, ...)", " ", TAU_USER);
+  _v(0) = x;
+  _v(1) = y;
 //  set(x, y);
 //  set(x, y);
 }
 }
 
 
@@ -130,7 +124,7 @@ INLINE_LINMATH FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2)::
 operator [](int i) const {
 operator [](int i) const {
   nassertr(i >= 0 && i < 2, 0.0);
   nassertr(i >= 0 && i < 2, 0.0);
-  return _v.data[i];
+  return _v(i);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -140,8 +134,8 @@ operator [](int i) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE &FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATTYPE &FLOATNAME(LVecBase2)::
 operator [](int i) {
 operator [](int i) {
-  nassertr(i >= 0 && i < 2, _v.data[0]);
-  return _v.data[i];
+  nassertr(i >= 0 && i < 2, _v(0));
+  return _v(i);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -163,7 +157,7 @@ size() {
 INLINE_LINMATH bool FLOATNAME(LVecBase2)::
 INLINE_LINMATH bool FLOATNAME(LVecBase2)::
 is_nan() const {
 is_nan() const {
   TAU_PROFILE("bool LVecBase2::is_nan()", " ", TAU_USER);
   TAU_PROFILE("bool LVecBase2::is_nan()", " ", TAU_USER);
-  return cnan(_v.v._0) || cnan(_v.v._1);
+  return cnan(_v(0)) || cnan(_v(1));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -174,7 +168,7 @@ is_nan() const {
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2)::
 get_cell(int i) const {
 get_cell(int i) const {
   nassertr(i >= 0 && i < 2, 0.0);
   nassertr(i >= 0 && i < 2, 0.0);
-  return _v.data[i];
+  return _v(i);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -184,7 +178,7 @@ get_cell(int i) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2)::
 get_x() const {
 get_x() const {
-  return _v.v._0;
+  return _v(0);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -194,7 +188,7 @@ get_x() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2)::
 get_y() const {
 get_y() const {
-  return _v.v._1;
+  return _v(1);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -205,7 +199,7 @@ get_y() const {
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 set_cell(int i, FLOATTYPE value) {
 set_cell(int i, FLOATTYPE value) {
   nassertv(i >= 0 && i < 2);
   nassertv(i >= 0 && i < 2);
-  _v.data[i] = value;
+  _v(i) = value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -215,7 +209,7 @@ set_cell(int i, FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 set_x(FLOATTYPE value) {
 set_x(FLOATTYPE value) {
-  _v.v._0 = value;
+  _v(0) = value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -225,7 +219,7 @@ set_x(FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 set_y(FLOATTYPE value) {
 set_y(FLOATTYPE value) {
-  _v.v._1 = value;
+  _v(1) = value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -236,7 +230,7 @@ set_y(FLOATTYPE value) {
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 add_to_cell(int i, FLOATTYPE value) {
 add_to_cell(int i, FLOATTYPE value) {
   nassertv(i >= 0 && i < 2);
   nassertv(i >= 0 && i < 2);
-  _v.data[i] += value;
+  _v(i) += value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -246,7 +240,7 @@ add_to_cell(int i, FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 add_x(FLOATTYPE value) {
 add_x(FLOATTYPE value) {
-  _v.v._0 += value;
+  _v(0) += value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -256,7 +250,7 @@ add_x(FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 add_y(FLOATTYPE value) {
 add_y(FLOATTYPE value) {
-  _v.v._1 += value;
+  _v(1) += value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -268,7 +262,7 @@ add_y(FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH const FLOATTYPE *FLOATNAME(LVecBase2)::
 INLINE_LINMATH const FLOATTYPE *FLOATNAME(LVecBase2)::
 get_data() const {
 get_data() const {
-  return _v.data;
+  return &_v(0);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -289,7 +283,7 @@ get_num_components() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase2)::iterator FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATNAME(LVecBase2)::iterator FLOATNAME(LVecBase2)::
 begin() {
 begin() {
-  return _v.data;
+  return &_v(0);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -311,7 +305,7 @@ end() {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase2)::const_iterator FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATNAME(LVecBase2)::const_iterator FLOATNAME(LVecBase2)::
 begin() const {
 begin() const {
-  return _v.data;
+  return &_v(0);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -335,8 +329,8 @@ end() const {
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 fill(FLOATTYPE fill_value) {
 fill(FLOATTYPE fill_value) {
   TAU_PROFILE("void LVecBase2::fill()", " ", TAU_USER);
   TAU_PROFILE("void LVecBase2::fill()", " ", TAU_USER);
-  _v.v._0 = fill_value;
-  _v.v._1 = fill_value;
+  _v(0) = fill_value;
+  _v(1) = fill_value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -347,8 +341,8 @@ fill(FLOATTYPE fill_value) {
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 set(FLOATTYPE x, FLOATTYPE y) {
 set(FLOATTYPE x, FLOATTYPE y) {
   TAU_PROFILE("void LVecBase2::set()", " ", TAU_USER);
   TAU_PROFILE("void LVecBase2::set()", " ", TAU_USER);
-  _v.v._0 = x;
-  _v.v._1 = y;
+  _v(0) = x;
+  _v(1) = y;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -359,7 +353,12 @@ set(FLOATTYPE x, FLOATTYPE y) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2)::
 length() const {
 length() const {
+  TAU_PROFILE("FLOATTYPE LVecBase2::length()", " ", TAU_USER);
+#ifdef HAVE_EIGEN
+  return _v.norm();
+#else
   return csqrt((*this).dot(*this));
   return csqrt((*this).dot(*this));
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -370,7 +369,12 @@ length() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2)::
 length_squared() const {
 length_squared() const {
+  TAU_PROFILE("FLOATTYPE LVecBase2::length_squared()", " ", TAU_USER);
+#ifdef HAVE_EIGEN
+  return _v.squaredNorm();
+#else
   return (*this).dot(*this);
   return (*this).dot(*this);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -402,7 +406,11 @@ normalize() {
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2)::
 dot(const FLOATNAME(LVecBase2) &other) const {
 dot(const FLOATNAME(LVecBase2) &other) const {
   TAU_PROFILE("FLOATTYPE LVecBase2::dot()", " ", TAU_USER);
   TAU_PROFILE("FLOATTYPE LVecBase2::dot()", " ", TAU_USER);
-  return _v.v._0 * other._v.v._0 + _v.v._1 * other._v.v._1;
+#ifdef HAVE_EIGEN
+  return _v.dot(other._v);
+#else
+  return _v(0) * other._v(0) + _v(1) * other._v(1);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -440,8 +448,12 @@ operator < (const FLOATNAME(LVecBase2) &other) const {
 INLINE_LINMATH bool FLOATNAME(LVecBase2)::
 INLINE_LINMATH bool FLOATNAME(LVecBase2)::
 operator == (const FLOATNAME(LVecBase2) &other) const {
 operator == (const FLOATNAME(LVecBase2) &other) const {
   TAU_PROFILE("bool LVecBase2::operator ==(const LVecBase2 &)", " ", TAU_USER);
   TAU_PROFILE("bool LVecBase2::operator ==(const LVecBase2 &)", " ", TAU_USER);
-  return (_v.v._0 == other._v.v._0 &&
-          _v.v._1 == other._v.v._1);
+#ifdef HAVE_EIGEN
+  return _v == other._v;
+#else
+  return (_v(0) == other._v(0) &&
+          _v(1) == other._v(1));
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -478,11 +490,11 @@ compare_to(const FLOATNAME(LVecBase2) &other) const {
 INLINE_LINMATH int FLOATNAME(LVecBase2)::
 INLINE_LINMATH int FLOATNAME(LVecBase2)::
 compare_to(const FLOATNAME(LVecBase2) &other, FLOATTYPE threshold) const {
 compare_to(const FLOATNAME(LVecBase2) &other, FLOATTYPE threshold) const {
   TAU_PROFILE("int LVecBase2::compare_to(const LVecBase2 &, FLOATTYPE)", " ", TAU_USER);
   TAU_PROFILE("int LVecBase2::compare_to(const LVecBase2 &, FLOATTYPE)", " ", TAU_USER);
-  if (!IS_THRESHOLD_COMPEQ(_v.v._0, other._v.v._0, threshold)) {
-    return (_v.v._0 < other._v.v._0) ? -1 : 1;
+  if (!IS_THRESHOLD_COMPEQ(_v(0), other._v(0), threshold)) {
+    return (_v(0) < other._v(0)) ? -1 : 1;
   }
   }
-  if (!IS_THRESHOLD_COMPEQ(_v.v._1, other._v.v._1, threshold)) {
-    return (_v.v._1 < other._v.v._1) ? -1 : 1;
+  if (!IS_THRESHOLD_COMPEQ(_v(1), other._v(1), threshold)) {
+    return (_v(1) < other._v(1)) ? -1 : 1;
   }
   }
   return 0;
   return 0;
 }
 }
@@ -529,8 +541,8 @@ INLINE_LINMATH size_t FLOATNAME(LVecBase2)::
 add_hash(size_t hash, FLOATTYPE threshold) const {
 add_hash(size_t hash, FLOATTYPE threshold) const {
   TAU_PROFILE("LVecBase2::add_hash(size_t, FLOATTYPE)", " ", TAU_USER);
   TAU_PROFILE("LVecBase2::add_hash(size_t, FLOATTYPE)", " ", TAU_USER);
   float_hash fhasher(threshold);
   float_hash fhasher(threshold);
-  hash = fhasher.add_hash(hash, _v.v._0);
-  hash = fhasher.add_hash(hash, _v.v._1);
+  hash = fhasher.add_hash(hash, _v(0));
+  hash = fhasher.add_hash(hash, _v(1));
   return hash;
   return hash;
 }
 }
 
 
@@ -541,7 +553,11 @@ add_hash(size_t hash, FLOATTYPE threshold) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::
 operator - () const {
 operator - () const {
-  return FLOATNAME(LVecBase2)(-_v.v._0, -_v.v._1);
+#ifdef HAVE_EIGEN
+  return FLOATNAME(LVecBase2)(-_v);
+#else
+  return FLOATNAME(LVecBase2)(-_v(0), -_v(1));
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -551,8 +567,12 @@ operator - () const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::
 operator + (const FLOATNAME(LVecBase2) &other) const {
 operator + (const FLOATNAME(LVecBase2) &other) const {
-  return FLOATNAME(LVecBase2)(_v.v._0 + other._v.v._0,
-                              _v.v._1 + other._v.v._1);
+#ifdef HAVE_EIGEN
+  return FLOATNAME(LVecBase2)(_v + other._v);
+#else
+  return FLOATNAME(LVecBase2)(_v(0) + other._v(0),
+                              _v(1) + other._v(1));
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -562,8 +582,12 @@ operator + (const FLOATNAME(LVecBase2) &other) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::
 operator - (const FLOATNAME(LVecBase2) &other) const {
 operator - (const FLOATNAME(LVecBase2) &other) const {
-  return FLOATNAME(LVecBase2)(_v.v._0 - other._v.v._0,
-                              _v.v._1 - other._v.v._1);
+#ifdef HAVE_EIGEN
+  return FLOATNAME(LVecBase2)(_v - other._v);
+#else
+  return FLOATNAME(LVecBase2)(_v(0) - other._v(0),
+                              _v(1) - other._v(1));
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -573,8 +597,12 @@ operator - (const FLOATNAME(LVecBase2) &other) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::
 operator * (FLOATTYPE scalar) const {
 operator * (FLOATTYPE scalar) const {
-  return FLOATNAME(LVecBase2)(_v.v._0 * scalar,
-                              _v.v._1 * scalar);
+#ifdef HAVE_EIGEN
+  return FLOATNAME(LVecBase2)(_v * scalar);
+#else
+  return FLOATNAME(LVecBase2)(_v(0) * scalar,
+                              _v(1) * scalar);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -585,8 +613,7 @@ operator * (FLOATTYPE scalar) const {
 INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::
 operator / (FLOATTYPE scalar) const {
 operator / (FLOATTYPE scalar) const {
   FLOATTYPE recip_scalar = 1.0f/scalar;
   FLOATTYPE recip_scalar = 1.0f/scalar;
-  return FLOATNAME(LVecBase2)(_v.v._0 * recip_scalar,
-                              _v.v._1 * recip_scalar);
+  return operator * (recip_scalar);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -596,8 +623,12 @@ operator / (FLOATTYPE scalar) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 operator += (const FLOATNAME(LVecBase2) &other) {
 operator += (const FLOATNAME(LVecBase2) &other) {
-  _v.v._0 += other._v.v._0;
-  _v.v._1 += other._v.v._1;
+#ifdef HAVE_EIGEN
+  _v += other._v;
+#else
+  _v(0) += other._v(0);
+  _v(1) += other._v(1);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -607,8 +638,12 @@ operator += (const FLOATNAME(LVecBase2) &other) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 operator -= (const FLOATNAME(LVecBase2) &other) {
 operator -= (const FLOATNAME(LVecBase2) &other) {
-  _v.v._0 -= other._v.v._0;
-  _v.v._1 -= other._v.v._1;
+#ifdef HAVE_EIGEN
+  _v -= other._v;
+#else
+  _v(0) -= other._v(0);
+  _v(1) -= other._v(1);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -618,8 +653,12 @@ operator -= (const FLOATNAME(LVecBase2) &other) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 operator *= (FLOATTYPE scalar) {
 operator *= (FLOATTYPE scalar) {
-  _v.v._0 *= scalar;
-  _v.v._1 *= scalar;
+#ifdef HAVE_EIGEN
+  _v *= scalar;
+#else
+  _v(0) *= scalar;
+  _v(1) *= scalar;
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -630,8 +669,7 @@ operator *= (FLOATTYPE scalar) {
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 operator /= (FLOATTYPE scalar) {
 operator /= (FLOATTYPE scalar) {
   FLOATTYPE recip_scalar = 1.0f/scalar;
   FLOATTYPE recip_scalar = 1.0f/scalar;
-  _v.v._0 *= recip_scalar;
-  _v.v._1 *= recip_scalar;
+  operator *= (recip_scalar);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -642,8 +680,8 @@ operator /= (FLOATTYPE scalar) {
 INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::
 fmax(const FLOATNAME(LVecBase2) &other) {
 fmax(const FLOATNAME(LVecBase2) &other) {
   TAU_PROFILE("LVecBase2::fmax()", " ", TAU_USER);
   TAU_PROFILE("LVecBase2::fmax()", " ", TAU_USER);
-  return FLOATNAME(LVecBase2)(_v.v._0 > other._v.v._0 ? _v.v._0 : other._v.v._0,
-                              _v.v._1 > other._v.v._1 ? _v.v._1 : other._v.v._1);
+  return FLOATNAME(LVecBase2)(_v(0) > other._v(0) ? _v(0) : other._v(0),
+                              _v(1) > other._v(1) ? _v(1) : other._v(1));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -654,8 +692,8 @@ fmax(const FLOATNAME(LVecBase2) &other) {
 INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::
 INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::
 fmin(const FLOATNAME(LVecBase2) &other) {
 fmin(const FLOATNAME(LVecBase2) &other) {
   TAU_PROFILE("LVecBase2::fmin()", " ", TAU_USER);
   TAU_PROFILE("LVecBase2::fmin()", " ", TAU_USER);
-  return FLOATNAME(LVecBase2)(_v.v._0 < other._v.v._0 ? _v.v._0 : other._v.v._0,
-                              _v.v._1 < other._v.v._1 ? _v.v._1 : other._v.v._1);
+  return FLOATNAME(LVecBase2)(_v(0) < other._v(0) ? _v(0) : other._v(0),
+                              _v(1) < other._v(1) ? _v(1) : other._v(1));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -667,8 +705,8 @@ fmin(const FLOATNAME(LVecBase2) &other) {
 INLINE_LINMATH bool FLOATNAME(LVecBase2)::
 INLINE_LINMATH bool FLOATNAME(LVecBase2)::
 almost_equal(const FLOATNAME(LVecBase2) &other, FLOATTYPE threshold) const {
 almost_equal(const FLOATNAME(LVecBase2) &other, FLOATTYPE threshold) const {
   TAU_PROFILE("bool LVecBase2::almost_equal(LVecBase2 &, FLOATTYPE)", " ", TAU_USER);
   TAU_PROFILE("bool LVecBase2::almost_equal(LVecBase2 &, FLOATTYPE)", " ", TAU_USER);
-  return (IS_THRESHOLD_EQUAL(_v.v._0, other._v.v._0, threshold) &&
-          IS_THRESHOLD_EQUAL(_v.v._1, other._v.v._1, threshold));
+  return (IS_THRESHOLD_EQUAL(_v(0), other._v(0), threshold) &&
+          IS_THRESHOLD_EQUAL(_v(1), other._v(1), threshold));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -690,8 +728,8 @@ almost_equal(const FLOATNAME(LVecBase2) &other) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 output(ostream &out) const {
 output(ostream &out) const {
-  out << MAYBE_ZERO(_v.v._0) << " "
-      << MAYBE_ZERO(_v.v._1);
+  out << MAYBE_ZERO(_v(0)) << " "
+      << MAYBE_ZERO(_v(1));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -711,8 +749,8 @@ generate_hash(ChecksumHashGenerator &hashgen) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const {
 generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const {
-  hashgen.add_fp(_v.v._0, threshold);
-  hashgen.add_fp(_v.v._1, threshold);
+  hashgen.add_fp(_v(0), threshold);
+  hashgen.add_fp(_v(1), threshold);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -729,11 +767,11 @@ generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const {
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 write_datagram_fixed(Datagram &destination) const {
 write_datagram_fixed(Datagram &destination) const {
 #if FLOATTOKEN == 'f'
 #if FLOATTOKEN == 'f'
-  destination.add_float32(_v.v._0);
-  destination.add_float32(_v.v._1);
+  destination.add_float32(_v(0));
+  destination.add_float32(_v(1));
 #else
 #else
-  destination.add_float64(_v.v._0);
-  destination.add_float64(_v.v._1);
+  destination.add_float64(_v(0));
+  destination.add_float64(_v(1));
 #endif
 #endif
 }
 }
 
 
@@ -746,11 +784,11 @@ write_datagram_fixed(Datagram &destination) const {
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 read_datagram_fixed(DatagramIterator &source) {
 read_datagram_fixed(DatagramIterator &source) {
 #if FLOATTOKEN == 'f'
 #if FLOATTOKEN == 'f'
-  _v.v._0 = source.get_float32();
-  _v.v._1 = source.get_float32();
+  _v(0) = source.get_float32();
+  _v(1) = source.get_float32();
 #else
 #else
-  _v.v._0 = source.get_float64();
-  _v.v._1 = source.get_float64();
+  _v(0) = source.get_float64();
+  _v(1) = source.get_float64();
 #endif
 #endif
 }
 }
 
 
@@ -764,8 +802,8 @@ read_datagram_fixed(DatagramIterator &source) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 write_datagram(Datagram &destination) const {
 write_datagram(Datagram &destination) const {
-  destination.add_stdfloat(_v.v._0);
-  destination.add_stdfloat(_v.v._1);
+  destination.add_stdfloat(_v(0));
+  destination.add_stdfloat(_v(1));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -775,6 +813,6 @@ write_datagram(Datagram &destination) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 INLINE_LINMATH void FLOATNAME(LVecBase2)::
 read_datagram(DatagramIterator &source) {
 read_datagram(DatagramIterator &source) {
-  _v.v._0 = source.get_stdfloat();
-  _v.v._1 = source.get_stdfloat();
+  _v(0) = source.get_stdfloat();
+  _v(1) = source.get_stdfloat();
 }
 }

+ 7 - 8
panda/src/linmath/lvecBase2_src.h

@@ -12,15 +12,13 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-//typedef struct {FLOATTYPE _0, _1} FLOATNAME(data);
-
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //       Class : LVecBase2
 //       Class : LVecBase2
 // Description : This is the base class for all two-component
 // Description : This is the base class for all two-component
 //               vectors and points.
 //               vectors and points.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDA_LINMATH FLOATNAME(LVecBase2) {
+class EXPCL_PANDA_LINMATH LINMATH_ALIGN FLOATNAME(LVecBase2) {
 PUBLISHED:
 PUBLISHED:
   typedef const FLOATTYPE *iterator;
   typedef const FLOATTYPE *iterator;
   typedef const FLOATTYPE *const_iterator;
   typedef const FLOATTYPE *const_iterator;
@@ -135,10 +133,11 @@ PUBLISHED:
   INLINE_LINMATH void read_datagram(DatagramIterator &source);
   INLINE_LINMATH void read_datagram(DatagramIterator &source);
 
 
 public:
 public:
-   union {
-        FLOATTYPE data[2];
-        struct {FLOATTYPE _0, _1;} v;
-   } _v;
+  // The underlying implementation is via the Eigen library, if available.
+  typedef LINMATH_MATRIX(FLOATTYPE, 1, 2) EVector2;
+  EVector2 _v;
+
+  INLINE_LINMATH FLOATNAME(LVecBase2)(const EVector2 &v) : _v(v) { }
 
 
 private:
 private:
   static const FLOATNAME(LVecBase2) _zero;
   static const FLOATNAME(LVecBase2) _zero;
@@ -156,7 +155,7 @@ private:
 };
 };
 
 
 
 
-INLINE_LINMATH ostream &operator << (ostream &out, const FLOATNAME(LVecBase2) &vec) {
+INLINE ostream &operator << (ostream &out, const FLOATNAME(LVecBase2) &vec) {
   vec.output(out);
   vec.output(out);
   return out;
   return out;
 }
 }

+ 16 - 16
panda/src/linmath/lvecBase3_ext_src.I

@@ -27,7 +27,7 @@ IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase4);
 INLINE void EXT_METHOD_ARGS(FLOATNAME(LVecBase3),
 INLINE void EXT_METHOD_ARGS(FLOATNAME(LVecBase3),
 __setitem__, int i, FLOATTYPE v) {
 __setitem__, int i, FLOATTYPE v) {
   nassertv(i >= 0 && i < 3);
   nassertv(i >= 0 && i < 3);
-  this->_v.data[i] = v;
+  this->_v(i) = v;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -38,9 +38,9 @@ __setitem__, int i, FLOATTYPE v) {
 INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LVecBase3),
 INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LVecBase3),
 python_repr, ostream &out, const string &class_name) {
 python_repr, ostream &out, const string &class_name) {
   out << class_name << "("
   out << class_name << "("
-      << MAYBE_ZERO(this->_v.v._0) << ", "
-      << MAYBE_ZERO(this->_v.v._1) << ", "
-      << MAYBE_ZERO(this->_v.v._2) << ")";
+      << MAYBE_ZERO(this->_v(0)) << ", "
+      << MAYBE_ZERO(this->_v(1)) << ", "
+      << MAYBE_ZERO(this->_v(2)) << ")";
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -81,27 +81,27 @@ __getattr__, const string &attr_name) {
   }
   }
 
 
   if (attr_name.size() == 1) {
   if (attr_name.size() == 1) {
-    return PyFloat_FromDouble(this->_v.data[attr_name[0] - 'x']);
+    return PyFloat_FromDouble(this->_v(attr_name[0] - 'x'));
 
 
   } else if (attr_name.size() == 2) {
   } else if (attr_name.size() == 2) {
     FLOATNAME(LVecBase2) *vec = new FLOATNAME(LVecBase2);
     FLOATNAME(LVecBase2) *vec = new FLOATNAME(LVecBase2);
-    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
+    vec->_v(0) = this->_v(attr_name[0] - 'x');
+    vec->_v(1) = this->_v(attr_name[1] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase2), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase2), true, false);
 
 
   } else if (attr_name.size() == 3) {
   } else if (attr_name.size() == 3) {
     FLOATNAME(LVecBase3) *vec = new FLOATNAME(LVecBase3);
     FLOATNAME(LVecBase3) *vec = new FLOATNAME(LVecBase3);
-    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
-    vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
+    vec->_v(0) = this->_v(attr_name[0] - 'x');
+    vec->_v(1) = this->_v(attr_name[1] - 'x');
+    vec->_v(2) = this->_v(attr_name[2] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase3), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase3), true, false);
 
 
   } else if (attr_name.size() == 4) {
   } else if (attr_name.size() == 4) {
     FLOATNAME(LVecBase4) *vec = new FLOATNAME(LVecBase4);
     FLOATNAME(LVecBase4) *vec = new FLOATNAME(LVecBase4);
-    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
-    vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
-    vec->_v.v._3 = this->_v.data[attr_name[3] - 'x'];
+    vec->_v(0) = this->_v(attr_name[0] - 'x');
+    vec->_v(1) = this->_v(attr_name[1] - 'x');
+    vec->_v(2) = this->_v(attr_name[2] - 'x');
+    vec->_v(3) = this->_v(attr_name[3] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase4), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase4), true, false);
   }
   }
 
 
@@ -157,7 +157,7 @@ __setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
       double value = PyFloat_AS_DOUBLE(fl);
       double value = PyFloat_AS_DOUBLE(fl);
       Py_DECREF(fl);
       Py_DECREF(fl);
 
 
-      this->_v.data[attr_name[i] - 'x'] = value;
+      this->_v(attr_name[i] - 'x') = value;
     }
     }
 
 
     Py_DECREF(fast);
     Py_DECREF(fast);
@@ -182,7 +182,7 @@ __setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
     // Loop through the components in the attribute name,
     // Loop through the components in the attribute name,
     // and assign the floating-point value to every one of them.
     // and assign the floating-point value to every one of them.
     for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
     for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
-      this->_v.data[(*it) - 'x'] = value;
+      this->_v((*it) - 'x') = value;
     }
     }
   }
   }
 
 

+ 159 - 119
panda/src/linmath/lvecBase3_src.I

@@ -27,12 +27,7 @@ FLOATNAME(LVecBase3)() {
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATNAME(LVecBase3)::
-FLOATNAME(LVecBase3)(const FLOATNAME(LVecBase3) &copy) {
-  TAU_PROFILE("LVecBase3::LVecBase3(LVecBase3 &)", " ", TAU_USER);
-  _v.v._0 = copy._v.v._0;
-  _v.v._1 = copy._v.v._1;
-  _v.v._2 = copy._v.v._2;
-//  (*this) = copy;
+FLOATNAME(LVecBase3)(const FLOATNAME(LVecBase3) &copy) : _v(copy._v) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -43,10 +38,7 @@ FLOATNAME(LVecBase3)(const FLOATNAME(LVecBase3) &copy) {
 INLINE_LINMATH FLOATNAME(LVecBase3) &FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATNAME(LVecBase3) &FLOATNAME(LVecBase3)::
 operator = (const FLOATNAME(LVecBase3) &copy) {
 operator = (const FLOATNAME(LVecBase3) &copy) {
   TAU_PROFILE("void LVecBase3::operator =(LVecBase3 &)", " ", TAU_USER);
   TAU_PROFILE("void LVecBase3::operator =(LVecBase3 &)", " ", TAU_USER);
-  _v.v._0 = copy._v.v._0;
-  _v.v._1 = copy._v.v._1;
-  _v.v._2 = copy._v.v._2;
-//  set(copy[0], copy[1], copy[2]);
+  _v = copy._v;
   return *this;
   return *this;
 }
 }
 
 
@@ -78,10 +70,10 @@ FLOATNAME(LVecBase3)(FLOATTYPE fill_value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATNAME(LVecBase3)::
 FLOATNAME(LVecBase3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) {
 FLOATNAME(LVecBase3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) {
-  TAU_PROFILE("void LVecBase3::operator = (FLOATTYPE, ...)", " ", TAU_USER);
-  _v.v._0 = x;
-  _v.v._1 = y;
-  _v.v._2 = z;
+  TAU_PROFILE("LVecBase3::LVecBase3(FLOATTYPE, ...)", " ", TAU_USER);
+  _v(0) = x;
+  _v(1) = y;
+  _v(2) = z;
 //  set(x, y, z);
 //  set(x, y, z);
 }
 }
 
 
@@ -142,7 +134,7 @@ INLINE_LINMATH FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3)::
 operator [](int i) const {
 operator [](int i) const {
   nassertr(i >= 0 && i < 3, 0.0);
   nassertr(i >= 0 && i < 3, 0.0);
-  return _v.data[i];
+  return _v(i);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -152,8 +144,8 @@ operator [](int i) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE &FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATTYPE &FLOATNAME(LVecBase3)::
 operator [](int i) {
 operator [](int i) {
-  nassertr(i >= 0 && i < 3, _v.data[0]);
-  return _v.data[i];
+  nassertr(i >= 0 && i < 3, _v(0));
+  return _v(i);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -175,7 +167,7 @@ size() {
 INLINE_LINMATH bool FLOATNAME(LVecBase3)::
 INLINE_LINMATH bool FLOATNAME(LVecBase3)::
 is_nan() const {
 is_nan() const {
   TAU_PROFILE("bool LVecBase3::is_nan()", " ", TAU_USER);
   TAU_PROFILE("bool LVecBase3::is_nan()", " ", TAU_USER);
-  return cnan(_v.v._0) || cnan(_v.v._1) || cnan(_v.v._2);
+  return cnan(_v(0)) || cnan(_v(1)) || cnan(_v(2));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -186,7 +178,7 @@ is_nan() const {
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3)::
 get_cell(int i) const {
 get_cell(int i) const {
   nassertr(i >= 0 && i < 3, 0);
   nassertr(i >= 0 && i < 3, 0);
-  return _v.data[i];
+  return _v(i);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -196,7 +188,7 @@ get_cell(int i) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3)::
 get_x() const {
 get_x() const {
-  return _v.v._0;
+  return _v(0);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -206,7 +198,7 @@ get_x() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3)::
 get_y() const {
 get_y() const {
-  return _v.v._1;
+  return _v(1);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -216,7 +208,7 @@ get_y() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3)::
 get_z() const {
 get_z() const {
-  return _v.v._2;
+  return _v(2);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -227,7 +219,7 @@ get_z() const {
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 set_cell(int i, FLOATTYPE value) {
 set_cell(int i, FLOATTYPE value) {
   nassertv(i >= 0 && i < 3);
   nassertv(i >= 0 && i < 3);
-  _v.data[i] = value;
+  _v(i) = value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -237,7 +229,7 @@ set_cell(int i, FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 set_x(FLOATTYPE value) {
 set_x(FLOATTYPE value) {
-  _v.v._0 = value;
+  _v(0) = value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -247,7 +239,7 @@ set_x(FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 set_y(FLOATTYPE value) {
 set_y(FLOATTYPE value) {
-  _v.v._1 = value;
+  _v(1) = value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -257,7 +249,7 @@ set_y(FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 set_z(FLOATTYPE value) {
 set_z(FLOATTYPE value) {
-  _v.v._2 = value;
+  _v(2) = value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -268,7 +260,7 @@ set_z(FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase3)::
 get_xy() const {
 get_xy() const {
-  return FLOATNAME(LVecBase2)(_v.v._0, _v.v._1);
+  return FLOATNAME(LVecBase2)(_v(0), _v(1));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -279,7 +271,7 @@ get_xy() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase3)::
 get_xz() const {
 get_xz() const {
-  return FLOATNAME(LVecBase2)(_v.v._0, _v.v._2);
+  return FLOATNAME(LVecBase2)(_v(0), _v(2));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -290,7 +282,7 @@ get_xz() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase3)::
 get_yz() const {
 get_yz() const {
-  return FLOATNAME(LVecBase2)(_v.v._1, _v.v._2);
+  return FLOATNAME(LVecBase2)(_v(1), _v(2));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -301,7 +293,7 @@ get_yz() const {
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 add_to_cell(int i, FLOATTYPE value) {
 add_to_cell(int i, FLOATTYPE value) {
   nassertv(i >= 0 && i < 3);
   nassertv(i >= 0 && i < 3);
-  _v.data[i] += value;
+  _v(i) += value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -311,7 +303,7 @@ add_to_cell(int i, FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 add_x(FLOATTYPE value) {
 add_x(FLOATTYPE value) {
-  _v.v._0 += value;
+  _v(0) += value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -321,7 +313,7 @@ add_x(FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 add_y(FLOATTYPE value) {
 add_y(FLOATTYPE value) {
-  _v.v._1 += value;
+  _v(1) += value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -331,7 +323,7 @@ add_y(FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 add_z(FLOATTYPE value) {
 add_z(FLOATTYPE value) {
-  _v.v._2 += value;
+  _v(2) += value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -343,7 +335,7 @@ add_z(FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH const FLOATTYPE *FLOATNAME(LVecBase3)::
 INLINE_LINMATH const FLOATTYPE *FLOATNAME(LVecBase3)::
 get_data() const {
 get_data() const {
-  return _v.data;
+  return &_v(0);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -364,7 +356,7 @@ get_num_components() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase3)::iterator FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATNAME(LVecBase3)::iterator FLOATNAME(LVecBase3)::
 begin() {
 begin() {
-  return _v.data;
+  return &_v(0);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -386,7 +378,7 @@ end() {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase3)::const_iterator FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATNAME(LVecBase3)::const_iterator FLOATNAME(LVecBase3)::
 begin() const {
 begin() const {
-  return _v.data;
+  return &_v(0);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -410,9 +402,13 @@ end() const {
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 fill(FLOATTYPE fill_value) {
 fill(FLOATTYPE fill_value) {
   TAU_PROFILE("void LVecBase3::fill()", " ", TAU_USER);
   TAU_PROFILE("void LVecBase3::fill()", " ", TAU_USER);
-  _v.v._0 = fill_value;
-  _v.v._1 = fill_value;
-  _v.v._2 = fill_value;
+#ifdef HAVE_EIGEN
+  _v = EVector3::Constant(fill_value);
+#else
+  _v(0) = fill_value;
+  _v(1) = fill_value;
+  _v(2) = fill_value;
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -423,9 +419,9 @@ fill(FLOATTYPE fill_value) {
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) {
 set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) {
   TAU_PROFILE("void LVecBase3::set()", " ", TAU_USER);
   TAU_PROFILE("void LVecBase3::set()", " ", TAU_USER);
-  _v.v._0 = x;
-  _v.v._1 = y;
-  _v.v._2 = z;
+  _v(0) = x;
+  _v(1) = y;
+  _v(2) = z;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -437,7 +433,11 @@ set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) {
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3)::
 length() const {
 length() const {
   TAU_PROFILE("FLOATTYPE LVecBase3::length()", " ", TAU_USER);
   TAU_PROFILE("FLOATTYPE LVecBase3::length()", " ", TAU_USER);
+#ifdef HAVE_EIGEN
+  return _v.norm();
+#else
   return csqrt((*this).dot(*this));
   return csqrt((*this).dot(*this));
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -449,7 +449,11 @@ length() const {
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3)::
 length_squared() const {
 length_squared() const {
   TAU_PROFILE("FLOATTYPE LVecBase3::length_squared()", " ", TAU_USER);
   TAU_PROFILE("FLOATTYPE LVecBase3::length_squared()", " ", TAU_USER);
+#ifdef HAVE_EIGEN
+  return _v.squaredNorm();
+#else
   return (*this).dot(*this);
   return (*this).dot(*this);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -482,7 +486,11 @@ normalize() {
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3)::
 dot(const FLOATNAME(LVecBase3) &other) const {
 dot(const FLOATNAME(LVecBase3) &other) const {
   TAU_PROFILE("FLOATTYPE LVecBase3::dot()", " ", TAU_USER);
   TAU_PROFILE("FLOATTYPE LVecBase3::dot()", " ", TAU_USER);
-  return _v.v._0 * other._v.v._0 + _v.v._1 * other._v.v._1 + _v.v._2 * other._v.v._2;
+#ifdef HAVE_EIGEN
+  return _v.dot(other._v);
+#else
+  return _v(0) * other._v(0) + _v(1) * other._v(1) + _v(2) * other._v(2);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -493,9 +501,13 @@ dot(const FLOATNAME(LVecBase3) &other) const {
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::
 cross(const FLOATNAME(LVecBase3) &other) const {
 cross(const FLOATNAME(LVecBase3) &other) const {
   TAU_PROFILE("LVecBase3 LVecBase3::cross()", " ", TAU_USER);
   TAU_PROFILE("LVecBase3 LVecBase3::cross()", " ", TAU_USER);
-  return FLOATNAME(LVecBase3)(_v.v._1 * other._v.v._2 - other._v.v._1 * _v.v._2,
-                              other._v.v._0 * _v.v._2 - _v.v._0 * other._v.v._2,
-                              _v.v._0 * other._v.v._1 - other._v.v._0 * _v.v._1);
+#ifdef HAVE_EIGEN
+  return FLOATNAME(LVecBase3)(_v.cross(other._v));
+#else
+  return FLOATNAME(LVecBase3)(_v(1) * other._v(2) - other._v(1) * _v(2),
+                              other._v(0) * _v(2) - _v(0) * other._v(2),
+                              _v(0) * other._v(1) - other._v(0) * _v(1));
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -533,9 +545,13 @@ operator < (const FLOATNAME(LVecBase3) &other) const {
 INLINE_LINMATH bool FLOATNAME(LVecBase3)::
 INLINE_LINMATH bool FLOATNAME(LVecBase3)::
 operator == (const FLOATNAME(LVecBase3) &other) const {
 operator == (const FLOATNAME(LVecBase3) &other) const {
   TAU_PROFILE("bool LVecBase3::operator ==(const LVecBase3 &)", " ", TAU_USER);
   TAU_PROFILE("bool LVecBase3::operator ==(const LVecBase3 &)", " ", TAU_USER);
-  return (_v.v._0 == other._v.v._0 &&
-          _v.v._1 == other._v.v._1 &&
-          _v.v._2 == other._v.v._2);
+#ifdef HAVE_EIGEN
+  return _v == other._v;
+#else
+  return (_v(0) == other._v(0) &&
+          _v(1) == other._v(1) &&
+          _v(2) == other._v(2));
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -591,9 +607,9 @@ get_standardized_rotation(FLOATTYPE angle_in_degrees) {
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::
 get_standardized_hpr() const {
 get_standardized_hpr() const {
   return FLOATNAME(LVecBase3)(
   return FLOATNAME(LVecBase3)(
-      get_standardized_rotation(_v.v._0),
-      get_standardized_rotation(_v.v._1),
-      get_standardized_rotation(_v.v._2));
+      get_standardized_rotation(_v(0)),
+      get_standardized_rotation(_v(1)),
+      get_standardized_rotation(_v(2)));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -620,14 +636,14 @@ compare_to(const FLOATNAME(LVecBase3) &other) const {
 INLINE_LINMATH int FLOATNAME(LVecBase3)::
 INLINE_LINMATH int FLOATNAME(LVecBase3)::
 compare_to(const FLOATNAME(LVecBase3) &other, FLOATTYPE threshold) const {
 compare_to(const FLOATNAME(LVecBase3) &other, FLOATTYPE threshold) const {
   TAU_PROFILE("int LVecBase3::compare_to(const LVecBase3 &, FLOATTYPE)", " ", TAU_USER);
   TAU_PROFILE("int LVecBase3::compare_to(const LVecBase3 &, FLOATTYPE)", " ", TAU_USER);
-  if (!IS_THRESHOLD_COMPEQ(_v.v._0, other._v.v._0, threshold)) {
-    return (_v.v._0 < other._v.v._0) ? -1 : 1;
+  if (!IS_THRESHOLD_COMPEQ(_v(0), other._v(0), threshold)) {
+    return (_v(0) < other._v(0)) ? -1 : 1;
   }
   }
-  if (!IS_THRESHOLD_COMPEQ(_v.v._1, other._v.v._1, threshold)) {
-    return (_v.v._1 < other._v.v._1) ? -1 : 1;
+  if (!IS_THRESHOLD_COMPEQ(_v(1), other._v(1), threshold)) {
+    return (_v(1) < other._v(1)) ? -1 : 1;
   }
   }
-  if (!IS_THRESHOLD_COMPEQ(_v.v._2, other._v.v._2, threshold)) {
-    return (_v.v._2 < other._v.v._2) ? -1 : 1;
+  if (!IS_THRESHOLD_COMPEQ(_v(2), other._v(2), threshold)) {
+    return (_v(2) < other._v(2)) ? -1 : 1;
   }
   }
   return 0;
   return 0;
 }
 }
@@ -674,9 +690,9 @@ INLINE_LINMATH size_t FLOATNAME(LVecBase3)::
 add_hash(size_t hash, FLOATTYPE threshold) const {
 add_hash(size_t hash, FLOATTYPE threshold) const {
   TAU_PROFILE("LVecBase3::add_hash(size_t, FLOATTYPE)", " ", TAU_USER);
   TAU_PROFILE("LVecBase3::add_hash(size_t, FLOATTYPE)", " ", TAU_USER);
   float_hash fhasher(threshold);
   float_hash fhasher(threshold);
-  hash = fhasher.add_hash(hash, _v.v._0);
-  hash = fhasher.add_hash(hash, _v.v._1);
-  hash = fhasher.add_hash(hash, _v.v._2);
+  hash = fhasher.add_hash(hash, _v(0));
+  hash = fhasher.add_hash(hash, _v(1));
+  hash = fhasher.add_hash(hash, _v(2));
   return hash;
   return hash;
 }
 }
 
 
@@ -687,7 +703,11 @@ add_hash(size_t hash, FLOATTYPE threshold) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::
 operator - () const {
 operator - () const {
-  return FLOATNAME(LVecBase3)(-_v.v._0, -_v.v._1, -_v.v._2);
+#ifdef HAVE_EIGEN
+  return FLOATNAME(LVecBase3)(-_v);
+#else
+  return FLOATNAME(LVecBase3)(-_v(0), -_v(1), -_v(2));
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -697,9 +717,13 @@ operator - () const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::
 operator + (const FLOATNAME(LVecBase3) &other) const {
 operator + (const FLOATNAME(LVecBase3) &other) const {
-  return FLOATNAME(LVecBase3)(_v.v._0 + other._v.v._0,
-                              _v.v._1 + other._v.v._1,
-                              _v.v._2 + other._v.v._2);
+#ifdef HAVE_EIGEN
+  return FLOATNAME(LVecBase3)(_v + other._v);
+#else
+  return FLOATNAME(LVecBase3)(_v(0) + other._v(0),
+                              _v(1) + other._v(1),
+                              _v(2) + other._v(2));
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -709,9 +733,13 @@ operator + (const FLOATNAME(LVecBase3) &other) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::
 operator - (const FLOATNAME(LVecBase3) &other) const {
 operator - (const FLOATNAME(LVecBase3) &other) const {
-  return FLOATNAME(LVecBase3)(_v.v._0 - other._v.v._0,
-                              _v.v._1 - other._v.v._1,
-                              _v.v._2 - other._v.v._2);
+#ifdef HAVE_EIGEN
+  return FLOATNAME(LVecBase3)(_v - other._v);
+#else
+  return FLOATNAME(LVecBase3)(_v(0) - other._v(0),
+                              _v(1) - other._v(1),
+                              _v(2) - other._v(2));
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -721,9 +749,13 @@ operator - (const FLOATNAME(LVecBase3) &other) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::
 operator * (FLOATTYPE scalar) const {
 operator * (FLOATTYPE scalar) const {
-  return FLOATNAME(LVecBase3)(_v.v._0 * scalar,
-                              _v.v._1 * scalar,
-                              _v.v._2 * scalar);
+#ifdef HAVE_EIGEN
+  return FLOATNAME(LVecBase3)(_v * scalar);
+#else
+  return FLOATNAME(LVecBase3)(_v(0) * scalar,
+                              _v(1) * scalar,
+                              _v(2) * scalar);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -734,9 +766,7 @@ operator * (FLOATTYPE scalar) const {
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::
 operator / (FLOATTYPE scalar) const {
 operator / (FLOATTYPE scalar) const {
   FLOATTYPE recip_scalar = 1.0f/scalar;
   FLOATTYPE recip_scalar = 1.0f/scalar;
-  return FLOATNAME(LVecBase3)(_v.v._0 * recip_scalar,
-                              _v.v._1 * recip_scalar,
-                              _v.v._2 * recip_scalar);
+  return operator * (recip_scalar);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -746,9 +776,13 @@ operator / (FLOATTYPE scalar) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 operator += (const FLOATNAME(LVecBase3) &other) {
 operator += (const FLOATNAME(LVecBase3) &other) {
-  _v.v._0 += other._v.v._0;
-  _v.v._1 += other._v.v._1;
-  _v.v._2 += other._v.v._2;
+#ifdef HAVE_EIGEN
+  _v += other._v;
+#else
+  _v(0) += other._v(0);
+  _v(1) += other._v(1);
+  _v(2) += other._v(2);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -758,9 +792,13 @@ operator += (const FLOATNAME(LVecBase3) &other) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 operator -= (const FLOATNAME(LVecBase3) &other) {
 operator -= (const FLOATNAME(LVecBase3) &other) {
-  _v.v._0 -= other._v.v._0;
-  _v.v._1 -= other._v.v._1;
-  _v.v._2 -= other._v.v._2;
+#ifdef HAVE_EIGEN
+  _v -= other._v;
+#else
+  _v(0) -= other._v(0);
+  _v(1) -= other._v(1);
+  _v(2) -= other._v(2);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -770,9 +808,13 @@ operator -= (const FLOATNAME(LVecBase3) &other) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 operator *= (FLOATTYPE scalar) {
 operator *= (FLOATTYPE scalar) {
-  _v.v._0 *= scalar;
-  _v.v._1 *= scalar;
-  _v.v._2 *= scalar;
+#ifdef HAVE_EIGEN
+  _v *= scalar;
+#else
+  _v(0) *= scalar;
+  _v(1) *= scalar;
+  _v(2) *= scalar;
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -783,9 +825,7 @@ operator *= (FLOATTYPE scalar) {
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 operator /= (FLOATTYPE scalar) {
 operator /= (FLOATTYPE scalar) {
   FLOATTYPE recip_scalar = 1.0f/scalar;
   FLOATTYPE recip_scalar = 1.0f/scalar;
-  _v.v._0 *= recip_scalar;
-  _v.v._1 *= recip_scalar;
-  _v.v._2 *= recip_scalar;
+  operator *= (recip_scalar);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -796,9 +836,9 @@ operator /= (FLOATTYPE scalar) {
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::
 fmax(const FLOATNAME(LVecBase3) &other) {
 fmax(const FLOATNAME(LVecBase3) &other) {
   TAU_PROFILE("LVecBase3::fmax()", " ", TAU_USER);
   TAU_PROFILE("LVecBase3::fmax()", " ", TAU_USER);
-  return FLOATNAME(LVecBase3)(_v.v._0 > other._v.v._0 ? _v.v._0 : other._v.v._0,
-                              _v.v._1 > other._v.v._1 ? _v.v._1 : other._v.v._1,
-                              _v.v._2 > other._v.v._2 ? _v.v._2 : other._v.v._2);
+  return FLOATNAME(LVecBase3)(_v(0) > other._v(0) ? _v(0) : other._v(0),
+                              _v(1) > other._v(1) ? _v(1) : other._v(1),
+                              _v(2) > other._v(2) ? _v(2) : other._v(2));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -809,9 +849,9 @@ fmax(const FLOATNAME(LVecBase3) &other) {
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::
 fmin(const FLOATNAME(LVecBase3) &other) {
 fmin(const FLOATNAME(LVecBase3) &other) {
   TAU_PROFILE("LVecBase3::fmin()", " ", TAU_USER);
   TAU_PROFILE("LVecBase3::fmin()", " ", TAU_USER);
-  return FLOATNAME(LVecBase3)(_v.v._0 < other._v.v._0 ? _v.v._0 : other._v.v._0,
-                              _v.v._1 < other._v.v._1 ? _v.v._1 : other._v.v._1,
-                              _v.v._2 < other._v.v._2 ? _v.v._2 : other._v.v._2);
+  return FLOATNAME(LVecBase3)(_v(0) < other._v(0) ? _v(0) : other._v(0),
+                              _v(1) < other._v(1) ? _v(1) : other._v(1),
+                              _v(2) < other._v(2) ? _v(2) : other._v(2));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -833,9 +873,9 @@ cross_into(const FLOATNAME(LVecBase3) &other) {
 INLINE_LINMATH bool FLOATNAME(LVecBase3)::
 INLINE_LINMATH bool FLOATNAME(LVecBase3)::
 almost_equal(const FLOATNAME(LVecBase3) &other, FLOATTYPE threshold) const {
 almost_equal(const FLOATNAME(LVecBase3) &other, FLOATTYPE threshold) const {
   TAU_PROFILE("bool LVecBase3::almost_equal(LVecBase3 &, FLOATTYPE)", " ", TAU_USER);
   TAU_PROFILE("bool LVecBase3::almost_equal(LVecBase3 &, FLOATTYPE)", " ", TAU_USER);
-  return (IS_THRESHOLD_EQUAL(_v.v._0, other._v.v._0, threshold) &&
-          IS_THRESHOLD_EQUAL(_v.v._1, other._v.v._1, threshold) &&
-          IS_THRESHOLD_EQUAL(_v.v._2, other._v.v._2, threshold));
+  return (IS_THRESHOLD_EQUAL(_v(0), other._v(0), threshold) &&
+          IS_THRESHOLD_EQUAL(_v(1), other._v(1), threshold) &&
+          IS_THRESHOLD_EQUAL(_v(2), other._v(2), threshold));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -857,9 +897,9 @@ almost_equal(const FLOATNAME(LVecBase3) &other) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 output(ostream &out) const {
 output(ostream &out) const {
-  out << MAYBE_ZERO(_v.v._0) << " "
-      << MAYBE_ZERO(_v.v._1) << " "
-      << MAYBE_ZERO(_v.v._2);
+  out << MAYBE_ZERO(_v(0)) << " "
+      << MAYBE_ZERO(_v(1)) << " "
+      << MAYBE_ZERO(_v(2));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -881,9 +921,9 @@ generate_hash(ChecksumHashGenerator &hashgen) const {
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const {
 generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const {
   TAU_PROFILE("LVecBase3::generate_hash(ChecksumHashGenerator &, FLOATTYPE)", " ", TAU_USER);
   TAU_PROFILE("LVecBase3::generate_hash(ChecksumHashGenerator &, FLOATTYPE)", " ", TAU_USER);
-  hashgen.add_fp(_v.v._0, threshold);
-  hashgen.add_fp(_v.v._1, threshold);
-  hashgen.add_fp(_v.v._2, threshold);
+  hashgen.add_fp(_v(0), threshold);
+  hashgen.add_fp(_v(1), threshold);
+  hashgen.add_fp(_v(2), threshold);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -900,13 +940,13 @@ generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const {
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 write_datagram_fixed(Datagram &destination) const {
 write_datagram_fixed(Datagram &destination) const {
 #if FLOATTOKEN == 'f'
 #if FLOATTOKEN == 'f'
-  destination.add_float32(_v.v._0);
-  destination.add_float32(_v.v._1);
-  destination.add_float32(_v.v._2);
+  destination.add_float32(_v(0));
+  destination.add_float32(_v(1));
+  destination.add_float32(_v(2));
 #else
 #else
-  destination.add_float64(_v.v._0);
-  destination.add_float64(_v.v._1);
-  destination.add_float64(_v.v._2);
+  destination.add_float64(_v(0));
+  destination.add_float64(_v(1));
+  destination.add_float64(_v(2));
 #endif
 #endif
 }
 }
 
 
@@ -919,13 +959,13 @@ write_datagram_fixed(Datagram &destination) const {
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 read_datagram_fixed(DatagramIterator &source) {
 read_datagram_fixed(DatagramIterator &source) {
 #if FLOATTOKEN == 'f'
 #if FLOATTOKEN == 'f'
-  _v.v._0 = source.get_float32();
-  _v.v._1 = source.get_float32();
-  _v.v._2 = source.get_float32();
+  _v(0) = source.get_float32();
+  _v(1) = source.get_float32();
+  _v(2) = source.get_float32();
 #else
 #else
-  _v.v._0 = source.get_float64();
-  _v.v._1 = source.get_float64();
-  _v.v._2 = source.get_float64();
+  _v(0) = source.get_float64();
+  _v(1) = source.get_float64();
+  _v(2) = source.get_float64();
 #endif
 #endif
 }
 }
 
 
@@ -939,9 +979,9 @@ read_datagram_fixed(DatagramIterator &source) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 write_datagram(Datagram &destination) const {
 write_datagram(Datagram &destination) const {
-  destination.add_stdfloat(_v.v._0);
-  destination.add_stdfloat(_v.v._1);
-  destination.add_stdfloat(_v.v._2);
+  destination.add_stdfloat(_v(0));
+  destination.add_stdfloat(_v(1));
+  destination.add_stdfloat(_v(2));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -951,7 +991,7 @@ write_datagram(Datagram &destination) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 INLINE_LINMATH void FLOATNAME(LVecBase3)::
 read_datagram(DatagramIterator &source) {
 read_datagram(DatagramIterator &source) {
-  _v.v._0 = source.get_stdfloat();
-  _v.v._1 = source.get_stdfloat();
-  _v.v._2 = source.get_stdfloat();
+  _v(0) = source.get_stdfloat();
+  _v(1) = source.get_stdfloat();
+  _v(2) = source.get_stdfloat();
 }
 }

+ 8 - 7
panda/src/linmath/lvecBase3_src.h

@@ -17,7 +17,7 @@
 // Description : This is the base class for all three-component
 // Description : This is the base class for all three-component
 //               vectors and points.
 //               vectors and points.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDA_LINMATH FLOATNAME(LVecBase3) {
+class EXPCL_PANDA_LINMATH LINMATH_ALIGN FLOATNAME(LVecBase3) {
 PUBLISHED:
 PUBLISHED:
   typedef const FLOATTYPE *iterator;
   typedef const FLOATTYPE *iterator;
   typedef const FLOATTYPE *const_iterator;
   typedef const FLOATTYPE *const_iterator;
@@ -145,10 +145,11 @@ PUBLISHED:
   INLINE_LINMATH void read_datagram(DatagramIterator &source);
   INLINE_LINMATH void read_datagram(DatagramIterator &source);
 
 
 public:
 public:
-  union {
-        FLOATTYPE data[3];
-        struct {FLOATTYPE _0, _1, _2;} v;
-   } _v;
+  // The underlying implementation is via the Eigen library, if available.
+  typedef LINMATH_MATRIX(FLOATTYPE, 1, 3) EVector3;
+  EVector3 _v;
+
+  INLINE_LINMATH FLOATNAME(LVecBase3)(const EVector3 &v) : _v(v) { }
 
 
 private:
 private:
   static const FLOATNAME(LVecBase3) _zero;
   static const FLOATNAME(LVecBase3) _zero;
@@ -161,13 +162,13 @@ public:
     return _type_handle;
     return _type_handle;
   }
   }
   static void init_type();
   static void init_type();
-
+ 
 private:
 private:
   static TypeHandle _type_handle;
   static TypeHandle _type_handle;
 };
 };
 
 
 
 
-INLINE_LINMATH ostream &operator << (ostream &out, const FLOATNAME(LVecBase3) &vec) {
+INLINE ostream &operator << (ostream &out, const FLOATNAME(LVecBase3) &vec) {
   vec.output(out);
   vec.output(out);
   return out;
   return out;
 };
 };

+ 18 - 18
panda/src/linmath/lvecBase4_ext_src.I

@@ -27,7 +27,7 @@ IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase4);
 INLINE void EXT_METHOD_ARGS(FLOATNAME(LVecBase4),
 INLINE void EXT_METHOD_ARGS(FLOATNAME(LVecBase4),
 __setitem__, int i, FLOATTYPE v) {
 __setitem__, int i, FLOATTYPE v) {
   nassertv(i >= 0 && i < 4);
   nassertv(i >= 0 && i < 4);
-  this->_v.data[i] = v;
+  this->_v(i) = v;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -38,10 +38,10 @@ __setitem__, int i, FLOATTYPE v) {
 INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LVecBase4),
 INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LVecBase4),
 python_repr, ostream &out, const string &class_name) {
 python_repr, ostream &out, const string &class_name) {
   out << class_name << "("
   out << class_name << "("
-      << MAYBE_ZERO(this->_v.v._0) << ", "
-      << MAYBE_ZERO(this->_v.v._1) << ", "
-      << MAYBE_ZERO(this->_v.v._2) << ", "
-      << MAYBE_ZERO(this->_v.v._3) << ")";
+      << MAYBE_ZERO(this->_v(0)) << ", "
+      << MAYBE_ZERO(this->_v(1)) << ", "
+      << MAYBE_ZERO(this->_v(2)) << ", "
+      << MAYBE_ZERO(this->_v(3)) << ")";
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -83,30 +83,30 @@ __getattr__, const string &attr_name) {
 
 
   if (attr_name.size() == 1) {
   if (attr_name.size() == 1) {
     if (attr_name[0] == 'w') {
     if (attr_name[0] == 'w') {
-      return PyFloat_FromDouble(this->_v.data[3]);
+      return PyFloat_FromDouble(this->_v(3));
     } else {
     } else {
-      return PyFloat_FromDouble(this->_v.data[attr_name[0] - 'x']);
+      return PyFloat_FromDouble(this->_v(attr_name[0] - 'x'));
     }
     }
 
 
   } else if (attr_name.size() == 2) {
   } else if (attr_name.size() == 2) {
     FLOATNAME(LVecBase2) *vec = new FLOATNAME(LVecBase2);
     FLOATNAME(LVecBase2) *vec = new FLOATNAME(LVecBase2);
-    vec->_v.v._0 = this->_v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
+    vec->_v(0) = this->_v((attr_name[0] == 'w') ? 3 : attr_name[0] - 'x');
+    vec->_v(1) = this->_v((attr_name[1] == 'w') ? 3 : attr_name[1] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase2), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase2), true, false);
 
 
   } else if (attr_name.size() == 3) {
   } else if (attr_name.size() == 3) {
     FLOATNAME(LVecBase3) *vec = new FLOATNAME(LVecBase3);
     FLOATNAME(LVecBase3) *vec = new FLOATNAME(LVecBase3);
-    vec->_v.v._0 = this->_v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
-    vec->_v.v._2 = this->_v.data[(attr_name[2] == 'w') ? 3 : attr_name[2] - 'x'];
+    vec->_v(0) = this->_v((attr_name[0] == 'w') ? 3 : attr_name[0] - 'x');
+    vec->_v(1) = this->_v((attr_name[1] == 'w') ? 3 : attr_name[1] - 'x');
+    vec->_v(2) = this->_v((attr_name[2] == 'w') ? 3 : attr_name[2] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase3), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase3), true, false);
 
 
   } else if (attr_name.size() == 4) {
   } else if (attr_name.size() == 4) {
     FLOATNAME(LVecBase4) *vec = new FLOATNAME(LVecBase4);
     FLOATNAME(LVecBase4) *vec = new FLOATNAME(LVecBase4);
-    vec->_v.v._0 = this->_v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
-    vec->_v.v._2 = this->_v.data[(attr_name[2] == 'w') ? 3 : attr_name[2] - 'x'];
-    vec->_v.v._3 = this->_v.data[(attr_name[3] == 'w') ? 3 : attr_name[3] - 'x'];
+    vec->_v(0) = this->_v((attr_name[0] == 'w') ? 3 : attr_name[0] - 'x');
+    vec->_v(1) = this->_v((attr_name[1] == 'w') ? 3 : attr_name[1] - 'x');
+    vec->_v(2) = this->_v((attr_name[2] == 'w') ? 3 : attr_name[2] - 'x');
+    vec->_v(3) = this->_v((attr_name[3] == 'w') ? 3 : attr_name[3] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase4), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase4), true, false);
   }
   }
 
 
@@ -162,7 +162,7 @@ __setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
       double value = PyFloat_AS_DOUBLE(fl);
       double value = PyFloat_AS_DOUBLE(fl);
       Py_DECREF(fl);
       Py_DECREF(fl);
 
 
-      this->_v.data[(attr_name[i] == 'w') ? 3 : attr_name[i] - 'x'] = value;
+      this->_v((attr_name[i] == 'w') ? 3 : attr_name[i] - 'x') = value;
     }
     }
 
 
     Py_DECREF(fast);
     Py_DECREF(fast);
@@ -187,7 +187,7 @@ __setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
     // Loop through the components in the attribute name,
     // Loop through the components in the attribute name,
     // and assign the floating-point value to every one of them.
     // and assign the floating-point value to every one of them.
     for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
     for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
-      this->_v.data[((*it) == 'w') ? 3 : (*it) - 'x'] = value;
+      this->_v(((*it) == 'w') ? 3 : (*it) - 'x') = value;
     }
     }
   }
   }
 
 

+ 173 - 143
panda/src/linmath/lvecBase4_src.I

@@ -28,13 +28,7 @@ FLOATNAME(LVecBase4)() {
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATNAME(LVecBase4)::
-FLOATNAME(LVecBase4)(const FLOATNAME(LVecBase4) &copy) {
-  TAU_PROFILE("LVecBase4::LVecBase4(LVecBase4 &)", " ", TAU_USER);
-  _v.v._0 = copy._v.v._0;
-  _v.v._1 = copy._v.v._1;
-  _v.v._2 = copy._v.v._2;
-  _v.v._3 = copy._v.v._3;
-//  (*this) = copy;
+FLOATNAME(LVecBase4)(const FLOATNAME(LVecBase4) &copy) : _v(copy._v) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -45,11 +39,7 @@ FLOATNAME(LVecBase4)(const FLOATNAME(LVecBase4) &copy) {
 INLINE_LINMATH FLOATNAME(LVecBase4) &FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATNAME(LVecBase4) &FLOATNAME(LVecBase4)::
 operator = (const FLOATNAME(LVecBase4) &copy) {
 operator = (const FLOATNAME(LVecBase4) &copy) {
   TAU_PROFILE("void LVecBase4::operator = (LVecBase4 &)", " ", TAU_USER);
   TAU_PROFILE("void LVecBase4::operator = (LVecBase4 &)", " ", TAU_USER);
-  _v.v._0 = copy._v.v._0;
-  _v.v._1 = copy._v.v._1;
-  _v.v._2 = copy._v.v._2;
-  _v.v._3 = copy._v.v._3;
-//  set(copy[0], copy[1], copy[2], copy[3]);
+  _v = copy._v;
   return *this;
   return *this;
 }
 }
 
 
@@ -81,12 +71,8 @@ FLOATNAME(LVecBase4)(FLOATTYPE fill_value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATNAME(LVecBase4)::
 FLOATNAME(LVecBase4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w) {
 FLOATNAME(LVecBase4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w) {
-  TAU_PROFILE("void LVecBase4::operator = (FLOATTYPE, ...)", " ", TAU_USER);
-  _v.v._0 = x;
-  _v.v._1 = y;
-  _v.v._2 = z;
-  _v.v._3 = w;
-//  set(x, y, z, w);
+  TAU_PROFILE("LVecBase4::LVecBase4(FLOATTYPE, ...)", " ", TAU_USER);
+  set(x, y, z, w);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -156,7 +142,7 @@ unit_w() {
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
 operator [](int i) const {
 operator [](int i) const {
   nassertr(i >= 0 && i < 4, 0.0);
   nassertr(i >= 0 && i < 4, 0.0);
-  return _v.data[i];
+  return _v(i);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -166,8 +152,8 @@ operator [](int i) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE &FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATTYPE &FLOATNAME(LVecBase4)::
 operator [](int i) {
 operator [](int i) {
-  nassertr(i >= 0 && i < 4, _v.data[0]);
-  return _v.data[i];
+  nassertr(i >= 0 && i < 4, _v(0));
+  return _v(i);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -189,7 +175,7 @@ size() {
 INLINE_LINMATH bool FLOATNAME(LVecBase4)::
 INLINE_LINMATH bool FLOATNAME(LVecBase4)::
 is_nan() const {
 is_nan() const {
   TAU_PROFILE("bool LVecBase4::is_nan()", " ", TAU_USER);
   TAU_PROFILE("bool LVecBase4::is_nan()", " ", TAU_USER);
-  return cnan(_v.v._0) || cnan(_v.v._1) || cnan(_v.v._2) || cnan(_v.v._3);
+  return cnan(_v(0)) || cnan(_v(1)) || cnan(_v(2)) || cnan(_v(3));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -200,7 +186,7 @@ is_nan() const {
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
 get_cell(int i) const {
 get_cell(int i) const {
   nassertr(i >= 0 && i < 4, 0.0);
   nassertr(i >= 0 && i < 4, 0.0);
-  return _v.data[i];
+  return _v(i);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -210,7 +196,7 @@ get_cell(int i) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
 get_x() const {
 get_x() const {
-  return _v.v._0;
+  return _v(0);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -220,7 +206,7 @@ get_x() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
 get_y() const {
 get_y() const {
-  return _v.v._1;
+  return _v(1);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -230,7 +216,7 @@ get_y() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
 get_z() const {
 get_z() const {
-  return _v.v._2;
+  return _v(2);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -240,7 +226,7 @@ get_z() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
 get_w() const {
 get_w() const {
-  return _v.v._3;
+  return _v(3);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -251,7 +237,7 @@ get_w() const {
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 set_cell(int i, FLOATTYPE value) {
 set_cell(int i, FLOATTYPE value) {
   nassertv(i >= 0 && i < 4);
   nassertv(i >= 0 && i < 4);
-  _v.data[i] = value;
+  _v(i) = value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -261,7 +247,7 @@ set_cell(int i, FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 set_x(FLOATTYPE value) {
 set_x(FLOATTYPE value) {
-  _v.v._0 = value;
+  _v(0) = value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -271,7 +257,7 @@ set_x(FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 set_y(FLOATTYPE value) {
 set_y(FLOATTYPE value) {
-  _v.v._1 = value;
+  _v(1) = value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -281,7 +267,7 @@ set_y(FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 set_z(FLOATTYPE value) {
 set_z(FLOATTYPE value) {
-  _v.v._2 = value;
+  _v(2) = value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -291,7 +277,7 @@ set_z(FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 set_w(FLOATTYPE value) {
 set_w(FLOATTYPE value) {
-  _v.v._3 = value;
+  _v(3) = value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -302,7 +288,7 @@ set_w(FLOATTYPE value) {
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 add_to_cell(int i, FLOATTYPE value) {
 add_to_cell(int i, FLOATTYPE value) {
   nassertv(i >= 0 && i < 4);
   nassertv(i >= 0 && i < 4);
-  _v.data[i] += value;
+  _v(i) += value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -312,7 +298,7 @@ add_to_cell(int i, FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 add_x(FLOATTYPE value) {
 add_x(FLOATTYPE value) {
-  _v.v._0 += value;
+  _v(0) += value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -322,7 +308,7 @@ add_x(FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 add_y(FLOATTYPE value) {
 add_y(FLOATTYPE value) {
-  _v.v._1 += value;
+  _v(1) += value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -332,7 +318,7 @@ add_y(FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 add_z(FLOATTYPE value) {
 add_z(FLOATTYPE value) {
-  _v.v._2 += value;
+  _v(2) += value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -342,7 +328,7 @@ add_z(FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 add_w(FLOATTYPE value) {
 add_w(FLOATTYPE value) {
-  _v.v._3 += value;
+  _v(3) += value;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -354,7 +340,7 @@ add_w(FLOATTYPE value) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH const FLOATTYPE *FLOATNAME(LVecBase4)::
 INLINE_LINMATH const FLOATTYPE *FLOATNAME(LVecBase4)::
 get_data() const {
 get_data() const {
-  return _v.data;
+  return &_v(0);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -375,7 +361,7 @@ get_num_components() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase4)::iterator FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATNAME(LVecBase4)::iterator FLOATNAME(LVecBase4)::
 begin() {
 begin() {
-  return _v.data;
+  return &_v(0);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -397,7 +383,7 @@ end() {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase4)::const_iterator FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATNAME(LVecBase4)::const_iterator FLOATNAME(LVecBase4)::
 begin() const {
 begin() const {
-  return _v.data;
+  return &_v(0);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -421,10 +407,14 @@ end() const {
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 fill(FLOATTYPE fill_value) {
 fill(FLOATTYPE fill_value) {
   TAU_PROFILE("void LVecBase4::fill()", " ", TAU_USER);
   TAU_PROFILE("void LVecBase4::fill()", " ", TAU_USER);
-  _v.v._0 = fill_value;
-  _v.v._1 = fill_value;
-  _v.v._2 = fill_value;
-  _v.v._3 = fill_value;
+#ifdef HAVE_EIGEN
+  _v = EVector4::Constant(fill_value);
+#else
+  _v(0) = fill_value;
+  _v(1) = fill_value;
+  _v(2) = fill_value;
+  _v(3) = fill_value;
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -435,10 +425,10 @@ fill(FLOATTYPE fill_value) {
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w) {
 set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w) {
   TAU_PROFILE("void LVecBase4::set()", " ", TAU_USER);
   TAU_PROFILE("void LVecBase4::set()", " ", TAU_USER);
-  _v.v._0 = x;
-  _v.v._1 = y;
-  _v.v._2 = z;
-  _v.v._3 = w;
+  _v(0) = x;
+  _v(1) = y;
+  _v(2) = z;
+  _v(3) = w;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -449,7 +439,12 @@ set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
 length() const {
 length() const {
+  TAU_PROFILE("FLOATTYPE LVecBase4::length()", " ", TAU_USER);
+#ifdef HAVE_EIGEN
+  return _v.norm();
+#else
   return csqrt((*this).dot(*this));
   return csqrt((*this).dot(*this));
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -460,7 +455,12 @@ length() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
 length_squared() const {
 length_squared() const {
+  TAU_PROFILE("FLOATTYPE LVecBase4::length_squared()", " ", TAU_USER);
+#ifdef HAVE_EIGEN
+  return _v.squaredNorm();
+#else
   return (*this).dot(*this);
   return (*this).dot(*this);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -492,9 +492,13 @@ normalize() {
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4)::
 dot(const FLOATNAME(LVecBase4) &other) const {
 dot(const FLOATNAME(LVecBase4) &other) const {
   TAU_PROFILE("FLOATTYPE LVecBase4::dot()", " ", TAU_USER);
   TAU_PROFILE("FLOATTYPE LVecBase4::dot()", " ", TAU_USER);
+#ifdef HAVE_EIGEN
+  return _v.dot(other._v);
+#else
   return
   return
-    _v.v._0 * other._v.v._0 + _v.v._1 * other._v.v._1 +
-    _v.v._2 * other._v.v._2 + _v.v._3 * other._v.v._3;
+    _v(0) * other._v(0) + _v(1) * other._v(1) +
+    _v(2) * other._v(2) + _v(3) * other._v(3);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -532,10 +536,14 @@ operator < (const FLOATNAME(LVecBase4) &other) const {
 INLINE_LINMATH bool FLOATNAME(LVecBase4)::
 INLINE_LINMATH bool FLOATNAME(LVecBase4)::
 operator == (const FLOATNAME(LVecBase4) &other) const {
 operator == (const FLOATNAME(LVecBase4) &other) const {
   TAU_PROFILE("bool LVecBase4::operator ==(const LVecBase4 &)", " ", TAU_USER);
   TAU_PROFILE("bool LVecBase4::operator ==(const LVecBase4 &)", " ", TAU_USER);
-  return (_v.v._0 == other._v.v._0 &&
-          _v.v._1 == other._v.v._1 &&
-          _v.v._2 == other._v.v._2 &&
-          _v.v._3 == other._v.v._3);
+#ifdef HAVE_EIGEN
+  return _v == other._v;
+#else
+  return (_v(0) == other._v(0) &&
+          _v(1) == other._v(1) &&
+          _v(2) == other._v(2) &&
+          _v(3) == other._v(3));
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -572,17 +580,17 @@ compare_to(const FLOATNAME(LVecBase4) &other) const {
 INLINE_LINMATH int FLOATNAME(LVecBase4)::
 INLINE_LINMATH int FLOATNAME(LVecBase4)::
 compare_to(const FLOATNAME(LVecBase4) &other, FLOATTYPE threshold) const {
 compare_to(const FLOATNAME(LVecBase4) &other, FLOATTYPE threshold) const {
   TAU_PROFILE("int LVecBase4::compare_to(const LVecBase4 &, FLOATTYPE)", " ", TAU_USER);
   TAU_PROFILE("int LVecBase4::compare_to(const LVecBase4 &, FLOATTYPE)", " ", TAU_USER);
-  if (!IS_THRESHOLD_COMPEQ(_v.v._0, other._v.v._0, threshold)) {
-    return (_v.v._0 < other._v.v._0) ? -1 : 1;
+  if (!IS_THRESHOLD_COMPEQ(_v(0), other._v(0), threshold)) {
+    return (_v(0) < other._v(0)) ? -1 : 1;
   }
   }
-  if (!IS_THRESHOLD_COMPEQ(_v.v._1, other._v.v._1, threshold)) {
-    return (_v.v._1 < other._v.v._1) ? -1 : 1;
+  if (!IS_THRESHOLD_COMPEQ(_v(1), other._v(1), threshold)) {
+    return (_v(1) < other._v(1)) ? -1 : 1;
   }
   }
-  if (!IS_THRESHOLD_COMPEQ(_v.v._2, other._v.v._2, threshold)) {
-    return (_v.v._2 < other._v.v._2) ? -1 : 1;
+  if (!IS_THRESHOLD_COMPEQ(_v(2), other._v(2), threshold)) {
+    return (_v(2) < other._v(2)) ? -1 : 1;
   }
   }
-  if (!IS_THRESHOLD_COMPEQ(_v.v._3, other._v.v._3, threshold)) {
-    return (_v.v._3 < other._v.v._3) ? -1 : 1;
+  if (!IS_THRESHOLD_COMPEQ(_v(3), other._v(3), threshold)) {
+    return (_v(3) < other._v(3)) ? -1 : 1;
   }
   }
   return 0;
   return 0;
 }
 }
@@ -629,10 +637,10 @@ INLINE_LINMATH size_t FLOATNAME(LVecBase4)::
 add_hash(size_t hash, FLOATTYPE threshold) const {
 add_hash(size_t hash, FLOATTYPE threshold) const {
   TAU_PROFILE("LVecBase4::add_hash(size_t, FLOATTYPE)", " ", TAU_USER);
   TAU_PROFILE("LVecBase4::add_hash(size_t, FLOATTYPE)", " ", TAU_USER);
   float_hash fhasher(threshold);
   float_hash fhasher(threshold);
-  hash = fhasher.add_hash(hash, _v.v._0);
-  hash = fhasher.add_hash(hash, _v.v._1);
-  hash = fhasher.add_hash(hash, _v.v._2);
-  hash = fhasher.add_hash(hash, _v.v._3);
+  hash = fhasher.add_hash(hash, _v(0));
+  hash = fhasher.add_hash(hash, _v(1));
+  hash = fhasher.add_hash(hash, _v(2));
+  hash = fhasher.add_hash(hash, _v(3));
   return hash;
   return hash;
 }
 }
 
 
@@ -643,7 +651,11 @@ add_hash(size_t hash, FLOATTYPE threshold) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::
 operator - () const {
 operator - () const {
-  return FLOATNAME(LVecBase4)(-_v.v._0, -_v.v._1, -_v.v._2, -_v.v._3);
+#ifdef HAVE_EIGEN
+  return FLOATNAME(LVecBase4)(-_v);
+#else
+  return FLOATNAME(LVecBase4)(-_v(0), -_v(1), -_v(2), -_v(3));
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -653,10 +665,14 @@ operator - () const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::
 operator + (const FLOATNAME(LVecBase4) &other) const {
 operator + (const FLOATNAME(LVecBase4) &other) const {
-  return FLOATNAME(LVecBase4)(_v.v._0 + other._v.v._0,
-                              _v.v._1 + other._v.v._1,
-                              _v.v._2 + other._v.v._2,
-                              _v.v._3 + other._v.v._3);
+#ifdef HAVE_EIGEN
+  return FLOATNAME(LVecBase4)(_v + other._v);
+#else
+  return FLOATNAME(LVecBase4)(_v(0) + other._v(0),
+                              _v(1) + other._v(1),
+                              _v(2) + other._v(2),
+                              _v(3) + other._v(3));
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -666,10 +682,14 @@ operator + (const FLOATNAME(LVecBase4) &other) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::
 operator - (const FLOATNAME(LVecBase4) &other) const {
 operator - (const FLOATNAME(LVecBase4) &other) const {
-  return FLOATNAME(LVecBase4)(_v.v._0 - other._v.v._0,
-                              _v.v._1 - other._v.v._1,
-                              _v.v._2 - other._v.v._2,
-                              _v.v._3 - other._v.v._3);
+#ifdef HAVE_EIGEN
+  return FLOATNAME(LVecBase4)(_v - other._v);
+#else
+  return FLOATNAME(LVecBase4)(_v(0) - other._v(0),
+                              _v(1) - other._v(1),
+                              _v(2) - other._v(2),
+                              _v(3) - other._v(3));
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -679,10 +699,14 @@ operator - (const FLOATNAME(LVecBase4) &other) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::
 operator * (FLOATTYPE scalar) const {
 operator * (FLOATTYPE scalar) const {
-  return FLOATNAME(LVecBase4)(_v.v._0 * scalar,
-                              _v.v._1 * scalar,
-                              _v.v._2 * scalar,
-                              _v.v._3 * scalar);
+#ifdef HAVE_EIGEN
+  return FLOATNAME(LVecBase4)(_v * scalar);
+#else
+  return FLOATNAME(LVecBase4)(_v(0) * scalar,
+                              _v(1) * scalar,
+                              _v(2) * scalar,
+                              _v(3) * scalar);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -693,10 +717,7 @@ operator * (FLOATTYPE scalar) const {
 INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::
 operator / (FLOATTYPE scalar) const {
 operator / (FLOATTYPE scalar) const {
   FLOATTYPE recip_scalar = 1.0f/scalar;
   FLOATTYPE recip_scalar = 1.0f/scalar;
-  return FLOATNAME(LVecBase4)(_v.v._0 * recip_scalar,
-                              _v.v._1 * recip_scalar,
-                              _v.v._2 * recip_scalar,
-                              _v.v._3 * recip_scalar);
+  return operator * (recip_scalar);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -706,10 +727,14 @@ operator / (FLOATTYPE scalar) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 operator += (const FLOATNAME(LVecBase4) &other) {
 operator += (const FLOATNAME(LVecBase4) &other) {
-  _v.v._0 += other._v.v._0;
-  _v.v._1 += other._v.v._1;
-  _v.v._2 += other._v.v._2;
-  _v.v._3 += other._v.v._3;
+#ifdef HAVE_EIGEN
+  _v += other._v;
+#else
+  _v(0) += other._v(0);
+  _v(1) += other._v(1);
+  _v(2) += other._v(2);
+  _v(3) += other._v(3);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -719,10 +744,14 @@ operator += (const FLOATNAME(LVecBase4) &other) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 operator -= (const FLOATNAME(LVecBase4) &other) {
 operator -= (const FLOATNAME(LVecBase4) &other) {
-  _v.v._0 -= other._v.v._0;
-  _v.v._1 -= other._v.v._1;
-  _v.v._2 -= other._v.v._2;
-  _v.v._3 -= other._v.v._3;
+#ifdef HAVE_EIGEN
+  _v -= other._v;
+#else
+  _v(0) -= other._v(0);
+  _v(1) -= other._v(1);
+  _v(2) -= other._v(2);
+  _v(3) -= other._v(3);
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -732,10 +761,14 @@ operator -= (const FLOATNAME(LVecBase4) &other) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 operator *= (FLOATTYPE scalar) {
 operator *= (FLOATTYPE scalar) {
-  _v.v._0 *= scalar;
-  _v.v._1 *= scalar;
-  _v.v._2 *= scalar;
-  _v.v._3 *= scalar;
+#ifdef HAVE_EIGEN
+  _v *= scalar;
+#else
+  _v(0) *= scalar;
+  _v(1) *= scalar;
+  _v(2) *= scalar;
+  _v(3) *= scalar;
+#endif  // HAVE_EIGEN
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -746,10 +779,7 @@ operator *= (FLOATTYPE scalar) {
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 operator /= (FLOATTYPE scalar) {
 operator /= (FLOATTYPE scalar) {
   FLOATTYPE recip_scalar = 1.0f/scalar;
   FLOATTYPE recip_scalar = 1.0f/scalar;
-  _v.v._0 *= recip_scalar;
-  _v.v._1 *= recip_scalar;
-  _v.v._2 *= recip_scalar;
-  _v.v._3 *= recip_scalar;
+  operator *= (recip_scalar);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -760,10 +790,10 @@ operator /= (FLOATTYPE scalar) {
 INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::
 fmax(const FLOATNAME(LVecBase4) &other) {
 fmax(const FLOATNAME(LVecBase4) &other) {
   TAU_PROFILE("LVecBase4::fmax()", " ", TAU_USER);
   TAU_PROFILE("LVecBase4::fmax()", " ", TAU_USER);
-  return FLOATNAME(LVecBase4)(_v.v._0 > other._v.v._0 ? _v.v._0 : other._v.v._0,
-                              _v.v._1 > other._v.v._1 ? _v.v._1 : other._v.v._1,
-                              _v.v._2 > other._v.v._2 ? _v.v._2 : other._v.v._2,
-                              _v.v._3 > other._v.v._3 ? _v.v._3 : other._v.v._3);
+  return FLOATNAME(LVecBase4)(_v(0) > other._v(0) ? _v(0) : other._v(0),
+                              _v(1) > other._v(1) ? _v(1) : other._v(1),
+                              _v(2) > other._v(2) ? _v(2) : other._v(2),
+                              _v(3) > other._v(3) ? _v(3) : other._v(3));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -774,10 +804,10 @@ fmax(const FLOATNAME(LVecBase4) &other) {
 INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::
 INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::
 fmin(const FLOATNAME(LVecBase4) &other) {
 fmin(const FLOATNAME(LVecBase4) &other) {
   TAU_PROFILE("LVecBase4::fmin()", " ", TAU_USER);
   TAU_PROFILE("LVecBase4::fmin()", " ", TAU_USER);
-  return FLOATNAME(LVecBase4)(_v.v._0 < other._v.v._0 ? _v.v._0 : other._v.v._0,
-                              _v.v._1 < other._v.v._1 ? _v.v._1 : other._v.v._1,
-                              _v.v._2 < other._v.v._2 ? _v.v._2 : other._v.v._2,
-                              _v.v._3 < other._v.v._3 ? _v.v._3 : other._v.v._3);
+  return FLOATNAME(LVecBase4)(_v(0) < other._v(0) ? _v(0) : other._v(0),
+                              _v(1) < other._v(1) ? _v(1) : other._v(1),
+                              _v(2) < other._v(2) ? _v(2) : other._v(2),
+                              _v(3) < other._v(3) ? _v(3) : other._v(3));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -789,10 +819,10 @@ fmin(const FLOATNAME(LVecBase4) &other) {
 INLINE_LINMATH bool FLOATNAME(LVecBase4)::
 INLINE_LINMATH bool FLOATNAME(LVecBase4)::
 almost_equal(const FLOATNAME(LVecBase4) &other, FLOATTYPE threshold) const {
 almost_equal(const FLOATNAME(LVecBase4) &other, FLOATTYPE threshold) const {
   TAU_PROFILE("bool LVecBase4::almost_equal(LVecBase4 &, FLOATTYPE)", " ", TAU_USER);
   TAU_PROFILE("bool LVecBase4::almost_equal(LVecBase4 &, FLOATTYPE)", " ", TAU_USER);
-  return (IS_THRESHOLD_EQUAL(_v.v._0, other._v.v._0, threshold) &&
-          IS_THRESHOLD_EQUAL(_v.v._1, other._v.v._1, threshold) &&
-          IS_THRESHOLD_EQUAL(_v.v._2, other._v.v._2, threshold) &&
-          IS_THRESHOLD_EQUAL(_v.v._3, other._v.v._3, threshold));
+  return (IS_THRESHOLD_EQUAL(_v(0), other._v(0), threshold) &&
+          IS_THRESHOLD_EQUAL(_v(1), other._v(1), threshold) &&
+          IS_THRESHOLD_EQUAL(_v(2), other._v(2), threshold) &&
+          IS_THRESHOLD_EQUAL(_v(3), other._v(3), threshold));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -814,10 +844,10 @@ almost_equal(const FLOATNAME(LVecBase4) &other) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 output(ostream &out) const {
 output(ostream &out) const {
-  out << MAYBE_ZERO(_v.v._0) << " "
-      << MAYBE_ZERO(_v.v._1) << " "
-      << MAYBE_ZERO(_v.v._2) << " "
-      << MAYBE_ZERO(_v.v._3);
+  out << MAYBE_ZERO(_v(0)) << " "
+      << MAYBE_ZERO(_v(1)) << " "
+      << MAYBE_ZERO(_v(2)) << " "
+      << MAYBE_ZERO(_v(3));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -839,10 +869,10 @@ generate_hash(ChecksumHashGenerator &hashgen) const {
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const {
 generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const {
   TAU_PROFILE("LVecBase4::generate_hash(ChecksumHashGenerator &, FLOATTYPE)", " ", TAU_USER);
   TAU_PROFILE("LVecBase4::generate_hash(ChecksumHashGenerator &, FLOATTYPE)", " ", TAU_USER);
-  hashgen.add_fp(_v.v._0, threshold);
-  hashgen.add_fp(_v.v._1, threshold);
-  hashgen.add_fp(_v.v._2, threshold);
-  hashgen.add_fp(_v.v._3, threshold);
+  hashgen.add_fp(_v(0), threshold);
+  hashgen.add_fp(_v(1), threshold);
+  hashgen.add_fp(_v(2), threshold);
+  hashgen.add_fp(_v(3), threshold);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -859,15 +889,15 @@ generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const {
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 write_datagram_fixed(Datagram &destination) const {
 write_datagram_fixed(Datagram &destination) const {
 #if FLOATTOKEN == 'f'
 #if FLOATTOKEN == 'f'
-  destination.add_float32(_v.v._0);
-  destination.add_float32(_v.v._1);
-  destination.add_float32(_v.v._2);
-  destination.add_float32(_v.v._3);
+  destination.add_float32(_v(0));
+  destination.add_float32(_v(1));
+  destination.add_float32(_v(2));
+  destination.add_float32(_v(3));
 #else
 #else
-  destination.add_float64(_v.v._0);
-  destination.add_float64(_v.v._1);
-  destination.add_float64(_v.v._2);
-  destination.add_float64(_v.v._3);
+  destination.add_float64(_v(0));
+  destination.add_float64(_v(1));
+  destination.add_float64(_v(2));
+  destination.add_float64(_v(3));
 #endif
 #endif
 }
 }
 
 
@@ -880,15 +910,15 @@ write_datagram_fixed(Datagram &destination) const {
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 read_datagram_fixed(DatagramIterator &source) {
 read_datagram_fixed(DatagramIterator &source) {
 #if FLOATTOKEN == 'f'
 #if FLOATTOKEN == 'f'
-  _v.v._0 = source.get_float32();
-  _v.v._1 = source.get_float32();
-  _v.v._2 = source.get_float32();
-  _v.v._3 = source.get_float32();
+  _v(0) = source.get_float32();
+  _v(1) = source.get_float32();
+  _v(2) = source.get_float32();
+  _v(3) = source.get_float32();
 #else
 #else
-  _v.v._0 = source.get_float64();
-  _v.v._1 = source.get_float64();
-  _v.v._2 = source.get_float64();
-  _v.v._3 = source.get_float64();
+  _v(0) = source.get_float64();
+  _v(1) = source.get_float64();
+  _v(2) = source.get_float64();
+  _v(3) = source.get_float64();
 #endif
 #endif
 }
 }
 
 
@@ -902,10 +932,10 @@ read_datagram_fixed(DatagramIterator &source) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 write_datagram(Datagram &destination) const {
 write_datagram(Datagram &destination) const {
-  destination.add_stdfloat(_v.v._0);
-  destination.add_stdfloat(_v.v._1);
-  destination.add_stdfloat(_v.v._2);
-  destination.add_stdfloat(_v.v._3);
+  destination.add_stdfloat(_v(0));
+  destination.add_stdfloat(_v(1));
+  destination.add_stdfloat(_v(2));
+  destination.add_stdfloat(_v(3));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -915,8 +945,8 @@ write_datagram(Datagram &destination) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 INLINE_LINMATH void FLOATNAME(LVecBase4)::
 read_datagram(DatagramIterator &source) {
 read_datagram(DatagramIterator &source) {
-  _v.v._0 = source.get_stdfloat();
-  _v.v._1 = source.get_stdfloat();
-  _v.v._2 = source.get_stdfloat();
-  _v.v._3 = source.get_stdfloat();
+  _v(0) = source.get_stdfloat();
+  _v(1) = source.get_stdfloat();
+  _v(2) = source.get_stdfloat();
+  _v(3) = source.get_stdfloat();
 }
 }

+ 7 - 6
panda/src/linmath/lvecBase4_src.h

@@ -20,7 +20,7 @@ class FLOATNAME(LVecBase3);
 // Description : This is the base class for all three-component
 // Description : This is the base class for all three-component
 //               vectors and points.
 //               vectors and points.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDA_LINMATH FLOATNAME(LVecBase4) {
+class EXPCL_PANDA_LINMATH LINMATH_ALIGN FLOATNAME(LVecBase4) {
 PUBLISHED:
 PUBLISHED:
   typedef const FLOATTYPE *iterator;
   typedef const FLOATTYPE *iterator;
   typedef const FLOATTYPE *const_iterator;
   typedef const FLOATTYPE *const_iterator;
@@ -143,10 +143,11 @@ PUBLISHED:
   INLINE_LINMATH void read_datagram(DatagramIterator &source);
   INLINE_LINMATH void read_datagram(DatagramIterator &source);
 
 
 public:
 public:
-  union {
-        FLOATTYPE data[4];
-        struct {FLOATTYPE _0, _1, _2, _3;} v;
-  } _v;
+  // The underlying implementation is via the Eigen library, if available.
+  typedef LINMATH_MATRIX(FLOATTYPE, 1, 4) EVector4;
+  EVector4 _v;
+
+  INLINE_LINMATH FLOATNAME(LVecBase4)(const EVector4 &v) : _v(v) { }
 
 
 private:
 private:
   static const FLOATNAME(LVecBase4) _zero;
   static const FLOATNAME(LVecBase4) _zero;
@@ -165,7 +166,7 @@ private:
   static TypeHandle _type_handle;
   static TypeHandle _type_handle;
 };
 };
 
 
-INLINE_LINMATH ostream &operator << (ostream &out, const FLOATNAME(LVecBase4) &vec) {
+INLINE ostream &operator << (ostream &out, const FLOATNAME(LVecBase4) &vec) {
   vec.output(out);
   vec.output(out);
   return out;
   return out;
 }
 }

+ 12 - 12
panda/src/linmath/lvector2_ext_src.I

@@ -27,8 +27,8 @@ IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector4);
 INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LVector2),
 INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LVector2),
 python_repr, ostream &out, const string &class_name) {
 python_repr, ostream &out, const string &class_name) {
   out << class_name << "("
   out << class_name << "("
-      << MAYBE_ZERO(this->_v.v._0) << ", "
-      << MAYBE_ZERO(this->_v.v._1) << ")";
+      << MAYBE_ZERO(this->_v(0)) << ", "
+      << MAYBE_ZERO(this->_v(1)) << ")";
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -46,27 +46,27 @@ __getattr__, const string &attr_name) {
   }
   }
 
 
   if (attr_name.size() == 1) {
   if (attr_name.size() == 1) {
-    return PyFloat_FromDouble(this->_v.data[attr_name[0] - 'x']);
+    return PyFloat_FromDouble(this->_v(attr_name[0] - 'x'));
 
 
   } else if (attr_name.size() == 2) {
   } else if (attr_name.size() == 2) {
     FLOATNAME(LVector2) *vec = new FLOATNAME(LVector2);
     FLOATNAME(LVector2) *vec = new FLOATNAME(LVector2);
-    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
+    vec->_v(0) = this->_v(attr_name[0] - 'x');
+    vec->_v(1) = this->_v(attr_name[1] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector2), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector2), true, false);
 
 
   } else if (attr_name.size() == 3) {
   } else if (attr_name.size() == 3) {
     FLOATNAME(LVector3) *vec = new FLOATNAME(LVector3);
     FLOATNAME(LVector3) *vec = new FLOATNAME(LVector3);
-    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
-    vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
+    vec->_v(0) = this->_v(attr_name[0] - 'x');
+    vec->_v(1) = this->_v(attr_name[1] - 'x');
+    vec->_v(2) = this->_v(attr_name[2] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector3), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector3), true, false);
 
 
   } else if (attr_name.size() == 4) {
   } else if (attr_name.size() == 4) {
     FLOATNAME(LVector4) *vec = new FLOATNAME(LVector4);
     FLOATNAME(LVector4) *vec = new FLOATNAME(LVector4);
-    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
-    vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
-    vec->_v.v._3 = this->_v.data[attr_name[3] - 'x'];
+    vec->_v(0) = this->_v(attr_name[0] - 'x');
+    vec->_v(1) = this->_v(attr_name[1] - 'x');
+    vec->_v(2) = this->_v(attr_name[2] - 'x');
+    vec->_v(3) = this->_v(attr_name[3] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector4), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector4), true, false);
   }
   }
 
 

+ 1 - 1
panda/src/linmath/lvector2_src.I

@@ -195,7 +195,7 @@ project(const FLOATNAME(LVecBase2) &onto) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVector2)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVector2)::
 signed_angle_rad(const FLOATNAME(LVector2) &other) const {
 signed_angle_rad(const FLOATNAME(LVector2) &other) const {
-  return catan2((_v.v._0*other._v.v._1)-(_v.v._1*other._v.v._0), dot(other));
+  return catan2((_v(0)*other._v(1))-(_v(1)*other._v(0)), dot(other));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 1 - 1
panda/src/linmath/lvector2_src.h

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

+ 13 - 13
panda/src/linmath/lvector3_ext_src.I

@@ -27,9 +27,9 @@ IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector4);
 INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LVector3),
 INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LVector3),
 python_repr, ostream &out, const string &class_name) {
 python_repr, ostream &out, const string &class_name) {
   out << class_name << "("
   out << class_name << "("
-      << MAYBE_ZERO(this->_v.v._0) << ", "
-      << MAYBE_ZERO(this->_v.v._1) << ", "
-      << MAYBE_ZERO(this->_v.v._2) << ")";
+      << MAYBE_ZERO(this->_v(0)) << ", "
+      << MAYBE_ZERO(this->_v(1)) << ", "
+      << MAYBE_ZERO(this->_v(2)) << ")";
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -47,27 +47,27 @@ __getattr__, const string &attr_name) {
   }
   }
 
 
   if (attr_name.size() == 1) {
   if (attr_name.size() == 1) {
-    return PyFloat_FromDouble(this->_v.data[attr_name[0] - 'x']);
+    return PyFloat_FromDouble(this->_v(attr_name[0] - 'x'));
 
 
   } else if (attr_name.size() == 2) {
   } else if (attr_name.size() == 2) {
     FLOATNAME(LVector2) *vec = new FLOATNAME(LVector2);
     FLOATNAME(LVector2) *vec = new FLOATNAME(LVector2);
-    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
+    vec->_v(0) = this->_v(attr_name[0] - 'x');
+    vec->_v(1) = this->_v(attr_name[1] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector2), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector2), true, false);
 
 
   } else if (attr_name.size() == 3) {
   } else if (attr_name.size() == 3) {
     FLOATNAME(LVector3) *vec = new FLOATNAME(LVector3);
     FLOATNAME(LVector3) *vec = new FLOATNAME(LVector3);
-    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
-    vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
+    vec->_v(0) = this->_v(attr_name[0] - 'x');
+    vec->_v(1) = this->_v(attr_name[1] - 'x');
+    vec->_v(2) = this->_v(attr_name[2] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector3), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector3), true, false);
 
 
   } else if (attr_name.size() == 4) {
   } else if (attr_name.size() == 4) {
     FLOATNAME(LVector4) *vec = new FLOATNAME(LVector4);
     FLOATNAME(LVector4) *vec = new FLOATNAME(LVector4);
-    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
-    vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
-    vec->_v.v._3 = this->_v.data[attr_name[3] - 'x'];
+    vec->_v(0) = this->_v(attr_name[0] - 'x');
+    vec->_v(1) = this->_v(attr_name[1] - 'x');
+    vec->_v(2) = this->_v(attr_name[2] - 'x');
+    vec->_v(3) = this->_v(attr_name[3] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector4), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector4), true, false);
   }
   }
 
 

+ 4 - 4
panda/src/linmath/lvector3_src.I

@@ -123,7 +123,7 @@ unit_z() {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVector2) FLOATNAME(LVector3)::
 INLINE_LINMATH FLOATNAME(LVector2) FLOATNAME(LVector3)::
 get_xy() const {
 get_xy() const {
-  return FLOATNAME(LVector2)(_v.v._0, _v.v._1);
+  return FLOATNAME(LVector2)(_v(0), _v(1));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -134,7 +134,7 @@ get_xy() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVector2) FLOATNAME(LVector3)::
 INLINE_LINMATH FLOATNAME(LVector2) FLOATNAME(LVector3)::
 get_xz() const {
 get_xz() const {
-  return FLOATNAME(LVector2)(_v.v._0, _v.v._2);
+  return FLOATNAME(LVector2)(_v(0), _v(2));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -145,7 +145,7 @@ get_xz() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATNAME(LVector2) FLOATNAME(LVector3)::
 INLINE_LINMATH FLOATNAME(LVector2) FLOATNAME(LVector3)::
 get_yz() const {
 get_yz() const {
-  return FLOATNAME(LVector2)(_v.v._1, _v.v._2);
+  return FLOATNAME(LVector2)(_v(1), _v(2));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -297,7 +297,7 @@ signed_angle_deg(const FLOATNAME(LVector3) &other,
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVector3)::
 INLINE_LINMATH FLOATTYPE FLOATNAME(LVector3)::
 relative_angle_rad(const FLOATNAME(LVector3) &other) const {
 relative_angle_rad(const FLOATNAME(LVector3) &other) const {
-  return atan2((_v.v._0*other._v.v._1)-(_v.v._1*other._v.v._0), dot(other));
+  return atan2((_v(0)*other._v(1))-(_v(1)*other._v(0)), dot(other));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 1 - 1
panda/src/linmath/lvector3_src.h

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

+ 15 - 15
panda/src/linmath/lvector4_ext_src.I

@@ -27,10 +27,10 @@ IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector4);
 INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LVector4),
 INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LVector4),
 python_repr, ostream &out, const string &class_name) {
 python_repr, ostream &out, const string &class_name) {
   out << class_name << "("
   out << class_name << "("
-      << MAYBE_ZERO(this->_v.v._0) << ", "
-      << MAYBE_ZERO(this->_v.v._1) << ", "
-      << MAYBE_ZERO(this->_v.v._2) << ", "
-      << MAYBE_ZERO(this->_v.v._3) << ")";
+      << MAYBE_ZERO(this->_v(0)) << ", "
+      << MAYBE_ZERO(this->_v(1)) << ", "
+      << MAYBE_ZERO(this->_v(2)) << ", "
+      << MAYBE_ZERO(this->_v(3)) << ")";
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -49,30 +49,30 @@ __getattr__, const string &attr_name) {
 
 
   if (attr_name.size() == 1) {
   if (attr_name.size() == 1) {
     if (attr_name[0] == 'w') {
     if (attr_name[0] == 'w') {
-      return PyFloat_FromDouble(this->_v.data[3]);
+      return PyFloat_FromDouble(this->_v(3));
     } else {
     } else {
-      return PyFloat_FromDouble(this->_v.data[attr_name[0] - 'x']);
+      return PyFloat_FromDouble(this->_v(attr_name[0] - 'x'));
     }
     }
 
 
   } else if (attr_name.size() == 2) {
   } else if (attr_name.size() == 2) {
     FLOATNAME(LVector2) *vec = new FLOATNAME(LVector2);
     FLOATNAME(LVector2) *vec = new FLOATNAME(LVector2);
-    vec->_v.v._0 = this->_v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
+    vec->_v(0) = this->_v((attr_name[0] == 'w') ? 3 : attr_name[0] - 'x');
+    vec->_v(1) = this->_v((attr_name[1] == 'w') ? 3 : attr_name[1] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector2), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector2), true, false);
 
 
   } else if (attr_name.size() == 3) {
   } else if (attr_name.size() == 3) {
     FLOATNAME(LVector3) *vec = new FLOATNAME(LVector3);
     FLOATNAME(LVector3) *vec = new FLOATNAME(LVector3);
-    vec->_v.v._0 = this->_v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
-    vec->_v.v._2 = this->_v.data[(attr_name[2] == 'w') ? 3 : attr_name[2] - 'x'];
+    vec->_v(0) = this->_v((attr_name[0] == 'w') ? 3 : attr_name[0] - 'x');
+    vec->_v(1) = this->_v((attr_name[1] == 'w') ? 3 : attr_name[1] - 'x');
+    vec->_v(2) = this->_v((attr_name[2] == 'w') ? 3 : attr_name[2] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector3), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector3), true, false);
 
 
   } else if (attr_name.size() == 4) {
   } else if (attr_name.size() == 4) {
     FLOATNAME(LVector4) *vec = new FLOATNAME(LVector4);
     FLOATNAME(LVector4) *vec = new FLOATNAME(LVector4);
-    vec->_v.v._0 = this->_v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
-    vec->_v.v._1 = this->_v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
-    vec->_v.v._2 = this->_v.data[(attr_name[2] == 'w') ? 3 : attr_name[2] - 'x'];
-    vec->_v.v._3 = this->_v.data[(attr_name[3] == 'w') ? 3 : attr_name[3] - 'x'];
+    vec->_v(0) = this->_v((attr_name[0] == 'w') ? 3 : attr_name[0] - 'x');
+    vec->_v(1) = this->_v((attr_name[1] == 'w') ? 3 : attr_name[1] - 'x');
+    vec->_v(2) = this->_v((attr_name[2] == 'w') ? 3 : attr_name[2] - 'x');
+    vec->_v(3) = this->_v((attr_name[3] == 'w') ? 3 : attr_name[3] - 'x');
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector4), true, false);
     return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector4), true, false);
   }
   }
 
 

+ 1 - 1
panda/src/linmath/lvector4_src.h

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

+ 121 - 111
panda/src/linmath/test_math.cxx

@@ -30,127 +30,137 @@ void test() {
 int main(int argc, char *argv[]) {
 int main(int argc, char *argv[]) {
   test();
   test();
 
 
-  /*
-
-  LOrientationf orientation; // = LQuaternionf::ident_quat();
-  orientation.set(LMatrix4f::rotate_mat(-45.0f, LVector3f(0, 0, 1)));
-  LRotationf rotation(LMatrix4f::rotate_mat(45.0f, LVector3f(0, 0, 1)));
-
-  nout << "Orientation: " << orientation << endl;
-  nout << "Rotation: " << rotation << endl;
-
-  LQuaternionf composition = orientation * rotation;
-
-  nout << "Composition (o * r): " << composition << endl;
-  composition.normalize();
-  nout << "Composition (after normalize): " << composition << endl;
-
-  LPoint3f p(1, 0, 0);
-  LMatrix4f m = LMatrix4f::ident_mat();
-
-  composition.extract_to_matrix(m);
-  cout << "Rotation => Matrix: " << m << endl;
-  cout << "Point: " << p << endl;
-  cout << "Matrix * Point: " << m * p << endl;
-  */
-
-  /*
-  LMatrix4d x = LMatrix4d::ident_mat();
-  LMatrix4d y = LMatrix4d::rotate_mat(90.0, LVector3d::up());
-  LMatrix4d a = LMatrix4d::translate_mat(10.0, 10.0, 0.0f);
-
-  nout << "x is " << x << "\ny is " << y << "\n"
-       << "x * y is " << x * y << "\n"
-       << "y * x is " << y * x << "\n"
-       << "invert(x) is " << invert(x) << "\n"
-       << "invert(y) is " << invert(y) << "\n"
-       << "y * a is " << y * a << "\n"
-       << "invert(y * a) is " << invert(y * a) << "\n"
-       << "invert(invert(y * a)) is " << invert(invert(y * a)) << "\n"
-       << "(y * a) * invert(y * a) is " << (y * a) * invert(y * a) << "\n"
-       << "a * y is " << a * y << "\n"
-       << "invert(a * y) is " << invert(a * y) << "\n"
-       << "invert(invert(a * y)) is " << invert(invert(a * y)) << "\n";
-
-  nout << "a is " << a << "\n"
-       << "a * y is " << a * y << "\n"
-       << "y * a is " << y * a << "\n";
-
-  LVector3d r = LVector3d::right();
-  nout << "r is " << r << "\n"
-       << "r * x is " << r * x << "\n"
-       << "r * y is " << r * y << "\n"
-       << "r * invert(y) is " << r * invert(y) << "\n"
-       << "r * a is " << r * a << "\n";
-
-  LPoint3d p(0.0f, 1.0f, 1.0f);
-  nout << "p is " << p << "\n"
-       << "p * x is " << p * x << "\n"
-       << "p * y is " << p * y << "\n"
-       << "p * invert(y) is " << p * invert(y) << "\n"
-       << "p * a is " << p * a << "\n";
-
-  LVecBase4d q(0.0f, 1.0f, 1.0f, 1.0f);
-  nout << "q is " << q << "\n"
-       << "q * x is " << q * x << "\n"
-       << "q * y is " << q * y << "\n"
-       << "q * invert(y) is " << q * invert(y) << "\n"
-       << "q * a is " << q * a << "\n";
-
-  LNormald v1(0,0,1), v2(1,1,1);
-  LVertexd p1(1,0,1), p2(1,2,3);
-  LColorf c1(1,1,1,1), c2(0,0,0,0);
-
-  p2 = p2 - v1;
-
-  nout << "v1 = " << v1
-       << "\nv2 = " << v2
-       << "\np1 = " << p1
-       << "\np2 = " << p2
-       << "\nc1 = " << c1
-       << "\n(c1 == c2) = " << (c1 == c2)
-       << "\n";
-
   {
   {
-    LVecBase3f hpr(0.0f, 0.0f, 0.0f);
-    LVecBase3f scale(1.0f, 1.0f, 1.0f);
+    LOrientationf orientation(LMatrix4f::rotate_mat(-45.0f, LVector3f(0, 0, 1)));
+    LRotationf rotation(LMatrix4f::rotate_mat(45.0f, LVector3f(0, 0, 1)));
 
 
-    if (argc > 3) {
-      hpr.set(patof(argv[1]), patof(argv[2]), patof(argv[3]));
-    }
-    if (argc > 6) {
-      scale.set(patof(argv[4]), patof(argv[5]), patof(argv[6]));
-    }
+    nout << "Orientation: " << orientation << endl;
+    nout << "Rotation: " << rotation << endl;
 
 
-    cerr << "< hpr = " << hpr << " scale = " << scale << "\n";
-    LMatrix3f mat;
-    compose_matrix(mat, scale, hpr);
+    LQuaternionf composition = orientation * rotation;
+
+    nout << "Composition (o * r): " << composition << endl;
+    composition.normalize();
+    nout << "Composition (after normalize): " << composition << endl;
+
+    LPoint3f p(1, 0, 0);
+    LMatrix4f m = LMatrix4f::ident_mat();
+
+    composition.extract_to_matrix(m);
+    cout << "Rotation => Matrix: " << m << endl;
+    cout << "Point: " << p << endl;
+    cout << "Point * Matrix: " << p * m << endl;
 
 
-    if (decompose_matrix(mat, scale, hpr)) {
-      nout << "> hpr = " << hpr << " scale = " << scale << "\n";
-    } else {
-      nout << "Cannot decompose\n";
-    }
   }
   }
-  */
-
-  /*
-  for (int p = -90; p < 90; p += 10) {
-    for (int x = -10; x < 10; x += 5) {
-      LVecBase3f hpr(0, p, 0);
-      LVecBase3f xyz(x, x, x);
-      LVecBase3f scale(1, 1, 1);
-      nout << "\n< hpr = " << hpr << " xyz = " << xyz << "\n";
-      LMatrix4f mat;
-      compose_matrix(mat, scale, hpr, xyz);
-      if (decompose_matrix(mat, scale, hpr, xyz)) {
-        nout << "> hpr = " << hpr << " xyz = " << xyz << "\n";
+  {
+
+    LMatrix4d x = LMatrix4d::ident_mat();
+    LMatrix4d y = LMatrix4d::rotate_mat(90.0, LVector3d::up());
+    LMatrix4d a = LMatrix4d::translate_mat(10.0, 10.0, 0.0f);
+
+    nout << "x is " << x << "\ny is " << y << "\n"
+         << "x * y is " << x * y << "\n"
+         << "y * x is " << y * x << "\n"
+         << "invert(x) is " << invert(x) << "\n"
+         << "invert(y) is " << invert(y) << "\n"
+         << "y * a is " << y * a << "\n"
+         << "invert(y * a) is " << invert(y * a) << "\n"
+         << "invert(invert(y * a)) is " << invert(invert(y * a)) << "\n"
+         << "(y * a) * invert(y * a) is " << (y * a) * invert(y * a) << "\n"
+         << "a * y is " << a * y << "\n"
+         << "invert(a * y) is " << invert(a * y) << "\n"
+         << "invert(invert(a * y)) is " << invert(invert(a * y)) << "\n";
+
+    nout << "a is " << a << "\n"
+         << "a * y is " << a * y << "\n"
+         << "y * a is " << y * a << "\n";
+
+    LVector3d r = LVector3d::right();
+    nout << "r is " << r << "\n"
+         << "r * x is " << r * x << "\n"
+         << "r * y is " << r * y << "\n"
+         << "r * invert(y) is " << r * invert(y) << "\n"
+         << "r * a is " << r * a << "\n";
+
+    LPoint3d p(0.0f, 1.0f, 1.0f);
+    nout << "p is " << p << "\n"
+         << "p * x is " << p * x << "\n"
+         << "p * y is " << p * y << "\n"
+         << "p * invert(y) is " << p * invert(y) << "\n"
+         << "p * a is " << p * a << "\n";
+
+    LVecBase4d q(0.0f, 1.0f, 1.0f, 1.0f);
+    nout << "q is " << q << "\n"
+         << "q * x is " << q * x << "\n"
+         << "q * y is " << q * y << "\n"
+         << "q * invert(y) is " << q * invert(y) << "\n"
+         << "q * a is " << q * a << "\n";
+
+    LNormald v1(0,0,1), v2(1,1,1);
+    LVertexd p1(1,0,1), p2(1,2,3);
+    LColorf c1(1,1,1,1), c2(0,0,0,0);
+
+    p2 = p2 - v1;
+
+    nout << "v1 = " << v1
+         << "\nv2 = " << v2
+         << "\np1 = " << p1
+         << "\np2 = " << p2
+         << "\nc1 = " << c1
+         << "\n(c1 == c2) = " << (c1 == c2)
+         << "\n";
+
+    {
+      LVecBase3f hpr(0.0f, 0.0f, 0.0f);
+      LVecBase3f scale(1.0f, 1.0f, 1.0f);
+
+      if (argc > 3) {
+        hpr.set(patof(argv[1]), patof(argv[2]), patof(argv[3]));
+      }
+      if (argc > 6) {
+        scale.set(patof(argv[4]), patof(argv[5]), patof(argv[6]));
+      }
+
+      cerr << "< hpr = " << hpr << " scale = " << scale << "\n";
+      LMatrix3f mat;
+      compose_matrix(mat, scale, hpr);
+
+      if (decompose_matrix(mat, scale, hpr)) {
+        nout << "> hpr = " << hpr << " scale = " << scale << "\n";
       } else {
       } else {
         nout << "Cannot decompose\n";
         nout << "Cannot decompose\n";
       }
       }
     }
     }
+
+  }
+  {
+    for (int p = -90; p < 90; p += 10) {
+      for (int x = -10; x < 10; x += 5) {
+        LVecBase3f hpr(0, p, 0);
+        LVecBase3f xyz(x, x, x);
+        LVecBase3f scale(1, 1, 1);
+        nout << "\n< hpr = " << hpr << " xyz = " << xyz << "\n";
+        LMatrix4f mat;
+        compose_matrix(mat, scale, hpr, xyz);
+        if (decompose_matrix(mat, scale, hpr, xyz)) {
+          nout << "> hpr = " << hpr << " xyz = " << xyz << "\n";
+        } else {
+          nout << "Cannot decompose\n";
+        }
+      }
+    }
+  }
+
+  {
+    LMatrix3f mat(1, 2, 3,
+                  4, 5, 6,
+                  7, 8, 9);
+    nout << "Matrix:";
+    for (LMatrix3f::iterator mi = mat.begin(); mi != mat.end(); ++mi) {
+      nout << " " << *mi;
+    }
+    nout << "\n";
   }
   }
-  */
 
 
   return(0);
   return(0);
 }
 }

+ 13 - 25
panda/src/mathutil/boundingSphere.cxx

@@ -19,8 +19,8 @@
 #include "boundingPlane.h"
 #include "boundingPlane.h"
 #include "config_mathutil.h"
 #include "config_mathutil.h"
 #include "dcast.h"
 #include "dcast.h"
+#include "cmath.h"
 
 
-#include <math.h>
 #include <algorithm>
 #include <algorithm>
 
 
 TypeHandle BoundingSphere::_type_handle;
 TypeHandle BoundingSphere::_type_handle;
@@ -104,30 +104,18 @@ xform(const LMatrix4 &mat) {
     // First, determine the longest axis of the matrix, in case it
     // First, determine the longest axis of the matrix, in case it
     // contains a non-uniform scale.
     // contains a non-uniform scale.
 
 
-/*
-    LVector3 x,y,z;
-        mat.get_row3(x,0);
-        mat.get_row3(y,1);
-        mat.get_row3(z,2);
+    LVecBase3 x, y, z;
+    mat.get_row3(x, 0);
+    mat.get_row3(y, 1);
+    mat.get_row3(z, 2);
 
 
     PN_stdfloat xd = dot(x, x);
     PN_stdfloat xd = dot(x, x);
     PN_stdfloat yd = dot(y, y);
     PN_stdfloat yd = dot(y, y);
     PN_stdfloat zd = dot(z, z);
     PN_stdfloat zd = dot(z, z);
-*/
-    PN_stdfloat xd,yd,zd,scale;
-
-#define ROW_DOTTED(mat,ROWNUM)                        \
-            (mat._m.m._##ROWNUM##0*mat._m.m._##ROWNUM##0 +    \
-             mat._m.m._##ROWNUM##1*mat._m.m._##ROWNUM##1 +    \
-             mat._m.m._##ROWNUM##2*mat._m.m._##ROWNUM##2)
-    
-    xd = ROW_DOTTED(mat,0);
-    yd = ROW_DOTTED(mat,1);
-    zd = ROW_DOTTED(mat,2);
-
-    scale = max(xd,yd);
-    scale = max(scale,zd);
-    scale = sqrtf(scale);
+
+    PN_stdfloat scale = max(xd, yd);
+    scale = max(scale, zd);
+    scale = csqrt(scale);
 
 
     // Transform the radius
     // Transform the radius
     _radius *= scale;
     _radius *= scale;
@@ -215,7 +203,7 @@ extend_by_point(const LPoint3 &point) {
     LVector3 v = point - _center;
     LVector3 v = point - _center;
     PN_stdfloat dist2 = dot(v, v);
     PN_stdfloat dist2 = dot(v, v);
     if (dist2 > _radius * _radius) {
     if (dist2 > _radius * _radius) {
-      _radius = sqrtf(dist2);
+      _radius = csqrt(dist2);
     }
     }
   }
   }
   return true;
   return true;
@@ -380,7 +368,7 @@ around_points(const LPoint3 *first, const LPoint3 *last) {
       max_dist2 = max(max_dist2, dist2);
       max_dist2 = max(max_dist2, dist2);
     }
     }
 
 
-    _radius = sqrtf(max_dist2);
+    _radius = csqrt(max_dist2);
   }
   }
 
 
 #ifndef NDEBUG
 #ifndef NDEBUG
@@ -593,8 +581,8 @@ contains_lineseg(const LPoint3 &a, const LPoint3 &b) const {
       return IF_no_intersection;
       return IF_no_intersection;
     }
     }
 
 
-        PN_stdfloat reciprocal_2A = 1.0f/(2.0f*A);
-    PN_stdfloat sqrt_radical = sqrtf(radical);
+    PN_stdfloat reciprocal_2A = 1.0f/(2.0f*A);
+    PN_stdfloat sqrt_radical = csqrt(radical);
 
 
     t1 = ( -B - sqrt_radical ) * reciprocal_2A;
     t1 = ( -B - sqrt_radical ) * reciprocal_2A;
     t2 = ( -B + sqrt_radical ) * reciprocal_2A;
     t2 = ( -B + sqrt_radical ) * reciprocal_2A;

+ 2 - 2
panda/src/mathutil/perlinNoise2.cxx

@@ -25,8 +25,8 @@ noise(const LVecBase2d &value) const {
   // Convert the vector to our local coordinate space.
   // Convert the vector to our local coordinate space.
   LVecBase2d vec = _input_xform.xform_point(value);
   LVecBase2d vec = _input_xform.xform_point(value);
 
 
-  double x = vec._v.v._0;
-  double y = vec._v.v._1;
+  double x = vec[0];
+  double y = vec[1];
 
 
   // Find unit square that contains point.
   // Find unit square that contains point.
   double xf = cfloor(x);
   double xf = cfloor(x);

+ 3 - 3
panda/src/mathutil/perlinNoise3.cxx

@@ -25,9 +25,9 @@ noise(const LVecBase3d &value) const {
   // Convert the vector to our local coordinate space.
   // Convert the vector to our local coordinate space.
   LVecBase3d vec = _input_xform.xform_point(value);
   LVecBase3d vec = _input_xform.xform_point(value);
 
 
-  double x = vec._v.v._0;
-  double y = vec._v.v._1;
-  double z = vec._v.v._2;
+  double x = vec[0];
+  double y = vec[1];
+  double z = vec[2];
 
 
   // Find unit cube that contains point.
   // Find unit cube that contains point.
   double xf = cfloor(x);
   double xf = cfloor(x);

+ 18 - 18
panda/src/mathutil/plane_src.I

@@ -21,10 +21,10 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_MATHUTIL FLOATNAME(LPlane)::
 INLINE_MATHUTIL FLOATNAME(LPlane)::
 FLOATNAME(LPlane)() {
 FLOATNAME(LPlane)() {
-  _v.v._0 = 0.0f;
-  _v.v._1 = 0.0f;
-  _v.v._2 = 1.0f;
-  _v.v._3 = 0.0f;
+  _v(0) = 0.0f;
+  _v(1) = 0.0f;
+  _v(2) = 1.0f;
+  _v(3) = 0.0f;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -53,10 +53,10 @@ FLOATNAME(LPlane)(const FLOATNAME(LPoint3) &a, const FLOATNAME(LPoint3) &b,
   FLOATNAME(LVector3) v = c - a;
   FLOATNAME(LVector3) v = c - a;
   FLOATNAME(LVector3) p = ::normalize(cross(u, v));
   FLOATNAME(LVector3) p = ::normalize(cross(u, v));
 
 
-  _v.v._0 = p[0];
-  _v.v._1 = p[1];
-  _v.v._2 = p[2];
-  _v.v._3 = -::dot(p, a);
+  _v(0) = p[0];
+  _v(1) = p[1];
+  _v(2) = p[2];
+  _v(3) = -::dot(p, a);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -70,10 +70,10 @@ FLOATNAME(LPlane)(const FLOATNAME(LVector3) &normal,
                  const FLOATNAME(LPoint3) &point) {
                  const FLOATNAME(LPoint3) &point) {
   FLOATNAME(LVector3) p = ::normalize(normal);
   FLOATNAME(LVector3) p = ::normalize(normal);
 
 
-  _v.v._0 = p[0];
-  _v.v._1 = p[1];
-  _v.v._2 = p[2];
-  _v.v._3 = -::dot(p, point);
+  _v(0) = p[0];
+  _v(1) = p[1];
+  _v(2) = p[2];
+  _v(3) = -::dot(p, point);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -138,7 +138,7 @@ xform(const FLOATNAME(LMatrix4) &mat) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_MATHUTIL FLOATNAME(LPlane) FLOATNAME(LPlane)::
 INLINE_MATHUTIL FLOATNAME(LPlane) FLOATNAME(LPlane)::
 operator - () const {
 operator - () const {
-  return FLOATNAME(LPlane)(-_v.v._0, -_v.v._1, -_v.v._2, -_v.v._3);
+  return FLOATNAME(LPlane)(-_v(0), -_v(1), -_v(2), -_v(3));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -148,7 +148,7 @@ operator - () const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_MATHUTIL FLOATNAME(LVector3) FLOATNAME(LPlane)::
 INLINE_MATHUTIL FLOATNAME(LVector3) FLOATNAME(LPlane)::
 get_normal() const {
 get_normal() const {
-  return FLOATNAME(LVector3)(_v.v._0, _v.v._1, _v.v._2);
+  return FLOATNAME(LVector3)(_v(0), _v(1), _v(2));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -163,7 +163,7 @@ get_normal() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_MATHUTIL FLOATTYPE FLOATNAME(LPlane)::
 INLINE_MATHUTIL FLOATTYPE FLOATNAME(LPlane)::
 dist_to_plane(const FLOATNAME(LPoint3) &point) const {
 dist_to_plane(const FLOATNAME(LPoint3) &point) const {
-  return (_v.v._0 * point[0] + _v.v._1 * point[1] + _v.v._2 * point[2] + _v.v._3);
+  return (_v(0) * point[0] + _v(1) * point[1] + _v(2) * point[2] + _v(3));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -185,9 +185,9 @@ project(const FLOATNAME(LPoint3) &point) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE_MATHUTIL void FLOATNAME(LPlane)::
 INLINE_MATHUTIL void FLOATNAME(LPlane)::
 flip() {
 flip() {
-  _v.v._0 = -_v.v._0;
-  _v.v._1 = -_v.v._1;
-  _v.v._2 = -_v.v._2;
+  _v(0) = -_v(0);
+  _v(1) = -_v(1);
+  _v(2) = -_v(2);
   // We don't flip D, that would make the plane flip over the origin.
   // We don't flip D, that would make the plane flip over the origin.
 }
 }
 
 

+ 20 - 20
panda/src/mathutil/plane_src.cxx

@@ -22,15 +22,15 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 FLOATNAME(LMatrix4) FLOATNAME(LPlane)::
 FLOATNAME(LMatrix4) FLOATNAME(LPlane)::
 get_reflection_mat() const {
 get_reflection_mat() const {
-  FLOATTYPE aa = _v.v._0 * _v.v._0; 
-  FLOATTYPE ab = _v.v._0 * _v.v._1;
-  FLOATTYPE ac = _v.v._0 * _v.v._2;
-  FLOATTYPE ad = _v.v._0 * _v.v._3;
-  FLOATTYPE bb = _v.v._1 * _v.v._1;
-  FLOATTYPE bc = _v.v._1 * _v.v._2;
-  FLOATTYPE bd = _v.v._1 * _v.v._3;
-  FLOATTYPE cc = _v.v._2 * _v.v._2;
-  FLOATTYPE cd = _v.v._2 * _v.v._3;
+  FLOATTYPE aa = _v(0) * _v(0); 
+  FLOATTYPE ab = _v(0) * _v(1);
+  FLOATTYPE ac = _v(0) * _v(2);
+  FLOATTYPE ad = _v(0) * _v(3);
+  FLOATTYPE bb = _v(1) * _v(1);
+  FLOATTYPE bc = _v(1) * _v(2);
+  FLOATTYPE bd = _v(1) * _v(3);
+  FLOATTYPE cc = _v(2) * _v(2);
+  FLOATTYPE cd = _v(2) * _v(3);
 
 
   return FLOATNAME(LMatrix4)(  1-2*aa,  -2*ab,  -2*ac,     0,
   return FLOATNAME(LMatrix4)(  1-2*aa,  -2*ab,  -2*ac,     0,
                               -2*ab, 1-2*bb,  -2*bc,     0,
                               -2*ab, 1-2*bb,  -2*bc,     0,
@@ -48,15 +48,15 @@ get_reflection_mat() const {
 FLOATNAME(LPoint3) FLOATNAME(LPlane)::
 FLOATNAME(LPoint3) FLOATNAME(LPlane)::
 get_point() const {
 get_point() const {
   // Choose the denominator based on the largest axis in the normal.
   // Choose the denominator based on the largest axis in the normal.
-  if (cabs(_v.v._0) >= cabs(_v.v._1) && cabs(_v.v._0) >= cabs(_v.v._2)) {
-    nassertr(_v.v._0 != 0.0f, FLOATNAME(LPoint3)(0.0f, 0.0f, 0.0f));
-    return FLOATNAME(LPoint3)(-_v.v._3 / _v.v._0, 0.0f, 0.0f);
-  } else if (cabs(_v.v._1) >= cabs(_v.v._2)) {
-    nassertr(_v.v._1 != 0.0f, FLOATNAME(LPoint3)(0.0f, 0.0f, 0.0f));
-    return FLOATNAME(LPoint3)(0.0f, -_v.v._3 / _v.v._1, 0.0f);
+  if (cabs(_v(0)) >= cabs(_v(1)) && cabs(_v(0)) >= cabs(_v(2))) {
+    nassertr(_v(0) != 0.0f, FLOATNAME(LPoint3)(0.0f, 0.0f, 0.0f));
+    return FLOATNAME(LPoint3)(-_v(3) / _v(0), 0.0f, 0.0f);
+  } else if (cabs(_v(1)) >= cabs(_v(2))) {
+    nassertr(_v(1) != 0.0f, FLOATNAME(LPoint3)(0.0f, 0.0f, 0.0f));
+    return FLOATNAME(LPoint3)(0.0f, -_v(3) / _v(1), 0.0f);
   } else {
   } else {
-    nassertr(_v.v._2 != 0.0f, FLOATNAME(LPoint3)(0.0f, 0.0f, 0.0f));
-    return FLOATNAME(LPoint3)(0.0f, 0.0f, -_v.v._3 / _v.v._2);
+    nassertr(_v(2) != 0.0f, FLOATNAME(LPoint3)(0.0f, 0.0f, 0.0f));
+    return FLOATNAME(LPoint3)(0.0f, 0.0f, -_v(3) / _v(2));
   }
   }
 }
 }
 
 
@@ -92,8 +92,8 @@ intersects_plane(FLOATNAME(LPoint3) &from,
   FLOATTYPE n1n2 = ::dot(n1, n2);
   FLOATTYPE n1n2 = ::dot(n1, n2);
  
  
   FLOATTYPE determinant_inv = 1.0f / (n1n1 * n2n2 - n1n2 * n1n2);
   FLOATTYPE determinant_inv = 1.0f / (n1n1 * n2n2 - n1n2 * n1n2);
-  FLOATTYPE c1 = (other._v.v._3 * n1n2 - _v.v._3 * n2n2) * determinant_inv;
-  FLOATTYPE c2 = (_v.v._3 * n1n2 - other._v.v._3 * n1n1) * determinant_inv;
+  FLOATTYPE c1 = (other._v(3) * n1n2 - _v(3) * n2n2) * determinant_inv;
+  FLOATTYPE c2 = (_v(3) * n1n2 - other._v(3) * n1n1) * determinant_inv;
   from = n1 * c1 + n2 * c2;
   from = n1 * c1 + n2 * c2;
 
 
   return true;
   return true;
@@ -129,7 +129,7 @@ intersects_parabola(FLOATTYPE &t1, FLOATTYPE &t2,
   FLOATNAME(LVector3) normal = get_normal();
   FLOATNAME(LVector3) normal = get_normal();
   FLOATTYPE a = normal.dot(parabola.get_a());
   FLOATTYPE a = normal.dot(parabola.get_a());
   FLOATTYPE b = normal.dot(parabola.get_b());
   FLOATTYPE b = normal.dot(parabola.get_b());
-  FLOATTYPE c = normal.dot(parabola.get_c()) + _v.v._3;
+  FLOATTYPE c = normal.dot(parabola.get_c()) + _v(3);
 
 
   if (IS_NEARLY_ZERO(a)) {
   if (IS_NEARLY_ZERO(a)) {
     // It's not quadratic.  The equation is actually:
     // It's not quadratic.  The equation is actually:

+ 4 - 7
panda/src/ode/odeBody.I

@@ -129,19 +129,16 @@ set_position(const LVecBase3f &pos) {
 
 
 INLINE void OdeBody::
 INLINE void OdeBody::
 set_rotation(const LMatrix3f r) {
 set_rotation(const LMatrix3f r) {
-  dMatrix3 mat3 = {r._m.data[0], r._m.data[1], r._m.data[2], 0,
-                   r._m.data[3], r._m.data[4], r._m.data[5], 0,
-                   r._m.data[6], r._m.data[7], r._m.data[8], 0};
+  dMatrix3 mat3 = { r(0, 0), r(0, 1), r(0, 2), 0,
+                    r(1, 0), r(1, 1), r(1, 2), 0,
+                    r(2, 0), r(2, 1), r(2, 2), 0 };
   
   
   dBodySetRotation(_id, mat3);
   dBodySetRotation(_id, mat3);
 }
 }
 
 
 INLINE void OdeBody::
 INLINE void OdeBody::
 set_quaternion(const LQuaternionf q) {
 set_quaternion(const LQuaternionf q) {
-  dQuaternion quat = {q._v.data[0], 
-                      q._v.data[1], 
-                      q._v.data[2], 
-                      q._v.data[3]};
+  dQuaternion quat = { q[0], q[1], q[2], q[3] };
   dBodySetQuaternion(_id, quat);
   dBodySetQuaternion(_id, quat);
 }
 }
 
 

+ 9 - 9
panda/src/ode/odeGeom.I

@@ -69,9 +69,9 @@ set_position(const LVecBase3f &pos) {
 
 
 INLINE void OdeGeom::
 INLINE void OdeGeom::
 set_rotation(const LMatrix3f &r) {
 set_rotation(const LMatrix3f &r) {
-  dMatrix3 rot = { r._m.data[0], r._m.data[1], r._m.data[2], 0,
-                   r._m.data[3], r._m.data[4], r._m.data[5], 0,
-                   r._m.data[6], r._m.data[7], r._m.data[8], 0 };
+  dMatrix3 rot = { r(0, 0), r(0, 1), r(0, 2), 0,
+                   r(1, 0), r(1, 1), r(1, 2), 0,
+                   r(2, 0), r(2, 1), r(2, 2), 0 };
   dGeomSetRotation(_id, rot);
   dGeomSetRotation(_id, rot);
 }
 }
 
 
@@ -167,9 +167,9 @@ set_offset_position(const LVecBase3f &pos) {
 
 
 INLINE void OdeGeom::
 INLINE void OdeGeom::
 set_offset_rotation(const LMatrix3f &r) {
 set_offset_rotation(const LMatrix3f &r) {
-  dMatrix3 rot = { r._m.data[0], r._m.data[1], r._m.data[2], 0,
-                   r._m.data[3], r._m.data[4], r._m.data[5], 0,
-                   r._m.data[6], r._m.data[7], r._m.data[8], 0 };
+  dMatrix3 rot = { r(0, 0), r(0, 1), r(0, 2), 0,
+                   r(1, 0), r(1, 1), r(1, 2), 0,
+                   r(2, 0), r(2, 1), r(2, 2), 0 };
   dGeomSetOffsetRotation(_id, rot);
   dGeomSetOffsetRotation(_id, rot);
 }
 }
 
 
@@ -191,9 +191,9 @@ set_offset_world_position(const LVecBase3f &pos) {
 
 
 INLINE void OdeGeom::
 INLINE void OdeGeom::
 set_offset_world_rotation(const LMatrix3f &r) {
 set_offset_world_rotation(const LMatrix3f &r) {
-  dMatrix3 rot = { r._m.data[0], r._m.data[1], r._m.data[2], 0,
-                   r._m.data[3], r._m.data[4], r._m.data[5], 0,
-                   r._m.data[6], r._m.data[7], r._m.data[8], 0 };
+  dMatrix3 rot = { r(0, 0), r(0, 1), r(0, 2), 0,
+                   r(1, 0), r(1, 1), r(1, 2), 0,
+                   r(2, 0), r(2, 1), r(2, 2), 0 };
   dGeomSetOffsetWorldRotation(_id, rot);
   dGeomSetOffsetWorldRotation(_id, rot);
 }
 }
 
 

+ 5 - 5
panda/src/ode/odeMass.I

@@ -39,8 +39,8 @@ set_parameters(dReal themass,
                const LMatrix3f &i) {
                const LMatrix3f &i) {
   set_parameters(themass,
   set_parameters(themass,
                  center[0], center[1], center[2], 
                  center[0], center[1], center[2], 
-                 i._m.data[0], i._m.data[4], i._m.data[8],
-                 i._m.data[1], i._m.data[2], i._m.data[5]);
+                 i(0, 0), i(1, 1), i(2, 2),
+                 i(0, 1), i(0, 2), i(1, 2));
 }
 }
 
 
 INLINE void OdeMass::
 INLINE void OdeMass::
@@ -130,9 +130,9 @@ translate(const LVecBase3f &pos) {
 
 
 INLINE void OdeMass::
 INLINE void OdeMass::
 rotate(const LMatrix3f &r) {
 rotate(const LMatrix3f &r) {
-  dMatrix3 rot = { r._m.data[0], r._m.data[1], r._m.data[2], 0,
-                   r._m.data[3], r._m.data[4], r._m.data[5], 0,
-                   r._m.data[6], r._m.data[7], r._m.data[8], 0 };
+  dMatrix3 rot = { r(0, 0), r(0, 1), r(0, 2), 0,
+                   r(1, 0), r(1, 1), r(1, 2), 0,
+                   r(2, 0), r(2, 1), r(2, 2), 0 };
   _mass.rotate(rot);
   _mass.rotate(rot);
 }
 }
 
 

Some files were not shown because too many files changed in this diff