瀏覽代碼

Review code format

pull/1797/head
Ray 3 年之前
父節點
當前提交
c828e481fb
共有 2 個檔案被更改,包括 27 行新增27 行删除
  1. +6
    -6
      src/models.c
  2. +21
    -21
      src/raymath.h

+ 6
- 6
src/models.c 查看文件

@ -1461,9 +1461,9 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
animVertex = Vector3Subtract(animVertex, inTranslation);
animVertex = Vector3RotateByQuaternion(animVertex, QuaternionMultiply(outRotation, QuaternionInvert(inRotation)));
animVertex = Vector3Add(animVertex, outTranslation);
model.meshes[m].animVertices[vCounter] += animVertex.x * boneWeight;
model.meshes[m].animVertices[vCounter + 1] += animVertex.y * boneWeight;
model.meshes[m].animVertices[vCounter + 2] += animVertex.z * boneWeight;
model.meshes[m].animVertices[vCounter] += animVertex.x*boneWeight;
model.meshes[m].animVertices[vCounter + 1] += animVertex.y*boneWeight;
model.meshes[m].animVertices[vCounter + 2] += animVertex.z*boneWeight;
// Normals processing
// NOTE: We use meshes.baseNormals (default normal) to calculate meshes.normals (animated normals)
@ -1471,9 +1471,9 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
{
animNormal = (Vector3){ model.meshes[m].normals[vCounter], model.meshes[m].normals[vCounter + 1], model.meshes[m].normals[vCounter + 2] };
animNormal = Vector3RotateByQuaternion(animNormal, QuaternionMultiply(outRotation, QuaternionInvert(inRotation)));
model.meshes[m].animNormals[vCounter] += animNormal.x * boneWeight;
model.meshes[m].animNormals[vCounter + 1] += animNormal.y * boneWeight;
model.meshes[m].animNormals[vCounter + 2] += animNormal.z * boneWeight;
model.meshes[m].animNormals[vCounter] += animNormal.x*boneWeight;
model.meshes[m].animNormals[vCounter + 1] += animNormal.y*boneWeight;
model.meshes[m].animNormals[vCounter + 2] += animNormal.z*boneWeight;
}
boneCounter += 1;
}

+ 21
- 21
src/raymath.h 查看文件

@ -1390,27 +1390,27 @@ RMDEF Matrix QuaternionToMatrix(Quaternion q)
{
Matrix result = MatrixIdentity();
float a2 = q.x * q.x;
float b2 = q.y * q.y;
float c2 = q.z * q.z;
float ac = q.x * q.z;
float ab = q.x * q.y;
float bc = q.y * q.z;
float ad = q.w * q.x;
float bd = q.w * q.y;
float cd = q.w * q.z;
result.m0 = 1 - 2 * (b2 + c2);
result.m1 = 2 * (ab + cd);
result.m2 = 2 * (ac - bd);
result.m4 = 2 * (ab - cd);
result.m5 = 1 - 2 * (a2 + c2);
result.m6 = 2 * (bc + ad);
result.m8 = 2 * (ac + bd);
result.m9 = 2 * (bc - ad);
result.m10 = 1 - 2 * (a2 + b2);
float a2 = q.x*q.x;
float b2 = q.y*q.y;
float c2 = q.z*q.z;
float ac = q.x*q.z;
float ab = q.x*q.y;
float bc = q.y*q.z;
float ad = q.w*q.x;
float bd = q.w*q.y;
float cd = q.w*q.z;
result.m0 = 1 - 2*(b2 + c2);
result.m1 = 2*(ab + cd);
result.m2 = 2*(ac - bd);
result.m4 = 2*(ab - cd);
result.m5 = 1 - 2*(a2 + c2);
result.m6 = 2*(bc + ad);
result.m8 = 2*(ac + bd);
result.m9 = 2*(bc - ad);
result.m10 = 1 - 2*(a2 + b2);
return result;
}

Loading…
取消
儲存