mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-20 02:08:14 +00:00
Correction of values used only once in GenMeshCubicmap (#3032)
* Correction of values used only once in GenMeshCubicmap The mapWidth and mapHeight values were only used as a limit in the for loop when they could be used throughout the function. * 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:
@@ -2940,11 +2940,8 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
|
|||||||
|
|
||||||
Color *pixels = LoadImageColors(cubicmap);
|
Color *pixels = LoadImageColors(cubicmap);
|
||||||
|
|
||||||
int mapWidth = cubicmap.width;
|
|
||||||
int mapHeight = cubicmap.height;
|
|
||||||
|
|
||||||
// NOTE: Max possible number of triangles numCubes*(12 triangles by cube)
|
// 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 vCounter = 0; // Used to count vertices
|
||||||
int tcCounter = 0; // Used to count texcoords
|
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 topTexUV = { 0.0f, 0.5f, 0.5f, 0.5f };
|
||||||
RectangleF bottomTexUV = { 0.5f, 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...
|
// Define the 8 vertex of the cube, we will combine them accordingly later...
|
||||||
Vector3 v1 = { w*(x - 0.5f), h2, h*(z - 0.5f) };
|
Vector3 v1 = { w*(x - 0.5f), h2, h*(z - 0.5f) };
|
||||||
|
Reference in New Issue
Block a user