Exemple #1
0
void rna_Main_worlds_remove(Main *bmain, ReportList *reports, struct World *world)
{
	if(ID_REAL_USERS(world) <= 0)
		free_libblock(&bmain->world, world);
	else
		BKE_reportf(reports, RPT_ERROR, "World \"%s\" must have zero users to be removed, found %d.", world->id.name+2, ID_REAL_USERS(world));
}
Exemple #2
0
void rna_Main_textures_remove(Main *bmain, ReportList *reports, struct Tex *tex)
{
	if(ID_REAL_USERS(tex) <= 0)
		free_libblock(&bmain->tex, tex);
	else
		BKE_reportf(reports, RPT_ERROR, "Texture \"%s\" must have zero users to be removed, found %d.", tex->id.name+2, ID_REAL_USERS(tex));
}
Exemple #3
0
void rna_Main_curves_remove(Main *bmain, ReportList *reports, struct Curve *cu)
{
	if(ID_REAL_USERS(cu) <= 0)
		free_libblock(&bmain->curve, cu);
	else
		BKE_reportf(reports, RPT_ERROR, "Curve \"%s\" must have zero users to be removed, found %d.", cu->id.name+2, ID_REAL_USERS(cu));
}
Exemple #4
0
void rna_Main_metaballs_remove(Main *bmain, ReportList *reports, struct MetaBall *mb)
{
	if(ID_REAL_USERS(mb) <= 0)
		free_libblock(&bmain->mball, mb);
	else
		BKE_reportf(reports, RPT_ERROR, "MetaBall \"%s\" must have zero users to be removed, found %d.", mb->id.name+2, ID_REAL_USERS(mb));
}
Exemple #5
0
int id_unlink(ID *id, int test)
{
	Main *mainlib= G.main;
	ListBase *lb;

	switch(GS(id->name)) {
		case ID_TXT:
			if(test) return 1;
			unlink_text(mainlib, (Text*)id);
			break;
		case ID_GR:
			if(test) return 1;
			unlink_group((Group*)id);
			break;
		case ID_OB:
			if(test) return 1;
			unlink_object((Object*)id);
			break;
	}

	if(id->us == 0) {
		if(test) return 1;

		lb= which_libbase(mainlib, GS(id->name));
		free_libblock(lb, id);

		return 1;
	}

	return 0;
}
Exemple #6
0
void rna_Main_lattices_remove(Main *bmain, ReportList *reports, struct Lattice *lt)
{
	if(ID_REAL_USERS(lt) <= 0)
		free_libblock(&bmain->latt, lt);
	else
		BKE_reportf(reports, RPT_ERROR, "Lattice \"%s\" must have zero users to be removed, found %d.", lt->id.name+2, ID_REAL_USERS(lt));
}
Exemple #7
0
void rna_Main_brushes_remove(Main *bmain, ReportList *reports, struct Brush *brush)
{
	if(ID_REAL_USERS(brush) <= 0)
		free_libblock(&bmain->brush, brush);
	else
		BKE_reportf(reports, RPT_ERROR, "Brush \"%s\" must have zero users to be removed, found %d.", brush->id.name+2, ID_REAL_USERS(brush));
}
Exemple #8
0
void rna_Main_images_remove(Main *bmain, ReportList *reports, Image *image)
{
	if(ID_REAL_USERS(image) <= 0)
		free_libblock(&bmain->image, image);
	else
		BKE_reportf(reports, RPT_ERROR, "Image \"%s\" must have zero users to be removed, found %d.", image->id.name+2, ID_REAL_USERS(image));

	/* XXX python now has invalid pointer? */
}
Exemple #9
0
void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp)
{
	if(ID_REAL_USERS(lamp) <= 0)
		free_libblock(&bmain->lamp, lamp);
	else
		BKE_reportf(reports, RPT_ERROR, "Lamp \"%s\" must have zero users to be removed, found %d.", lamp->id.name+2, ID_REAL_USERS(lamp));

	/* XXX python now has invalid pointer? */
}
Exemple #10
0
void rna_Main_meshes_remove(Main *bmain, ReportList *reports, Mesh *mesh)
{
	if(ID_REAL_USERS(mesh) <= 0)
		free_libblock(&bmain->mesh, mesh);
	else
		BKE_reportf(reports, RPT_ERROR, "Mesh \"%s\" must have zero users to be removed, found %d.", mesh->id.name+2, ID_REAL_USERS(mesh));

	/* XXX python now has invalid pointer? */
}
Exemple #11
0
void rna_Main_nodetree_remove(Main *bmain, ReportList *reports, struct bNodeTree *tree)
{
	if(ID_REAL_USERS(tree) <= 0)
		free_libblock(&bmain->nodetree, tree);
	else
		BKE_reportf(reports, RPT_ERROR, "Node Tree \"%s\" must have zero users to be removed, found %d.", tree->id.name+2, ID_REAL_USERS(tree));

	/* XXX python now has invalid pointer? */
}
Exemple #12
0
void rna_Main_materials_remove(Main *bmain, ReportList *reports, struct Material *material)
{
	if(ID_REAL_USERS(material) <= 0)
		free_libblock(&bmain->mat, material);
	else
		BKE_reportf(reports, RPT_ERROR, "Material \"%s\" must have zero users to be removed, found %d.", material->id.name+2, ID_REAL_USERS(material));

	/* XXX python now has invalid pointer? */
}
Exemple #13
0
void rna_Main_cameras_remove(Main *bmain, ReportList *reports, struct Camera *camera)
{
	if(ID_REAL_USERS(camera) <= 0)
		free_libblock(&bmain->camera, camera);
	else
		BKE_reportf(reports, RPT_ERROR, "Camera \"%s\" must have zero users to be removed, found %d.", camera->id.name+2, ID_REAL_USERS(camera));

	/* XXX python now has invalid pointer? */
}
Exemple #14
0
void rna_Main_fonts_remove(Main *bmain, ReportList *reports, VFont *vfont)
{
	if(ID_REAL_USERS(vfont) <= 0)
		free_libblock(&bmain->vfont, vfont);
	else
		BKE_reportf(reports, RPT_ERROR, "Font \"%s\" must have zero users to be removed, found %d.", vfont->id.name+2, ID_REAL_USERS(vfont));

	/* XXX python now has invalid pointer? */
}
Exemple #15
0
void rna_Main_actions_remove(Main *bmain, ReportList *reports, bAction *act)
{
	if(ID_REAL_USERS(act) <= 0)
		free_libblock(&bmain->action, act);
	else
		BKE_reportf(reports, RPT_ERROR, "Action \"%s\" must have zero users to be removed, found %d.", act->id.name+2, ID_REAL_USERS(act));

	/* XXX python now has invalid pointer? */
}
Exemple #16
0
void rna_Main_particles_remove(Main *bmain, ReportList *reports, ParticleSettings *part)
{
	if(ID_REAL_USERS(part) <= 0)
		free_libblock(&bmain->particle, part);
	else
		BKE_reportf(reports, RPT_ERROR, "Particle Settings \"%s\" must have zero users to be removed, found %d.", part->id.name+2, ID_REAL_USERS(part));

	/* XXX python now has invalid pointer? */
}
Exemple #17
0
void rna_Main_armatures_remove(Main *bmain, ReportList *reports, bArmature *arm)
{
	if(ID_REAL_USERS(arm) <= 0)
		free_libblock(&bmain->armature, arm);
	else
		BKE_reportf(reports, RPT_ERROR, "Armature \"%s\" must have zero users to be removed, found %d.", arm->id.name+2, ID_REAL_USERS(arm));

	/* XXX python now has invalid pointer? */
}
Exemple #18
0
void rna_Main_speakers_remove(Main *bmain, ReportList *reports, Speaker *speaker)
{
	if(ID_REAL_USERS(speaker) <= 0)
		free_libblock(&bmain->speaker, speaker);
	else
		BKE_reportf(reports, RPT_ERROR, "Speaker \"%s\" must have zero users to be removed, found %d.", speaker->id.name+2, ID_REAL_USERS(speaker));

	/* XXX python now has invalid pointer? */
}
Exemple #19
0
void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *object)
{
	if(ID_REAL_USERS(object) <= 0) {
		unlink_object(object); /* needed or ID pointers to this are not cleared */
		free_libblock(&bmain->object, object);
	}
	else {
		BKE_reportf(reports, RPT_ERROR, "Object \"%s\" must have zero users to be removed, found %d.", object->id.name+2, ID_REAL_USERS(object));
	}
}
Exemple #20
0
Object* DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera, Scene *sce)
{
	const COLLADAFW::UniqueId& cam_uid = camera->getInstanciatedObjectId();
	if (uid_camera_map.find(cam_uid) == uid_camera_map.end()) {	
		fprintf(stderr, "Couldn't find camera by UID.\n");
		return NULL;
	}
	Object *ob = add_object(sce, OB_CAMERA);
	Camera *cam = uid_camera_map[cam_uid];
	Camera *old_cam = (Camera*)ob->data;
	ob->data = cam;
	old_cam->id.us--;
	if (old_cam->id.us == 0)
		free_libblock(&G.main->camera, old_cam);
	return ob;
}
Exemple #21
0
void free_libblock_us(ListBase *lb, void *idv)		/* test users */
{
	ID *id= idv;
	
	id->us--;

	if(id->us<0) {
		if(id->lib) printf("ERROR block %s %s users %d\n", id->lib->name, id->name, id->us);
		else printf("ERROR block %s users %d\n", id->name, id->us);
	}
	if(id->us==0) {
		if( GS(id->name)==ID_OB ) unlink_object((Object *)id);
		
		free_libblock(lb, id);
	}
}
Exemple #22
0
Object* DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Scene *sce)
{
	const COLLADAFW::UniqueId& lamp_uid = lamp->getInstanciatedObjectId();
	if (uid_lamp_map.find(lamp_uid) == uid_lamp_map.end()) {	
		fprintf(stderr, "Couldn't find lamp by UID. \n");
		return NULL;
	}
	Object *ob = add_object(sce, OB_LAMP);
	Lamp *la = uid_lamp_map[lamp_uid];
	Lamp *old_lamp = (Lamp*)ob->data;
	ob->data = la;
	old_lamp->id.us--;
	if (old_lamp->id.us == 0)
		free_libblock(&G.main->lamp, old_lamp);
	return ob;
}
Exemple #23
0
void free_main(Main *mainvar)
{
	/* also call when reading a file, erase all, etc */
	ListBase *lbarray[MAX_LIBARRAY];
	int a;

	a= set_listbasepointers(mainvar, lbarray);
	while(a--) {
		ListBase *lb= lbarray[a];
		ID *id;
		
		while ( (id= lb->first) ) {
			free_libblock(lb, id);
		}
	}

	MEM_freeN(mainvar);
}
Exemple #24
0
void rna_Main_groups_remove(Main *bmain, Group *group)
{
	unlink_group(group);
	free_libblock(&bmain->group, group);
	/* XXX python now has invalid pointer? */
}
Exemple #25
0
/* returns 1 if its OK */
int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
{
    bNodeLink *link, *linkn;
    bNode *node, *nextn;
    bNodeTree *ngroup, *wgroup;
    ListBase anim_basepaths = {NULL, NULL};

    ngroup= (bNodeTree *)gnode->id;
    if(ngroup==NULL) return 0;

    /* clear new pointers, set in copytree */
    for(node= ntree->nodes.first; node; node= node->next)
        node->new_node= NULL;

    /* wgroup is a temporary copy of the NodeTree we're merging in
     *	- all of wgroup's nodes are transferred across to their new home
     *	- ngroup (i.e. the source NodeTree) is left unscathed
     */
    wgroup= ntreeCopyTree(ngroup);

    /* add the nodes into the ntree */
    for(node= wgroup->nodes.first; node; node= nextn) {
        nextn= node->next;

        /* keep track of this node's RNA "base" path (the part of the pat identifying the node)
         * if the old nodetree has animation data which potentially covers this node
         */
        if (wgroup->adt) {
            PointerRNA ptr;
            char *path;

            RNA_pointer_create(&wgroup->id, &RNA_Node, node, &ptr);
            path = RNA_path_from_ID_to_struct(&ptr);

            if (path)
                BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
        }

        /* migrate node */
        BLI_remlink(&wgroup->nodes, node);
        BLI_addtail(&ntree->nodes, node);

        node->locx+= gnode->locx;
        node->locy+= gnode->locy;

        node->flag |= NODE_SELECT;
    }

    /* restore external links to and from the gnode */
    for(link= ntree->links.first; link; link= link->next) {
        if (link->fromnode==gnode) {
            if (link->fromsock->groupsock) {
                bNodeSocket *gsock= link->fromsock->groupsock;
                if (gsock->link) {
                    if (gsock->link->fromnode) {
                        /* NB: using the new internal copies here! the groupsock pointer still maps to the old tree */
                        link->fromnode = (gsock->link->fromnode ? gsock->link->fromnode->new_node : NULL);
                        link->fromsock = gsock->link->fromsock->new_sock;
                    }
                    else {
                        /* group output directly maps to group input */
                        bNodeSocket *insock= node_group_find_input(gnode, gsock->link->fromsock);
                        if (insock->link) {
                            link->fromnode = insock->link->fromnode;
                            link->fromsock = insock->link->fromsock;
                        }
                    }
                }
                else {
                    /* copy the default input value from the group socket default to the external socket */
                    convert_socket_value(gsock, link->tosock);
                }
            }
        }
    }
    /* remove internal output links, these are not used anymore */
    for(link=wgroup->links.first; link; link= linkn) {
        linkn = link->next;
        if (!link->tonode)
            nodeRemLink(wgroup, link);
    }
    /* restore links from internal nodes */
    for(link= wgroup->links.first; link; link= link->next) {
        /* indicates link to group input */
        if (!link->fromnode) {
            /* NB: can't use find_group_node_input here,
             * because gnode sockets still point to the old tree!
             */
            bNodeSocket *insock;
            for (insock= gnode->inputs.first; insock; insock= insock->next)
                if (insock->groupsock->new_sock == link->fromsock)
                    break;
            if (insock->link) {
                link->fromnode = insock->link->fromnode;
                link->fromsock = insock->link->fromsock;
            }
            else {
                /* copy the default input value from the group node socket default to the internal socket */
                convert_socket_value(insock, link->tosock);
                nodeRemLink(wgroup, link);
            }
        }
    }

    /* add internal links to the ntree */
    for(link= wgroup->links.first; link; link= linkn) {
        linkn= link->next;
        BLI_remlink(&wgroup->links, link);
        BLI_addtail(&ntree->links, link);
    }

    /* and copy across the animation */
    if (wgroup->adt) {
        LinkData *ld, *ldn=NULL;
        bAction *waction;

        /* firstly, wgroup needs to temporary dummy action that can be destroyed, as it shares copies */
        waction = wgroup->adt->action = copy_action(wgroup->adt->action);

        /* now perform the moving */
        BKE_animdata_separate_by_basepath(&wgroup->id, &ntree->id, &anim_basepaths);

        /* paths + their wrappers need to be freed */
        for (ld = anim_basepaths.first; ld; ld = ldn) {
            ldn = ld->next;

            MEM_freeN(ld->data);
            BLI_freelinkN(&anim_basepaths, ld);
        }

        /* free temp action too */
        free_libblock(&G.main->action, waction);
    }

    /* delete the group instance. this also removes old input links! */
    nodeFreeNode(ntree, gnode);

    /* free the group tree (takes care of user count) */
    free_libblock(&G.main->nodetree, wgroup);

    ntree->update |= NTREE_UPDATE_NODES|NTREE_UPDATE_LINKS;
    ntreeUpdateTree(ntree);

    return 1;
}
Exemple #26
0
void rna_Main_texts_remove(Main *bmain, Text *text)
{
	unlink_text(bmain, text);
	free_libblock(&bmain->text, text);
	/* XXX python now has invalid pointer? */
}