fix: unable to display models if indices are not contiguous in the input file (#2248)

If you tried to collect the indices using addressof like stl pattern
collects vertices you get a small square for visualizer and no error
message. The changes here are able to extract the indices if they can be
extracted and give an error message if they can't.
This commit is contained in:
paxcut
2025-05-14 22:08:16 -07:00
committed by GitHub
parent 828951ffe9
commit 8f222dab99
2 changed files with 8 additions and 1 deletions

View File

@@ -923,7 +923,13 @@ namespace hex::plugin::visualizers {
auto *iterable = dynamic_cast<pl::ptrn::IIterable*>(indicesPattern.get());
if (iterable != nullptr && iterable->getEntryCount() > 0) {
const auto &content = iterable->getEntry(0);
auto content = iterable->getEntry(0);
while (content->getSize() == 0) {
auto children = content->getChildren();
if (children.size() == 0)
throw std::runtime_error("hex.visualizers.pl_visualizer.3d.error_message_invalid_index_pattern"_lang.get());
content = static_cast<const std::shared_ptr<pl::ptrn::Pattern>>(children.begin()->second);
}
if (content->getSize() == 1) {
s_indexType = IndexType::U8;
processRendering<u8>(verticesPattern, indicesPattern, normalsPattern, colorsPattern, uvPattern);