@@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
28
28
#include " content_sao.h"
29
29
#include " nodedef.h"
30
30
#include " voxelalgorithms.h"
31
- // #include "profiler.h" // For TimeTaker
31
+ #include " profiler.h" // For TimeTaker
32
32
#include " settings.h" // For g_settings
33
33
#include " emerge.h"
34
34
#include " dungeongen.h"
@@ -67,14 +67,15 @@ MapgenFractal::MapgenFractal(int mapgenid, MapgenParams *params, EmergeManager *
67
67
MapgenFractalParams *sp = (MapgenFractalParams *)params->sparams ;
68
68
this ->spflags = sp->spflags ;
69
69
70
- this ->iterations = sp->iterations ;
71
- this ->scale = sp->scale ;
70
+ this ->m_iterations = sp->m_iterations ;
71
+ this ->m_scale = sp->m_scale ;
72
+ this ->m_offset = sp->m_offset ;
73
+ this ->m_slice_w = sp->m_slice_w ;
72
74
73
- this ->moffset = sp->moffset ;
74
- this ->mslice_w = sp->mslice_w ;
75
-
76
- this ->joffset = sp->joffset ;
77
- this ->jslice_w = sp->jslice_w ;
75
+ this ->j_iterations = sp->j_iterations ;
76
+ this ->j_scale = sp->j_scale ;
77
+ this ->j_offset = sp->j_offset ;
78
+ this ->j_slice_w = sp->j_slice_w ;
78
79
this ->julia_x = sp->julia_x ;
79
80
this ->julia_y = sp->julia_y ;
80
81
this ->julia_z = sp->julia_z ;
@@ -143,14 +144,15 @@ MapgenFractalParams::MapgenFractalParams()
143
144
{
144
145
spflags = 0 ;
145
146
146
- iterations = 9 ;
147
- scale = v3f (1024.0 , 256.0 , 1024.0 );
148
-
149
- moffset = v3f (1.75 , 0.0 , 0.0 ); // Mandelbrot set only
150
- mslice_w = 0.0 ;
147
+ m_iterations = 9 ; // Mandelbrot set only
148
+ m_scale = v3f (1024.0 , 256.0 , 1024.0 );
149
+ m_offset = v3f (1.75 , 0.0 , 0.0 );
150
+ m_slice_w = 0.0 ;
151
151
152
- joffset = v3f (0.0 , 1.0 , 0.0 ); // Julia set only
153
- jslice_w = 0.0 ;
152
+ j_iterations = 9 ; // Julia set only
153
+ j_scale = v3f (2048.0 , 512.0 , 2048.0 );
154
+ j_offset = v3f (0.0 , 1.0 , 0.0 );
155
+ j_slice_w = 0.0 ;
154
156
julia_x = 0.33 ;
155
157
julia_y = 0.33 ;
156
158
julia_z = 0.33 ;
@@ -166,14 +168,15 @@ void MapgenFractalParams::readParams(const Settings *settings)
166
168
{
167
169
settings->getFlagStrNoEx (" mgfractal_spflags" , spflags, flagdesc_mapgen_fractal);
168
170
169
- settings->getU16NoEx (" mgfractal_iterations" , iterations);
170
- settings->getV3FNoEx (" mgfractal_scale" , scale);
171
-
172
- settings->getV3FNoEx (" mgfractal_moffset" , moffset);
173
- settings->getFloatNoEx (" mgfractal_mslice_w" , mslice_w);
171
+ settings->getU16NoEx (" mgfractal_m_iterations" , m_iterations);
172
+ settings->getV3FNoEx (" mgfractal_m_scale" , m_scale);
173
+ settings->getV3FNoEx (" mgfractal_m_offset" , m_offset);
174
+ settings->getFloatNoEx (" mgfractal_m_slice_w" , m_slice_w);
174
175
175
- settings->getV3FNoEx (" mgfractal_joffset" , joffset);
176
- settings->getFloatNoEx (" mgfractal_jslice_w" , jslice_w);
176
+ settings->getU16NoEx (" mgfractal_j_iterations" , j_iterations);
177
+ settings->getV3FNoEx (" mgfractal_j_scale" , j_scale);
178
+ settings->getV3FNoEx (" mgfractal_j_offset" , j_offset);
179
+ settings->getFloatNoEx (" mgfractal_j_slice_w" , j_slice_w);
177
180
settings->getFloatNoEx (" mgfractal_julia_x" , julia_x);
178
181
settings->getFloatNoEx (" mgfractal_julia_y" , julia_y);
179
182
settings->getFloatNoEx (" mgfractal_julia_z" , julia_z);
@@ -189,14 +192,15 @@ void MapgenFractalParams::writeParams(Settings *settings) const
189
192
{
190
193
settings->setFlagStr (" mgfractal_spflags" , spflags, flagdesc_mapgen_fractal, U32_MAX);
191
194
192
- settings->setU16 (" mgfractal_iterations" , iterations);
193
- settings->setV3F (" mgfractal_scale" , scale);
195
+ settings->setU16 (" mgfractal_m_iterations" , m_iterations);
196
+ settings->setV3F (" mgfractal_m_scale" , m_scale);
197
+ settings->setV3F (" mgfractal_m_offset" , m_offset);
198
+ settings->setFloat (" mgfractal_m_slice_w" , m_slice_w);
194
199
195
- settings->setV3F (" mgfractal_moffset" , moffset);
196
- settings->setFloat (" mgfractal_mslice_w" , mslice_w);
197
-
198
- settings->setV3F (" mgfractal_joffset" , joffset);
199
- settings->setFloat (" mgfractal_jslice_w" , jslice_w);
200
+ settings->setU16 (" mgfractal_j_iterations" , j_iterations);
201
+ settings->setV3F (" mgfractal_j_scale" , j_scale);
202
+ settings->setV3F (" mgfractal_j_offset" , j_offset);
203
+ settings->setFloat (" mgfractal_j_slice_w" , j_slice_w);
200
204
settings->setFloat (" mgfractal_julia_x" , julia_x);
201
205
settings->setFloat (" mgfractal_julia_y" , julia_y);
202
206
settings->setFloat (" mgfractal_julia_z" , julia_z);
@@ -240,7 +244,7 @@ void MapgenFractal::makeChunk(BlockMakeData *data)
240
244
this ->generating = true ;
241
245
this ->vm = data->vmanip ;
242
246
this ->ndef = data->nodedef ;
243
- // TimeTaker t("makeChunk");
247
+ TimeTaker t (" makeChunk" );
244
248
245
249
v3s16 blockpos_min = data->blockpos_min ;
246
250
v3s16 blockpos_max = data->blockpos_max ;
@@ -322,7 +326,7 @@ void MapgenFractal::makeChunk(BlockMakeData *data)
322
326
// Sprinkle some dust on top after everything else was generated
323
327
dustTopNodes ();
324
328
325
- // printf("makeChunk: %dms\n", t.stop());
329
+ printf (" makeChunk: %dms\n " , t.stop ());
326
330
327
331
updateLiquid (&data->transforming_liquid , full_node_min, full_node_max);
328
332
@@ -376,21 +380,23 @@ bool MapgenFractal::getFractalAtPoint(s16 x, s16 y, s16 z)
376
380
cy = julia_y;
377
381
cz = julia_z;
378
382
cw = julia_w;
379
- ox = (float )x / scale .X - joffset .X ;
380
- oy = (float )y / scale .Y - joffset .Y ;
381
- oz = (float )z / scale .Z - joffset .Z ;
382
- ow = jslice_w ;
383
+ ox = (float )x / j_scale .X - j_offset .X ;
384
+ oy = (float )y / j_scale .Y - j_offset .Y ;
385
+ oz = (float )z / j_scale .Z - j_offset .Z ;
386
+ ow = j_slice_w ;
383
387
} else { // Mandelbrot set
384
- cx = (float )x / scale .X - moffset .X ;
385
- cy = (float )y / scale .Y - moffset .Y ;
386
- cz = (float )z / scale .Z - moffset .Z ;
387
- cw = mslice_w ;
388
+ cx = (float )x / m_scale .X - m_offset .X ;
389
+ cy = (float )y / m_scale .Y - m_offset .Y ;
390
+ cz = (float )z / m_scale .Z - m_offset .Z ;
391
+ cw = m_slice_w ;
388
392
ox = 0 .0f ;
389
393
oy = 0 .0f ;
390
394
oz = 0 .0f ;
391
395
ow = 0 .0f ;
392
396
}
393
397
398
+ u16 iterations = spflags & MGFRACTAL_JULIA ? j_iterations : m_iterations;
399
+
394
400
for (u16 iter = 0 ; iter < iterations; iter++) {
395
401
// 4D "Roundy" Mandelbrot set
396
402
float nx = ox * ox - oy * oy - oz * oz - ow * ow + cx;
0 commit comments