Clear blendshapes without memset

Avoids warning due to glm::vec3 not being trivially copyable
This commit is contained in:
Dale Glass 2022-06-23 21:24:28 +02:00 committed by HifiExperiments
parent 194eebf57c
commit 189f91b05d
2 changed files with 22 additions and 1 deletions

View file

@ -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;

View file

@ -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;