Removed trailing spaces

This commit is contained in:
Ray 2021-03-19 19:43:44 +01:00
parent e28f754fbe
commit 9909068714
9 changed files with 175 additions and 175 deletions

View File

@ -171,7 +171,7 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
# Starting on August 2020, minimum required target API is Android 10 (API level 29)
ANDROID_ARCH ?= arm64
ANDROID_API_VERSION ?= 29
# Android required path variables
# NOTE: Starting with Android NDK r21, no more toolchain generation is required, NDK is the toolchain on itself
ifeq ($(OS),Windows_NT)
@ -181,7 +181,7 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
ANDROID_NDK ?= /usr/lib/android/ndk
ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64
endif
# NOTE: Sysroot can also be reference from $(ANDROID_NDK)/sysroot
ANDROID_SYSROOT ?= $(ANDROID_TOOLCHAIN)/sysroot
@ -197,7 +197,7 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
ifeq ($(ANDROID_ARCH),x86_64)
ANDROID_ARCH_NAME = x86_64
endif
endif
# Define raylib graphics api depending on selected platform
@ -413,7 +413,7 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
NATIVE_APP_GLUE = $(ANDROID_NDK)/sources/android/native_app_glue
# Include android_native_app_glue.h
INCLUDE_PATHS += -I$(NATIVE_APP_GLUE)
# Android required libraries
INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include
ifeq ($(ANDROID_ARCH),arm)
@ -507,7 +507,7 @@ else
cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so
endif
ifeq ($(PLATFORM_OS),OSX)
$(CC) -dynamiclib -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib $(OBJS) $(LDFLAGS) -compatibility_version $(RAYLIB_API_VERSION) -current_version $(RAYLIB_VERSION) -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo
$(CC) -dynamiclib -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib $(OBJS) $(LDFLAGS) -compatibility_version $(RAYLIB_API_VERSION) -current_version $(RAYLIB_VERSION) -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo
install_name_tool -id "lib$(RAYLIB_LIB_NAME).$(VERSION).dylib" $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib
@echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib)!"
cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).dylib
@ -606,7 +606,7 @@ physac.o : physac.c physac.h
# Compile android_native_app_glue module
android_native_app_glue.o : $(NATIVE_APP_GLUE)/android_native_app_glue.c
$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
# Install generated and needed files to desired directories.
# On GNU/Linux and BSDs, there are some standard directories that contain extra

View File

@ -40,7 +40,7 @@
#define SUPPORT_SSH_KEYBOARD_RPI 1
// Draw a mouse pointer on screen
#define SUPPORT_MOUSE_CURSOR_NATIVE 1
// Setting a higher resolution can improve the accuracy of time-out intervals in wait functions.
// Setting a higher resolution can improve the accuracy of time-out intervals in wait functions.
// However, it can also reduce overall system performance, because the thread scheduler switches tasks more often.
#define SUPPORT_WINMM_HIGHRES_TIMER 1
// Use busy wait loop for timing sync, if not defined, a high-resolution timer is setup and used

View File

@ -153,7 +153,7 @@
#if defined(SUPPORT_COMPRESSION_API)
#define SINFL_IMPLEMENTATION
#include "external/sinfl.h"
#define SDEFL_IMPLEMENTATION
#include "external/sdefl.h"
#endif
@ -906,7 +906,7 @@ void CloseWindow(void)
close(CORE.Input.Keyboard.fd);
CORE.Input.Keyboard.fd = -1;
}
for (int i = 0; i < sizeof(CORE.Input.eventWorker)/sizeof(InputEventWorker); ++i)
{
if (CORE.Input.eventWorker[i].threadId)
@ -914,7 +914,7 @@ void CloseWindow(void)
pthread_join(CORE.Input.eventWorker[i].threadId, NULL);
}
}
if (CORE.Input.Gamepad.threadId) pthread_join(CORE.Input.Gamepad.threadId, NULL);
#endif
@ -1044,24 +1044,24 @@ void ToggleFullscreen(void)
if (!monitor)
{
TRACELOG(LOG_WARNING, "GLFW: Failed to get monitor");
CORE.Window.fullscreen = false; // Toggle fullscreen flag
CORE.Window.flags &= ~FLAG_FULLSCREEN_MODE;
glfwSetWindowMonitor(CORE.Window.handle, NULL, 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE);
return;
}
CORE.Window.fullscreen = true; // Toggle fullscreen flag
CORE.Window.flags |= FLAG_FULLSCREEN_MODE;
glfwSetWindowMonitor(CORE.Window.handle, monitor, 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE);
}
else
{
CORE.Window.fullscreen = false; // Toggle fullscreen flag
CORE.Window.flags &= ~FLAG_FULLSCREEN_MODE;
glfwSetWindowMonitor(CORE.Window.handle, NULL, CORE.Window.position.x, CORE.Window.position.y, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE);
}
@ -1506,7 +1506,7 @@ int GetCurrentMonitor(void)
int y = 0;
glfwGetWindowPos(CORE.Window.handle, &x, &y);
for (int i = 0; i < monitorCount; i++)
{
int mx = 0;
@ -1557,7 +1557,7 @@ int GetMonitorWidth(int monitor)
{
int count = 0;
const GLFWvidmode *modes = glfwGetVideoModes(monitors[monitor], &count);
// We return the maximum resolution available, the last one in the modes array
if (count > 0) return modes[count - 1].width;
else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor");
@ -1578,7 +1578,7 @@ int GetMonitorHeight(int monitor)
{
int count = 0;
const GLFWvidmode *modes = glfwGetVideoModes(monitors[monitor], &count);
// We return the maximum resolution available, the last one in the modes array
if (count > 0) return modes[count - 1].height;
else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor");
@ -1912,7 +1912,7 @@ void BeginMode3D(Camera3D camera)
rlLoadIdentity(); // Reset current matrix (projection)
float aspect = (float)CORE.Window.currentFbo.width/(float)CORE.Window.currentFbo.height;
double top = 0;
if (camera.projection == CAMERA_PERSPECTIVE) top = RL_CULL_DISTANCE_NEAR*tan(camera.fovy*0.5*DEG2RAD);
else if (camera.projection == CAMERA_ORTHOGRAPHIC) top = camera.fovy/2.0;
@ -2600,7 +2600,7 @@ unsigned char *CompressData(unsigned char *data, int dataLength, int *compDataLe
int bounds = sdefl_bound(dataLength);
compData = (unsigned char *)RL_CALLOC(bounds, 1);
*compDataLength = sdeflate(&sdefl, compData, data, dataLength, COMPRESSION_QUALITY_DEFLATE); // Compression level 8, same as stbwi
TraceLog(LOG_INFO, "SYSTEM: Data compressed: Original size: %i -> Comp. size: %i\n", dataLength, compDataLength);
#endif
@ -2617,10 +2617,10 @@ unsigned char *DecompressData(unsigned char *compData, int compDataLength, int *
data = RL_CALLOC(MAX_DECOMPRESSION_SIZE*1024*1024, 1);
int length = sinflate(data, compData, compDataLength);
unsigned char *temp = RL_REALLOC(data, length);
if (temp != NULL) data = temp;
else TRACELOG(LOG_WARNING, "SYSTEM: Failed to re-allocate required decompression memory");
*dataLength = length;
TraceLog(LOG_INFO, "SYSTEM: Data compressed: Original size: %i -> Comp. size: %i\n", dataLength, compDataLength);
@ -3184,7 +3184,7 @@ Vector2 GetTouchPosition(int index)
#if defined(PLATFORM_WEB) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM) || defined(PLATFORM_UWP)
if (index < MAX_TOUCH_POINTS) position = CORE.Input.Touch.position[index];
else TRACELOG(LOG_WARNING, "INPUT: Required touch point out of range (Max touch points: %i)", MAX_TOUCH_POINTS);
// TODO: Touch position scaling required?
#endif
@ -3297,7 +3297,7 @@ static bool InitGraphicsDevice(int width, int height)
else glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_FALSE);
#endif
if (CORE.Window.flags & FLAG_MSAA_4X_HINT)
if (CORE.Window.flags & FLAG_MSAA_4X_HINT)
{
TRACELOG(LOG_INFO, "DISPLAY: Trying to enable MSAA x4");
glfwWindowHint(GLFW_SAMPLES, 4); // Tries to enable multisampling x4 (MSAA), default is 0
@ -3339,7 +3339,7 @@ static bool InitGraphicsDevice(int width, int height)
}
#if defined(PLATFORM_DESKTOP)
// NOTE: GLFW 3.4+ defers initialization of the Joystick subsystem on the first call to any Joystick related functions.
// NOTE: GLFW 3.4+ defers initialization of the Joystick subsystem on the first call to any Joystick related functions.
// Forcing this initialization here avoids doing it on `PollInputEvents` called by `EndDrawing` after first frame has been just drawn.
// The initialization will still happen and possible delays still occur, but before the window is shown, which is a nicer experience.
// REF: https://github.com/raysan5/raylib/issues/1554
@ -4189,9 +4189,9 @@ static void InitTimer(void)
{
srand((unsigned int)time(NULL)); // Initialize random seed
// Setting a higher resolution can improve the accuracy of time-out intervals in wait functions.
// However, it can also reduce overall system performance, because the thread scheduler switches tasks more often.
// High resolutions can also prevent the CPU power management system from entering power-saving modes.
// Setting a higher resolution can improve the accuracy of time-out intervals in wait functions.
// However, it can also reduce overall system performance, because the thread scheduler switches tasks more often.
// High resolutions can also prevent the CPU power management system from entering power-saving modes.
// Setting a higher resolution does not improve the accuracy of the high-resolution performance counter.
#if defined(_WIN32) && defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP) && !defined(PLATFORM_UWP)
timeBeginPeriod(1); // Setup high-resolution timer to 1ms (granularity of 1-2 ms)
@ -4280,7 +4280,7 @@ static void PollInputEvents(void)
#if defined(PLATFORM_RPI) || defined(PLATFORM_DRM)
// Register previous keys states
for (int i = 0; i < 512; i++) CORE.Input.Keyboard.previousKeyState[i] = CORE.Input.Keyboard.currentKeyState[i];
PollKeyboardEvents();
// Register previous mouse states
@ -4291,7 +4291,7 @@ static void PollInputEvents(void)
CORE.Input.Mouse.previousButtonState[i] = CORE.Input.Mouse.currentButtonState[i];
CORE.Input.Mouse.currentButtonState[i] = CORE.Input.Mouse.currentButtonStateEvdev[i];
}
// Register gamepads buttons events
for (int i = 0; i < MAX_GAMEPADS; i++)
{
@ -4366,8 +4366,8 @@ static void PollInputEvents(void)
for (int k = 0; (buttons != NULL) && (k < GLFW_GAMEPAD_BUTTON_DPAD_LEFT + 1) && (k < MAX_GAMEPAD_BUTTONS); k++)
{
GamepadButton button = -1;
GamepadButton button = -1;
switch (k)
{
case GLFW_GAMEPAD_BUTTON_Y: button = GAMEPAD_BUTTON_RIGHT_FACE_UP; break;
@ -4391,7 +4391,7 @@ static void PollInputEvents(void)
case GLFW_GAMEPAD_BUTTON_RIGHT_THUMB: button = GAMEPAD_BUTTON_RIGHT_THUMB; break;
default: break;
}
if (button != -1) // Check for valid button
{
if (buttons[k] == GLFW_PRESS)
@ -4450,7 +4450,7 @@ static void PollInputEvents(void)
for (int j = 0; (j < gamepadState.numButtons) && (j < MAX_GAMEPAD_BUTTONS); j++)
{
GamepadButton button = -1;
// Gamepad Buttons reference: https://www.w3.org/TR/gamepad/#gamepad-interface
switch (j)
{
@ -4472,7 +4472,7 @@ static void PollInputEvents(void)
case 15: button = GAMEPAD_BUTTON_LEFT_FACE_RIGHT; break;
default: break;
}
if (button != -1) // Check for valid button
{
if (gamepadState.digitalButton[j] == 1)
@ -4609,10 +4609,10 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height)
CORE.Window.currentFbo.width = width;
CORE.Window.currentFbo.height = height;
CORE.Window.resizedLastFrame = true;
if(IsWindowFullscreen())
return;
// Set current screen size
CORE.Window.screen.width = width;
CORE.Window.screen.height = height;
@ -4697,7 +4697,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
}
}
else
#endif // SUPPORT_GIF_RECORDING
#endif // SUPPORT_GIF_RECORDING
{
TakeScreenshot(TextFormat("screenshot%03i.png", screenshotCounter));
screenshotCounter++;
@ -5406,7 +5406,7 @@ static void InitEvdevInput(void)
char path[MAX_FILEPATH_LENGTH];
DIR *directory;
struct dirent *entity;
// Initialise keyboard file descriptor
CORE.Input.Keyboard.fd = -1;
@ -5669,7 +5669,7 @@ static void PollKeyboardEvents(void)
struct input_event event;
int keycode;
// Try to read data from the keyboard and only continue if successful
while (read(fd, &event, sizeof(event)) == (int)sizeof(event))
{
@ -5762,7 +5762,7 @@ static void *EventThread(void *arg)
{
CORE.Input.Mouse.position.x = (event.value - worker->absRange.x)*CORE.Window.screen.width/worker->absRange.width; // Scale acording to absRange
CORE.Input.Touch.position[0].x = (event.value - worker->absRange.x)*CORE.Window.screen.width/worker->absRange.width; // Scale acording to absRange
#if defined(SUPPORT_GESTURES_SYSTEM)
touchAction = TOUCH_MOVE;
gestureUpdate = true;
@ -5807,7 +5807,7 @@ static void *EventThread(void *arg)
if(event.code == ABS_PRESSURE)
{
int previousMouseLeftButtonState = CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_LEFT_BUTTON];
if(!event.value && previousMouseLeftButtonState)
{
CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_LEFT_BUTTON] = 0;
@ -5817,7 +5817,7 @@ static void *EventThread(void *arg)
gestureUpdate = true;
#endif
}
if(event.value && !previousMouseLeftButtonState)
{
CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_LEFT_BUTTON] = 1;
@ -6079,7 +6079,7 @@ void UWPKeyDownEvent(int key, bool down, bool controlKey)
}
}
else
#endif // SUPPORT_GIF_RECORDING
#endif // SUPPORT_GIF_RECORDING
{
TakeScreenshot(TextFormat("screenshot%03i.png", screenshotCounter));
screenshotCounter++;

View File

@ -859,7 +859,7 @@ void UnloadMesh(Mesh mesh)
{
// Unload rlgl mesh vboId data
rlUnloadMesh(&mesh);
RL_FREE(mesh.vertices);
RL_FREE(mesh.texcoords);
RL_FREE(mesh.normals);
@ -1033,7 +1033,7 @@ ModelAnimation *LoadModelAnimations(const char *fileName, int *animCount)
#if defined(SUPPORT_FILEFORMAT_GLTF)
if (IsFileExtension(fileName, ".gltf;.glb")) animations = LoadGLTFModelAnimations(fileName, animCount);
#endif
return animations;
}
@ -1093,7 +1093,7 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
model.meshes[m].animNormals[vCounter + 1] = animNormal.y;
model.meshes[m].animNormals[vCounter + 2] = animNormal.z;
}
vCounter += 3;
boneCounter += 4;
}
@ -3300,11 +3300,11 @@ static ModelAnimation* LoadIQMModelAnimations(const char* fileName, int* animCou
{
#define IQM_MAGIC "INTERQUAKEMODEL" // IQM file magic number
#define IQM_VERSION 2 // only IQM version 2 supported
unsigned int fileSize = 0;
unsigned char *fileData = LoadFileData(fileName, &fileSize);
unsigned char *fileDataPtr = fileData;
typedef struct IQMHeader {
char magic[16];
unsigned int version;
@ -3321,60 +3321,60 @@ static ModelAnimation* LoadIQMModelAnimations(const char* fileName, int* animCou
unsigned int num_comment, ofs_comment;
unsigned int num_extensions, ofs_extensions;
} IQMHeader;
typedef struct IQMPose {
int parent;
unsigned int mask;
float channeloffset[10];
float channelscale[10];
} IQMPose;
typedef struct IQMAnim {
unsigned int name;
unsigned int first_frame, num_frames;
float framerate;
unsigned int flags;
} IQMAnim;
// In case file can not be read, return an empty model
if (fileDataPtr == NULL) return NULL;
// Read IQM header
IQMHeader *iqmHeader = (IQMHeader *)fileDataPtr;
if (memcmp(iqmHeader->magic, IQM_MAGIC, sizeof(IQM_MAGIC)) != 0)
{
TRACELOG(LOG_WARNING, "MODEL: [%s] IQM file is not a valid model", fileName);
return NULL;
}
if (iqmHeader->version != IQM_VERSION)
{
TRACELOG(LOG_WARNING, "MODEL: [%s] IQM file version not supported (%i)", fileName, iqmHeader->version);
return NULL;
}
// Get bones data
IQMPose *poses = RL_MALLOC(iqmHeader->num_poses*sizeof(IQMPose));
//fseek(iqmFile, iqmHeader->ofs_poses, SEEK_SET);
//fread(poses, iqmHeader->num_poses*sizeof(IQMPose), 1, iqmFile);
memcpy(poses, fileDataPtr + iqmHeader->ofs_poses, iqmHeader->num_poses*sizeof(IQMPose));
// Get animations data
*animCount = iqmHeader->num_anims;
IQMAnim *anim = RL_MALLOC(iqmHeader->num_anims*sizeof(IQMAnim));
//fseek(iqmFile, iqmHeader->ofs_anims, SEEK_SET);
//fread(anim, iqmHeader->num_anims*sizeof(IQMAnim), 1, iqmFile);
memcpy(anim, fileDataPtr + iqmHeader->ofs_anims, iqmHeader->num_anims*sizeof(IQMAnim));
ModelAnimation *animations = RL_MALLOC(iqmHeader->num_anims*sizeof(ModelAnimation));
// frameposes
unsigned short *framedata = RL_MALLOC(iqmHeader->num_frames*iqmHeader->num_framechannels*sizeof(unsigned short));
//fseek(iqmFile, iqmHeader->ofs_frames, SEEK_SET);
//fread(framedata, iqmHeader->num_frames*iqmHeader->num_framechannels*sizeof(unsigned short), 1, iqmFile);
memcpy(framedata, fileDataPtr + iqmHeader->ofs_frames, iqmHeader->num_frames*iqmHeader->num_framechannels*sizeof(unsigned short));
for (unsigned int a = 0; a < iqmHeader->num_anims; a++)
{
animations[a].frameCount = anim[a].num_frames;
@ -3382,105 +3382,105 @@ static ModelAnimation* LoadIQMModelAnimations(const char* fileName, int* animCou
animations[a].bones = RL_MALLOC(iqmHeader->num_poses*sizeof(BoneInfo));
animations[a].framePoses = RL_MALLOC(anim[a].num_frames*sizeof(Transform *));
// animations[a].framerate = anim.framerate; // TODO: Use framerate?
for (unsigned int j = 0; j < iqmHeader->num_poses; j++)
{
strcpy(animations[a].bones[j].name, "ANIMJOINTNAME");
animations[a].bones[j].parent = poses[j].parent;
}
for (unsigned int j = 0; j < anim[a].num_frames; j++) animations[a].framePoses[j] = RL_MALLOC(iqmHeader->num_poses*sizeof(Transform));
int dcounter = anim[a].first_frame*iqmHeader->num_framechannels;
for (unsigned int frame = 0; frame < anim[a].num_frames; frame++)
{
for (unsigned int i = 0; i < iqmHeader->num_poses; i++)
{
animations[a].framePoses[frame][i].translation.x = poses[i].channeloffset[0];
if (poses[i].mask & 0x01)
{
animations[a].framePoses[frame][i].translation.x += framedata[dcounter]*poses[i].channelscale[0];
dcounter++;
}
animations[a].framePoses[frame][i].translation.y = poses[i].channeloffset[1];
if (poses[i].mask & 0x02)
{
animations[a].framePoses[frame][i].translation.y += framedata[dcounter]*poses[i].channelscale[1];
dcounter++;
}
animations[a].framePoses[frame][i].translation.z = poses[i].channeloffset[2];
if (poses[i].mask & 0x04)
{
animations[a].framePoses[frame][i].translation.z += framedata[dcounter]*poses[i].channelscale[2];
dcounter++;
}
animations[a].framePoses[frame][i].rotation.x = poses[i].channeloffset[3];
if (poses[i].mask & 0x08)
{
animations[a].framePoses[frame][i].rotation.x += framedata[dcounter]*poses[i].channelscale[3];
dcounter++;
}
animations[a].framePoses[frame][i].rotation.y = poses[i].channeloffset[4];
if (poses[i].mask & 0x10)
{
animations[a].framePoses[frame][i].rotation.y += framedata[dcounter]*poses[i].channelscale[4];
dcounter++;
}
animations[a].framePoses[frame][i].rotation.z = poses[i].channeloffset[5];
if (poses[i].mask & 0x20)
{
animations[a].framePoses[frame][i].rotation.z += framedata[dcounter]*poses[i].channelscale[5];
dcounter++;
}
animations[a].framePoses[frame][i].rotation.w = poses[i].channeloffset[6];
if (poses[i].mask & 0x40)
{
animations[a].framePoses[frame][i].rotation.w += framedata[dcounter]*poses[i].channelscale[6];
dcounter++;
}
animations[a].framePoses[frame][i].scale.x = poses[i].channeloffset[7];
if (poses[i].mask & 0x80)
{
animations[a].framePoses[frame][i].scale.x += framedata[dcounter]*poses[i].channelscale[7];
dcounter++;
}
animations[a].framePoses[frame][i].scale.y = poses[i].channeloffset[8];
if (poses[i].mask & 0x100)
{
animations[a].framePoses[frame][i].scale.y += framedata[dcounter]*poses[i].channelscale[8];
dcounter++;
}
animations[a].framePoses[frame][i].scale.z = poses[i].channeloffset[9];
if (poses[i].mask & 0x200)
{
animations[a].framePoses[frame][i].scale.z += framedata[dcounter]*poses[i].channelscale[9];
dcounter++;
}
animations[a].framePoses[frame][i].rotation = QuaternionNormalize(animations[a].framePoses[frame][i].rotation);
}
}
// Build frameposes
for (unsigned int frame = 0; frame < anim[a].num_frames; frame++)
{
@ -3496,13 +3496,13 @@ static ModelAnimation* LoadIQMModelAnimations(const char* fileName, int* animCou
}
}
}
RL_FREE(fileData);
RL_FREE(framedata);
RL_FREE(poses);
RL_FREE(anim);
return animations;
}
@ -3667,17 +3667,17 @@ static bool GLTFReadValue(cgltf_accessor* acc, unsigned int index, void* variabl
{
return false;
}
memcpy(variable, index == 0 ? acc->min : acc->max, elements * size);
return true;
}
unsigned int stride = size * elements;
memset(variable, 0, stride);
if(acc->buffer_view == NULL || acc->buffer_view->buffer == NULL || acc->buffer_view->buffer->data == NULL)
return false;
void* readPosition = ((char*)acc->buffer_view->buffer->data) + (index * stride) + acc->buffer_view->offset + acc->offset;
memcpy(variable, readPosition, stride);
return true;
@ -3740,10 +3740,10 @@ static Model LoadGLTF(const char *fileName)
model.boneCount = (int)data->nodes_count;
model.bones = RL_CALLOC(model.boneCount, sizeof(BoneInfo));
model.bindPose = RL_CALLOC(model.boneCount, sizeof(Transform));
InitGLTFBones(&model, data);
LoadGLTFMaterial(&model, fileName, data);
int primitiveIndex = 0;
for (unsigned int i = 0; i < data->meshes_count; i++)
@ -3759,7 +3759,7 @@ static Model LoadGLTF(const char *fileName)
int bufferSize = model.meshes[primitiveIndex].vertexCount * 3 * sizeof(float);
model.meshes[primitiveIndex].vertices = RL_MALLOC(bufferSize);
model.meshes[primitiveIndex].animVertices = RL_MALLOC(bufferSize);
if(acc->component_type == cgltf_component_type_r_32f)
{
for(int a = 0; a < acc->count; a++)
@ -3783,17 +3783,17 @@ static Model LoadGLTF(const char *fileName)
// TODO: Support normalized unsigned byte/unsigned short vertices
TRACELOG(LOG_WARNING, "MODEL: [%s] glTF vertices must be float or int", fileName);
}
memcpy(model.meshes[primitiveIndex].animVertices, model.meshes[primitiveIndex].vertices, bufferSize);
}
else if (data->meshes[i].primitives[p].attributes[j].type == cgltf_attribute_type_normal)
{
cgltf_accessor *acc = data->meshes[i].primitives[p].attributes[j].data;
int bufferSize = (int)(acc->count*3*sizeof(float));
model.meshes[primitiveIndex].normals = RL_MALLOC(bufferSize);
model.meshes[primitiveIndex].animNormals = RL_MALLOC(bufferSize);
if(acc->component_type == cgltf_component_type_r_32f)
{
for(int a = 0; a < acc->count; a++)
@ -3817,7 +3817,7 @@ static Model LoadGLTF(const char *fileName)
// TODO: Support normalized unsigned byte/unsigned short normals
TRACELOG(LOG_WARNING, "MODEL: [%s] glTF normals must be float or int", fileName);
}
memcpy(model.meshes[primitiveIndex].animNormals, model.meshes[primitiveIndex].normals, bufferSize);
}
else if (data->meshes[i].primitives[p].attributes[j].type == cgltf_attribute_type_texcoord)
@ -3827,7 +3827,7 @@ static Model LoadGLTF(const char *fileName)
if (acc->component_type == cgltf_component_type_r_32f)
{
model.meshes[primitiveIndex].texcoords = RL_MALLOC(acc->count*2*sizeof(float));
for(int a = 0; a < acc->count; a++)
{
GLTFReadValue(acc, a, model.meshes[primitiveIndex].texcoords + (a * 2), 2, sizeof(float));
@ -3847,9 +3847,9 @@ static Model LoadGLTF(const char *fileName)
else if (data->meshes[i].primitives[p].attributes[j].type == cgltf_attribute_type_weights)
{
cgltf_accessor *acc = data->meshes[i].primitives[p].attributes[j].data;
model.meshes[primitiveIndex].boneWeights = RL_MALLOC(acc->count*4*sizeof(float));
if(acc->component_type == cgltf_component_type_r_32f)
{
for(int a = 0; a < acc->count; a++)
@ -3879,7 +3879,7 @@ static Model LoadGLTF(const char *fileName)
cgltf_accessor *acc = data->meshes[i].primitives[p].indices;
LoadGLTFModelIndices(&model, acc, primitiveIndex);
if (data->meshes[i].primitives[p].material)
{
// Compute the offset
@ -3889,14 +3889,14 @@ static Model LoadGLTF(const char *fileName)
{
model.meshMaterial[primitiveIndex] = model.materialCount - 1;
}
BindGLTFPrimitiveToBones(&model, data, primitiveIndex);
primitiveIndex++;
}
}
cgltf_free(data);
}
else TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to load glTF data", fileName);
@ -3913,7 +3913,7 @@ static void InitGLTFBones(Model* model, const cgltf_data* data)
strcpy(model->bones[j].name, data->nodes[j].name == 0 ? "ANIMJOINT" : data->nodes[j].name);
model->bones[j].parent = (data->nodes[j].parent != NULL) ? data->nodes[j].parent - data->nodes : -1;
}
for (unsigned int i = 0; i < data->nodes_count; i++)
{
if (data->nodes[i].has_translation) memcpy(&model->bindPose[i].translation, data->nodes[i].translation, 3 * sizeof(float));
@ -3923,11 +3923,11 @@ static void InitGLTFBones(Model* model, const cgltf_data* data)
else model->bindPose[i].rotation = QuaternionIdentity();
model->bindPose[i].rotation = QuaternionNormalize(model->bindPose[i].rotation);
if (data->nodes[i].has_scale) memcpy(&model->bindPose[i].scale, data->nodes[i].scale, 3 * sizeof(float));
else model->bindPose[i].scale = Vector3One();
}
{
bool* completedBones = RL_CALLOC(model->boneCount, sizeof(bool));
int numberCompletedBones = 0;
@ -4032,7 +4032,7 @@ static void LoadGLTFMaterial(Model* model, const char* fileName, const cgltf_dat
}
}
}
model->materials[model->materialCount - 1] = LoadMaterialDefault();
}
@ -4047,7 +4047,7 @@ static void LoadGLTFBoneAttribute(Model* model, cgltf_accessor* jointsAccessor,
{
GLTFReadValue(jointsAccessor, a, bones + (a * 4), 4, sizeof(short));
}
for (unsigned int a = 0; a < jointsAccessor->count * 4; a++)
{
cgltf_node* skinJoint = data->skins->joints[bones[a]];
@ -4072,11 +4072,11 @@ static void LoadGLTFBoneAttribute(Model* model, cgltf_accessor* jointsAccessor,
{
GLTFReadValue(jointsAccessor, a, bones + (a * 4), 4, sizeof(unsigned char));
}
for (unsigned int a = 0; a < jointsAccessor->count * 4; a++)
{
cgltf_node* skinJoint = data->skins->joints[bones[a]];
for (unsigned int k = 0; k < data->nodes_count; k++)
{
if (&(data->nodes[k]) == skinJoint)
@ -4118,7 +4118,7 @@ static void BindGLTFPrimitiveToBones(Model* model, const cgltf_data* data, int p
model->meshes[primitiveIndex].boneIds[b] = 0;
model->meshes[primitiveIndex].boneWeights[b] = 0.0f;
}
}
Vector3 boundVertex = { 0 };
@ -4157,7 +4157,7 @@ static void BindGLTFPrimitiveToBones(Model* model, const cgltf_data* data, int p
model->meshes[primitiveIndex].normals[vCounter + 1] = boundNormal.y;
model->meshes[primitiveIndex].normals[vCounter + 2] = boundNormal.z;
}
vCounter += 3;
boneCounter += 4;
}
@ -4174,7 +4174,7 @@ static void LoadGLTFModelIndices(Model* model, cgltf_accessor* indexAccessor, in
{
model->meshes[primitiveIndex].triangleCount = (int)indexAccessor->count / 3;
model->meshes[primitiveIndex].indices = RL_MALLOC(model->meshes[primitiveIndex].triangleCount * 3 * sizeof(unsigned short));
unsigned short readValue = 0;
for(int a = 0; a < indexAccessor->count; a++)
{
@ -4186,7 +4186,7 @@ static void LoadGLTFModelIndices(Model* model, cgltf_accessor* indexAccessor, in
{
model->meshes[primitiveIndex].triangleCount = (int)indexAccessor->count / 3;
model->meshes[primitiveIndex].indices = RL_MALLOC(model->meshes[primitiveIndex].triangleCount * 3 * sizeof(unsigned short));
unsigned char readValue = 0;
for(int a = 0; a < indexAccessor->count; a++)
{
@ -4232,16 +4232,16 @@ static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCo
// glTF file loading
unsigned int dataSize = 0;
unsigned char *fileData = LoadFileData(fileName, &dataSize);
ModelAnimation *animations = NULL;
if (fileData == NULL) return animations;
// glTF data loading
cgltf_options options = { 0 };
cgltf_data *data = NULL;
cgltf_result result = cgltf_parse(&options, fileData, dataSize, &data);
if (result == cgltf_result_success)
{
TRACELOG(LOG_INFO, "MODEL: [%s] glTF animations (%s) count: %i", fileName, (data->file_type == 2)? "glb" :
@ -4263,34 +4263,34 @@ static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCo
// - input - points in time this transformation happens
// - output - the transformation amount at the given input points in time
// - interpolation - the type of interpolation to use between the frames
cgltf_animation *animation = data->animations + a;
ModelAnimation *output = animations + a;
// 30 frames sampled per second
const float TIMESTEP = (1.0f / 30.0f);
float animationDuration = 0.0f;
// Getting the max animation time to consider for animation duration
for (unsigned int i = 0; i < animation->channels_count; i++)
{
cgltf_animation_channel* channel = animation->channels + i;
int frameCounts = (int)channel->sampler->input->count;
float lastFrameTime = 0.0f;
if (GLTFReadValue(channel->sampler->input, frameCounts - 1, &lastFrameTime, 1, sizeof(float)))
{
animationDuration = fmaxf(lastFrameTime, animationDuration);
}
}
output->frameCount = (int)(animationDuration / TIMESTEP);
output->boneCount = (int)data->nodes_count;
output->bones = RL_MALLOC(output->boneCount*sizeof(BoneInfo));
output->framePoses = RL_MALLOC(output->frameCount*sizeof(Transform *));
// output->framerate = // TODO: Use framerate instead of const timestep
// Name and parent bones
for (unsigned int j = 0; j < data->nodes_count; j++)
{
@ -4303,7 +4303,7 @@ static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCo
for (int frame = 0; frame < output->frameCount; frame++)
{
output->framePoses[frame] = RL_MALLOC(output->frameCount*data->nodes_count*sizeof(Transform));
for (unsigned int i = 0; i < data->nodes_count; i++)
{
output->framePoses[frame][i].translation = Vector3Zero();
@ -4312,15 +4312,15 @@ static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCo
output->framePoses[frame][i].scale = Vector3One();
}
}
// for each single transformation type on single bone
for (unsigned int channelId = 0; channelId < animation->channels_count; channelId++)
{
cgltf_animation_channel* channel = animation->channels + channelId;
cgltf_animation_sampler* sampler = channel->sampler;
int boneId = (int)(channel->target_node - data->nodes);
for (int frame = 0; frame < output->frameCount; frame++)
{
bool shouldSkipFurtherTransformation = true;
@ -4328,7 +4328,7 @@ static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCo
int outputMax = 0;
float frameTime = frame * TIMESTEP;
float lerpPercent = 0.0f;
// For this transformation:
// getting between which input values the current frame time position
// and also what is the percent to use in the linear interpolation later
@ -4342,7 +4342,7 @@ static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCo
shouldSkipFurtherTransformation = false;
outputMin = (j == 0) ? 0 : j - 1;
outputMax = j;
float previousInputTime = 0.0f;
if (GLTFReadValue(sampler->input, outputMin, &previousInputTime, 1, sizeof(float)))
{
@ -4351,13 +4351,13 @@ static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCo
lerpPercent = (frameTime - previousInputTime)/(inputFrameTime - previousInputTime);
}
}
break;
}
}
}
else break;
}
// If the current transformation has no information for the current frame time point
if (shouldSkipFurtherTransformation) continue;
@ -4365,20 +4365,20 @@ static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCo
{
Vector3 translationStart;
Vector3 translationEnd;
bool success = GLTFReadValue(sampler->output, outputMin, &translationStart, 3, sizeof(float));
success = GLTFReadValue(sampler->output, outputMax, &translationEnd, 3, sizeof(float)) || success;
if (success) output->framePoses[frame][boneId].translation = Vector3Lerp(translationStart, translationEnd, lerpPercent);
}
if (channel->target_path == cgltf_animation_path_type_rotation)
{
Quaternion rotationStart;
Quaternion rotationEnd;
bool success = GLTFReadValue(sampler->output, outputMin, &rotationStart, 4, sizeof(float));
success = GLTFReadValue(sampler->output, outputMax, &rotationEnd, 4, sizeof(float)) || success;
if (success)
{
output->framePoses[frame][boneId].rotation = QuaternionLerp(rotationStart, rotationEnd, lerpPercent);
@ -4389,15 +4389,15 @@ static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCo
{
Vector3 scaleStart;
Vector3 scaleEnd;
bool success = GLTFReadValue(sampler->output, outputMin, &scaleStart, 3, sizeof(float));
success = GLTFReadValue(sampler->output, outputMax, &scaleEnd, 3, sizeof(float)) || success;
if (success) output->framePoses[frame][boneId].scale = Vector3Lerp(scaleStart, scaleEnd, lerpPercent);
}
}
}
// Build frameposes
for (int frame = 0; frame < output->frameCount; frame++)
{
@ -4432,13 +4432,13 @@ static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCo
}
}
cgltf_free(data);
}
else TRACELOG(LOG_WARNING, ": [%s] Failed to load glTF data", fileName);
RL_FREE(fileData);
return animations;
}

View File

@ -1302,10 +1302,10 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int d
{
Music music = { 0 };
bool musicLoaded = false;
char fileExtLower[16] = { 0 };
strcpy(fileExtLower, TextToLower(fileType));
if (false) { }
#if defined(SUPPORT_FILEFORMAT_WAV)
else if (TextIsEqual(fileExtLower, ".wav"))
@ -1313,10 +1313,10 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int d
drwav *ctxWav = RL_CALLOC(1, sizeof(drwav));
bool success = drwav_init_memory(ctxWav, (const void*)data, dataSize, NULL);
music.ctxType = MUSIC_AUDIO_WAV;
music.ctxData = ctxWav;
if (success)
{
int sampleSize = ctxWav->bitsPerSample;
@ -1414,14 +1414,14 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int d
int result = 0;
jar_mod_init(ctxMod);
// copy data to allocated memory for default UnloadMusicStream
unsigned char *newData = RL_MALLOC(dataSize);
int it = dataSize / sizeof(unsigned char);
for (int i = 0; i < it; i++){
newData[i] = data[i];
}
// Memory loaded version for jar_mod_load_file()
if (dataSize && dataSize < 32*1024*1024)
{
@ -1429,7 +1429,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int d
ctxMod->modfile = newData;
if(jar_mod_load(ctxMod, (void*)ctxMod->modfile, dataSize)) result = dataSize;
}
if (result > 0)
{
music.ctxType = MUSIC_MODULE_MOD;
@ -1444,7 +1444,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int d
musicLoaded = true;
}
}
#endif
#endif
else TRACELOG(LOG_WARNING, "STREAM: [%s] Fileformat not supported", fileType);
if (!musicLoaded)

View File

@ -984,7 +984,7 @@ RMDEF Matrix MatrixRotateZYX(Vector3 ang)
result.m0 = cz*cy;
result.m1 = cz*sy*sx - cx*sz;
result.m2 = sz*sx + cz*cx*sy;
result.m3 = 0;
result.m3 = 0;
result.m4 = cy*sz;
result.m5 = cz*cx + sz*sy*sx;
@ -995,7 +995,7 @@ RMDEF Matrix MatrixRotateZYX(Vector3 ang)
result.m9 = cy*sx;
result.m10 = cy*cx;
result.m11 = 0;
result.m12 = 0;
result.m13 = 0;
result.m14 = 0;
@ -1294,11 +1294,11 @@ RMDEF Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount)
float cosHalfTheta = q1.x*q2.x + q1.y*q2.y + q1.z*q2.z + q1.w*q2.w;
if (cosHalfTheta < 0)
if (cosHalfTheta < 0)
{
q2.x = -q2.x; q2.y = -q2.y; q2.z = -q2.z; q2.w = -q2.w;
cosHalfTheta = -cosHalfTheta;
}
}
if (fabs(cosHalfTheta) >= 1.0f) result = q1;
else if (cosHalfTheta > 0.95f) result = QuaternionNlerp(q1, q2, amount);
@ -1478,7 +1478,7 @@ RMDEF Quaternion QuaternionFromEuler(float pitch, float yaw, float roll)
q.y = x0*y1*z0 + x1*y0*z1;
q.z = x0*y0*z1 - x1*y1*z0;
q.w = x0*y0*z0 + x1*y1*z1;
return q;
}

View File

@ -1690,17 +1690,17 @@ void rlglInit(int width, int height)
if ((glGenVertexArrays != NULL) && (glBindVertexArray != NULL) && (glDeleteVertexArrays != NULL)) RLGL.ExtSupported.vao = true;
}
// Check instanced rendering support
if (strcmp(extList[i], (const char *)"GL_ANGLE_instanced_arrays") == 0)
if (strcmp(extList[i], (const char *)"GL_ANGLE_instanced_arrays") == 0)
{
glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)eglGetProcAddress("glDrawArraysInstancedANGLE");
glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)eglGetProcAddress("glDrawElementsInstancedANGLE");
glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISOREXTPROC)eglGetProcAddress("glVertexAttribDivisorANGLE");
if ((glDrawArraysInstanced != NULL) && (glDrawElementsInstanced != NULL) && (glVertexAttribDivisor != NULL)) RLGL.ExtSupported.instancing = true;
}
// Check NPOT textures support
// NOTE: Only check on OpenGL ES, OpenGL 3.3 has NPOT textures full support as core feature
if (strcmp(extList[i], (const char *)"GL_OES_texture_npot") == 0) RLGL.ExtSupported.texNPOT = true;
@ -2507,7 +2507,7 @@ void rlLoadMesh(Mesh *mesh, bool dynamic)
TRACELOG(LOG_WARNING, "VAO: [ID %i] Trying to re-load an already loaded mesh", mesh->vaoId);
return;
}
mesh->vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VERTEX_BUFFERS, sizeof(unsigned int));
mesh->vaoId = 0; // Vertex Array Object
@ -4075,10 +4075,10 @@ static unsigned int CompileShader(const char *shaderStr, int type)
if (success == GL_FALSE)
{
TRACELOG(LOG_WARNING, "SHADER: [ID %i] Failed to compile shader code", shader);
int maxLength = 0;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &maxLength);
if (maxLength > 0)
{
int length = 0;
@ -4127,8 +4127,8 @@ static unsigned int LoadShaderProgram(unsigned int vShaderId, unsigned int fShad
int maxLength = 0;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &maxLength);
if (maxLength > 0)
if (maxLength > 0)
{
int length = 0;
char *log = RL_CALLOC(maxLength, sizeof(char));

View File

@ -658,7 +658,7 @@ void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color
rlEnableTexture(GetShapesTexture().id);
rlBegin(RL_QUADS);
rlNormal3f(0.0f, 0.0f, 1.0f);
rlColor4ub(color.r, color.g, color.b, color.a);
@ -673,7 +673,7 @@ void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color
rlTexCoord2f((GetShapesTextureRec().x + GetShapesTextureRec().width)/GetShapesTexture().width, GetShapesTextureRec().y/GetShapesTexture().height);
rlVertex2f(topLeft.x, topLeft.y);
rlEnd();
rlDisableTexture();
}

View File

@ -3239,7 +3239,7 @@ void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2
rlEnableTexture(texture.id);
rlBegin(RL_QUADS);
rlColor4ub(tint.r, tint.g, tint.b, tint.a);
rlNormal3f(0.0f, 0.0f, 1.0f); // Normal vector pointing towards viewer
@ -3262,10 +3262,10 @@ void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2
if (flipX) rlTexCoord2f(source.x/width, source.y/height);
else rlTexCoord2f((source.x + source.width)/width, source.y/height);
rlVertex2f(topLeft.x, topLeft.y);
rlEnd();
rlDisableTexture();
// NOTE: Vertex position can be transformed using matrices
// but the process is way more costly than just calculating
// the vertex positions manually, like done above.