~ubuntu-branches/ubuntu/trusty/openscenegraph/trusty

« back to all changes in this revision

Viewing changes to OpenSceneGraph/src/osg/ClipNode.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-07-29 04:34:38 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 lenny)
  • Revision ID: james.westby@ubuntu.com-20080729043438-no1h9h0dpsrlzp1y
* Non-maintainer upload.
* No longer try to detect (using /proc/cpuinfo when available) how many
  CPUs are available, fixing the FTBFS (due to -j0) on various platforms
  (Closes: #477353). The right way to do it is to support parallel=n in
  DEB_BUILD_OPTIONS (see Debian Policy §4.9.1), and adequate support has
  been implemented.
* Add patch to fix FTBFS due to the build system now refusing to handle
  whitespaces (Policy CMP0004 say the logs), thanks to Andreas Putzo who
  provided it (Closes: #482239):
   - debian/patches/fix-cmp0004-build-failure.dpatch
* Remove myself from Uploaders, as requested a while ago, done by Luk in
  his 2.2.0-2.1 NMU, which was never acknowledged.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
using namespace osg;
18
18
 
19
 
ClipNode::ClipNode()
 
19
ClipNode::ClipNode():
 
20
    _value(StateAttribute::ON)
20
21
{
21
 
    _value = StateAttribute::ON;
22
22
    _stateset = new StateSet;
23
23
}
24
24
 
25
 
ClipNode::ClipNode(const ClipNode& cn, const CopyOp& copyop):Group(cn,copyop)
 
25
ClipNode::ClipNode(const ClipNode& cn, const CopyOp& copyop):
 
26
    Group(cn,copyop),
 
27
    _value(cn._value)
26
28
{
27
29
    for(ClipPlaneList::const_iterator itr=cn._planes.begin();
28
30
        itr!=cn._planes.end();
29
31
        ++itr)
30
32
    {
31
33
        ClipPlane* plane = dynamic_cast<ClipPlane*>(copyop(itr->get()));
32
 
        if (plane) addClipPlane(plane);
 
34
        if (!plane)
 
35
            continue;
 
36
        _planes.push_back(plane);
 
37
        _stateset->setAssociatedModes(plane, _value);
33
38
    }
34
39
}
35
40
 
41
46
void ClipNode::createClipBox(const BoundingBox& bb,unsigned int clipPlaneNumberBase)
42
47
{
43
48
    _planes.clear();
 
49
    if (!_stateset.valid()) _stateset = new osg::StateSet;
44
50
 
45
51
    _planes.push_back(new ClipPlane(clipPlaneNumberBase  ,1.0,0.0,0.0,-bb.xMin()));
 
52
    _stateset->setAssociatedModes(_planes.back().get(), _value);
46
53
    _planes.push_back(new ClipPlane(clipPlaneNumberBase+1,-1.0,0.0,0.0,bb.xMax()));
 
54
    _stateset->setAssociatedModes(_planes.back().get(), _value);
47
55
 
48
56
    _planes.push_back(new ClipPlane(clipPlaneNumberBase+2,0.0,1.0,0.0,-bb.yMin()));
 
57
    _stateset->setAssociatedModes(_planes.back().get(), _value);
49
58
    _planes.push_back(new ClipPlane(clipPlaneNumberBase+3,0.0,-1.0,0.0,bb.yMax()));
 
59
    _stateset->setAssociatedModes(_planes.back().get(), _value);
50
60
 
51
61
    _planes.push_back(new ClipPlane(clipPlaneNumberBase+4,0.0,0.0,1.0,-bb.zMin()));
 
62
    _stateset->setAssociatedModes(_planes.back().get(), _value);
52
63
    _planes.push_back(new ClipPlane(clipPlaneNumberBase+5,0.0,0.0,-1.0,bb.zMax()));
53
 
 
54
 
    setLocalStateSetModes(_value);
 
64
    _stateset->setAssociatedModes(_planes.back().get(), _value);
55
65
}
56
66
 
57
67
// Add a ClipPlane to a ClipNode. Return true if plane is added, 
64
74
    {
65
75
        // cliplane doesn't exist in list so add it.
66
76
        _planes.push_back(clipplane);
67
 
        setLocalStateSetModes(_value);
 
77
        if (!_stateset.valid()) _stateset = new osg::StateSet;
 
78
        _stateset->setAssociatedModes(clipplane, _value);
68
79
        return true;
69
80
    }
70
81
    else
83
94
    if (itr!=_planes.end())
84
95
    {
85
96
        // cliplane exist in list so erase it.
 
97
        _stateset->removeAssociatedModes(clipplane);
86
98
        _planes.erase(itr);
87
 
        setLocalStateSetModes(_value);
88
99
        return true;
89
100
    }
90
101
    else
99
110
{
100
111
    if (pos<_planes.size())
101
112
    {
102
 
        _planes.erase(_planes.begin()+pos);
103
 
        setLocalStateSetModes(_value);
 
113
        ClipPlaneList::iterator itr = _planes.begin();
 
114
        std::advance(itr, pos);
 
115
        _stateset->removeAssociatedModes(itr->get());
 
116
        _planes.erase(itr);
104
117
        return true;
105
118
    }
106
119
    else
120
133
    }
121
134
}
122
135
 
123
 
void ClipNode::setLocalStateSetModes(const StateAttribute::GLModeValue value)
 
136
void ClipNode::setLocalStateSetModes(StateAttribute::GLModeValue value)
124
137
{
 
138
    _value = value;
125
139
    if (!_stateset) _stateset = new StateSet;
126
 
    _stateset->clear();
127
140
    setStateSetModes(*_stateset,value);
128
141
}
129
142