[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27309] branches/bge_eigen2: I got the scenegraph to compile with Eigen2 now.

Mitchell Stokes mogurijin at gmail.com
Sun Mar 7 10:13:17 CET 2010


Revision: 27309
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27309
Author:   moguri
Date:     2010-03-07 10:13:17 +0100 (Sun, 07 Mar 2010)

Log Message:
-----------
I got the scenegraph to compile with Eigen2 now. I also added BGE_Transform to KX_EigenTypes.h. KX_EigenMatrixAddons.h and KX_EigenTransformAddons.h are used to extend Eigen::Matrix and Eigen::Transform to give them some MoTo like functions, which will make porting easier. 

However, most of the functions I've added are stubbed out for the time being. These are marked with an XXX - Stub comment.

Also, SG_Spatial's GetWorldTransform() is commented out and needs to be fixed. This is marked with XXX - Eigen TODO.

Modified Paths:
--------------
    branches/bge_eigen2/source/gameengine/Expressions/KX_EigenTypes.h
    branches/bge_eigen2/source/gameengine/SceneGraph/CMakeLists.txt
    branches/bge_eigen2/source/gameengine/SceneGraph/SG_BBox.cpp
    branches/bge_eigen2/source/gameengine/SceneGraph/SG_BBox.h
    branches/bge_eigen2/source/gameengine/SceneGraph/SG_Spatial.cpp
    branches/bge_eigen2/source/gameengine/SceneGraph/SG_Spatial.h
    branches/bge_eigen2/source/gameengine/SceneGraph/SG_Tree.cpp
    branches/bge_eigen2/source/gameengine/SceneGraph/SG_Tree.h

Added Paths:
-----------
    branches/bge_eigen2/source/gameengine/Expressions/KX_EigenMatrixAddons.h
    branches/bge_eigen2/source/gameengine/Expressions/KX_EigenTransformAddons.h

Property Changed:
----------------
    branches/bge_eigen2/


Property changes on: branches/bge_eigen2
___________________________________________________________________
Name: svn:ignore
   - *.pdb
.*
TAGS
build
cscope.out
install
mingw
mingw-user-config.py
mingw-user-config_debug.py
msvc
msvc-user-config.py
obj
sgc.bat
sgd.bat
smc.bat
ssenv.bat
tags
user-config.py
user-def.mk

   + *.pdb
.*
TAGS
build
cscope.out
install
mingw
mingw-user-config.py
mingw-user-config_debug.py
msvc
msvc-user-config.py
obj
projectfiles_cmake
sgc.bat
sgd.bat
smc.bat
ssenv.bat
tags
user-config.py
user-def.mk


Added: branches/bge_eigen2/source/gameengine/Expressions/KX_EigenMatrixAddons.h
===================================================================
--- branches/bge_eigen2/source/gameengine/Expressions/KX_EigenMatrixAddons.h	                        (rev 0)
+++ branches/bge_eigen2/source/gameengine/Expressions/KX_EigenMatrixAddons.h	2010-03-07 09:13:17 UTC (rev 27309)
@@ -0,0 +1,23 @@
+inline void setValue(const _Scalar *m)
+{
+	// XXX - stub
+}
+
+inline void getValue(Scalar *m) const
+{
+	// XXX -stub
+}
+
+inline _Scalar length() const { return norm(); }
+
+inline _Scalar length2() const { return norm()*norm(); }
+
+inline _Scalar distance(Matrix<_Scalar, _Rows, 1> p) const { return Matrix<_Scalar, _Rows, 1>(p - *this).length(); }
+
+inline _Scalar distance2(Matrix<_Scalar, _Rows, 1> p) const { return Matrix<_Scalar, _Rows, 1>(p - *this).length2(); }
+
+inline int closestAxis() const
+{
+	// XXX - stub
+	return 0;
+}
\ No newline at end of file

Added: branches/bge_eigen2/source/gameengine/Expressions/KX_EigenTransformAddons.h
===================================================================
--- branches/bge_eigen2/source/gameengine/Expressions/KX_EigenTransformAddons.h	                        (rev 0)
+++ branches/bge_eigen2/source/gameengine/Expressions/KX_EigenTransformAddons.h	2010-03-07 09:13:17 UTC (rev 27309)
@@ -0,0 +1,5 @@
+inline Eigen::Matrix<float, 3, 1> operator()(const Eigen::Matrix<float, 3, 1>) const
+{
+	// XXX - stub
+	return Eigen::Matrix<float, 3, 1>(0, 0, 0);
+}
\ No newline at end of file

Modified: branches/bge_eigen2/source/gameengine/Expressions/KX_EigenTypes.h
===================================================================
--- branches/bge_eigen2/source/gameengine/Expressions/KX_EigenTypes.h	2010-03-07 05:04:22 UTC (rev 27308)
+++ branches/bge_eigen2/source/gameengine/Expressions/KX_EigenTypes.h	2010-03-07 09:13:17 UTC (rev 27309)
@@ -10,7 +10,14 @@
 #undef max
 #endif
 
+// Add some functions to Eigen::Transform
+#define EIGEN_TRANSFORM_PLUGIN "KX_EigenTransformAddons.h"
+
+// Add some functions to Eigen::Matrix
+#define EIGEN_MATRIX_PLUGIN "KX_EigenMatrixAddons.h"
+
 #include <Eigen/Core>
+#include <Eigen/Geometry>
 #include "KX_AlignedObjectArray.h"
 
 // C++ doesn't support templated typedefs, so we use a define instead
@@ -25,6 +32,8 @@
 typedef Eigen::Matrix<BGE_Scalar, 3, 3> BGE_Matrix3;
 typedef Eigen::Matrix<BGE_Scalar, 4, 4> BGE_Matrix4;
 
+typedef Eigen::Transform<BGE_Scalar, 3> BGE_Transform;
+
 // The following is borrowed from MoTo
 
 const BGE_Scalar  BGE_DEGS_PER_RAD(57.29577951308232286465);

Modified: branches/bge_eigen2/source/gameengine/SceneGraph/CMakeLists.txt
===================================================================
--- branches/bge_eigen2/source/gameengine/SceneGraph/CMakeLists.txt	2010-03-07 05:04:22 UTC (rev 27308)
+++ branches/bge_eigen2/source/gameengine/SceneGraph/CMakeLists.txt	2010-03-07 09:13:17 UTC (rev 27309)
@@ -29,6 +29,7 @@
 SET(INC
 	.
 	../../../intern/moto/include
+	../../../source/gameengine/Expressions
 	../../../extern/Eigen2
 )
 

Modified: branches/bge_eigen2/source/gameengine/SceneGraph/SG_BBox.cpp
===================================================================
--- branches/bge_eigen2/source/gameengine/SceneGraph/SG_BBox.cpp	2010-03-07 05:04:22 UTC (rev 27308)
+++ branches/bge_eigen2/source/gameengine/SceneGraph/SG_BBox.cpp	2010-03-07 09:13:17 UTC (rev 27309)
@@ -39,22 +39,22 @@
 {
 }
 
-SG_BBox::SG_BBox(const MT_Point3 &min, const MT_Point3 &max) :
+SG_BBox::SG_BBox(const BGE_Vector3 &min, const BGE_Vector3 &max) :
 	m_min(min),
 	m_max(max)
 {
 }
 
-SG_BBox::SG_BBox(const SG_BBox &other, const MT_Transform &world) :
+SG_BBox::SG_BBox(const SG_BBox &other, const BGE_Transform &world) :
 	m_min(world(other.m_min)),
 	m_max(world(other.m_max))
 {
-	*this += world(MT_Point3(m_min[0], m_min[1], m_max[2]));
-	*this += world(MT_Point3(m_min[0], m_max[1], m_min[2]));
-	*this += world(MT_Point3(m_min[0], m_max[1], m_max[2]));
-	*this += world(MT_Point3(m_max[0], m_min[1], m_min[2]));
-	*this += world(MT_Point3(m_max[0], m_min[1], m_max[2]));
-	*this += world(MT_Point3(m_max[0], m_max[1], m_min[2]));
+	*this += world(BGE_Vector3(m_min[0], m_min[1], m_max[2]));
+	*this += world(BGE_Vector3(m_min[0], m_max[1], m_min[2]));
+	*this += world(BGE_Vector3(m_min[0], m_max[1], m_max[2]));
+	*this += world(BGE_Vector3(m_max[0], m_min[1], m_min[2]));
+	*this += world(BGE_Vector3(m_max[0], m_min[1], m_max[2]));
+	*this += world(BGE_Vector3(m_max[0], m_max[1], m_min[2]));
 }
 
 SG_BBox::SG_BBox(const SG_BBox &other) :
@@ -67,7 +67,7 @@
 {
 }
 
-SG_BBox& SG_BBox::operator +=(const MT_Point3 &point)
+SG_BBox& SG_BBox::operator +=(const BGE_Vector3 &point)
 {
 	if (point[0] < m_min[0])
 		m_min[0] = point[0];
@@ -102,39 +102,39 @@
 	return ret;
 }
 
-MT_Scalar SG_BBox::volume() const
+BGE_Scalar SG_BBox::volume() const
 {
-	MT_Vector3 size = m_max - m_min;
+	BGE_Vector3 size = m_max - m_min;
 	return size[0]*size[1]*size[2];
 }
 #if 0
-void SG_BBox::translate(const MT_Vector3& dx)
+void SG_BBox::translate(const BGE_Vector3& dx)
 {
 	m_min += dx;
 	m_max += dx;
 }
 
-void SG_BBox::scale(const MT_Vector3& size, const MT_Point3& point)
+void SG_BBox::scale(const BGE_Vector3& size, const BGE_Vector3& point)
 {
-	MT_Vector3 center = (m_max - m_min)/2. + point;
+	BGE_Vector3 center = (m_max - m_min)/2. + point;
 	m_max = (m_max - center)*size;
 	m_min = (m_min - center)*size;
 }
 #endif
 
-SG_BBox SG_BBox::transform(const MT_Transform &world) const
+SG_BBox SG_BBox::transform(const BGE_Transform &world) const
 {
 	SG_BBox bbox(world(m_min), world(m_max));
-	bbox += world(MT_Point3(m_min[0], m_min[1], m_max[2]));
-	bbox += world(MT_Point3(m_min[0], m_max[1], m_min[2]));
-	bbox += world(MT_Point3(m_min[0], m_max[1], m_max[2]));
-	bbox += world(MT_Point3(m_max[0], m_min[1], m_min[2]));
-	bbox += world(MT_Point3(m_max[0], m_min[1], m_max[2]));
-	bbox += world(MT_Point3(m_max[0], m_max[1], m_min[2]));
+	bbox += world(BGE_Vector3(m_min[0], m_min[1], m_max[2]));
+	bbox += world(BGE_Vector3(m_min[0], m_max[1], m_min[2]));
+	bbox += world(BGE_Vector3(m_min[0], m_max[1], m_max[2]));
+	bbox += world(BGE_Vector3(m_max[0], m_min[1], m_min[2]));
+	bbox += world(BGE_Vector3(m_max[0], m_min[1], m_max[2]));
+	bbox += world(BGE_Vector3(m_max[0], m_max[1], m_min[2]));
 	return bbox;
 }
 
-bool SG_BBox::inside(const MT_Point3 &point) const
+bool SG_BBox::inside(const BGE_Vector3 &point) const
 {
 	return point[0] >= m_min[0] && point[0] <= m_max[0] &&
 	    point[1] >= m_min[1] && point[1] <= m_max[1] &&
@@ -163,43 +163,43 @@
 	return point1?(point2?INSIDE:INTERSECT):(point2?INTERSECT:OUTSIDE);
 }
 
-void SG_BBox::get(MT_Point3 *box, const MT_Transform &world) const
+void SG_BBox::get(BGE_Vector3 *box, const BGE_Transform &world) const
 {
 	*box++ = world(m_min);
-	*box++ = world(MT_Point3(m_min[0], m_min[1], m_max[2]));
-	*box++ = world(MT_Point3(m_min[0], m_max[1], m_min[2]));
-	*box++ = world(MT_Point3(m_min[0], m_max[1], m_max[2]));
-	*box++ = world(MT_Point3(m_max[0], m_min[1], m_min[2]));
-	*box++ = world(MT_Point3(m_max[0], m_min[1], m_max[2]));
-	*box++ = world(MT_Point3(m_max[0], m_max[1], m_min[2]));
+	*box++ = world(BGE_Vector3(m_min[0], m_min[1], m_max[2]));
+	*box++ = world(BGE_Vector3(m_min[0], m_max[1], m_min[2]));
+	*box++ = world(BGE_Vector3(m_min[0], m_max[1], m_max[2]));
+	*box++ = world(BGE_Vector3(m_max[0], m_min[1], m_min[2]));
+	*box++ = world(BGE_Vector3(m_max[0], m_min[1], m_max[2]));
+	*box++ = world(BGE_Vector3(m_max[0], m_max[1], m_min[2]));
 	*box++ = world(m_max);
 }
 
-void SG_BBox::getaa(MT_Point3 *box, const MT_Transform &world) const
+void SG_BBox::getaa(BGE_Vector3 *box, const BGE_Transform &world) const
 {
-	const MT_Point3 min(world(m_min)), max(world(m_max));
+	const BGE_Vector3 min(world(m_min)), max(world(m_max));
 	*box++ = min;
-	*box++ = MT_Point3(min[0], min[1], max[2]);
-	*box++ = MT_Point3(min[0], max[1], min[2]);
-	*box++ = MT_Point3(min[0], max[1], max[2]);
-	*box++ = MT_Point3(max[0], min[1], min[2]);
-	*box++ = MT_Point3(max[0], min[1], max[2]);
-	*box++ = MT_Point3(max[0], max[1], min[2]);
+	*box++ = BGE_Vector3(min[0], min[1], max[2]);
+	*box++ = BGE_Vector3(min[0], max[1], min[2]);
+	*box++ = BGE_Vector3(min[0], max[1], max[2]);
+	*box++ = BGE_Vector3(max[0], min[1], min[2]);
+	*box++ = BGE_Vector3(max[0], min[1], max[2]);
+	*box++ = BGE_Vector3(max[0], max[1], min[2]);
 	*box++ = max;
 }
 
-void SG_BBox::getmm(MT_Point3 *box, const MT_Transform &world) const
+void SG_BBox::getmm(BGE_Vector3 *box, const BGE_Transform &world) const
 {
-	const MT_Point3 min(world(m_min)), max(world(m_max));
+	const BGE_Vector3 min(world(m_min)), max(world(m_max));
 	*box++ = min;
 	*box++ = max;
 }
 
 void SG_BBox::split(SG_BBox &left, SG_BBox &right) const
 {
-	MT_Scalar sizex = m_max[0] - m_min[0];
-	MT_Scalar sizey = m_max[1] - m_min[1];
-	MT_Scalar sizez = m_max[2] - m_min[2];
+	BGE_Scalar sizex = m_max[0] - m_min[0];
+	BGE_Scalar sizey = m_max[1] - m_min[1];
+	BGE_Scalar sizez = m_max[2] - m_min[2];
 	if (sizex < sizey)
 	{
 		if (sizey > sizez)

Modified: branches/bge_eigen2/source/gameengine/SceneGraph/SG_BBox.h
===================================================================
--- branches/bge_eigen2/source/gameengine/SceneGraph/SG_BBox.h	2010-03-07 05:04:22 UTC (rev 27308)
+++ branches/bge_eigen2/source/gameengine/SceneGraph/SG_BBox.h	2010-03-07 09:13:17 UTC (rev 27309)
@@ -31,10 +31,7 @@
 #ifndef __SG_BBOX_H__
 #define __SG_BBOX_H__
  
-#include "MT_Scalar.h"
-#include "MT_Point3.h"
-#include "MT_Vector3.h"
-#include "MT_Transform.h"
+#include "KX_EigenTypes.h"
 
 #include <vector> 
 
@@ -51,20 +48,20 @@
  */
 class SG_BBox
 {
-	MT_Point3 m_min;
-	MT_Point3 m_max;
+	BGE_Vector3 m_min;
+	BGE_Vector3 m_max;
 public:
 	typedef enum { INSIDE, INTERSECT, OUTSIDE } intersect;
 	SG_BBox();
-	SG_BBox(const MT_Point3 &min, const MT_Point3 &max);
-	SG_BBox(const SG_BBox &other, const MT_Transform &world);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list