#include "cVertex.h"

void cVertex::getSumForwardFacingNormal(cVector& incident, cVector& normal)
{
    normal = cVector();
    for(int i = 0; i < numFaces_; ++i)
    {
        if(triangles_[i]->forwardFacing(incident))
        {
            normal += triangles_[i]->getNormal();
        }
    }
}

void cVertex::computeVertexNormal()
{
    normal_ = cVector(0,0.0001,0); 	// somehow we have a 0 normal somewhere, this is just a hackish fix
                                        // however, this only affects drawing, so it doesnt matter
    
    for(int i = 0; i < numFaces_; ++i)
        normal_ += triangles_[i]->getNormal();
      
    normal_.normalize();
}



