diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 69a593ed09..6ad2534038 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -1949,7 +1949,9 @@ void Blender::run() { blendedMeshSizes.push_back(numVertsInMesh); // initialize offsets to zero - memset(unpackedBlendshapeOffsets.data(), 0, numVertsInMesh * sizeof(BlendshapeOffsetUnpacked)); + for(BlendshapeOffsetUnpacked &bou : unpackedBlendshapeOffsets) { + bou.clear(); + } // for each blendshape in this mesh, accumulate the offsets into unpackedBlendshapeOffsets. const float NORMAL_COEFFICIENT_SCALE = 0.01f; diff --git a/libraries/shared/src/BlendshapeConstants.h b/libraries/shared/src/BlendshapeConstants.h index 596e7df4ee..b741059146 100644 --- a/libraries/shared/src/BlendshapeConstants.h +++ b/libraries/shared/src/BlendshapeConstants.h @@ -122,6 +122,25 @@ struct BlendshapeOffsetUnpacked { float positionOffsetX, positionOffsetY, positionOffsetZ; float normalOffsetX, normalOffsetY, normalOffsetZ; float tangentOffsetX, tangentOffsetY, tangentOffsetZ; + + /** + * @brief Set all components of all the offsets to zero + * + * @note glm::vec3 is not trivially copyable, so it's not correct to clear it with memset. + */ + void clear() { + positionOffsetX = 0.0f; + positionOffsetY = 0.0f; + positionOffsetZ = 0.0f; + + normalOffsetX = 0.0f; + normalOffsetY = 0.0f; + normalOffsetZ = 0.0f; + + tangentOffsetX = 0.0f; + tangentOffsetY = 0.0f; + tangentOffsetZ = 0.0f; + } }; using BlendshapeOffset = BlendshapeOffsetPacked;