CodePlexProject Hosting for Open Source Software

1

Vote
I've been studying Hieroglyph3, and I've noticed a small mistake he implementation of a class method

The mistake is as follows:

The implementation of method

Source code shot from hieroglyph3-90825:

`PerlinNoise::noise3`

The class was designed as a random noise generator, using interpolation on three pre-initialized private floating point arrays. Each array (namely g1, g2, g3) corresponds to a generating method(noise, noise2, noise3).The mistake is as follows:

The implementation of method

`PerlinNoise::noise3`

should have used `g3`

, but used `g2`

instead, thus an ```
array_index_out_of_bound
```

error might occur when the method is invoked.Source code shot from hieroglyph3-90825:

// in header PerlinNoise.h: class PerlinNoise { // ... private: #define base 0x100 float g2[base + base + 2][2]; float g3[base + base + 2][3]; } // in PerlinNoise.cpp: float PerlinNoise::noise3( float x, float y, float z ) { // ... // Errors: array index out of bound! q should have referred to a pointer in g3. q = g2[b000]; u = rx0*q[0] + ry0*q[1] + rz0*q[2]; q = g2[b100]; v = rx1*q[0] + ry0*q[1] + rz0*q[2]; a = lerp(sx, u, v); q = g2[b010]; u = rx0*q[0] + ry1*q[1] + rz0*q[2]; q = g2[b110]; v = rx1*q[0] + ry1*q[1] + rz0*q[2]; b = lerp(sx, u, v); q = g2[b001]; u = rx0*q[0] + ry0*q[1] + rz1*q[2]; q = g2[b101]; v = rx1*q[0] + ry0*q[1] + rz1*q[2]; c = lerp(sx, u, v); q = g2[b011]; u = rx0*q[0] + ry1*q[1] + rz1*q[2]; q = g2[b111]; v = rx1*q[0] + ry1*q[1] + rz1*q[2]; d = lerp(sx, u, v); // ... }

No files are attached

## comments