@@ -1065,14 +1065,14 @@ bool RenderSystem::drawMesh(MeshComponent& mesh, Transform& transform, CameraCom
10651065 }
10661066
10671067 if (mesh.submeshes [i].hasSkinning ){
1068- render.applyUniformBlock (mesh.submeshes [i].slotVSSkinning , sizeof (Matrix4 ) * mesh. bonesMatrix . size () + (sizeof (float ) * 4 ), mesh.bonesMatrix . data () );
1068+ render.applyUniformBlock (mesh.submeshes [i].slotVSSkinning , sizeof (float ) * 16 * MAX_BONES + (sizeof (float ) * 4 ), & mesh.bonesMatrix );
10691069 }
10701070
10711071 if (mesh.submeshes [i].hasMorphTarget ){
10721072 if (!mesh.submeshes [i].hasMorphNormal && !mesh.submeshes [i].hasMorphTangent ){
1073- render.applyUniformBlock (mesh.submeshes [i].slotVSMorphTarget , sizeof (float ) * mesh. morphWeights . size (), mesh.morphWeights . data () );
1073+ render.applyUniformBlock (mesh.submeshes [i].slotVSMorphTarget , sizeof (float ) * MAX_MORPHTARGETS , & mesh.morphWeights );
10741074 }else {
1075- render.applyUniformBlock (mesh.submeshes [i].slotVSMorphTarget , sizeof (float ) * mesh. morphWeights . size () / 2 , mesh.morphWeights . data () );
1075+ render.applyUniformBlock (mesh.submeshes [i].slotVSMorphTarget , sizeof (float ) * MAX_MORPHTARGETS / 2 , & mesh.morphWeights );
10761076 }
10771077 }
10781078
@@ -1127,13 +1127,13 @@ bool RenderSystem::drawMeshDepth(MeshComponent& mesh, const float cameraFar, con
11271127 depthRender.applyUniformBlock (mesh.submeshes [i].slotVSDepthParams , sizeof (float ) * 32 , &vsDepthParams);
11281128
11291129 if (mesh.submeshes [i].hasSkinning ){
1130- depthRender.applyUniformBlock (mesh.submeshes [i].slotVSDepthSkinning , sizeof (Matrix4 ) * mesh. bonesMatrix . size () + (sizeof (float ) * 4 ), mesh.bonesMatrix . data () );
1130+ depthRender.applyUniformBlock (mesh.submeshes [i].slotVSDepthSkinning , sizeof (float ) * 16 * MAX_BONES + (sizeof (float ) * 4 ), & mesh.bonesMatrix );
11311131 }
11321132 if (mesh.submeshes [i].hasMorphTarget ){
11331133 if (!mesh.submeshes [i].hasMorphNormal && !mesh.submeshes [i].hasMorphTangent ){
1134- depthRender.applyUniformBlock (mesh.submeshes [i].slotVSDepthMorphTarget , sizeof (float ) * mesh. morphWeights . size (), mesh.morphWeights . data () );
1134+ depthRender.applyUniformBlock (mesh.submeshes [i].slotVSDepthMorphTarget , sizeof (float ) * MAX_MORPHTARGETS , & mesh.morphWeights );
11351135 }else {
1136- depthRender.applyUniformBlock (mesh.submeshes [i].slotVSDepthMorphTarget , sizeof (float ) * mesh. morphWeights . size () / 2 , mesh.morphWeights . data () );
1136+ depthRender.applyUniformBlock (mesh.submeshes [i].slotVSDepthMorphTarget , sizeof (float ) * MAX_MORPHTARGETS / 2 , & mesh.morphWeights );
11371137 }
11381138 }
11391139
@@ -3069,7 +3069,7 @@ void RenderSystem::update(double dt){
30693069 if (model && mesh) {
30703070 Matrix4 skinning = model->inverseDerivedTransform * transform.modelMatrix * bone.offsetMatrix ;
30713071
3072- if (mesh-> bonesMatrix . validIndex ( bone.index ) )
3072+ if (bone. index >= 0 && bone.index < MAX_BONES )
30733073 mesh->bonesMatrix [bone.index ] = skinning;
30743074 }
30753075 }
0 commit comments