Use unsigned int for animation count. (#2002)
LoadModelAnimations takes an `int` for the animation count parameter. The animation count should never be negative, so it makes sense to specify it as unsigned in the API. This matches the API for UnloadModelAnimations, which expects an unsigned int. Both GLTF and IQMM also store the animation count internally as unsigned, and we were casting to a signed int for no reason. GLTF actually uses `size_t` internally, so we're technically risking overflow, but having 2^32 animations seems unlikely.
This commit is contained in:
parent
8a434b4fd4
commit
9607ea5c0a
@ -1436,7 +1436,7 @@ RLAPI void SetMaterialTexture(Material *material, int mapType, Texture2D texture
|
||||
RLAPI void SetModelMeshMaterial(Model *model, int meshId, int materialId); // Set material for a mesh
|
||||
|
||||
// Model animations loading/unloading functions
|
||||
RLAPI ModelAnimation *LoadModelAnimations(const char *fileName, int *animCount); // Load model animations from file
|
||||
RLAPI ModelAnimation *LoadModelAnimations(const char *fileName, unsigned int *animCount); // Load model animations from file
|
||||
RLAPI void UpdateModelAnimation(Model model, ModelAnimation anim, int frame); // Update model animation pose
|
||||
RLAPI void UnloadModelAnimation(ModelAnimation anim); // Unload animation data
|
||||
RLAPI void UnloadModelAnimations(ModelAnimation* animations, unsigned int count); // Unload animation array data
|
||||
|
@ -128,11 +128,11 @@ static Model LoadOBJ(const char *fileName); // Load OBJ mesh data
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_IQM)
|
||||
static Model LoadIQM(const char *fileName); // Load IQM mesh data
|
||||
static ModelAnimation *LoadIQMModelAnimations(const char *fileName, int *animCount); // Load IQM animation data
|
||||
static ModelAnimation *LoadIQMModelAnimations(const char *fileName, unsigned int *animCount); // Load IQM animation data
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_GLTF)
|
||||
static Model LoadGLTF(const char *fileName); // Load GLTF mesh data
|
||||
static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCount); // Load GLTF animation data
|
||||
static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, unsigned int *animCount); // Load GLTF animation data
|
||||
static void LoadGLTFMaterial(Model *model, const char *fileName, const cgltf_data *data);
|
||||
static void LoadGLTFMesh(cgltf_data *data, cgltf_mesh *mesh, Model *outModel, Matrix currentTransform, int *primitiveIndex, const char *fileName);
|
||||
static void LoadGLTFNode(cgltf_data *data, cgltf_node *node, Model *outModel, Matrix currentTransform, int *primitiveIndex, const char *fileName);
|
||||
@ -1607,7 +1607,7 @@ void SetModelMeshMaterial(Model *model, int meshId, int materialId)
|
||||
}
|
||||
|
||||
// Load model animations from file
|
||||
ModelAnimation *LoadModelAnimations(const char *fileName, int *animCount)
|
||||
ModelAnimation *LoadModelAnimations(const char *fileName, unsigned int *animCount)
|
||||
{
|
||||
ModelAnimation *animations = NULL;
|
||||
|
||||
@ -4072,7 +4072,7 @@ static Model LoadIQM(const char *fileName)
|
||||
}
|
||||
|
||||
// Load IQM animation data
|
||||
static ModelAnimation* LoadIQMModelAnimations(const char *fileName, int *animCount)
|
||||
static ModelAnimation* LoadIQMModelAnimations(const char *fileName, unsigned int *animCount)
|
||||
{
|
||||
#define IQM_MAGIC "INTERQUAKEMODEL" // IQM file magic number
|
||||
#define IQM_VERSION 2 // only IQM version 2 supported
|
||||
@ -5067,7 +5067,7 @@ static void BindGLTFPrimitiveToBones(Model *model, const cgltf_data *data, int p
|
||||
}
|
||||
|
||||
// LoadGLTF loads in animation data from given filename
|
||||
static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCount)
|
||||
static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, unsigned int *animCount)
|
||||
{
|
||||
/***********************************************************************************
|
||||
|
||||
@ -5102,7 +5102,7 @@ static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCo
|
||||
result = cgltf_load_buffers(&options, data, fileName);
|
||||
if (result != cgltf_result_success) TRACELOG(LOG_WARNING, "MODEL: [%s] unable to load glTF animations data", fileName);
|
||||
animations = RL_MALLOC(data->animations_count*sizeof(ModelAnimation));
|
||||
*animCount = (int)data->animations_count;
|
||||
*animCount = (unsigned int)data->animations_count;
|
||||
|
||||
for (unsigned int a = 0; a < data->animations_count; a++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user