diff options
-rw-r--r-- | source/blender/makesdna/DNA_texture_types.h | 16 | ||||
-rw-r--r-- | source/blender/render/intern/source/texture.c | 98 | ||||
-rw-r--r-- | source/blender/src/buttons_shading.c | 14 | ||||
-rw-r--r-- | source/blender/src/editmesh_add.c | 1 |
4 files changed, 102 insertions, 27 deletions
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index cd6a0b8bbdb..14617018910 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -243,6 +243,22 @@ typedef struct Tex { #define TEX_NOISESOFT 0 #define TEX_NOISEPERL 1 +/* tex->noisebasis2 in texture.c - wood waveforms */ +#define TEX_SIN 0 +#define TEX_SAW 1 +#define TEX_TRI 2 + +/* tex->stype in texture.c - wood types */ +#define TEX_BAND 0 +#define TEX_RING 1 +#define TEX_BANDNOISE 2 +#define TEX_RINGNOISE 3 + +/* tex->stype in texture.c - marble types */ +#define TEX_SOFT 0 +#define TEX_SHARP 1 +#define TEX_SHARPER 2 + /* wrap */ #define MTEX_FLAT 0 #define MTEX_CUBE 1 diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index 97b64d0141a..d6847a3f70d 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -354,30 +354,71 @@ static int clouds(Tex *tex, float *texvec, TexResult *texres) } +/* creates a sine wave */ +static float tex_sin(float a) +{ + a = 0.5 + 0.5*sin(a); + + return a; +} + +/* creates a saw wave */ +static float tex_saw(float a) +{ + const float b = 2*M_PI; + + int n = (int)(a / b); + a -= n*b; + if (a < 0) a += b; + return a / b; +} + +/* creates a triangle wave */ +static float tex_tri(float a) +{ + const float b = 2*M_PI; + const float rmax = 1.0; + + a = rmax - 2.0*fabs(floor((a*(1.0/b))+0.5) - (a*(1.0/b))); + + return a; +} + /* computes basic wood intensity value at x,y,z */ static float wood_int(Tex *tex, float x, float y, float z) { - float wi=0; + float wi=0; + short wf = tex->noisebasis2; /* wave form: TEX_SIN=0, TEX_SAW=1, TEX_TRI=2 */ + short wt = tex->stype; /* wood type: TEX_BAND=0, TEX_RING=1, TEX_BANDNOISE=2, TEX_RINGNOISE=3 */ - if (tex->stype==0) - wi = 0.5 + 0.5*sin((x + y + z)*10.0); - else if (tex->stype==1) - wi = 0.5 + 0.5*sin(sqrt(x*x + y*y + z*z)*20.0); - else if (tex->stype==2) { - wi = BLI_gNoise(tex->noisesize, x, y, z, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); - wi = 0.5 + 0.5*sin(tex->turbul*wi + (x + y + z)*10.0); + float (*waveform[3])(float); /* create array of pointers to waveform functions */ + waveform[0] = tex_sin; /* assign address of tex_sin() function to pointer array */ + waveform[1] = tex_saw; + waveform[2] = tex_tri; + + if ((wf>TEX_TRI) || (wf<TEX_SIN)) wf=0; /* check to be sure noisebasis2 is initialized ahead of time */ + + if (wt==TEX_BAND) { + wi = waveform[wf]((x + y + z)*10.0); } - else if (tex->stype==3) { - wi = BLI_gNoise(tex->noisesize, x, y, z, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); - wi = 0.5 + 0.5*sin(tex->turbul*wi + (sqrt(x*x + y*y + z*z))*20.0); + else if (wt==TEX_RING) { + wi = waveform[wf](sqrt(x*x + y*y + z*z)*20.0); } - + else if (wt==TEX_BANDNOISE) { + wi = tex->turbul*BLI_gNoise(tex->noisesize, x, y, z, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); + wi = waveform[wf]((x + y + z)*10.0 + wi); + } + else if (wt==TEX_RINGNOISE) { + wi = tex->turbul*BLI_gNoise(tex->noisesize, x, y, z, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); + wi = waveform[wf](sqrt(x*x + y*y + z*z)*20.0 + wi); + } + return wi; } static int wood(Tex *tex, float *texvec, TexResult *texres) { - int rv=0; /* return value, int:0, col:1, nor:2, everything:3 */ + int rv=TEX_INT; /* return value, int:0, col:1, nor:2, everything:3 */ texres->tin = wood_int(tex, texvec[0], texvec[1], texvec[2]); if (texres->nor!=NULL) { @@ -387,7 +428,7 @@ static int wood(Tex *tex, float *texvec, TexResult *texres) texres->nor[2] = wood_int(tex, texvec[0], texvec[1], texvec[2] + tex->nabla); tex_normal_derivate(tex, texres); - rv += 2; + rv = TEX_NOR; } BRICONT; @@ -399,13 +440,28 @@ static int wood(Tex *tex, float *texvec, TexResult *texres) static float marble_int(Tex *tex, float x, float y, float z) { float n, mi; - + short wf = tex->noisebasis2; /* wave form: TEX_SIN=0, TEX_SAW=1, TEX_TRI=2 */ + short mt = tex->stype; /* marble type: TEX_SOFT=0, TEX_SHARP=1,TEX_SHAPER=2 */ + + float (*waveform[3])(float); /* create array of pointers to waveform functions */ + waveform[0] = tex_sin; /* assign address of tex_sin() function to pointer array */ + waveform[1] = tex_saw; + waveform[2] = tex_tri; + + if ((wf>TEX_TRI) || (wf<TEX_SIN)) wf=0; /* check to be sure noisebasis2 isn't initialized ahead of time */ + n = 5.0 * (x + y + z); + + mi = n + tex->turbul * BLI_gTurbulence(tex->noisesize, x, y, z, tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); - mi = 0.5 + 0.5 * sin(n + tex->turbul * BLI_gTurbulence(tex->noisesize, x, y, z, tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis)); - if (tex->stype>=1) { - mi = sqrt(mi); - if (tex->stype==2) mi = sqrt(mi); + if (mt>=TEX_SOFT) { /* TEX_SOFT always true */ + mi = waveform[wf](mi); + if (mt==TEX_SHARP) { + mi = sqrt(mi); + } + else if (mt==TEX_SHARPER) { + mi = sqrt(sqrt(mi)); + } } return mi; @@ -413,7 +469,7 @@ static float marble_int(Tex *tex, float x, float y, float z) static int marble(Tex *tex, float *texvec, TexResult *texres) { - int rv=0; /* return value, int:0, col:1, nor:2, everything:3 */ + int rv=TEX_INT; /* return value, int:0, col:1, nor:2, everything:3 */ texres->tin = marble_int(tex, texvec[0], texvec[1], texvec[2]); @@ -425,7 +481,7 @@ static int marble(Tex *tex, float *texvec, TexResult *texres) tex_normal_derivate(tex, texres); - rv += 2; + rv = TEX_NOR; } BRICONT; diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c index 9b8c10b39ff..d184178fd47 100644 --- a/source/blender/src/buttons_shading.c +++ b/source/blender/src/buttons_shading.c @@ -894,12 +894,12 @@ static void texture_panel_wood(Tex *tex) uiDefButF(block, NUM, B_TEXPRV, "NoiseSize :", 10, 130, 150, 19, &tex->noisesize, 0.0001, 2.0, 10, 0, "Sets scaling for noise input"); uiDefButF(block, NUM, B_TEXPRV, "Turbulence:", 160, 130, 150, 19, &tex->turbul, 0.0, 200.0, 10, 0, "Sets the turbulence of the bandnoise and ringnoise types"); uiBlockEndAlign(block); - + /* newnoise: noisebasis menu */ uiDefBut(block, LABEL, 0, "Noise Basis", 10, 30, 150, 19, 0, 0.0, 0.0, 0, 0, ""); uiDefButS(block, MENU, B_TEXPRV, noisebasis_menu(), 10, 10, 150, 19, &tex->noisebasis, 0,0,0,0, "Sets the noise basis used for turbulence"); uiDefButF(block, NUM, B_NOP, "Nabla: ", 160, 10, 150, 19, &tex->nabla, 0.001, 0.1, 1, 0, "Defines size of derivative offset used for calculating normal"); - + } static void texture_panel_stucci(Tex *tex) @@ -938,15 +938,19 @@ static void texture_panel_marble(Tex *tex) block= uiNewBlock(&curarea->uiblocks, "texture_panel_marble", UI_EMBOSS, UI_HELV, curarea->win); if(uiNewPanel(curarea, block, "Marble", "Texture", 640, 0, 318, 204)==0) return; uiSetButLock(tex->id.lib!=0, "Can't edit library data"); - + uiBlockBeginAlign(block); uiDefButS(block, ROW, B_TEXPRV, "Soft", 10, 180, 100, 18, &tex->stype, 2.0, 0.0, 0, 0, "Uses soft marble"); uiDefButS(block, ROW, B_TEXPRV, "Sharp", 110, 180, 100, 18, &tex->stype, 2.0, 1.0, 0, 0, "Uses more clearly defined marble"); uiDefButS(block, ROW, B_TEXPRV, "Sharper", 210, 180, 100, 18, &tex->stype, 2.0, 2.0, 0, 0, "Uses very clearly defined marble"); - + uiDefButS(block, ROW, B_TEXPRV, "Soft noise", 10, 160, 150, 19, &tex->noisetype, 12.0, 0.0, 0, 0, "Generates soft noise"); uiDefButS(block, ROW, B_TEXPRV, "Hard noise", 160, 160, 150, 19, &tex->noisetype, 12.0, 1.0, 0, 0, "Generates hard noise"); + uiDefButS(block, ROW, B_TEXPRV, "Sin", 10, 140, 100, 18, &tex->noisebasis2, 8.0, 0.0, 0, 0, "Uses soft marble"); + uiDefButS(block, ROW, B_TEXPRV, "Saw", 110, 140, 100, 18, &tex->noisebasis2, 8.0, 1.0, 0, 0, "Uses more clearly defined marble"); + uiDefButS(block, ROW, B_TEXPRV, "Tri", 210, 140, 100, 18, &tex->noisebasis2, 8.0, 2.0, 0, 0, "Uses very clearly defined marble"); + uiBlockBeginAlign(block); uiDefButF(block, NUM, B_TEXPRV, "NoiseSize :", 10, 110, 150, 19, &tex->noisesize, 0.0001, 2.0, 10, 0, "Sets scaling for noise input"); uiDefButS(block, NUM, B_TEXPRV, "NoiseDepth:", 10, 90, 150, 19, &tex->noisedepth, 0.0, 6.0, 0, 0, "Sets the depth of the marble calculation"); @@ -957,7 +961,7 @@ static void texture_panel_marble(Tex *tex) uiDefBut(block, LABEL, 0, "Noise Basis", 10, 30, 150, 19, 0, 0.0, 0.0, 0, 0, ""); uiDefButS(block, MENU, B_TEXPRV, noisebasis_menu(), 10, 10, 150, 19, &tex->noisebasis, 0,0,0,0, "Sets the noise basis used for turbulence"); uiDefButF(block, NUM, B_NOP, "Nabla: ", 160, 10, 150, 19, &tex->nabla, 0.001, 0.1, 1, 0, "Defines size of derivative offset used for calculating normal"); - + } static void texture_panel_clouds(Tex *tex) diff --git a/source/blender/src/editmesh_add.c b/source/blender/src/editmesh_add.c index b285b80da15..5952f8d96cf 100644 --- a/source/blender/src/editmesh_add.c +++ b/source/blender/src/editmesh_add.c @@ -535,7 +535,6 @@ void add_primitiveMesh(int type) fill= 0; if(newob) rename_id((ID *)G.obedit, "Circle"); if(newob) rename_id((ID *)me, "Circle"); - if(G.scene->selectmode==SCE_SELECT_FACE) notice("Circle is not visible in face mode"); undostr="Add Circle"; break; case 5: /* cylinder */ |