Example #1
0
/* used everywhere in blenkernel and text.c */
void *copy_libblock(void *rt)
{
	ID *idn, *id;
	ListBase *lb;
	char *cp, *cpn;
	int idn_len;
	
	id= rt;

	lb= wich_libbase(G.main, GS(id->name));
	idn= alloc_libblock(lb, GS(id->name), id->name+2);
	
	if(idn==NULL) {
		printf("ERROR: Illegal ID name for %s (Crashing now)\n", id->name);
	}
	
	idn_len= MEM_allocN_len(idn);
	if(idn_len - sizeof(ID) > 0) {
		cp= (char *)id;
		cpn= (char *)idn;
		memcpy(cpn+sizeof(ID), cp+sizeof(ID), idn_len - sizeof(ID));
	}
	
	id->newid= idn;
	idn->flag |= LIB_NEW;
	if (id->properties) idn->properties = IDP_CopyProperty(id->properties);
	
	/* the duplicate should get a copy of the animdata */
	id_copy_animdata(idn);
	
	return idn;
}
Example #2
0
/* used everywhere in blenkernel */
void *copy_libblock(void *rt)
{
	ID *idn, *id;
	ListBase *lb;
	char *cp, *cpn;
	size_t idn_len;
	
	id= rt;

	lb= which_libbase(G.main, GS(id->name));
	idn= alloc_libblock(lb, GS(id->name), id->name+2);

	assert(idn != NULL);

	idn_len= MEM_allocN_len(idn);
	if((int)idn_len - (int)sizeof(ID) > 0) { /* signed to allow neg result */
		cp= (char *)id;
		cpn= (char *)idn;
		memcpy(cpn+sizeof(ID), cp+sizeof(ID), idn_len - sizeof(ID));
	}
	
	id->newid= idn;
	idn->flag |= LIB_NEW;

	copy_libblock_data(idn, id, FALSE);
	
	return idn;
}
Example #3
0
File: world.c Project: jinjoh/NOOR
World *add_world(char *name)
{
	World *wrld;

	wrld= alloc_libblock(&G.main->world, ID_WO, name);
	
	wrld->horr= 0.25f;
	wrld->horg= 0.25f;
	wrld->horb= 0.25f;
	wrld->zenr= 0.1f;
	wrld->zeng= 0.1f;
	wrld->zenb= 0.1f;
	wrld->skytype= 0;
	wrld->stardist= 15.0f;
	wrld->starsize= 2.0f;
	
	wrld->exp= 0.0f;
	wrld->exposure=wrld->range= 1.0f;

	wrld->aodist= 10.0f;
	wrld->aosamp= 5;
	wrld->aoenergy= 1.0f;
	wrld->aobias= 0.05f;
	wrld->ao_samp_method = WO_AOSAMP_HAMMERSLEY;	
	wrld->ao_approx_error= 0.25f;
	
	wrld->preview = NULL;

	return wrld;
}
Example #4
0
bAction *add_empty_action(const char name[])
{
	bAction *act;
	
	act= alloc_libblock(&G.main->action, ID_AC, name);
	
	return act;
}	
Example #5
0
File: group.c Project: jinjoh/NOOR
Group *add_group(char *name)
{
	Group *group;
	
	group = alloc_libblock(&G.main->group, ID_GR, name);
	group->layer= (1<<20)-1;
	return group;
}
Example #6
0
Material *add_material(const char *name)
{
	Material *ma;

	ma= alloc_libblock(&G.main->mat, ID_MA, name);
	
	init_material(ma);
	
	return ma;	
}
Example #7
0
Tex *add_texture(const char *name)
{
	Main *bmain= G.main;
	Tex *tex;

	tex= alloc_libblock(&bmain->tex, ID_TE, name);
	
	default_tex(tex);
	
	return tex;
}
Example #8
0
void *add_lamp(const char *name)
{
	Lamp *la;
	
	la=  alloc_libblock(&G.main->lamp, ID_LA, name);
	
	la->r= la->g= la->b= la->k= 1.0f;
	la->haint= la->energy= 1.0f;
	la->dist= 25.0f;
	la->spotsize= 45.0f;
	la->spotblend= 0.15f;
	la->att2= 1.0f;
	la->mode= LA_SHAD_BUF;
	la->bufsize= 512;
	la->clipsta= 0.5f;
	la->clipend= 40.0f;
	la->shadspotsize= 45.0f;
	la->samp= 3;
	la->bias= 1.0f;
	la->soft= 3.0f;
	la->compressthresh= 0.05f;
	la->ray_samp= la->ray_sampy= la->ray_sampz= 1; 
	la->area_size=la->area_sizey=la->area_sizez= 1.0f; 
	la->buffers= 1;
	la->buftype= LA_SHADBUF_HALFWAY;
	la->ray_samp_method = LA_SAMP_HALTON;
	la->adapt_thresh = 0.001f;
	la->preview=NULL;
	la->falloff_type = LA_FALLOFF_INVSQUARE;
	la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f);
	la->sun_effect_type = 0;
	la->horizon_brightness = 1.0;
	la->spread = 1.0;
	la->sun_brightness = 1.0;
	la->sun_size = 1.0;
	la->backscattered_light = 1.0f;
	la->atm_turbidity = 2.0f;
	la->atm_inscattering_factor = 1.0f;
	la->atm_extinction_factor = 1.0f;
	la->atm_distance_factor = 1.0f;
	la->sun_intensity = 1.0f;
	la->skyblendtype= MA_RAMP_ADD;
	la->skyblendfac= 1.0f;
	la->sky_colorspace= BLI_XYZ_CIE;
	la->sky_exposure= 1.0f;
	
	curvemapping_initialize(la->curfalloff);
	return la;
}
Example #9
0
Mesh *add_mesh(const char *name)
{
	Mesh *me;
	
	me= alloc_libblock(&G.main->mesh, ID_ME, name);
	
	me->size[0]= me->size[1]= me->size[2]= 1.0;
	me->smoothresh= 30;
	me->texflag= AUTOSPACE;
	me->flag= ME_TWOSIDED;
	me->bb= unit_boundbox();
	me->drawflag= ME_DRAWEDGES|ME_DRAWFACES|ME_DRAWCREASES;
	
	return me;
}
Example #10
0
Lattice *add_lattice(const char *name)
{
	Lattice *lt;
	
	lt= alloc_libblock(&G.main->latt, ID_LT, name);
	
	lt->flag= LT_GRID;
	
	lt->typeu= lt->typev= lt->typew= KEY_BSPLINE;
	
	lt->def= MEM_callocN(sizeof(BPoint), "lattvert"); /* temporary */
	resizelattice(lt, 2, 2, 2, NULL);	/* creates a uniform lattice */
		
	return lt;
}
Example #11
0
File: wm.c Project: mik0001/Blender
/* on startup, it adds all data, for matching */
void wm_add_default(bContext *C)
{
	wmWindowManager *wm= alloc_libblock(&CTX_data_main(C)->wm, ID_WM, "WinMan");
	wmWindow *win;
	bScreen *screen= CTX_wm_screen(C); /* XXX from file read hrmf */
	
	CTX_wm_manager_set(C, wm);
	win= wm_window_new(C);
	win->screen= screen;
	screen->winid= win->winid;
	BLI_strncpy(win->screenname, screen->id.name+2, sizeof(win->screenname));
	
	wm->winactive= win;
	wm->file_saved= 1;
	wm_window_make_drawable(C, win); 
}
Example #12
0
void *add_camera(const char *name)
{
	Camera *cam;
	
	cam=  alloc_libblock(&G.main->camera, ID_CA, name);

	cam->lens= 35.0f;
	cam->sensor_x= 32.0f;
	cam->sensor_y= 18.0f;
	cam->clipsta= 0.1f;
	cam->clipend= 100.0f;
	cam->drawsize= 0.5f;
	cam->ortho_scale= 6.0;
	cam->flag |= CAM_SHOWPASSEPARTOUT;
	cam->passepartalpha = 0.5f;
	
	return cam;
}
Example #13
0
Brush *add_brush(const char *name)
{
	Brush *brush;

	brush= alloc_libblock(&G.main->brush, ID_BR, name);

	/* enable fake user by default */
	brush->id.flag |= LIB_FAKEUSER;

	brush_set_defaults(brush);

	brush->sculpt_tool = SCULPT_TOOL_DRAW; /* sculpting defaults to the draw tool for new brushes */

	 /* the default alpha falloff curve */
	brush_curve_preset(brush, CURVE_PRESET_SMOOTH);

	return brush;
}
Example #14
0
void *add_speaker(const char *name)
{
	Speaker *spk;

	spk=  alloc_libblock(&G.main->speaker, ID_SPK, name);

	spk->attenuation = 1.0f;
	spk->cone_angle_inner = 360.0f;
	spk->cone_angle_outer = 360.0f;
	spk->cone_volume_outer = 1.0f;
	spk->distance_max = FLT_MAX;
	spk->distance_reference = 1.0f;
	spk->flag = 0;
	spk->pitch = 1.0f;
	spk->sound = NULL;
	spk->volume = 1.0f;
	spk->volume_max = 1.0f;
	spk->volume_min = 0.0f;

	return spk;
}
Example #15
0
VFont *load_vfont(Main *bmain, const char *name)
{
	char filename[FILE_MAXFILE];
	VFont *vfont= NULL;
	PackedFile *pf;
	PackedFile *tpf = NULL;	
	int is_builtin;
	struct TmpFont *tmpfnt;
	
	if (strcmp(name, FO_BUILTIN_NAME)==0) {
		BLI_strncpy(filename, name, sizeof(filename));
		
		pf= get_builtin_packedfile();
		is_builtin= 1;
	}
	else {
		char dir[FILE_MAXDIR];
		
		BLI_strncpy(dir, name, sizeof(dir));
		BLI_splitdirstring(dir, filename);

		pf= newPackedFile(NULL, name, bmain->name);
		tpf= newPackedFile(NULL, name, bmain->name);
		
		is_builtin= 0;
	}

	if (pf) {
		VFontData *vfd;

		vfd= BLI_vfontdata_from_freetypefont(pf);
		if (vfd) {
			vfont = alloc_libblock(&bmain->vfont, ID_VF, filename);
			vfont->data = vfd;

			/* if there's a font name, use it for the ID name */
			if (vfd->name[0] != '\0') {
				BLI_strncpy(vfont->id.name+2, vfd->name, sizeof(vfont->id.name)-2);
			}
			BLI_strncpy(vfont->name, name, sizeof(vfont->name));

			// if autopack is on store the packedfile in de font structure
			if (!is_builtin && (G.fileflags & G_AUTOPACK)) {
				vfont->packedfile = pf;
			}
			
			// Do not add FO_BUILTIN_NAME to temporary listbase
			if (strcmp(filename, FO_BUILTIN_NAME)) {
				tmpfnt= (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font");
				tmpfnt->pf= tpf;
				tmpfnt->vfont= vfont;
				BLI_addtail(&ttfdata, tmpfnt);
			}			
		}
		
		// Free the packed file
		if (!vfont || vfont->packedfile != pf) {
			freePackedFile(pf);
		}
	
		//XXX waitcursor(0);
	}
	
	return vfont;
}