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