style cleanup: nodes
This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
|
||||
int sh_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
|
||||
{
|
||||
return (strcmp(ntree->idname, "ShaderNodeTree")==0);
|
||||
return STREQ(ntree->idname, "ShaderNodeTree");
|
||||
}
|
||||
|
||||
void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass, short flag)
|
||||
@@ -54,16 +54,16 @@ void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, shor
|
||||
|
||||
void nodestack_get_vec(float *in, short type_in, bNodeStack *ns)
|
||||
{
|
||||
float *from= ns->vec;
|
||||
float *from = ns->vec;
|
||||
|
||||
if (type_in==SOCK_FLOAT) {
|
||||
if (ns->sockettype==SOCK_FLOAT)
|
||||
*in= *from;
|
||||
if (type_in == SOCK_FLOAT) {
|
||||
if (ns->sockettype == SOCK_FLOAT)
|
||||
*in = *from;
|
||||
else
|
||||
*in= (from[0]+from[1]+from[2]) / 3.0f;
|
||||
*in = (from[0] + from[1] + from[2]) / 3.0f;
|
||||
}
|
||||
else if (type_in==SOCK_VECTOR) {
|
||||
if (ns->sockettype==SOCK_FLOAT) {
|
||||
else if (type_in == SOCK_VECTOR) {
|
||||
if (ns->sockettype == SOCK_FLOAT) {
|
||||
in[0] = from[0];
|
||||
in[1] = from[0];
|
||||
in[2] = from[0];
|
||||
@@ -73,10 +73,10 @@ void nodestack_get_vec(float *in, short type_in, bNodeStack *ns)
|
||||
}
|
||||
}
|
||||
else { /* type_in==SOCK_RGBA */
|
||||
if (ns->sockettype==SOCK_RGBA) {
|
||||
if (ns->sockettype == SOCK_RGBA) {
|
||||
copy_v4_v4(in, from);
|
||||
}
|
||||
else if (ns->sockettype==SOCK_FLOAT) {
|
||||
else if (ns->sockettype == SOCK_FLOAT) {
|
||||
in[0] = from[0];
|
||||
in[1] = from[0];
|
||||
in[2] = from[0];
|
||||
@@ -99,33 +99,33 @@ void ntreeShaderGetTexcoMode(bNodeTree *ntree, int r_mode, short *texco, int *mo
|
||||
int a;
|
||||
|
||||
for (node = ntree->nodes.first; node; node = node->next) {
|
||||
if (node->type==SH_NODE_TEXTURE) {
|
||||
if (node->type == SH_NODE_TEXTURE) {
|
||||
if ((r_mode & R_OSA) && node->id) {
|
||||
Tex *tex= (Tex *)node->id;
|
||||
Tex *tex = (Tex *)node->id;
|
||||
if (ELEM(tex->type, TEX_IMAGE, TEX_ENVMAP)) {
|
||||
*texco |= TEXCO_OSA|NEED_UV;
|
||||
*texco |= TEXCO_OSA | NEED_UV;
|
||||
}
|
||||
}
|
||||
/* usability exception... without input we still give the node orcos */
|
||||
sock= node->inputs.first;
|
||||
if (sock==NULL || sock->link==NULL)
|
||||
*texco |= TEXCO_ORCO|NEED_UV;
|
||||
sock = node->inputs.first;
|
||||
if (sock == NULL || sock->link == NULL)
|
||||
*texco |= TEXCO_ORCO | NEED_UV;
|
||||
}
|
||||
else if (node->type==SH_NODE_GEOMETRY) {
|
||||
else if (node->type == SH_NODE_GEOMETRY) {
|
||||
/* note; sockets always exist for the given type! */
|
||||
for (a=0, sock= node->outputs.first; sock; sock= sock->next, a++) {
|
||||
for (a = 0, sock = node->outputs.first; sock; sock = sock->next, a++) {
|
||||
if (sock->flag & SOCK_IN_USE) {
|
||||
switch (a) {
|
||||
case GEOM_OUT_GLOB:
|
||||
*texco |= TEXCO_GLOB|NEED_UV; break;
|
||||
*texco |= TEXCO_GLOB | NEED_UV; break;
|
||||
case GEOM_OUT_VIEW:
|
||||
*texco |= TEXCO_VIEW|NEED_UV; break;
|
||||
*texco |= TEXCO_VIEW | NEED_UV; break;
|
||||
case GEOM_OUT_ORCO:
|
||||
*texco |= TEXCO_ORCO|NEED_UV; break;
|
||||
*texco |= TEXCO_ORCO | NEED_UV; break;
|
||||
case GEOM_OUT_UV:
|
||||
*texco |= TEXCO_UV|NEED_UV; break;
|
||||
*texco |= TEXCO_UV | NEED_UV; break;
|
||||
case GEOM_OUT_NORMAL:
|
||||
*texco |= TEXCO_NORM|NEED_UV; break;
|
||||
*texco |= TEXCO_NORM | NEED_UV; break;
|
||||
case GEOM_OUT_VCOL:
|
||||
*texco |= NEED_UV; *mode |= MA_VERTEXCOL; break;
|
||||
case GEOM_OUT_VCOL_ALPHA:
|
||||
@@ -142,34 +142,34 @@ void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns)
|
||||
memset(gs, 0, sizeof(*gs));
|
||||
|
||||
copy_v4_v4(gs->vec, ns->vec);
|
||||
gs->link= ns->data;
|
||||
gs->link = ns->data;
|
||||
|
||||
if (type == SOCK_FLOAT)
|
||||
gs->type= GPU_FLOAT;
|
||||
gs->type = GPU_FLOAT;
|
||||
else if (type == SOCK_VECTOR)
|
||||
gs->type= GPU_VEC3;
|
||||
gs->type = GPU_VEC3;
|
||||
else if (type == SOCK_RGBA)
|
||||
gs->type= GPU_VEC4;
|
||||
gs->type = GPU_VEC4;
|
||||
else if (type == SOCK_SHADER)
|
||||
gs->type= GPU_VEC4;
|
||||
gs->type = GPU_VEC4;
|
||||
else
|
||||
gs->type= GPU_NONE;
|
||||
gs->type = GPU_NONE;
|
||||
|
||||
gs->name = "";
|
||||
gs->hasinput= ns->hasinput && ns->data;
|
||||
gs->hasinput = ns->hasinput && ns->data;
|
||||
/* XXX Commented out the ns->data check here, as it seems it's not always set,
|
||||
* even though there *is* a valid connection/output... But that might need
|
||||
* further investigation.
|
||||
*/
|
||||
gs->hasoutput= ns->hasoutput /*&& ns->data*/;
|
||||
gs->sockettype= ns->sockettype;
|
||||
gs->hasoutput = ns->hasoutput /*&& ns->data*/;
|
||||
gs->sockettype = ns->sockettype;
|
||||
}
|
||||
|
||||
void node_data_from_gpu_stack(bNodeStack *ns, GPUNodeStack *gs)
|
||||
{
|
||||
copy_v4_v4(ns->vec, gs->vec);
|
||||
ns->data= gs->link;
|
||||
ns->sockettype= gs->sockettype;
|
||||
ns->data = gs->link;
|
||||
ns->sockettype = gs->sockettype;
|
||||
}
|
||||
|
||||
static void gpu_stack_from_data_list(GPUNodeStack *gs, ListBase *sockets, bNodeStack **ns)
|
||||
@@ -177,10 +177,10 @@ static void gpu_stack_from_data_list(GPUNodeStack *gs, ListBase *sockets, bNodeS
|
||||
bNodeSocket *sock;
|
||||
int i;
|
||||
|
||||
for (sock=sockets->first, i=0; sock; sock = sock->next, i++)
|
||||
for (sock = sockets->first, i = 0; sock; sock = sock->next, i++)
|
||||
node_gpu_stack_from_data(&gs[i], sock->type, ns[i]);
|
||||
|
||||
gs[i].type= GPU_NONE;
|
||||
gs[i].type = GPU_NONE;
|
||||
}
|
||||
|
||||
static void data_from_gpu_stack_list(ListBase *sockets, bNodeStack **ns, GPUNodeStack *gs)
|
||||
@@ -188,7 +188,7 @@ static void data_from_gpu_stack_list(ListBase *sockets, bNodeStack **ns, GPUNode
|
||||
bNodeSocket *sock;
|
||||
int i;
|
||||
|
||||
for (sock=sockets->first, i=0; sock; sock = sock->next, i++)
|
||||
for (sock = sockets->first, i = 0; sock; sock = sock->next, i++)
|
||||
node_data_from_gpu_stack(ns[i], &gs[i]);
|
||||
}
|
||||
|
||||
@@ -206,8 +206,8 @@ bNode *nodeGetActiveTexture(bNodeTree *ntree)
|
||||
|
||||
/* node active texture node in this tree, look inside groups */
|
||||
for (node = ntree->nodes.first; node; node = node->next) {
|
||||
if (node->type==NODE_GROUP) {
|
||||
tnode = nodeGetActiveTexture((bNodeTree*)node->id);
|
||||
if (node->type == NODE_GROUP) {
|
||||
tnode = nodeGetActiveTexture((bNodeTree *)node->id);
|
||||
if (tnode)
|
||||
return tnode;
|
||||
}
|
||||
@@ -222,19 +222,19 @@ void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs)
|
||||
bNode *node;
|
||||
int n;
|
||||
bNodeStack *stack;
|
||||
bNodeStack *nsin[MAX_SOCKET]; /* arbitrary... watch this */
|
||||
bNodeStack *nsout[MAX_SOCKET]; /* arbitrary... watch this */
|
||||
bNodeStack *nsin[MAX_SOCKET]; /* arbitrary... watch this */
|
||||
bNodeStack *nsout[MAX_SOCKET]; /* arbitrary... watch this */
|
||||
GPUNodeStack gpuin[MAX_SOCKET + 1], gpuout[MAX_SOCKET + 1];
|
||||
int do_it;
|
||||
|
||||
stack= exec->stack;
|
||||
stack = exec->stack;
|
||||
|
||||
for (n=0, nodeexec= exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) {
|
||||
for (n = 0, nodeexec = exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) {
|
||||
node = nodeexec->node;
|
||||
|
||||
do_it = FALSE;
|
||||
/* for groups, only execute outputs for edited group */
|
||||
if (node->typeinfo->nclass==NODE_CLASS_OUTPUT) {
|
||||
if (node->typeinfo->nclass == NODE_CLASS_OUTPUT) {
|
||||
if (do_outputs && (node->flag & NODE_DO_OUTPUT))
|
||||
do_it = TRUE;
|
||||
}
|
||||
@@ -255,10 +255,10 @@ void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs)
|
||||
|
||||
void node_shader_gpu_tex_mapping(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *UNUSED(out))
|
||||
{
|
||||
NodeTexBase *base= node->storage;
|
||||
TexMapping *texmap= &base->tex_mapping;
|
||||
float domin= (texmap->flag & TEXMAP_CLIP_MIN) != 0;
|
||||
float domax= (texmap->flag & TEXMAP_CLIP_MAX) != 0;
|
||||
NodeTexBase *base = node->storage;
|
||||
TexMapping *texmap = &base->tex_mapping;
|
||||
float domin = (texmap->flag & TEXMAP_CLIP_MIN) != 0;
|
||||
float domax = (texmap->flag & TEXMAP_CLIP_MAX) != 0;
|
||||
|
||||
if (domin || domax || !(texmap->flag & TEXMAP_UNIT_MATRIX)) {
|
||||
GPUNodeLink *tmat = GPU_uniform((float *)texmap->mat);
|
||||
|
||||
Reference in New Issue
Block a user