Improve Clouds::render mathematics

This commit is contained in:
Loic Blot 2015-03-07 13:23:38 +01:00
parent 5698e2baf8
commit a603a76787

@ -162,30 +162,25 @@ void Clouds::render()
bool *grid = new bool[cloud_radius_i * 2 * cloud_radius_i * 2]; bool *grid = new bool[cloud_radius_i * 2 * cloud_radius_i * 2];
for(s16 zi=-cloud_radius_i; zi<cloud_radius_i; zi++) float cloud_size_noise = cloud_size / BS / 200;
for(s16 xi=-cloud_radius_i; xi<cloud_radius_i; xi++)
{ for(s16 zi = -cloud_radius_i; zi < cloud_radius_i; zi++) {
u32 i = (zi+cloud_radius_i)*cloud_radius_i*2 + xi+cloud_radius_i; u32 si = (zi + cloud_radius_i) * cloud_radius_i * 2 + cloud_radius_i;
for(s16 xi = -cloud_radius_i; xi < cloud_radius_i; xi++) {
u32 i = si + xi;
v2s16 p_in_noise_i( v2s16 p_in_noise_i(
xi + center_of_drawing_in_noise_i.X, xi + center_of_drawing_in_noise_i.X,
zi + center_of_drawing_in_noise_i.Y zi + center_of_drawing_in_noise_i.Y
); );
#if 0
double noise = noise2d_perlin_abs(
(float)p_in_noise_i.X*cloud_size/BS/200,
(float)p_in_noise_i.Y*cloud_size/BS/200,
m_seed, 3, 0.4);
grid[i] = (noise >= 0.80);
#endif
#if 1
double noise = noise2d_perlin( double noise = noise2d_perlin(
(float)p_in_noise_i.X*cloud_size/BS/200, (float)p_in_noise_i.X * cloud_size_noise,
(float)p_in_noise_i.Y*cloud_size/BS/200, (float)p_in_noise_i.Y * cloud_size_noise,
m_seed, 3, 0.5); m_seed, 3, 0.5);
grid[i] = (noise >= 0.4); grid[i] = (noise >= 0.4);
#endif }
} }
#define GETINDEX(x, z, radius) (((z)+(radius))*(radius)*2 + (x)+(radius)) #define GETINDEX(x, z, radius) (((z)+(radius))*(radius)*2 + (x)+(radius))