mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-01 16:06:41 +00:00
Combine data check with data handling logic
This commit is contained in:
parent
4e8e8304aa
commit
19843af704
1 changed files with 20 additions and 21 deletions
|
@ -105,10 +105,28 @@ auto handleNiGeometry(const Nif::NiGeometry& geometry, Function&& function)
|
||||||
-> decltype(function(static_cast<const Nif::NiTriShapeData&>(geometry.data.get())))
|
-> decltype(function(static_cast<const Nif::NiTriShapeData&>(geometry.data.get())))
|
||||||
{
|
{
|
||||||
if (geometry.recType == Nif::RC_NiTriShape || geometry.recType == Nif::RC_BSLODTriShape)
|
if (geometry.recType == Nif::RC_NiTriShape || geometry.recType == Nif::RC_BSLODTriShape)
|
||||||
return function(static_cast<const Nif::NiTriShapeData&>(geometry.data.get()));
|
{
|
||||||
|
if (geometry.data->recType != Nif::RC_NiTriShapeData)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
auto data = static_cast<const Nif::NiTriShapeData*>(geometry.data.getPtr());
|
||||||
|
if (data->triangles.empty())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
return function(static_cast<const Nif::NiTriShapeData&>(*data));
|
||||||
|
}
|
||||||
|
|
||||||
if (geometry.recType == Nif::RC_NiTriStrips)
|
if (geometry.recType == Nif::RC_NiTriStrips)
|
||||||
return function(static_cast<const Nif::NiTriStripsData&>(geometry.data.get()));
|
{
|
||||||
|
if (geometry.data->recType != Nif::RC_NiTriStripsData)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
auto data = static_cast<const Nif::NiTriStripsData*>(geometry.data.getPtr());
|
||||||
|
if (data->strips.empty())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
return function(static_cast<const Nif::NiTriStripsData&>(*data));
|
||||||
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -372,25 +390,6 @@ void BulletNifLoader::handleNiTriShape(const Nif::NiGeometry& niGeometry, const
|
||||||
if (niGeometry.data.empty() || niGeometry.data->vertices.empty())
|
if (niGeometry.data.empty() || niGeometry.data->vertices.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (niGeometry.recType == Nif::RC_NiTriShape || niGeometry.recType == Nif::RC_BSLODTriShape)
|
|
||||||
{
|
|
||||||
if (niGeometry.data->recType != Nif::RC_NiTriShapeData)
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto data = static_cast<const Nif::NiTriShapeData*>(niGeometry.data.getPtr());
|
|
||||||
if (data->triangles.empty())
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (niGeometry.recType == Nif::RC_NiTriStrips)
|
|
||||||
{
|
|
||||||
if (niGeometry.data->recType != Nif::RC_NiTriStripsData)
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto data = static_cast<const Nif::NiTriStripsData*>(niGeometry.data.getPtr());
|
|
||||||
if (data->strips.empty())
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!niGeometry.skin.empty())
|
if (!niGeometry.skin.empty())
|
||||||
isAnimated = false;
|
isAnimated = false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue