You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After raylib 5.5, updating animation causes segfault when using these gltf assests , due to this line of code . Given these models used to animate on previous versions of raylib, we should account for this edge case.
Segfault is due to the fact that not all mesh in the model (IE: hats) are part of the animation. A null check of some kind fixes the issue on my side.
if (mesh.boneWeights == NULL) continue;
// Iterates over 4 bones per vertex
for (int j = 0; j < 4; j++, boneCounter++)
{
boneWeight = mesh.boneWeights[boneCounter];
boneId = mesh.boneIds[boneCounter];
....
Environment
Fedora
Issue Screenshot
screenshot is all mesh data for a given model, we can see 1 boneweights to be null for the first mesh.
Code Example
Using the animation example, slightly modified.
#include "raylib.h"
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - model animation");
// Define the camera to look into our 3d world
Camera camera = { 0 };
camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 45.0f; // Camera field-of-view Y
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
path = "path/to/model.glb"
Model model = LoadModel(path); // Load the animated model mesh and basic data
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
// Load animation data
int animsCount = 0;
ModelAnimation *anims = LoadModelAnimations(path, &animsCount);
int animFrameCounter = 0;
DisableCursor(); // Catch cursor
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(&camera, CAMERA_FIRST_PERSON);
animFrameCounter++;
UpdateModelAnimation(model, anims[0], animFrameCounter);
if (animFrameCounter >= anims[0].frameCount) animFrameCounter = 0;
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
BeginMode3D(camera);
DrawModelEx(model, position, (Vector3){ 1.0f, 0.0f, 0.0f }, -90.0f, (Vector3){ 1.0f, 1.0f, 1.0f }, WHITE);
DrawGrid(10, 1.0f); // Draw a grid
EndMode3D();
EndDrawing();
//----------------------------------------------------------------------------------
}
return 0;
}
The text was updated successfully, but these errors were encountered:
Issue description
After raylib 5.5, updating animation causes segfault when using these gltf assests , due to this line of code . Given these models used to animate on previous versions of raylib, we should account for this edge case.
Segfault is due to the fact that not all mesh in the model (IE: hats) are part of the animation. A null check of some kind fixes the issue on my side.
Environment
Fedora
Issue Screenshot
screenshot is all mesh data for a given model, we can see 1 boneweights to be null for the first mesh.
Code Example
Using the animation example, slightly modified.
The text was updated successfully, but these errors were encountered: