summaryrefslogtreecommitdiffhomepage
path: root/src/rmodels.c
diff options
context:
space:
mode:
authorRay <[email protected]>2022-11-10 12:03:17 +0100
committerRay <[email protected]>2022-11-10 12:03:17 +0100
commit31edd13a72edd69993074941e013cbeff475f782 (patch)
tree2dc1e6ba56f33d7ad23cecab71e31d203a39586b /src/rmodels.c
parent3888299bf5f50a828a26ce52e29db41a8764a193 (diff)
downloadraylib-31edd13a72edd69993074941e013cbeff475f782.tar.gz
raylib-31edd13a72edd69993074941e013cbeff475f782.zip
Minor formating tweaks
Diffstat (limited to 'src/rmodels.c')
-rw-r--r--src/rmodels.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/rmodels.c b/src/rmodels.c
index 80205d49..2ca5ef09 100644
--- a/src/rmodels.c
+++ b/src/rmodels.c
@@ -2117,13 +2117,14 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
for (int m = 0; m < model.meshCount; m++)
{
Mesh mesh = model.meshes[m];
+
if (mesh.boneIds == NULL || mesh.boneWeights == NULL)
{
- TRACELOG(LOG_WARNING, "MODEL: UpdateModelAnimation Mesh %i has no connection to bones",m);
+ TRACELOG(LOG_WARNING, "MODEL: UpdateModelAnimation(): Mesh %i has no connection to bones", m);
continue;
}
- bool updated = false; // set to true when anim vertex information is updated
+ bool updated = false; // Flag to check when anim vertex information is updated
Vector3 animVertex = { 0 };
Vector3 animNormal = { 0 };
@@ -2140,13 +2141,13 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
float boneWeight = 0.0;
const int vValues = mesh.vertexCount*3;
- for (int vCounter = 0; vCounter < vValues; vCounter+=3)
+ for (int vCounter = 0; vCounter < vValues; vCounter += 3)
{
mesh.animVertices[vCounter] = 0;
mesh.animVertices[vCounter + 1] = 0;
mesh.animVertices[vCounter + 2] = 0;
- if (mesh.animNormals!=NULL)
+ if (mesh.animNormals != NULL)
{
mesh.animNormals[vCounter] = 0;
mesh.animNormals[vCounter + 1] = 0;
@@ -2157,16 +2158,15 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
for (int j = 0; j < 4; j++, boneCounter++)
{
boneWeight = mesh.boneWeights[boneCounter];
- // early stop when no transformation will be applied
- if (boneWeight == 0.0f)
- {
- continue;
- }
+
+ // Early stop when no transformation will be applied
+ if (boneWeight == 0.0f) continue;
+
boneId = mesh.boneIds[boneCounter];
//int boneIdParent = model.bones[boneId].parent;
inTranslation = model.bindPose[boneId].translation;
inRotation = model.bindPose[boneId].rotation;
- // inScale = model.bindPose[boneId].scale;
+ //inScale = model.bindPose[boneId].scale;
outTranslation = anim.framePoses[frame][boneId].translation;
outRotation = anim.framePoses[frame][boneId].rotation;
outScale = anim.framePoses[frame][boneId].scale;
@@ -2178,7 +2178,7 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
animVertex = Vector3Subtract(animVertex, inTranslation);
animVertex = Vector3RotateByQuaternion(animVertex, QuaternionMultiply(outRotation, QuaternionInvert(inRotation)));
animVertex = Vector3Add(animVertex, outTranslation);
-// animVertex = Vector3Transform(animVertex, model.transform);
+ //animVertex = Vector3Transform(animVertex, model.transform);
mesh.animVertices[vCounter] += animVertex.x*boneWeight;
mesh.animVertices[vCounter + 1] += animVertex.y*boneWeight;
mesh.animVertices[vCounter + 2] += animVertex.z*boneWeight;
@@ -2198,10 +2198,11 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
}
// Upload new vertex data to GPU for model drawing
- // Only update data when values changed.
- if (updated){
- rlUpdateVertexBuffer(mesh.vboId[0], mesh.animVertices, mesh.vertexCount*3*sizeof(float), 0); // Update vertex position
- rlUpdateVertexBuffer(mesh.vboId[2], mesh.animNormals, mesh.vertexCount*3*sizeof(float), 0); // Update vertex normals
+ // NOTE: Only update data when values changed
+ if (updated)
+ {
+ rlUpdateVertexBuffer(mesh.vboId[0], mesh.animVertices, mesh.vertexCount*3*sizeof(float), 0); // Update vertex position
+ rlUpdateVertexBuffer(mesh.vboId[2], mesh.animNormals, mesh.vertexCount*3*sizeof(float), 0); // Update vertex normals
}
}
}