Wojciech Lewandowski wrote:
Oops I have forgot to attach the release zip. Its attached here.

Cheers,
Wojtek

Hi,
Here are diffs to make view dependent shadows compile with gcc 4.3. I don't think any of the required changes are due to bugs in gcc, rather differing or stricter interpretations of the standard:
strings.h and stdlib.h need to be included in a couple of places
local classes can't be template arguments
set::erase doesn't return a value
itoa isn't standard on Linux
nondependent name lookup doesn't look in dependent classes.

Thanks,
Tim


Hi Again,

One more release. I have added methods to modify base and shadow texture sampler & TexCoord index. I have also modified shadow example to allow changing CastsShadowTraversalMask & ReceiveShadowTraversalMasks. Both this options are useful when trying to load external models which have nonstd masks set.

I must admit I was not able to completely get rid of problems with omnidirectional lights. Directional lights are working great but omnidirectional lights continue to break shadows in certain light/camera angle combinations. I have found a workaround that fixes some of these issues when scene is larger than frustum but it brings problems in opposite case where frustum fully contains the scene.

I am leaving for one week. I will continue my work on this after return.

Cheers,
Wojtek

Hi Guys,

Attached is a new version of ViewDepdendentShadow code. I have also included
modified osgShadow (osgShadowViewDependent) example with new (-4 option)
island scene and options to select one of LiSPSM variants.

recommended use is

osgshadow -4 --lispsm <--DrawBounds| --CullBounds | --ViewBounds>
<--debugHUD> --minFarDist 500  --minLightMargin 10

I am aware I have neglected few things. I will continue tweaking the code.
Probably will send few more versions in incoming weeks. But I think its
pretty mature right now and really would like to get some feedback from
Robert and others. I will probably also try to add some comments: licensing info (OSGPL), thanks for my company, and maybe some doxygen comments if time
allows.

Cheers,
Wojtek Lewandowski
diff --git a/IslandScene.cpp b/IslandScene.cpp
index a44fc34..e7c5592 100644
--- a/IslandScene.cpp
+++ b/IslandScene.cpp
@@ -10,6 +10,8 @@
 #include <osg/AlphaFunc>
 #include <osg/CullFace>
 
+#include <stdlib.h>
+
 static unsigned int heightTexture[] = {
  0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00010101, 
0x02000000, 0x00020809,
  0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000000, 
0x00000000, 0x00000000,
diff --git a/ViewDependentShadow/ConvexPolyhedron.cpp 
b/ViewDependentShadow/ConvexPolyhedron.cpp
index f7b7881..ad64d96 100644
--- a/ViewDependentShadow/ConvexPolyhedron.cpp
+++ b/ViewDependentShadow/ConvexPolyhedron.cpp
@@ -282,6 +282,22 @@ void ConvexPolyhedron::transform(const osg::Matrix& 
matrix, const osg::Matrix& i
 
     checkCoherency( true, "ConvexPolyhedron::transform" );
 }
+
+namespace
+{
+typedef std::vector< double > Distances;
+typedef std::vector< osg::Vec4d > Points;
+
+// Auxilliary params contined per face
+struct FaceDistances
+{
+    ConvexPolyhedron::Faces::iterator itr;
+    Points points;
+    Distances distances;
+    int below, above, on;
+};
+}
+
 
////////////////////////////////////////////////////////////////////////////////
 void ConvexPolyhedron::transformClip(const osg::Matrix& matrix, const 
osg::Matrix& inverse)
 {
@@ -289,15 +305,8 @@ void ConvexPolyhedron::transformClip(const osg::Matrix& 
matrix, const osg::Matri
 
     if( _faces.empty() ) return;
 
-    typedef std::vector< double > Distances;
-    typedef std::vector< osg::Vec4d > Points;
-
     ConvexPolyhedron cp( *this );
 
-    // Auxilliary params contined per face
-    struct FaceDistances
-    { Faces::iterator itr; Points points; Distances distances; int below, 
above, on; };
-
     typedef std::vector< FaceDistances > FaceDistancesList;
     FaceDistancesList faceDistances;
     faceDistances.resize( _faces.size() );
@@ -542,7 +551,7 @@ void ConvexPolyhedron::transformClip(const osg::Matrix& 
matrix, const osg::Matri
         Edges::iterator itr = edges.begin();
         vertices.push_back( itr->first );
         vertices.push_back( itr->second );
-        itr = edges.erase( itr );
+        edges.erase( itr++ );
 
         for( unsigned int vertices_size = 0;
             vertices_size < vertices.size(); )
@@ -566,7 +575,7 @@ void ConvexPolyhedron::transformClip(const osg::Matrix& 
matrix, const osg::Matri
                 if( not_added )
                     ++itr;
                 else
-                    itr = edges.erase( itr );
+                    edges.erase( itr++ );
             }
         }
 
@@ -669,7 +678,7 @@ bool ConvexPolyhedron::mergeFaces
         Edges::iterator itr = edges.begin();
         vertices.push_back( itr->first );
         vertices.push_back( itr->second );
-        itr = edges.erase( itr );
+        edges.erase( itr++ );
 
         for( unsigned int vertices_size = 0;
             vertices_size < vertices.size(); )
@@ -693,7 +702,7 @@ bool ConvexPolyhedron::mergeFaces
                 if( not_added )
                     ++itr;
                 else
-                    itr = edges.erase( itr );
+                    edges.erase( itr++ );
             }
         }
 
@@ -1170,7 +1179,7 @@ osg::BoundingBox ConvexPolyhedron::computeBoundingBox( 
const osg::Matrix & m ) c
 
////////////////////////////////////////////////////////////////////////////////
 void ConvexPolyhedron::cut(const osg::Polytope & polytope)
 {
-    char * apc[6] = { "left", "right", "bottom", "top", "near", "far" };
+    const char * apc[6] = { "left", "right", "bottom", "top", "near", "far" };
     char ac[16];
     int i = 0;
 
@@ -1178,7 +1187,14 @@ void ConvexPolyhedron::cut(const osg::Polytope & 
polytope)
         itr != polytope.getPlaneList().end();
         ++itr)
     {
-        cut(*itr, std::string( i < 6 ? apc[i] : itoa( i, ac, 10 ) ) );
+        const char* arg;
+        if (i < 6) {
+            arg = apc[i];
+        } else {
+            sprintf(ac, "%d", i);
+            arg = ac;
+        }
+        cut(*itr, std::string( arg ) );
         i++;
     }
 
@@ -1201,14 +1217,8 @@ void ConvexPolyhedron::cut(const osg::Plane& plane, 
const std::string& name)
 {
     if( _faces.empty() ) return;
 
-    typedef std::vector< double > Distances;
-
     ConvexPolyhedron cp( *this );
 
-    // Auxilliary params contined per face
-    struct FaceDistances
-    { Faces::iterator itr; Distances distances; int below, above, on; };
-
     typedef std::vector< FaceDistances > FaceDistancesList;
     FaceDistancesList faceDistances;
     faceDistances.resize( _faces.size() );
@@ -1434,7 +1444,7 @@ void ConvexPolyhedron::cut(const osg::Plane& plane, const 
std::string& name)
         Edges::iterator itr = edges.begin();
         vertices.push_back( itr->first );
         vertices.push_back( itr->second );
-        itr = edges.erase( itr );
+        edges.erase( itr++ );
 
         for( unsigned int vertices_size = 0;
             vertices_size < vertices.size(); )
@@ -1458,7 +1468,7 @@ void ConvexPolyhedron::cut(const osg::Plane& plane, const 
std::string& name)
                 if( not_added )
                     ++itr;
                 else
-                    itr = edges.erase( itr );
+                    edges.erase( itr++ );
             }
         }
 
@@ -1594,7 +1604,7 @@ void ConvexPolyhedron::extrude( const osg::Vec3d & offset 
)
             {
                 Face & face = createFace();
                 char ac[40] = "Side plane from edge extrude ";
-                itoa( new_face_counter++, ac + strlen( ac ), 10 );
+                sprintf(ac + strlen(ac), "%d", new_face_counter++);
                 face.name = ac;
 
                 // Compute face plane
diff --git a/ViewDependentShadow/MinimalCullBoundsShadowMap.cpp 
b/ViewDependentShadow/MinimalCullBoundsShadowMap.cpp
index dcb966d..68ec669 100644
--- a/ViewDependentShadow/MinimalCullBoundsShadowMap.cpp
+++ b/ViewDependentShadow/MinimalCullBoundsShadowMap.cpp
@@ -14,6 +14,8 @@
 // Thanks to to my company http://www.ai.com.pl for letting me free this work.
 
////////////////////////////////////////////////////////////////////////////////
 
+#include <string.h>
+            
 #include <ViewDependentShadow/MinimalCullBoundsShadowMap>
 #include <osgUtil/RenderLeaf>
 
diff --git a/ViewDependentShadow/MinimalDrawBoundsShadowMap.cpp 
b/ViewDependentShadow/MinimalDrawBoundsShadowMap.cpp
index 4bff1ce..71e7290 100644
--- a/ViewDependentShadow/MinimalDrawBoundsShadowMap.cpp
+++ b/ViewDependentShadow/MinimalDrawBoundsShadowMap.cpp
@@ -24,6 +24,7 @@
 #include <osg/AlphaFunc>
 #include <osg/Image>
 #include <iostream>
+#include <string.h>
 
 #define ANALYSIS_DEPTH
 #define USE_FLOAT_IMAGE
diff --git a/ViewDependentShadow/MinimalShadowMap 
b/ViewDependentShadow/MinimalShadowMap
index 5e75d16..69f38fc 100644
--- a/ViewDependentShadow/MinimalShadowMap
+++ b/ViewDependentShadow/MinimalShadowMap
@@ -122,7 +122,7 @@ protected:
             ( osg::Matrix & projection, float n = 0, float f = FLT_MAX );
 
         static void extendProjection
-            ( osg::Matrix & projection, osg::Viewport * viewport, osg::Vec2& 
margin );
+            ( osg::Matrix & projection, osg::Viewport * viewport, const 
osg::Vec2& margin );
     };
 
     META_ViewDependentShadowTechniqueData( ThisClass, ThisClass::ViewData )
diff --git a/ViewDependentShadow/MinimalShadowMap.cpp 
b/ViewDependentShadow/MinimalShadowMap.cpp
index c27398f..c4ad73b 100644
--- a/ViewDependentShadow/MinimalShadowMap.cpp
+++ b/ViewDependentShadow/MinimalShadowMap.cpp
@@ -408,7 +408,7 @@ void MinimalShadowMap::ViewData::clampProjection
 // Method computes such new projection which maintains perpective/world ratio
 
////////////////////////////////////////////////////////////////////////////////
 void MinimalShadowMap::ViewData::extendProjection
-    ( osg::Matrix & projection, osg::Viewport * viewport, osg::Vec2& margin )
+    ( osg::Matrix & projection, osg::Viewport * viewport, const osg::Vec2& 
margin )
 {
   double l,r,b,t,n,f;
 
diff --git a/ViewDependentShadow/ProjectionShadowMap 
b/ViewDependentShadow/ProjectionShadowMap
index a3af039..eb7b911 100644
--- a/ViewDependentShadow/ProjectionShadowMap
+++ b/ViewDependentShadow/ProjectionShadowMap
@@ -56,15 +56,16 @@ protected:
             ( const osg::Camera* cameraMain, osg::Camera* cameraShadow, int 
pass = 1 )
         {
 
+            // Force dependent name lookup
             ShadowProjectionAlgorithmClass::operator()
-                ( &_sceneReceivingShadowPolytope, cameraMain, cameraShadow );
+                ( &this->_sceneReceivingShadowPolytope, cameraMain, 
cameraShadow );
 
             // DebugBoundingBox( computeScenePolytopeBounds(), 
"ProjectionShadowMap" );
             BaseClass::ViewData::frameShadowCastingCamera( cameraMain, 
cameraShadow, pass );
         }
     };
 
-    META_ViewDependentShadowTechniqueData( ThisClass, ThisClass::ViewData )
+    META_ViewDependentShadowTechniqueData( ThisClass, typename 
ThisClass::ViewData )
 };
 
 } // namespace ViewDependentShadow
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to