Remove trailing spaces

This commit is contained in:
raysan5 2021-06-30 16:39:07 +02:00
parent 0776f1e106
commit 9e7ca41f58
6 changed files with 92 additions and 91 deletions

View File

@ -800,7 +800,7 @@ void InitWindow(int width, int height, const char *title)
// Initialize assets manager // Initialize assets manager
InitAssetManager(CORE.Android.app->activity->assetManager, CORE.Android.app->activity->internalDataPath); InitAssetManager(CORE.Android.app->activity->assetManager, CORE.Android.app->activity->internalDataPath);
// Initialize base path for storage // Initialize base path for storage
CORE.Storage.basePath = CORE.Android.app->activity->internalDataPath; CORE.Storage.basePath = CORE.Android.app->activity->internalDataPath;
@ -838,10 +838,10 @@ void InitWindow(int width, int height, const char *title)
// Initialize hi-res timer // Initialize hi-res timer
InitTimer(); InitTimer();
// Initialize random seed // Initialize random seed
srand((unsigned int)time(NULL)); srand((unsigned int)time(NULL));
// Initialize base path for storage // Initialize base path for storage
CORE.Storage.basePath = GetWorkingDirectory(); CORE.Storage.basePath = GetWorkingDirectory();
@ -1945,7 +1945,7 @@ void BeginDrawing(void)
{ {
// WARNING: Previously to BeginDrawing() other render textures drawing could happen, // WARNING: Previously to BeginDrawing() other render textures drawing could happen,
// consequently the measure for update vs draw is not accurate (only the total frame time is accurate) // consequently the measure for update vs draw is not accurate (only the total frame time is accurate)
CORE.Time.current = GetTime(); // Number of elapsed seconds since InitTimer() CORE.Time.current = GetTime(); // Number of elapsed seconds since InitTimer()
CORE.Time.update = CORE.Time.current - CORE.Time.previous; CORE.Time.update = CORE.Time.current - CORE.Time.previous;
CORE.Time.previous = CORE.Time.current; CORE.Time.previous = CORE.Time.current;
@ -2347,7 +2347,7 @@ RLAPI Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode)
{ {
Shader shader = { 0 }; Shader shader = { 0 };
shader.locs = (int *)RL_CALLOC(MAX_SHADER_LOCATIONS, sizeof(int)); shader.locs = (int *)RL_CALLOC(MAX_SHADER_LOCATIONS, sizeof(int));
// NOTE: All locations must be reseted to -1 (no location) // NOTE: All locations must be reseted to -1 (no location)
for (int i = 0; i < MAX_SHADER_LOCATIONS; i++) shader.locs[i] = -1; for (int i = 0; i < MAX_SHADER_LOCATIONS; i++) shader.locs[i] = -1;
@ -3113,7 +3113,7 @@ bool SaveStorageValue(unsigned int position, int value)
success = SaveFileData(path, newFileData, newDataSize); success = SaveFileData(path, newFileData, newDataSize);
RL_FREE(newFileData); RL_FREE(newFileData);
TRACELOG(LOG_INFO, "FILEIO: [%s] Saved storage value: %i", path, value); TRACELOG(LOG_INFO, "FILEIO: [%s] Saved storage value: %i", path, value);
} }
else else
@ -3127,7 +3127,7 @@ bool SaveStorageValue(unsigned int position, int value)
success = SaveFileData(path, fileData, dataSize); success = SaveFileData(path, fileData, dataSize);
UnloadFileData(fileData); UnloadFileData(fileData);
TRACELOG(LOG_INFO, "FILEIO: [%s] Saved storage value: %i", path, value); TRACELOG(LOG_INFO, "FILEIO: [%s] Saved storage value: %i", path, value);
} }
#endif #endif
@ -3144,7 +3144,7 @@ int LoadStorageValue(unsigned int position)
#if defined(SUPPORT_DATA_STORAGE) #if defined(SUPPORT_DATA_STORAGE)
char path[512] = { 0 }; char path[512] = { 0 };
strcpy(path, TextFormat("%s/%s", CORE.Storage.basePath, STORAGE_DATA_FILE)); strcpy(path, TextFormat("%s/%s", CORE.Storage.basePath, STORAGE_DATA_FILE));
unsigned int dataSize = 0; unsigned int dataSize = 0;
unsigned char *fileData = LoadFileData(path, &dataSize); unsigned char *fileData = LoadFileData(path, &dataSize);
@ -3158,7 +3158,7 @@ int LoadStorageValue(unsigned int position)
} }
UnloadFileData(fileData); UnloadFileData(fileData);
TRACELOG(LOG_INFO, "FILEIO: [%s] Loaded storage value: %i", path, value); TRACELOG(LOG_INFO, "FILEIO: [%s] Loaded storage value: %i", path, value);
} }
#endif #endif
@ -4694,7 +4694,7 @@ void WaitTime(float ms)
#if defined(SUPPORT_PARTIALBUSY_WAIT_LOOP) #if defined(SUPPORT_PARTIALBUSY_WAIT_LOOP)
double previousTime = GetTime(); double previousTime = GetTime();
double currentTime = 0.0; double currentTime = 0.0;
// Partial busy wait loop (only a fraction of the total wait time) // Partial busy wait loop (only a fraction of the total wait time)
while ((currentTime - previousTime) < busyWait/1000.0f) currentTime = GetTime(); while ((currentTime - previousTime) < busyWait/1000.0f) currentTime = GetTime();
#endif #endif
@ -5360,7 +5360,7 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
// Initialize hi-res timer // Initialize hi-res timer
InitTimer(); InitTimer();
// Initialize random seed // Initialize random seed
srand((unsigned int)time(NULL)); srand((unsigned int)time(NULL));

View File

@ -4139,7 +4139,7 @@ static Image LoadImageFromCgltfImage(cgltf_image *image, const char *texPath, Co
static bool ReadGLTFValue(cgltf_accessor *acc, unsigned int index, void *variable) static bool ReadGLTFValue(cgltf_accessor *acc, unsigned int index, void *variable)
{ {
unsigned int typeElements = 0; unsigned int typeElements = 0;
switch (acc->type) switch (acc->type)
{ {
case cgltf_type_scalar: typeElements = 1; break; case cgltf_type_scalar: typeElements = 1; break;
@ -4152,10 +4152,10 @@ static bool ReadGLTFValue(cgltf_accessor *acc, unsigned int index, void *variabl
case cgltf_type_invalid: typeElements = 0; break; case cgltf_type_invalid: typeElements = 0; break;
default: break; default: break;
} }
unsigned int typeSize = 0; unsigned int typeSize = 0;
switch (acc->component_type) switch (acc->component_type)
{ {
case cgltf_component_type_r_8u: case cgltf_component_type_r_8u:
case cgltf_component_type_r_8: typeSize = 1; break; case cgltf_component_type_r_8: typeSize = 1; break;
@ -4166,9 +4166,9 @@ static bool ReadGLTFValue(cgltf_accessor *acc, unsigned int index, void *variabl
case cgltf_component_type_invalid: typeSize = 0; break; case cgltf_component_type_invalid: typeSize = 0; break;
default: break; default: break;
} }
unsigned int singleElementSize = typeSize*typeElements; unsigned int singleElementSize = typeSize*typeElements;
if (acc->count == 2) if (acc->count == 2)
{ {
if (index > 1) return false; if (index > 1) return false;
@ -4176,11 +4176,11 @@ static bool ReadGLTFValue(cgltf_accessor *acc, unsigned int index, void *variabl
memcpy(variable, index == 0 ? acc->min : acc->max, singleElementSize); memcpy(variable, index == 0 ? acc->min : acc->max, singleElementSize);
return true; return true;
} }
memset(variable, 0, singleElementSize); memset(variable, 0, singleElementSize);
if (acc->buffer_view == NULL || acc->buffer_view->buffer == NULL || acc->buffer_view->buffer->data == NULL) return false; if (acc->buffer_view == NULL || acc->buffer_view->buffer == NULL || acc->buffer_view->buffer->data == NULL) return false;
if (!acc->buffer_view->stride) if (!acc->buffer_view->stride)
{ {
void *readPosition = ((char *)acc->buffer_view->buffer->data) + (index*singleElementSize) + acc->buffer_view->offset + acc->offset; void *readPosition = ((char *)acc->buffer_view->buffer->data) + (index*singleElementSize) + acc->buffer_view->offset + acc->offset;
@ -4191,7 +4191,7 @@ static bool ReadGLTFValue(cgltf_accessor *acc, unsigned int index, void *variabl
void *readPosition = ((char *)acc->buffer_view->buffer->data) + (index*acc->buffer_view->stride) + acc->buffer_view->offset + acc->offset; void *readPosition = ((char *)acc->buffer_view->buffer->data) + (index*acc->buffer_view->stride) + acc->buffer_view->offset + acc->offset;
memcpy(variable, readPosition, singleElementSize); memcpy(variable, readPosition, singleElementSize);
} }
return true; return true;
} }
@ -4210,7 +4210,7 @@ static void *ReadGLTFValuesAs(cgltf_accessor* acc, cgltf_component_type type, bo
case cgltf_component_type_invalid: typeSize = 0; break; case cgltf_component_type_invalid: typeSize = 0; break;
default: break; default: break;
} }
unsigned int typeElements = 0; unsigned int typeElements = 0;
switch (acc->type) switch (acc->type)
{ {
@ -4224,15 +4224,15 @@ static void *ReadGLTFValuesAs(cgltf_accessor* acc, cgltf_component_type type, bo
case cgltf_type_invalid: typeElements = 0; break; case cgltf_type_invalid: typeElements = 0; break;
default: break; default: break;
} }
if (acc->component_type == type) if (acc->component_type == type)
{ {
void *array = RL_MALLOC(count*typeElements*typeSize); void *array = RL_MALLOC(count*typeElements*typeSize);
for (unsigned int i = 0; i < count; i++) ReadGLTFValue(acc, i, (char *)array + i*typeElements*typeSize); for (unsigned int i = 0; i < count; i++) ReadGLTFValue(acc, i, (char *)array + i*typeElements*typeSize);
return array; return array;
} }
else else
{ {
@ -4248,15 +4248,15 @@ static void *ReadGLTFValuesAs(cgltf_accessor* acc, cgltf_component_type type, bo
case cgltf_component_type_invalid: accTypeSize = 0; break; case cgltf_component_type_invalid: accTypeSize = 0; break;
default: break; default: break;
} }
void *array = RL_MALLOC(count*typeElements*typeSize); void *array = RL_MALLOC(count*typeElements*typeSize);
void *additionalArray = RL_MALLOC(count*typeElements*accTypeSize); void *additionalArray = RL_MALLOC(count*typeElements*accTypeSize);
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
ReadGLTFValue(acc, i, (char *)additionalArray + i*typeElements*accTypeSize); ReadGLTFValue(acc, i, (char *)additionalArray + i*typeElements*accTypeSize);
} }
switch (acc->component_type) switch (acc->component_type)
{ {
case cgltf_component_type_r_8u: case cgltf_component_type_r_8u:
@ -4332,7 +4332,7 @@ static void *ReadGLTFValuesAs(cgltf_accessor* acc, cgltf_component_type type, bo
unsigned int *typedArray = (unsigned int *)array; unsigned int *typedArray = (unsigned int *)array;
for (unsigned int i = 0; i < count*typeElements; i++) typedArray[i] = (unsigned int)typedAdditionalArray[i]; for (unsigned int i = 0; i < count*typeElements; i++) typedArray[i] = (unsigned int)typedAdditionalArray[i];
} break; } break;
default: default:
{ {
RL_FREE(array); RL_FREE(array);
RL_FREE(additionalArray); RL_FREE(additionalArray);
@ -4382,7 +4382,7 @@ static void *ReadGLTFValuesAs(cgltf_accessor* acc, cgltf_component_type type, bo
unsigned int* typedArray = (unsigned int*) array; unsigned int* typedArray = (unsigned int*) array;
for (unsigned int i = 0; i < count*typeElements; i++) typedArray[i] = (unsigned int)typedAdditionalArray[i]; for (unsigned int i = 0; i < count*typeElements; i++) typedArray[i] = (unsigned int)typedAdditionalArray[i];
} break; } break;
default: default:
{ {
RL_FREE(array); RL_FREE(array);
RL_FREE(additionalArray); RL_FREE(additionalArray);
@ -4535,7 +4535,7 @@ static void *ReadGLTFValuesAs(cgltf_accessor* acc, cgltf_component_type type, bo
return NULL; return NULL;
} break; } break;
} }
RL_FREE(additionalArray); RL_FREE(additionalArray);
return array; return array;
} }
@ -4583,7 +4583,7 @@ static Model LoadGLTF(const char *fileName)
// Read data buffers // Read data buffers
result = cgltf_load_buffers(&options, data, fileName); result = cgltf_load_buffers(&options, data, fileName);
if (result != cgltf_result_success) TRACELOG(LOG_INFO, "MODEL: [%s] Failed to load mesh/material buffers", fileName); if (result != cgltf_result_success) TRACELOG(LOG_INFO, "MODEL: [%s] Failed to load mesh/material buffers", fileName);
if (data->scenes_count > 1) TRACELOG(LOG_INFO, "MODEL: [%s] Has multiple scenes but only the first one will be loaded", fileName); if (data->scenes_count > 1) TRACELOG(LOG_INFO, "MODEL: [%s] Has multiple scenes but only the first one will be loaded", fileName);
int primitivesCount = 0; int primitivesCount = 0;
@ -4591,7 +4591,7 @@ static Model LoadGLTF(const char *fileName)
{ {
GetGLTFPrimitiveCount(data->scene->nodes[i], &primitivesCount); GetGLTFPrimitiveCount(data->scene->nodes[i], &primitivesCount);
} }
// Process glTF data and map to model // Process glTF data and map to model
model.meshCount = primitivesCount; model.meshCount = primitivesCount;
model.meshes = RL_CALLOC(model.meshCount, sizeof(Mesh)); model.meshes = RL_CALLOC(model.meshCount, sizeof(Mesh));
@ -4601,10 +4601,10 @@ static Model LoadGLTF(const char *fileName)
model.boneCount = (int)data->nodes_count; model.boneCount = (int)data->nodes_count;
model.bones = RL_CALLOC(model.boneCount, sizeof(BoneInfo)); model.bones = RL_CALLOC(model.boneCount, sizeof(BoneInfo));
model.bindPose = RL_CALLOC(model.boneCount, sizeof(Transform)); model.bindPose = RL_CALLOC(model.boneCount, sizeof(Transform));
InitGLTFBones(&model, data); InitGLTFBones(&model, data);
LoadGLTFMaterial(&model, fileName, data); LoadGLTFMaterial(&model, fileName, data);
int primitiveIndex = 0; int primitiveIndex = 0;
for (unsigned int i = 0; i < data->scene->nodes_count; i++) for (unsigned int i = 0; i < data->scene->nodes_count; i++)
{ {
@ -4875,12 +4875,12 @@ static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCo
{ {
if (data->nodes[i].has_translation) memcpy(&output->framePoses[frame][i].translation, data->nodes[i].translation, 3*sizeof(float)); if (data->nodes[i].has_translation) memcpy(&output->framePoses[frame][i].translation, data->nodes[i].translation, 3*sizeof(float));
else output->framePoses[frame][i].translation = Vector3Zero(); else output->framePoses[frame][i].translation = Vector3Zero();
if (data->nodes[i].has_rotation) memcpy(&output->framePoses[frame][i], data->nodes[i].rotation, 4*sizeof(float)); if (data->nodes[i].has_rotation) memcpy(&output->framePoses[frame][i], data->nodes[i].rotation, 4*sizeof(float));
else output->framePoses[frame][i].rotation = QuaternionIdentity(); else output->framePoses[frame][i].rotation = QuaternionIdentity();
output->framePoses[frame][i].rotation = QuaternionNormalize(output->framePoses[frame][i].rotation); output->framePoses[frame][i].rotation = QuaternionNormalize(output->framePoses[frame][i].rotation);
if (data->nodes[i].has_scale) memcpy(&output->framePoses[frame][i].scale, data->nodes[i].scale, 3*sizeof(float)); if (data->nodes[i].has_scale) memcpy(&output->framePoses[frame][i].scale, data->nodes[i].scale, 3*sizeof(float));
else output->framePoses[frame][i].scale = Vector3One(); else output->framePoses[frame][i].scale = Vector3One();
} }
@ -4933,22 +4933,22 @@ static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCo
// 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) continue; if (shouldSkipFurtherTransformation) 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;
float values[3]; float values[3];
bool success = ReadGLTFValue(sampler->output, outputMin, values); bool success = ReadGLTFValue(sampler->output, outputMin, values);
translationStart.x = values[0]; translationStart.x = values[0];
translationStart.y = values[1]; translationStart.y = values[1];
translationStart.z = values[2]; translationStart.z = values[2];
success = ReadGLTFValue(sampler->output, outputMax, values) || success; success = ReadGLTFValue(sampler->output, outputMax, values) || success;
translationEnd.x = values[0]; translationEnd.x = values[0];
translationEnd.y = values[1]; translationEnd.y = values[1];
translationEnd.z = values[2]; translationEnd.z = values[2];
@ -4959,18 +4959,18 @@ static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCo
{ {
Vector4 rotationStart; Vector4 rotationStart;
Vector4 rotationEnd; Vector4 rotationEnd;
float values[4]; float values[4];
bool success = ReadGLTFValue(sampler->output, outputMin, &values); bool success = ReadGLTFValue(sampler->output, outputMin, &values);
rotationStart.x = values[0]; rotationStart.x = values[0];
rotationStart.y = values[1]; rotationStart.y = values[1];
rotationStart.z = values[2]; rotationStart.z = values[2];
rotationStart.w = values[3]; rotationStart.w = values[3];
success = ReadGLTFValue(sampler->output, outputMax, &values) || success; success = ReadGLTFValue(sampler->output, outputMax, &values) || success;
rotationEnd.x = values[0]; rotationEnd.x = values[0];
rotationEnd.y = values[1]; rotationEnd.y = values[1];
rotationEnd.z = values[2]; rotationEnd.z = values[2];
@ -4985,17 +4985,17 @@ static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCo
{ {
Vector3 scaleStart; Vector3 scaleStart;
Vector3 scaleEnd; Vector3 scaleEnd;
float values[3]; float values[3];
bool success = ReadGLTFValue(sampler->output, outputMin, &values); bool success = ReadGLTFValue(sampler->output, outputMin, &values);
scaleStart.x = values[0]; scaleStart.x = values[0];
scaleStart.y = values[1]; scaleStart.y = values[1];
scaleStart.z = values[2]; scaleStart.z = values[2];
success = ReadGLTFValue(sampler->output, outputMax, &values) || success; success = ReadGLTFValue(sampler->output, outputMax, &values) || success;
scaleEnd.x = values[0]; scaleEnd.x = values[0];
scaleEnd.y = values[1]; scaleEnd.y = values[1];
scaleEnd.z = values[2]; scaleEnd.z = values[2];
@ -5060,9 +5060,9 @@ void LoadGLTFMesh(cgltf_data* data, cgltf_mesh* mesh, Model* outModel, Matrix cu
outModel->meshes[(*primitiveIndex)].vertexCount = (int)acc->count; outModel->meshes[(*primitiveIndex)].vertexCount = (int)acc->count;
int bufferSize = outModel->meshes[(*primitiveIndex)].vertexCount*3*sizeof(float); int bufferSize = outModel->meshes[(*primitiveIndex)].vertexCount*3*sizeof(float);
outModel->meshes[(*primitiveIndex)].animVertices = RL_MALLOC(bufferSize); outModel->meshes[(*primitiveIndex)].animVertices = RL_MALLOC(bufferSize);
outModel->meshes[(*primitiveIndex)].vertices = ReadGLTFValuesAs(acc, cgltf_component_type_r_32f, false); outModel->meshes[(*primitiveIndex)].vertices = ReadGLTFValuesAs(acc, cgltf_component_type_r_32f, false);
// Transform using the nodes matrix attributes // Transform using the nodes matrix attributes
for (unsigned int v = 0; v < outModel->meshes[(*primitiveIndex)].vertexCount; v++) for (unsigned int v = 0; v < outModel->meshes[(*primitiveIndex)].vertexCount; v++)
{ {
@ -5070,25 +5070,25 @@ void LoadGLTFMesh(cgltf_data* data, cgltf_mesh* mesh, Model* outModel, Matrix cu
outModel->meshes[(*primitiveIndex)].vertices[(v*3 + 0)], outModel->meshes[(*primitiveIndex)].vertices[(v*3 + 0)],
outModel->meshes[(*primitiveIndex)].vertices[(v*3 + 1)], outModel->meshes[(*primitiveIndex)].vertices[(v*3 + 1)],
outModel->meshes[(*primitiveIndex)].vertices[(v*3 + 2)] }; outModel->meshes[(*primitiveIndex)].vertices[(v*3 + 2)] };
vertex = Vector3Transform(vertex, currentTransform); vertex = Vector3Transform(vertex, currentTransform);
outModel->meshes[(*primitiveIndex)].vertices[(v*3 + 0)] = vertex.x; outModel->meshes[(*primitiveIndex)].vertices[(v*3 + 0)] = vertex.x;
outModel->meshes[(*primitiveIndex)].vertices[(v*3 + 1)] = vertex.y; outModel->meshes[(*primitiveIndex)].vertices[(v*3 + 1)] = vertex.y;
outModel->meshes[(*primitiveIndex)].vertices[(v*3 + 2)] = vertex.z; outModel->meshes[(*primitiveIndex)].vertices[(v*3 + 2)] = vertex.z;
} }
memcpy(outModel->meshes[(*primitiveIndex)].animVertices, outModel->meshes[(*primitiveIndex)].vertices, bufferSize); memcpy(outModel->meshes[(*primitiveIndex)].animVertices, outModel->meshes[(*primitiveIndex)].vertices, bufferSize);
} }
else if (mesh->primitives[p].attributes[j].type == cgltf_attribute_type_normal) else if (mesh->primitives[p].attributes[j].type == cgltf_attribute_type_normal)
{ {
cgltf_accessor *acc = mesh->primitives[p].attributes[j].data; cgltf_accessor *acc = mesh->primitives[p].attributes[j].data;
int bufferSize = (int)(acc->count*3*sizeof(float)); int bufferSize = (int)(acc->count*3*sizeof(float));
outModel->meshes[(*primitiveIndex)].animNormals = RL_MALLOC(bufferSize); outModel->meshes[(*primitiveIndex)].animNormals = RL_MALLOC(bufferSize);
outModel->meshes[(*primitiveIndex)].normals = ReadGLTFValuesAs(acc, cgltf_component_type_r_32f, false); outModel->meshes[(*primitiveIndex)].normals = ReadGLTFValuesAs(acc, cgltf_component_type_r_32f, false);
// Transform using the nodes matrix attributes // Transform using the nodes matrix attributes
for (unsigned int v = 0; v < outModel->meshes[(*primitiveIndex)].vertexCount; v++) for (unsigned int v = 0; v < outModel->meshes[(*primitiveIndex)].vertexCount; v++)
{ {
@ -5096,14 +5096,14 @@ void LoadGLTFMesh(cgltf_data* data, cgltf_mesh* mesh, Model* outModel, Matrix cu
outModel->meshes[(*primitiveIndex)].normals[(v*3 + 0)], outModel->meshes[(*primitiveIndex)].normals[(v*3 + 0)],
outModel->meshes[(*primitiveIndex)].normals[(v*3 + 1)], outModel->meshes[(*primitiveIndex)].normals[(v*3 + 1)],
outModel->meshes[(*primitiveIndex)].normals[(v*3 + 2)] }; outModel->meshes[(*primitiveIndex)].normals[(v*3 + 2)] };
normal = Vector3Transform(normal, currentTransform); normal = Vector3Transform(normal, currentTransform);
outModel->meshes[(*primitiveIndex)].normals[(v*3 + 0)] = normal.x; outModel->meshes[(*primitiveIndex)].normals[(v*3 + 0)] = normal.x;
outModel->meshes[(*primitiveIndex)].normals[(v*3 + 1)] = normal.y; outModel->meshes[(*primitiveIndex)].normals[(v*3 + 1)] = normal.y;
outModel->meshes[(*primitiveIndex)].normals[(v*3 + 2)] = normal.z; outModel->meshes[(*primitiveIndex)].normals[(v*3 + 2)] = normal.z;
} }
memcpy(outModel->meshes[(*primitiveIndex)].animNormals, outModel->meshes[(*primitiveIndex)].normals, bufferSize); memcpy(outModel->meshes[(*primitiveIndex)].animNormals, outModel->meshes[(*primitiveIndex)].normals, bufferSize);
} }
else if (mesh->primitives[p].attributes[j].type == cgltf_attribute_type_texcoord) else if (mesh->primitives[p].attributes[j].type == cgltf_attribute_type_texcoord)
@ -5116,14 +5116,14 @@ void LoadGLTFMesh(cgltf_data* data, cgltf_mesh* mesh, Model* outModel, Matrix cu
cgltf_accessor *acc = mesh->primitives[p].attributes[j].data; cgltf_accessor *acc = mesh->primitives[p].attributes[j].data;
unsigned int boneCount = acc->count; unsigned int boneCount = acc->count;
unsigned int totalBoneWeights = boneCount*4; unsigned int totalBoneWeights = boneCount*4;
outModel->meshes[(*primitiveIndex)].boneIds = RL_MALLOC(totalBoneWeights*sizeof(int)); outModel->meshes[(*primitiveIndex)].boneIds = RL_MALLOC(totalBoneWeights*sizeof(int));
short *bones = ReadGLTFValuesAs(acc, cgltf_component_type_r_16, false); short *bones = ReadGLTFValuesAs(acc, cgltf_component_type_r_16, false);
for (unsigned int a = 0; a < totalBoneWeights; a++) for (unsigned int a = 0; a < totalBoneWeights; a++)
{ {
outModel->meshes[(*primitiveIndex)].boneIds[a] = 0; outModel->meshes[(*primitiveIndex)].boneIds[a] = 0;
if (bones[a] < 0) continue; if (bones[a] < 0) continue;
cgltf_node* skinJoint = data->skins->joints[bones[a]]; cgltf_node* skinJoint = data->skins->joints[bones[a]];
for (unsigned int k = 0; k < data->nodes_count; k++) for (unsigned int k = 0; k < data->nodes_count; k++)
{ {
@ -5147,7 +5147,7 @@ void LoadGLTFMesh(cgltf_data* data, cgltf_mesh* mesh, Model* outModel, Matrix cu
outModel->meshes[(*primitiveIndex)].colors = ReadGLTFValuesAs(acc, cgltf_component_type_r_8u, true); outModel->meshes[(*primitiveIndex)].colors = ReadGLTFValuesAs(acc, cgltf_component_type_r_8u, true);
} }
} }
cgltf_accessor *acc = mesh->primitives[p].indices; cgltf_accessor *acc = mesh->primitives[p].indices;
if (acc) if (acc)
{ {
@ -5159,7 +5159,7 @@ void LoadGLTFMesh(cgltf_data* data, cgltf_mesh* mesh, Model* outModel, Matrix cu
// Unindexed mesh // Unindexed mesh
outModel->meshes[(*primitiveIndex)].triangleCount = outModel->meshes[(*primitiveIndex)].vertexCount/3; outModel->meshes[(*primitiveIndex)].triangleCount = outModel->meshes[(*primitiveIndex)].vertexCount/3;
} }
if (mesh->primitives[p].material) if (mesh->primitives[p].material)
{ {
// Compute the offset // Compute the offset
@ -5168,30 +5168,30 @@ void LoadGLTFMesh(cgltf_data* data, cgltf_mesh* mesh, Model* outModel, Matrix cu
else outModel->meshMaterial[(*primitiveIndex)] = outModel->materialCount - 1; else outModel->meshMaterial[(*primitiveIndex)] = outModel->materialCount - 1;
BindGLTFPrimitiveToBones(outModel, data, *primitiveIndex); BindGLTFPrimitiveToBones(outModel, data, *primitiveIndex);
(*primitiveIndex) = (*primitiveIndex) + 1; (*primitiveIndex) = (*primitiveIndex) + 1;
} }
} }
void LoadGLTFNode(cgltf_data* data, cgltf_node* node, Model* outModel, Matrix currentTransform, int* primitiveIndex, const char *fileName) void LoadGLTFNode(cgltf_data* data, cgltf_node* node, Model* outModel, Matrix currentTransform, int* primitiveIndex, const char *fileName)
{ {
Matrix nodeTransform = { Matrix nodeTransform = {
node->matrix[0], node->matrix[4], node->matrix[8], node->matrix[12], node->matrix[0], node->matrix[4], node->matrix[8], node->matrix[12],
node->matrix[1], node->matrix[5], node->matrix[9], node->matrix[13], node->matrix[1], node->matrix[5], node->matrix[9], node->matrix[13],
node->matrix[2], node->matrix[6], node->matrix[10], node->matrix[14], node->matrix[2], node->matrix[6], node->matrix[10], node->matrix[14],
node->matrix[3], node->matrix[7], node->matrix[11], node->matrix[15] }; node->matrix[3], node->matrix[7], node->matrix[11], node->matrix[15] };
currentTransform = MatrixMultiply(nodeTransform, currentTransform); currentTransform = MatrixMultiply(nodeTransform, currentTransform);
if (node->mesh != NULL) LoadGLTFMesh(data, node->mesh, outModel, currentTransform, primitiveIndex, fileName); if (node->mesh != NULL) LoadGLTFMesh(data, node->mesh, outModel, currentTransform, primitiveIndex, fileName);
for (unsigned int i = 0; i < node->children_count; i++) LoadGLTFNode(data, node->children[i], outModel, currentTransform, primitiveIndex, fileName); for (unsigned int i = 0; i < node->children_count; i++) LoadGLTFNode(data, node->children[i], outModel, currentTransform, primitiveIndex, fileName);
} }
static void GetGLTFPrimitiveCount(cgltf_node* node, int* outCount) static void GetGLTFPrimitiveCount(cgltf_node* node, int* outCount)
{ {
if (node->mesh != NULL) *outCount += node->mesh->primitives_count; if (node->mesh != NULL) *outCount += node->mesh->primitives_count;
for (unsigned int i = 0; i < node->children_count; i++) GetGLTFPrimitiveCount(node->children[i], outCount); for (unsigned int i = 0; i < node->children_count; i++) GetGLTFPrimitiveCount(node->children[i], outCount);
} }

View File

@ -738,7 +738,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
wave.sampleSize = 16; wave.sampleSize = 16;
wave.channels = wav.channels; wave.channels = wav.channels;
wave.data = (short *)RL_MALLOC(wave.sampleCount*sizeof(short)); wave.data = (short *)RL_MALLOC(wave.sampleCount*sizeof(short));
// NOTE: We are forcing conversion to 16bit sample size on reading // NOTE: We are forcing conversion to 16bit sample size on reading
drwav_read_pcm_frames_s16(&wav, wav.totalPCMFrameCount, wave.data); drwav_read_pcm_frames_s16(&wav, wav.totalPCMFrameCount, wave.data);
} }
@ -761,7 +761,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
wave.channels = info.channels; wave.channels = info.channels;
wave.sampleCount = (unsigned int)stb_vorbis_stream_length_in_samples(oggData)*info.channels; // Independent by channel wave.sampleCount = (unsigned int)stb_vorbis_stream_length_in_samples(oggData)*info.channels; // Independent by channel
wave.data = (short *)RL_MALLOC(wave.sampleCount*sizeof(short)); wave.data = (short *)RL_MALLOC(wave.sampleCount*sizeof(short));
// NOTE: Get the number of samples to process (be careful! we ask for number of shorts!) // NOTE: Get the number of samples to process (be careful! we ask for number of shorts!)
stb_vorbis_get_samples_short_interleaved(oggData, info.channels, (short *)wave.data, wave.sampleCount); stb_vorbis_get_samples_short_interleaved(oggData, info.channels, (short *)wave.data, wave.sampleCount);
stb_vorbis_close(oggData); stb_vorbis_close(oggData);
@ -770,10 +770,10 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_FLAC) #if defined(SUPPORT_FILEFORMAT_FLAC)
else if (TextIsEqual(fileExtLower, ".flac")) else if (TextIsEqual(fileExtLower, ".flac"))
{ {
unsigned long long int totalFrameCount = 0; unsigned long long int totalFrameCount = 0;
// NOTE: We are forcing conversion to 16bit sample size on reading // NOTE: We are forcing conversion to 16bit sample size on reading
wave.data = drflac_open_memory_and_read_pcm_frames_s16(fileData, dataSize, &wave.channels, &wave.sampleRate, &totalFrameCount, NULL); wave.data = drflac_open_memory_and_read_pcm_frames_s16(fileData, dataSize, &wave.channels, &wave.sampleRate, &totalFrameCount, NULL);
wave.sampleSize = 16; wave.sampleSize = 16;
@ -787,7 +787,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
{ {
drmp3_config config = { 0 }; drmp3_config config = { 0 };
unsigned long long int totalFrameCount = 0; unsigned long long int totalFrameCount = 0;
// NOTE: We are forcing conversion to 32bit float sample size on reading // NOTE: We are forcing conversion to 32bit float sample size on reading
wave.data = drmp3_open_memory_and_read_pcm_frames_f32(fileData, dataSize, &config, &totalFrameCount, NULL); wave.data = drmp3_open_memory_and_read_pcm_frames_f32(fileData, dataSize, &config, &totalFrameCount, NULL);
wave.sampleSize = 32; wave.sampleSize = 32;
@ -799,11 +799,11 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
wave.sampleCount = (int)totalFrameCount*wave.channels; wave.sampleCount = (int)totalFrameCount*wave.channels;
} }
else TRACELOG(LOG_WARNING, "WAVE: Failed to load MP3 data"); else TRACELOG(LOG_WARNING, "WAVE: Failed to load MP3 data");
} }
#endif #endif
else TRACELOG(LOG_WARNING, "WAVE: Data format not supported"); else TRACELOG(LOG_WARNING, "WAVE: Data format not supported");
TRACELOG(LOG_INFO, "WAVE: Data loaded successfully (%i Hz, %i bit, %i channels)", wave.sampleRate, wave.sampleSize, wave.channels); TRACELOG(LOG_INFO, "WAVE: Data loaded successfully (%i Hz, %i bit, %i channels)", wave.sampleRate, wave.sampleSize, wave.channels);
return wave; return wave;
@ -900,7 +900,7 @@ bool ExportWave(Wave wave, const char *fileName)
if (false) { } if (false) { }
#if defined(SUPPORT_FILEFORMAT_WAV) #if defined(SUPPORT_FILEFORMAT_WAV)
else if (IsFileExtension(fileName, ".wav")) else if (IsFileExtension(fileName, ".wav"))
{ {
drwav wav = { 0 }; drwav wav = { 0 };
drwav_data_format format = { 0 }; drwav_data_format format = { 0 };

View File

@ -646,8 +646,8 @@ typedef enum {
typedef enum { typedef enum {
MOUSE_CURSOR_DEFAULT = 0, // Default pointer shape MOUSE_CURSOR_DEFAULT = 0, // Default pointer shape
MOUSE_CURSOR_ARROW = 1, // Arrow shape MOUSE_CURSOR_ARROW = 1, // Arrow shape
MOUSE_CURSOR_IBEAM = 2, // Text writing cursor shape MOUSE_CURSOR_IBEAM = 2, // Text writing cursor shape
MOUSE_CURSOR_CROSSHAIR = 3, // Cross shape MOUSE_CURSOR_CROSSHAIR = 3, // Cross shape
MOUSE_CURSOR_POINTING_HAND = 4, // Pointing hand cursor MOUSE_CURSOR_POINTING_HAND = 4, // Pointing hand cursor
MOUSE_CURSOR_RESIZE_EW = 5, // Horizontal resize/move arrow shape MOUSE_CURSOR_RESIZE_EW = 5, // Horizontal resize/move arrow shape
MOUSE_CURSOR_RESIZE_NS = 6, // Vertical resize/move arrow shape MOUSE_CURSOR_RESIZE_NS = 6, // Vertical resize/move arrow shape

View File

@ -1567,10 +1567,10 @@ RLAPI const char *CodepointToUtf8(int codepoint, int *byteLength)
int *LoadCodepoints(const char *text, int *count) int *LoadCodepoints(const char *text, int *count)
{ {
int textLength = TextLength(text); int textLength = TextLength(text);
int bytesProcessed = 0; int bytesProcessed = 0;
int codepointsCount = 0; int codepointsCount = 0;
// Allocate a big enough buffer to store as many codepoints as text bytes // Allocate a big enough buffer to store as many codepoints as text bytes
int *codepoints = RL_CALLOC(textLength, sizeof(int)); int *codepoints = RL_CALLOC(textLength, sizeof(int));
@ -1650,7 +1650,7 @@ int GetCodepoint(const char *text, int *bytesProcessed)
else if ((octet & 0xe0) == 0xc0) else if ((octet & 0xe0) == 0xc0)
{ {
// Two octets // Two octets
// [0]xC2-DF [1]UTF8-tail(x80-BF) // [0]xC2-DF [1]UTF8-tail(x80-BF)
unsigned char octet1 = text[1]; unsigned char octet1 = text[1];

View File

@ -379,7 +379,7 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i
else if (TextIsEqual(fileExtLower, ".astc")) image = LoadASTC(fileData, dataSize); else if (TextIsEqual(fileExtLower, ".astc")) image = LoadASTC(fileData, dataSize);
#endif #endif
else TRACELOG(LOG_WARNING, "IMAGE: Data format not supported"); else TRACELOG(LOG_WARNING, "IMAGE: Data format not supported");
TRACELOG(LOG_INFO, "IMAGE: Data loaded successfully (%ix%i | %s | %i mipmaps)", image.width, image.height, rlGetPixelFormatName(image.format), image.mipmaps); TRACELOG(LOG_INFO, "IMAGE: Data loaded successfully (%ix%i | %s | %i mipmaps)", image.width, image.height, rlGetPixelFormatName(image.format), image.mipmaps);
return image; return image;
@ -3218,8 +3218,8 @@ void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest,
float width = (float)texture.width; float width = (float)texture.width;
float height = (float)texture.height; float height = (float)texture.height;
float patchWidth = (dest.width <= 0.0f)? 0.0f : dest.width; float patchWidth = ((int)dest.width <= 0)? 0.0f : dest.width;
float patchHeight = (dest.height <= 0.0f)? 0.0f : dest.height; float patchHeight = ((int)dest.height <= 0)? 0.0f : dest.height;
if (nPatchInfo.source.width < 0) nPatchInfo.source.x -= nPatchInfo.source.width; if (nPatchInfo.source.width < 0) nPatchInfo.source.x -= nPatchInfo.source.width;
if (nPatchInfo.source.height < 0) nPatchInfo.source.y -= nPatchInfo.source.height; if (nPatchInfo.source.height < 0) nPatchInfo.source.y -= nPatchInfo.source.height;
@ -3233,14 +3233,15 @@ void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest,
float rightBorder = (float)nPatchInfo.right; float rightBorder = (float)nPatchInfo.right;
float bottomBorder = (float)nPatchInfo.bottom; float bottomBorder = (float)nPatchInfo.bottom;
// adjust the lateral (left and right) border widths in case patchWidth < texture.width // Adjust the lateral (left and right) border widths in case patchWidth < texture.width
if (patchWidth <= (leftBorder + rightBorder) && nPatchInfo.layout != NPATCH_THREE_PATCH_VERTICAL) if (patchWidth <= (leftBorder + rightBorder) && nPatchInfo.layout != NPATCH_THREE_PATCH_VERTICAL)
{ {
drawCenter = false; drawCenter = false;
leftBorder = (leftBorder/(leftBorder + rightBorder))*patchWidth; leftBorder = (leftBorder/(leftBorder + rightBorder))*patchWidth;
rightBorder = patchWidth - leftBorder; rightBorder = patchWidth - leftBorder;
} }
// adjust the lateral (top and bottom) border heights in case patchHeight < texture.height
// Adjust the lateral (top and bottom) border heights in case patchHeight < texture.height
if (patchHeight <= (topBorder + bottomBorder) && nPatchInfo.layout != NPATCH_THREE_PATCH_HORIZONTAL) if (patchHeight <= (topBorder + bottomBorder) && nPatchInfo.layout != NPATCH_THREE_PATCH_HORIZONTAL)
{ {
drawMiddle = false; drawMiddle = false;