Example #1
0
/* local tree then owns all compbufs */
static void localize(bNodeTree *localtree, bNodeTree *ntree)
{
	bNode *node, *node_next;
	bNodeSocket *sock;
	
	for (node= ntree->nodes.first; node; node= node->next) {
		/* ensure new user input gets handled ok */
		node->need_exec= 0;
		
		/* move over the compbufs */
		/* right after ntreeCopyTree() oldsock pointers are valid */
		
		if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
			if (node->id) {
				if (node->flag & NODE_DO_OUTPUT)
					node->new_node->id= (ID *)BKE_image_copy((Image *)node->id);
				else
					node->new_node->id= NULL;
			}
		}
		
		for (sock= node->outputs.first; sock; sock= sock->next) {
			sock->new_sock->cache= sock->cache;
			compbuf_set_node(sock->new_sock->cache, node->new_node);
			
			sock->cache= NULL;
			sock->new_sock->new_sock= sock;
		}
	}
	
	/* replace muted nodes by internal links */
	for (node= localtree->nodes.first; node; node= node_next) {
		node_next = node->next;
		
		if (node->flag & NODE_MUTED) {
			/* make sure the update tag isn't lost when removing the muted node.
			 * propagate this to all downstream nodes.
			 */
			if (node->need_exec) {
				bNodeLink *link;
				for (link=localtree->links.first; link; link=link->next)
					if (link->fromnode==node && link->tonode)
						link->tonode->need_exec = 1;
			}
			
			nodeInternalRelink(localtree, node);
			nodeFreeNode(localtree, node);
		}
	}
}
Example #2
0
int id_copy(ID *id, ID **newid, int test)
{
    if (!test) *newid = NULL;

    /* conventions:
     * - make shallow copy, only this ID block
     * - id.us of the new ID is set to 1 */
    switch (GS(id->name)) {
    case ID_SCE:
        return 0; /* can't be copied from here */
    case ID_LI:
        return 0; /* can't be copied from here */
    case ID_OB:
        if (!test) *newid = (ID *)BKE_object_copy((Object *)id);
        return 1;
    case ID_ME:
        if (!test) *newid = (ID *)BKE_mesh_copy((Mesh *)id);
        return 1;
    case ID_CU:
        if (!test) *newid = (ID *)BKE_curve_copy((Curve *)id);
        return 1;
    case ID_MB:
        if (!test) *newid = (ID *)BKE_mball_copy((MetaBall *)id);
        return 1;
    case ID_MA:
        if (!test) *newid = (ID *)BKE_material_copy((Material *)id);
        return 1;
    case ID_TE:
        if (!test) *newid = (ID *)BKE_texture_copy((Tex *)id);
        return 1;
    case ID_IM:
        if (!test) *newid = (ID *)BKE_image_copy((Image *)id);
        return 1;
    case ID_LT:
        if (!test) *newid = (ID *)BKE_lattice_copy((Lattice *)id);
        return 1;
    case ID_LA:
        if (!test) *newid = (ID *)BKE_lamp_copy((Lamp *)id);
        return 1;
    case ID_SPK:
        if (!test) *newid = (ID *)BKE_speaker_copy((Speaker *)id);
        return 1;
    case ID_CA:
        if (!test) *newid = (ID *)BKE_camera_copy((Camera *)id);
        return 1;
    case ID_IP:
        return 0; /* deprecated */
    case ID_KE:
        if (!test) *newid = (ID *)BKE_key_copy((Key *)id);
        return 1;
    case ID_WO:
        if (!test) *newid = (ID *)BKE_world_copy((World *)id);
        return 1;
    case ID_SCR:
        return 0; /* can't be copied from here */
    case ID_VF:
        return 0; /* not implemented */
    case ID_TXT:
        if (!test) *newid = (ID *)BKE_text_copy((Text *)id);
        return 1;
    case ID_SCRIPT:
        return 0; /* deprecated */
    case ID_SO:
        return 0; /* not implemented */
    case ID_GR:
        if (!test) *newid = (ID *)BKE_group_copy((Group *)id);
        return 1;
    case ID_AR:
        if (!test) *newid = (ID *)BKE_armature_copy((bArmature *)id);
        return 1;
    case ID_AC:
        if (!test) *newid = (ID *)BKE_action_copy((bAction *)id);
        return 1;
    case ID_NT:
        if (!test) *newid = (ID *)ntreeCopyTree((bNodeTree *)id);
        return 1;
    case ID_BR:
        if (!test) *newid = (ID *)BKE_brush_copy((Brush *)id);
        return 1;
    case ID_PA:
        if (!test) *newid = (ID *)BKE_particlesettings_copy((ParticleSettings *)id);
        return 1;
    case ID_WM:
        return 0; /* can't be copied from here */
    case ID_GD:
        return 0; /* not implemented */
    }

    return 0;
}