Mgfractal: Move julia set selection into formula parameter

Improve default parameters
Update and improve documentation
Unhide mapgen, but is still unstable
This commit is contained in:
paramat 2015-11-21 20:22:45 +00:00
parent a4e3ed0136
commit c24f3b0a65
5 changed files with 65 additions and 50 deletions

@ -970,29 +970,33 @@ mgflat_np_cave2 (Mapgen flat cave2 noise parameters) noise_params 0, 12, (128, 1
[***Mapgen fractal] [***Mapgen fractal]
# Map generation attributes specific to Mapgen fractal. # Choice of 8 4-dimensional fractals.
# The 'julia' flag results in the corresponding julia set being generated. # 1 = "Roundy" mandelbrot set.
# Flags that are not specified in the flag string are not modified from the default. # 2 = "Roundy" julia set.
# Flags starting with "no" are used to explicitly disable them. # 3 = "Squarry" mandelbrot set.
mgfractal_spflags (Mapgen fractal flags) flags nojulia julia,nojulia # 4 = "Squarry" julia set.
# 5 = "Mandy Cousin" mandelbrot set.
# Choice of 4 mandelbrot set variations. # 6 = "Mandy Cousin" julia set.
# 1 = 4D "Roundy" mandelbrot set, 2 = 4D "Squarry" mandelbrot set, # 7 = "Variation" mandelbrot set.
# 3 = 4D "Mandy Cousin" mandelbrot set, 4 = 4D mandelbrot set variation. # 8 = "Variation" julia set.
mgfractal_formula (Mapgen fractal formula) int 1 1 4 mgfractal_formula (Mapgen fractal formula) int 1 1 8
# Iterations of the recursive function. # Iterations of the recursive function.
# Controls scale of finest detail. # Controls scale of finest detail.
mgfractal_iterations (Mapgen fractal iterations) int 9 mgfractal_iterations (Mapgen fractal iterations) int 11
# Approximate (X,Y,Z) scales in nodes. # Approximate (X,Y,Z) scale of fractal in nodes.
mgfractal_scale (Mapgen fractal scale) v3f (1024.0, 256.0, 1024.0) mgfractal_scale (Mapgen fractal scale) v3f (4096.0, 1024.0, 4096.0)
# (X,Y,Z) offsets from world centre. # (X,Y,Z) offset of fractal from world centre.
# Range roughly -2 to 2, multiply by 'scale' for offsets in nodes. # Used to move a suitable spawn area of low land close to (0, 0).
mgfractal_offset (Mapgen fractal offset) v3f (1.75, 0.0, 0.0) # The default is suitable for mandelbrot sets, it needs to be edited for julia sets,
# do this by greatly reducing 'scale' and setting 'offset' initially to (0, 0, 0).
# Range roughly -2 to 2. Multiply by 'scale' for offset in nodes.
mgfractal_offset (Mapgen fractal offset) v3f (1.79, 0.0, 0.0)
# W co-ordinate of the generated 3D slice of the 4D shape. # W co-ordinate of the generated 3D slice of the 4D shape.
# Alters the generated 3D shape.
# Range roughly -2 to 2. # Range roughly -2 to 2.
mgfractal_slice_w (Mapgen fractal slice w) float 0.0 mgfractal_slice_w (Mapgen fractal slice w) float 0.0

@ -1234,44 +1234,59 @@
#### Mapgen fractal #### Mapgen fractal
# Map generation attributes specific to Mapgen fractal. # Choice of 8 4-dimensional fractals.
# The 'julia' flag results in the corresponding julia set being generated. # 1 = "Roundy" mandelbrot set.
# Flags that are not specified in the flag string are not modified from the default. # 2 = "Roundy" julia set.
# Flags starting with "no" are used to explicitly disable them. # 3 = "Squarry" mandelbrot set.
# type: flags possible values: julia, nojulia # 4 = "Squarry" julia set.
# mgfractal_spflags = nojulia # 5 = "Mandy Cousin" mandelbrot set.
# 6 = "Mandy Cousin" julia set.
# Choice of 4 mandelbrot set variations. # 7 = "Variation" mandelbrot set.
# 1 = 4D "Roundy" mandelbrot set, 2 = 4D "Squarry" mandelbrot set, # 8 = "Variation" julia set.
# 3 = 4D "Mandy Cousin" mandelbrot set, 4 = 4D mandelbrot set variation.
# type: int # type: int
# mgfractal_formula = 1 # mgfractal_formula = 1
# Iterations of the recursive function. # Iterations of the recursive function.
# Controls scale of finest detail. # Controls scale of finest detail.
# type: int # type: int
# mgfractal_iterations = 9 # mgfractal_iterations = 11
# Approximate (X,Y,Z) scales in nodes. # Approximate (X,Y,Z) scale of fractal in nodes.
# type: v3f # type: v3f
# mgfractal_scale = (1024.0, 256.0, 1024.0) # mgfractal_scale = (4096.0, 1024.0, 4096.0)
# (X,Y,Z) offsets from world centre. # (X,Y,Z) offset of fractal from world centre.
# Range roughly -2 to 2, multiply by 'scale' for offsets in nodes. # Used to move a suitable spawn area of low land close to (0, 0).
# The default is suitable for mandelbrot sets, it needs to be edited for julia sets,
# do this by greatly reducing 'scale' and setting 'offset' initially to (0, 0, 0).
# Range roughly -2 to 2. Multiply by 'scale' for offset in nodes.
# type: v3f # type: v3f
# mgfractal_offset = (1.75, 0.0, 0.0) # mgfractal_offset = (1.79, 0.0, 0.0)
# W co-ordinate of the generated 3D slice of the 4D shape. # W co-ordinate of the generated 3D slice of the 4D shape.
# Alters the generated 3D shape.
# Range roughly -2 to 2. # Range roughly -2 to 2.
# type: float # type: float
# mgfractal_slice_w = 0.0 # mgfractal_slice_w = 0.0
# Julia set only: 4 values determining the 4D shape. # Julia set only: X value determining the 4D shape.
# Range roughly -2 to 2. # Range roughly -2 to 2.
# type: float # type: float
# mgfractal_julia_x = 0.33 # mgfractal_julia_x = 0.33
# Julia set only: Y value determining the 4D shape.
# Range roughly -2 to 2.
# type: float
# mgfractal_julia_y = 0.33 # mgfractal_julia_y = 0.33
# Julia set only: Z value determining the 4D shape.
# Range roughly -2 to 2.
# type: float
# mgfractal_julia_z = 0.33 # mgfractal_julia_z = 0.33
# Julia set only: W value determining the 4D shape.
# Range roughly -2 to 2.
# type: float
# mgfractal_julia_w = 0.33 # mgfractal_julia_w = 0.33
# type: noise_params # type: noise_params

@ -107,7 +107,7 @@ MapgenDesc g_reg_mapgens[] = {
{"v6", new MapgenFactoryV6, true}, {"v6", new MapgenFactoryV6, true},
{"v7", new MapgenFactoryV7, true}, {"v7", new MapgenFactoryV7, true},
{"flat", new MapgenFactoryFlat, false}, {"flat", new MapgenFactoryFlat, false},
{"fractal", new MapgenFactoryFractal, false}, {"fractal", new MapgenFactoryFractal, true},
{"singlenode", new MapgenFactorySinglenode, false}, {"singlenode", new MapgenFactorySinglenode, false},
}; };

@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_sao.h" #include "content_sao.h"
#include "nodedef.h" #include "nodedef.h"
#include "voxelalgorithms.h" #include "voxelalgorithms.h"
#include "profiler.h" // For TimeTaker //#include "profiler.h" // For TimeTaker
#include "settings.h" // For g_settings #include "settings.h" // For g_settings
#include "emerge.h" #include "emerge.h"
#include "dungeongen.h" #include "dungeongen.h"
@ -41,7 +41,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
FlagDesc flagdesc_mapgen_fractal[] = { FlagDesc flagdesc_mapgen_fractal[] = {
{"julia", MGFRACTAL_JULIA},
{NULL, 0} {NULL, 0}
}; };
@ -143,9 +142,9 @@ MapgenFractalParams::MapgenFractalParams()
spflags = 0; spflags = 0;
formula = 1; formula = 1;
iterations = 9; iterations = 11;
scale = v3f(1024.0, 256.0, 1024.0); scale = v3f(4096.0, 1024.0, 4096.0);
offset = v3f(1.75, 0.0, 0.0); offset = v3f(1.79, 0.0, 0.0);
slice_w = 0.0; slice_w = 0.0;
julia_x = 0.33; julia_x = 0.33;
@ -236,7 +235,7 @@ void MapgenFractal::makeChunk(BlockMakeData *data)
this->generating = true; this->generating = true;
this->vm = data->vmanip; this->vm = data->vmanip;
this->ndef = data->nodedef; this->ndef = data->nodedef;
TimeTaker t("makeChunk"); //TimeTaker t("makeChunk");
v3s16 blockpos_min = data->blockpos_min; v3s16 blockpos_min = data->blockpos_min;
v3s16 blockpos_max = data->blockpos_max; v3s16 blockpos_max = data->blockpos_max;
@ -319,7 +318,7 @@ void MapgenFractal::makeChunk(BlockMakeData *data)
// Sprinkle some dust on top after everything else was generated // Sprinkle some dust on top after everything else was generated
dustTopNodes(); dustTopNodes();
printf("makeChunk: %dms\n", t.stop()); //printf("makeChunk: %dms\n", t.stop());
updateLiquid(&data->transforming_liquid, full_node_min, full_node_max); updateLiquid(&data->transforming_liquid, full_node_min, full_node_max);
@ -369,7 +368,7 @@ bool MapgenFractal::getFractalAtPoint(s16 x, s16 y, s16 z)
{ {
float cx, cy, cz, cw, ox, oy, oz, ow; float cx, cy, cz, cw, ox, oy, oz, ow;
if (spflags & MGFRACTAL_JULIA) { // Julia set if (formula % 2 == 0) { // Julia sets, formula = 2, 4, 6, 8
cx = julia_x; cx = julia_x;
cy = julia_y; cy = julia_y;
cz = julia_z; cz = julia_z;
@ -378,7 +377,7 @@ bool MapgenFractal::getFractalAtPoint(s16 x, s16 y, s16 z)
oy = (float)y / scale.Y - offset.Y; oy = (float)y / scale.Y - offset.Y;
oz = (float)z / scale.Z - offset.Z; oz = (float)z / scale.Z - offset.Z;
ow = slice_w; ow = slice_w;
} else { // Mandelbrot set } else { // Mandelbrot sets, formula = 1, 3, 5, 7
cx = (float)x / scale.X - offset.X; cx = (float)x / scale.X - offset.X;
cy = (float)y / scale.Y - offset.Y; cy = (float)y / scale.Y - offset.Y;
cz = (float)z / scale.Z - offset.Z; cz = (float)z / scale.Z - offset.Z;
@ -395,22 +394,22 @@ bool MapgenFractal::getFractalAtPoint(s16 x, s16 y, s16 z)
float nz = 0.0f; float nz = 0.0f;
float nw = 0.0f; float nw = 0.0f;
if (formula == 1) { // 4D "Roundy" Mandelbrot Set if (formula == 1 || formula == 2) { // 4D "Roundy" Mandelbrot/Julia Set
nx = ox * ox - oy * oy - oz * oz - ow * ow + cx; nx = ox * ox - oy * oy - oz * oz - ow * ow + cx;
ny = 2.0f * (ox * oy + oz * ow) + cy; ny = 2.0f * (ox * oy + oz * ow) + cy;
nz = 2.0f * (ox * oz + oy * ow) + cz; nz = 2.0f * (ox * oz + oy * ow) + cz;
nw = 2.0f * (ox * ow + oy * oz) + cw; nw = 2.0f * (ox * ow + oy * oz) + cw;
} else if (formula == 2) { // 4D "Squarry" Mandelbrot Set } else if (formula == 3 || formula == 4) { // 4D "Squarry" Mandelbrot/Julia Set
nx = ox * ox - oy * oy - oz * oz - ow * ow + cx; nx = ox * ox - oy * oy - oz * oz - ow * ow + cx;
ny = 2.0f * (ox * oy + oz * ow) + cy; ny = 2.0f * (ox * oy + oz * ow) + cy;
nz = 2.0f * (ox * oz + oy * ow) + cz; nz = 2.0f * (ox * oz + oy * ow) + cz;
nw = 2.0f * (ox * ow - oy * oz) + cw; nw = 2.0f * (ox * ow - oy * oz) + cw;
} else if (formula == 3) { // 4D "Mandy Cousin" Mandelbrot Set } else if (formula == 5 || formula == 6) { // 4D "Mandy Cousin" Mandelbrot/Julia Set
nx = ox * ox - oy * oy - oz * oz + ow * ow + cx; nx = ox * ox - oy * oy - oz * oz + ow * ow + cx;
ny = 2.0f * (ox * oy + oz * ow) + cy; ny = 2.0f * (ox * oy + oz * ow) + cy;
nz = 2.0f * (ox * oz + oy * ow) + cz; nz = 2.0f * (ox * oz + oy * ow) + cz;
nw = 2.0f * (ox * ow + oy * oz) + cw; nw = 2.0f * (ox * ow + oy * oz) + cw;
} else if (formula == 4) { // 4D Mandelbrot Set Variation } else if (formula == 7 || formula == 8) { // 4D "Variation" Mandelbrot/Julia Set
nx = ox * ox - oy * oy - oz * oz - ow * ow + cx; nx = ox * ox - oy * oy - oz * oz - ow * ow + cx;
ny = 2.0f * (ox * oy + oz * ow) + cy; ny = 2.0f * (ox * oy + oz * ow) + cy;
nz = 2.0f * (ox * oz - oy * ow) + cz; nz = 2.0f * (ox * oz - oy * ow) + cz;

@ -25,9 +25,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define MGFRACTAL_LARGE_CAVE_DEPTH -33 #define MGFRACTAL_LARGE_CAVE_DEPTH -33
/////////////////// Mapgen Fractal flags
#define MGFRACTAL_JULIA 0x01
class BiomeManager; class BiomeManager;
extern FlagDesc flagdesc_mapgen_fractal[]; extern FlagDesc flagdesc_mapgen_fractal[];