1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-19 12:41:37 +00:00

Fix formatting

This commit is contained in:
Alexei Kotov 2023-09-27 17:20:30 +03:00
parent 0497fd111f
commit b4f81fb4fa
2 changed files with 16 additions and 16 deletions

View file

@ -138,7 +138,6 @@ namespace Nif
void read(NIFStream* nif); void read(NIFStream* nif);
}; };
NiGeometryDataPtr mData; NiGeometryDataPtr mData;
NiSkinInstancePtr mSkin; NiSkinInstancePtr mSkin;
MaterialData mMaterial; MaterialData mMaterial;

View file

@ -1533,7 +1533,8 @@ namespace NifOsg
continue; continue;
const std::vector<Nif::NiMorphData::MorphData>& morphs = nimorphctrl->mData.getPtr()->mMorphs; const std::vector<Nif::NiMorphData::MorphData>& morphs = nimorphctrl->mData.getPtr()->mMorphs;
if (morphs.empty() || morphs[0].mVertices.size() if (morphs.empty()
|| morphs[0].mVertices.size()
!= static_cast<const osg::Vec3Array*>(geom->getVertexArray())->size()) != static_cast<const osg::Vec3Array*>(geom->getVertexArray())->size())
continue; continue;
@ -1568,12 +1569,11 @@ namespace NifOsg
return; return;
osg::ref_ptr<osg::Geometry> geometry(new osg::Geometry); osg::ref_ptr<osg::Geometry> geometry(new osg::Geometry);
geometry->addPrimitiveSet(new osg::DrawElementsUShort( geometry->addPrimitiveSet(
osg::PrimitiveSet::TRIANGLES, triangles.size(), triangles.data())); new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES, triangles.size(), triangles.data()));
auto normbyteToFloat = [](uint8_t value) { return value / 255.f * 2.f - 1.f; }; auto normbyteToFloat = [](uint8_t value) { return value / 255.f * 2.f - 1.f; };
auto halfToFloat = [](uint16_t value) auto halfToFloat = [](uint16_t value) {
{
uint32_t bits = static_cast<uint32_t>(value & 0x8000) << 16; uint32_t bits = static_cast<uint32_t>(value & 0x8000) << 16;
const uint32_t exp16 = (value & 0x7c00) >> 10; const uint32_t exp16 = (value & 0x7c00) >> 10;
@ -1587,8 +1587,7 @@ namespace NifOsg
{ {
++offset; ++offset;
frac16 <<= 1; frac16 <<= 1;
} } while ((frac16 & 0x400) != 0x400);
while ((frac16 & 0x400) != 0x400);
frac16 &= 0x3ff; frac16 &= 0x3ff;
bits |= (0x71 - offset) << 23; bits |= (0x71 - offset) << 23;
} }
@ -1599,7 +1598,7 @@ namespace NifOsg
return result; return result;
}; };
const bool fullPrecision = bsTriShape->mVertDesc.mFlags & Nif::BSVertexDesc::VertexAttribute::Full_Precision; const bool fullPrec = bsTriShape->mVertDesc.mFlags & Nif::BSVertexDesc::VertexAttribute::Full_Precision;
const bool hasVertices = bsTriShape->mVertDesc.mFlags & Nif::BSVertexDesc::VertexAttribute::Vertex; const bool hasVertices = bsTriShape->mVertDesc.mFlags & Nif::BSVertexDesc::VertexAttribute::Vertex;
const bool hasNormals = bsTriShape->mVertDesc.mFlags & Nif::BSVertexDesc::VertexAttribute::Normals; const bool hasNormals = bsTriShape->mVertDesc.mFlags & Nif::BSVertexDesc::VertexAttribute::Normals;
const bool hasColors = bsTriShape->mVertDesc.mFlags & Nif::BSVertexDesc::VertexAttribute::Vertex_Colors; const bool hasColors = bsTriShape->mVertDesc.mFlags & Nif::BSVertexDesc::VertexAttribute::Vertex_Colors;
@ -1613,13 +1612,15 @@ namespace NifOsg
{ {
if (hasVertices) if (hasVertices)
{ {
if (fullPrecision) if (fullPrec)
vertices.emplace_back(elem.mVertex.x(), elem.mVertex.y(), elem.mVertex.z()); vertices.emplace_back(elem.mVertex.x(), elem.mVertex.y(), elem.mVertex.z());
else else
vertices.emplace_back(halfToFloat(elem.mHalfVertex[0]), halfToFloat(elem.mHalfVertex[1]), halfToFloat(elem.mHalfVertex[2])); vertices.emplace_back(halfToFloat(elem.mHalfVertex[0]), halfToFloat(elem.mHalfVertex[1]),
halfToFloat(elem.mHalfVertex[2]));
} }
if (hasNormals) if (hasNormals)
normals.emplace_back(normbyteToFloat(elem.mNormal[0]), normbyteToFloat(elem.mNormal[1]), normbyteToFloat(elem.mNormal[2])); normals.emplace_back(normbyteToFloat(elem.mNormal[0]), normbyteToFloat(elem.mNormal[1]),
normbyteToFloat(elem.mNormal[2]));
if (hasColors) if (hasColors)
colors.emplace_back(elem.mVertColor[0], elem.mVertColor[1], elem.mVertColor[2], elem.mVertColor[3]); colors.emplace_back(elem.mVertColor[0], elem.mVertColor[1], elem.mVertColor[2], elem.mVertColor[3]);
if (hasUV) if (hasUV)
@ -1635,8 +1636,8 @@ namespace NifOsg
geometry->setColorArray( geometry->setColorArray(
new osg::Vec4ubArray(colors.size(), colors.data()), osg::Array::BIND_PER_VERTEX); new osg::Vec4ubArray(colors.size(), colors.data()), osg::Array::BIND_PER_VERTEX);
if (!uvlist.empty()) if (!uvlist.empty())
geometry->setTexCoordArray(0, new osg::Vec2Array(uvlist.size(), uvlist.data()), geometry->setTexCoordArray(
osg::Array::BIND_PER_VERTEX); 0, new osg::Vec2Array(uvlist.size(), uvlist.data()), osg::Array::BIND_PER_VERTEX);
std::vector<const Nif::NiProperty*> drawableProps; std::vector<const Nif::NiProperty*> drawableProps;
collectDrawableProperties(nifNode, parent, drawableProps); collectDrawableProperties(nifNode, parent, drawableProps);