mirror of
https://github.com/raysan5/raylib.git
synced 2026-10-11 04:01:54 -04:00
Compare commits
4 Commits
012e274ae8
...
d8ddc8a0a6
| Author | SHA1 | Date | |
|---|---|---|---|
| d8ddc8a0a6 | |||
| 8341321d1a | |||
| 51d713d54d | |||
| 3ff30034de |
@ -139,6 +139,9 @@ int main(void)
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
RL_FREE(transforms); // Free transforms
|
||||
UnloadMaterial(matInstances); // Also unloads the instancing shader
|
||||
UnloadMaterial(matDefault); // Unload default material
|
||||
UnloadMesh(cube); // Unload cube mesh
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
1
src/external/vox_loader.h
vendored
1
src/external/vox_loader.h
vendored
@ -733,6 +733,7 @@ void Vox_FreeArrays(VoxArray3D* voxarray)
|
||||
|
||||
// Free arrays
|
||||
freeArrayVector3(&voxarray->vertices);
|
||||
freeArrayVector3(&voxarray->normals);
|
||||
freeArrayUShort(&voxarray->indices);
|
||||
freeArrayColor(&voxarray->colors);
|
||||
}
|
||||
|
||||
@ -2000,7 +2000,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
|
||||
EndPaint(hwnd, &ps);
|
||||
}
|
||||
else DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
}
|
||||
} break;
|
||||
case WM_INPUT:
|
||||
{
|
||||
//HandleRawInput(lparam);
|
||||
|
||||
@ -2486,6 +2486,9 @@ void UpdateModelAnimationEx(Model model, ModelAnimation animA, float frameA, Mod
|
||||
// NOTE: Required for CPU skinning, uploads animated vertex buffers to GPU
|
||||
static void UpdateModelAnimationVertexBuffers(Model model)
|
||||
{
|
||||
static Matrix boneNormalMatrices[256] = { 0 }; // Normal matrix per bone, bone indices are unsigned char
|
||||
bool boneNormalsReady = false;
|
||||
|
||||
for (int m = 0; m < model.meshCount; m++)
|
||||
{
|
||||
Mesh mesh = model.meshes[m];
|
||||
@ -2502,6 +2505,14 @@ static void UpdateModelAnimationVertexBuffers(Model model)
|
||||
if ((mesh.boneWeights == NULL) || (mesh.boneIndices == NULL) ||
|
||||
(mesh.animVertices == NULL) || (mesh.animNormals == NULL)) continue;
|
||||
|
||||
// Normal matrix only depends on the bone, compute it once per bone instead of per vertex
|
||||
if ((mesh.normals != NULL) && !boneNormalsReady)
|
||||
{
|
||||
memset(boneNormalMatrices, 0, 256*sizeof(Matrix));
|
||||
for (unsigned int b = 0; (b < model.skeleton.boneCount) && (b < 256); b++) boneNormalMatrices[b] = MatrixTranspose(MatrixInvert(model.boneMatrices[b]));
|
||||
boneNormalsReady = true;
|
||||
}
|
||||
|
||||
for (int vCounter = 0; vCounter < vertexValuesCount; vCounter += 3)
|
||||
{
|
||||
mesh.animVertices[vCounter] = 0;
|
||||
@ -2534,7 +2545,7 @@ static void UpdateModelAnimationVertexBuffers(Model model)
|
||||
if ((mesh.normals != NULL) && (mesh.animNormals != NULL ))
|
||||
{
|
||||
animNormal = (Vector3){ mesh.normals[vCounter], mesh.normals[vCounter + 1], mesh.normals[vCounter + 2] };
|
||||
animNormal = Vector3Transform(animNormal, MatrixTranspose(MatrixInvert(model.boneMatrices[boneIndex])));
|
||||
animNormal = Vector3Transform(animNormal, boneNormalMatrices[boneIndex]);
|
||||
mesh.animNormals[vCounter] += animNormal.x*boneWeight;
|
||||
mesh.animNormals[vCounter + 1] += animNormal.y*boneWeight;
|
||||
mesh.animNormals[vCounter + 2] += animNormal.z*boneWeight;
|
||||
|
||||
Reference in New Issue
Block a user