Review formatting

This commit is contained in:
Ray 2024-04-21 12:29:09 +02:00
parent cf47fbb20b
commit 3caa424ad4
7 changed files with 122 additions and 120 deletions

View File

@ -46,7 +46,7 @@ int main(void)
Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position
UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM
bool pause = false; // Pause camera orbital rotation (and zoom)
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
@ -58,7 +58,7 @@ int main(void)
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_P)) pause = !pause;
if (!pause) UpdateCamera(&camera, CAMERA_ORBITAL);
//----------------------------------------------------------------------------------
@ -76,10 +76,10 @@ int main(void)
DrawTextureEx(cubicmap, (Vector2){ screenWidth - cubicmap.width*4.0f - 20, 20.0f }, 0.0f, 4.0f, WHITE);
DrawRectangleLines(screenWidth - cubicmap.width*4 - 20, 20, cubicmap.width*4, cubicmap.height*4, GREEN);
DrawText("cubicmap image used to", 658, 90, 10, GRAY);
DrawText("generate map 3d model", 658, 104, 10, GRAY);
DrawFPS(10, 10);
EndDrawing();

View File

@ -1377,7 +1377,7 @@ int InitPlatform(void)
if (CORE.Window.fullscreen)
{
// remember center for switchinging from fullscreen to window
// Remember center for switchinging from fullscreen to window
if ((CORE.Window.screen.height == CORE.Window.display.height) && (CORE.Window.screen.width == CORE.Window.display.width))
{
// If screen width/height equal to the display, we can't calculate the window pos for toggling full-screened/windowed.
@ -1515,7 +1515,7 @@ int InitPlatform(void)
// If graphic device is no properly initialized, we end program
if (!CORE.Window.ready) { TRACELOG(LOG_FATAL, "PLATFORM: Failed to initialize graphic device"); return -1; }
else
else
{
// Try to center window on screen but avoiding window-bar outside of screen
int monitorX = 0;

View File

@ -512,7 +512,7 @@ void InitAudioDevice(void)
}
TRACELOG(LOG_INFO, "AUDIO: Device initialized successfully");
TRACELOG(LOG_INFO, " > Backend: miniaudio / %s", ma_get_backend_name(AUDIO.System.context.backend));
TRACELOG(LOG_INFO, " > Backend: miniaudio | %s", ma_get_backend_name(AUDIO.System.context.backend));
TRACELOG(LOG_INFO, " > Format: %s -> %s", ma_get_format_name(AUDIO.System.device.playback.format), ma_get_format_name(AUDIO.System.device.playback.internalFormat));
TRACELOG(LOG_INFO, " > Channels: %d -> %d", AUDIO.System.device.playback.channels, AUDIO.System.device.playback.internalChannels);
TRACELOG(LOG_INFO, " > Sample rate: %d -> %d", AUDIO.System.device.sampleRate, AUDIO.System.device.playback.internalSampleRate);
@ -896,13 +896,13 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
bool IsWaveReady(Wave wave)
{
bool result = false;
if ((wave.data != NULL) && // Validate wave data available
(wave.frameCount > 0) && // Validate frame count
(wave.sampleRate > 0) && // Validate sample rate is supported
(wave.sampleSize > 0) && // Validate sample size is supported
(wave.channels > 0)) result = true; // Validate number of channels supported
return result;
}
@ -997,13 +997,13 @@ Sound LoadSoundAlias(Sound source)
bool IsSoundReady(Sound sound)
{
bool result = false;
if ((sound.frameCount > 0) && // Validate frame count
(sound.stream.buffer != NULL) && // Validate stream buffer
(sound.stream.sampleRate > 0) && // Validate sample rate is supported
(sound.stream.sampleSize > 0) && // Validate sample size is supported
(sound.stream.channels > 0)) result = true; // Validate number of channels supported
return result;
}
@ -1196,9 +1196,9 @@ void StopSound(Sound sound)
bool IsSoundPlaying(Sound sound)
{
bool result = false;
if (IsAudioBufferPlaying(sound.stream.buffer)) result = true;
return result;
}

View File

@ -1420,7 +1420,7 @@ void SetShaderValueTexture(Shader shader, int locIndex, Texture2D texture)
Ray GetScreenToWorldRay(Vector2 position, Camera camera)
{
Ray ray = GetScreenToWorldRayEx(position, camera, GetScreenWidth(), GetScreenHeight());
return ray;
}
@ -1463,8 +1463,8 @@ Ray GetScreenToWorldRayEx(Vector2 position, Camera camera, int width, int height
Vector3 farPoint = Vector3Unproject((Vector3){ deviceCoords.x, deviceCoords.y, 1.0f }, matProj, matView);
// Unproject the mouse cursor in the near plane
// We need this as the source position because orthographic projects,
// compared to perspective doesn't have a convergence point,
// We need this as the source position because orthographic projects,
// compared to perspective doesn't have a convergence point,
// meaning that the "eye" of the camera is more like a plane than a point
Vector3 cameraPlanePointerPos = Vector3Unproject((Vector3){ deviceCoords.x, deviceCoords.y, -1.0f }, matProj, matView);
@ -1484,7 +1484,7 @@ Ray GetScreenToWorldRayEx(Vector2 position, Camera camera, int width, int height
Matrix GetCameraMatrix(Camera camera)
{
Matrix mat = MatrixLookAt(camera.position, camera.target, camera.up);
return mat;
}
@ -1951,9 +1951,9 @@ const char *GetFileExtension(const char *fileName)
static const char *strprbrk(const char *s, const char *charset)
{
const char *latestMatch = NULL;
for (; s = strpbrk(s, charset), s != NULL; latestMatch = s++) { }
return latestMatch;
}
@ -1961,9 +1961,9 @@ static const char *strprbrk(const char *s, const char *charset)
const char *GetFileName(const char *filePath)
{
const char *fileName = NULL;
if (filePath != NULL) fileName = strprbrk(filePath, "\\/");
if (fileName != NULL) return filePath;
return fileName + 1;
@ -2244,9 +2244,9 @@ bool IsPathFile(const char *path)
bool IsFileDropped(void)
{
bool result = false;
if (CORE.Window.dropFileCount > 0) result = true;
return result;
}

View File

@ -706,7 +706,7 @@ void DrawCapsule(Vector3 startPos, Vector3 endPos, float radius, int slices, int
Vector3 capCenter = endPos;
float baseSliceAngle = (2.0f*PI)/slices;
float baseRingAngle = PI * 0.5f / rings;
float baseRingAngle = PI*0.5f/rings;
rlBegin(RL_TRIANGLES);
rlColor4ub(color.r, color.g, color.b, color.a);
@ -725,34 +725,34 @@ void DrawCapsule(Vector3 startPos, Vector3 endPos, float radius, int slices, int
// as we iterate through the rings they must get smaller by the cos(angle(i))
// compute the four vertices
float ringSin1 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 0 ));
float ringCos1 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 0 ));
float ringSin1 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle*( i + 0 ));
float ringCos1 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle*( i + 0 ));
Vector3 w1 = (Vector3){
capCenter.x + (sinf(baseRingAngle * ( i + 0 ))*b0.x + ringSin1*b1.x + ringCos1*b2.x) * radius,
capCenter.y + (sinf(baseRingAngle * ( i + 0 ))*b0.y + ringSin1*b1.y + ringCos1*b2.y) * radius,
capCenter.z + (sinf(baseRingAngle * ( i + 0 ))*b0.z + ringSin1*b1.z + ringCos1*b2.z) * radius
capCenter.x + (sinf(baseRingAngle*( i + 0 ))*b0.x + ringSin1*b1.x + ringCos1*b2.x)*radius,
capCenter.y + (sinf(baseRingAngle*( i + 0 ))*b0.y + ringSin1*b1.y + ringCos1*b2.y)*radius,
capCenter.z + (sinf(baseRingAngle*( i + 0 ))*b0.z + ringSin1*b1.z + ringCos1*b2.z)*radius
};
float ringSin2 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 0 ));
float ringCos2 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 0 ));
float ringSin2 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle*( i + 0 ));
float ringCos2 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle*( i + 0 ));
Vector3 w2 = (Vector3){
capCenter.x + (sinf(baseRingAngle * ( i + 0 ))*b0.x + ringSin2*b1.x + ringCos2*b2.x) * radius,
capCenter.y + (sinf(baseRingAngle * ( i + 0 ))*b0.y + ringSin2*b1.y + ringCos2*b2.y) * radius,
capCenter.z + (sinf(baseRingAngle * ( i + 0 ))*b0.z + ringSin2*b1.z + ringCos2*b2.z) * radius
capCenter.x + (sinf(baseRingAngle*( i + 0 ))*b0.x + ringSin2*b1.x + ringCos2*b2.x)*radius,
capCenter.y + (sinf(baseRingAngle*( i + 0 ))*b0.y + ringSin2*b1.y + ringCos2*b2.y)*radius,
capCenter.z + (sinf(baseRingAngle*( i + 0 ))*b0.z + ringSin2*b1.z + ringCos2*b2.z)*radius
};
float ringSin3 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 1 ));
float ringCos3 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 1 ));
float ringSin3 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle*( i + 1 ));
float ringCos3 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle*( i + 1 ));
Vector3 w3 = (Vector3){
capCenter.x + (sinf(baseRingAngle * ( i + 1 ))*b0.x + ringSin3*b1.x + ringCos3*b2.x) * radius,
capCenter.y + (sinf(baseRingAngle * ( i + 1 ))*b0.y + ringSin3*b1.y + ringCos3*b2.y) * radius,
capCenter.z + (sinf(baseRingAngle * ( i + 1 ))*b0.z + ringSin3*b1.z + ringCos3*b2.z) * radius
capCenter.x + (sinf(baseRingAngle*( i + 1 ))*b0.x + ringSin3*b1.x + ringCos3*b2.x)*radius,
capCenter.y + (sinf(baseRingAngle*( i + 1 ))*b0.y + ringSin3*b1.y + ringCos3*b2.y)*radius,
capCenter.z + (sinf(baseRingAngle*( i + 1 ))*b0.z + ringSin3*b1.z + ringCos3*b2.z)*radius
};
float ringSin4 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 1 ));
float ringCos4 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 1 ));
float ringSin4 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle*( i + 1 ));
float ringCos4 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle*( i + 1 ));
Vector3 w4 = (Vector3){
capCenter.x + (sinf(baseRingAngle * ( i + 1 ))*b0.x + ringSin4*b1.x + ringCos4*b2.x) * radius,
capCenter.y + (sinf(baseRingAngle * ( i + 1 ))*b0.y + ringSin4*b1.y + ringCos4*b2.y) * radius,
capCenter.z + (sinf(baseRingAngle * ( i + 1 ))*b0.z + ringSin4*b1.z + ringCos4*b2.z) * radius
capCenter.x + (sinf(baseRingAngle*( i + 1 ))*b0.x + ringSin4*b1.x + ringCos4*b2.x)*radius,
capCenter.y + (sinf(baseRingAngle*( i + 1 ))*b0.y + ringSin4*b1.y + ringCos4*b2.y)*radius,
capCenter.z + (sinf(baseRingAngle*( i + 1 ))*b0.z + ringSin4*b1.z + ringCos4*b2.z)*radius
};
// Make sure cap triangle normals are facing outwards
@ -849,7 +849,7 @@ void DrawCapsuleWires(Vector3 startPos, Vector3 endPos, float radius, int slices
Vector3 capCenter = endPos;
float baseSliceAngle = (2.0f*PI)/slices;
float baseRingAngle = PI * 0.5f / rings;
float baseRingAngle = PI*0.5f/rings;
rlBegin(RL_LINES);
rlColor4ub(color.r, color.g, color.b, color.a);
@ -868,34 +868,34 @@ void DrawCapsuleWires(Vector3 startPos, Vector3 endPos, float radius, int slices
// as we iterate through the rings they must get smaller by the cos(angle(i))
// compute the four vertices
float ringSin1 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 0 ));
float ringCos1 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 0 ));
float ringSin1 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle*( i + 0 ));
float ringCos1 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle*( i + 0 ));
Vector3 w1 = (Vector3){
capCenter.x + (sinf(baseRingAngle * ( i + 0 ))*b0.x + ringSin1*b1.x + ringCos1*b2.x) * radius,
capCenter.y + (sinf(baseRingAngle * ( i + 0 ))*b0.y + ringSin1*b1.y + ringCos1*b2.y) * radius,
capCenter.z + (sinf(baseRingAngle * ( i + 0 ))*b0.z + ringSin1*b1.z + ringCos1*b2.z) * radius
capCenter.x + (sinf(baseRingAngle*( i + 0 ))*b0.x + ringSin1*b1.x + ringCos1*b2.x)*radius,
capCenter.y + (sinf(baseRingAngle*( i + 0 ))*b0.y + ringSin1*b1.y + ringCos1*b2.y)*radius,
capCenter.z + (sinf(baseRingAngle*( i + 0 ))*b0.z + ringSin1*b1.z + ringCos1*b2.z)*radius
};
float ringSin2 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 0 ));
float ringCos2 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 0 ));
float ringSin2 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle*( i + 0 ));
float ringCos2 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle*( i + 0 ));
Vector3 w2 = (Vector3){
capCenter.x + (sinf(baseRingAngle * ( i + 0 ))*b0.x + ringSin2*b1.x + ringCos2*b2.x) * radius,
capCenter.y + (sinf(baseRingAngle * ( i + 0 ))*b0.y + ringSin2*b1.y + ringCos2*b2.y) * radius,
capCenter.z + (sinf(baseRingAngle * ( i + 0 ))*b0.z + ringSin2*b1.z + ringCos2*b2.z) * radius
capCenter.x + (sinf(baseRingAngle*( i + 0 ))*b0.x + ringSin2*b1.x + ringCos2*b2.x)*radius,
capCenter.y + (sinf(baseRingAngle*( i + 0 ))*b0.y + ringSin2*b1.y + ringCos2*b2.y)*radius,
capCenter.z + (sinf(baseRingAngle*( i + 0 ))*b0.z + ringSin2*b1.z + ringCos2*b2.z)*radius
};
float ringSin3 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 1 ));
float ringCos3 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 1 ));
float ringSin3 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle*( i + 1 ));
float ringCos3 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle*( i + 1 ));
Vector3 w3 = (Vector3){
capCenter.x + (sinf(baseRingAngle * ( i + 1 ))*b0.x + ringSin3*b1.x + ringCos3*b2.x) * radius,
capCenter.y + (sinf(baseRingAngle * ( i + 1 ))*b0.y + ringSin3*b1.y + ringCos3*b2.y) * radius,
capCenter.z + (sinf(baseRingAngle * ( i + 1 ))*b0.z + ringSin3*b1.z + ringCos3*b2.z) * radius
capCenter.x + (sinf(baseRingAngle*( i + 1 ))*b0.x + ringSin3*b1.x + ringCos3*b2.x)*radius,
capCenter.y + (sinf(baseRingAngle*( i + 1 ))*b0.y + ringSin3*b1.y + ringCos3*b2.y)*radius,
capCenter.z + (sinf(baseRingAngle*( i + 1 ))*b0.z + ringSin3*b1.z + ringCos3*b2.z)*radius
};
float ringSin4 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 1 ));
float ringCos4 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 1 ));
float ringSin4 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle*( i + 1 ));
float ringCos4 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle*( i + 1 ));
Vector3 w4 = (Vector3){
capCenter.x + (sinf(baseRingAngle * ( i + 1 ))*b0.x + ringSin4*b1.x + ringCos4*b2.x) * radius,
capCenter.y + (sinf(baseRingAngle * ( i + 1 ))*b0.y + ringSin4*b1.y + ringCos4*b2.y) * radius,
capCenter.z + (sinf(baseRingAngle * ( i + 1 ))*b0.z + ringSin4*b1.z + ringCos4*b2.z) * radius
capCenter.x + (sinf(baseRingAngle*( i + 1 ))*b0.x + ringSin4*b1.x + ringCos4*b2.x)*radius,
capCenter.y + (sinf(baseRingAngle*( i + 1 ))*b0.y + ringSin4*b1.y + ringCos4*b2.y)*radius,
capCenter.z + (sinf(baseRingAngle*( i + 1 ))*b0.z + ringSin4*b1.z + ringCos4*b2.z)*radius
};
rlVertex3f(w1.x, w1.y, w1.z);
@ -1105,7 +1105,7 @@ Model LoadModelFromMesh(Mesh mesh)
bool IsModelReady(Model model)
{
bool result = false;
if ((model.meshes != NULL) && // Validate model contains some mesh
(model.materials != NULL) && // Validate model contains some material (at least default one)
(model.meshMaterial != NULL) && // Validate mesh-material linkage
@ -1113,7 +1113,7 @@ bool IsModelReady(Model model)
(model.materialCount > 0)) result = true; // Validate material count
// NOTE: This is a very general model validation, many elements could be validated from a model...
return result;
}
@ -1966,18 +1966,18 @@ static void ProcessMaterialsOBJ(Material *materials, tinyobj_material_t *mats, i
materials[m].maps[MATERIAL_MAP_DIFFUSE].texture = (Texture2D){ rlGetTextureIdDefault(), 1, 1, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 };
if (mats[m].diffuse_texname != NULL) materials[m].maps[MATERIAL_MAP_DIFFUSE].texture = LoadTexture(mats[m].diffuse_texname); //char *diffuse_texname; // map_Kd
else materials[m].maps[MATERIAL_MAP_DIFFUSE].color = (Color){ (unsigned char)(mats[m].diffuse[0]*255.0f), (unsigned char)(mats[m].diffuse[1]*255.0f), (unsigned char)(mats[m].diffuse[2] * 255.0f), 255 }; //float diffuse[3];
else materials[m].maps[MATERIAL_MAP_DIFFUSE].color = (Color){ (unsigned char)(mats[m].diffuse[0]*255.0f), (unsigned char)(mats[m].diffuse[1]*255.0f), (unsigned char)(mats[m].diffuse[2]*255.0f), 255 }; //float diffuse[3];
materials[m].maps[MATERIAL_MAP_DIFFUSE].value = 0.0f;
if (mats[m].specular_texname != NULL) materials[m].maps[MATERIAL_MAP_SPECULAR].texture = LoadTexture(mats[m].specular_texname); //char *specular_texname; // map_Ks
materials[m].maps[MATERIAL_MAP_SPECULAR].color = (Color){ (unsigned char)(mats[m].specular[0]*255.0f), (unsigned char)(mats[m].specular[1]*255.0f), (unsigned char)(mats[m].specular[2] * 255.0f), 255 }; //float specular[3];
materials[m].maps[MATERIAL_MAP_SPECULAR].color = (Color){ (unsigned char)(mats[m].specular[0]*255.0f), (unsigned char)(mats[m].specular[1]*255.0f), (unsigned char)(mats[m].specular[2]*255.0f), 255 }; //float specular[3];
materials[m].maps[MATERIAL_MAP_SPECULAR].value = 0.0f;
if (mats[m].bump_texname != NULL) materials[m].maps[MATERIAL_MAP_NORMAL].texture = LoadTexture(mats[m].bump_texname); //char *bump_texname; // map_bump, bump
materials[m].maps[MATERIAL_MAP_NORMAL].color = WHITE;
materials[m].maps[MATERIAL_MAP_NORMAL].value = mats[m].shininess;
materials[m].maps[MATERIAL_MAP_EMISSION].color = (Color){ (unsigned char)(mats[m].emission[0]*255.0f), (unsigned char)(mats[m].emission[1]*255.0f), (unsigned char)(mats[m].emission[2] * 255.0f), 255 }; //float emission[3];
materials[m].maps[MATERIAL_MAP_EMISSION].color = (Color){ (unsigned char)(mats[m].emission[0]*255.0f), (unsigned char)(mats[m].emission[1]*255.0f), (unsigned char)(mats[m].emission[2]*255.0f), 255 }; //float emission[3];
if (mats[m].displacement_texname != NULL) materials[m].maps[MATERIAL_MAP_HEIGHT].texture = LoadTexture(mats[m].displacement_texname); //char *displacement_texname; // disp
}
@ -2038,10 +2038,10 @@ Material LoadMaterialDefault(void)
bool IsMaterialReady(Material material)
{
bool result = false;
if ((material.maps != NULL) && // Validate material contain some map
(material.shader.id > 0)) result = true; // Validate material shader is valid
return result;
}
@ -2349,7 +2349,7 @@ Mesh GenMeshPlane(float width, float length, int resX, int resZ)
for (int face = 0; face < numFaces; face++)
{
// Retrieve lower left corner from face ind
int i = face + face / (resX - 1);
int i = face + face/(resX - 1);
triangles[t++] = i + resX;
triangles[t++] = i + 1;
@ -3038,7 +3038,7 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
Color *pixels = LoadImageColors(cubicmap);
// NOTE: Max possible number of triangles numCubes*(12 triangles by cube)
int maxTriangles = cubicmap.width * cubicmap.height * 12;
int maxTriangles = cubicmap.width*cubicmap.height*12;
int vCounter = 0; // Used to count vertices
int tcCounter = 0; // Used to count texcoords
@ -3588,6 +3588,8 @@ void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector
DrawBillboardPro(camera, texture, source, position, up, size, Vector2Zero(), 0.0f, tint);
}
// Draw a billboard with additional parameters
// NOTE: Size defines the destination rectangle size, stretching the source texture as required
void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint)
{
// NOTE: Billboard size will maintain source rectangle aspect ratio, size will represent billboard width
@ -3657,7 +3659,7 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector
rlBegin(RL_QUADS);
rlColor4ub(tint.r, tint.g, tint.b, tint.a);
if (sizeRatio.x * sizeRatio.y >= 0.0f)
if (sizeRatio.x*sizeRatio.y >= 0.0f)
{
// Bottom-left corner for texture and quad
rlTexCoord2f((float)source.x/texture.width, (float)source.y/texture.height);
@ -5278,7 +5280,7 @@ static Model LoadGLTF(const char *fileName)
}
else TRACELOG(LOG_WARNING, "MODEL: [%s] Color attribute data format not supported", fileName);
}
// NOTE: Attributes related to animations are processed separately
@ -5405,7 +5407,7 @@ static Model LoadGLTF(const char *fileName)
{
// Init raylib mesh boneIds to copy glTF attribute data
model.meshes[meshIndex].boneIds = RL_CALLOC(model.meshes[meshIndex].vertexCount*4, sizeof(unsigned char));
// Load attribute: vec4, u8 (unsigned char)
LOAD_ATTRIBUTE(attribute, 4, unsigned char, model.meshes[meshIndex].boneIds)
}
@ -6310,7 +6312,7 @@ static ModelAnimation *LoadModelAnimationsM3D(const char *fileName, int *animCou
for (unsigned int a = 0; a < m3d->numaction; a++)
{
animations[a].frameCount = m3d->action[a].durationmsec / M3D_ANIMDELAY;
animations[a].frameCount = m3d->action[a].durationmsec/M3D_ANIMDELAY;
animations[a].boneCount = m3d->numbone + 1;
animations[a].bones = RL_MALLOC((m3d->numbone + 1)*sizeof(BoneInfo));
animations[a].framePoses = RL_MALLOC(animations[a].frameCount*sizeof(Transform *));

View File

@ -2202,7 +2202,7 @@ bool CheckCollisionPointPoly(Vector2 point, Vector2 *points, int pointCount)
for (int i = 0, j = pointCount - 1; i < pointCount; j = i++)
{
if ((points[i].y > point.y) != (points[j].y > point.y) &&
(point.x < (points[j].x - points[i].x) * (point.y - points[i].y) / (points[j].y - points[i].y) + points[i].x))
(point.x < (points[j].x - points[i].x)*(point.y - points[i].y)/(points[j].y - points[i].y) + points[i].x))
{
inside = !inside;
}
@ -2347,14 +2347,14 @@ Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2)
static float EaseCubicInOut(float t, float b, float c, float d)
{
float result = 0.0f;
if ((t /= 0.5f*d) < 1) result = 0.5f*c*t*t*t + b;
else
{
t -= 2;
result = 0.5f*c*(t*t*t + 2.0f) + b;
}
return result;
}

View File

@ -293,7 +293,7 @@ Image LoadImage(const char *fileName)
unsigned char *fileData = LoadFileData(fileName, &dataSize);
// Loading image from memory data
if (fileData != NULL)
if (fileData != NULL)
{
image = LoadImageFromMemory(GetFileExtension(fileName), fileData, dataSize);
@ -318,7 +318,7 @@ Image LoadImageRaw(const char *fileName, int width, int height, int format, int
if (size <= dataSize) // Security check
{
// Offset file data to expected raw image by header size
// Offset file data to expected raw image by header size
if ((headerSize > 0) && ((headerSize + size) <= dataSize)) dataPtr += headerSize;
image.data = RL_MALLOC(size); // Allocate required memory in bytes
@ -385,8 +385,8 @@ Image LoadImageSvg(const char *fileNameOrString, int width, int height)
int offsetX = 0;
int offsetY = 0;
if (scaleHeight > scaleWidth) offsetY = (height - svgImage->height*scale) / 2;
else offsetX = (width - svgImage->width*scale) / 2;
if (scaleHeight > scaleWidth) offsetY = (height - svgImage->height*scale)/2;
else offsetX = (width - svgImage->width*scale)/2;
// Rasterize
struct NSVGrasterizer *rast = nsvgCreateRasterizer();
@ -464,7 +464,7 @@ Image LoadImageAnimFromMemory(const char *fileType, const unsigned char *fileDat
{
Image image = { 0 };
int frameCount = 0;
// Security check for input data
if ((fileType == NULL) || (fileData == NULL) || (dataSize == 0)) return image;
@ -501,7 +501,7 @@ Image LoadImageAnimFromMemory(const char *fileType, const unsigned char *fileDat
Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, int dataSize)
{
Image image = { 0 };
// Security check for input data
if ((fileType == NULL) || (fileData == NULL) || (dataSize == 0)) return image;
@ -710,13 +710,13 @@ Image LoadImageFromScreen(void)
bool IsImageReady(Image image)
{
bool result = false;
if ((image.data != NULL) && // Validate pixel data available
(image.width > 0) &&
(image.height > 0) && // Validate image size
(image.format > 0) && // Validate image format
(image.mipmaps > 0)) result = true; // Validate image mipmaps (at least 1 for basic mipmap level)
return result;
}
@ -1018,8 +1018,8 @@ Image GenImageGradientSquare(int width, int height, float density, Color inner,
float distY = fabsf(y - centerY);
// Normalize the distances by the dimensions of the gradient rectangle
float normalizedDistX = distX / centerX;
float normalizedDistY = distY / centerY;
float normalizedDistX = distX/centerX;
float normalizedDistY = distY/centerY;
// Calculate the total normalized Manhattan distance
float manhattanDist = fmaxf(normalizedDistX, normalizedDistY);
@ -1615,7 +1615,7 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
// Scale image depending on text size
if (textSize.y != imSize.y)
{
float scaleFactor = textSize.y / imSize.y;
float scaleFactor = textSize.y/imSize.y;
TRACELOG(LOG_INFO, "IMAGE: Text scaled by factor: %f", scaleFactor);
// Using nearest-neighbor scaling algorithm for default font
@ -2214,17 +2214,17 @@ void ImageKernelConvolution(Image *image, float* kernel, int kernelSize)
if (imgindex >= (unsigned int)(image->width*image->height))
{
temp[kernelWidth * xkabs + ykabs].x = 0.0f;
temp[kernelWidth * xkabs + ykabs].y = 0.0f;
temp[kernelWidth * xkabs + ykabs].z = 0.0f;
temp[kernelWidth * xkabs + ykabs].w = 0.0f;
temp[kernelWidth*xkabs + ykabs].x = 0.0f;
temp[kernelWidth*xkabs + ykabs].y = 0.0f;
temp[kernelWidth*xkabs + ykabs].z = 0.0f;
temp[kernelWidth*xkabs + ykabs].w = 0.0f;
}
else
{
temp[kernelWidth * xkabs + ykabs].x = ((float)pixels[imgindex].r)/255.0f*kernel[kernelWidth*xkabs + ykabs];
temp[kernelWidth * xkabs + ykabs].y = ((float)pixels[imgindex].g)/255.0f*kernel[kernelWidth*xkabs + ykabs];
temp[kernelWidth * xkabs + ykabs].z = ((float)pixels[imgindex].b)/255.0f*kernel[kernelWidth*xkabs + ykabs];
temp[kernelWidth * xkabs + ykabs].w = ((float)pixels[imgindex].a)/255.0f*kernel[kernelWidth*xkabs + ykabs];
temp[kernelWidth*xkabs + ykabs].x = ((float)pixels[imgindex].r)/255.0f*kernel[kernelWidth*xkabs + ykabs];
temp[kernelWidth*xkabs + ykabs].y = ((float)pixels[imgindex].g)/255.0f*kernel[kernelWidth*xkabs + ykabs];
temp[kernelWidth*xkabs + ykabs].z = ((float)pixels[imgindex].b)/255.0f*kernel[kernelWidth*xkabs + ykabs];
temp[kernelWidth*xkabs + ykabs].w = ((float)pixels[imgindex].a)/255.0f*kernel[kernelWidth*xkabs + ykabs];
}
}
}
@ -2672,7 +2672,7 @@ void ImageColorTint(Image *image, Color color)
float cB = (float)color.b/255;
float cA = (float)color.a/255;
for (int i = 0; i < image->width * image->height; i++)
for (int i = 0; i < image->width*image->height; i++)
{
unsigned char r = (unsigned char)(((float)pixels[i].r/255*cR)*255.0f);
unsigned char g = (unsigned char)(((float)pixels[i].g/255*cG)*255.0f);
@ -2702,7 +2702,7 @@ void ImageColorInvert(Image *image)
Color *pixels = LoadImageColors(*image);
for (int i = 0; i < image->width * image->height; i++)
for (int i = 0; i < image->width*image->height; i++)
{
pixels[i].r = 255 - pixels[i].r;
pixels[i].g = 255 - pixels[i].g;
@ -2739,7 +2739,7 @@ void ImageColorContrast(Image *image, float contrast)
Color *pixels = LoadImageColors(*image);
for (int i = 0; i < image->width * image->height; i++)
for (int i = 0; i < image->width*image->height; i++)
{
float pR = (float)pixels[i].r/255.0f;
pR -= 0.5f;
@ -2791,7 +2791,7 @@ void ImageColorBrightness(Image *image, int brightness)
Color *pixels = LoadImageColors(*image);
for (int i = 0; i < image->width * image->height; i++)
for (int i = 0; i < image->width*image->height; i++)
{
int cR = pixels[i].r + brightness;
int cG = pixels[i].g + brightness;
@ -2828,7 +2828,7 @@ void ImageColorReplace(Image *image, Color color, Color replace)
Color *pixels = LoadImageColors(*image);
for (int i = 0; i < image->width * image->height; i++)
for (int i = 0; i < image->width*image->height; i++)
{
if ((pixels[i].r == color.r) &&
(pixels[i].g == color.g) &&
@ -3616,7 +3616,7 @@ void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color)
}
// Repeat the first row data for all other rows
int bytesPerRow = bytesPerPixel * (int)rec.width;
int bytesPerRow = bytesPerPixel*(int)rec.width;
for (int y = 1; y < (int)rec.height; y++)
{
memcpy(pSrcPixel + (y*dst->width)*bytesPerPixel, pSrcPixel, bytesPerRow);
@ -3957,7 +3957,7 @@ RenderTexture2D LoadRenderTexture(int width, int height)
bool IsTextureReady(Texture2D texture)
{
bool result = false;
// TODO: Validate maximum texture size supported by GPU?
if ((texture.id > 0) && // Validate OpenGL id
@ -3965,7 +3965,7 @@ bool IsTextureReady(Texture2D texture)
(texture.height > 0) && // Validate texture size
(texture.format > 0) && // Validate texture pixel format
(texture.mipmaps > 0)) result = true; // Validate texture mipmaps (at least 1 for basic mipmap level)
return result;
}
@ -3984,11 +3984,11 @@ void UnloadTexture(Texture2D texture)
bool IsRenderTextureReady(RenderTexture2D target)
{
bool result = false;
if ((target.id > 0) && // Validate OpenGL id
IsTextureReady(target.depth) && // Validate FBO depth texture/renderbuffer
IsTextureReady(target.texture)) result = true; // Validate FBO texture
return result;
}
@ -4498,10 +4498,10 @@ bool ColorIsEqual(Color col1, Color col2)
Color Fade(Color color, float alpha)
{
Color result = color;
if (alpha < 0.0f) alpha = 0.0f;
else if (alpha > 1.0f) alpha = 1.0f;
result.a = (unsigned char)(255.0f*alpha);
return result;
@ -4511,7 +4511,7 @@ Color Fade(Color color, float alpha)
int ColorToInt(Color color)
{
int result = (((int)color.r << 24) | ((int)color.g << 16) | ((int)color.b << 8) | (int)color.a);
return result;
}
@ -4732,7 +4732,7 @@ Color ColorContrast(Color color, float contrast)
Color ColorAlpha(Color color, float alpha)
{
Color result = color;
if (alpha < 0.0f) alpha = 0.0f;
else if (alpha > 1.0f) alpha = 1.0f;
@ -5042,15 +5042,15 @@ int GetPixelDataSize(int width, int height, int format)
static float HalfToFloat(unsigned short x)
{
float result = 0.0f;
const unsigned int e = (x & 0x7C00) >> 10; // Exponent
const unsigned int m = (x & 0x03FF) << 13; // Mantissa
const float fm = (float)m;
const unsigned int v = (*(unsigned int*)&fm) >> 23; // Evil log2 bit hack to count leading zeros in denormalized format
const unsigned int r = (x & 0x8000) << 16 | (e != 0)*((e + 112) << 23 | m) | ((e == 0)&(m != 0))*((v - 37) << 23 | ((m << (150 - v)) & 0x007FE000)); // sign : normalized : denormalized
result = *(float *)&r;
return result;
}
@ -5058,13 +5058,13 @@ static float HalfToFloat(unsigned short x)
static unsigned short FloatToHalf(float x)
{
unsigned short result = 0;
const unsigned int b = (*(unsigned int*) & x) + 0x00001000; // Round-to-nearest-even: add last bit after truncated mantissa
const unsigned int e = (b & 0x7F800000) >> 23; // Exponent
const unsigned int m = b & 0x007FFFFF; // Mantissa; in line below: 0x007FF000 = 0x00800000-0x00001000 = decimal indicator flag - initial rounding
result = (b & 0x80000000) >> 16 | (e > 112)*((((e - 112) << 10) & 0x7C00) | m >> 13) | ((e < 113) & (e > 101))*((((0x007FF000 + m) >> (125 - e)) + 1) >> 1) | (e > 143)*0x7FFF; // sign : normalized : denormalized : saturate
return result;
}