We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There is no need to use dynamic allocation in the perlin class. Simply declare ranvec, perm_x, perm_y and perm_z as arrays and that's it:
perlin
ranvec
perm_x
perm_y
perm_z
class perlin { public: perlin() { - ranvec = new vec3[point_count]; for (int i = 0; i < point_count; i++) { ranvec[i] = unit_vector(vec3::random(-1,1)); } - perm_x = perlin_generate_perm(); - perm_y = perlin_generate_perm(); - perm_z = perlin_generate_perm(); + perlin_generate_perm(perm_x); + perlin_generate_perm(perm_y); + perlin_generate_perm(perm_z); } - - ~perlin() { - delete[] ranvec; - delete[] perm_x; - delete[] perm_y; - delete[] perm_z; - } double noise(const point3& p) const { @@ -71,20 +63,16 @@ class perlin { private: static const int point_count = 256; - vec3* ranvec; - int* perm_x; - int* perm_y; - int* perm_z; + vec3 ranvec[point_count]; + int perm_x[point_count]; + int perm_y[point_count]; + int perm_z[point_count]; - static int* perlin_generate_perm() { - auto p = new int[point_count]; - + static void perlin_generate_perm(int* p) { for (int i = 0; i < point_count; i++) p[i] = i; permute(p, point_count); - - return p; } static void permute(int* p, int n) {
The text was updated successfully, but these errors were encountered:
Oif. Strong agreement.
Sorry, something went wrong.
Resolves #1483
12c4e05
1473cba
Resolved in #1533
rupsis
No branches or pull requests
There is no need to use dynamic allocation in the
perlin
class. Simply declareranvec
,perm_x
,perm_y
andperm_z
as arrays and that's it:The text was updated successfully, but these errors were encountered: