Review formating #5306

This commit is contained in:
Ray
2025-10-26 18:21:24 +01:00
parent e244cf297a
commit cb58ca63d4

View File

@@ -163,7 +163,9 @@ int main(void)
splat = MatrixMultiply(splat, MatrixRotateZ(DEG2RAD*((float)GetRandomValue(-180, 180))));
Mesh decalMesh = GenMeshDecal(model, splat, decalSize, decalOffset);
if (decalMesh.vertexCount > 0) {
if (decalMesh.vertexCount > 0)
{
int decalIndex = decalCount++;
decalModels[decalIndex] = LoadModelFromMesh(decalMesh);
decalModels[decalIndex].materials[0].maps[0] = decalMaterial.maps[0];
@@ -220,12 +222,14 @@ int main(void)
for (int i = 0; i < decalCount; i++)
{
if (i == 20) {
if (i == 20)
{
DrawText("...", x0, yPos, 10, LIME);
yPos += 15;
}
if (i < 20) {
if (i < 20)
{
DrawText(TextFormat("Decal #%d", i+1), x0, yPos, 10, LIME);
DrawText(TextFormat("%d", decalModels[i].meshes[0].vertexCount), x1, yPos, 10, LIME);
DrawText(TextFormat("%d", decalModels[i].meshes[0].triangleCount), x2, yPos, 10, LIME);
@@ -246,21 +250,16 @@ int main(void)
Rectangle rect = (Rectangle){ 10, screenHeight - 100, 100, 60 };
if (Button(rect, showModel ? "Hide Model" : "Show Model")) {
showModel = !showModel;
}
if (Button(rect, showModel ? "Hide Model" : "Show Model")) showModel = !showModel;
rect.x += rect.width + 10;
if (Button(rect, "Clear Decals")) {
for (int i = 0; i < decalCount; i++)
{
UnloadModel(decalModels[i]);
}
if (Button(rect, "Clear Decals"))
{
for (int i = 0; i < decalCount; i++) UnloadModel(decalModels[i]);
decalCount = 0;
}
DrawFPS(10, 10);
EndDrawing();
@@ -272,14 +271,12 @@ int main(void)
UnloadModel(model);
UnloadTexture(modelTexture);
for (int i = 0; i < decalCount; i++) {
UnloadModel(decalModels[i]);
}
// Unload decal models
for (int i = 0; i < decalCount; i++) UnloadModel(decalModels[i]);
UnloadTexture(decalTexture);
// Free the data for decal generation
FreeDecalMeshData();
FreeDecalMeshData(); // Free the data for decal generation
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
@@ -364,6 +361,7 @@ static Vector3 ClipSegment(Vector3 v0, Vector3 v1, Vector3 p, float s)
return position;
}
// Generate mesh decals for provided model
static Mesh GenMeshDecal(Model inputModel, Matrix projection, float decalSize, float decalOffset)
{
// We're going to use these to build up our decal meshes
@@ -371,10 +369,11 @@ static Mesh GenMeshDecal(Model inputModel, Matrix projection, float decalSize, f
static MeshBuilder meshBuilders[2] = { 0 };
// Ugly way of telling us to free the static MeshBuilder data
if (inputModel.meshCount == -1) {
if (inputModel.meshCount == -1)
{
FreeMeshBuilder(&meshBuilders[0]);
FreeMeshBuilder(&meshBuilders[1]);
return (Mesh){0};
return (Mesh){ 0 };
}
// We're going to need the inverse matrix
@@ -584,15 +583,16 @@ static Mesh GenMeshDecal(Model inputModel, Matrix projection, float decalSize, f
}
}
static bool Button(Rectangle rec, char *label)
// Button UI element
static bool Button(Rectangle rec, const char *label)
{
Color bgColor = GRAY;
bool pressed = false;
if (CheckCollisionPointRec(GetMousePosition(), rec)) {
if (CheckCollisionPointRec(GetMousePosition(), rec))
{
bgColor = LIGHTGRAY;
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
pressed = true;
}
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) pressed = true;
}
DrawRectangleRec(rec, bgColor);