diff options
author | Ton Roosendaal <ton@blender.org> | 2005-12-03 15:55:35 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-12-03 15:55:35 +0300 |
commit | 8cb14867b0ad104ebe1f6fd086656dd12ada5758 (patch) | |
tree | 26e38fe819a0bf1715d73347939a4361e9c0eee6 /source | |
parent | 8a84a957f2b0cc95608cda81c2aeb655f1732788 (diff) |
Added Copy/Paste 'mapping' options for World/Lamp buttons.
Also: moved render defines from scene to render module itself.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/include/butspace.h | 5 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 27 | ||||
-rw-r--r-- | source/blender/render/extern/include/render_types.h | 32 | ||||
-rw-r--r-- | source/blender/render/intern/source/rendercore.c | 37 | ||||
-rw-r--r-- | source/blender/render/intern/source/renderdatabase.c | 29 | ||||
-rw-r--r-- | source/blender/src/buttons_shading.c | 88 |
6 files changed, 161 insertions, 57 deletions
diff --git a/source/blender/include/butspace.h b/source/blender/include/butspace.h index 33a074ba46d..e354b4b74d4 100644 --- a/source/blender/include/butspace.h +++ b/source/blender/include/butspace.h @@ -155,6 +155,8 @@ void test_idbutton_cb(void *namev, void *arg2_unused); #define B_SBUFF 1104 #define B_SHADBUF 1105 #define B_SHADRAY 1106 +#define B_LMTEXPASTE 1107 +#define B_LMTEXCOPY 1108 /* *********************** */ #define B_MATBUTS 1300 @@ -178,6 +180,7 @@ void test_idbutton_cb(void *namev, void *arg2_unused); /* yafray: material preset menu event */ #define B_MAT_YF_PRESET 1217 + /* *********************** */ #define B_TEXBUTS 1400 @@ -249,6 +252,8 @@ void test_idbutton_cb(void *namev, void *arg2_unused); #define B_TEXCLEARWORLD 1501 #define B_COLHOR 1502 #define B_COLZEN 1503 +#define B_WMTEXPASTE 1504 +#define B_WMTEXCOPY 1505 /* *********************** */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index fe54a631bdd..6323caeda6c 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -407,33 +407,6 @@ typedef struct Scene { #define R_RADHDR 21 #define R_TIFF 22 -/* **************** RENDER ********************* */ -/* mode flag is same as for renderdata */ -/* flag */ -#define R_ZTRA 1 -#define R_HALO 2 -#define R_SEC_FIELD 4 -#define R_LAMPHALO 8 -#define R_RENDERING 16 -#define R_ANIMRENDER 32 -#define R_REDRAW_PRV 64 - -/* vlakren->flag (vlak = face in dutch) char!!! */ -#define R_SMOOTH 1 -#define R_VISIBLE 2 - /* strand flag, means special handling */ -#define R_STRAND 4 -#define R_NOPUNOFLIP 8 -#define R_FULL_OSA 16 -#define R_FACE_SPLIT 32 - /* Tells render to divide face other way. */ -#define R_DIVIDE_24 64 - /* vertex normals are tangent or view-corrected vector, for hair strands */ -#define R_TANGENT 128 - -/* vertren->texofs (texcoordinate offset relative to vertren->orco */ -#define R_UVOFS3 1 - /* **************** SCENE ********************* */ #define RAD_PHASE_PATCHES 1 #define RAD_PHASE_FACES 2 diff --git a/source/blender/render/extern/include/render_types.h b/source/blender/render/extern/include/render_types.h index 3a09ba133ef..8118e72f24a 100644 --- a/source/blender/render/extern/include/render_types.h +++ b/source/blender/render/extern/include/render_types.h @@ -194,9 +194,9 @@ typedef struct VertRen float *orco; float *sticky; void *svert; /* smooth vert, only used during initrender */ - short clip, texofs; /* texofs= flag */ - float accum; /* accum for radio weighting, and for strand texco static particles */ + short clip; short flag; /* in use for clipping ztra parts */ + float accum; /* accum for radio weighting, and for strand texco static particles */ } VertRen; /* ------------------------------------------------------------------------- */ @@ -313,6 +313,34 @@ typedef struct LampRen struct MTex *mtex[MAX_MTEX]; } LampRen; +/* **************** defines ********************* */ + +/* mode flag is same as for renderdata */ +/* flag */ +#define R_ZTRA 1 +#define R_HALO 2 +#define R_SEC_FIELD 4 +#define R_LAMPHALO 8 +#define R_RENDERING 16 +#define R_ANIMRENDER 32 +#define R_REDRAW_PRV 64 + +/* vlakren->flag (vlak = face in dutch) char!!! */ +#define R_SMOOTH 1 +#define R_VISIBLE 2 +/* strand flag, means special handling */ +#define R_STRAND 4 +#define R_NOPUNOFLIP 8 +#define R_FULL_OSA 16 +#define R_FACE_SPLIT 32 +/* Tells render to divide face other way. */ +#define R_DIVIDE_24 64 +/* vertex normals are tangent or view-corrected vector, for hair strands */ +#define R_TANGENT 128 + + + + #endif /* RENDER_TYPES_H */ diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 26ac9b51af4..b1ee0908eef 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -113,10 +113,11 @@ void calc_view_vector(float *view, float x, float y) } } +#if 0 static void fogcolor(float *colf, float *rco, float *view) { - float alpha, stepsize, dist, hor[3], zen[3], vec[3], dview[3]; - float accum[4]={0.0f, 0.0f, 0.0f, 0.0f}, div=0.0f; + float alpha, stepsize, startdist, dist, hor[4], zen[3], vec[3], dview[3]; + float div=0.0f, distfac; hor[0]= R.wrld.horr; hor[1]= R.wrld.horg; hor[2]= R.wrld.horb; zen[0]= R.wrld.zenr; zen[1]= R.wrld.zeng; zen[2]= R.wrld.zenb; @@ -130,30 +131,29 @@ static void fogcolor(float *colf, float *rco, float *view) dview[0]= view[0]/(stepsize*div); dview[1]= view[1]/(stepsize*div); dview[2]= -stepsize; - -if(G.rt) printf("\n"); - for(dist= -rco[2]; dist>R.wrld.miststa; dist-= stepsize) { + + startdist= -rco[2] + BLI_frand(); + for(dist= startdist; dist>R.wrld.miststa; dist-= stepsize) { hor[0]= R.wrld.horr; hor[1]= R.wrld.horg; hor[2]= R.wrld.horb; alpha= 1.0f; do_sky_tex(vec, vec, NULL, hor, zen, &alpha); -if(G.rt) printf("dist %f ", dist); -if(G.rt) printvecf("vec", vec); - accum[3]= (dist-R.wrld.miststa)/R.wrld.mistdist; -if(G.rt) printf("accum %f\n", accum[3]); - accum[3]= hor[0]*accum[3]; + distfac= (dist-R.wrld.miststa)/R.wrld.mistdist; + + hor[3]= hor[0]*distfac*distfac; /* premul! */ - accum[0]= hor[0]*accum[3]; - accum[1]= hor[1]*accum[3]; - accum[2]= hor[2]*accum[3]; - addAlphaOverFloat(colf, accum); + alpha= hor[3]; + hor[0]= hor[0]*alpha; + hor[1]= hor[1]*alpha; + hor[2]= hor[2]*alpha; + addAlphaOverFloat(colf, hor); VECSUB(vec, vec, dview); - } - + } } +#endif float mistfactor(float zcor, float *co) /* dist en height, return alpha */ { @@ -2375,11 +2375,6 @@ void *shadepixel(float x, float y, int z, int facenr, int mask, float *col, floa } } - /* FOG */ - if(0) {//(R.wrld.mode & WO_MIST) && (shi.mat->mode & MA_NOMIST)==0 ) { - fogcolor(col, shi.co, shi.view); - } - /* MIST */ if((R.wrld.mode & WO_MIST) && (shi.mat->mode & MA_NOMIST)==0 ) { if(R.r.mode & R_ORTHO) diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index ee003964764..b2f7cdfca48 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -74,6 +74,35 @@ /* ------------------------------------------------------------------------- */ +#if 0 +/* proposal for more dynamic allocation of options for render vertices, so we dont + have to reserve this space inside vertices */ +typedef struct VertTableNode { + VertRen *vert; + float *rad; + float *sticky; + float *strand; + float *tangent; + float *stress; +} VertTableNode; + +#define RE_STICKY_ELEMS 3 +float *RE_vertren_get_sticky(VertRen *ver, int verify) +{ + float *sticky; + int a= ver->index>>8; + + sticky= R.blove[a].sticky; + if(sticky==NULL) { + if(verify) + sticky= R.blove[a].sticky= MEM_mallocN(RE_STICKY_ELEMS*sizeof(float), "sticky table"); + else + return NULL; + } + sticky+= (nr & 255)*RE_STICKY_ELEMS; +} +#endif + VertRen *RE_findOrAddVert(int nr) { VertRen *v, **temp; diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c index eac6964f187..73243750841 100644 --- a/source/blender/src/buttons_shading.c +++ b/source/blender/src/buttons_shading.c @@ -111,12 +111,9 @@ int vergcband(const void *, const void *); void save_env(char *); void drawcolorband(ColorBand *, float , float , float , float ); - -static MTex mtexcopybuf; static MTex emptytex; static int packdummy = 0; - static char *mapto_blendtype_pup(void) { static char string[1024]; @@ -1726,6 +1723,8 @@ static void radio_panel_render(Radio *rad) void do_worldbuts(unsigned short event) { + static short mtexcopied=0; + static MTex mtexcopybuf; World *wrld; MTex *mtex; @@ -1743,6 +1742,35 @@ void do_worldbuts(unsigned short event) BIF_preview_changed(G.buts); } break; + case B_WMTEXCOPY: + wrld= G.buts->lockpoin; + if(wrld && wrld->mtex[(int)wrld->texact] ) { + mtex= wrld->mtex[(int)wrld->texact]; + if(mtex->tex==0) { + error("No texture available"); + } + else { + memcpy(&mtexcopybuf, wrld->mtex[(int)wrld->texact], sizeof(MTex)); + mtexcopied= 1; + } + } + break; + case B_WMTEXPASTE: + wrld= G.buts->lockpoin; + if(wrld && mtexcopied && mtexcopybuf.tex) { + if(wrld->mtex[(int)wrld->texact]==0 ) + wrld->mtex[(int)wrld->texact]= MEM_mallocN(sizeof(MTex), "mtex"); + else if(wrld->mtex[(int)wrld->texact]->tex) + wrld->mtex[(int)wrld->texact]->tex->id.us--; + + memcpy(wrld->mtex[(int)wrld->texact], &mtexcopybuf, sizeof(MTex)); + + id_us_plus((ID *)mtexcopybuf.tex); + BIF_undo_push("Paste mapping settings"); + BIF_preview_changed(G.buts); + scrarea_queue_winredraw(curarea); + } + break; } } @@ -1841,7 +1869,7 @@ static void world_panel_texture(World *wrld) uiDefBut(block, TEX, B_IDNAME, "TE:", 100,160,200,19, id->name+2, 0.0, 18.0, 0, 0, "Displays name of the texture block: click to change"); sprintf(str, "%d", id->us); uiDefBut(block, BUT, 0, str, 196,140,21,19, 0, 0, 0, 0, 0, "Displays number of users of texture: click to make single user"); - uiDefIconBut(block, BUT, B_AUTOTEXNAME, ICON_AUTO, 279,140,21,19, 0, 0, 0, 0, 0, "Auto-assigns name to texture"); + uiDefIconBut(block, BUT, B_AUTOTEXNAME, ICON_AUTO, 220,140,21,19, 0, 0, 0, 0, 0, "Auto-assigns name to texture"); if(id->lib) { if(wrld->id.lib) uiDefIconBut(block, BUT, 0, ICON_DATALIB, 219,140,21,19, 0, 0, 0, 0, 0, ""); else uiDefIconBut(block, BUT, 0, ICON_PARLIB, 219,140,21,19, 0, 0, 0, 0, 0, ""); @@ -1854,7 +1882,11 @@ static void world_panel_texture(World *wrld) uiBlockSetCol(block, TH_AUTO); - + /* copy/paste */ + uiBlockBeginAlign(block); + uiDefIconBut(block, BUT, B_WMTEXCOPY, ICON_COPYUP, 250,140,25,19, 0, 0, 0, 0, 0, "Copies the mapping settings to the buffer"); + uiDefIconBut(block, BUT, B_WMTEXPASTE, ICON_PASTEUP,275,140,25,19, 0, 0, 0, 0, 0, "Pastes the mapping settings from the buffer"); + /* TEXCO */ uiBlockBeginAlign(block); uiDefButS(block, ROW, B_MATPRV, "View", 100,110,100,20, &(mtex->texco), 4.0, (float)TEXCO_VIEW, 0, 0, "Uses view vector for the texture coordinates"); @@ -2051,6 +2083,8 @@ static void world_panel_preview(World *wrld) void do_lampbuts(unsigned short event) { + static short mtexcopied=0; + static MTex mtexcopybuf; Lamp *la; MTex *mtex; @@ -2094,6 +2128,36 @@ void do_lampbuts(unsigned short event) allqueue(REDRAWBUTSSHADING, 0); allqueue(REDRAWVIEW3D, 0); break; + case B_LMTEXCOPY: + la= G.buts->lockpoin; + if(la && la->mtex[(int)la->texact] ) { + mtex= la->mtex[(int)la->texact]; + if(mtex->tex==0) { + error("No texture available"); + } + else { + memcpy(&mtexcopybuf, la->mtex[(int)la->texact], sizeof(MTex)); + mtexcopied= 1; + } + } + break; + case B_LMTEXPASTE: + la= G.buts->lockpoin; + if(la && mtexcopied && mtexcopybuf.tex) { + if(la->mtex[(int)la->texact]==0 ) + la->mtex[(int)la->texact]= MEM_mallocN(sizeof(MTex), "mtex"); + else if(la->mtex[(int)la->texact]->tex) + la->mtex[(int)la->texact]->tex->id.us--; + + memcpy(la->mtex[(int)la->texact], &mtexcopybuf, sizeof(MTex)); + + id_us_plus((ID *)mtexcopybuf.tex); + BIF_undo_push("Paste mapping settings"); + BIF_preview_changed(G.buts); + scrarea_queue_winredraw(curarea); + } + break; + } if(event) freefastshade(); @@ -2190,7 +2254,7 @@ static void lamp_panel_texture(Object *ob, Lamp *la) uiDefBut(block, TEX, B_IDNAME, "TE:", 100,160,200,19, id->name+2, 0.0, 18.0, 0, 0, "Displays name of the texture block: click to change"); sprintf(str, "%d", id->us); uiDefBut(block, BUT, 0, str, 196,140,21,19, 0, 0, 0, 0, 0, "Displays number of users of texture: click to make single user"); - uiDefIconBut(block, BUT, B_AUTOTEXNAME, ICON_AUTO, 241,140,21,19, 0, 0, 0, 0, 0, "Auto-assigns name to texture"); + uiDefIconBut(block, BUT, B_AUTOTEXNAME, ICON_AUTO, 221,140,21,19, 0, 0, 0, 0, 0, "Auto-assigns name to texture"); if(id->lib) { if(la->id.lib) uiDefIconBut(block, BUT, 0, ICON_DATALIB, 219,140,21,19, 0, 0, 0, 0, 0, ""); else uiDefIconBut(block, BUT, 0, ICON_PARLIB, 219,140,21,19, 0, 0, 0, 0, 0, ""); @@ -2201,6 +2265,11 @@ static void lamp_panel_texture(Object *ob, Lamp *la) else uiDefButS(block, TOG, B_LTEXBROWSE, "Add New" ,100, 160, 200, 19, &(G.buts->texnr), -1.0, 32767.0, 0, 0, "Adds a new texture datablock"); + /* copy/paste */ + uiBlockBeginAlign(block); + uiDefIconBut(block, BUT, B_LMTEXCOPY, ICON_COPYUP, 250,140,25,19, 0, 0, 0, 0, 0, "Copies the mapping settings to the buffer"); + uiDefIconBut(block, BUT, B_LMTEXPASTE, ICON_PASTEUP, 275,140,25,19, 0, 0, 0, 0, 0, "Pastes the mapping settings from the buffer"); + /* TEXCO */ uiBlockSetCol(block, TH_AUTO); uiBlockBeginAlign(block); @@ -2490,6 +2559,7 @@ static void lamp_panel_preview(Object *ob, Lamp *la) void do_matbuts(unsigned short event) { static short mtexcopied=0; + static MTex mtexcopybuf; Material *ma; MTex *mtex; @@ -2612,7 +2682,11 @@ void do_matbuts(unsigned short event) case B_MTEXPASTE: ma= G.buts->lockpoin; if(ma && mtexcopied && mtexcopybuf.tex) { - if(ma->mtex[(int)ma->texact]==0 ) ma->mtex[(int)ma->texact]= MEM_mallocN(sizeof(MTex), "mtex"); + if(ma->mtex[(int)ma->texact]==0 ) + ma->mtex[(int)ma->texact]= MEM_mallocN(sizeof(MTex), "mtex"); + else if(ma->mtex[(int)ma->texact]->tex) + ma->mtex[(int)ma->texact]->tex->id.us--; + memcpy(ma->mtex[(int)ma->texact], &mtexcopybuf, sizeof(MTex)); id_us_plus((ID *)mtexcopybuf.tex); |