]> git.pld-linux.org Git - packages/SimGear.git/blame - OpenSceneGraph-3.3.2.patch
- updated to 2016.2.1
[packages/SimGear.git] / OpenSceneGraph-3.3.2.patch
CommitLineData
05b68381
JR
1commit 791273c61de23d2ec383a270db27015d235a9938
2Author: Thomas Geymayer <tomgey@gmail.com>
3Date: Sat Aug 9 17:18:21 2014 +0200
4
5 Update for OpenSceneGraph 3.3.2 API changes.
6
7diff --git a/simgear/canvas/ODGauge.cxx b/simgear/canvas/ODGauge.cxx
8index 5c547ea..4a2b7fa 100644
9--- a/simgear/canvas/ODGauge.cxx
10+++ b/simgear/canvas/ODGauge.cxx
11@@ -44,6 +44,7 @@
12 #include <osg/ShadeModel>
13 #include <osg/StateSet>
14 #include <osg/FrameBufferObject> // for GL_DEPTH_STENCIL_EXT on Windows
15+#include <osg/Version>
16 #include <osgUtil/RenderBin>
17
18 #include <cassert>
19@@ -266,7 +267,15 @@ namespace canvas
20 //----------------------------------------------------------------------------
21 void ODGauge::reinit()
22 {
23- osg::NodeCallback* cull_callback = camera ? camera->getCullCallback() : 0;
24+ osg::NodeCallback* cull_callback =
25+ camera
26+#if OSG_VERSION_LESS_THAN(3,3,2)
27+ ? camera->getCullCallback()
28+#else
29+ ? dynamic_cast<osg::NodeCallback*>(camera->getCullCallback())
30+#endif
31+ : 0;
32+
33 clear();
34 allocRT(cull_callback);
35 }
36diff --git a/simgear/canvas/elements/CanvasElement.cxx b/simgear/canvas/elements/CanvasElement.cxx
37index 478cfb8..f895292 100644
38--- a/simgear/canvas/elements/CanvasElement.cxx
39+++ b/simgear/canvas/elements/CanvasElement.cxx
40@@ -27,6 +27,7 @@
41 #include <osg/Drawable>
42 #include <osg/Geode>
43 #include <osg/Scissor>
44+#include <osg/Version>
45
46 #include <boost/algorithm/string/predicate.hpp>
47 #include <boost/foreach.hpp>
48@@ -649,7 +650,11 @@ namespace canvas
49 osg::BoundingBox Element::getBoundingBox() const
50 {
51 if( _drawable )
52+#if OSG_VERSION_LESS_THAN(3,3,2)
53 return _drawable->getBound();
54+#else
55+ return _drawable->getBoundingBox();
56+#endif
57
58 osg::BoundingBox bb;
59
60@@ -672,7 +677,13 @@ namespace canvas
61 return osg::BoundingBox();
62
63 osg::BoundingBox transformed;
64- const osg::BoundingBox& bb = _drawable->getBound();
65+ const osg::BoundingBox& bb =
66+#if OSG_VERSION_LESS_THAN(3,3,2)
67+ _drawable->getBound();
68+#else
69+ _drawable->getBoundingBox();
70+#endif
71+
72 for(int i = 0; i < 4; ++i)
73 transformed.expandBy( bb.corner(i) * m );
74
75diff --git a/simgear/canvas/elements/CanvasImage.cxx b/simgear/canvas/elements/CanvasImage.cxx
76index 4f4ffc7..c89c71a 100644
77--- a/simgear/canvas/elements/CanvasImage.cxx
78+++ b/simgear/canvas/elements/CanvasImage.cxx
79@@ -413,7 +413,14 @@ namespace canvas
80 && child->getNameString() == "visible"
81 && child->getBoolValue() )
82 {
83- CullCallback* cb = static_cast<CullCallback*>(_geom->getCullCallback());
84+ CullCallback* cb =
85+#if OSG_VERSION_LESS_THAN(3,3,2)
86+ static_cast<CullCallback*>
87+#else
88+ dynamic_cast<CullCallback*>
89+#endif
90+ ( _geom->getCullCallback() );
91+
92 if( cb )
93 cb->cullNextFrame();
94 }
95diff --git a/simgear/canvas/elements/CanvasPath.cxx b/simgear/canvas/elements/CanvasPath.cxx
96index ba5351f..9eddcb3 100644
97--- a/simgear/canvas/elements/CanvasPath.cxx
98+++ b/simgear/canvas/elements/CanvasPath.cxx
99@@ -20,6 +20,7 @@
100 #include <simgear/scene/util/parse_color.hxx>
101
102 #include <osg/Drawable>
103+#include <osg/Version>
104
105 #include <vg/openvg.h>
106 #include <cassert>
107@@ -372,7 +373,13 @@ namespace canvas
108 /**
109 * Compute the bounding box
110 */
111- virtual osg::BoundingBox computeBound() const
112+ virtual osg::BoundingBox
113+#if OSG_VERSION_LESS_THAN(3,3,2)
114+ computeBound()
115+#else
116+ computeBoundingBox()
117+#endif
118+ const
119 {
120 if( _path == VG_INVALID_HANDLE || (_attributes_dirty & PATH) )
121 return osg::BoundingBox();
122diff --git a/simgear/canvas/elements/CanvasText.cxx b/simgear/canvas/elements/CanvasText.cxx
123index ebe76d4..239383c 100644
124--- a/simgear/canvas/elements/CanvasText.cxx
125+++ b/simgear/canvas/elements/CanvasText.cxx
126@@ -45,7 +45,13 @@ namespace canvas
127 SGVec2i sizeForWidth(int w) const;
128 osg::Vec2 handleHit(const osg::Vec2f& pos);
129
130- virtual osg::BoundingBox computeBound() const;
131+ virtual osg::BoundingBox
132+#if OSG_VERSION_LESS_THAN(3,3,2)
133+ computeBound()
134+#else
135+ computeBoundingBox()
136+#endif
137+ const;
138
139 protected:
140
141@@ -467,9 +473,20 @@ namespace canvas
142 }
143
144 //----------------------------------------------------------------------------
145- osg::BoundingBox Text::TextOSG::computeBound() const
146+ osg::BoundingBox
147+#if OSG_VERSION_LESS_THAN(3,3,2)
148+ Text::TextOSG::computeBound()
149+#else
150+ Text::TextOSG::computeBoundingBox()
151+#endif
152+ const
153 {
154- osg::BoundingBox bb = osgText::Text::computeBound();
155+ osg::BoundingBox bb =
156+#if OSG_VERSION_LESS_THAN(3,3,2)
157+ osgText::Text::computeBound();
158+#else
159+ osgText::Text::computeBoundingBox();
160+#endif
161
162 #if OSG_VERSION_LESS_THAN(3,1,0)
163 if( bb.valid() )
164diff --git a/simgear/scene/material/EffectGeode.hxx b/simgear/scene/material/EffectGeode.hxx
165index 515b1a0..34b87e3 100644
166--- a/simgear/scene/material/EffectGeode.hxx
167+++ b/simgear/scene/material/EffectGeode.hxx
168@@ -18,6 +18,9 @@
169 #define SIMGEAR_EFFECT_GEODE_HXX 1
170
171 #include <osg/Geode>
172+#include <osg/Version>
173+
174+#include <boost/iterator/iterator_adaptor.hpp>
175
176 #include "Effect.hxx"
177
178@@ -25,7 +28,41 @@ namespace simgear
179 {
180 class EffectGeode : public osg::Geode
181 {
182-public:
183+ public:
184+
185+#if OSG_VERSION_LESS_THAN(3,3,2)
186+ typedef DrawableList::iterator DrawablesIterator;
187+#else
188+ class DrawablesIterator:
189+ public boost::iterator_adaptor<
190+ DrawablesIterator,
191+ osg::NodeList::iterator,
192+ osg::ref_ptr<osg::Drawable>,
193+ boost::use_default,
194+ osg::ref_ptr<osg::Drawable> // No reference as Reference type.
195+ // The child list does not contain Drawable
196+ // ref_ptr so we can not return any
197+ // references to them.
198+ >
199+ {
200+ public:
201+
202+ DrawablesIterator()
203+ {}
204+
205+ explicit DrawablesIterator(osg::NodeList::iterator const& node_it):
206+ DrawablesIterator::iterator_adaptor_(node_it)
207+ {}
208+
209+ private:
210+ friend class boost::iterator_core_access;
211+ osg::ref_ptr<osg::Drawable> dereference() const
212+ {
213+ return base_reference()->get()->asDrawable();
214+ }
215+ };
216+#endif
217+
218 EffectGeode();
219 EffectGeode(const EffectGeode& rhs,
220 const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
221@@ -34,9 +71,15 @@ public:
222 void setEffect(Effect* effect);
223 virtual void resizeGLObjectBuffers(unsigned int maxSize);
224 virtual void releaseGLObjects(osg::State* = 0) const;
225- typedef DrawableList::iterator DrawablesIterator;
226+
227+#if OSG_VERSION_LESS_THAN(3,3,2)
228 DrawablesIterator drawablesBegin() { return _drawables.begin(); }
229 DrawablesIterator drawablesEnd() { return _drawables.end(); }
230+#else
231+ DrawablesIterator drawablesBegin() { return DrawablesIterator(_children.begin()); }
232+ DrawablesIterator drawablesEnd() { return DrawablesIterator(_children.end()); }
233+#endif
234+
235 void runGenerators(osg::Geometry *geometry);
236 private:
237 osg::ref_ptr<Effect> _effect;
238diff --git a/simgear/scene/material/Technique.cxx b/simgear/scene/material/Technique.cxx
239index d5d9b06..93a17b8 100644
240--- a/simgear/scene/material/Technique.cxx
241+++ b/simgear/scene/material/Technique.cxx
242@@ -140,27 +140,40 @@ Technique::processDrawables(const EffectGeode::DrawablesIterator& begin,
243 EffectGeode::DrawablesIterator itr = begin;
244 bool computeNearFar
245 = cv->getComputeNearFarMode() != CullVisitor::DO_NOT_COMPUTE_NEAR_FAR;
246- for (int i = 0; i < NUM_DRAWABLES && itr != end; ++itr, ++i) {
247- Drawable* drawable = itr->get();
248- const BoundingBox& bb = drawable->getBound();
249- if ((drawable->getCullCallback()
250- && drawable->getCullCallback()->cull(cv, drawable,
251- &cv->getRenderInfo()))
252- || (isCullingActive && cv->isCulled(bb))) {
253- depth[i] = FLT_MAX;
254- continue;
255- }
256- if (computeNearFar && bb.valid()) {
257- if (!cv->updateCalculatedNearFar(matrix, *drawable, false)) {
258- depth[i] = FLT_MAX;
259- continue;
260- }
261+ for (int i = 0; i < NUM_DRAWABLES && itr != end; ++itr, ++i)
262+ {
263+ Drawable* drawable = itr->get();
264+
265+#if OSG_VERSION_LESS_THAN(3,3,2)
266+ const BoundingBox& bb = drawable->getBound();
267+ osg::Drawable::CullCallback* cull = drawable->getCullCallback();
268+#else
269+ const BoundingBox& bb = drawable->getBoundingBox();
270+ osg::Drawable::CullCallback* cull =
271+ dynamic_cast<osg::Drawable::CullCallback*>(drawable->getCullCallback());
272+#endif
273+
274+ if( (cull && cull->cull(cv, drawable, &cv->getRenderInfo()))
275+ || (isCullingActive && cv->isCulled(bb)) )
276+ {
277+ depth[i] = FLT_MAX;
278+ continue;
279+ }
280+
281+ if( computeNearFar && bb.valid() )
282+ {
283+ if( !cv->updateCalculatedNearFar(matrix, *drawable, false) )
284+ {
285+ depth[i] = FLT_MAX;
286+ continue;
287 }
288- depth[i] = (bb.valid()
289- ? cv->getDistanceFromEyePoint(bb.center(), false)
290- : 0.0f);
291- if (isNaN(depth[i]))
292- depth[i] = FLT_MAX;
293+ }
294+
295+ depth[i] = bb.valid()
296+ ? cv->getDistanceFromEyePoint(bb.center(), false)
297+ : 0.0f;
298+ if( isNaN(depth[i]) )
299+ depth[i] = FLT_MAX;
300 }
301 EffectCullVisitor* ecv = dynamic_cast<EffectCullVisitor*>( cv );
302 EffectGeode::DrawablesIterator drawablesEnd = itr;
303diff --git a/simgear/scene/sky/CloudShaderGeometry.hxx b/simgear/scene/sky/CloudShaderGeometry.hxx
304index 20d0db8..6d78af2 100644
305--- a/simgear/scene/sky/CloudShaderGeometry.hxx
306+++ b/simgear/scene/sky/CloudShaderGeometry.hxx
307@@ -95,7 +95,13 @@ class CloudShaderGeometry : public osg::Drawable
308 { return _cloudsprites[i]; }
309
310 virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
311- virtual osg::BoundingBox computeBound() const
312+ virtual osg::BoundingBox
313+#if OSG_VERSION_LESS_THAN(3,3,2)
314+ computeBound()
315+#else
316+ computeBoundingBox()
317+#endif
318+ const
319 {
320 return _bbox;
321 }
322diff --git a/simgear/scene/tgdb/SGVasiDrawable.cxx b/simgear/scene/tgdb/SGVasiDrawable.cxx
323index bb3ce0e..d66474f 100644
324--- a/simgear/scene/tgdb/SGVasiDrawable.cxx
325+++ b/simgear/scene/tgdb/SGVasiDrawable.cxx
326@@ -104,7 +104,12 @@ SGVasiDrawable::drawImplementation(osg::RenderInfo& renderInfo) const
327 }
328
329 osg::BoundingBox
330-SGVasiDrawable::computeBound() const
331+#if OSG_VERSION_LESS_THAN(3,3,2)
332+SGVasiDrawable::computeBound()
333+#else
334+SGVasiDrawable::computeBoundingBox()
335+#endif
336+const
337 {
338 osg::BoundingBox bb;
339 for (unsigned i = 0; i < _lights.size(); ++i)
340diff --git a/simgear/scene/tgdb/SGVasiDrawable.hxx b/simgear/scene/tgdb/SGVasiDrawable.hxx
341index 242e393..e4b0479 100644
342--- a/simgear/scene/tgdb/SGVasiDrawable.hxx
343+++ b/simgear/scene/tgdb/SGVasiDrawable.hxx
344@@ -23,9 +23,10 @@
345 #define _SG_VASI_DRAWABLE_HXX
346
347 #include <simgear/compiler.h>
348+#include <simgear/math/SGMath.hxx>
349
350 #include <osg/Drawable>
351-#include <simgear/math/SGMath.hxx>
352+#include <osg/Version>
353
354 class SGVasiDrawable : public osg::Drawable {
355 struct LightData;
356@@ -49,7 +50,13 @@ public:
357 const SGVec3f& up);
358
359 virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
360- virtual osg::BoundingBox computeBound() const;
361+ virtual osg::BoundingBox
362+#if OSG_VERSION_LESS_THAN(3,3,2)
363+ computeBound()
364+#else
365+ computeBoundingBox()
366+#endif
367+ const;
368
369 private:
370 SGVec4f getColor(float angleDeg) const;
371diff --git a/simgear/scene/tgdb/ShaderGeometry.cxx b/simgear/scene/tgdb/ShaderGeometry.cxx
372index 36a3093..5d286c3 100644
373--- a/simgear/scene/tgdb/ShaderGeometry.cxx
374+++ b/simgear/scene/tgdb/ShaderGeometry.cxx
375@@ -60,9 +60,21 @@ void ShaderGeometry::drawImplementation(osg::RenderInfo& renderInfo) const
376 }
377 }
378
379-BoundingBox ShaderGeometry::computeBound() const
380+BoundingBox
381+#if OSG_VERSION_LESS_THAN(3,3,2)
382+ShaderGeometry::computeBound()
383+#else
384+ShaderGeometry::computeBoundingBox()
385+#endif
386+const
387 {
388- const BoundingBox& geom_box = _geometry->getBound();
389+ const BoundingBox& geom_box =
390+#if OSG_VERSION_LESS_THAN(3,3,2)
391+ _geometry->getBound();
392+#else
393+ _geometry->getBoundingBox();
394+#endif
395+
396 BoundingBox bb;
397 const Vec4Array* posScales = _posScaleArray.get();
398 if (!posScales)
399diff --git a/simgear/scene/tgdb/ShaderGeometry.hxx b/simgear/scene/tgdb/ShaderGeometry.hxx
400index 30c72fb..a5de095 100644
401--- a/simgear/scene/tgdb/ShaderGeometry.hxx
402+++ b/simgear/scene/tgdb/ShaderGeometry.hxx
403@@ -58,8 +58,15 @@ class ShaderGeometry : public osg::Drawable
404 META_Object(flightgear, ShaderGeometry);
405
406 virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
407- virtual osg::BoundingBox computeBound() const;
408
409+ virtual osg::BoundingBox
410+#if OSG_VERSION_LESS_THAN(3,3,2)
411+ computeBound()
412+#else
413+ computeBoundingBox()
414+#endif
415+ const;
416+
417 void setGeometry(osg::Geometry* geometry)
418 {
419 _geometry = geometry;
420diff --git a/simgear/scene/util/SGEnlargeBoundingBox.cxx b/simgear/scene/util/SGEnlargeBoundingBox.cxx
421index 8e5d8f3..5ff1985 100644
422--- a/simgear/scene/util/SGEnlargeBoundingBox.cxx
423+++ b/simgear/scene/util/SGEnlargeBoundingBox.cxx
424@@ -24,7 +24,9 @@
425 #endif
426
427 #include "SGEnlargeBoundingBox.hxx"
428+
429 #include <osg/Drawable>
430+#include <osg/Version>
431
432 SGEnlargeBoundingBox::SGEnlargeBoundingBox(float offset) :
433 _offset(offset)
434@@ -41,7 +43,13 @@ SGEnlargeBoundingBox::SGEnlargeBoundingBox(const SGEnlargeBoundingBox& cb,
435 osg::BoundingBox
436 SGEnlargeBoundingBox::computeBound(const osg::Drawable& drawable) const
437 {
438- osg::BoundingBox bound = drawable.computeBound();
439+ osg::BoundingBox bound =
440+#if OSG_VERSION_LESS_THAN(3,3,2)
441+ drawable.computeBound();
442+#else
443+ drawable.computeBoundingBox();
444+#endif
445+
446 if (!bound.valid())
447 return bound;
448 return osg::BoundingBox(bound._min - osg::Vec3(_offset, _offset, _offset),
449diff --git a/simgear/scene/util/UpdateOnceCallback.cxx b/simgear/scene/util/UpdateOnceCallback.cxx
450index 2615df4..99d0192 100644
451--- a/simgear/scene/util/UpdateOnceCallback.cxx
452+++ b/simgear/scene/util/UpdateOnceCallback.cxx
453@@ -20,6 +20,7 @@
454 #include "UpdateOnceCallback.hxx"
455
456 #include <osg/Node>
457+#include <osg/NodeVisitor>
458
459 namespace simgear
460 {
461commit 68d0891665683cbe115c0689a9f17f4aa078cf56
462Author: Thomas Geymayer <tomgey@gmail.com>
463Date: Sun Aug 10 15:36:27 2014 +0200
464
465 Canvas: fix element mouse hit detection with OSG 3.3.2.
466
467diff --git a/simgear/canvas/elements/CanvasElement.cxx b/simgear/canvas/elements/CanvasElement.cxx
468index f895292..6d8c930 100644
469--- a/simgear/canvas/elements/CanvasElement.cxx
470+++ b/simgear/canvas/elements/CanvasElement.cxx
471@@ -398,7 +398,13 @@ namespace canvas
472
473 // Drawables have a bounding box...
474 if( _drawable )
475- return _drawable->getBound().contains(osg::Vec3f(local_pos, 0));
476+ return _drawable->
477+#if OSG_VERSION_LESS_THAN(3,3,2)
478+ getBound()
479+#else
480+ getBoundingBox()
481+#endif
482+ .contains(osg::Vec3f(local_pos, 0));
483 else if( _transform.valid() )
484 // ... for other elements, i.e. groups only a bounding sphere is available
485 return _transform->getBound().contains(osg::Vec3f(parent_pos, 0));
This page took 0.124834 seconds and 4 git commands to generate.