Fix compiler warning in Tube worklet

Older GCC compilers were giving warnings in the operator of the
GeneratePoints worklets for tubes because they could not completely
determine that variables were being properly initialized in the first
loop iteration (and therefore initialized for every subsequent
iteration). Fixed that by moving the initialization for the first
iteration outside of the loop.
This commit is contained in:
Kenneth Moreland 2019-11-06 17:06:11 -07:00
parent 05917e11a1
commit cd30bc5875

@ -304,19 +304,18 @@ public:
return;
else
{
vtkm::Vec3f n, p, pNext, sNext, sPrev;
vtkm::Id outIdx = tubePointOffsets;
vtkm::Id pIdx, pNextIdx;
vtkm::Id pIdx = ptIndices[0];
vtkm::Id pNextIdx = ptIndices[1];
vtkm::Vec3f p = inPts.Get(pIdx);
vtkm::Vec3f pNext = inPts.Get(pNextIdx);
vtkm::Vec3f sNext = pNext - p;
vtkm::Vec3f sPrev = sNext;
for (vtkm::IdComponent j = 0; j < numPoints; j++)
{
if (j == 0) //first point
{
pIdx = ptIndices[j];
pNextIdx = ptIndices[j + 1];
p = inPts.Get(pIdx);
pNext = inPts.Get(pNextIdx);
sNext = pNext - p;
sPrev = sNext;
//Variables initialized before loop started.
}
else if (j == numPoints - 1) //last point
{
@ -333,7 +332,7 @@ public:
sPrev = sNext;
sNext = pNext - p;
}
n = inNormals.Get(polylineOffset + j);
vtkm::Vec3f n = inNormals.Get(polylineOffset + j);
//Coincident points.
if (vtkm::Magnitude(sNext) <= vtkm::Epsilon<vtkm::FloatDefault>())