mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-24 22:43:47 +00:00
avoids creating empty statesets for collada nodes (#3128)
* avoids creating empty statesets for collada nodes With this PR we avoid creating empty statesets for collada nodes which will be detrimental to osg's draw performance. * scenemanager.cpp
This commit is contained in:
parent
fd251dfe55
commit
e41fe7573a
@ -243,19 +243,22 @@ namespace Resource
|
||||
|
||||
void apply(osg::Node& node) override
|
||||
{
|
||||
if (node.getOrCreateStateSet()->getRenderingHint() == osg::StateSet::TRANSPARENT_BIN)
|
||||
if (osg::StateSet* stateset = node.getStateSet())
|
||||
{
|
||||
osg::ref_ptr<osg::Depth> depth = SceneUtil::createDepth();
|
||||
depth->setWriteMask(false);
|
||||
if (stateset->getRenderingHint() == osg::StateSet::TRANSPARENT_BIN)
|
||||
{
|
||||
osg::ref_ptr<osg::Depth> depth = SceneUtil::createDepth();
|
||||
depth->setWriteMask(false);
|
||||
|
||||
node.getOrCreateStateSet()->setAttributeAndModes(depth, osg::StateAttribute::ON);
|
||||
}
|
||||
else if (node.getOrCreateStateSet()->getRenderingHint() == osg::StateSet::OPAQUE_BIN)
|
||||
{
|
||||
osg::ref_ptr<osg::Depth> depth = SceneUtil::createDepth();
|
||||
depth->setWriteMask(true);
|
||||
stateset->setAttributeAndModes(depth, osg::StateAttribute::ON);
|
||||
}
|
||||
else if (stateset->getRenderingHint() == osg::StateSet::OPAQUE_BIN)
|
||||
{
|
||||
osg::ref_ptr<osg::Depth> depth = SceneUtil::createDepth();
|
||||
depth->setWriteMask(true);
|
||||
|
||||
node.getOrCreateStateSet()->setAttributeAndModes(depth, osg::StateAttribute::ON);
|
||||
stateset->setAttributeAndModes(depth, osg::StateAttribute::ON);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if the <node> has <extra type="Node"> <technique profile="OpenSceneGraph"> <Descriptions> <Description>
|
||||
@ -268,22 +271,25 @@ namespace Resource
|
||||
}
|
||||
|
||||
// Iterate each description, and see if the current node uses the specified material for alpha testing
|
||||
for (auto description : mDescriptions)
|
||||
if (node.getStateSet())
|
||||
{
|
||||
std::vector<std::string> descriptionParts;
|
||||
std::istringstream descriptionStringStream(description);
|
||||
for (std::string part; std::getline(descriptionStringStream, part, ' ');)
|
||||
for (auto description : mDescriptions)
|
||||
{
|
||||
descriptionParts.emplace_back(part);
|
||||
}
|
||||
|
||||
if (descriptionParts.size() > (3) && descriptionParts.at(3) == node.getOrCreateStateSet()->getName())
|
||||
{
|
||||
if (descriptionParts.at(0) == "alphatest")
|
||||
std::vector<std::string> descriptionParts;
|
||||
std::istringstream descriptionStringStream(description);
|
||||
for (std::string part; std::getline(descriptionStringStream, part, ' ');)
|
||||
{
|
||||
osg::AlphaFunc::ComparisonFunction mode = getTestMode(descriptionParts.at(1));
|
||||
osg::ref_ptr<osg::AlphaFunc> alphaFunc (new osg::AlphaFunc(mode, std::stod(descriptionParts.at(2))));
|
||||
node.getOrCreateStateSet()->setAttributeAndModes(alphaFunc, osg::StateAttribute::ON);
|
||||
descriptionParts.emplace_back(part);
|
||||
}
|
||||
|
||||
if (descriptionParts.size() > (3) && descriptionParts.at(3) == node.getStateSet()->getName())
|
||||
{
|
||||
if (descriptionParts.at(0) == "alphatest")
|
||||
{
|
||||
osg::AlphaFunc::ComparisonFunction mode = getTestMode(descriptionParts.at(1));
|
||||
osg::ref_ptr<osg::AlphaFunc> alphaFunc (new osg::AlphaFunc(mode, std::stod(descriptionParts.at(2))));
|
||||
node.getStateSet()->setAttributeAndModes(alphaFunc, osg::StateAttribute::ON);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user