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:
parent
cbd14833fd
commit
aee1edaf9e
1 changed files with 51 additions and 29 deletions
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue