Commit 99cfad9d authored by hybrid's avatar hybrid

Normals recalculation fix by Squarefox

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3990 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 83444c6b
...@@ -106,14 +106,15 @@ void recalculateNormalsT(IMeshBuffer* buffer, bool smooth, bool angleWeighted) ...@@ -106,14 +106,15 @@ void recalculateNormalsT(IMeshBuffer* buffer, bool smooth, bool angleWeighted)
const core::vector3df& v1 = buffer->getPosition(idx[i+0]); const core::vector3df& v1 = buffer->getPosition(idx[i+0]);
const core::vector3df& v2 = buffer->getPosition(idx[i+1]); const core::vector3df& v2 = buffer->getPosition(idx[i+1]);
const core::vector3df& v3 = buffer->getPosition(idx[i+2]); const core::vector3df& v3 = buffer->getPosition(idx[i+2]);
core::vector3df normal = core::plane3d<f32>(v1, v2, v3).Normal; const core::vector3df normal = core::plane3d<f32>(v1, v2, v3).Normal;
core::vector3df weight(1.f,1.f,1.f);
if (angleWeighted) if (angleWeighted)
normal *= getAngleWeight(v1,v2,v3); weight = getAngleWeight(v1,v2,v3);
buffer->getNormal(idx[i+0]) += normal; buffer->getNormal(idx[i+0]) += weight.X*normal;
buffer->getNormal(idx[i+1]) += normal; buffer->getNormal(idx[i+1]) += weight.Y*normal;
buffer->getNormal(idx[i+2]) += normal; buffer->getNormal(idx[i+2]) += weight.Z*normal;
} }
for ( i = 0; i!= vtxcnt; ++i ) for ( i = 0; i!= vtxcnt; ++i )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment