Skip to content

Commit 799a690

Browse files
committed
Revert "Using HybridArray with MAX_BONES and MAX_MORPHTARGETS"
This reverts commit 94a1cad.
1 parent 94a1cad commit 799a690

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

engine/core/component/MeshComponent.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ namespace Supernova{
8989
HybridArray<Submesh, MAX_SUBMESHES> submeshes;
9090
unsigned int numSubmeshes = 0;
9191

92-
HybridArray<Matrix4, MAX_BONES> bonesMatrix;
92+
Matrix4 bonesMatrix[MAX_BONES];
9393
float normAdjustJoint = 1;
9494
float normAdjustWeight = 1;
9595

96-
HybridArray<float, MAX_MORPHTARGETS> morphWeights;
96+
float morphWeights[MAX_MORPHTARGETS];
9797

9898
AABB aabb = AABB::ZERO;
9999
AABB verticesAABB = AABB::ZERO; // is not influenced by instances

engine/core/subsystem/RenderSystem.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)