root/OpenSceneGraph/trunk/src/osgShadow/ViewDependentShadowTechnique.cpp @ 13041

Revision 13041, 3.4 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12 *
13 * ViewDependentShadow codes Copyright (C) 2008 Wojciech Lewandowski
14 * Thanks to to my company http://www.ai.com.pl for allowing me free this work.
15*/
16
17#include <osgShadow/ViewDependentShadowTechnique>
18#include <osgShadow/ShadowedScene>
19
20using namespace osgShadow;
21
22
23ViewDependentShadowTechnique::ViewDependentShadowTechnique()
24{
25    dirty();
26}
27
28ViewDependentShadowTechnique::ViewDependentShadowTechnique
29    (const ViewDependentShadowTechnique& copy, const osg::CopyOp& copyop):
30        ShadowTechnique(copy,copyop)
31{
32    dirty();
33}
34
35ViewDependentShadowTechnique::~ViewDependentShadowTechnique(void)
36{
37
38}
39
40void ViewDependentShadowTechnique::traverse(osg::NodeVisitor& nv)
41{
42    osgShadow::ShadowTechnique::traverse(nv);
43}
44
45void ViewDependentShadowTechnique::dirty()
46{
47    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_viewDataMapMutex);
48
49    osgShadow::ShadowTechnique::_dirty = true;
50
51    for( ViewDataMap::iterator mitr = _viewDataMap.begin();
52         mitr != _viewDataMap.end();
53         ++mitr )
54    {
55        mitr->second->dirty( true );
56    }
57}
58
59void ViewDependentShadowTechnique::init()
60{
61    //osgShadow::ShadowTechnique::init( );
62    osgShadow::ShadowTechnique::_dirty = false;
63}
64
65void ViewDependentShadowTechnique::update(osg::NodeVisitor& nv)
66{
67    //osgShadow::ShadowTechnique::update( nv );
68    osgShadow::ShadowTechnique::_shadowedScene->osg::Group::traverse(nv);
69}
70
71void ViewDependentShadowTechnique::cull(osgUtil::CullVisitor& cv)
72{
73    //osgShadow::ShadowTechnique::cull( cv );
74
75    ViewData * vd = getViewDependentData( &cv );
76
77    if ( !vd || vd->_dirty || vd->_cv != &cv || vd->_st != this ) {
78        vd = initViewDependentData( &cv, vd );
79        setViewDependentData( &cv, vd );
80    }
81
82    if( vd ) {
83        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(vd->_mutex);
84        vd->cull();
85    } else {
86        osgShadow::ShadowTechnique::_shadowedScene->osg::Group::traverse(cv);
87    }
88}
89
90void ViewDependentShadowTechnique::cleanSceneGraph()
91{
92    //osgShadow::ShadowTechnique::cleanSceneGraph( );
93}
94
95ViewDependentShadowTechnique::ViewData *
96ViewDependentShadowTechnique::getViewDependentData( osgUtil::CullVisitor * cv )
97{
98    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_viewDataMapMutex);
99    return _viewDataMap[ cv ].get();
100}
101
102void ViewDependentShadowTechnique::setViewDependentData
103    ( osgUtil::CullVisitor * cv, ViewData * data )
104{
105    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_viewDataMapMutex);
106    _viewDataMap[ cv ] = data;
107}
108
109void ViewDependentShadowTechnique::ViewData::dirty( bool flag )
110{
111    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
112    _dirty = flag;
113}
114
115void ViewDependentShadowTechnique::ViewData::init
116    (  ViewDependentShadowTechnique *st, osgUtil::CullVisitor * cv )
117{
118    _cv = cv;
119    _st = st;
120    dirty( false );
121}
122
123void ViewDependentShadowTechnique::ViewData::cull( void )
124{
125
126}
Note: See TracBrowser for help on using the browser.