I am porting this SimplexNoise modual from C++ to C#, and have ran into issues with the way the programmer has retrevied values from arrays. He has something like as follows:
simplexnoise.h
static const int grad3[12][3] = {
{1,1,0}, {-1,1,0}, {1,-1,0}, {-1,-1,0},
{1,0,1}, {-1,0,1}, {1,0,-1}, {-1,0,-1},
{0,1,1}, {0,-1,1}, {0,1,-1}, {0,-1,-1}
};
simplesxnoise.cpp
n1 = t1 * t1 * dot(grad3[gi1], x1, y1);
And in my C# port:
SimplexNoise.cs
private static int[][] grad3 = new int[][] { new int[] {1,1,0}, new int[] {-1,1,0}, new int[] {1,-1,0}, new int[] {-1,-1,0},
new int[] {1,0,1}, new int[] {-1,0,1}, new int[] {1,0,-1}, new int[] {-1,0,-1},
new int[] {0,1,1}, new int[] {0,-1,1}, new int[] {0,1,-1}, new int[] {0,-1,-1}};
...
n1 = t1 * t1 * dot(grad3[gi1], x1, y1);
And for that line I get, cannot convert from int[] to int. Which is logical but how does this not have any errors in the C++ version? I only know the basics of C++ but from what I know that is an attempt to assign an integer variable with a 1D int array, which just doesn’t make any sence.
Any ideas?
This is because according to the source that you linked,
dot()expects an array as its first argument:const int* gmeans “a pointer to an integer”, or “an integer array”. Considering the usage, it is “an integer array” that the signature implies. Hence, you need to change the signature of your C#dot():