]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/model/shadowvolume.hxx
Modified Files:
[simgear.git] / simgear / scene / model / shadowvolume.hxx
index 102da84d43d3fe20eb04688500129056f55ba1d7..8f5ebcde51d8589a128994b6d3c5aaec187315d0 100644 (file)
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 //
 
 #ifndef _SHADOWVOLUME_HXX
 #define _SHADOWVOLUME_HXX
 
+#include <simgear/compiler.h>
+#include <simgear/props/props.hxx>
 
-#include <plib/sg.h>
 #include <vector>
 #include <map>
 
@@ -41,7 +42,7 @@ class SGPropertyNode;
 class SGShadowVolume {
 
 public:
-       SGShadowVolume();
+       SGShadowVolume( ssgBranch *root );
        ~SGShadowVolume();
 
        typedef enum {
@@ -58,45 +59,48 @@ public:
        void setupShadows(double lon, double lat,
                double gst, double SunRightAscension, double SunDeclination, double sunAngle );
        void endOfFrame(void);
-
+       static int ACpostTravCB( ssgEntity *entity, int traversal_mask );
 
 private:
 
        class ShadowCaster
        {
        public:
-               ssgBranch *geometry_leaf;
-               ssgBranch *scenery_object;
-               ssgBranch *lib_object;
-               ssgBranch *first_select;
+               typedef struct {
+                       sgVec4 planeEquations;
+                       int neighbourIndices[3];
+                       bool isSilhouetteEdge[3];
+                       bool isFacingLight;
+               } triData;
+
+               ssgSharedPtr<ssgBranch> geometry_leaf;
+               ssgSharedPtr<ssgBranch> scenery_object;
+               ssgSharedPtr<ssgBranch> lib_object;
+               ssgSharedPtr<ssgBranch> first_select;
                sgVec3 last_lightpos;
+               sgMat4 last_transform;
                int frameNumber;
 
                int *indices;
                int numTriangles;
-               sgVec3 * vertices;
-
-               // plane equation of each face
-               sgVec4 * planeEquations;
-
-               bool * isFacingLight;
+               triData *triangles;
 
-               int * neighbourIndices;
-
-               bool * isSilhouetteEdge;
+               sgVec4 * vertices;
+               GLushort *silhouetteEdgeIndices;
+               int lastSilhouetteIndicesCount;
+               bool isTranslucent;
 
                ShadowCaster( int _num_tri, ssgBranch * _geometry_leaf );
                ~ShadowCaster();
-               void addLeaf( int & tri_idx, ssgLeaf *_geometry_leaf );
+               void addLeaf( int & tri_idx, int & ind_idx, ssgLeaf *_geometry_leaf );
                void SetConnectivity();
                void CalculateSilhouetteEdges(sgVec3 lightPosition);
                void DrawInfiniteShadowVolume(sgVec3 lightPosition, bool drawCaps);
-               void computeShadows(sgMat4 rotation, sgMat4 rotation_translation);
+               void computeShadows(sgMat4 rotation, sgMat4 rotation_translation, OccluderType occluder_type);
                void getNetTransform ( ssgBranch * branch, sgMat4 xform );
-               bool isSelected (  ssgBranch * branch );
+               bool isSelected (  ssgBranch * branch, float dist);
 
                bool sameVertex(int edge1, int edge2);
-               void addTri(int p, sgVec3 a, sgVec3 b, sgVec3 c);
        };
        typedef vector<ShadowCaster *> ShadowCaster_list;
 
@@ -107,36 +111,36 @@ private:
                void computeShadows(void);
                void traverseTree(ssgBranch *branch);
                void find_trans(void);
-               ssgBranch *scenery_object;
-               ssgBranch *lib_object;
-               ssgBranch *pending_object;
-               ssgBranch *tile;
+               ssgSharedPtr<ssgBranch> scenery_object;
+               ssgSharedPtr<ssgBranch> lib_object;
+               ssgSharedPtr<ssgBranch> pending_object;
+               ssgSharedPtr<ssgBranch> tile;
                ShadowCaster_list parts;
                OccluderType occluder_type;
        };
-       typedef map<ssgBranch *, SceneryObject *> SceneryObject_map;
+       typedef map<ssgSharedPtr<ssgBranch>, SceneryObject *> SceneryObject_map;
 
 
 private:
        void update_light_view(void);
        void computeShadows(void);
+       void cull ( ssgBranch *b, sgFrustum *f, sgMat4 m, int test_needed );
 
-       bool    init_done;
        bool    shadows_enabled;
        bool    shadowsAC_enabled, shadowsAI_enabled, shadowsTO_enabled, shadowsDebug_enabled;
-       SGPropertyNode *sim_rendering;
+       bool    shadowsAC_transp_enabled;
+       bool    use_alpha;
+       bool    canDoAlpha, canDoStencil;
+       SGPropertyNode_ptr sim_rendering;
 
        sgVec3 sunPos;
        int frameNumber;
+       int lastTraverseTreeFrame;
        sgMat4 CameraViewM;
-       sgMat4 invViewAngle;
        double  sun_angle;
        SceneryObject_map sceneryObjects;
-       /** this sphere contains the visible scene and is used to cull shadow casters */
-       sgSphere frustumSphere;
-       /** this sphere contains the near clip plane and is used to check the need of a zfail */
-       sgSphere nearClipSphere;
-
+       ssgSharedPtr<ssgBranch> ssg_root;
+       bool shadows_rendered;
 };
 
 #endif // _SHADOWVOLUME_HXX