mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 10:53:51 +00:00
#5463: Optimizer fix, problem was indeed related to tangents not being transformd properly.
This commit is contained in:
parent
142a9e772b
commit
f94ca28dbe
1 changed files with 19 additions and 4 deletions
|
@ -358,6 +358,21 @@ void CollectLowestTransformsVisitor::doTransform(osg::Object* obj,osg::Matrix& m
|
||||||
{
|
{
|
||||||
osgUtil::TransformAttributeFunctor tf(matrix);
|
osgUtil::TransformAttributeFunctor tf(matrix);
|
||||||
drawable->accept(tf);
|
drawable->accept(tf);
|
||||||
|
|
||||||
|
osg::Geometry *geom = drawable->asGeometry();
|
||||||
|
osg::Vec4Array* tangents = geom ? dynamic_cast<osg::Vec4Array*>(geom->getTexCoordArray(7)) : nullptr;
|
||||||
|
if (tangents)
|
||||||
|
{
|
||||||
|
for (unsigned int i=0; i<tangents->size(); ++i)
|
||||||
|
{
|
||||||
|
osg::Vec4f& itr = (*tangents)[i];
|
||||||
|
osg::Vec3f vec3 (itr.x(), itr.y(), itr.z());
|
||||||
|
vec3 = osg::Matrix::transform3x3(tf._im, vec3);
|
||||||
|
vec3.normalize();
|
||||||
|
itr = osg::Vec4f(vec3.x(), vec3.y(), vec3.z(), itr.w());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
drawable->dirtyBound();
|
drawable->dirtyBound();
|
||||||
drawable->dirtyDisplayList();
|
drawable->dirtyDisplayList();
|
||||||
|
|
||||||
|
@ -614,12 +629,12 @@ void Optimizer::FlattenStaticTransformsVisitor::apply(osg::Drawable& drawable)
|
||||||
if((geometry) && (isOperationPermissibleForObject(&drawable)))
|
if((geometry) && (isOperationPermissibleForObject(&drawable)))
|
||||||
{
|
{
|
||||||
osg::VertexBufferObject* vbo = nullptr;
|
osg::VertexBufferObject* vbo = nullptr;
|
||||||
if(geometry->getVertexArray() && geometry->getVertexArray()->referenceCount() > 1) {
|
if(geometry->getVertexArray() && geometry->getVertexArray()->referenceCount() > 1)
|
||||||
geometry->setVertexArray(cloneArray(geometry->getVertexArray(), vbo, geometry));
|
geometry->setVertexArray(cloneArray(geometry->getVertexArray(), vbo, geometry));
|
||||||
}
|
if(geometry->getNormalArray() && geometry->getNormalArray()->referenceCount() > 1)
|
||||||
if(geometry->getNormalArray() && geometry->getNormalArray()->referenceCount() > 1) {
|
|
||||||
geometry->setNormalArray(cloneArray(geometry->getNormalArray(), vbo, geometry));
|
geometry->setNormalArray(cloneArray(geometry->getNormalArray(), vbo, geometry));
|
||||||
}
|
if(geometry->getTexCoordArray(7) && geometry->getTexCoordArray(7)->referenceCount() > 1) // tangents
|
||||||
|
geometry->setTexCoordArray(7, cloneArray(geometry->getTexCoordArray(7), vbo, geometry));
|
||||||
}
|
}
|
||||||
_drawableSet.insert(&drawable);
|
_drawableSet.insert(&drawable);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue