mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-10 21:40:15 +00:00
Fix crash when NiGeometry lacks NiGeometryData
This commit is contained in:
parent
43a58e181f
commit
64fde2d7c2
@ -1072,28 +1072,32 @@ namespace NifOsg
|
|||||||
if (nifNode->recType == Nif::RC_NiTriShape)
|
if (nifNode->recType == Nif::RC_NiTriShape)
|
||||||
{
|
{
|
||||||
const Nif::NiTriShape* triShape = static_cast<const Nif::NiTriShape*>(nifNode);
|
const Nif::NiTriShape* triShape = static_cast<const Nif::NiTriShape*>(nifNode);
|
||||||
const Nif::NiTriShapeData* data = triShape->data.getPtr();
|
if (const Nif::NiTriShapeData* data = triShape->data.getPtr())
|
||||||
vertexColorsPresent = !data->colors.empty();
|
{
|
||||||
triCommonToGeometry(geometry, data->vertices, data->normals, data->uvlist, data->colors, boundTextures, triShape->name);
|
vertexColorsPresent = !data->colors.empty();
|
||||||
if (!data->triangles.empty())
|
triCommonToGeometry(geometry, data->vertices, data->normals, data->uvlist, data->colors, boundTextures, triShape->name);
|
||||||
geometry->addPrimitiveSet(new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES, data->triangles.size(),
|
if (!data->triangles.empty())
|
||||||
(unsigned short*)data->triangles.data()));
|
geometry->addPrimitiveSet(new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES, data->triangles.size(),
|
||||||
|
(unsigned short*)data->triangles.data()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const Nif::NiTriStrips* triStrips = static_cast<const Nif::NiTriStrips*>(nifNode);
|
const Nif::NiTriStrips* triStrips = static_cast<const Nif::NiTriStrips*>(nifNode);
|
||||||
const Nif::NiTriStripsData* data = triStrips->data.getPtr();
|
if (const Nif::NiTriStripsData* data = triStrips->data.getPtr())
|
||||||
vertexColorsPresent = !data->colors.empty();
|
|
||||||
triCommonToGeometry(geometry, data->vertices, data->normals, data->uvlist, data->colors, boundTextures, triStrips->name);
|
|
||||||
if (!data->strips.empty())
|
|
||||||
{
|
{
|
||||||
for (const std::vector<unsigned short>& strip : data->strips)
|
vertexColorsPresent = !data->colors.empty();
|
||||||
|
triCommonToGeometry(geometry, data->vertices, data->normals, data->uvlist, data->colors, boundTextures, triStrips->name);
|
||||||
|
if (!data->strips.empty())
|
||||||
{
|
{
|
||||||
// Can't make a triangle from less than three vertices.
|
for (const std::vector<unsigned short>& strip : data->strips)
|
||||||
if (strip.size() < 3)
|
{
|
||||||
continue;
|
// Can't make a triangle from less than three vertices.
|
||||||
geometry->addPrimitiveSet(new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLE_STRIP, strip.size(),
|
if (strip.size() < 3)
|
||||||
(unsigned short*)strip.data()));
|
continue;
|
||||||
|
geometry->addPrimitiveSet(new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLE_STRIP, strip.size(),
|
||||||
|
(unsigned short*)strip.data()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user