double_transform.patch: Modifications to existing files double_transform_files.tar.bz2: New files to be added
I am still working on testing OSG::DoubleTransform on the trunk, but so far, things are looking good.
-Patrick Aron Bierbaum wrote:
On Fri, Feb 20, 2009 at 4:57 PM, Patrick Hartling <[email protected]> wrote:I have taken care of merging all the changes on the fcptr_stable_jun07 branch except for two. I suspect that these should be reviewed before merging to ensure that everyone can come to a consensus about how these additions should be implemented. The first change is r1280: http://opensg.vrsource.org/trac/changeset/1280 Add a DoubleTransform core that allows for double precision transformations. Allow to select a double precision matrix stack in the render traversal at compile time. Does anyone have feedback on the implementation or questions about the use of this new node core? We have been using it very successfully since it was added back in June 2008. AFAIK, we have not been using the single-precision transform core since then.I would like to point out that this code is only used when enabled at compile time, and also it allows you to mix and match double and single precision matrices. We actually only use double precision matrices for a large navigation matrix, and any transforms that position geometry on a global scale. This follows the concept of a floating origin, where the idea is that we want to OpenSG matrix stack to be stored in double precision so that by the time that we push a matrix onto the OpenGL stack it is close to 0.0, where floating point has more precision. -AronThe second change is r1655: http://opensg.vrsource.org/trac/changeset/1655 Add intersection code for double transforms. This one clearly depends on r1280 and fills in a missing piece of that revision. Earlier today, I merged the performance monitor foreground that Allen has been working on since the fcptr_stable_jun07 branch was created. I did it all as one revision (http://opensg.vrsource.org/trac/changeset/1763) and asked Allen to verify that everything made it to the trunk intact. Allen has already indicated that there are pieces of this that could be cleaned up, and he may want to elaborate on that here. Otherwise, going through a code review of this addition could be beneficial in general. -Patrick -- Patrick L. Hartling Senior Software Engineer, Priority 5 http://www.priority5.com/ The information transmitted in this communication is intended only for the person or entity to which it is addressed and contains proprietary material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please destroy any copies, contact the sender and delete the material from any computer. ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ Opensg-core mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opensg-core
-- Patrick L. Hartling Senior Software Engineer, Priority 5 http://www.priority5.com/ The information transmitted in this communication is intended only for the person or entity to which it is addressed and contains proprietary material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please destroy any copies, contact the sender and delete the material from any computer.
Index: Source/System/Action/RenderAction/OSGRenderPartition.cpp
===================================================================
--- Source/System/Action/RenderAction/OSGRenderPartition.cpp (revision 1762)
+++ Source/System/Action/RenderAction/OSGRenderPartition.cpp (working copy)
@@ -745,14 +745,32 @@
Pnt3f objPos;
actNode->getVolume().getCenter(objPos);
-
+
+#ifndef OSG_ENABLE_DOUBLE_MATRIX_STACK
_currMatrix.second.mult(objPos, objPos);
+#else
+ Pnt3d temp(objPos[0], objPos[1], objPos[2]);
+ _currMatrix.second.mult(temp);
+#endif
pNewElem->setNode (&*actNode );
pNewElem->setFunctor ( func );
+ pNewElem->setState ( pState );
+
+#ifndef OSG_ENABLE_DOUBLE_MATRIX_STACK
pNewElem->setMatrixStore (_currMatrix);
- pNewElem->setState ( pState );
pNewElem->setScalar ( objPos[2] );
+#else
+ // Now that we have accumulated all transformations we can convert back
+ // to a floating point matrix.
+ Matrix4f tempMat;
+ tempMat.convertFrom(_currMatrix.second);
+ std::pair<UInt32, Matrix> temp_ms(_currMatrix.first, tempMat);
+
+ pNewElem->setMatrixStore (temp_ms );
+ pNewElem->setScalar ( temp[2] );
+#endif
+
pNewElem->setLightState (_uiLightState);
if(_sStateOverrides.top()->empty() == false &&
@@ -792,8 +810,12 @@
}
RenderTreeNode *pNewElem = _pNodePool->create();
-
+
+#ifndef OSG_ENABLE_DOUBLE_MATRIX_STACK
Pnt3f objPos;
+#else
+ Pnt3d objPos;
+#endif
//_oDrawEnv.getRTAction()->getActNode()->getVolume().getCenter(objPos);
@@ -805,7 +827,11 @@
objVol.getBounds(min,max);
+#ifndef OSG_ENABLE_DOUBLE_MATRIX_STACK
Pnt3r p[8];
+#else
+ Pnt3d p[8];
+#endif
p[0].setValues(min[0],min[1],min[2]);
p[1].setValues(max[0],min[1],min[2]);
p[2].setValues(min[0],max[1],min[2]);
@@ -834,10 +860,21 @@
pNewElem->setNode (&*actNode );
pNewElem->setFunctor ( func );
- pNewElem->setMatrixStore(_currMatrix );
pNewElem->setState ( pState );
pNewElem->setLightState (_uiLightState);
+#ifndef OSG_ENABLE_DOUBLE_MATRIX_STACK
+ pNewElem->setMatrixStore(_currMatrix );
+#else
+ // Now that we have accumulated all transformations we can convert back
+ // to a floating point matrix.
+ Matrix4f tempMat;
+ tempMat.convertFrom(_currMatrix.second);
+ std::pair<UInt32, Matrix> temp_ms(_currMatrix.first, tempMat);
+
+ pNewElem->setMatrixStore(temp_ms );
+#endif
+
// Normalize scalar to 0..1 for bucket sorting
pNewElem->setScalar ( (-objPos[2] - getNear()) /
(getFar() - getNear()) );
@@ -882,7 +919,19 @@
pNewElem->setNode (&* actNode );
pNewElem->setFunctor ( func );
+
+#ifndef OSG_ENABLE_DOUBLE_MATRIX_STACK
pNewElem->setMatrixStore( _currMatrix);
+#else
+ // Now that we have accumulated all transformations we can convert back
+ // to a floating point matrix.
+ Matrix4f tempMat;
+ tempMat.convertFrom(_currMatrix.second);
+ std::pair<UInt32, Matrix> temp_ms(_currMatrix.first, tempMat);
+
+ pNewElem->setMatrixStore( temp_ms );
+#endif
+
pNewElem->setLightState (_uiLightState);
if(_sStateOverrides.top()->empty() == false &&
@@ -1270,16 +1319,6 @@
_accMatrix.mult(_currMatrix.second);
}
-void RenderPartition::pushMatrix(const Matrix &matrix)
-{
- _vMatrixStack.push_back(_currMatrix);
-
- _currMatrix.first = ++_uiMatrixId;
- _currMatrix.second.mult(matrix);
-
- updateTopMatrix();
-}
-
void RenderPartition::popMatrix(void )
{
_currMatrix.first = _vMatrixStack.back().first;
Index: Source/System/Action/RenderAction/OSGRenderPartition.inl
===================================================================
--- Source/System/Action/RenderAction/OSGRenderPartition.inl (revision 1762)
+++ Source/System/Action/RenderAction/OSGRenderPartition.inl (working copy)
@@ -233,11 +233,28 @@
{
_oDrawEnv.setupViewing(matrix);
+#ifndef OSG_ENABLE_DOUBLE_MATRIX_STACK
_currMatrix.second = matrix;
+#else
+ Matrix4d temp;
+ temp.convertFrom(matrix);
+ _currMatrix.second = temp;
+#endif
updateTopMatrix();
}
+template<class MatrixType> inline
+void RenderPartition::pushMatrix(const MatrixType &matrix)
+{
+ _vMatrixStack.push_back(_currMatrix);
+
+ _currMatrix.first = ++_uiMatrixId;
+ _currMatrix.second.mult(matrix);
+
+ updateTopMatrix();
+}
+
inline
const Matrix4f &RenderPartition::getViewing(void)
{
Index: Source/System/Action/RenderAction/OSGRenderAction.cpp
===================================================================
--- Source/System/Action/RenderAction/OSGRenderAction.cpp (revision 1762)
+++ Source/System/Action/RenderAction/OSGRenderAction.cpp (working copy)
@@ -858,11 +858,6 @@
_pActivePartition->releaseLightIndex();
}
-void RenderAction::pushMatrix(const Matrix &matrix)
-{
- _pActivePartition->pushMatrix(matrix);
-}
-
void RenderAction::popMatrix(void)
{
_pActivePartition->popMatrix();
Index: Source/System/Action/RenderAction/OSGRenderAction.inl
===================================================================
--- Source/System/Action/RenderAction/OSGRenderAction.inl (revision 1762)
+++ Source/System/Action/RenderAction/OSGRenderAction.inl (working copy)
@@ -85,6 +85,13 @@
/*---------------------------- properties ---------------------------------*/
+template<class MatrixType> inline
+void RenderAction::pushMatrix(const MatrixType &matrix)
+{
+ _pActivePartition->pushMatrix(matrix);
+}
+
+
inline
void RenderAction::setKeyGen(UInt32 uiKeyGen)
{
Index: Source/System/Action/RenderAction/OSGRenderPartition.h
===================================================================
--- Source/System/Action/RenderAction/OSGRenderPartition.h (revision 1762)
+++ Source/System/Action/RenderAction/OSGRenderPartition.h (working copy)
@@ -110,6 +110,9 @@
to compare actual matrix elements.
*/
typedef std::pair<UInt32, Matrix> MatrixStore;
+#ifdef OSG_ENABLE_DOUBLE_MATRIX_STACK
+ typedef std::pair<UInt32, Matrix4d> DoubleMatrixStore;
+#endif
/*! DrawFunctor is the signature for the methods that are called
from within the draw tree
@@ -142,7 +145,11 @@
typedef std::stack<StateOverride *> OverrideStack;
/*! MatrixStack keeps track of matrices during traversal */
+#ifdef OSG_ENABLE_DOUBLE_MATRIX_STACK
+ typedef std::vector<DoubleMatrixStore> MatrixStack;
+#else
typedef std::vector<MatrixStore> MatrixStack;
+#endif
typedef std::vector<RenderPartition *> GroupStore;
@@ -260,8 +267,9 @@
void disable(void);
/*------------------------- assignment ----------------------------------*/
-
- void pushMatrix(const Matrix &matrix);
+
+ template<class MatrixType>
+ void pushMatrix(const MatrixType &matrix);
void popMatrix ( void );
const Matrix &topMatrix ( void );
@@ -385,7 +393,11 @@
UInt32 _uiMatrixId;
+#ifdef OSG_ENABLE_DOUBLE_MATRIX_STACK
+ DoubleMatrixStore _currMatrix;
+#else
MatrixStore _currMatrix;
+#endif
Matrix _accMatrix;
MatrixStack _vMatrixStack;
Index: Source/System/Action/RenderAction/OSGRenderAction.h
===================================================================
--- Source/System/Action/RenderAction/OSGRenderAction.h (revision 1762)
+++ Source/System/Action/RenderAction/OSGRenderAction.h (working copy)
@@ -168,7 +168,8 @@
/*--------------------------- matrix ------------------------------------*/
- void pushMatrix (const Matrix &matrix);
+ template<class MatrixType>
+ void pushMatrix (const MatrixType &matrix);
void popMatrix ( void );
const Matrix &topMatrix ( void );
Property changes on: Source/Base/Field/Wrapper/OSGMatrix4dFields.h
___________________________________________________________________
Added: svn:mergeinfo
Index: Source/Base/Base/OSGMatrix.inl
===================================================================
--- Source/Base/Base/OSGMatrix.inl (revision 1762)
+++ Source/Base/Base/OSGMatrix.inl (working copy)
@@ -433,10 +433,11 @@
/*-------------------------------------------------------------------------*/
/* Helper */
-template<class ValueTypeT> inline
-ValueTypeT TransformationMatrix<ValueTypeT>::rowMulCol4(
- const TransformationMatrix &gRowMat, UInt32 iRow,
- const TransformationMatrix &gColMat, UInt32 iColumn) const
+template<class ValueTypeT>
+template<class ValueTypeR, class ValueTypeS> inline
+ ValueTypeT TransformationMatrix<ValueTypeT>::rowMulCol4(
+ const TransformationMatrix<ValueTypeR> &gRowMat, UInt32 iRow,
+ const TransformationMatrix<ValueTypeS> &gColMat, UInt32 iColumn) const
{
return
gRowMat[0][iRow] * gColMat[iColumn][0] +
@@ -2506,8 +2507,9 @@
return true;
}
-template<class ValueTypeT> inline
-void TransformationMatrix<ValueTypeT>::mult(const TransformationMatrix &matrix)
+template<class ValueTypeT>
+template<class ValueTypeR> inline
+void TransformationMatrix<ValueTypeT>::mult(const TransformationMatrix<ValueTypeR> &matrix)
{
ValueTypeT rTmpMat[4][4];
@@ -2552,9 +2554,10 @@
_matrix[3][3] = rTmpMat[3][3];
}
-template<class ValueTypeT> inline
+template<class ValueTypeT>
+template<class ValueTypeR> inline
void TransformationMatrix<ValueTypeT>::multLeft(
- const TransformationMatrix &matrix)
+ const TransformationMatrix<ValueTypeR> &matrix)
{
ValueTypeT rTmpMat[4][4];
Index: Source/Base/Base/OSGMatrix.h
===================================================================
--- Source/Base/Base/OSGMatrix.h (revision 1762)
+++ Source/Base/Base/OSGMatrix.h (working copy)
@@ -342,8 +342,10 @@
bool transpose ( void );
bool transposeFrom(const TransformationMatrix &matrix);
- void mult (const TransformationMatrix &matrix);
- void multLeft (const TransformationMatrix &matrix);
+ template<class ValueTypeR>
+ void mult (const TransformationMatrix<ValueTypeR>& mat);
+ template<class ValueTypeR>
+ void multLeft (const TransformationMatrix<ValueTypeR>& mat);
void add (const TransformationMatrix &matrix);
void scale ( ValueTypeT s );
@@ -404,10 +406,11 @@
/*! \name Internal Math */
/*! \{ */
- ValueTypeT rowMulCol4(const TransformationMatrix &gRowMat,
- UInt32 iRow,
- const TransformationMatrix &gColMat,
- UInt32 iColumn) const;
+ template<class ValueTypeR, class ValueTypeS>
+ ValueTypeT rowMulCol4(const TransformationMatrix<ValueTypeR> &gRowMat,
+ UInt32 iRow,
+ const TransformationMatrix<ValueTypeS> &gColMat,
+ UInt32 iColumn) const;
ValueTypeT det2_calc (const ValueTypeT a1,
const ValueTypeT a2,
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt (revision 1762)
+++ CMakeLists.txt (working copy)
@@ -52,6 +52,7 @@
OSG_OPTION(OSG_ENABLE_TESTCONTAINER "" OFF)
OSG_OPTION(OSG_ENABLE_VALGRIND_CHECKS "" OFF)
OSG_OPTION(OSG_ENABLE_MEMORY_DEBUGGING "" OFF)
+OSG_OPTION(OSG_ENABLE_DOUBLE_MATRIX_STACK "" OFF)
IF(WIN32)
OPTION(OSG_ENABLE_WIN_LOCALSTORAGE "" ON)
double_transform_files.tar.bz2
Description: BZip2 compressed data
------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H
_______________________________________________ Opensg-core mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opensg-core
