mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-14 06:40:40 +00:00
Fix crash when NiGeometry lacks NiGeometryData
This commit is contained in:
parent
43a58e181f
commit
64fde2d7c2
@ -1072,17 +1072,20 @@ 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();
|
vertexColorsPresent = !data->colors.empty();
|
||||||
triCommonToGeometry(geometry, data->vertices, data->normals, data->uvlist, data->colors, boundTextures, triShape->name);
|
triCommonToGeometry(geometry, data->vertices, data->normals, data->uvlist, data->colors, boundTextures, triShape->name);
|
||||||
if (!data->triangles.empty())
|
if (!data->triangles.empty())
|
||||||
geometry->addPrimitiveSet(new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES, data->triangles.size(),
|
geometry->addPrimitiveSet(new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES, data->triangles.size(),
|
||||||
(unsigned short*)data->triangles.data()));
|
(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();
|
vertexColorsPresent = !data->colors.empty();
|
||||||
triCommonToGeometry(geometry, data->vertices, data->normals, data->uvlist, data->colors, boundTextures, triStrips->name);
|
triCommonToGeometry(geometry, data->vertices, data->normals, data->uvlist, data->colors, boundTextures, triStrips->name);
|
||||||
if (!data->strips.empty())
|
if (!data->strips.empty())
|
||||||
@ -1097,6 +1100,7 @@ namespace NifOsg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// osg::Material properties are handled here for two reasons:
|
// osg::Material properties are handled here for two reasons:
|
||||||
// - if there are no vertex colors, we need to disable colorMode.
|
// - if there are no vertex colors, we need to disable colorMode.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user