Selaa lähdekoodia

Remove trail spaces

pull/1830/head
Ray 4 vuotta sitten
vanhempi
commit
4b93feb172
7 muutettua tiedostoa jossa 91 lisäystä ja 91 poistoa
  1. +63
    -63
      src/core.c
  2. +21
    -21
      src/models.c
  3. +2
    -2
      src/raudio.c
  4. +1
    -1
      src/raymath.h
  5. +2
    -2
      src/shapes.c
  6. +1
    -1
      src/text.c
  7. +1
    -1
      src/textures.c

+ 63
- 63
src/core.c Näytä tiedosto

@ -547,27 +547,27 @@ typedef enum {
static const char *autoEventTypeName[] = { static const char *autoEventTypeName[] = {
"EVENT_NONE", "EVENT_NONE",
"INPUT_KEY_UP",
"INPUT_KEY_DOWN",
"INPUT_KEY_PRESSED",
"INPUT_KEY_RELEASED",
"INPUT_MOUSE_BUTTON_UP",
"INPUT_MOUSE_BUTTON_DOWN",
"INPUT_MOUSE_POSITION",
"INPUT_MOUSE_WHEEL_MOTION",
"INPUT_GAMEPAD_CONNECT",
"INPUT_GAMEPAD_DISCONNECT",
"INPUT_GAMEPAD_BUTTON_UP",
"INPUT_KEY_UP",
"INPUT_KEY_DOWN",
"INPUT_KEY_PRESSED",
"INPUT_KEY_RELEASED",
"INPUT_MOUSE_BUTTON_UP",
"INPUT_MOUSE_BUTTON_DOWN",
"INPUT_MOUSE_POSITION",
"INPUT_MOUSE_WHEEL_MOTION",
"INPUT_GAMEPAD_CONNECT",
"INPUT_GAMEPAD_DISCONNECT",
"INPUT_GAMEPAD_BUTTON_UP",
"INPUT_GAMEPAD_BUTTON_DOWN", "INPUT_GAMEPAD_BUTTON_DOWN",
"INPUT_GAMEPAD_AXIS_MOTION", "INPUT_GAMEPAD_AXIS_MOTION",
"INPUT_TOUCH_UP",
"INPUT_TOUCH_DOWN",
"INPUT_TOUCH_POSITION",
"INPUT_GESTURE",
"WINDOW_CLOSE",
"WINDOW_MAXIMIZE",
"WINDOW_MINIMIZE",
"WINDOW_RESIZE",
"INPUT_TOUCH_UP",
"INPUT_TOUCH_DOWN",
"INPUT_TOUCH_POSITION",
"INPUT_GESTURE",
"WINDOW_CLOSE",
"WINDOW_MAXIMIZE",
"WINDOW_MINIMIZE",
"WINDOW_RESIZE",
"ACTION_TAKE_SCREENSHOT", "ACTION_TAKE_SCREENSHOT",
"ACTION_SETTARGETFPS" "ACTION_SETTARGETFPS"
}; };
@ -835,7 +835,7 @@ void InitWindow(int width, int height, const char *title)
CORE.Window.ready = InitGraphicsDevice(width, height); CORE.Window.ready = InitGraphicsDevice(width, height);
// If graphic device is no properly initialized, we end program // If graphic device is no properly initialized, we end program
if (!CORE.Window.ready)
if (!CORE.Window.ready)
{ {
TRACELOG(LOG_FATAL, "Failed to initialize Graphic Device"); TRACELOG(LOG_FATAL, "Failed to initialize Graphic Device");
return; return;
@ -896,12 +896,12 @@ void InitWindow(int width, int height, const char *title)
CORE.Input.Mouse.currentPosition.x = (float)CORE.Window.screen.width/2.0f; CORE.Input.Mouse.currentPosition.x = (float)CORE.Window.screen.width/2.0f;
CORE.Input.Mouse.currentPosition.y = (float)CORE.Window.screen.height/2.0f; CORE.Input.Mouse.currentPosition.y = (float)CORE.Window.screen.height/2.0f;
#if defined(SUPPORT_EVENTS_AUTOMATION) #if defined(SUPPORT_EVENTS_AUTOMATION)
events = (AutomationEvent *)malloc(MAX_CODE_AUTOMATION_EVENTS*sizeof(AutomationEvent)); events = (AutomationEvent *)malloc(MAX_CODE_AUTOMATION_EVENTS*sizeof(AutomationEvent));
CORE.Time.frameCounter = 0; CORE.Time.frameCounter = 0;
#endif #endif
#endif // PLATFORM_DESKTOP || PLATFORM_WEB || PLATFORM_RPI || PLATFORM_DRM || PLATFORM_UWP #endif // PLATFORM_DESKTOP || PLATFORM_WEB || PLATFORM_RPI || PLATFORM_DRM || PLATFORM_UWP
} }
@ -2040,12 +2040,12 @@ void EndDrawing(void)
} }
PollInputEvents(); // Poll user events PollInputEvents(); // Poll user events
#if defined(SUPPORT_EVENTS_AUTOMATION) #if defined(SUPPORT_EVENTS_AUTOMATION)
if (eventsRecording) RecordAutomationEvent(CORE.Time.frameCounter); if (eventsRecording) RecordAutomationEvent(CORE.Time.frameCounter);
// TODO: When should we play? After/before/replace PollInputEvents()? // TODO: When should we play? After/before/replace PollInputEvents()?
if (eventsPlaying)
if (eventsPlaying)
{ {
if (CORE.Time.frameCounter >= eventCount) eventsPlaying = false; if (CORE.Time.frameCounter >= eventCount) eventsPlaying = false;
PlayAutomationEvent(CORE.Time.frameCounter); PlayAutomationEvent(CORE.Time.frameCounter);
@ -4813,7 +4813,7 @@ static void PollInputEvents(void)
// Register previous mouse wheel state // Register previous mouse wheel state
CORE.Input.Mouse.previousWheelMove = CORE.Input.Mouse.currentWheelMove; CORE.Input.Mouse.previousWheelMove = CORE.Input.Mouse.currentWheelMove;
CORE.Input.Mouse.currentWheelMove = 0.0f; CORE.Input.Mouse.currentWheelMove = 0.0f;
// Register previous mouse position // Register previous mouse position
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition; CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
#endif #endif
@ -5070,7 +5070,7 @@ static void SwapBuffers(void)
{ {
gbm_surface_release_buffer(CORE.Window.gbmSurface, CORE.Window.prevBO); gbm_surface_release_buffer(CORE.Window.gbmSurface, CORE.Window.prevBO);
} }
CORE.Window.prevBO = bo; CORE.Window.prevBO = bo;
#endif // PLATFORM_DRM #endif // PLATFORM_DRM
#endif // PLATFORM_ANDROID || PLATFORM_RPI || PLATFORM_DRM || PLATFORM_UWP #endif // PLATFORM_ANDROID || PLATFORM_RPI || PLATFORM_DRM || PLATFORM_UWP
@ -5190,7 +5190,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
else if (key == GLFW_KEY_F11 && action == GLFW_PRESS) else if (key == GLFW_KEY_F11 && action == GLFW_PRESS)
{ {
eventsRecording = !eventsRecording; eventsRecording = !eventsRecording;
// On finish recording, we export events into a file // On finish recording, we export events into a file
if (!eventsRecording) ExportAutomationEvents("eventsrec.rep"); if (!eventsRecording) ExportAutomationEvents("eventsrec.rep");
} }
@ -5198,7 +5198,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
{ {
LoadAutomationEvents("eventsrec.rep"); LoadAutomationEvents("eventsrec.rep");
eventsPlaying = true; eventsPlaying = true;
TRACELOG(LOG_WARNING, "eventsPlaying enabled!"); TRACELOG(LOG_WARNING, "eventsPlaying enabled!");
} }
#endif #endif
@ -6796,22 +6796,22 @@ static int FindNearestConnectorMode(const drmModeConnector *connector, uint widt
static void LoadAutomationEvents(const char *fileName) static void LoadAutomationEvents(const char *fileName)
{ {
//unsigned char fileId[4] = { 0 }; //unsigned char fileId[4] = { 0 };
// Load binary // Load binary
/* /*
FILE *repFile = fopen(fileName, "rb"); FILE *repFile = fopen(fileName, "rb");
fread(fileId, 4, 1, repFile); fread(fileId, 4, 1, repFile);
if ((fileId[0] == 'r') && (fileId[1] == 'E') && (fileId[2] == 'P') && (fileId[1] == ' ')) if ((fileId[0] == 'r') && (fileId[1] == 'E') && (fileId[2] == 'P') && (fileId[1] == ' '))
{ {
fread(&eventCount, sizeof(int), 1, repFile); fread(&eventCount, sizeof(int), 1, repFile);
TraceLog(LOG_WARNING, "Events loaded: %i\n", eventCount); TraceLog(LOG_WARNING, "Events loaded: %i\n", eventCount);
fread(events, sizeof(AutomationEvent), eventCount, repFile); fread(events, sizeof(AutomationEvent), eventCount, repFile);
} }
fclose(repFile); fclose(repFile);
*/ */
// Load events (text file) // Load events (text file)
FILE *repFile = fopen(fileName, "rt"); FILE *repFile = fopen(fileName, "rt");
@ -6827,20 +6827,20 @@ static void LoadAutomationEvents(const char *fileName)
if (buffer[0] == 'c') sscanf(buffer, "c %i", &eventCount); if (buffer[0] == 'c') sscanf(buffer, "c %i", &eventCount);
else if (buffer[0] == 'e') else if (buffer[0] == 'e')
{ {
sscanf(buffer, "e %d %d %d %d %d", &events[count].frame, &events[count].type,
sscanf(buffer, "e %d %d %d %d %d", &events[count].frame, &events[count].type,
&events[count].params[0], &events[count].params[1], &events[count].params[2]); &events[count].params[0], &events[count].params[1], &events[count].params[2]);
count++; count++;
} }
fgets(buffer, 256, repFile); fgets(buffer, 256, repFile);
} }
if (count != eventCount) TRACELOG(LOG_WARNING, "Events count provided is different than count"); if (count != eventCount) TRACELOG(LOG_WARNING, "Events count provided is different than count");
fclose(repFile); fclose(repFile);
} }
TRACELOG(LOG_WARNING, "Events loaded: %i", eventCount); TRACELOG(LOG_WARNING, "Events loaded: %i", eventCount);
} }
@ -6858,23 +6858,23 @@ static void ExportAutomationEvents(const char *fileName)
fwrite(events, sizeof(AutomationEvent), eventCount, repFile); fwrite(events, sizeof(AutomationEvent), eventCount, repFile);
fclose(repFile); fclose(repFile);
*/ */
// Export events as text // Export events as text
FILE *repFile = fopen(fileName, "wt"); FILE *repFile = fopen(fileName, "wt");
if (repFile != NULL) if (repFile != NULL)
{ {
fprintf(repFile, "# Automation events list\n"); fprintf(repFile, "# Automation events list\n");
fprintf(repFile, "# c <events_count>\n"); fprintf(repFile, "# c <events_count>\n");
fprintf(repFile, "# e <frame> <event_type> <param0> <param1> <param2> // <event_type_name>\n"); fprintf(repFile, "# e <frame> <event_type> <param0> <param1> <param2> // <event_type_name>\n");
fprintf(repFile, "c %i\n", eventCount); fprintf(repFile, "c %i\n", eventCount);
for (int i = 0; i < eventCount; i++) for (int i = 0; i < eventCount; i++)
{ {
fprintf(repFile, "e %i %i %i %i %i // %s\n", events[i].frame, events[i].type,
fprintf(repFile, "e %i %i %i %i %i // %s\n", events[i].frame, events[i].type,
events[i].params[0], events[i].params[1], events[i].params[2], autoEventTypeName[events[i].type]); events[i].params[0], events[i].params[1], events[i].params[2], autoEventTypeName[events[i].type]);
} }
fclose(repFile); fclose(repFile);
} }
} }
@ -6893,11 +6893,11 @@ static void RecordAutomationEvent(unsigned int frame)
events[eventCount].params[0] = key; events[eventCount].params[0] = key;
events[eventCount].params[1] = 0; events[eventCount].params[1] = 0;
events[eventCount].params[2] = 0; events[eventCount].params[2] = 0;
TRACELOG(LOG_INFO, "[%i] INPUT_KEY_UP: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]); TRACELOG(LOG_INFO, "[%i] INPUT_KEY_UP: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]);
eventCount++; eventCount++;
} }
// INPUT_KEY_DOWN // INPUT_KEY_DOWN
if (CORE.Input.Keyboard.currentKeyState[key]) if (CORE.Input.Keyboard.currentKeyState[key])
{ {
@ -6922,11 +6922,11 @@ static void RecordAutomationEvent(unsigned int frame)
events[eventCount].params[0] = button; events[eventCount].params[0] = button;
events[eventCount].params[1] = 0; events[eventCount].params[1] = 0;
events[eventCount].params[2] = 0; events[eventCount].params[2] = 0;
TRACELOG(LOG_INFO, "[%i] INPUT_MOUSE_BUTTON_UP: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]); TRACELOG(LOG_INFO, "[%i] INPUT_MOUSE_BUTTON_UP: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]);
eventCount++; eventCount++;
} }
// INPUT_MOUSE_BUTTON_DOWN // INPUT_MOUSE_BUTTON_DOWN
if (CORE.Input.Mouse.currentButtonState[button]) if (CORE.Input.Mouse.currentButtonState[button])
{ {
@ -6940,7 +6940,7 @@ static void RecordAutomationEvent(unsigned int frame)
eventCount++; eventCount++;
} }
} }
// INPUT_MOUSE_POSITION (only saved if changed) // INPUT_MOUSE_POSITION (only saved if changed)
if (((int)CORE.Input.Mouse.currentPosition.x != (int)CORE.Input.Mouse.previousPosition.x) || if (((int)CORE.Input.Mouse.currentPosition.x != (int)CORE.Input.Mouse.previousPosition.x) ||
((int)CORE.Input.Mouse.currentPosition.y != (int)CORE.Input.Mouse.previousPosition.y)) ((int)CORE.Input.Mouse.currentPosition.y != (int)CORE.Input.Mouse.previousPosition.y))
@ -6954,7 +6954,7 @@ static void RecordAutomationEvent(unsigned int frame)
TRACELOG(LOG_INFO, "[%i] INPUT_MOUSE_POSITION: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]); TRACELOG(LOG_INFO, "[%i] INPUT_MOUSE_POSITION: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]);
eventCount++; eventCount++;
} }
// INPUT_MOUSE_WHEEL_MOTION // INPUT_MOUSE_WHEEL_MOTION
if ((int)CORE.Input.Mouse.currentWheelMove != (int)CORE.Input.Mouse.previousWheelMove) if ((int)CORE.Input.Mouse.currentWheelMove != (int)CORE.Input.Mouse.previousWheelMove)
{ {
@ -6967,7 +6967,7 @@ static void RecordAutomationEvent(unsigned int frame)
TRACELOG(LOG_INFO, "[%i] INPUT_MOUSE_WHEEL_MOTION: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]); TRACELOG(LOG_INFO, "[%i] INPUT_MOUSE_WHEEL_MOTION: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]);
eventCount++; eventCount++;
} }
for (int id = 0; id < MAX_TOUCH_POINTS; id++) for (int id = 0; id < MAX_TOUCH_POINTS; id++)
{ {
// INPUT_TOUCH_UP // INPUT_TOUCH_UP
@ -6982,7 +6982,7 @@ static void RecordAutomationEvent(unsigned int frame)
TRACELOG(LOG_INFO, "[%i] INPUT_TOUCH_UP: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]); TRACELOG(LOG_INFO, "[%i] INPUT_TOUCH_UP: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]);
eventCount++; eventCount++;
} }
// INPUT_TOUCH_DOWN // INPUT_TOUCH_DOWN
if (CORE.Input.Touch.currentTouchState[id]) if (CORE.Input.Touch.currentTouchState[id])
{ {
@ -6991,11 +6991,11 @@ static void RecordAutomationEvent(unsigned int frame)
events[eventCount].params[0] = id; events[eventCount].params[0] = id;
events[eventCount].params[1] = 0; events[eventCount].params[1] = 0;
events[eventCount].params[2] = 0; events[eventCount].params[2] = 0;
TRACELOG(LOG_INFO, "[%i] INPUT_TOUCH_DOWN: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]); TRACELOG(LOG_INFO, "[%i] INPUT_TOUCH_DOWN: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]);
eventCount++; eventCount++;
} }
// INPUT_TOUCH_POSITION // INPUT_TOUCH_POSITION
// TODO: It requires the id! // TODO: It requires the id!
/* /*
@ -7013,7 +7013,7 @@ static void RecordAutomationEvent(unsigned int frame)
} }
*/ */
} }
for (int gamepad = 0; gamepad < MAX_GAMEPADS; gamepad++) for (int gamepad = 0; gamepad < MAX_GAMEPADS; gamepad++)
{ {
// INPUT_GAMEPAD_CONNECT // INPUT_GAMEPAD_CONNECT
@ -7024,7 +7024,7 @@ static void RecordAutomationEvent(unsigned int frame)
// TODO: Save gamepad connect event // TODO: Save gamepad connect event
} }
*/ */
// INPUT_GAMEPAD_DISCONNECT // INPUT_GAMEPAD_DISCONNECT
/* /*
if ((CORE.Input.Gamepad.currentState[gamepad] != CORE.Input.Gamepad.previousState[gamepad]) && if ((CORE.Input.Gamepad.currentState[gamepad] != CORE.Input.Gamepad.previousState[gamepad]) &&
@ -7033,7 +7033,7 @@ static void RecordAutomationEvent(unsigned int frame)
// TODO: Save gamepad disconnect event // TODO: Save gamepad disconnect event
} }
*/ */
for (int button = 0; button < MAX_GAMEPAD_BUTTONS; button++) for (int button = 0; button < MAX_GAMEPAD_BUTTONS; button++)
{ {
// INPUT_GAMEPAD_BUTTON_UP // INPUT_GAMEPAD_BUTTON_UP
@ -7044,11 +7044,11 @@ static void RecordAutomationEvent(unsigned int frame)
events[eventCount].params[0] = gamepad; events[eventCount].params[0] = gamepad;
events[eventCount].params[1] = button; events[eventCount].params[1] = button;
events[eventCount].params[2] = 0; events[eventCount].params[2] = 0;
TRACELOG(LOG_INFO, "[%i] INPUT_GAMEPAD_BUTTON_UP: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]); TRACELOG(LOG_INFO, "[%i] INPUT_GAMEPAD_BUTTON_UP: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]);
eventCount++; eventCount++;
} }
// INPUT_GAMEPAD_BUTTON_DOWN // INPUT_GAMEPAD_BUTTON_DOWN
if (CORE.Input.Gamepad.currentButtonState[gamepad][button]) if (CORE.Input.Gamepad.currentButtonState[gamepad][button])
{ {
@ -7062,7 +7062,7 @@ static void RecordAutomationEvent(unsigned int frame)
eventCount++; eventCount++;
} }
} }
for (int axis = 0; axis < MAX_GAMEPAD_AXIS; axis++) for (int axis = 0; axis < MAX_GAMEPAD_AXIS; axis++)
{ {
// INPUT_GAMEPAD_AXIS_MOTION // INPUT_GAMEPAD_AXIS_MOTION
@ -7079,7 +7079,7 @@ static void RecordAutomationEvent(unsigned int frame)
} }
} }
} }
// INPUT_GESTURE // INPUT_GESTURE
if (GESTURES.current != GESTURE_NONE) if (GESTURES.current != GESTURE_NONE)
{ {
@ -7128,19 +7128,19 @@ static void PlayAutomationEvent(unsigned int frame)
case INPUT_GAMEPAD_AXIS_MOTION: // param[0]: gamepad, param[1]: axis, param[2]: delta case INPUT_GAMEPAD_AXIS_MOTION: // param[0]: gamepad, param[1]: axis, param[2]: delta
{ {
CORE.Input.Gamepad.axisState[events[i].params[0]][events[i].params[1]] = ((float)events[i].params[2]/32768.0f); CORE.Input.Gamepad.axisState[events[i].params[0]][events[i].params[1]] = ((float)events[i].params[2]/32768.0f);
} break;
} break;
case INPUT_GESTURE: GESTURES.current = events[i].params[0]; break; // param[0]: gesture (enum Gesture) -> gestures.h: GESTURES.current case INPUT_GESTURE: GESTURES.current = events[i].params[0]; break; // param[0]: gesture (enum Gesture) -> gestures.h: GESTURES.current
// Window events // Window events
case WINDOW_CLOSE: CORE.Window.shouldClose = true; break; case WINDOW_CLOSE: CORE.Window.shouldClose = true; break;
case WINDOW_MAXIMIZE: MaximizeWindow(); break; case WINDOW_MAXIMIZE: MaximizeWindow(); break;
case WINDOW_MINIMIZE: MinimizeWindow(); break; case WINDOW_MINIMIZE: MinimizeWindow(); break;
case WINDOW_RESIZE: SetWindowSize(events[i].params[0], events[i].params[1]); break; case WINDOW_RESIZE: SetWindowSize(events[i].params[0], events[i].params[1]); break;
// Custom events // Custom events
case ACTION_TAKE_SCREENSHOT:
case ACTION_TAKE_SCREENSHOT:
{ {
TakeScreenshot(TextFormat("screenshot%03i.png", screenshotCounter));
TakeScreenshot(TextFormat("screenshot%03i.png", screenshotCounter));
screenshotCounter++; screenshotCounter++;
} break; } break;
case ACTION_SETTARGETFPS: SetTargetFPS(events[i].params[0]); break; case ACTION_SETTARGETFPS: SetTargetFPS(events[i].params[0]); break;

+ 21
- 21
src/models.c Näytä tiedosto

@ -2815,7 +2815,7 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector
{ {
// NOTE: Billboard size will maintain source rectangle aspect ratio, size will represent billboard width // NOTE: Billboard size will maintain source rectangle aspect ratio, size will represent billboard width
Vector2 sizeRatio = { size.y, size.x*(float)source.height/source.width }; Vector2 sizeRatio = { size.y, size.x*(float)source.height/source.width };
Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up); Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
Vector3 right = { matView.m0, matView.m4, matView.m8 }; Vector3 right = { matView.m0, matView.m4, matView.m8 };
@ -2826,7 +2826,7 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector
Vector3 rightScaled = Vector3Scale(right, sizeRatio.x/2); Vector3 rightScaled = Vector3Scale(right, sizeRatio.x/2);
Vector3 upScaled = Vector3Scale(up, sizeRatio.y/2); Vector3 upScaled = Vector3Scale(up, sizeRatio.y/2);
Vector3 p1 = Vector3Add(rightScaled, upScaled); Vector3 p1 = Vector3Add(rightScaled, upScaled);
Vector3 p2 = Vector3Subtract(rightScaled, upScaled); Vector3 p2 = Vector3Subtract(rightScaled, upScaled);
@ -2834,25 +2834,25 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector
Vector3 topRight = p1; Vector3 topRight = p1;
Vector3 bottomRight = p2; Vector3 bottomRight = p2;
Vector3 bottomLeft = Vector3Scale(p1, -1); Vector3 bottomLeft = Vector3Scale(p1, -1);
if (rotation != 0.0f) if (rotation != 0.0f)
{
{
float sinRotation = sinf(rotation*DEG2RAD); float sinRotation = sinf(rotation*DEG2RAD);
float cosRotation = cosf(rotation*DEG2RAD); float cosRotation = cosf(rotation*DEG2RAD);
// NOTE: (-1, 1) is the range where origin.x, origin.y is inside the texture // NOTE: (-1, 1) is the range where origin.x, origin.y is inside the texture
float rotateAboutX = sizeRatio.x*origin.x/2; float rotateAboutX = sizeRatio.x*origin.x/2;
float rotateAboutY = sizeRatio.y*origin.y/2; float rotateAboutY = sizeRatio.y*origin.y/2;
float xtvalue, ytvalue; float xtvalue, ytvalue;
float rotatedX, rotatedY; float rotatedX, rotatedY;
xtvalue = Vector3DotProduct(right, topLeft) - rotateAboutX; // Project points to x and y coordinates on the billboard plane xtvalue = Vector3DotProduct(right, topLeft) - rotateAboutX; // Project points to x and y coordinates on the billboard plane
ytvalue = Vector3DotProduct(up, topLeft) - rotateAboutY; ytvalue = Vector3DotProduct(up, topLeft) - rotateAboutY;
rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX; // Rotate about the point origin
rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX; // Rotate about the point origin
rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY; rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY;
topLeft = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX)); // Translate back to cartesian coordinates topLeft = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX)); // Translate back to cartesian coordinates
xtvalue = Vector3DotProduct(right, topRight) - rotateAboutX; xtvalue = Vector3DotProduct(right, topRight) - rotateAboutX;
ytvalue = Vector3DotProduct(up, topRight) - rotateAboutY; ytvalue = Vector3DotProduct(up, topRight) - rotateAboutY;
rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX; rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX;
@ -2864,20 +2864,20 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector
rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX; rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX;
rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY; rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY;
bottomRight = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX)); bottomRight = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX));
xtvalue = Vector3DotProduct(right, bottomLeft)-rotateAboutX; xtvalue = Vector3DotProduct(right, bottomLeft)-rotateAboutX;
ytvalue = Vector3DotProduct(up, bottomLeft)-rotateAboutY; ytvalue = Vector3DotProduct(up, bottomLeft)-rotateAboutY;
rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX; rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX;
rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY; rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY;
bottomLeft = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX)); bottomLeft = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX));
} }
// Translate points to the draw center (position) // Translate points to the draw center (position)
topLeft = Vector3Add(topLeft, position); topLeft = Vector3Add(topLeft, position);
topRight = Vector3Add(topRight, position); topRight = Vector3Add(topRight, position);
bottomRight = Vector3Add(bottomRight, position); bottomRight = Vector3Add(bottomRight, position);
bottomLeft = Vector3Add(bottomLeft, position); bottomLeft = Vector3Add(bottomLeft, position);
rlCheckRenderBatchLimit(4); rlCheckRenderBatchLimit(4);
rlSetTexture(texture.id); rlSetTexture(texture.id);
@ -2902,7 +2902,7 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector
rlVertex3f(topRight.x, topRight.y, topRight.z); rlVertex3f(topRight.x, topRight.y, topRight.z);
rlEnd(); rlEnd();
rlSetTexture(0);
rlSetTexture(0);
} }
// Draw a bounding box with wires // Draw a bounding box with wires
@ -2992,7 +2992,7 @@ RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius)
collision.hit = d >= 0.0f; collision.hit = d >= 0.0f;
// Check if ray origin is inside the sphere to calculate the correct collision point // Check if ray origin is inside the sphere to calculate the correct collision point
if (distance < radius)
if (distance < radius)
{ {
collision.distance = vector + sqrtf(d); collision.distance = vector + sqrtf(d);
@ -3001,8 +3001,8 @@ RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius)
// Calculate collision normal (pointing outwards) // Calculate collision normal (pointing outwards)
collision.normal = Vector3Negate(Vector3Normalize(Vector3Subtract(collision.point, center))); collision.normal = Vector3Negate(Vector3Normalize(Vector3Subtract(collision.point, center)));
}
else
}
else
{ {
collision.distance = vector - sqrtf(d); collision.distance = vector - sqrtf(d);
@ -3012,7 +3012,7 @@ RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius)
// Calculate collision normal (pointing inwards) // Calculate collision normal (pointing inwards)
collision.normal = Vector3Normalize(Vector3Subtract(collision.point, center)); collision.normal = Vector3Normalize(Vector3Subtract(collision.point, center));
} }
return collision; return collision;
} }
@ -3119,7 +3119,7 @@ RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix transform)
} }
} }
} }
return collision; return collision;
} }
@ -3374,7 +3374,7 @@ static Model LoadOBJ(const char *fileName)
tinyobj_materials_free(materials, materialCount); tinyobj_materials_free(materials, materialCount);
UnloadFileText(fileText); UnloadFileText(fileText);
RL_FREE(matFaces); RL_FREE(matFaces);
RL_FREE(vCount); RL_FREE(vCount);
RL_FREE(vtCount); RL_FREE(vtCount);
@ -3696,11 +3696,11 @@ static Model LoadIQM(const char *fileName)
//fseek(iqmFile, va[i].offset, SEEK_SET); //fseek(iqmFile, va[i].offset, SEEK_SET);
//fread(blendw, iqmHeader->num_vertexes*4*sizeof(unsigned char), 1, iqmFile); //fread(blendw, iqmHeader->num_vertexes*4*sizeof(unsigned char), 1, iqmFile);
memcpy(color, fileDataPtr + va[i].offset, iqmHeader->num_vertexes*4*sizeof(unsigned char)); memcpy(color, fileDataPtr + va[i].offset, iqmHeader->num_vertexes*4*sizeof(unsigned char));
for (unsigned int m = 0; m < iqmHeader->num_meshes; m++) for (unsigned int m = 0; m < iqmHeader->num_meshes; m++)
{ {
model.meshes[m].colors = RL_CALLOC(model.meshes[m].vertexCount*4, sizeof(unsigned char)); model.meshes[m].colors = RL_CALLOC(model.meshes[m].vertexCount*4, sizeof(unsigned char));
int vCounter = 0; int vCounter = 0;
for (unsigned int i = imesh[m].first_vertex*4; i < (imesh[m].first_vertex + imesh[m].num_vertexes)*4; i++) for (unsigned int i = imesh[m].first_vertex*4; i < (imesh[m].first_vertex + imesh[m].num_vertexes)*4; i++)
{ {

+ 2
- 2
src/raudio.c Näytä tiedosto

@ -1784,7 +1784,7 @@ AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
// The size of a streaming buffer must be at least double the size of a period // The size of a streaming buffer must be at least double the size of a period
unsigned int periodSize = AUDIO.System.device.playback.internalPeriodSizeInFrames; unsigned int periodSize = AUDIO.System.device.playback.internalPeriodSizeInFrames;
// If the buffer is not set, compute one that would give us a buffer good enough for a decent frame rate // If the buffer is not set, compute one that would give us a buffer good enough for a decent frame rate
unsigned int subBufferSize = (AUDIO.Buffer.defaultSize == 0)? AUDIO.System.device.sampleRate/30 : AUDIO.Buffer.defaultSize; unsigned int subBufferSize = (AUDIO.Buffer.defaultSize == 0)? AUDIO.System.device.sampleRate/30 : AUDIO.Buffer.defaultSize;
@ -2352,7 +2352,7 @@ static bool TextIsEqual(const char *text1, const char *text2)
static const char *TextToLower(const char *text) static const char *TextToLower(const char *text)
{ {
#define MAX_TEXT_BUFFER_LENGTH 1024 #define MAX_TEXT_BUFFER_LENGTH 1024
static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 }; static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 };
for (int i = 0; i < MAX_TEXT_BUFFER_LENGTH; i++) for (int i = 0; i < MAX_TEXT_BUFFER_LENGTH; i++)

+ 1
- 1
src/raymath.h Näytä tiedosto

@ -1389,7 +1389,7 @@ RMDEF Quaternion QuaternionFromMatrix(Matrix mat)
RMDEF Matrix QuaternionToMatrix(Quaternion q) RMDEF Matrix QuaternionToMatrix(Quaternion q)
{ {
Matrix result = MatrixIdentity(); Matrix result = MatrixIdentity();
float a2 = q.x*q.x; float a2 = q.x*q.x;
float b2 = q.y*q.y; float b2 = q.y*q.y;
float c2 = q.z*q.z; float c2 = q.z*q.z;

+ 2
- 2
src/shapes.c Näytä tiedosto

@ -130,9 +130,9 @@ void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color)
float scale = thick/(2*length); float scale = thick/(2*length);
Vector2 radius = { -scale*delta.y, scale*delta.x }; Vector2 radius = { -scale*delta.y, scale*delta.x };
Vector2 strip[4] = { Vector2 strip[4] = {
{ startPos.x - radius.x, startPos.y - radius.y },
{ startPos.x - radius.x, startPos.y - radius.y },
{ startPos.x + radius.x, startPos.y + radius.y }, { startPos.x + radius.x, startPos.y + radius.y },
{ endPos.x - radius.x, endPos.y - radius.y },
{ endPos.x - radius.x, endPos.y - radius.y },
{ endPos.x + radius.x, endPos.y + radius.y } { endPos.x + radius.x, endPos.y + radius.y }
}; };

+ 1
- 1
src/text.c Näytä tiedosto

@ -849,7 +849,7 @@ void DrawText(const char *text, int posX, int posY, int fontSize, Color color)
void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint) void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint)
{ {
if (font.texture.id == 0) font = GetFontDefault(); // Security check in case of not valid font if (font.texture.id == 0) font = GetFontDefault(); // Security check in case of not valid font
int length = TextLength(text); // Total length in bytes of the text, scanned by codepoints in loop int length = TextLength(text); // Total length in bytes of the text, scanned by codepoints in loop
int textOffsetY = 0; // Offset between lines (on line break '\n') int textOffsetY = 0; // Offset between lines (on line break '\n')

+ 1
- 1
src/textures.c Näytä tiedosto

@ -503,7 +503,7 @@ bool ExportImageAsCode(Image image, const char *fileName)
success = SaveFileText(fileName, txtData); success = SaveFileText(fileName, txtData);
RL_FREE(txtData); RL_FREE(txtData);
#endif // SUPPORT_IMAGE_EXPORT #endif // SUPPORT_IMAGE_EXPORT
if (success != 0) TRACELOG(LOG_INFO, "FILEIO: [%s] Image exported successfully", fileName); if (success != 0) TRACELOG(LOG_INFO, "FILEIO: [%s] Image exported successfully", fileName);

Ladataan…
Peruuta
Tallenna