255 smoothNormalArray = normalArray;
268 debugAssert(vertexArray.size() == normalArray.size());
269 smoothNormalArray.resize(normalArray.size());
278 static const int k = 8;
281 Table<Point3, SmallArray<Vector3, k> > normalTable;
282 for (
int v = 0; v < vertexArray.size(); ++v) {
284 SmallArray<Vector3, k>& list = normalTable.getCreate(vertexArray[v], ignore);
285 list.append(normalArray[v]);
288 for (
int v = 0; v < vertexArray.size(); ++v) {
291 const Vector3& original = normalArray[v];
293 const SmallArray<Vector3, k>& list = normalTable[vertexArray[v]];
295 for (
int i = 0; i < list.size(); ++i) {
296 const Vector3& N = list[i];
297 const float cosAngle = N.dot(original);
299 if (cosAngle > cosThresholdAngle) {
305 const Vector3& average = sum.directionOrZero();
307 const bool indeterminate = average.isZero();
309 const bool backFacing = original.dot(average) < 0;
311 if (indeterminate || backFacing) {
313 smoothNormalArray[v] = original;
316 smoothNormalArray[v] = average;
323 debugPrintf(
"Taking slower weld path because vertexWeldRadius = %f\n",
330 for (
int v = 0; v < normalArray.size(); ++v) {
331 grid.insert(VN(vertexArray[v], normalArray[v]));
335 for (
int v = 0; v < normalArray.size(); ++v) {
339 PointHashGrid<VN>::SphereIterator it =
344 const Vector3& original = normalArray[v];
345 while (it.isValid()) {
346 const Vector3& N = it->normal;
347 const float cosAngle = N.dot(original);
349 if (cosAngle > cosThresholdAngle) {
356 const Vector3& average = sum.directionOrZero();
358 const bool indeterminate = average.isZero();
360 const bool backFacing = original.dot(average) < 0;
362 if (indeterminate || backFacing) {
364 smoothNormalArray[v] = original;
367 smoothNormalArray[v] = average;
std::string __cdecl debugPrintf(const char *fmt...) G3D_CHECK_PRINTF_ARGS
Definition: debugAssert.cpp:355
static MemoryManager::Ref create()
Definition: MemoryManager.cpp:35
int iRound(double fValue)
Definition: g3dmath.h:226
shared_ptr< class MemoryManager > Ref
Definition: MemoryManager.h:31
float normalSmoothingAngle
Definition: Welder.cpp:94
#define debugAssert(exp)
Definition: debugAssert.h:160
float vertexWeldRadius
Definition: Welder.cpp:89
#define alwaysAssertM(exp, message)
Definition: debugAssert.h:165