Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/models/models_animation_blend_custom.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
// Module Functions Declaration
//------------------------------------------------------------------------------------
static bool IsUpperBodyBone(const char *boneName);
static void UpdateModelAnimationBones(Model *model, ModelAnimation *anim1, int frame1,
static void UpdateModelAnimationBoneCustom(Model *model, ModelAnimation *anim1, int frame1,
ModelAnimation *anim2, int frame2, float blend, bool upperBodyBlend);

//------------------------------------------------------------------------------------
Expand Down Expand Up @@ -117,7 +117,7 @@ int main(void)
// When upperBodyBlend is ON: upper body = attack (1.0), lower body = walk (0.0)
// When upperBodyBlend is OFF: uniform blend at 0.5 (50% walk, 50% attack)
float blendFactor = (upperBodyBlend? 1.0f : 0.5f);
UpdateModelAnimationBones(&model, &anim0, animCurrentFrame0,
UpdateModelAnimationBoneCustom(&model, &anim0, animCurrentFrame0,
&anim1, animCurrentFrame1, blendFactor, upperBodyBlend);

// raylib provided animation blending function
Expand Down Expand Up @@ -194,7 +194,7 @@ static bool IsUpperBodyBone(const char *boneName)
}

// Blend two animations per-bone with selective upper/lower body blending
static void UpdateModelAnimationBones(Model *model, ModelAnimation *anim0, int frame0,
static void UpdateModelAnimationBoneCustom(Model *model, ModelAnimation *anim0, int frame0,
ModelAnimation *anim1, int frame1, float blend, bool upperBodyBlend)
{
// Validate inputs
Expand Down
5 changes: 3 additions & 2 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,9 @@
#define SUPPORT_MESH_GENERATION 1
#endif
#ifndef SUPPORT_GPU_SKINNING
// GPU skinning disabled by default, some GPUs do not support more than 8 VBOs
#define SUPPORT_GPU_SKINNING 0
// GPU skinning enabled by default for GL3.3+,
// Some GPUs do not support more than 8 VBOs so you may need to disable it if you have issues loading animated models
#define SUPPORT_GPU_SKINNING 1

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to avoid enabling this by default. CPU solution is widely supported but GPU can fail in some platforms.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not disable CPU skinning. Would you be ok with default enable for GL 3.3+?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If GPU skinning can not be enabled on target platform, does it fallback to CPU skinning? I'd like to keep the conditionals at minimum in config.h.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a plan for how to do this. I will test it in a fork.
Is there any hard info on devices that that the smaller number of vertex attributes? or is it just an ambiguous "some" ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My research on the OpenGL spec.
OpenGL 3.0 - 4.6: Requires a minimum of 16 attributes

#endif

//------------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/raylib.h
Original file line number Diff line number Diff line change
Expand Up @@ -1655,6 +1655,8 @@ RLAPI void SetModelMeshMaterial(Model *model, int meshId, int materialId);
RLAPI ModelAnimation *LoadModelAnimations(const char *fileName, int *animCount); // Load model animations from file
RLAPI void UpdateModelAnimation(Model model, ModelAnimation anim, float frame); // Update model animation pose (vertex buffers and bone matrices)
RLAPI void UpdateModelAnimationEx(Model model, ModelAnimation animA, float frameA, ModelAnimation animB, float frameB, float blend); // Update model animation pose, blending two animations
RLAPI void UpdateModelAnimationBones(Model model, ModelAnimation anim, float frame); // Update model animation pose (bones only)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could those functions be kept internal to rmodels, I prefer to expose the minimum required functions for users.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is very useful for people who want to do GPU skinning only.
This was a function in 5.5, but it was removed for 6.0 for no clear reason (incorrectly in my option).
I am simply restoring it due to it's utility.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed them because I considered most users don't need them, that was the reason to add the models_animation_blend_custom example, for users that need that level of control.

RLAPI void UpdateModelAnimationBonesEx(Model model, ModelAnimation animA, float frameA, ModelAnimation animB, float frameB, float blend); // Update model animation bones to pose, blending two animations
RLAPI void UnloadModelAnimations(ModelAnimation *animations, int animCount); // Unload animation array data
RLAPI bool IsModelAnimationValid(Model model, ModelAnimation anim); // Check model animation skeleton match

Expand Down
159 changes: 91 additions & 68 deletions src/rmodels.c

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions tools/rlparser/output/raylib_api.json
Original file line number Diff line number Diff line change
Expand Up @@ -11839,6 +11839,56 @@
}
]
},
{
"name": "UpdateModelAnimationBones",
"description": "Update model animation pose (bones only)",
"returnType": "void",
"params": [
{
"type": "Model",
"name": "model"
},
{
"type": "ModelAnimation",
"name": "anim"
},
{
"type": "float",
"name": "frame"
}
]
},
{
"name": "UpdateModelAnimationBonesEx",
"description": "Update model animation bones to pose, blending two animations",
"returnType": "void",
"params": [
{
"type": "Model",
"name": "model"
},
{
"type": "ModelAnimation",
"name": "animA"
},
{
"type": "float",
"name": "frameA"
},
{
"type": "ModelAnimation",
"name": "animB"
},
{
"type": "float",
"name": "frameB"
},
{
"type": "float",
"name": "blend"
}
]
},
{
"name": "UnloadModelAnimations",
"description": "Unload animation array data",
Expand Down
23 changes: 23 additions & 0 deletions tools/rlparser/output/raylib_api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7999,6 +7999,29 @@ return {
{type = "float", name = "blend"}
}
},
{
name = "UpdateModelAnimationBones",
description = "Update model animation pose (bones only)",
returnType = "void",
params = {
{type = "Model", name = "model"},
{type = "ModelAnimation", name = "anim"},
{type = "float", name = "frame"}
}
},
{
name = "UpdateModelAnimationBonesEx",
description = "Update model animation bones to pose, blending two animations",
returnType = "void",
params = {
{type = "Model", name = "model"},
{type = "ModelAnimation", name = "animA"},
{type = "float", name = "frameA"},
{type = "ModelAnimation", name = "animB"},
{type = "float", name = "frameB"},
{type = "float", name = "blend"}
}
},
{
name = "UnloadModelAnimations",
description = "Unload animation array data",
Expand Down
19 changes: 19 additions & 0 deletions tools/rlparser/output/raylib_api.sexpr
Original file line number Diff line number Diff line change
Expand Up @@ -6095,6 +6095,25 @@
((type "float") (name "frameB"))
((type "float") (name "blend"))))

((name "UpdateModelAnimationBones")
(description "Update model animation pose (bones only)")
(return-type "void")
(params
((type "Model") (name "model"))
((type "ModelAnimation") (name "anim"))
((type "float") (name "frame"))))

((name "UpdateModelAnimationBonesEx")
(description "Update model animation bones to pose, blending two animations")
(return-type "void")
(params
((type "Model") (name "model"))
((type "ModelAnimation") (name "animA"))
((type "float") (name "frameA"))
((type "ModelAnimation") (name "animB"))
((type "float") (name "frameB"))
((type "float") (name "blend"))))

((name "UnloadModelAnimations")
(description "Unload animation array data")
(return-type "void")
Expand Down
Loading