mirror of
https://github.com/raysan5/raylib.git
synced 2025-11-10 20:45:10 +00:00
Review formating #5306
This commit is contained in:
@@ -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++)
|
||||
if (Button(rect, "Clear Decals"))
|
||||
{
|
||||
UnloadModel(decalModels[i]);
|
||||
}
|
||||
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,7 +369,8 @@ 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 };
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user