GCC Code Coverage Report


Directory: ./
File: src/properties.cpp
Date: 2024-08-14 11:04:57
Exec Total Coverage
Lines: 0 20 0.0%
Branches: 0 10 0.0%

Line Branch Exec Source
1 // Copyright (c) 2020, Joseph Mirabel
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3
4 #include <gepetto/viewer/properties.h>
5
6 #include <osg/CullFace>
7 #include <osg/LightModel>
8
9 namespace gepetto {
10 namespace viewer {
11 bool BackfaceDrawingProperty::impl_get(bool& value) {
12 if (!hasReadAccess()) {
13 invalidGet();
14 return false;
15 }
16 value = static_cast<bool>(stateSet_->getMode(GL_CULL_FACE) &
17 osg::StateAttribute::ON);
18 return true;
19 }
20
21 bool BackfaceDrawingProperty::impl_set(const bool& on) {
22 if (!hasWriteAccess()) {
23 invalidSet();
24 return false;
25 }
26
27 stateSet_->setMode(GL_CULL_FACE,
28 (on ? osg::StateAttribute::ON : osg::StateAttribute::OFF));
29
30 if (on) {
31 osg::LightModel* ltModel = new osg::LightModel;
32 ltModel->setTwoSided(on);
33 stateSet_->setAttribute(ltModel);
34 stateSet_->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
35 } else {
36 stateSet_->removeAttribute(osg::StateAttribute::LIGHTMODEL);
37 stateSet_->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
38 }
39 return true;
40 }
41
42 } /* namespace viewer */
43 } /* namespace gepetto */
44