From 814b56e5e2c6da331c6b4f71b5f167ff2fa5afb1 Mon Sep 17 00:00:00 2001 From: wuxq Date: Sat, 28 Apr 2018 15:05:21 +0800 Subject: [PATCH 1/2] multi joint has bug with ReplaceData multi joint has a bug in ReplaceData_joint with "bin" change --- code/glTF2Exporter.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/code/glTF2Exporter.cpp b/code/glTF2Exporter.cpp index fcf8005ae..9bd9bae33 100644 --- a/code/glTF2Exporter.cpp +++ b/code/glTF2Exporter.cpp @@ -642,9 +642,8 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref& meshRef, RefbufferView->byteLength; unsigned int s_bytesPerComp= ComponentTypeSize(ComponentType_UNSIGNED_SHORT); unsigned int bytesPerComp = ComponentTypeSize(vertexJointAccessor->componentType); - unsigned int s_bytesLen = bytesLen * s_bytesPerComp / bytesPerComp; Ref buf = vertexJointAccessor->bufferView->buffer; - uint8_t* arrys = new uint8_t[s_bytesLen]; + uint8_t* arrys = new uint8_t[bytesLen]; unsigned int i = 0; for ( unsigned int j = 0; j <= bytesLen; j += bytesPerComp ){ size_t len_p = offset + j; @@ -655,7 +654,7 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref& meshRef, RefReplaceData_joint(offset, bytesLen, arrys, s_bytesLen); + buf->ReplaceData_joint(offset, bytesLen, arrys, bytesLen); vertexJointAccessor->componentType = ComponentType_UNSIGNED_SHORT; p.attributes.joint.push_back( vertexJointAccessor ); From cc1bde0514773ff9b96ca2284215e20545017f4a Mon Sep 17 00:00:00 2001 From: wuxq Date: Tue, 8 May 2018 18:31:27 +0800 Subject: [PATCH 2/2] change the length of bufferView byteLength chang the joint attribute bufferView byteLength --- code/glTF2Exporter.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/glTF2Exporter.cpp b/code/glTF2Exporter.cpp index 431046d72..041250bee 100644 --- a/code/glTF2Exporter.cpp +++ b/code/glTF2Exporter.cpp @@ -642,6 +642,7 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref& meshRef, RefbufferView->byteLength; unsigned int s_bytesPerComp= ComponentTypeSize(ComponentType_UNSIGNED_SHORT); unsigned int bytesPerComp = ComponentTypeSize(vertexJointAccessor->componentType); + unsigned int s_bytesLen = bytesLen * s_bytesPerComp / bytesPerComp; Ref buf = vertexJointAccessor->bufferView->buffer; uint8_t* arrys = new uint8_t[bytesLen]; unsigned int i = 0; @@ -656,6 +657,7 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref& meshRef, RefReplaceData_joint(offset, bytesLen, arrys, bytesLen); vertexJointAccessor->componentType = ComponentType_UNSIGNED_SHORT; + vertexJointAccessor->bufferView->byteLength = s_bytesLen; p.attributes.joint.push_back( vertexJointAccessor ); }