Fixed bug with inline comments for variables not parsing correctly.

This commit is contained in:
Edward R. Gonzalez 2023-10-25 23:44:25 -04:00
parent c1ab233686
commit 212d907d73
7 changed files with 253 additions and 252 deletions

View File

@ -29,7 +29,8 @@
"vector": "cpp", "vector": "cpp",
"list": "cpp", "list": "cpp",
"xhash": "cpp", "xhash": "cpp",
"glfw3.h": "c" "glfw3.h": "c",
"stdbool.h": "c"
}, },
"C_Cpp.intelliSenseEngineFallback": "disabled", "C_Cpp.intelliSenseEngineFallback": "disabled",
"mesonbuild.configureOnOpen": true, "mesonbuild.configureOnOpen": true,

View File

@ -292,27 +292,27 @@ typedef enum bool
// Vector2, 2 components // Vector2, 2 components
typedef struct Vector2 typedef struct Vector2
{ {
f32 x; f32 x; // Vector x component
f32 y; f32 y; // Vector y component
} Vector2; } Vector2;
// Vector3, 3 components // Vector3, 3 components
typedef struct Vector3 typedef struct Vector3
{ {
f32 x; f32 x; // Vector x component
f32 y; f32 y; // Vector y component
f32 z; f32 z; // Vector z component
} Vector3; } Vector3;
// Vector4, 4 components // Vector4, 4 components
typedef struct Vector4 typedef struct Vector4
{ {
f32 x; f32 x; // Vector x component
f32 y; f32 y; // Vector y component
f32 z; f32 z; // Vector z component
f32 w; f32 w; // Vector w component
} Vector4; } Vector4;
@ -322,52 +322,52 @@ typedef Vector4 Quaternion;
// Matrix, 4x4 components, column major, OpenGL style, right-handed // Matrix, 4x4 components, column major, OpenGL style, right-handed
typedef struct Matrix typedef struct Matrix
{ {
f32 m0, m4, m8, m12; f32 m0, m4, m8, m12; // Matrix first row (4 components)
f32 m1, m5, m9, m13; f32 m1, m5, m9, m13; // Matrix second row (4 components)
f32 m2, m6, m10, m14; f32 m2, m6, m10, m14; // Matrix third row (4 components)
f32 m3, m7, m11, m15; f32 m3, m7, m11, m15; // Matrix fourth row (4 components)
} Matrix; } Matrix;
// Color, 4 components, R8G8B8A8 (32bit) // Color, 4 components, R8G8B8A8 (32bit)
typedef struct Color typedef struct Color
{ {
u8 r; u8 r; // Color red value
u8 g; u8 g; // Color green value
u8 b; u8 b; // Color blue value
u8 a; u8 a; // Color alpha value
} Color; } Color;
// Rectangle, 4 components // Rectangle, 4 components
typedef struct Rectangle typedef struct Rectangle
{ {
f32 x; f32 x; // Rectangle top-left corner position x
f32 y; f32 y; // Rectangle top-left corner position y
f32 width; f32 width; // Rectangle width
f32 height; f32 height; // Rectangle height
} Rectangle; } Rectangle;
// Image, pixel data stored in CPU memory (RAM) // Image, pixel data stored in CPU memory (RAM)
typedef struct Image typedef struct Image
{ {
void* data; void* data; // Image raw data
s32 width; s32 width; // Image base width
s32 height; s32 height; // Image base height
s32 mipmaps; s32 mipmaps; // Mipmap levels, 1 by default
s32 format; s32 format; // Data format (PixelFormat type)
} Image; } Image;
// Texture, tex data stored in GPU memory (VRAM) // Texture, tex data stored in GPU memory (VRAM)
typedef struct Texture typedef struct Texture
{ {
u32 id; u32 id; // OpenGL texture id
s32 width; s32 width; // Texture base width
s32 height; s32 height; // Texture base height
s32 mipmaps; s32 mipmaps; // Mipmap levels, 1 by default
s32 format; s32 format; // Data format (PixelFormat type)
} Texture; } Texture;
@ -380,9 +380,9 @@ typedef Texture TextureCubemap;
// RenderTexture, fbo for texture rendering // RenderTexture, fbo for texture rendering
typedef struct RenderTexture typedef struct RenderTexture
{ {
u32 id; u32 id; // OpenGL framebuffer object id
Texture texture; Texture texture; // Color buffer attachment texture
Texture depth; Texture depth; // Depth buffer attachment texture
} RenderTexture; } RenderTexture;
@ -392,46 +392,46 @@ typedef RenderTexture RenderTexture2D;
// NPatchInfo, n-patch layout info // NPatchInfo, n-patch layout info
typedef struct NPatchInfo typedef struct NPatchInfo
{ {
Rectangle source; Rectangle source; // Texture source rectangle
s32 left; s32 left; // Left border offset
s32 top; s32 top; // Top border offset
s32 right; s32 right; // Right border offset
s32 bottom; s32 bottom; // Bottom border offset
s32 layout; s32 layout; // Layout of the n-patch: 3x3, 1x3 or 3x1
} NPatchInfo; } NPatchInfo;
// GlyphInfo, font characters glyphs info // GlyphInfo, font characters glyphs info
typedef struct GlyphInfo typedef struct GlyphInfo
{ {
s32 value; s32 value; // Character value (Unicode)
s32 offsetX; s32 offsetX; // Character offset X when drawing
s32 offsetY; s32 offsetY; // Character offset Y when drawing
s32 advanceX; s32 advanceX; // Character advance position X
Image image; Image image; // Character image data
} GlyphInfo; } GlyphInfo;
// Font, font texture and GlyphInfo array data // Font, font texture and GlyphInfo array data
typedef struct Font typedef struct Font
{ {
s32 baseSize; s32 baseSize; // Base size (default chars height)
s32 glyphCount; s32 glyphCount; // Number of glyph characters
s32 glyphPadding; s32 glyphPadding; // Padding around the glyph characters
Texture2D texture; Texture2D texture; // Texture atlas containing the glyphs
Rectangle* recs; Rectangle* recs; // Rectangles in texture for the glyphs
GlyphInfo* glyphs; GlyphInfo* glyphs; // Glyphs info data
} Font; } Font;
// Camera, defines position/orientation in 3d space // Camera, defines position/orientation in 3d space
typedef struct Camera3D typedef struct Camera3D
{ {
Vector3 position; Vector3 position; // Camera position
Vector3 target; Vector3 target; // Camera target it looks-at
Vector3 up; Vector3 up; // Camera up vector (rotation over its axis)
f32 fovy; f32 fovy; // Camera field-of-view aperture in Y (degrees) in perspective, used as near plane width in orthographic
s32 projection; s32 projection; // Camera projection: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC
} Camera3D; } Camera3D;
@ -440,146 +440,146 @@ typedef Camera3D Camera; // Camera type fallback, defaults to Camera3D
// Camera2D, defines position/orientation in 2d space // Camera2D, defines position/orientation in 2d space
typedef struct Camera2D typedef struct Camera2D
{ {
Vector2 offset; Vector2 offset; // Camera offset (displacement from target)
Vector2 target; Vector2 target; // Camera target (rotation and zoom origin)
f32 rotation; f32 rotation; // Camera rotation in degrees
f32 zoom; f32 zoom; // Camera zoom (scaling), should be 1.0f by default
} Camera2D; } Camera2D;
// Mesh, vertex data and vao/vbo // Mesh, vertex data and vao/vbo
typedef struct Mesh typedef struct Mesh
{ {
s32 vertexCount; s32 vertexCount; // Number of vertices stored in arrays
s32 triangleCount; s32 triangleCount; // Number of triangles stored (indexed or not)
// Vertex attributes data // Vertex attributes data
f32* vertices; f32* vertices; // Vertex position (XYZ - 3 components per vertex) (shader-location = 0)
f32* texcoords; f32* texcoords; // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
f32* texcoords2; f32* texcoords2; // Vertex texture second coordinates (UV - 2 components per vertex) (shader-location = 5)
f32* normals; f32* normals; // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
f32* tangents; f32* tangents; // Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4)
u8* colors; u8* colors; // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
u8* indices; u8* indices; // Vertex indices (in case vertex data comes indexed)
// Animation vertex data // Animation vertex data
f32* animVertices; f32* animVertices; // Animated vertex positions (after bones transformations)
f32* animNormals; f32* animNormals; // Animated normals (after bones transformations)
u8* boneIds; u8* boneIds; // Vertex bone ids, max 255 bone ids, up to 4 bones influence by vertex (skinning)
f32* boneWeights; f32* boneWeights; // Vertex bone weight, up to 4 bones influence by vertex (skinning)
// OpenGL identifiers // OpenGL identifiers
u32 vaoId; u32 vaoId; // OpenGL Vertex Array Object id
unsigned int* vboId; unsigned int* vboId; // OpenGL Vertex Buffer Objects id (default vertex data)
} Mesh; } Mesh;
// Shader // Shader
typedef struct Shader typedef struct Shader
{ {
u32 id; u32 id; // Shader program id
s32* locs; s32* locs; // Shader locations array (RL_MAX_SHADER_LOCATIONS)
} Shader; } Shader;
// MaterialMap // MaterialMap
typedef struct MaterialMap typedef struct MaterialMap
{ {
Texture2D texture; Texture2D texture; // Material map texture
Color color; Color color; // Material map color
f32 value; f32 value; // Material map value
} MaterialMap; } MaterialMap;
// Material, includes shader and maps // Material, includes shader and maps
typedef struct Material typedef struct Material
{ {
Shader shader; Shader shader; // Material shader
MaterialMap* maps; MaterialMap* maps; // Material maps array (MAX_MATERIAL_MAPS)
f32 params; f32 params; // Material generic parameters (if required)
} Material; } Material;
// Transform, vertex transformation data // Transform, vertex transformation data
typedef struct Transform typedef struct Transform
{ {
Vector3 translation; Vector3 translation; // Translation
Quaternion rotation; Quaternion rotation; // Rotation
Vector3 scale; Vector3 scale; // Scale
} Transform; } Transform;
// Bone, skeletal animation bone // Bone, skeletal animation bone
typedef struct BoneInfo typedef struct BoneInfo
{ {
char name[ 32 ]; char name[ 32 ]; // Bone name
s32 parent; s32 parent; // Bone parent
} BoneInfo; } BoneInfo;
// Model, meshes, materials and animation data // Model, meshes, materials and animation data
typedef struct Model typedef struct Model
{ {
Matrix transform; Matrix transform; // Local transform matrix
s32 meshCount; s32 meshCount; // Number of meshes
s32 materialCount; s32 materialCount; // Number of materials
Mesh* meshes; Mesh* meshes; // Meshes array
Material* materials; Material* materials; // Materials array
s32* meshMaterial; s32* meshMaterial; // Mesh material number
// Animation data // Animation data
s32 boneCount; s32 boneCount; // Number of bones
BoneInfo* bones; BoneInfo* bones; // Bones information (skeleton)
Transform* bindPose; Transform* bindPose; // Bones base transformation (pose)
} Model; } Model;
// ModelAnimation // ModelAnimation
typedef struct ModelAnimation typedef struct ModelAnimation
{ {
s32 boneCount; s32 boneCount; // Number of bones
s32 frameCount; s32 frameCount; // Number of animation frames
BoneInfo* bones; BoneInfo* bones; // Bones information (skeleton)
Transform** framePoses; Transform** framePoses; // Poses array by frame
char name[ 32 ]; char name[ 32 ]; // Animation name
} ModelAnimation; } ModelAnimation;
// Ray, ray for raycasting // Ray, ray for raycasting
typedef struct Ray typedef struct Ray
{ {
Vector3 position; Vector3 position; // Ray position (origin)
Vector3 direction; Vector3 direction; // Ray direction
} Ray; } Ray;
// RayCollision, ray hit information // RayCollision, ray hit information
typedef struct RayCollision typedef struct RayCollision
{ {
bool hit; bool hit; // Did the ray hit something?
f32 distance; f32 distance; // Distance to the nearest hit
Vector3 point; Vector3 point; // Point of the nearest hit
Vector3 normal; Vector3 normal; // Surface normal of hit
} RayCollision; } RayCollision;
// BoundingBox // BoundingBox
typedef struct BoundingBox typedef struct BoundingBox
{ {
Vector3 min; Vector3 min; // Minimum vertex box-corner
Vector3 max; Vector3 max; // Maximum vertex box-corner
} BoundingBox; } BoundingBox;
// Wave, audio wave data // Wave, audio wave data
typedef struct Wave typedef struct Wave
{ {
u32 frameCount; u32 frameCount; // Total number of frames (considering channels)
u32 sampleRate; u32 sampleRate; // Frequency (samples per second)
u32 sampleSize; u32 sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported)
u32 channels; u32 channels; // Number of channels (1-mono, 2-stereo, ...)
void* data; void* data; // Buffer data pointer
} Wave; } Wave;
@ -591,71 +591,71 @@ typedef struct rAudioProcessor rAudioProcessor;
// AudioStream, custom audio stream // AudioStream, custom audio stream
typedef struct AudioStream typedef struct AudioStream
{ {
rAudioBuffer* buffer; rAudioBuffer* buffer; // Pointer to internal data used by the audio system
rAudioProcessor* processor; rAudioProcessor* processor; // Pointer to internal data processor, useful for audio effects
u32 sampleRate; u32 sampleRate; // Frequency (samples per second)
u32 sampleSize; u32 sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported)
u32 channels; u32 channels; // Number of channels (1-mono, 2-stereo, ...)
} AudioStream; } AudioStream;
// Sound // Sound
typedef struct Sound typedef struct Sound
{ {
AudioStream stream; AudioStream stream; // Audio stream
u32 frameCount; u32 frameCount; // Total number of frames (considering channels)
} Sound; } Sound;
// Music, audio stream, anything longer than ~10 seconds should be streamed // Music, audio stream, anything longer than ~10 seconds should be streamed
typedef struct Music typedef struct Music
{ {
AudioStream stream; AudioStream stream; // Audio stream
u32 frameCount; u32 frameCount; // Total number of frames (considering channels)
bool looping; bool looping; // Music looping enable
s32 ctxType; s32 ctxType; // Type of music context (audio filetype)
void* ctxData; void* ctxData; // Audio context data, depends on type
} Music; } Music;
// VrDeviceInfo, Head-Mounted-Display device parameters // VrDeviceInfo, Head-Mounted-Display device parameters
typedef struct VrDeviceInfo typedef struct VrDeviceInfo
{ {
s32 hResolution; s32 hResolution; // Horizontal resolution in pixels
s32 vResolution; s32 vResolution; // Vertical resolution in pixels
f32 hScreenSize; f32 hScreenSize; // Horizontal size in meters
f32 vScreenSize; f32 vScreenSize; // Vertical size in meters
f32 vScreenCenter; f32 vScreenCenter; // Screen center in meters
f32 eyeToScreenDistance; f32 eyeToScreenDistance; // Distance between eye and display in meters
f32 lensSeparationDistance; f32 lensSeparationDistance; // Lens separation distance in meters
f32 interpupillaryDistance; f32 interpupillaryDistance; // IPD (distance between pupils) in meters
f32 lensDistortionValues; f32 lensDistortionValues; // Lens distortion constant parameters
f32 chromaAbCorrection; f32 chromaAbCorrection; // Chromatic aberration correction parameters
} VrDeviceInfo; } VrDeviceInfo;
// VrStereoConfig, VR stereo rendering configuration for simulator // VrStereoConfig, VR stereo rendering configuration for simulator
typedef struct VrStereoConfig typedef struct VrStereoConfig
{ {
Matrix projection[ 2 ]; Matrix projection[ 2 ]; // VR projection matrices (per eye)
Matrix viewOffset[ 2 ]; Matrix viewOffset[ 2 ]; // VR view offset matrices (per eye)
f32 leftLensCenter; f32 leftLensCenter; // VR left lens center
f32 rightLensCenter; f32 rightLensCenter; // VR right lens center
f32 leftScreenCenter; f32 leftScreenCenter; // VR left screen center
f32 rightScreenCenter; f32 rightScreenCenter; // VR right screen center
f32 scale; f32 scale; // VR distortion scale
f32 scaleIn; f32 scaleIn; // VR distortion scale in
} VrStereoConfig; } VrStereoConfig;
// File path list // File path list
typedef struct FilePathList typedef struct FilePathList
{ {
u32 capacity; u32 capacity; // Filepaths max entries
u32 count; u32 count; // Filepaths entries count
char** paths; char** paths; // Filepaths entries
} FilePathList; } FilePathList;

View File

@ -149,10 +149,10 @@ typedef Vector4 Quaternion;
// Matrix type (OpenGL style 4x4 - right handed, column major) // Matrix type (OpenGL style 4x4 - right handed, column major)
typedef struct Matrix typedef struct Matrix
{ {
f32 m0, m4, m8, m12; f32 m0, m4, m8, m12; // Matrix first row (4 components)
f32 m1, m5, m9, m13; f32 m1, m5, m9, m13; // Matrix second row (4 components)
f32 m2, m6, m10, m14; f32 m2, m6, m10, m14; // Matrix third row (4 components)
f32 m3, m7, m11, m15; f32 m3, m7, m11, m15; // Matrix fourth row (4 components)
} Matrix; } Matrix;
#endif #endif

View File

@ -40,7 +40,7 @@
**********************************************************************************************/ **********************************************************************************************/
#ifndef RCAMERA_H #ifndef RCAMERA_H
#define RCAMERA_H #define RL_RCAMERA_H
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Defines and Macros // Defines and Macros
@ -52,24 +52,21 @@
#if defined( _WIN32 ) #if defined( _WIN32 )
#if defined( BUILD_LIBTYPE_SHARED ) #if defined( BUILD_LIBTYPE_SHARED )
#if defined( __TINYC__ ) #if defined( __TINYC__ )
#define __declspec( x ) __attribute__( ( x ) ) #define RL___declspec( x ) __attribute__( ( x ) )
#endif #endif
#define RLAPI __declspec( dllexport ) // We are building the library as a Win32 shared library (.dll)
#elif defined( USE_LIBTYPE_SHARED ) #elif defined( USE_LIBTYPE_SHARED )
#define RLAPI __declspec( dllimport ) // We are using the library as a Win32 shared library (.dll)
#endif #endif
#endif #endif
#ifndef RLAPI #ifndef RLAPI
#define RLAPI // Functions defined as 'extern' by default (implicit specifiers)
#endif #endif
#if defined( RCAMERA_STANDALONE ) #if defined( RCAMERA_STANDALONE )
#define CAMERA_CULL_DISTANCE_NEAR 0.01 #define RL_CAMERA_CULL_DISTANCE_NEAR 0.01
#define CAMERA_CULL_DISTANCE_FAR 1000.0 #define RL_CAMERA_CULL_DISTANCE_FAR 1000.0
#else #else
#define CAMERA_CULL_DISTANCE_NEAR RL_CULL_DISTANCE_NEAR #define RL_CAMERA_CULL_DISTANCE_NEAR RL_CULL_DISTANCE_NEAR
#define CAMERA_CULL_DISTANCE_FAR RL_CULL_DISTANCE_FAR #define RL_CAMERA_CULL_DISTANCE_FAR RL_CULL_DISTANCE_FAR
#endif #endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -80,25 +77,28 @@
// Vector2, 2 components // Vector2, 2 components
typedef struct Vector2 typedef struct Vector2
{ {
float x; // Vector x component f32 x; // Vector x component
float y; // Vector y component f32 y; // Vector y component
} Vector2; } Vector2;
// Vector3, 3 components // Vector3, 3 components
typedef struct Vector3 typedef struct Vector3
{ {
float x; // Vector x component f32 x; // Vector x component
float y; // Vector y component f32 y; // Vector y component
float z; // Vector z component f32 z; // Vector z component
} Vector3; } Vector3;
// Matrix, 4x4 components, column major, OpenGL style, right-handed // Matrix, 4x4 components, column major, OpenGL style, right-handed
typedef struct Matrix typedef struct Matrix
{ {
float m0, m4, m8, m12; // Matrix first row (4 components) f32 m0, m4, m8, m12; // Matrix first row (4 components)
float m1, m5, m9, m13; // Matrix second row (4 components) f32 m1, m5, m9, m13; // Matrix second row (4 components)
float m2, m6, m10, m14; // Matrix third row (4 components) f32 m2, m6, m10, m14; // Matrix third row (4 components)
float m3, m7, m11, m15; // Matrix fourth row (4 components) f32 m3, m7, m11, m15; // Matrix fourth row (4 components)
} Matrix; } Matrix;
// Camera type, defines a camera position/orientation in 3d space // Camera type, defines a camera position/orientation in 3d space
@ -107,8 +107,9 @@ typedef struct Camera3D
Vector3 position; // Camera position Vector3 position; // Camera position
Vector3 target; // Camera target it looks-at Vector3 target; // Camera target it looks-at
Vector3 up; // Camera up vector (rotation over its axis) Vector3 up; // Camera up vector (rotation over its axis)
float fovy; // Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic f32 fovy; // Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic
int projection; // Camera projection type: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC s32 projection; // Camera projection type: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC
} Camera3D; } Camera3D;
typedef Camera3D Camera; // Camera type fallback, defaults to Camera3D typedef Camera3D Camera; // Camera type fallback, defaults to Camera3D
@ -116,18 +117,20 @@ typedef Camera3D Camera; // Camera type fallback, defaults to Camera3D
// Camera projection // Camera projection
typedef enum typedef enum
{ {
CAMERA_PERSPECTIVE = 0, // Perspective projection Camera_Perspective = 0, // Perspective projection
CAMERA_ORTHOGRAPHIC // Orthographic projection Camera_Orthographic // orthographic projection
} CameraProjection; } CameraProjection;
// Camera system modes // Camera system modes
typedef enum typedef enum
{ {
CAMERA_CUSTOM = 0, // Camera custom, controlled by user (UpdateCamera() does nothing) Camera_Custom = 0, // Camera custom, controlled by user (UpdateCamera() does nothing)
CAMERA_FREE, // Camera free mode Camera_Free, // Camera free mode
CAMERA_ORBITAL, // Camera orbital, around target, zoom supported Camera_Orbital, // Camera orbital, around target, zoom supported
CAMERA_FIRST_PERSON, // Camera first person Camera_First_Person, // Camera first person
CAMERA_THIRD_PERSON // Camera third person Camera_Third_Person // camera third person
} CameraMode; } CameraMode;
#endif #endif
@ -141,33 +144,38 @@ typedef enum
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined( __cplusplus ) #if defined( __cplusplus )
extern "C" namespace raylib
{ // Prevents name mangling of functions {
extern "C"
{
// Prevents name mangling of functions
#endif #endif
RLAPI Vector3 GetCameraForward( Camera* camera ); RLAPI Vector3 get_camera_forward( Camera* camera );
RLAPI Vector3 GetCameraUp( Camera* camera ); RLAPI Vector3 get_camera_up( Camera* camera );
RLAPI Vector3 GetCameraRight( Camera* camera ); RLAPI Vector3 get_camera_right( Camera* camera );
// Camera movement // Camera movement
RLAPI void CameraMoveForward( Camera* camera, float distance, bool moveInWorldPlane ); RLAPI void camera_move_forward( Camera* camera, f32 distance, bool moveInWorldPlane );
RLAPI void CameraMoveUp( Camera* camera, float distance ); RLAPI void camera_move_up( Camera* camera, f32 distance );
RLAPI void CameraMoveRight( Camera* camera, float distance, bool moveInWorldPlane ); RLAPI void camera_move_right( Camera* camera, f32 distance, bool moveInWorldPlane );
RLAPI void CameraMoveToTarget( Camera* camera, float delta ); RLAPI void camera_move_to_target( Camera* camera, f32 delta );
// Camera rotation // Camera rotation
RLAPI void CameraYaw( Camera* camera, float angle, bool rotateAroundTarget ); RLAPI void camera_yaw( Camera* camera, f32 angle, bool rotateAroundTarget );
RLAPI void CameraPitch( Camera* camera, float angle, bool lockView, bool rotateAroundTarget, bool rotateUp ); RLAPI void camera_pitch( Camera* camera, f32 angle, bool lockView, bool rotateAroundTarget, bool rotateUp );
RLAPI void CameraRoll( Camera* camera, float angle ); RLAPI void camera_roll( Camera* camera, f32 angle );
RLAPI Matrix GetCameraViewMatrix( Camera* camera ); RLAPI Matrix get_camera_view_matrix( Camera* camera );
RLAPI Matrix GetCameraProjectionMatrix( Camera* camera, float aspect ); RLAPI Matrix get_camera_projection_matrix( Camera* camera, f32 aspect );
#if defined( __cplusplus ) #if defined( __cplusplus )
}
} }
#endif #endif
#endif // RCAMERA_H #endif
// RCAMERA_H
/*********************************************************************************** /***********************************************************************************
@ -178,20 +186,21 @@ extern "C"
#if defined( RCAMERA_IMPLEMENTATION ) #if defined( RCAMERA_IMPLEMENTATION )
#include "raymath.h" // Required for vector maths: #include "raymath.h"
// Vector3Add() // Required for vector maths:
// Vector3Subtract() // Vector3Add()
// Vector3Scale() // Vector3Subtract()
// Vector3Normalize() // Vector3Scale()
// Vector3Distance() // Vector3Normalize()
// Vector3CrossProduct() // Vector3Distance()
// Vector3RotateByAxisAngle() // Vector3CrossProduct()
// Vector3Angle() // Vector3RotateByAxisAngle()
// Vector3Negate() // Vector3Angle()
// MatrixLookAt() // Vector3Negate()
// MatrixPerspective() // MatrixLookAt()
// MatrixOrtho() // MatrixPerspective()
// MatrixIdentity() // MatrixOrtho()
// MatrixIdentity()
// raylib required functionality: // raylib required functionality:
// GetMouseDelta() // GetMouseDelta()
@ -203,23 +212,23 @@ extern "C"
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Defines and Macros // Defines and Macros
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#define CAMERA_MOVE_SPEED 0.09f #define RL_CAMERA_MOVE_SPEED 0.09f
#define CAMERA_ROTATION_SPEED 0.03f #define RL_CAMERA_ROTATION_SPEED 0.03f
#define CAMERA_PAN_SPEED 0.2f #define RL_CAMERA_PAN_SPEED 0.2f
// Camera mouse movement sensitivity // Camera mouse movement sensitivity
#define CAMERA_MOUSE_MOVE_SENSITIVITY 0.003f // TODO: it should be independant of framerate #define RL_CAMERA_MOUSE_MOVE_SENSITIVITY 0.003f // TODO: it should be independant of framerate
#define CAMERA_MOUSE_SCROLL_SENSITIVITY 1.5f #define RL_CAMERA_MOUSE_SCROLL_SENSITIVITY 1.5f
#define CAMERA_ORBITAL_SPEED 0.5f // Radians per second #define RL_CAMERA_ORBITAL_SPEED 0.5f // Radians per second
#define CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER 8.0f #define RL_CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER 8.0f
#define CAMERA_FIRST_PERSON_STEP_DIVIDER 30.0f #define RL_CAMERA_FIRST_PERSON_STEP_DIVIDER 30.0f
#define CAMERA_FIRST_PERSON_WAVING_DIVIDER 200.0f #define RL_CAMERA_FIRST_PERSON_WAVING_DIVIDER 200.0f
// PLAYER (used by camera) // PLAYER (used by camera)
#define PLAYER_MOVEMENT_SENSITIVITY 20.0f #define RL_PLAYER_MOVEMENT_SENSITIVITY 20.0f
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Types and Structures Definition // Types and Structures Definition
@ -240,20 +249,20 @@ extern "C"
// Module Functions Definition // Module Functions Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Returns the cameras forward vector (normalized) // Returns the cameras forward vector (normalized)
Vector3 GetCameraForward( Camera* camera ) Vector3 get_camera_forward( Camera* camera )
{ {
return Vector3Normalize( Vector3Subtract( camera->target, camera->position ) ); return Vector3Normalize( Vector3Subtract( camera->target, camera->position ) );
} }
// Returns the cameras up vector (normalized) // Returns the cameras up vector (normalized)
// Note: The up vector might not be perpendicular to the forward vector // Note: The up vector might not be perpendicular to the forward vector
Vector3 GetCameraUp( Camera* camera ) Vector3 get_camera_up( Camera* camera )
{ {
return Vector3Normalize( camera->up ); return Vector3Normalize( camera->up );
} }
// Returns the cameras right vector (normalized) // Returns the cameras right vector (normalized)
Vector3 GetCameraRight( Camera* camera ) Vector3 get_camera_right( Camera* camera )
{ {
Vector3 forward = GetCameraForward( camera ); Vector3 forward = GetCameraForward( camera );
Vector3 up = GetCameraUp( camera ); Vector3 up = GetCameraUp( camera );
@ -262,7 +271,7 @@ Vector3 GetCameraRight( Camera* camera )
} }
// Moves the camera in its forward direction // Moves the camera in its forward direction
void CameraMoveForward( Camera* camera, float distance, bool moveInWorldPlane ) void camera_move_forward( Camera* camera, f32 distance, bool moveInWorldPlane )
{ {
Vector3 forward = GetCameraForward( camera ); Vector3 forward = GetCameraForward( camera );
@ -282,7 +291,7 @@ void CameraMoveForward( Camera* camera, float distance, bool moveInWorldPlane )
} }
// Moves the camera in its up direction // Moves the camera in its up direction
void CameraMoveUp( Camera* camera, float distance ) void camera_move_up( Camera* camera, f32 distance )
{ {
Vector3 up = GetCameraUp( camera ); Vector3 up = GetCameraUp( camera );
@ -295,7 +304,7 @@ void CameraMoveUp( Camera* camera, float distance )
} }
// Moves the camera target in its current right direction // Moves the camera target in its current right direction
void CameraMoveRight( Camera* camera, float distance, bool moveInWorldPlane ) void camera_move_right( Camera* camera, f32 distance, bool moveInWorldPlane )
{ {
Vector3 right = GetCameraRight( camera ); Vector3 right = GetCameraRight( camera );
@ -315,7 +324,7 @@ void CameraMoveRight( Camera* camera, float distance, bool moveInWorldPlane )
} }
// Moves the camera position closer/farther to/from the camera target // Moves the camera position closer/farther to/from the camera target
void CameraMoveToTarget( Camera* camera, float delta ) void camera_move_to_target( Camera* camera, f32 delta )
{ {
float distance = Vector3Distance( camera->position, camera->target ); float distance = Vector3Distance( camera->position, camera->target );
@ -335,9 +344,8 @@ void CameraMoveToTarget( Camera* camera, float delta )
// Yaw is "looking left and right" // Yaw is "looking left and right"
// If rotateAroundTarget is false, the camera rotates around its position // If rotateAroundTarget is false, the camera rotates around its position
// Note: angle must be provided in radians // Note: angle must be provided in radians
void CameraYaw( Camera* camera, float angle, bool rotateAroundTarget ) void camera_yaw( Camera* camera, f32 angle, bool rotateAroundTarget )
{ {
// Rotation axis
Vector3 up = GetCameraUp( camera ); Vector3 up = GetCameraUp( camera );
// View vector // View vector
@ -363,9 +371,8 @@ void CameraYaw( Camera* camera, float angle, bool rotateAroundTarget )
// - rotateAroundTarget defines if rotation is around target or around its position // - rotateAroundTarget defines if rotation is around target or around its position
// - rotateUp rotates the up direction as well (typically only usefull in CAMERA_FREE) // - rotateUp rotates the up direction as well (typically only usefull in CAMERA_FREE)
// NOTE: angle must be provided in radians // NOTE: angle must be provided in radians
void CameraPitch( Camera* camera, float angle, bool lockView, bool rotateAroundTarget, bool rotateUp ) void camera_pitch( Camera* camera, f32 angle, bool lockView, bool rotateAroundTarget, bool rotateUp )
{ {
// Up direction
Vector3 up = GetCameraUp( camera ); Vector3 up = GetCameraUp( camera );
// View vector // View vector
@ -417,9 +424,8 @@ void CameraPitch( Camera* camera, float angle, bool lockView, bool rotateAroundT
// Rotates the camera around its forward vector // Rotates the camera around its forward vector
// Roll is "turning your head sideways to the left or right" // Roll is "turning your head sideways to the left or right"
// Note: angle must be provided in radians // Note: angle must be provided in radians
void CameraRoll( Camera* camera, float angle ) void camera_roll( Camera* camera, f32 angle )
{ {
// Rotation axis
Vector3 forward = GetCameraForward( camera ); Vector3 forward = GetCameraForward( camera );
// Rotate up direction around forward axis // Rotate up direction around forward axis
@ -427,13 +433,13 @@ void CameraRoll( Camera* camera, float angle )
} }
// Returns the camera view matrix // Returns the camera view matrix
Matrix GetCameraViewMatrix( Camera* camera ) Matrix get_camera_view_matrix( Camera* camera )
{ {
return MatrixLookAt( camera->position, camera->target, camera->up ); return MatrixLookAt( camera->position, camera->target, camera->up );
} }
// Returns the camera projection matrix // Returns the camera projection matrix
Matrix GetCameraProjectionMatrix( Camera* camera, float aspect ) Matrix get_camera_projection_matrix( Camera* camera, f32 aspect )
{ {
if ( camera->projection == CAMERA_PERSPECTIVE ) if ( camera->projection == CAMERA_PERSPECTIVE )
{ {
@ -453,7 +459,7 @@ Matrix GetCameraProjectionMatrix( Camera* camera, float aspect )
#if ! defined( RCAMERA_STANDALONE ) #if ! defined( RCAMERA_STANDALONE )
// Update camera position for selected mode // Update camera position for selected mode
// Camera mode: CAMERA_FREE, CAMERA_FIRST_PERSON, CAMERA_THIRD_PERSON, CAMERA_ORBITAL or CUSTOM // Camera mode: CAMERA_FREE, CAMERA_FIRST_PERSON, CAMERA_THIRD_PERSON, CAMERA_ORBITAL or CUSTOM
void UpdateCamera( Camera* camera, int mode ) void update_camera( Camera* camera, s32 mode )
{ {
Vector2 mousePositionDelta = GetMouseDelta(); Vector2 mousePositionDelta = GetMouseDelta();
@ -560,20 +566,12 @@ void UpdateCamera( Camera* camera, int mode )
CameraMoveToTarget( camera, -2.0f ); CameraMoveToTarget( camera, -2.0f );
} }
} }
#endif // !RCAMERA_STANDALONE #endif
// !RCAMERA_STANDALONE
// Update camera movement, movement/rotation values should be provided by user // Update camera movement, movement/rotation values should be provided by user
void UpdateCameraPro( Camera* camera, Vector3 movement, Vector3 rotation, float zoom ) void update_camera_pro( Camera* camera, Vector3 movement, Vector3 rotation, f32 zoom )
{ {
// Required values
// movement.x - Move forward/backward
// movement.y - Move right/left
// movement.z - Move up/down
// rotation.x - yaw
// rotation.y - pitch
// rotation.z - roll
// zoom - Move towards target
bool lockView = true; bool lockView = true;
bool rotateAroundTarget = false; bool rotateAroundTarget = false;
bool rotateUp = false; bool rotateUp = false;
@ -593,4 +591,5 @@ void UpdateCameraPro( Camera* camera, Vector3 movement, Vector3 rotation, float
CameraMoveToTarget( camera, zoom ); CameraMoveToTarget( camera, zoom );
} }
#endif // RCAMERA_IMPLEMENTATION #endif
// RCAMERA_IMPLEMENTATION

View File

@ -9,6 +9,7 @@
constexpr char const* path_config = "config.h"; constexpr char const* path_config = "config.h";
constexpr char const* path_raylib = "raylib.h"; constexpr char const* path_raylib = "raylib.h";
constexpr char const* path_raymath = "raymath.h"; constexpr char const* path_raymath = "raymath.h";
constexpr char const* path_rcamera = "rcamera.h";
constexpr char const* path_rcore = "rcore.h"; constexpr char const* path_rcore = "rcore.h";
constexpr char const* path_rgestures = "rgestures.h"; constexpr char const* path_rgestures = "rgestures.h";
constexpr char const* path_rgl = "rgl.h"; constexpr char const* path_rgl = "rgl.h";
@ -207,7 +208,7 @@ void refactor_file( char const* path )
String name_scratch = String::make_reserve( GlobalAllocator, kilobytes(1) ); String name_scratch = String::make_reserve( GlobalAllocator, kilobytes(1) );
// CodeBody includes // CodeBody includes
// CodeBody nspace_body = def_body( ECode::Namespace ); // CodeBody nspace_body = def_body( ECode::Namespace );
CodeBody new_code = def_body( ECode::Global_Body ); CodeBody new_code = def_body( ECode::Global_Body );
@ -283,6 +284,7 @@ int gen_main()
refactor_file( path_config ); refactor_file( path_config );
refactor_file( path_raylib ); refactor_file( path_raylib );
refactor_file( path_raymath ); refactor_file( path_raymath );
refactor_file( path_rcamera );
return 0; return 0;
} }

View File

@ -111,7 +111,7 @@ function setup-raylib {
$build_result = build-simple $path_build $includes $compiler_args $linker_args $unit $executable $build_result = build-simple $path_build $includes $compiler_args $linker_args $unit $executable
Push-Location $path_raylib_src Push-Location $path_raylib_src
if ( Test-Path( $executable ) ) { if ( Test-Path( $executable ) ) {
$time_taken = Measure-Command { & $executable Measure-Command { & $executable
| ForEach-Object { | ForEach-Object {
write-host `t $_ -ForegroundColor Green write-host `t $_ -ForegroundColor Green
} }

View File

@ -3655,7 +3655,6 @@ CodeVar parse_variable_after_name(
eat( TokType::Statement_End ); eat( TokType::Statement_End );
// Check for inline comment : <type> <identifier> = <expression>; // <inline comment> // Check for inline comment : <type> <identifier> = <expression>; // <inline comment>
CodeComment inline_cmt = NoCode;
if ( left && ( currtok_noskip.Type == TokType::Comment ) && currtok_noskip.Line == stmt_end.Line ) if ( left && ( currtok_noskip.Type == TokType::Comment ) && currtok_noskip.Line == stmt_end.Line )
{ {
inline_cmt = parse_comment(); inline_cmt = parse_comment();