1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 15:29:55 +00:00

Partially revert "Attach shaders to geometry that lacks a stateset if necessary"

This reverts commit 6aef366fd3.
This commit is contained in:
AnyOldName3 2023-03-08 00:15:49 +00:00
parent cbd14833fd
commit aee1edaf9e

View file

@ -865,51 +865,73 @@ namespace Shader
void ShaderVisitor::apply(osg::Geometry& geometry) void ShaderVisitor::apply(osg::Geometry& geometry)
{ {
pushRequirements(geometry); bool needPop = (geometry.getStateSet() != nullptr);
if (geometry.getStateSet()) // TODO: check if stateset affects shader permutation before pushing it if (geometry.getStateSet()) // TODO: check if stateset affects shader permutation before pushing it
{
pushRequirements(geometry);
applyStateSet(geometry.getStateSet(), geometry); applyStateSet(geometry.getStateSet(), geometry);
}
const ShaderRequirements& reqs = mRequirements.back(); if (!mRequirements.empty())
adjustGeometry(geometry, reqs); {
createProgram(reqs); const ShaderRequirements& reqs = mRequirements.back();
popRequirements(); adjustGeometry(geometry, reqs);
createProgram(reqs);
}
else
ensureFFP(geometry);
if (needPop)
popRequirements();
} }
void ShaderVisitor::apply(osg::Drawable& drawable) void ShaderVisitor::apply(osg::Drawable& drawable)
{ {
pushRequirements(drawable); bool needPop = drawable.getStateSet();
if (drawable.getStateSet()) if (needPop)
applyStateSet(drawable.getStateSet(), drawable);
const ShaderRequirements& reqs = mRequirements.back();
createProgram(reqs);
if (auto rig = dynamic_cast<SceneUtil::RigGeometry*>(&drawable))
{ {
osg::ref_ptr<osg::Geometry> sourceGeometry = rig->getSourceGeometry(); pushRequirements(drawable);
if (sourceGeometry && adjustGeometry(*sourceGeometry, reqs))
rig->setSourceGeometry(sourceGeometry); if (drawable.getStateSet())
applyStateSet(drawable.getStateSet(), drawable);
} }
else if (auto morph = dynamic_cast<SceneUtil::MorphGeometry*>(&drawable))
if (!mRequirements.empty())
{ {
osg::ref_ptr<osg::Geometry> sourceGeometry = morph->getSourceGeometry(); const ShaderRequirements& reqs = mRequirements.back();
if (sourceGeometry && adjustGeometry(*sourceGeometry, reqs)) createProgram(reqs);
morph->setSourceGeometry(sourceGeometry);
} if (auto rig = dynamic_cast<SceneUtil::RigGeometry*>(&drawable))
else if (auto osgaRig = dynamic_cast<SceneUtil::RigGeometryHolder*>(&drawable))
{
osg::ref_ptr<SceneUtil::OsgaRigGeometry> sourceOsgaRigGeometry = osgaRig->getSourceRigGeometry();
osg::ref_ptr<osg::Geometry> sourceGeometry = sourceOsgaRigGeometry->getSourceGeometry();
if (sourceGeometry && adjustGeometry(*sourceGeometry, reqs))
{ {
sourceOsgaRigGeometry->setSourceGeometry(sourceGeometry); osg::ref_ptr<osg::Geometry> sourceGeometry = rig->getSourceGeometry();
osgaRig->setSourceRigGeometry(sourceOsgaRigGeometry); if (sourceGeometry && adjustGeometry(*sourceGeometry, reqs))
rig->setSourceGeometry(sourceGeometry);
}
else if (auto morph = dynamic_cast<SceneUtil::MorphGeometry*>(&drawable))
{
osg::ref_ptr<osg::Geometry> sourceGeometry = morph->getSourceGeometry();
if (sourceGeometry && adjustGeometry(*sourceGeometry, reqs))
morph->setSourceGeometry(sourceGeometry);
}
else if (auto osgaRig = dynamic_cast<SceneUtil::RigGeometryHolder*>(&drawable))
{
osg::ref_ptr<SceneUtil::OsgaRigGeometry> sourceOsgaRigGeometry = osgaRig->getSourceRigGeometry();
osg::ref_ptr<osg::Geometry> sourceGeometry = sourceOsgaRigGeometry->getSourceGeometry();
if (sourceGeometry && adjustGeometry(*sourceGeometry, reqs))
{
sourceOsgaRigGeometry->setSourceGeometry(sourceGeometry);
osgaRig->setSourceRigGeometry(sourceOsgaRigGeometry);
}
} }
} }
else
ensureFFP(drawable);
popRequirements(); if (needPop)
popRequirements();
} }
void ShaderVisitor::setAllowedToModifyStateSets(bool allowed) void ShaderVisitor::setAllowedToModifyStateSets(bool allowed)