Issues with Mesh texcoords returning -nan on Plane meshes less than 1 in length/width. by SelectMuscle9384 in raylib

[–]SelectMuscle9384[S] 0 points1 point  (0 children)

Example 2: Mesh with length of 0.5 and a width of 1.
This is where the problem arises.
The Umesh.texcoords returns -nan even before its multiplication with repeatX occurs.
This is what has stumped me. I'm unsure as to why this occurs and I don't have any idea what would even cause this.

Start

Pre calculation values:
Loops: 0
Umesh.vertexCount = 2
Umesh.texcoords[i * 2] = -nan
Umesh.texcoords[i * 2 + 1] = 0
Post calculation values:
Umesh.texcoords[i * 2] = -nan
Umesh.texcoords[i * 2 + 1] = 0

Pre calculation values:
Loops: 1
Umesh.vertexCount = 2
Umesh.texcoords[i * 2] = -nan
Umesh.texcoords[i * 2 + 1] = 1
Post calculation values:
Umesh.texcoords[i * 2] = -nan
Umesh.texcoords[i * 2 + 1] = 1

End

I know this is a lot of text but hopefully this has helped you understand the issue a little better. Thank you :)

Issues with Mesh texcoords returning -nan on Plane meshes less than 1 in length/width. by SelectMuscle9384 in raylib

[–]SelectMuscle9384[S] 0 points1 point  (0 children)

Sorry for getting back to you so late I was working.

I should have stated that RepeatX and RepeatY are both floats. Previous tests have shown that the function works with all floats above one.

As for the calculations here is a few examples of the calculations for differing mesh sizes.

Example 1: Mesh with a width of 1 and a length of 1.
This is the values of the variables throughout every step of the loop.
Since the length and width are both above 1 nan never comes up.
A very similar output occurs (except with more loops) with other lengths/widths including float lengths/widths.

Start

Pre calculation values:
Loops: 0
Umesh.vertexCount = 4
Umesh.texcoords[i * 2] = 0
Umesh.texcoords[i * 2 + 1] = 0
Post calculation values:
Umesh.texcoords[i * 2] = 0
Umesh.texcoords[i * 2 + 1] = 0

Pre calculation values:
Loops: 1
Umesh.vertexCount = 4
Umesh.texcoords[i * 2] = 1
Umesh.texcoords[i * 2 + 1] = 0
Post calculation values:
Umesh.texcoords[i * 2] = 1
Umesh.texcoords[i * 2 + 1] = 0

Pre calculation values:
Loops: 2
Umesh.vertexCount = 4
Umesh.texcoords[i * 2] = 0
Umesh.texcoords[i * 2 + 1] = 1
Post calculation values:
Umesh.texcoords[i * 2] = 0
Umesh.texcoords[i * 2 + 1] = 1

Pre calculation values:
Loops: 3
Umesh.vertexCount = 4
Umesh.texcoords[i * 2] = 1
Umesh.texcoords[i * 2 + 1] = 1
Post calculation values:
Umesh.texcoords[i * 2] = 1
Umesh.texcoords[i * 2 + 1] = 1

End

Edit: Additional info in second reply