Commit 3bea0460 authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

Fix compilation with old OSG version.

parent 44555898
Pipeline #9473 failed with stage
in 4 minutes and 55 seconds
......@@ -16,17 +16,17 @@ namespace viewer {
class BackfaceDrawingProperty : public Property
{
public:
typedef osg::NodeRefPtr NodeRefPtr;
typedef osg::StateSetRefPtr StateSetRefPtr;
bool hasReadAccess () const { return static_cast<bool>(node_); }
bool hasWriteAccess() const { return static_cast<bool>(node_); }
bool hasReadAccess () const { return static_cast<bool>(stateSet_); }
bool hasWriteAccess() const { return static_cast<bool>(stateSet_); }
std::string type() { return details::property_type<bool>::to_string(); }
BackfaceDrawingProperty () : Property("BackfaceDrawing") {}
void node (const NodeRefPtr& node) { node_ = node; }
NodeRefPtr node () const { return node_; }
void stateSet (const StateSetRefPtr& stateSet) { stateSet_ = stateSet; }
StateSetRefPtr stateSet () const { return stateSet_; }
virtual QWidget* guiEditor ()
{
......@@ -38,7 +38,7 @@ class BackfaceDrawingProperty : public Property
bool impl_get( bool& value);
private:
NodeRefPtr node_;
osg::StateSetRefPtr stateSet_;
};
} /* namespace viewer */
......
......@@ -71,7 +71,12 @@ osgUtil::Intersector* PointIntersector::clone( osgUtil::IntersectionVisitor& iv
void PointIntersector::intersect( osgUtil::IntersectionVisitor& iv, osg::Drawable* drawable )
{
osg::BoundingBox bb = drawable->getBoundingBox();
osg::BoundingBox bb =
#if OSG_VERSION_LESS_THAN(3,3,3)
drawable->getBound();
#else
drawable->getBoundingBox();
#endif
bb.xMin() -= _pickBias; bb.xMax() += _pickBias;
bb.yMin() -= _pickBias; bb.yMax() += _pickBias;
bb.zMin() -= _pickBias; bb.zMax() += _pickBias;
......
......@@ -169,7 +169,7 @@ namespace viewer {
collada_ptr_->setDataVariance(osg::Object::STATIC);
}
collada_ptr_->setName ("meshfile");
backfaceDrawing_.node(collada_ptr_);
backfaceDrawing_.stateSet(collada_ptr_->getOrCreateStateSet());
backfaceDrawing_.set(false);
/* Create PositionAttitudeTransform */
......
......@@ -42,7 +42,7 @@ namespace viewer {
{
/* Init the beam as a Geometry */
beam_ptr_ = new ::osg::Geometry();
backfaceDrawing_.node(beam_ptr_);
backfaceDrawing_.stateSet(beam_ptr_->getOrCreateStateSet());
backfaceDrawing_.set(false);
/* Define points of the beam */
......@@ -72,10 +72,10 @@ namespace viewer {
/* Set a default line width */
osg::LineWidth* linewidth = new osg::LineWidth();
linewidth->setWidth(1.0f);
beam_ptr_->getOrCreateStateSet()->setAttributeAndModes(linewidth, osg::StateAttribute::ON);
beam_ptr_->getStateSet()->setAttributeAndModes(linewidth, osg::StateAttribute::ON);
osg::Point* point = new osg::Point(3.f);
beam_ptr_->getOrCreateStateSet()->setAttribute(point, osg::StateAttribute::ON);
beam_ptr_->getStateSet()->setAttribute(point, osg::StateAttribute::ON);
addProperty(FloatProperty::create("PointSize",
FloatProperty::getterFromMemberFunction(point, &osg::Point::getSize),
......
......@@ -11,8 +11,8 @@ namespace viewer {
bool BackfaceDrawingProperty::impl_get(bool& value)
{
if (!hasReadAccess ()) { invalidGet(); return false; }
value = static_cast<bool>(node_->getOrCreateStateSet()
->getMode(GL_CULL_FACE) & osg::StateAttribute::ON);
value = static_cast<bool>(stateSet_->getMode(GL_CULL_FACE)
& osg::StateAttribute::ON);
return true;
}
......@@ -20,19 +20,17 @@ bool BackfaceDrawingProperty::impl_set (const bool& on)
{
if (!hasWriteAccess()) { invalidSet(); return false; }
osg::StateSet* ss = node_->getOrCreateStateSet();
ss->setMode(GL_CULL_FACE,
stateSet_->setMode(GL_CULL_FACE,
(on ? osg::StateAttribute::ON : osg::StateAttribute::OFF));
if (on) {
osg::LightModel* ltModel = new osg::LightModel;
ltModel->setTwoSided(on);
ss->setAttribute(ltModel);
ss->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
stateSet_->setAttribute(ltModel);
stateSet_->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
} else {
ss->removeAttribute(osg::StateAttribute::LIGHTMODEL);
ss->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
stateSet_->removeAttribute(osg::StateAttribute::LIGHTMODEL);
stateSet_->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
}
return true;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment