summaryrefslogtreecommitdiff
path: root/graphics/aqsis/patches/patch-al
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/aqsis/patches/patch-al')
-rw-r--r--graphics/aqsis/patches/patch-al204
1 files changed, 204 insertions, 0 deletions
diff --git a/graphics/aqsis/patches/patch-al b/graphics/aqsis/patches/patch-al
new file mode 100644
index 00000000000..ea831d8e9e5
--- /dev/null
+++ b/graphics/aqsis/patches/patch-al
@@ -0,0 +1,204 @@
+$NetBSD: patch-al,v 1.1 2006/05/11 18:55:31 joerg Exp $
+
+--- render/subdivision.h.orig 2002-04-25 09:08:54.000000000 +0000
++++ render/subdivision.h
+@@ -181,46 +181,7 @@ class CqWVert : public CqPoolable<CqWVer
+ * \param pSurf Pointer to the CqWSurf on which we are working.
+ */
+ template <class T>
+- T GetSmoothedScalar( T& t, T( CqSubdivider::*F ) ( CqPolygonPoints*, TqInt ), CqSubdivider* pSurf, CqPolygonPoints* pPoints )
+- {
+- // NOTE: Checks should have been made prior to this call to ensure it is neither
+- // a boundary point or a crease/corner point with sharp edges.
+-
+- // Q the average of the face points surrounding the vertex.
+- T Q = T( 0.0f );
+- std::vector<CqWEdge*>::iterator iE;
+- CqWFace* pF;
+- TqInt cE = 0;
+-
+- for ( iE = m_apEdges.begin(); iE != m_apEdges.end(); iE++ )
+- {
+- if ( ( *iE ) ->pvHead() == this ) pF = ( *iE ) ->pfLeft();
+- else pF = ( *iE ) ->pfRight();
+- if ( pF )
+- {
+- Q += ( pSurf->*F ) ( pPoints, pF->pvSubdivide() ->iVertex() );
+- cE++;
+- }
+- }
+- Q *= ( 1.0f / ( cE * cE ) );
+-
+- // R average of the midpoints of the edges that share the old vertex.
+- T R = T( 0.0f );
+- cE = 0;
+- for ( iE = m_apEdges.begin(); iE != m_apEdges.end(); iE++ )
+- {
+- if ( ( *iE ) ->IsValid() )
+- {
+- if ( ( *iE ) ->pvHead() == this ) R += ( pSurf->*F ) ( pPoints, ( *iE ) ->pvTail() ->iVertex() );
+- else R += ( pSurf->*F ) ( pPoints, ( *iE ) ->pvHead() ->iVertex() );
+- cE++;
+- }
+- }
+- R *= ( 1.0f / ( cE * cE ) );
+-
+- T S = ( pSurf->*F ) ( pPoints, iVertex() ) * ( ( cE - 2.0f ) / ( TqFloat ) cE );
+- return ( S + R + Q );
+- }
++ T GetSmoothedScalar( T& t, T( CqSubdivider::*F ) ( CqPolygonPoints*, TqInt ), CqSubdivider* pSurf, CqPolygonPoints* pPoints );
+
+ /** Templatised function to perform the subdivision arithmetic on a paramter type.
+ * \param t Temp of the template type to overcome the VC++ problem with template functions.
+@@ -228,35 +189,7 @@ class CqWVert : public CqPoolable<CqWVer
+ * \param pSurf Pointer to the CqWSurf on which we are working.
+ */
+ template <class T>
+- T GetCreaseScalar( T& t, T( CqSubdivider::*F ) ( CqPolygonPoints*, TqInt ), CqSubdivider* pSurf, CqPolygonPoints* pPoints )
+- {
+- T P = T( 0.0f );
+- std::vector<CqWEdge*>::iterator iE;
+- TqFloat S = 0.0;
+- TqInt cS = 0;
+-
+- for ( iE = m_apEdges.begin(); iE != m_apEdges.end(); iE++ )
+- {
+- if ( ( *iE ) ->Sharpness() > 0 && ( *iE ) ->IsValid() )
+- {
+- if ( ( *iE ) ->pvHead() == this ) P += ( pSurf->*F ) ( pPoints, ( *iE ) ->pvTail() ->iVertex() );
+- else P += ( pSurf->*F ) ( pPoints, ( *iE ) ->pvHead() ->iVertex() );
+- S += ( *iE ) ->Sharpness();
+- cS++;
+- }
+- }
+- P += ( pSurf->*F ) ( pPoints, iVertex() ) * 6.0f;
+- P /= 8.0f; // Crease point
+-
+- S /= ( TqFloat ) cS;
+- if ( cS == 2 && S > 0.0f && S < 1.0f )
+- {
+- T P2;
+- P2 = GetSmoothedScalar( P2, F, pSurf, pPoints );
+- P = ( P2 * ( 1.0f - S ) ) + ( P * S ); // Linear blend for variable crease.
+- }
+- return ( P );
+- }
++ T GetCreaseScalar( T& t, T( CqSubdivider::*F ) ( CqPolygonPoints*, TqInt ), CqSubdivider* pSurf, CqPolygonPoints* pPoints );
+
+ /** Templatised function to perform the subdivision arithmetic on a paramter type.
+ * \param t Temp of the template type to overcome the VC++ problem with template functions.
+@@ -264,19 +197,7 @@ class CqWVert : public CqPoolable<CqWVer
+ * \param pSurf Pointer to the CqWSurf on which we are working.
+ */
+ template <class T>
+- T GetBoundaryScalar( T& t, T( CqSubdivider::*F ) ( CqPolygonPoints*, TqInt ), CqSubdivider* pSurf, CqPolygonPoints* pPoints )
+- {
+- T P = T( 0.0f );
+- std::vector<CqWEdge*>::iterator iE;
+- for ( iE = m_apEdges.begin(); iE != m_apEdges.end(); iE++ )
+- if ( ( *iE ) ->IsBoundary() )
+- if ( ( *iE ) ->pvHead() == this ) P += ( pSurf->*F ) ( pPoints, ( *iE ) ->pvTail() ->iVertex() );
+- else P += ( pSurf->*F ) ( pPoints, ( *iE ) ->pvHead() ->iVertex() );
+-
+- P += ( pSurf->*F ) ( pPoints, iVertex() ) * 6.0f;
+- P /= 8.0f;
+- return ( P );
+- }
++ T GetBoundaryScalar( T& t, T( CqSubdivider::*F ) ( CqPolygonPoints*, TqInt ), CqSubdivider* pSurf, CqPolygonPoints* pPoints );
+
+ private:
+ TqInt m_iVertex; ///< Index of the vertex in the vertex list
+@@ -1168,6 +1089,93 @@ inline CqWFace* CqWReference::pfRight()
+ return ( m_pFace == m_pEdge->pfLeft() ? m_pEdge->pfRight() : m_pEdge->pfLeft() );
+ }
+
++template <class T> inline
++T CqWVert::GetSmoothedScalar( T& t, T( CqSubdivider::*F ) ( CqPolygonPoints*, TqInt ), CqSubdivider* pSurf, CqPolygonPoints* pPoints )
++{
++ // NOTE: Checks should have been made prior to this call to ensure it is neither
++ // a boundary point or a crease/corner point with sharp edges.
++
++ // Q the average of the face points surrounding the vertex.
++ T Q = T( 0.0f );
++ std::vector<CqWEdge*>::iterator iE;
++ CqWFace* pF;
++ TqInt cE = 0;
++
++ for ( iE = m_apEdges.begin(); iE != m_apEdges.end(); iE++ )
++ {
++ if ( ( *iE ) ->pvHead() == this ) pF = ( *iE ) ->pfLeft();
++ else pF = ( *iE ) ->pfRight();
++ if ( pF )
++ {
++ Q += ( pSurf->*F ) ( pPoints, pF->pvSubdivide() ->iVertex() );
++ cE++;
++ }
++ }
++ Q *= ( 1.0f / ( cE * cE ) );
++
++ // R average of the midpoints of the edges that share the old vertex.
++ T R = T( 0.0f );
++ cE = 0;
++ for ( iE = m_apEdges.begin(); iE != m_apEdges.end(); iE++ )
++ {
++ if ( ( *iE ) ->IsValid() )
++ {
++ if ( ( *iE ) ->pvHead() == this ) R += ( pSurf->*F ) ( pPoints, ( *iE ) ->pvTail() ->iVertex() );
++ else R += ( pSurf->*F ) ( pPoints, ( *iE ) ->pvHead() ->iVertex() );
++ cE++;
++ }
++ }
++ R *= ( 1.0f / ( cE * cE ) );
++
++ T S = ( pSurf->*F ) ( pPoints, iVertex() ) * ( ( cE - 2.0f ) / ( TqFloat ) cE );
++ return ( S + R + Q );
++}
++
++template <class T> inline
++T CqWVert::GetCreaseScalar( T& t, T( CqSubdivider::*F ) ( CqPolygonPoints*, TqInt ), CqSubdivider* pSurf, CqPolygonPoints* pPoints )
++{
++ T P = T( 0.0f );
++ std::vector<CqWEdge*>::iterator iE;
++ TqFloat S = 0.0;
++ TqInt cS = 0;
++
++ for ( iE = m_apEdges.begin(); iE != m_apEdges.end(); iE++ )
++ {
++ if ( ( *iE ) ->Sharpness() > 0 && ( *iE ) ->IsValid() )
++ {
++ if ( ( *iE ) ->pvHead() == this ) P += ( pSurf->*F ) ( pPoints, ( *iE ) ->pvTail() ->iVertex() );
++ else P += ( pSurf->*F ) ( pPoints, ( *iE ) ->pvHead() ->iVertex() );
++ S += ( *iE ) ->Sharpness();
++ cS++;
++ }
++ }
++ P += ( pSurf->*F ) ( pPoints, iVertex() ) * 6.0f;
++ P /= 8.0f; // Crease point
++
++ S /= ( TqFloat ) cS;
++ if ( cS == 2 && S > 0.0f && S < 1.0f )
++ {
++ T P2;
++ P2 = GetSmoothedScalar( P2, F, pSurf, pPoints );
++ P = ( P2 * ( 1.0f - S ) ) + ( P * S ); // Linear blend for variable crease.
++ }
++ return ( P );
++}
++
++template <class T> inline
++T CqWVert::GetBoundaryScalar( T& t, T( CqSubdivider::*F ) ( CqPolygonPoints*, TqInt ), CqSubdivider* pSurf, CqPolygonPoints* pPoints )
++{
++ T P = T( 0.0f );
++ std::vector<CqWEdge*>::iterator iE;
++ for ( iE = m_apEdges.begin(); iE != m_apEdges.end(); iE++ )
++ if ( ( *iE ) ->IsBoundary() )
++ if ( ( *iE ) ->pvHead() == this ) P += ( pSurf->*F ) ( pPoints, ( *iE ) ->pvTail() ->iVertex() );
++ else P += ( pSurf->*F ) ( pPoints, ( *iE ) ->pvHead() ->iVertex() );
++
++ P += ( pSurf->*F ) ( pPoints, iVertex() ) * 6.0f;
++ P /= 8.0f;
++ return ( P );
++}
+
+ //-----------------------------------------------------------------------
+