mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 08:09:41 +00:00
Use polygon offset to render navmesh and recast mesh
This commit is contained in:
parent
0511a81baa
commit
d1a1b8c01c
2 changed files with 20 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
||||||
#include "navmesh.hpp"
|
#include "navmesh.hpp"
|
||||||
#include "detourdebugdraw.hpp"
|
#include "detourdebugdraw.hpp"
|
||||||
|
#include "depth.hpp"
|
||||||
|
|
||||||
#include <components/detournavigator/settings.hpp>
|
#include <components/detournavigator/settings.hpp>
|
||||||
|
|
||||||
|
@ -7,6 +8,7 @@
|
||||||
|
|
||||||
#include <osg/Group>
|
#include <osg/Group>
|
||||||
#include <osg/Material>
|
#include <osg/Material>
|
||||||
|
#include <osg/PolygonOffset>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -241,7 +243,14 @@ namespace SceneUtil
|
||||||
|
|
||||||
osg::ref_ptr<osg::Material> material = new osg::Material;
|
osg::ref_ptr<osg::Material> material = new osg::Material;
|
||||||
material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
|
material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
|
||||||
group->getOrCreateStateSet()->setAttribute(material);
|
|
||||||
|
const float polygonOffsetFactor = SceneUtil::AutoDepth::isReversed() ? 1.0 : -1.0;
|
||||||
|
const float polygonOffsetUnits = SceneUtil::AutoDepth::isReversed() ? 1.0 : -1.0;
|
||||||
|
osg::ref_ptr<osg::PolygonOffset> polygonOffset = new osg::PolygonOffset(polygonOffsetFactor, polygonOffsetUnits);
|
||||||
|
|
||||||
|
osg::ref_ptr<osg::StateSet> stateSet = group->getOrCreateStateSet();
|
||||||
|
stateSet->setAttribute(material);
|
||||||
|
stateSet->setAttributeAndModes(polygonOffset);
|
||||||
|
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "recastmesh.hpp"
|
#include "recastmesh.hpp"
|
||||||
#include "detourdebugdraw.hpp"
|
#include "detourdebugdraw.hpp"
|
||||||
|
#include "depth.hpp"
|
||||||
|
|
||||||
#include <components/detournavigator/settings.hpp>
|
#include <components/detournavigator/settings.hpp>
|
||||||
#include <components/detournavigator/recastmesh.hpp>
|
#include <components/detournavigator/recastmesh.hpp>
|
||||||
|
@ -9,6 +10,7 @@
|
||||||
|
|
||||||
#include <osg/Group>
|
#include <osg/Group>
|
||||||
#include <osg/Material>
|
#include <osg/Material>
|
||||||
|
#include <osg/PolygonOffset>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -69,7 +71,14 @@ namespace SceneUtil
|
||||||
|
|
||||||
osg::ref_ptr<osg::Material> material = new osg::Material;
|
osg::ref_ptr<osg::Material> material = new osg::Material;
|
||||||
material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
|
material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
|
||||||
group->getOrCreateStateSet()->setAttribute(material);
|
|
||||||
|
const float polygonOffsetFactor = SceneUtil::AutoDepth::isReversed() ? 1.0 : -1.0;
|
||||||
|
const float polygonOffsetUnits = SceneUtil::AutoDepth::isReversed() ? 1.0 : -1.0;
|
||||||
|
osg::ref_ptr<osg::PolygonOffset> polygonOffset = new osg::PolygonOffset(polygonOffsetFactor, polygonOffsetUnits);
|
||||||
|
|
||||||
|
osg::ref_ptr<osg::StateSet> stateSet = group->getOrCreateStateSet();
|
||||||
|
stateSet->setAttribute(material);
|
||||||
|
stateSet->setAttributeAndModes(polygonOffset);
|
||||||
|
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue