1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-13 12:40:04 +00:00

Use state sets without transparency support for recast mesh and agents paths

This commit is contained in:
elsid 2024-05-19 02:14:56 +02:00
parent 98d530d8cb
commit 4b8897e33e
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625
5 changed files with 49 additions and 17 deletions

@ -8,6 +8,7 @@
#include <components/sceneutil/agentpath.hpp>
#include <components/sceneutil/detourdebugdraw.hpp>
#include <osg/LineWidth>
#include <osg/Material>
#include <osg/PositionAttitudeTransform>
#include <osg/StateSet>
@ -30,13 +31,21 @@ namespace MWRender
stateSet->setAttribute(material);
return stateSet;
}
osg::ref_ptr<osg::StateSet> makeDebugDrawStateSet()
{
osg::ref_ptr<osg::StateSet> stateSet = new osg::StateSet;
stateSet->setAttributeAndModes(new osg::LineWidth());
return stateSet;
}
}
ActorsPaths::ActorsPaths(const osg::ref_ptr<osg::Group>& root, bool enabled)
: mRootNode(root)
, mEnabled(enabled)
, mGroupStateSet(makeGroupStateSet())
, mDebugDrawStateSet(SceneUtil::DebugDraw::makeStateSet())
, mDebugDrawStateSet(makeDebugDrawStateSet())
{
}

@ -7,10 +7,13 @@
#include <components/detournavigator/settings.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/resource/scenemanager.hpp>
#include <components/sceneutil/depth.hpp>
#include <components/sceneutil/detourdebugdraw.hpp>
#include <components/sceneutil/navmesh.hpp>
#include <components/sceneutil/workqueue.hpp>
#include <osg/BlendFunc>
#include <osg/LineWidth>
#include <osg/PositionAttitudeTransform>
#include <osg/StateSet>
@ -23,6 +26,29 @@
namespace MWRender
{
namespace
{
osg::ref_ptr<osg::StateSet> makeDebugDrawStateSet()
{
const osg::ref_ptr<osg::LineWidth> lineWidth = new osg::LineWidth();
const osg::ref_ptr<osg::BlendFunc> blendFunc = new osg::BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
const osg::ref_ptr<SceneUtil::AutoDepth> depth = new SceneUtil::AutoDepth;
depth->setWriteMask(false);
osg::ref_ptr<osg::StateSet> stateSet = new osg::StateSet;
stateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
stateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
stateSet->setAttributeAndModes(lineWidth);
stateSet->setAttributeAndModes(blendFunc);
stateSet->setAttributeAndModes(depth);
return stateSet;
}
}
struct NavMesh::LessByTilePosition
{
bool operator()(const DetourNavigator::TilePosition& lhs,
@ -169,7 +195,7 @@ namespace MWRender
: mRootNode(root)
, mWorkQueue(workQueue)
, mGroupStateSet(SceneUtil::makeDetourGroupStateSet())
, mDebugDrawStateSet(SceneUtil::DebugDraw::makeStateSet())
, mDebugDrawStateSet(makeDebugDrawStateSet())
, mEnabled(enabled)
, mMode(mode)
, mId(std::numeric_limits<std::size_t>::max())

@ -17,11 +17,22 @@
namespace MWRender
{
namespace
{
osg::ref_ptr<osg::StateSet> makeDebugDrawStateSet()
{
osg::ref_ptr<osg::StateSet> stateSet = new osg::StateSet;
stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
return stateSet;
}
}
RecastMesh::RecastMesh(const osg::ref_ptr<osg::Group>& root, bool enabled)
: mRootNode(root)
, mEnabled(enabled)
, mGroupStateSet(SceneUtil::makeDetourGroupStateSet())
, mDebugDrawStateSet(SceneUtil::DebugDraw::makeStateSet())
, mDebugDrawStateSet(makeDebugDrawStateSet())
{
}

@ -108,18 +108,6 @@ namespace SceneUtil
mColors->push_back(value);
}
osg::ref_ptr<osg::StateSet> DebugDraw::makeStateSet()
{
osg::ref_ptr<osg::StateSet> stateSet = new osg::StateSet;
stateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
stateSet->setMode(GL_DEPTH, osg::StateAttribute::OFF);
stateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
stateSet->setAttributeAndModes(new osg::LineWidth());
stateSet->setAttributeAndModes(new osg::BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
return stateSet;
}
osg::ref_ptr<osg::StateSet> makeDetourGroupStateSet()
{
osg::ref_ptr<osg::Material> material = new osg::Material;

@ -18,8 +18,6 @@ namespace SceneUtil
explicit DebugDraw(osg::Group& group, const osg::ref_ptr<osg::StateSet>& stateSet, const osg::Vec3f& shift,
float recastInvertedScaleFactor);
static osg::ref_ptr<osg::StateSet> makeStateSet();
void depthMask(bool state) override;
void texture(bool state) override;