Skip to content

Commit

Permalink
Added check to prevent div by zero in normalization in vboteapot
Browse files Browse the repository at this point in the history
  • Loading branch information
dangets committed Oct 27, 2013
1 parent 35e3571 commit 2594cbf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ingredients/vboteapot.cpp
Expand Up @@ -261,7 +261,13 @@ vec3 VBOTeapot::evaluateNormal( int gridU, int gridV, float *B, float *dB, vec3
dv += patch[i][j] * B[gridU*4+i] * dB[gridV*4+j];
}
}
return glm::normalize( glm::cross( du, dv ) );

vec3 norm = glm::cross(du, dv);
if (glm::length(norm) != 0.0f) {
norm = glm::normalize(norm);
}

return norm;
}

void VBOTeapot::render() const {
Expand Down

0 comments on commit 2594cbf

Please sign in to comment.