@@ -295,7 +295,20 @@ bool Model::updateGeometry() {
295
295
// TODO: should all Models have a valid _rig?
296
296
if (_rig.jointStatesEmpty () && getHFMModel ().joints .size () > 0 ) {
297
297
initJointStates ();
298
- assert (_meshStates.empty ());
298
+
299
+ if (!_meshStates.empty ()) {
300
+ // See https://github.com/vircadia/vircadia/issues/958 for a discussion of the issues found here with
301
+ // a previously existing assert, and the likely reasons for things going wrong here.
302
+ //
303
+ // TL;DR: There may be a threading issue, or it could be due to something lacking joints, which would cause
304
+ // initJointStates() to fail to make _rig.jointStatesEmpty() false, causing things to end up here twice.
305
+ //
306
+ // In any case it appears to be safe to simply clear _meshStates here, even though this shouldn't happen.
307
+ _meshStates.clear ();
308
+ qCWarning (renderutils) << " _meshStates has" << _meshStates.size () << " items when it should have none. Model with URL "
309
+ << _url.toString () << " ; translation" << _translation << " ; rotation" << _rotation << " ; scale" << _scale
310
+ << " ; joint state count" << _rig.getJointStateCount () << " ; type" << (modelProviderType == NestableType::Avatar ? " Avatar" : " Entity" );
311
+ }
299
312
300
313
const HFMModel& hfmModel = getHFMModel ();
301
314
int i = 0 ;
@@ -841,8 +854,8 @@ void Model::calculateTriangleSets(const HFMModel& hfmModel) {
841
854
int i2 = part.quadIndices [vIndex++];
842
855
int i3 = part.quadIndices [vIndex++];
843
856
844
- // track the model space version... these points will be transformed by the FST's offset,
845
- // which includes the scaling, rotation, and translation specified by the FST/FBX,
857
+ // track the model space version... these points will be transformed by the FST's offset,
858
+ // which includes the scaling, rotation, and translation specified by the FST/FBX,
846
859
// this can't change at runtime, so we can safely store these in our TriangleSet
847
860
glm::vec3 v0 = glm::vec3 (meshTransform * glm::vec4 (mesh.vertices [i0], 1 .0f ));
848
861
glm::vec3 v1 = glm::vec3 (meshTransform * glm::vec4 (mesh.vertices [i1], 1 .0f ));
@@ -863,8 +876,8 @@ void Model::calculateTriangleSets(const HFMModel& hfmModel) {
863
876
int i1 = part.triangleIndices [vIndex++];
864
877
int i2 = part.triangleIndices [vIndex++];
865
878
866
- // track the model space version... these points will be transformed by the FST's offset,
867
- // which includes the scaling, rotation, and translation specified by the FST/FBX,
879
+ // track the model space version... these points will be transformed by the FST's offset,
880
+ // which includes the scaling, rotation, and translation specified by the FST/FBX,
868
881
// this can't change at runtime, so we can safely store these in our TriangleSet
869
882
glm::vec3 v0 = glm::vec3 (meshTransform * glm::vec4 (mesh.vertices [i0], 1 .0f ));
870
883
glm::vec3 v1 = glm::vec3 (meshTransform * glm::vec4 (mesh.vertices [i1], 1 .0f ));
0 commit comments