This patch fixes two issue:
1. Fix the calculation of the blendshape normalization factor so that it can
handle smaller maximum distance between the original mesh and the deformed
mesh.
2. Apply the min and max properties of the accessor to all the elements in the
accessor, not just the elements in the sparse storage.
Change-Id: Iea90cbacf91fc7311242d9a47454b06afee82200
const float maxDistance = sqrtf(maxDistanceSquared);
const float maxDistance = sqrtf(maxDistanceSquared);
- const float normalizeFactor = (maxDistanceSquared < Math::MACHINE_EPSILON_1000) ? 1.f : (0.5f / maxDistance);
+ const float normalizeFactor = (maxDistanceSquared < Math::MACHINE_EPSILON_100) ? 1.f : (0.5f / maxDistance);
// Calculate and store the unnormalize factor.
blendShapeUnnormalizeFactor = maxDistance * 2.0f;
// Calculate and store the unnormalize factor.
blendShapeUnnormalizeFactor = maxDistance * 2.0f;
- // If there are sparse indices then process only relevant data
- if(sparseIndices && !sparseIndices->empty())
+ auto end = values + count * numComponents;
+ while(values != end)
- for(auto elementIndex : *sparseIndices)
+ auto nextElement = values + numComponents;
+ uint32_t i = 0;
+ while(values != nextElement)
- auto value = values + (elementIndex * numComponents);
- for(auto i = 0u; i < numComponents; ++i)
- {
- clampFn(min.data(), max.data(), i, *value);
- }
- }
- }
- else // if there's no sparse indices process all vertices
- {
- auto end = values + count * numComponents;
- while(values != end)
- {
- auto nextElement = values + numComponents;
- uint32_t i = 0;
- while(values != nextElement)
- {
- clampFn(min.data(), max.data(), i, *values);
- ++values;
- ++i;
- }
+ clampFn(min.data(), max.data(), i, *values);
+ ++values;
+ ++i;