root/OpenSceneGraph/trunk/src/osg/ProxyNode.cpp @ 10341

Revision 10341, 3.3 kB (checked in by robert, 5 years ago)

From Mathias Froehlich, "attached is a change to the ProxyNode? that also includes ProxyNode? local
database options like recently added to PagedLOD.

Also there is a change to the traverse method:
The previous ProxyNode? checks the VisitorType? to be a CULL_VISITOR and the
presence of a request handler to submit a database request.
In contrast to that PagedLOD uses the request handler if it is there - even if
the visitor type is not a cull visitor.
The change removes the cull visitor test from the ProxyNode? so that it behaves
like the PagedLOD.
I believe that the presence of a request handler in a visitor might be
sufficient to trigger the requests as this is done in the PagedLOD anyway.

Based on rev 10332."

  • 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 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
14#include <osg/ProxyNode>
15#include <osg/CullStack>
16#include <osg/Notify>
17
18using namespace osg;
19
20ProxyNode::ProxyNode() :
21    _loadingExtReference(LOAD_IMMEDIATELY),
22    _centerMode(USER_DEFINED_CENTER),
23    _radius(-1)
24{
25}
26
27ProxyNode::ProxyNode(const ProxyNode& proxynode,const CopyOp& copyop):
28    Group(proxynode,copyop),
29    _filenameList(proxynode._filenameList),
30    _databaseOptions(proxynode._databaseOptions),
31    _databasePath(proxynode._databasePath),
32    _loadingExtReference(proxynode._loadingExtReference),
33    _centerMode(proxynode._centerMode),
34    _userDefinedCenter(proxynode._userDefinedCenter),
35    _radius(proxynode._radius)
36{
37}
38
39void ProxyNode::setDatabasePath(const std::string& path)
40{
41    _databasePath = path;
42    if (!_databasePath.empty())
43    {
44        char& lastCharacter = _databasePath[_databasePath.size()-1];
45        const char unixSlash = '/';
46        const char winSlash = '\\';
47
48        if (lastCharacter==winSlash)
49        {
50            lastCharacter = unixSlash;
51        }
52        else if (lastCharacter!=unixSlash)
53        {
54            _databasePath += unixSlash;
55        }
56    }
57}
58
59void ProxyNode::traverse(NodeVisitor& nv)
60{
61    if (nv.getDatabaseRequestHandler() && _filenameList.size()>_children.size() &&
62        _loadingExtReference!=NO_AUTOMATIC_LOADING)
63    {
64        for(unsigned int i=_children.size(); i<_filenameList.size(); ++i)
65        {
66            nv.getDatabaseRequestHandler()->requestNodeFile(_databasePath+_filenameList[i].first, this, 1.0f, nv.getFrameStamp(), _filenameList[i].second, _databaseOptions.get());
67        }
68    }
69    else
70    {
71        Group::traverse(nv);
72    }
73}
74
75void ProxyNode::expandFileNameListTo(unsigned int pos)
76{
77    if (pos>=_filenameList.size()) _filenameList.resize(pos+1);
78}
79
80bool ProxyNode::addChild( Node *child )
81{
82    if (Group::addChild(child))
83    {
84        expandFileNameListTo(_children.size()-1);
85        return true;
86    }
87    return false;
88}
89
90bool ProxyNode::addChild(Node *child, const std::string& filename)
91{
92    if (Group::addChild(child))
93    {
94        setFileName(_children.size()-1,filename);
95        return true;
96    }
97    return false;
98}
99
100bool ProxyNode::removeChildren(unsigned int pos,unsigned int numChildrenToRemove)
101{
102    if (pos<_filenameList.size()) _filenameList.erase(_filenameList.begin()+pos, osg::minimum(_filenameList.begin()+(pos+numChildrenToRemove), _filenameList.end()) );
103
104    return Group::removeChildren(pos,numChildrenToRemove);
105}
106
107BoundingSphere ProxyNode::computeBound() const
108{
109    if (_centerMode==USER_DEFINED_CENTER && _radius>=0.0f)
110    {
111        return BoundingSphere(_userDefinedCenter,_radius);
112    }
113    else
114    {
115        return Group::computeBound();
116    }
117}
118
Note: See TracBrowser for help on using the browser.