1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 19:19:56 +00:00

Merge pull request #2505 from Capostrophic/crashfix

Avoid using getPtr() on empty geometry data
This commit is contained in:
Alexei Dobrohotov 2019-08-26 23:07:18 +03:00 committed by GitHub
commit 06c792e434
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1072,8 +1072,9 @@ 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);
if (const Nif::NiTriShapeData* data = triShape->data.getPtr()) if (!triShape->data.empty())
{ {
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())
@ -1084,8 +1085,9 @@ namespace NifOsg
else else
{ {
const Nif::NiTriStrips* triStrips = static_cast<const Nif::NiTriStrips*>(nifNode); const Nif::NiTriStrips* triStrips = static_cast<const Nif::NiTriStrips*>(nifNode);
if (const Nif::NiTriStripsData* data = triStrips->data.getPtr()) if (!triStrips->data.empty())
{ {
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())