root/OpenSceneGraph/trunk/src/osg/StateAttribute.cpp @ 9354

Revision 9354, 2.5 kB (checked in by robert, 4 years ago)

From Paul Martz, "I'm not sure why this message was added, but it doesn't appear to merit INFO verbosity. Changing this from INFO to DEBUG_FP."

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This application is open source and may be redistributed and/or modified   
4 * freely and without restriction, both in commericial and non commericial
5 * applications, as long as this copyright notice is maintained.
6 *
7 * This application is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10*/
11
12#include <osg/StateAttribute>
13#include <osg/StateSet>
14#include <osg/State>
15#include <osg/Notify>
16
17#include <algorithm>
18
19using namespace osg;
20
21
22StateAttribute::StateAttribute()
23    :Object(true)
24{
25}
26
27
28void StateAttribute::addParent(osg::StateSet* object)
29{
30    osg::notify(osg::DEBUG_FP)<<"Adding parent"<<getRefMutex()<<std::endl;
31    OpenThreads::ScopedPointerLock<OpenThreads::Mutex> lock(getRefMutex());
32   
33    _parents.push_back(object);
34}
35
36void StateAttribute::removeParent(osg::StateSet* object)
37{
38    OpenThreads::ScopedPointerLock<OpenThreads::Mutex> lock(getRefMutex());
39   
40    ParentList::iterator pitr = std::find(_parents.begin(),_parents.end(),object);
41    if (pitr!=_parents.end()) _parents.erase(pitr);
42}
43
44
45void StateAttribute::setUpdateCallback(Callback* uc)
46{
47    osg::notify(osg::INFO)<<"StateAttribute::Setting Update callbacks"<<std::endl;
48
49    if (_updateCallback==uc) return;
50   
51    int delta = 0;
52    if (_updateCallback.valid()) --delta;
53    if (uc) ++delta;
54
55    _updateCallback = uc;
56   
57    if (delta!=0)
58    {
59        osg::notify(osg::INFO)<<"Going to set StateAttribute parents"<<std::endl;
60
61        for(ParentList::iterator itr=_parents.begin();
62            itr!=_parents.end();
63            ++itr)
64        {
65            osg::notify(osg::INFO)<<"   Setting StateAttribute parent"<<std::endl;
66
67            (*itr)->setNumChildrenRequiringUpdateTraversal((*itr)->getNumChildrenRequiringUpdateTraversal()+delta);
68        }
69    }
70}
71
72void StateAttribute::setEventCallback(Callback* ec)
73{
74    osg::notify(osg::INFO)<<"StateAttribute::Setting Event callbacks"<<std::endl;
75
76    if (_eventCallback==ec) return;
77   
78    int delta = 0;
79    if (_eventCallback.valid()) --delta;
80    if (ec) ++delta;
81
82    _eventCallback = ec;
83   
84    if (delta!=0)
85    {
86        for(ParentList::iterator itr=_parents.begin();
87            itr!=_parents.end();
88            ++itr)
89        {
90            (*itr)->setNumChildrenRequiringEventTraversal((*itr)->getNumChildrenRequiringEventTraversal()+delta);
91        }
92    }
93}
Note: See TracBrowser for help on using the browser.