Print bound textures in BC (feature #7194)

7220-lua-add-a-general-purpose-lexical-parser
Alexei Kotov 1 year ago
parent a41cbfb349
commit 192f79841b

@ -48,6 +48,7 @@
Feature #7087: Block resolution change in the Windowed Fullscreen mode
Feature #7130: Ability to set MyGUI logging verbosity
Feature #7148: Optimize string literal lookup in mwscript
Feature #7194: Ori to show texture paths
Task #7117: Replace boost::scoped_array with std::vector
Task #7151: Do not use std::strerror to get errno error message

@ -21,6 +21,8 @@
#include <components/resource/resourcesystem.hpp>
#include <components/resource/scenemanager.hpp>
#include <components/sceneutil/positionattitudetransform.hpp>
#include <components/esm3/loadacti.hpp>
#include <components/esm3/loadalch.hpp>
#include <components/esm3/loadappa.hpp>
@ -75,6 +77,41 @@
namespace
{
struct TextureFetchVisitor : osg::NodeVisitor
{
std::vector<std::pair<std::string, std::string>> mTextures;
TextureFetchVisitor(osg::NodeVisitor::TraversalMode mode = TRAVERSE_ALL_CHILDREN)
: osg::NodeVisitor(mode)
{
}
void apply(osg::Node& node) override
{
const osg::StateSet* stateset = node.getStateSet();
if (stateset)
{
const osg::StateSet::TextureAttributeList& texAttributes = stateset->getTextureAttributeList();
for (size_t i = 0; i < texAttributes.size(); i++)
{
const osg::StateAttribute* attr = stateset->getTextureAttribute(i, osg::StateAttribute::TEXTURE);
if (!attr)
continue;
const osg::Texture* texture = attr->asTexture();
if (!texture)
continue;
const osg::Image* image = texture->getImage(0);
std::string fileName;
if (image)
fileName = image->getFileName();
mTextures.emplace_back(texture->getName(), fileName);
}
}
traverse(node);
}
};
void addToLevList(ESM::LevelledListBase* list, const ESM::RefId& itemId, int level)
{
for (auto& levelItem : list->mList)
@ -1384,6 +1421,38 @@ namespace MWScript
const std::string archive = vfs->getArchive(model);
if (!archive.empty())
msg << "(" << archive << ")" << std::endl;
TextureFetchVisitor visitor;
SceneUtil::PositionAttitudeTransform* baseNode = ptr.getRefData().getBaseNode();
if (baseNode)
baseNode->accept(visitor);
msg << "Bound textures: ";
if (!visitor.mTextures.empty())
{
msg << std::endl;
std::string lastTextureSrc;
for (auto& [textureName, fileName] : visitor.mTextures)
{
std::string textureSrc;
if (!fileName.empty())
textureSrc = vfs->getArchive(fileName);
if (lastTextureSrc.empty() || textureSrc != lastTextureSrc)
{
lastTextureSrc = textureSrc;
if (lastTextureSrc.empty())
lastTextureSrc = "[No Source]";
msg << " " << lastTextureSrc << std::endl;
}
msg << " ";
msg << (textureName.empty() ? "[Anonymous]: " : textureName) << ": ";
msg << (fileName.empty() ? "[No File]" : fileName) << std::endl;
}
}
else
{
msg << "[None]" << std::endl;
}
}
if (!ptr.getClass().getScript(ptr).empty())
msg << "Script: " << ptr.getClass().getScript(ptr) << std::endl;

Loading…
Cancel
Save