Sfoglia il codice sorgente

Merge pull request #1925 from wuxq/fix_gltf2_export_componentType_error

multi joint has bug  with ReplaceData
Kim Kulling 7 anni fa
parent
commit
0b77ebbb3e
1 ha cambiato i file con 3 aggiunte e 2 eliminazioni
  1. 3 2
      code/glTF2Exporter.cpp

+ 3 - 2
code/glTF2Exporter.cpp

@@ -641,7 +641,7 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref<Mesh>& meshRef, Ref<Buf
         unsigned int bytesPerComp = ComponentTypeSize(vertexJointAccessor->componentType);
         unsigned int bytesPerComp = ComponentTypeSize(vertexJointAccessor->componentType);
         size_t s_bytesLen = bytesLen * s_bytesPerComp / bytesPerComp;
         size_t s_bytesLen = bytesLen * s_bytesPerComp / bytesPerComp;
         Ref<Buffer> buf = vertexJointAccessor->bufferView->buffer;
         Ref<Buffer> buf = vertexJointAccessor->bufferView->buffer;
-        uint8_t* arrys = new uint8_t[s_bytesLen];
+        uint8_t* arrys = new uint8_t[bytesLen];
         unsigned int i = 0;
         unsigned int i = 0;
         for ( unsigned int j = 0; j <= bytesLen; j += bytesPerComp ){
         for ( unsigned int j = 0; j <= bytesLen; j += bytesPerComp ){
             size_t len_p = offset + j;
             size_t len_p = offset + j;
@@ -652,8 +652,9 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref<Mesh>& meshRef, Ref<Buf
             memcpy(&arrys[i*s_bytesPerComp], data, s_bytesPerComp);
             memcpy(&arrys[i*s_bytesPerComp], data, s_bytesPerComp);
             ++i;
             ++i;
         }
         }
-        buf->ReplaceData_joint(offset, bytesLen, arrys, s_bytesLen);
+        buf->ReplaceData_joint(offset, bytesLen, arrys, bytesLen);
         vertexJointAccessor->componentType = ComponentType_UNSIGNED_SHORT;
         vertexJointAccessor->componentType = ComponentType_UNSIGNED_SHORT;
+        vertexJointAccessor->bufferView->byteLength = s_bytesLen;
 
 
         p.attributes.joint.push_back( vertexJointAccessor );
         p.attributes.joint.push_back( vertexJointAccessor );
     }
     }