Some misc tweaks
This commit is contained in:
parent
8df56c5843
commit
01b3c97c42
3 changed files with 43 additions and 49 deletions
|
@ -3879,7 +3879,7 @@ static bool InitGraphicsDevice(int width, int height)
|
||||||
|
|
||||||
TRACELOG(LOG_TRACE, "DISPLAY: EGL configs available: %d", numConfigs);
|
TRACELOG(LOG_TRACE, "DISPLAY: EGL configs available: %d", numConfigs);
|
||||||
|
|
||||||
EGLConfig *configs = calloc(numConfigs, sizeof(*configs));
|
EGLConfig *configs = RL_CALLOC(numConfigs, sizeof(*configs));
|
||||||
if (!configs)
|
if (!configs)
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_WARNING, "DISPLAY: Failed to get memory for EGL configs");
|
TRACELOG(LOG_WARNING, "DISPLAY: Failed to get memory for EGL configs");
|
||||||
|
@ -3916,7 +3916,7 @@ static bool InitGraphicsDevice(int width, int height)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(configs);
|
RL_FREE(configs);
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
|
|
36
src/models.c
36
src/models.c
|
@ -4032,6 +4032,7 @@ static ModelAnimation* LoadGLTFModelAnimations(const char *fileName, int *animCo
|
||||||
- ...
|
- ...
|
||||||
|
|
||||||
*************************************************************************************/
|
*************************************************************************************/
|
||||||
|
|
||||||
// glTF file loading
|
// glTF file loading
|
||||||
unsigned int dataSize = 0;
|
unsigned int dataSize = 0;
|
||||||
unsigned char *fileData = LoadFileData(fileName, &dataSize);
|
unsigned char *fileData = LoadFileData(fileName, &dataSize);
|
||||||
|
@ -4081,6 +4082,7 @@ static ModelAnimation* LoadGLTFModelAnimations(const char *fileName, int *animCo
|
||||||
cgltf_animation_channel* channel = animation->channels + i;
|
cgltf_animation_channel* channel = animation->channels + i;
|
||||||
int frameCounts = (int)channel->sampler->input->count;
|
int frameCounts = (int)channel->sampler->input->count;
|
||||||
float lastFrameTime = 0.0f;
|
float lastFrameTime = 0.0f;
|
||||||
|
|
||||||
if (GltfReadFloat(channel->sampler->input, frameCounts - 1, &lastFrameTime, 1))
|
if (GltfReadFloat(channel->sampler->input, frameCounts - 1, &lastFrameTime, 1))
|
||||||
{
|
{
|
||||||
animationDuration = fmaxf(lastFrameTime, animationDuration);
|
animationDuration = fmaxf(lastFrameTime, animationDuration);
|
||||||
|
@ -4150,31 +4152,28 @@ static ModelAnimation* LoadGLTFModelAnimations(const char *fileName, int *animCo
|
||||||
{
|
{
|
||||||
lerpPercent = (frameTime - previousInputTime)/(inputFrameTime - previousInputTime);
|
lerpPercent = (frameTime - previousInputTime)/(inputFrameTime - previousInputTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the current transformation has no information for the current frame time point
|
// If the current transformation has no information for the current frame time point
|
||||||
if (shouldSkipFurtherTransformation) {
|
if (shouldSkipFurtherTransformation) continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (channel->target_path == cgltf_animation_path_type_translation) {
|
if (channel->target_path == cgltf_animation_path_type_translation)
|
||||||
|
{
|
||||||
Vector3 translationStart;
|
Vector3 translationStart;
|
||||||
Vector3 translationEnd;
|
Vector3 translationEnd;
|
||||||
|
|
||||||
bool success = GltfReadFloat(sampler->output, outputMin, (float *)&translationStart, 3);
|
bool success = GltfReadFloat(sampler->output, outputMin, (float *)&translationStart, 3);
|
||||||
success = GltfReadFloat(sampler->output, outputMax, (float *)&translationEnd, 3) || success;
|
success = GltfReadFloat(sampler->output, outputMax, (float *)&translationEnd, 3) || success;
|
||||||
|
|
||||||
if (success)
|
if (success) output->framePoses[frame][boneId].translation = Vector3Lerp(translationStart, translationEnd, lerpPercent);
|
||||||
|
}
|
||||||
|
if (channel->target_path == cgltf_animation_path_type_rotation)
|
||||||
{
|
{
|
||||||
output->framePoses[frame][boneId].translation = Vector3Lerp(translationStart, translationEnd, lerpPercent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (channel->target_path == cgltf_animation_path_type_rotation) {
|
|
||||||
Quaternion rotationStart;
|
Quaternion rotationStart;
|
||||||
Quaternion rotationEnd;
|
Quaternion rotationEnd;
|
||||||
|
|
||||||
|
@ -4185,20 +4184,17 @@ static ModelAnimation* LoadGLTFModelAnimations(const char *fileName, int *animCo
|
||||||
{
|
{
|
||||||
output->framePoses[frame][boneId].rotation = QuaternionLerp(rotationStart, rotationEnd, lerpPercent);
|
output->framePoses[frame][boneId].rotation = QuaternionLerp(rotationStart, rotationEnd, lerpPercent);
|
||||||
output->framePoses[frame][boneId].rotation = QuaternionNormalize(output->framePoses[frame][boneId].rotation);
|
output->framePoses[frame][boneId].rotation = QuaternionNormalize(output->framePoses[frame][boneId].rotation);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (channel->target_path == cgltf_animation_path_type_scale) {
|
if (channel->target_path == cgltf_animation_path_type_scale)
|
||||||
|
{
|
||||||
Vector3 scaleStart;
|
Vector3 scaleStart;
|
||||||
Vector3 scaleEnd;
|
Vector3 scaleEnd;
|
||||||
|
|
||||||
bool success = GltfReadFloat(sampler->output, outputMin, (float *)&scaleStart, 3);
|
bool success = GltfReadFloat(sampler->output, outputMin, (float *)&scaleStart, 3);
|
||||||
success = GltfReadFloat(sampler->output, outputMax, (float *)&scaleEnd, 3) || success;
|
success = GltfReadFloat(sampler->output, outputMax, (float *)&scaleEnd, 3) || success;
|
||||||
|
|
||||||
if (success)
|
if (success) output->framePoses[frame][boneId].scale = Vector3Lerp(scaleStart, scaleEnd, lerpPercent);
|
||||||
{
|
|
||||||
output->framePoses[frame][boneId].scale = Vector3Lerp(scaleStart, scaleEnd, lerpPercent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4209,12 +4205,14 @@ static ModelAnimation* LoadGLTFModelAnimations(const char *fileName, int *animCo
|
||||||
bool *completedBones = RL_CALLOC(output->boneCount, sizeof(bool));
|
bool *completedBones = RL_CALLOC(output->boneCount, sizeof(bool));
|
||||||
int numberCompletedBones = 0;
|
int numberCompletedBones = 0;
|
||||||
|
|
||||||
while (numberCompletedBones < output->boneCount) {
|
while (numberCompletedBones < output->boneCount)
|
||||||
|
{
|
||||||
for (int i = 0; i < output->boneCount; i++)
|
for (int i = 0; i < output->boneCount; i++)
|
||||||
{
|
{
|
||||||
if (completedBones[i]) continue;
|
if (completedBones[i]) continue;
|
||||||
|
|
||||||
if (output->bones[i].parent < 0) {
|
if (output->bones[i].parent < 0)
|
||||||
|
{
|
||||||
completedBones[i] = true;
|
completedBones[i] = true;
|
||||||
numberCompletedBones++;
|
numberCompletedBones++;
|
||||||
continue;
|
continue;
|
||||||
|
|
20
src/rlgl.h
20
src/rlgl.h
|
@ -4051,25 +4051,21 @@ static unsigned int CompileShader(const char *shaderStr, int type)
|
||||||
glCompileShader(shader);
|
glCompileShader(shader);
|
||||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
|
glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
|
||||||
|
|
||||||
if (success != GL_TRUE)
|
if (success == GL_FALSE)
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_WARNING, "SHADER: [ID %i] Failed to compile shader code", shader);
|
TRACELOG(LOG_WARNING, "SHADER: [ID %i] Failed to compile shader code", shader);
|
||||||
|
|
||||||
int maxLength = 0;
|
int maxLength = 0;
|
||||||
int length;
|
|
||||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &maxLength);
|
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &maxLength);
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
if (maxLength > 0)
|
||||||
char *log = RL_MALLOC(maxLength);
|
{
|
||||||
#else
|
int length = 0;
|
||||||
char log[maxLength];
|
char *log = RL_CALLOC(maxLength, sizeof(char));
|
||||||
#endif
|
|
||||||
glGetShaderInfoLog(shader, maxLength, &length, log);
|
glGetShaderInfoLog(shader, maxLength, &length, log);
|
||||||
|
|
||||||
TRACELOG(LOG_WARNING, "SHADER: [ID %i] Compile error: %s", shader, log);
|
TRACELOG(LOG_WARNING, "SHADER: [ID %i] Compile error: %s", shader, log);
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
RL_FREE(log);
|
RL_FREE(log);
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
else TRACELOG(LOG_INFO, "SHADER: [ID %i] Compiled successfully", shader);
|
else TRACELOG(LOG_INFO, "SHADER: [ID %i] Compiled successfully", shader);
|
||||||
|
|
||||||
|
@ -4113,7 +4109,7 @@ static unsigned int LoadShaderProgram(unsigned int vShaderId, unsigned int fShad
|
||||||
|
|
||||||
if (maxLength > 0)
|
if (maxLength > 0)
|
||||||
{
|
{
|
||||||
int length;
|
int length = 0;
|
||||||
char *log = RL_CALLOC(maxLength, sizeof(char));
|
char *log = RL_CALLOC(maxLength, sizeof(char));
|
||||||
glGetProgramInfoLog(program, maxLength, &length, log);
|
glGetProgramInfoLog(program, maxLength, &length, log);
|
||||||
TRACELOG(LOG_WARNING, "SHADER: [ID %i] Link error: %s", program, log);
|
TRACELOG(LOG_WARNING, "SHADER: [ID %i] Link error: %s", program, log);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue