Skip to content

Commit 2377506

Browse files
committed
Update rcamera.h
1 parent 0133a4e commit 2377506

File tree

1 file changed

+24
-27
lines changed

1 file changed

+24
-27
lines changed

src/rcamera.h

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@
5050
// Function specifiers in case library is build/used as a shared library (Windows)
5151
// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll
5252
#if defined(_WIN32)
53-
#if defined(BUILD_LIBTYPE_SHARED)
54-
#if defined(__TINYC__)
55-
#define __declspec(x) __attribute__((x))
56-
#endif
57-
#define RLAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll)
58-
#elif defined(USE_LIBTYPE_SHARED)
59-
#define RLAPI __declspec(dllimport) // We are using the library as a Win32 shared library (.dll)
60-
#endif
53+
#if defined(BUILD_LIBTYPE_SHARED)
54+
#if defined(__TINYC__)
55+
#define __declspec(x) __attribute__((x))
56+
#endif
57+
#define RLAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll)
58+
#elif defined(USE_LIBTYPE_SHARED)
59+
#define RLAPI __declspec(dllimport) // We are using the library as a Win32 shared library (.dll)
60+
#endif
6161
#endif
6262

6363
#ifndef RLAPI
@@ -191,19 +191,21 @@ RLAPI Matrix GetCameraProjectionMatrix(Camera *camera, float aspect);
191191
// IsKeyDown()
192192
// IsKeyPressed()
193193
// GetFrameTime()
194+
195+
#include <math.h> // Required for: fabsf()
194196

195197
//----------------------------------------------------------------------------------
196198
// Defines and Macros
197199
//----------------------------------------------------------------------------------
198-
#define CAMERA_MOVE_SPEED 5.4f // Units per second
199-
#define CAMERA_ROTATION_SPEED 0.03f
200-
#define CAMERA_PAN_SPEED 0.2f
200+
#define CAMERA_MOVE_SPEED 5.4f // Units per second
201+
#define CAMERA_ROTATION_SPEED 0.03f
202+
#define CAMERA_PAN_SPEED 0.2f
201203

202204
// Camera mouse movement sensitivity
203-
#define CAMERA_MOUSE_MOVE_SENSITIVITY 0.003f
205+
#define CAMERA_MOUSE_MOVE_SENSITIVITY 0.003f
204206

205207
// Camera orbital speed in CAMERA_ORBITAL mode
206-
#define CAMERA_ORBITAL_SPEED 0.5f // Radians per second
208+
#define CAMERA_ORBITAL_SPEED 0.5f // Radians per second
207209

208210
//----------------------------------------------------------------------------------
209211
// Types and Structures Definition
@@ -253,12 +255,10 @@ void CameraMoveForward(Camera *camera, float distance, bool moveInWorldPlane)
253255
if (moveInWorldPlane)
254256
{
255257
// Project vector onto world plane (the plane defined by the up vector)
256-
if (fabsf(camera->up.z) > 0)
257-
forward.z = 0;
258-
else if (fabsf(camera->up.x) > 0)
259-
forward.x = 0;
260-
else
261-
forward.y = 0;
258+
if (fabsf(camera->up.z) > 0) forward.z = 0;
259+
else if (fabsf(camera->up.x) > 0) forward.x = 0;
260+
else forward.y = 0;
261+
262262
forward = Vector3Normalize(forward);
263263
}
264264

@@ -291,12 +291,9 @@ void CameraMoveRight(Camera *camera, float distance, bool moveInWorldPlane)
291291
if (moveInWorldPlane)
292292
{
293293
// Project vector onto world plane (the plane defined by the up vector)
294-
if (fabsf(camera->up.z) > 0)
295-
right.z = 0;
296-
else if (fabsf(camera->up.x) > 0)
297-
right.x = 0;
298-
else
299-
right.y = 0;
294+
if (fabsf(camera->up.z) > 0) right.z = 0;
295+
else if (fabsf(camera->up.x) > 0) right.x = 0;
296+
else right.y = 0;
300297

301298
right = Vector3Normalize(right);
302299
}
@@ -356,7 +353,7 @@ void CameraYaw(Camera *camera, float angle, bool rotateAroundTarget)
356353
// - lockView prevents camera overrotation (aka "somersaults")
357354
// - rotateAroundTarget defines if rotation is around target or around its position
358355
// - rotateUp rotates the up direction as well (typically only usefull in CAMERA_FREE)
359-
// NOTE: angle must be provided in radians
356+
// NOTE: [angle] must be provided in radians
360357
void CameraPitch(Camera *camera, float angle, bool lockView, bool rotateAroundTarget, bool rotateUp)
361358
{
362359
// Up direction
@@ -393,7 +390,7 @@ void CameraPitch(Camera *camera, float angle, bool lockView, bool rotateAroundTa
393390
// Move position relative to target
394391
camera->position = Vector3Subtract(camera->target, targetPosition);
395392
}
396-
else // rotate around camera.position
393+
else // Rotate around camera.position
397394
{
398395
// Move target relative to position
399396
camera->target = Vector3Add(camera->position, targetPosition);

0 commit comments

Comments
 (0)