slight refactoring
This commit is contained in:
parent
e01df69575
commit
47d28b4f1e
8 changed files with 79 additions and 73 deletions
|
@ -73,6 +73,7 @@ public:
|
|||
|
||||
void compute_normals();
|
||||
|
||||
void compute_bounds();
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -90,10 +91,6 @@ protected:
|
|||
|
||||
// TODO add weights, tangents etc. pp.
|
||||
|
||||
private:
|
||||
|
||||
void compute_bounds();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ void mesh::compute_normals()
|
|||
vertex3array_t normals; normals.resize(_vertices.size());
|
||||
|
||||
// for indexed-faceset
|
||||
for (auto i = 1; i < _indices.size()-1;i++)
|
||||
for (size_t i = 1; i < _indices.size()-1;i++)
|
||||
{
|
||||
// left index and right index
|
||||
auto il = (i - 1 + _indices.size()) % _indices.size();
|
||||
|
@ -26,13 +26,12 @@ void mesh::compute_normals()
|
|||
auto li = _indices[il];
|
||||
auto ri = _indices[ir];
|
||||
|
||||
// calculate delta vectors
|
||||
auto dL = vector3( _vertices[li] - _vertices[ci] );
|
||||
auto dR = vector3( _vertices[ri] - _vertices[ci] );
|
||||
// calculate edges between vertices
|
||||
auto edgeLeft = vector3( _vertices[li] - _vertices[ci] );
|
||||
auto edgeRight = vector3( _vertices[ri] - _vertices[ci] );
|
||||
|
||||
auto N = dR.cross(dL).normalized();
|
||||
|
||||
//auto dV = _vertices[idx0].cross(_vertices[idx1]);
|
||||
// calculate counter clockwise and normalize
|
||||
auto N = edgeRight.cross(edgeLeft).normalized();
|
||||
|
||||
// NOTE that addition is ugly
|
||||
normals[ci] = N + normals[ci];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue