Orange: daily noodle updates;
- Texture Node: now displays 'intensity values' in node too, and has input, and shows in buttons when activated in Node editor. (no browsing buttons yet...) - New: "Normal Node". This uses a new UI button, which allows to quickly input a normal vector, based on spherical coordinates. The Normal Node has optional vector input, and delivers a dot product then. This can be used as a blending factor between nodes, or for fake extra light in a certain direction. - New: "Geometry Node". This actually replaces the Input node. It offers all coordinates (vectors) as being the starting point for shading and for textures. Note: for preview render this doesn't give much different results yet... this is the start for real render support! - http://www.blender.org/bf/rt5.jpg The two new nodes in action - Bugfix: the "Block" button (which delivers popups) did not return a correct event when nothing happened (mouse moved out), which could cause mouse clicks to be passed on to the queue.
This commit is contained in:
		@@ -108,9 +108,11 @@ void			nodeRemLink(struct bNodeTree *ntree, struct bNodeLink *link);
 | 
			
		||||
 | 
			
		||||
struct bNodeLink *nodeFindLink(struct bNodeTree *ntree, struct bNodeSocket *from, struct bNodeSocket *to);
 | 
			
		||||
int				nodeCountSocketLinks(struct bNodeTree *ntree, struct bNodeSocket *sock);
 | 
			
		||||
 | 
			
		||||
void			nodeSetActive(struct bNodeTree *ntree, struct bNode *node);
 | 
			
		||||
struct bNode	*nodeGetActive(struct bNodeTree *ntree);
 | 
			
		||||
struct bNode	*nodeGetActiveID(struct bNodeTree *ntree, short idtype);
 | 
			
		||||
void			nodeSetActive(struct bNodeTree *ntree, struct bNode *node);
 | 
			
		||||
void			nodeClearActiveID(struct bNodeTree *ntree, short idtype);
 | 
			
		||||
 | 
			
		||||
/* ************** SHADER NODES *************** */
 | 
			
		||||
 | 
			
		||||
@@ -127,6 +129,8 @@ struct ShadeResult;
 | 
			
		||||
#define SH_NODE_VALTORGB	104
 | 
			
		||||
#define SH_NODE_RGBTOBW		105
 | 
			
		||||
#define SH_NODE_TEXTURE		106
 | 
			
		||||
#define SH_NODE_NORMAL		107
 | 
			
		||||
#define SH_NODE_GEOMETRY	108
 | 
			
		||||
 | 
			
		||||
/* custom defines: options for Material node */
 | 
			
		||||
#define SH_NODE_MAT_DIFF	1
 | 
			
		||||
 
 | 
			
		||||
@@ -446,6 +446,7 @@ bNode *nodeGetActive(bNodeTree *ntree)
 | 
			
		||||
	return node;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* two active flags, ID nodes have special flag for buttons display */
 | 
			
		||||
bNode *nodeGetActiveID(bNodeTree *ntree, short idtype)
 | 
			
		||||
{
 | 
			
		||||
	bNode *node;
 | 
			
		||||
@@ -459,6 +460,18 @@ bNode *nodeGetActiveID(bNodeTree *ntree, short idtype)
 | 
			
		||||
	return node;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* two active flags, ID nodes have special flag for buttons display */
 | 
			
		||||
void nodeClearActiveID(bNodeTree *ntree, short idtype)
 | 
			
		||||
{
 | 
			
		||||
	bNode *node;
 | 
			
		||||
	
 | 
			
		||||
	if(ntree==NULL) return;
 | 
			
		||||
	
 | 
			
		||||
	for(node= ntree->nodes.first; node; node= node->next)
 | 
			
		||||
		if(node->id && GS(node->id->name)==idtype)
 | 
			
		||||
			node->flag &= ~NODE_ACTIVE_ID;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* two active flags, ID nodes have special flag for buttons display */
 | 
			
		||||
void nodeSetActive(bNodeTree *ntree, bNode *node)
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -159,18 +159,59 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in,
 | 
			
		||||
static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 | 
			
		||||
{
 | 
			
		||||
	if(data && node->id) {
 | 
			
		||||
		ShadeInput *shi;
 | 
			
		||||
		ShadeInput *shi= ((ShaderCallData *)data)->shi;
 | 
			
		||||
		float *vec;
 | 
			
		||||
		int retval;
 | 
			
		||||
		
 | 
			
		||||
		shi= ((ShaderCallData *)data)->shi;
 | 
			
		||||
		
 | 
			
		||||
		multitex_ext((Tex *)node->id, shi->co, out[0]->vec, out[1]->vec, out[1]->vec+1, out[1]->vec+2, out[1]->vec+3);
 | 
			
		||||
		/* out: value, color, normal */
 | 
			
		||||
		if(in[0]->hasinput)
 | 
			
		||||
			vec= in[0]->vec;
 | 
			
		||||
		else
 | 
			
		||||
			vec= shi->co;
 | 
			
		||||
		
 | 
			
		||||
		retval= multitex_ext((Tex *)node->id, vec, out[0]->vec, out[1]->vec, out[1]->vec+1, out[1]->vec+2, out[1]->vec+3);
 | 
			
		||||
		if((retval & TEX_RGB)==0) {
 | 
			
		||||
			out[1]->vec[0]= out[0]->vec[0];
 | 
			
		||||
			out[1]->vec[1]= out[0]->vec[0];
 | 
			
		||||
			out[1]->vec[2]= out[0]->vec[0];
 | 
			
		||||
			out[1]->vec[3]= 1.0f;
 | 
			
		||||
		}
 | 
			
		||||
		if(shi->do_preview)
 | 
			
		||||
			nodeAddToPreview(node, out[1]->vec, shi->xs, shi->ys);
 | 
			
		||||
 | 
			
		||||
		
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* **************** geometry node ************ */
 | 
			
		||||
 | 
			
		||||
static void node_shader_exec_geom(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 | 
			
		||||
{
 | 
			
		||||
	if(data) {
 | 
			
		||||
		ShadeInput *shi= ((ShaderCallData *)data)->shi;
 | 
			
		||||
		
 | 
			
		||||
		/* out: global, local, view, orco, uv, normal */
 | 
			
		||||
		VECCOPY(out[0]->vec, shi->gl);
 | 
			
		||||
		VECCOPY(out[1]->vec, shi->co);
 | 
			
		||||
		VECCOPY(out[2]->vec, shi->view);
 | 
			
		||||
		VECCOPY(out[3]->vec, shi->lo);
 | 
			
		||||
		VECCOPY(out[4]->vec, shi->uv);
 | 
			
		||||
		VECCOPY(out[5]->vec, shi->vno);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* **************** normal node ************ */
 | 
			
		||||
 | 
			
		||||
/* generates normal, does dot product */
 | 
			
		||||
static void node_shader_exec_normal(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 | 
			
		||||
{
 | 
			
		||||
	bNodeSocket *sock= node->outputs.first;
 | 
			
		||||
	/* stack order input:  normal */
 | 
			
		||||
	/* stack order output: normal, value */
 | 
			
		||||
	
 | 
			
		||||
	VECCOPY(out[0]->vec, sock->ns.vec);
 | 
			
		||||
	out[1]->vec[0]= INPR(out[0]->vec, in[0]->vec);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* **************** value node ************ */
 | 
			
		||||
 | 
			
		||||
static void node_shader_exec_value(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 | 
			
		||||
@@ -197,9 +238,12 @@ static void node_shader_exec_mix_rgb(void *data, bNode *node, bNodeStack **in, b
 | 
			
		||||
	/* stack order in: fac, col1, col2 */
 | 
			
		||||
	/* stack order out: col */
 | 
			
		||||
	float col[3];
 | 
			
		||||
	float fac= in[0]->vec[0];
 | 
			
		||||
	
 | 
			
		||||
	CLAMP(fac, 0.0f, 1.0f);
 | 
			
		||||
	
 | 
			
		||||
	VECCOPY(col, in[1]->vec);
 | 
			
		||||
	ramp_blend(node->custom1, col, col+1, col+2, in[0]->vec[0], in[2]->vec);
 | 
			
		||||
	ramp_blend(node->custom1, col, col+1, col+2, fac, in[2]->vec);
 | 
			
		||||
	VECCOPY(out[0]->vec, col);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -272,6 +316,29 @@ static bNodeType sh_node_output= {
 | 
			
		||||
	
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* **************** GEOMETRY INFO ******************** */
 | 
			
		||||
static bNodeSocketType sh_node_geom_out[]= {
 | 
			
		||||
	{	SOCK_VECTOR, 0, "Global",	0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},	/* btw; uses no limit */
 | 
			
		||||
	{	SOCK_VECTOR, 0, "Local",	0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
 | 
			
		||||
	{	SOCK_VECTOR, 0, "View",	0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
 | 
			
		||||
	{	SOCK_VECTOR, 0, "Orco",	0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
 | 
			
		||||
	{	SOCK_VECTOR, 0, "UV",	0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
 | 
			
		||||
	{	SOCK_VECTOR, 0, "Normal",	0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
 | 
			
		||||
	{	-1, 0, ""	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static bNodeType sh_node_geom= {
 | 
			
		||||
	/* type code   */	SH_NODE_GEOMETRY,
 | 
			
		||||
	/* name        */	"Geometry",
 | 
			
		||||
	/* width+range */	60, 40, 100,
 | 
			
		||||
	/* class+opts  */	NODE_CLASS_GENERATOR, 0,
 | 
			
		||||
	/* input sock  */	NULL,
 | 
			
		||||
	/* output sock */	sh_node_geom_out,
 | 
			
		||||
	/* storage     */	"",
 | 
			
		||||
	/* execfunc    */	node_shader_exec_geom,
 | 
			
		||||
	
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* **************** MATERIAL ******************** */
 | 
			
		||||
static bNodeSocketType sh_node_material_in[]= {
 | 
			
		||||
	{	SOCK_VECTOR, 1, "Normal",	0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
 | 
			
		||||
@@ -298,6 +365,10 @@ static bNodeType sh_node_material= {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* **************** TEXTURE ******************** */
 | 
			
		||||
static bNodeSocketType sh_node_texture_in[]= {
 | 
			
		||||
	{	SOCK_VECTOR, 1, "Vector",	0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},	/* no limit */
 | 
			
		||||
	{	-1, 0, ""	}
 | 
			
		||||
};
 | 
			
		||||
static bNodeSocketType sh_node_texture_out[]= {
 | 
			
		||||
	{	SOCK_VALUE, 0, "Value",		1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
 | 
			
		||||
	{	SOCK_RGBA , 0, "Color",		1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
 | 
			
		||||
@@ -310,13 +381,37 @@ static bNodeType sh_node_texture= {
 | 
			
		||||
	/* name        */	"Texture",
 | 
			
		||||
	/* width+range */	120, 80, 240,
 | 
			
		||||
	/* class+opts  */	NODE_CLASS_GENERATOR, NODE_OPTIONS|NODE_PREVIEW,
 | 
			
		||||
	/* input sock  */	NULL,
 | 
			
		||||
	/* input sock  */	sh_node_texture_in,
 | 
			
		||||
	/* output sock */	sh_node_texture_out,
 | 
			
		||||
	/* storage     */	"",
 | 
			
		||||
	/* execfunc    */	node_shader_exec_texture,
 | 
			
		||||
	
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* **************** NORMAL  ******************** */
 | 
			
		||||
static bNodeSocketType sh_node_normal_in[]= {
 | 
			
		||||
	{	SOCK_VECTOR, 1, "Normal",	0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
 | 
			
		||||
	{	-1, 0, ""	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static bNodeSocketType sh_node_normal_out[]= {
 | 
			
		||||
	{	SOCK_VECTOR, 0, "Normal",	0.0f, 0.0f, 1.0f, 1.0f, -1.0f, 1.0f},
 | 
			
		||||
	{	SOCK_VALUE, 0, "Dot",		1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
 | 
			
		||||
	{	-1, 0, ""	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static bNodeType sh_node_normal= {
 | 
			
		||||
	/* type code   */	SH_NODE_NORMAL,
 | 
			
		||||
	/* name        */	"Normal",
 | 
			
		||||
	/* width+range */	100, 60, 200,
 | 
			
		||||
	/* class+opts  */	NODE_CLASS_GENERATOR, NODE_OPTIONS,
 | 
			
		||||
	/* input sock  */	sh_node_normal_in,
 | 
			
		||||
	/* output sock */	sh_node_normal_out,
 | 
			
		||||
	/* storage     */	"",
 | 
			
		||||
	/* execfunc    */	node_shader_exec_normal,
 | 
			
		||||
	
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* **************** VALUE ******************** */
 | 
			
		||||
static bNodeSocketType sh_node_value_out[]= {
 | 
			
		||||
	{	SOCK_VALUE, 0, "Value",		0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
 | 
			
		||||
@@ -436,6 +531,8 @@ bNodeType *node_all_shaders[]= {
 | 
			
		||||
	&sh_node_valtorgb,
 | 
			
		||||
	&sh_node_rgbtobw,
 | 
			
		||||
	&sh_node_texture,
 | 
			
		||||
	&sh_node_normal,
 | 
			
		||||
	&sh_node_geom,
 | 
			
		||||
	NULL
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -114,7 +114,13 @@ struct ScrArea;
 | 
			
		||||
#define UI_BUT_ALIGN_DOWN	(1<<15)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Button types */
 | 
			
		||||
/* Button types, bits stored in 1 value... and a short even!
 | 
			
		||||
- bits 0-4:  bitnr (0-31)
 | 
			
		||||
- bits 5-7:  pointer type
 | 
			
		||||
- bit  8:    for 'bit'
 | 
			
		||||
- bit  9-15: button type (now 6 bits, 64 types)
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#define CHA	32
 | 
			
		||||
#define SHO	64
 | 
			
		||||
#define INT	96
 | 
			
		||||
@@ -154,8 +160,9 @@ struct ScrArea;
 | 
			
		||||
#define ROUNDBOX (28<<9)
 | 
			
		||||
#define CHARTAB (29<<9)
 | 
			
		||||
#define BUT_COLORBAND (30<<9)
 | 
			
		||||
#define BUT_NORMAL (31<<9)
 | 
			
		||||
 | 
			
		||||
#define BUTTYPE	(31<<9)
 | 
			
		||||
#define BUTTYPE	(63<<9)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1200,7 +1200,7 @@ static void texture_panel_colors(Tex *tex)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void texture_panel_texture(MTex *mtex, Material *ma, World *wrld, Lamp *la)
 | 
			
		||||
static void texture_panel_texture(MTex *mtex, Material *ma, World *wrld, Lamp *la, bNode *node)
 | 
			
		||||
{
 | 
			
		||||
	MTex *mt=NULL;
 | 
			
		||||
	uiBlock *block;
 | 
			
		||||
@@ -1215,11 +1215,14 @@ static void texture_panel_texture(MTex *mtex, Material *ma, World *wrld, Lamp *l
 | 
			
		||||
	/* first do the browse but */
 | 
			
		||||
	if(mtex)
 | 
			
		||||
		id= (ID *)mtex->tex;
 | 
			
		||||
	else if(node)
 | 
			
		||||
		id= node->id;
 | 
			
		||||
	
 | 
			
		||||
	if(ma) idfrom= &ma->id;
 | 
			
		||||
	else if(wrld) idfrom= &wrld->id;
 | 
			
		||||
	else idfrom= &la->id;
 | 
			
		||||
 | 
			
		||||
	else if(la) idfrom= &la->id;
 | 
			
		||||
	else idfrom= NULL;
 | 
			
		||||
	
 | 
			
		||||
	uiBlockSetCol(block, TH_BUT_SETTING2);
 | 
			
		||||
	if(ma) {
 | 
			
		||||
		std_libbuttons(block, 10, 180, 0, NULL, B_TEXBROWSE, ID_TE, 0, id, idfrom, &(G.buts->texnr), B_TEXALONE, B_TEXLOCAL, B_TEXDELETE, B_AUTOTEXNAME, B_KEEPDATA);
 | 
			
		||||
@@ -1229,45 +1232,49 @@ static void texture_panel_texture(MTex *mtex, Material *ma, World *wrld, Lamp *l
 | 
			
		||||
	}
 | 
			
		||||
	else if(la) {
 | 
			
		||||
		std_libbuttons(block, 10, 180, 0, NULL, B_LTEXBROWSE, ID_TE, 0, id, idfrom, &(G.buts->texnr), B_TEXALONE, B_TEXLOCAL, B_TEXDELETE, B_AUTOTEXNAME, B_KEEPDATA);
 | 
			
		||||
	}
 | 
			
		||||
	else if(node) {
 | 
			
		||||
		
 | 
			
		||||
	}
 | 
			
		||||
	uiBlockSetCol(block, TH_BUT_NEUTRAL);
 | 
			
		||||
 | 
			
		||||
	/* From button: removed */
 | 
			
		||||
 | 
			
		||||
	/* CHANNELS */
 | 
			
		||||
	uiBlockBeginAlign(block);
 | 
			
		||||
	yco= 150;
 | 
			
		||||
	for(a= 0; a<MAX_MTEX; a++) {
 | 
			
		||||
		
 | 
			
		||||
		if(ma) mt= ma->mtex[a];
 | 
			
		||||
		else if(wrld)  mt= wrld->mtex[a];
 | 
			
		||||
		else if(la)  mt= la->mtex[a];
 | 
			
		||||
		
 | 
			
		||||
		if(mt && mt->tex) splitIDname(mt->tex->id.name+2, str, &loos);
 | 
			
		||||
		else strcpy(str, "");
 | 
			
		||||
		str[14]= 0;
 | 
			
		||||
	if(node==NULL) {
 | 
			
		||||
		uiBlockBeginAlign(block);
 | 
			
		||||
		yco= 150;
 | 
			
		||||
		for(a= 0; a<MAX_MTEX; a++) {
 | 
			
		||||
			
 | 
			
		||||
			if(ma) mt= ma->mtex[a];
 | 
			
		||||
			else if(wrld)  mt= wrld->mtex[a];
 | 
			
		||||
			else if(la)  mt= la->mtex[a];
 | 
			
		||||
			
 | 
			
		||||
			if(mt && mt->tex) splitIDname(mt->tex->id.name+2, str, &loos);
 | 
			
		||||
			else strcpy(str, "");
 | 
			
		||||
			str[14]= 0;
 | 
			
		||||
 | 
			
		||||
		if(ma) {
 | 
			
		||||
			uiDefButC(block, ROW, B_TEXCHANNEL, str,	10,yco,140,19, &(ma->texact), 0.0, (float)a, 0, 0, "Click to select texture channel");
 | 
			
		||||
			yco-= 20;
 | 
			
		||||
			if(ma) {
 | 
			
		||||
				uiDefButC(block, ROW, B_TEXCHANNEL, str,	10,yco,140,19, &(ma->texact), 0.0, (float)a, 0, 0, "Click to select texture channel");
 | 
			
		||||
				yco-= 20;
 | 
			
		||||
			}
 | 
			
		||||
			else if(wrld) {
 | 
			
		||||
				uiDefButS(block, ROW, B_TEXCHANNEL, str,	10,yco,140,19, &(wrld->texact), 0.0, (float)a, 0, 0, "");
 | 
			
		||||
				yco-= 20;
 | 
			
		||||
			}
 | 
			
		||||
			else if(la) {
 | 
			
		||||
				uiDefButS(block, ROW, B_TEXCHANNEL, str,	10,yco,140,19, &(la->texact), 0.0, (float)a, 0, 0, "");
 | 
			
		||||
				yco-= 20;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else if(wrld) {
 | 
			
		||||
			uiDefButS(block, ROW, B_TEXCHANNEL, str,	10,yco,140,19, &(wrld->texact), 0.0, (float)a, 0, 0, "");
 | 
			
		||||
			yco-= 20;
 | 
			
		||||
		}
 | 
			
		||||
		else if(la) {
 | 
			
		||||
			uiDefButS(block, ROW, B_TEXCHANNEL, str,	10,yco,140,19, &(la->texact), 0.0, (float)a, 0, 0, "");
 | 
			
		||||
			yco-= 20;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	uiBlockEndAlign(block);
 | 
			
		||||
	
 | 
			
		||||
		uiBlockEndAlign(block);
 | 
			
		||||
	}	
 | 
			
		||||
	uiBlockSetCol(block, TH_AUTO);
 | 
			
		||||
 | 
			
		||||
	/* TYPES */
 | 
			
		||||
	if(mtex && mtex->tex) {
 | 
			
		||||
	if(id) {
 | 
			
		||||
		char textypes[512];
 | 
			
		||||
		Tex *tex= mtex->tex;
 | 
			
		||||
		Tex *tex= (Tex *)id;
 | 
			
		||||
 | 
			
		||||
		uiSetButLock(tex->id.lib!=0, "Can't edit library data");
 | 
			
		||||
		
 | 
			
		||||
@@ -3590,14 +3597,22 @@ void texture_panels()
 | 
			
		||||
	Material *ma=NULL;
 | 
			
		||||
	Lamp *la=NULL;
 | 
			
		||||
	World *wrld=NULL;
 | 
			
		||||
	bNode *node=NULL;
 | 
			
		||||
	Object *ob= OBACT;
 | 
			
		||||
	MTex *mtex= NULL;
 | 
			
		||||
	
 | 
			
		||||
	if(G.buts->texfrom==0) {
 | 
			
		||||
		if(ob) {
 | 
			
		||||
			ma= give_current_material(ob, ob->actcol);
 | 
			
		||||
			ma= get_active_matlayer(ma);
 | 
			
		||||
			if(ma) mtex= ma->mtex[ ma->texact ];
 | 
			
		||||
			if(ma && ma->use_nodes)
 | 
			
		||||
				node= nodeGetActiveID(ma->nodetree, ID_TE);
 | 
			
		||||
 | 
			
		||||
			if(node)
 | 
			
		||||
				ma= NULL;
 | 
			
		||||
			else {
 | 
			
		||||
				ma= get_active_matlayer(ma);
 | 
			
		||||
				if(ma) mtex= ma->mtex[ ma->texact ];
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	else if(G.buts->texfrom==1) {
 | 
			
		||||
@@ -3611,57 +3626,61 @@ void texture_panels()
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	texture_panel_preview(ma || wrld || la);	// for 'from' buttons
 | 
			
		||||
	texture_panel_preview(ma || wrld || la || node);	// for 'from' buttons
 | 
			
		||||
	
 | 
			
		||||
	if(ma || wrld || la) {
 | 
			
		||||
	
 | 
			
		||||
		texture_panel_texture(mtex, ma, wrld, la);
 | 
			
		||||
	if(ma || wrld || la || node) {
 | 
			
		||||
		Tex *tex= NULL;
 | 
			
		||||
		
 | 
			
		||||
		if(mtex && mtex->tex) {
 | 
			
		||||
			texture_panel_colors(mtex->tex);
 | 
			
		||||
		texture_panel_texture(mtex, ma, wrld, la, node);
 | 
			
		||||
		
 | 
			
		||||
		if(mtex) tex= mtex->tex;
 | 
			
		||||
		else if(node) tex= (Tex *)node->id;
 | 
			
		||||
		
 | 
			
		||||
		if(tex) {
 | 
			
		||||
			texture_panel_colors(tex);
 | 
			
		||||
			
 | 
			
		||||
			switch(mtex->tex->type) {
 | 
			
		||||
			switch(tex->type) {
 | 
			
		||||
			case TEX_IMAGE:
 | 
			
		||||
				texture_panel_image(mtex->tex);
 | 
			
		||||
				texture_panel_image1(mtex->tex);
 | 
			
		||||
				texture_panel_image(tex);
 | 
			
		||||
				texture_panel_image1(tex);
 | 
			
		||||
				break;
 | 
			
		||||
			case TEX_ENVMAP:
 | 
			
		||||
				texture_panel_envmap(mtex->tex);
 | 
			
		||||
				texture_panel_envmap(tex);
 | 
			
		||||
				break;
 | 
			
		||||
			case TEX_CLOUDS:
 | 
			
		||||
				texture_panel_clouds(mtex->tex);
 | 
			
		||||
				texture_panel_clouds(tex);
 | 
			
		||||
				break;
 | 
			
		||||
			case TEX_MARBLE:
 | 
			
		||||
				texture_panel_marble(mtex->tex);
 | 
			
		||||
				texture_panel_marble(tex);
 | 
			
		||||
				break;
 | 
			
		||||
			case TEX_STUCCI:
 | 
			
		||||
				texture_panel_stucci(mtex->tex);
 | 
			
		||||
				texture_panel_stucci(tex);
 | 
			
		||||
				break;
 | 
			
		||||
			case TEX_WOOD:
 | 
			
		||||
				texture_panel_wood(mtex->tex);
 | 
			
		||||
				texture_panel_wood(tex);
 | 
			
		||||
				break;
 | 
			
		||||
			case TEX_BLEND:
 | 
			
		||||
				texture_panel_blend(mtex->tex);
 | 
			
		||||
				texture_panel_blend(tex);
 | 
			
		||||
				break;
 | 
			
		||||
			case TEX_MAGIC:
 | 
			
		||||
				texture_panel_magic(mtex->tex);
 | 
			
		||||
				texture_panel_magic(tex);
 | 
			
		||||
				break;
 | 
			
		||||
			case TEX_PLUGIN:
 | 
			
		||||
				texture_panel_plugin(mtex->tex);
 | 
			
		||||
				texture_panel_plugin(tex);
 | 
			
		||||
				break;
 | 
			
		||||
			case TEX_NOISE:
 | 
			
		||||
				// no panel! (e: not really true, is affected by noisedepth param)
 | 
			
		||||
				break;
 | 
			
		||||
			/* newnoise: musgrave panels */
 | 
			
		||||
				/* newnoise: musgrave panels */
 | 
			
		||||
			case TEX_MUSGRAVE:
 | 
			
		||||
				texture_panel_musgrave(mtex->tex);
 | 
			
		||||
				texture_panel_musgrave(tex);
 | 
			
		||||
				break;
 | 
			
		||||
			case TEX_DISTNOISE:
 | 
			
		||||
				texture_panel_distnoise(mtex->tex);
 | 
			
		||||
				texture_panel_distnoise(tex);
 | 
			
		||||
				break;
 | 
			
		||||
			/* newnoise: voronoi */
 | 
			
		||||
				/* newnoise: voronoi */
 | 
			
		||||
			case TEX_VORONOI:
 | 
			
		||||
				texture_panel_voronoi(mtex->tex);
 | 
			
		||||
				texture_panel_voronoi(tex);
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -122,6 +122,8 @@ static uiBlock *socket_vector_menu(void *sock_v)
 | 
			
		||||
	
 | 
			
		||||
	uiBlockSetDirection(block, UI_TOP);
 | 
			
		||||
	
 | 
			
		||||
	allqueue(REDRAWNODE, 0);
 | 
			
		||||
	
 | 
			
		||||
	return block;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -282,6 +284,19 @@ static int node_shader_buts_texture(uiBlock *block, bNodeTree *ntree, bNode *nod
 | 
			
		||||
	return 19;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int node_shader_buts_normal(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
 | 
			
		||||
{
 | 
			
		||||
	if(block) {
 | 
			
		||||
		bNodeSocket *sock= node->outputs.first;		/* first socket stores normal */
 | 
			
		||||
		
 | 
			
		||||
		uiDefButF(block, BUT_NORMAL, B_NODE_EXEC, "", 
 | 
			
		||||
				  butr->xmin, butr->ymin, butr->xmax-butr->xmin, butr->ymax-butr->ymin, 
 | 
			
		||||
				  sock->ns.vec, 0.0f, 1.0f, 0, 0, "");
 | 
			
		||||
		
 | 
			
		||||
	}	
 | 
			
		||||
	return (int)(node->width-NODE_DY);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int node_shader_buts_value(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
 | 
			
		||||
{
 | 
			
		||||
	if(block) {
 | 
			
		||||
@@ -362,6 +377,9 @@ static void node_shader_set_butfunc(bNodeType *ntype)
 | 
			
		||||
		case SH_NODE_TEXTURE:
 | 
			
		||||
			ntype->butfunc= node_shader_buts_texture;
 | 
			
		||||
			break;
 | 
			
		||||
		case SH_NODE_NORMAL:
 | 
			
		||||
			ntype->butfunc= node_shader_buts_normal;
 | 
			
		||||
			break;
 | 
			
		||||
		case SH_NODE_VALUE:
 | 
			
		||||
			ntype->butfunc= node_shader_buts_value;
 | 
			
		||||
			break;
 | 
			
		||||
@@ -536,27 +554,36 @@ static void node_update(bNode *node)
 | 
			
		||||
	bNodeSocket *nsock;
 | 
			
		||||
	
 | 
			
		||||
	if(node->flag & NODE_HIDDEN) {
 | 
			
		||||
		float rad, drad;
 | 
			
		||||
		float rad, drad, hiddenrad= HIDDEN_RAD;
 | 
			
		||||
		int totin, totout, tot;
 | 
			
		||||
		
 | 
			
		||||
		/* calculate minimal radius */
 | 
			
		||||
		totin= BLI_countlist(&node->inputs);
 | 
			
		||||
		totout= BLI_countlist(&node->outputs);
 | 
			
		||||
		tot= MAX2(totin, totout);
 | 
			
		||||
		if(tot>4) {
 | 
			
		||||
			hiddenrad += 5.0*(float)(tot-4);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		node->totr.xmin= node->locx;
 | 
			
		||||
		node->totr.xmax= node->locx + 3*HIDDEN_RAD + node->miniwidth;
 | 
			
		||||
		node->totr.ymax= node->locy + (HIDDEN_RAD - 0.5f*NODE_DY);
 | 
			
		||||
		node->totr.ymin= node->totr.ymax - 2*HIDDEN_RAD;
 | 
			
		||||
		node->totr.xmax= node->locx + 3*hiddenrad + node->miniwidth;
 | 
			
		||||
		node->totr.ymax= node->locy + (hiddenrad - 0.5f*NODE_DY);
 | 
			
		||||
		node->totr.ymin= node->totr.ymax - 2*hiddenrad;
 | 
			
		||||
		
 | 
			
		||||
		/* output connectors */
 | 
			
		||||
		rad=drad= M_PI/(1.0f + (float)BLI_countlist(&node->outputs));
 | 
			
		||||
		rad=drad= M_PI/(1.0f + (float)totout);
 | 
			
		||||
		
 | 
			
		||||
		for(nsock= node->outputs.first; nsock; nsock= nsock->next, rad+= drad) {
 | 
			
		||||
			nsock->locx= node->totr.xmax - HIDDEN_RAD + sin(rad)*HIDDEN_RAD;
 | 
			
		||||
			nsock->locy= node->totr.ymin + HIDDEN_RAD + cos(rad)*HIDDEN_RAD;
 | 
			
		||||
			nsock->locx= node->totr.xmax - hiddenrad + sin(rad)*hiddenrad;
 | 
			
		||||
			nsock->locy= node->totr.ymin + hiddenrad + cos(rad)*hiddenrad;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		/* input connectors */
 | 
			
		||||
		rad=drad= - M_PI/(1.0f + (float)BLI_countlist(&node->inputs));
 | 
			
		||||
		rad=drad= - M_PI/(1.0f + (float)totin);
 | 
			
		||||
		
 | 
			
		||||
		for(nsock= node->inputs.first; nsock; nsock= nsock->next, rad+= drad) {
 | 
			
		||||
			nsock->locx= node->totr.xmin + HIDDEN_RAD + sin(rad)*HIDDEN_RAD;
 | 
			
		||||
			nsock->locy= node->totr.ymin + HIDDEN_RAD + cos(rad)*HIDDEN_RAD;
 | 
			
		||||
			nsock->locx= node->totr.xmin + hiddenrad + sin(rad)*hiddenrad;
 | 
			
		||||
			nsock->locy= node->totr.ymin + hiddenrad + cos(rad)*hiddenrad;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	else {
 | 
			
		||||
@@ -785,21 +812,22 @@ void node_hidden_draw(SpaceNode *snode, bNode *node)
 | 
			
		||||
	bNodeSocket *sock;
 | 
			
		||||
	rctf *rct= &node->totr;
 | 
			
		||||
	float dx, centy= 0.5f*(rct->ymax+rct->ymin);
 | 
			
		||||
	float hiddenrad= 0.5f*(rct->ymax-rct->ymin);
 | 
			
		||||
	int color_id= node_get_colorid(node);
 | 
			
		||||
	
 | 
			
		||||
	/* shadow */
 | 
			
		||||
	uiSetRoundBox(15);
 | 
			
		||||
	nodeshadow(rct, HIDDEN_RAD, node->flag & SELECT);
 | 
			
		||||
	nodeshadow(rct, hiddenrad, node->flag & SELECT);
 | 
			
		||||
 | 
			
		||||
	/* body */
 | 
			
		||||
	BIF_ThemeColorShade(color_id, 20);	
 | 
			
		||||
	uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, HIDDEN_RAD);
 | 
			
		||||
	uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad);
 | 
			
		||||
	
 | 
			
		||||
	/* outline active emphasis */
 | 
			
		||||
	if(node->flag & NODE_ACTIVE) {
 | 
			
		||||
		glEnable(GL_BLEND);
 | 
			
		||||
		glColor4ub(200, 200, 200, 140);
 | 
			
		||||
		gl_round_box(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, HIDDEN_RAD);
 | 
			
		||||
		gl_round_box(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad);
 | 
			
		||||
		glDisable(GL_BLEND);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
@@ -832,7 +860,7 @@ void node_hidden_draw(SpaceNode *snode, bNode *node)
 | 
			
		||||
	//	if(node->id) {
 | 
			
		||||
	//		glEnable(GL_BLEND);
 | 
			
		||||
	//		BIF_icon_set_aspect(node->id->icon_id, snode->aspect);
 | 
			
		||||
	//		BIF_icon_draw(rct->xmin+HIDDEN_RAD, -1.0f+rct->ymin+HIDDEN_RAD/2, node->id->icon_id);
 | 
			
		||||
	//		BIF_icon_draw(rct->xmin+hiddenrad, -1.0f+rct->ymin+hiddenrad/2, node->id->icon_id);
 | 
			
		||||
	//		glDisable(GL_BLEND);
 | 
			
		||||
	//	}
 | 
			
		||||
	
 | 
			
		||||
 
 | 
			
		||||
@@ -166,12 +166,8 @@ void node_shader_default(Material *ma)
 | 
			
		||||
	out= nodeAddNodeType(ma->nodetree, SH_NODE_OUTPUT);
 | 
			
		||||
	out->locx= 300.0f; out->locy= 300.0f;
 | 
			
		||||
	
 | 
			
		||||
	/* we add default the own material as shader */
 | 
			
		||||
	in= nodeAddNodeType(ma->nodetree, SH_NODE_MATERIAL);
 | 
			
		||||
	in->locx= 10.0f; in->locy= 300.0f;
 | 
			
		||||
//	in->id= (ID *)ma;
 | 
			
		||||
//	id_us_plus(in->id);
 | 
			
		||||
//	in->flag |= NODE_ACTIVE_ID;
 | 
			
		||||
	nodeSetActive(ma->nodetree, in);
 | 
			
		||||
	
 | 
			
		||||
	/* only a link from color to color */
 | 
			
		||||
@@ -548,6 +544,13 @@ void node_set_active(SpaceNode *snode, bNode *node)
 | 
			
		||||
	
 | 
			
		||||
	/* tree specific activate calls */
 | 
			
		||||
	if(snode->treetype==NTREE_SHADER) {
 | 
			
		||||
		
 | 
			
		||||
		/* when we select a material, active texture is cleared, for buttons */
 | 
			
		||||
		if(node->id && GS(node->id->name)==ID_MA)
 | 
			
		||||
			nodeClearActiveID(snode->nodetree, ID_TE);
 | 
			
		||||
		if(node->id)
 | 
			
		||||
			BIF_preview_changed(-1);	/* temp hack to force texture preview to update */
 | 
			
		||||
		
 | 
			
		||||
		allqueue(REDRAWBUTSSHADING, 1);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -762,7 +765,7 @@ static void node_add_menu(SpaceNode *snode)
 | 
			
		||||
	short event, mval[2];
 | 
			
		||||
	
 | 
			
		||||
	/* shader menu, still hardcoded defines... solve */
 | 
			
		||||
	event= pupmenu("Add Node%t|Input%x0|Output%x1|Material%x100|Texture%x106|Value %x102|Color %x101|Mix Color %x103|ColorRamp %x104|Color to BW %x105");
 | 
			
		||||
	event= pupmenu("Add Node%t|Output%x1|Geometry%x108|Material%x100|Texture%x106|Normal%x107|Value %x102|Color %x101|Mix Color %x103|ColorRamp %x104|Color to BW %x105");
 | 
			
		||||
	if(event<1) return;
 | 
			
		||||
	
 | 
			
		||||
	getmouseco_areawin(mval);
 | 
			
		||||
@@ -1124,7 +1127,8 @@ int node_uiDoBlocks(SpaceNode *snode, ListBase *lb, short event)
 | 
			
		||||
{
 | 
			
		||||
	bNode *node;
 | 
			
		||||
	rctf rect;
 | 
			
		||||
	
 | 
			
		||||
	ListBase listb= *lb;
 | 
			
		||||
	int retval= UI_NOTHING;
 | 
			
		||||
	short mval[2];
 | 
			
		||||
	
 | 
			
		||||
	getmouseco_areawin(mval);
 | 
			
		||||
@@ -1138,14 +1142,16 @@ int node_uiDoBlocks(SpaceNode *snode, ListBase *lb, short event)
 | 
			
		||||
	for(node= snode->nodetree->nodes.first; node; node= node->next) {
 | 
			
		||||
		if(node->block) {
 | 
			
		||||
			if(node == visible_node(snode, &rect)) {
 | 
			
		||||
				ListBase lb;
 | 
			
		||||
				
 | 
			
		||||
				lb.first= lb.last= node->block;
 | 
			
		||||
				return uiDoBlocks(&lb, event);
 | 
			
		||||
				lb->first= lb->last= node->block;
 | 
			
		||||
				retval= uiDoBlocks(lb, event);
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return UI_NOTHING;
 | 
			
		||||
	*lb= listb;
 | 
			
		||||
	
 | 
			
		||||
	return retval;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void winqreadnodespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
 | 
			
		||||
 
 | 
			
		||||
@@ -46,6 +46,7 @@
 | 
			
		||||
#include "DNA_armature_types.h"
 | 
			
		||||
#include "DNA_lamp_types.h"
 | 
			
		||||
#include "DNA_material_types.h"
 | 
			
		||||
#include "DNA_node_types.h"
 | 
			
		||||
#include "DNA_object_types.h"
 | 
			
		||||
#include "DNA_scene_types.h"
 | 
			
		||||
#include "DNA_screen_types.h"
 | 
			
		||||
@@ -67,6 +68,7 @@
 | 
			
		||||
#include "BKE_library.h"
 | 
			
		||||
#include "BKE_main.h"
 | 
			
		||||
#include "BKE_material.h"
 | 
			
		||||
#include "BKE_node.h"
 | 
			
		||||
#include "BKE_texture.h"
 | 
			
		||||
#include "BKE_utildefines.h"
 | 
			
		||||
#include "BSE_drawipo.h"
 | 
			
		||||
@@ -280,12 +282,22 @@ void buttons_active_id(ID **id, ID **idfrom)
 | 
			
		||||
 | 
			
		||||
			if(G.buts->texfrom==0) {
 | 
			
		||||
				if(ob && ob->type<OB_LAMP && ob->type) {
 | 
			
		||||
					bNode *node= NULL;
 | 
			
		||||
					
 | 
			
		||||
					ma= give_current_material(ob, ob->actcol);
 | 
			
		||||
					ma= get_active_matlayer(ma);
 | 
			
		||||
					*idfrom= (ID *)ma;
 | 
			
		||||
					if(ma) {
 | 
			
		||||
						mtex= ma->mtex[ ma->texact ];
 | 
			
		||||
						if(mtex) *id= (ID *)mtex->tex;
 | 
			
		||||
					if(ma && ma->use_nodes)
 | 
			
		||||
						node= nodeGetActiveID(ma->nodetree, ID_TE);
 | 
			
		||||
					if(node) {
 | 
			
		||||
						*idfrom= NULL;
 | 
			
		||||
						*id= node->id;
 | 
			
		||||
					}
 | 
			
		||||
					else {
 | 
			
		||||
						ma= get_active_matlayer(ma);
 | 
			
		||||
						*idfrom= (ID *)ma;
 | 
			
		||||
						if(ma) {
 | 
			
		||||
							mtex= ma->mtex[ ma->texact ];
 | 
			
		||||
							if(mtex) *id= (ID *)mtex->tex;
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 
 | 
			
		||||
@@ -3209,7 +3209,6 @@ static void do_colorband_evt(ColorBand *coba)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static int ui_do_but_COLORBAND(uiBut *but)
 | 
			
		||||
{	
 | 
			
		||||
	ColorBand *coba= (ColorBand *)but->poin;
 | 
			
		||||
@@ -3279,6 +3278,66 @@ static int ui_do_but_COLORBAND(uiBut *but)
 | 
			
		||||
	return but->retval;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* button is presumed square */
 | 
			
		||||
/* if mouse moves outside of sphere, it does negative normal */
 | 
			
		||||
static int ui_do_but_NORMAL(uiBut *but)
 | 
			
		||||
{
 | 
			
		||||
	float dx, dy, rad, radsq, mrad, *fp= (float *)but->poin;
 | 
			
		||||
	int firsttime=1;
 | 
			
		||||
	short mval[2], mvalo[2];
 | 
			
		||||
	
 | 
			
		||||
	rad= 0.5f*(but->x2 - but->x1);
 | 
			
		||||
	radsq= rad*rad;
 | 
			
		||||
	
 | 
			
		||||
	uiGetMouse(mywinget(), mvalo);
 | 
			
		||||
	
 | 
			
		||||
	while(get_mbut() & L_MOUSE) {
 | 
			
		||||
		
 | 
			
		||||
		uiGetMouse(mywinget(), mval);
 | 
			
		||||
		
 | 
			
		||||
		if(mval[0]!=mvalo[0] || mval[1]!=mvalo[1] || firsttime) {
 | 
			
		||||
			firsttime= 0;
 | 
			
		||||
			
 | 
			
		||||
			dx= -but->x1-rad + (float)mval[0];
 | 
			
		||||
			dy= -but->y1-rad + (float)mval[1];
 | 
			
		||||
 | 
			
		||||
			mrad= dx*dx+dy*dy;
 | 
			
		||||
			if(mrad < radsq) {	/* inner circle */
 | 
			
		||||
				fp[0]= dx;
 | 
			
		||||
				fp[1]= dy;
 | 
			
		||||
				fp[2]= sqrt( radsq-dx*dx-dy*dy );
 | 
			
		||||
			}
 | 
			
		||||
			else {	/* outer circle */
 | 
			
		||||
				float norx, nory;
 | 
			
		||||
				
 | 
			
		||||
				mrad= sqrt(mrad);	// veclen
 | 
			
		||||
				norx= dx/mrad;
 | 
			
		||||
				nory= dy/mrad;
 | 
			
		||||
				
 | 
			
		||||
				dx= norx*(2.0f*rad - mrad);
 | 
			
		||||
				dy= nory*(2.0f*rad - mrad);
 | 
			
		||||
				
 | 
			
		||||
				mrad= dx*dx+dy*dy;
 | 
			
		||||
				if(mrad < radsq) {
 | 
			
		||||
					fp[0]= dx;
 | 
			
		||||
					fp[1]= dy;
 | 
			
		||||
					fp[2]= -sqrt( radsq-dx*dx-dy*dy );
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			Normalise(fp);
 | 
			
		||||
				
 | 
			
		||||
			ui_draw_but(but);
 | 
			
		||||
			ui_block_flush_back(but->block);
 | 
			
		||||
 | 
			
		||||
			mvalo[0]= mval[0];
 | 
			
		||||
			mvalo[1]= mval[1];
 | 
			
		||||
		}
 | 
			
		||||
		BIF_wait_for_statechange();
 | 
			
		||||
	}
 | 
			
		||||
			
 | 
			
		||||
	return but->retval;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* ************************************************ */
 | 
			
		||||
 | 
			
		||||
void uiSetButLock(int val, char *lockstr)
 | 
			
		||||
@@ -3476,6 +3535,9 @@ static int ui_do_button(uiBlock *block, uiBut *but, uiEvent *uevent)
 | 
			
		||||
	case BUT_COLORBAND:
 | 
			
		||||
		retval= ui_do_but_COLORBAND(but);
 | 
			
		||||
		break;
 | 
			
		||||
	case BUT_NORMAL:
 | 
			
		||||
		retval= ui_do_but_NORMAL(but);
 | 
			
		||||
		break;
 | 
			
		||||
		
 | 
			
		||||
#ifdef INTERNATIONAL
 | 
			
		||||
	case CHARTAB:
 | 
			
		||||
@@ -4432,9 +4494,9 @@ int uiDoBlocks(ListBase *lb, int event)
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			block->in_use= 1; // bit awkward, but now we can detect if frontbuf flush should be set
 | 
			
		||||
			retval= ui_do_block(block, &uevent);
 | 
			
		||||
			retval |= ui_do_block(block, &uevent); /* we 'or' because 2nd loop can return to here, and we we want 'out' to return */
 | 
			
		||||
			block->in_use= 0;
 | 
			
		||||
			if(retval==UI_EXIT_LOOP) break;
 | 
			
		||||
			if(retval & UI_EXIT_LOOP) break;
 | 
			
		||||
			
 | 
			
		||||
			/* now a new block could be created for menus, this is 
 | 
			
		||||
			   inserted in the beginning of a list */
 | 
			
		||||
 
 | 
			
		||||
@@ -1968,7 +1968,78 @@ static void ui_draw_but_COLORBAND(uiBut *but)
 | 
			
		||||
	glEnd();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void ui_draw_but_NORMAL(uiBut *but)
 | 
			
		||||
{
 | 
			
		||||
	static GLuint displist=0;
 | 
			
		||||
	int a, old[8];
 | 
			
		||||
	float vec0[3]={0.0f, 0.0f, 0.0f};
 | 
			
		||||
	float vec1[3]={1.0f, 1.0f, 1.0f};
 | 
			
		||||
	float dir[4], size;
 | 
			
		||||
	
 | 
			
		||||
	/* backdrop */
 | 
			
		||||
	BIF_ThemeColor(TH_BUT_NEUTRAL);
 | 
			
		||||
	uiSetRoundBox(15);
 | 
			
		||||
	gl_round_box(GL_POLYGON, but->x1, but->y1, but->x2, but->y2, 5.0f);
 | 
			
		||||
	
 | 
			
		||||
	/* sphere color */
 | 
			
		||||
	glEnable(GL_COLOR_MATERIAL);
 | 
			
		||||
	glColor3ub(200, 200, 200);
 | 
			
		||||
	glCullFace(GL_BACK); glEnable(GL_CULL_FACE);
 | 
			
		||||
	
 | 
			
		||||
	/* disable blender light */
 | 
			
		||||
	for(a=0; a<8; a++) {
 | 
			
		||||
		old[a]= glIsEnabled(GL_LIGHT0+a);
 | 
			
		||||
		glDisable(GL_LIGHT0+a);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/* own light */
 | 
			
		||||
	glEnable(GL_LIGHT7);
 | 
			
		||||
	glEnable(GL_LIGHTING);
 | 
			
		||||
	
 | 
			
		||||
	VECCOPY(dir, (float *)but->poin);
 | 
			
		||||
	dir[3]= 0.0f;	/* glLight needs 4 args, 0.0 is sun */
 | 
			
		||||
	glLightfv(GL_LIGHT7, GL_POSITION, dir); 
 | 
			
		||||
	glLightfv(GL_LIGHT7, GL_DIFFUSE, vec1); 
 | 
			
		||||
	glLightfv(GL_LIGHT7, GL_SPECULAR, vec0); 
 | 
			
		||||
	glLightf(GL_LIGHT7, GL_CONSTANT_ATTENUATION, 1.0f);
 | 
			
		||||
	glLightf(GL_LIGHT7, GL_LINEAR_ATTENUATION, 0.0f);
 | 
			
		||||
	
 | 
			
		||||
	/* transform to button */
 | 
			
		||||
	glPushMatrix();
 | 
			
		||||
	glTranslatef(but->x1 + 0.5f*(but->x2-but->x1), but->y1+ 0.5f*(but->y2-but->y1), 0.0f);
 | 
			
		||||
	size= (but->x2-but->x1)/200.f;
 | 
			
		||||
	glScalef(size, size, size);
 | 
			
		||||
			 
 | 
			
		||||
	if(displist==0) {
 | 
			
		||||
		GLUquadricObj	*qobj;
 | 
			
		||||
		
 | 
			
		||||
		displist= glGenLists(1);
 | 
			
		||||
		glNewList(displist, GL_COMPILE_AND_EXECUTE);
 | 
			
		||||
		
 | 
			
		||||
		qobj	= gluNewQuadric();
 | 
			
		||||
		gluQuadricDrawStyle(qobj, GLU_FILL); 
 | 
			
		||||
		glShadeModel(GL_SMOOTH);
 | 
			
		||||
		gluSphere( qobj, 100.0, 32, 24);
 | 
			
		||||
		glShadeModel(GL_FLAT);
 | 
			
		||||
		gluDeleteQuadric(qobj);  
 | 
			
		||||
		
 | 
			
		||||
		glEndList();
 | 
			
		||||
	}
 | 
			
		||||
	else glCallList(displist);
 | 
			
		||||
	
 | 
			
		||||
	glPopMatrix();
 | 
			
		||||
	glDisable(GL_LIGHTING);
 | 
			
		||||
	glDisable(GL_COLOR_MATERIAL);
 | 
			
		||||
	glDisable(GL_CULL_FACE);
 | 
			
		||||
	
 | 
			
		||||
	/* enable blender light */
 | 
			
		||||
	for(a=0; a<8; a++) {
 | 
			
		||||
		if(old[a])
 | 
			
		||||
			glEnable(GL_LIGHT0+a);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void ui_draw_roundbox(uiBut *but)
 | 
			
		||||
{
 | 
			
		||||
@@ -2089,6 +2160,9 @@ void ui_draw_but(uiBut *but)
 | 
			
		||||
	case BUT_COLORBAND:
 | 
			
		||||
		ui_draw_but_COLORBAND(but);
 | 
			
		||||
		break;
 | 
			
		||||
	case BUT_NORMAL:
 | 
			
		||||
		ui_draw_but_NORMAL(but);
 | 
			
		||||
		break;
 | 
			
		||||
		
 | 
			
		||||
	default:
 | 
			
		||||
		but->embossfunc(but->type, but->themecol, but->aspect, but->x1, but->y1, but->x2, but->y2, but->flag);
 | 
			
		||||
 
 | 
			
		||||
@@ -478,7 +478,7 @@ void myortho2(float x1, float x2, float y1, float y2)
 | 
			
		||||
	/* prevent opengl from generating errors */
 | 
			
		||||
	if(x1==x2) x2+=1.0;
 | 
			
		||||
	if(y1==y2) y2+=1.0;
 | 
			
		||||
	bwin_ortho(curswin, x1, x2, y1, y2, -1, 1);
 | 
			
		||||
	bwin_ortho(curswin, x1, x2, y1, y2, -100, 100);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void mywindow(float x1, float x2, float y1, float y2, float n, float f)
 | 
			
		||||
 
 | 
			
		||||
@@ -357,6 +357,7 @@ static void draw_tex_crop(Tex *tex)
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* temporal abuse; if id_code is -1 it only does texture.... solve! */
 | 
			
		||||
void BIF_preview_changed(short id_code)
 | 
			
		||||
{
 | 
			
		||||
	ScrArea *sa;
 | 
			
		||||
@@ -370,7 +371,7 @@ void BIF_preview_changed(short id_code)
 | 
			
		||||
					if (sbuts->ri) sbuts->ri->cury= 0;
 | 
			
		||||
					addafterqueue(sa->win, RENDERPREVIEW, 1);
 | 
			
		||||
				}
 | 
			
		||||
				else if(tab==TAB_SHADING_TEX && (id_code==ID_TE)) {
 | 
			
		||||
				else if(tab==TAB_SHADING_TEX && (id_code==ID_TE || id_code==-1)) {
 | 
			
		||||
					if (sbuts->ri) sbuts->ri->cury= 0;
 | 
			
		||||
					addafterqueue(sa->win, RENDERPREVIEW, 1);
 | 
			
		||||
				}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user