root/OpenSceneGraph/trunk/src/osg/Hint.cpp @ 13041

Revision 13041, 1.9 kB (checked in by robert, 2 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
14#include <osg/Hint>
15#include <osg/StateSet>
16
17using namespace osg;
18
19void Hint::apply(State& /*state*/) const
20{
21    if (_target==GL_NONE || _mode==GL_NONE) return;
22
23    glHint(_target, _mode);
24}
25
26void Hint::setTarget(GLenum target)
27{
28    if (_target==target) return;
29
30    if (_parents.empty())
31    {
32        _target = target;
33        return;
34    }
35
36    // take a reference to this clip plane to prevent it from going out of scope
37    // when we remove it temporarily from its parents.
38    osg::ref_ptr<Hint> hintRef = this;
39
40    // copy the parents as they _parents list will be changed by the subsequent removeAttributes.
41    ParentList parents = _parents;
42
43    // remove this attribute from its parents as its position is being changed
44    // and would no longer be valid.
45    ParentList::iterator itr;
46    for(itr = parents.begin();
47        itr != parents.end();
48        ++itr)
49    {
50        osg::StateSet* stateset = *itr;
51        stateset->removeAttribute(this);
52    }
53
54    // assign the hint target
55    _target = target;
56
57    // add this attribute back into its original parents with its new position
58    for(itr = parents.begin();
59        itr != parents.end();
60        ++itr)
61    {
62        osg::StateSet* stateset = *itr;
63        stateset->setAttribute(this);
64    }
65}
Note: See TracBrowser for help on using the browser.