mapWidth and mapHeight removed from GenMeshCubicmap
mapWidth and mapHeight have been removed from GenMeshCubicmap in favor of using cubicmap.width and cubicmap.height
This commit is contained in:
parent
c5ecdc5583
commit
192be92dbe
|
|
@ -2940,11 +2940,8 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
|
|||
|
||||
Color *pixels = LoadImageColors(cubicmap);
|
||||
|
||||
int mapWidth = cubicmap.width;
|
||||
int mapHeight = cubicmap.height;
|
||||
|
||||
// NOTE: Max possible number of triangles numCubes*(12 triangles by cube)
|
||||
int maxTriangles = mapWidth * mapHeight * 12;
|
||||
int maxTriangles = cubicmap.width * cubicmap.height * 12;
|
||||
|
||||
int vCounter = 0; // Used to count vertices
|
||||
int tcCounter = 0; // Used to count texcoords
|
||||
|
|
@ -2981,9 +2978,9 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
|
|||
RectangleF topTexUV = { 0.0f, 0.5f, 0.5f, 0.5f };
|
||||
RectangleF bottomTexUV = { 0.5f, 0.5f, 0.5f, 0.5f };
|
||||
|
||||
for (int z = 0; z < mapHeight; ++z)
|
||||
for (int z = 0; z < cubicmap.height; ++z)
|
||||
{
|
||||
for (int x = 0; x < mapWidth; ++x)
|
||||
for (int x = 0; x < cubicmap.width; ++x)
|
||||
{
|
||||
// Define the 8 vertex of the cube, we will combine them accordingly later...
|
||||
Vector3 v1 = { w*(x - 0.5f), h2, h*(z - 0.5f) };
|
||||
|
|
@ -2996,7 +2993,7 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
|
|||
Vector3 v8 = { w*(x + 0.5f), 0, h*(z + 0.5f) };
|
||||
|
||||
// We check pixel color to be WHITE -> draw full cube
|
||||
if (COLOR_EQUAL(pixels[z*mapWidth + x], WHITE))
|
||||
if (COLOR_EQUAL(pixels[z*cubicmap.width + x], WHITE))
|
||||
{
|
||||
// Define triangles and checking collateral cubes
|
||||
//------------------------------------------------
|
||||
|
|
@ -3053,7 +3050,7 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
|
|||
tcCounter += 6;
|
||||
|
||||
// Checking cube on bottom of current cube
|
||||
if (((z < mapHeight - 1) && COLOR_EQUAL(pixels[(z + 1)*mapWidth + x], BLACK)) || (z == mapHeight - 1))
|
||||
if (((z < cubicmap.height - 1) && COLOR_EQUAL(pixels[(z + 1)*cubicmap.width + x], BLACK)) || (z == cubicmap.height - 1))
|
||||
{
|
||||
// Define front triangles (2 tris, 6 vertex) --> v2 v7 v3, v3 v7 v8
|
||||
// NOTE: Collateral occluded faces are not generated
|
||||
|
|
@ -3083,7 +3080,7 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
|
|||
}
|
||||
|
||||
// Checking cube on top of current cube
|
||||
if (((z > 0) && COLOR_EQUAL(pixels[(z - 1)*mapWidth + x], BLACK)) || (z == 0))
|
||||
if (((z > 0) && COLOR_EQUAL(pixels[(z - 1)*cubicmap.width + x], BLACK)) || (z == 0))
|
||||
{
|
||||
// Define back triangles (2 tris, 6 vertex) --> v1 v5 v6, v1 v4 v5
|
||||
// NOTE: Collateral occluded faces are not generated
|
||||
|
|
@ -3113,7 +3110,7 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
|
|||
}
|
||||
|
||||
// Checking cube on right of current cube
|
||||
if (((x < mapWidth - 1) && COLOR_EQUAL(pixels[z*mapWidth + (x + 1)], BLACK)) || (x == mapWidth - 1))
|
||||
if (((x < cubicmap.width - 1) && COLOR_EQUAL(pixels[z*cubicmap.width + (x + 1)], BLACK)) || (x == cubicmap.width - 1))
|
||||
{
|
||||
// Define right triangles (2 tris, 6 vertex) --> v3 v8 v4, v4 v8 v5
|
||||
// NOTE: Collateral occluded faces are not generated
|
||||
|
|
@ -3143,7 +3140,7 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
|
|||
}
|
||||
|
||||
// Checking cube on left of current cube
|
||||
if (((x > 0) && COLOR_EQUAL(pixels[z*mapWidth + (x - 1)], BLACK)) || (x == 0))
|
||||
if (((x > 0) && COLOR_EQUAL(pixels[z*cubicmap.width + (x - 1)], BLACK)) || (x == 0))
|
||||
{
|
||||
// Define left triangles (2 tris, 6 vertex) --> v1 v7 v2, v1 v6 v7
|
||||
// NOTE: Collateral occluded faces are not generated
|
||||
|
|
@ -3173,7 +3170,7 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
|
|||
}
|
||||
}
|
||||
// We check pixel color to be BLACK, we will only draw floor and roof
|
||||
else if (COLOR_EQUAL(pixels[z*mapWidth + x], BLACK))
|
||||
else if (COLOR_EQUAL(pixels[z*cubicmap.width + x], BLACK))
|
||||
{
|
||||
// Define top triangles (2 tris, 6 vertex --> v1-v2-v3, v1-v3-v4)
|
||||
mapVertices[vCounter] = v1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user