Exemplo n.º 1
0
World *add_world(Main *bmain, const char *name)
{
	World *wrld;

	wrld = BKE_libblock_alloc(&bmain->world, ID_WO, name);
	
	wrld->horr = 0.05f;
	wrld->horg = 0.05f;
	wrld->horb = 0.05f;
	wrld->zenr = 0.01f;
	wrld->zeng = 0.01f;
	wrld->zenb = 0.01f;
	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->ao_env_energy = 1.0f;
	wrld->ao_indirect_energy = 1.0f;
	wrld->ao_indirect_bounces = 1;
	wrld->aobias = 0.05f;
	wrld->ao_samp_method = WO_AOSAMP_HAMMERSLEY;
	wrld->ao_approx_error = 0.25f;
	
	wrld->preview = NULL;
	wrld->miststa = 5.0f;
	wrld->mistdist = 25.0f;

	return wrld;
}
Exemplo n.º 2
0
/* used everywhere in blenkernel */
void *BKE_libblock_copy(ID *id)
{
    ID *idn;
    ListBase *lb;
    size_t idn_len;

    lb = which_libbase(G.main, GS(id->name));
    idn = BKE_libblock_alloc(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 */
        const char *cp = (const char *)id;
        char *cpn = (char *)idn;

        memcpy(cpn + sizeof(ID), cp + sizeof(ID), idn_len - sizeof(ID));
    }

    id->newid = idn;
    idn->flag |= LIB_NEW;

    BKE_libblock_copy_data(idn, id, FALSE);

    return idn;
}
Exemplo n.º 3
0
bSound *sound_new_file(struct Main *bmain, const char *filename)
{
	bSound *sound = NULL;

	char str[FILE_MAX];
	char *path;

	size_t len;

	BLI_strncpy(str, filename, sizeof(str));

	path = /*bmain ? bmain->name :*/ G.main->name;

	BLI_path_abs(str, path);

	len = strlen(filename);
	while (len > 0 && filename[len - 1] != '/' && filename[len - 1] != '\\')
		len--;

	sound = BKE_libblock_alloc(bmain, ID_SO, filename + len);
	BLI_strncpy(sound->name, filename, FILE_MAX);
	/* sound->type = SOUND_TYPE_FILE; */ /* XXX unused currently */

	sound_load(bmain, sound);

	if (!sound->playback_handle) {
		BKE_libblock_free(bmain, sound);
		sound = NULL;
	}

	return sound;
}
Exemplo n.º 4
0
bSound *sound_new_limiter(struct Main *bmain, bSound *source, float start, float end)
{
	bSound *sound = NULL;

	char name[MAX_ID_NAME + 5];
	strcpy(name, "lim_");
	strcpy(name + 4, source->id.name);

	sound = BKE_libblock_alloc(bmain, ID_SO, name);

	sound->child_sound = source;
	sound->start = start;
	sound->end = end;
	sound->type = SOUND_TYPE_LIMITER;

	sound_load(bmain, sound);

	if (!sound->playback_handle)
	{
		BKE_libblock_free(bmain, sound);
		sound = NULL;
	}

	return sound;
}
Exemplo n.º 5
0
/* Add new collection, without view layer syncing. */
static Collection *collection_add(Main *bmain,
                                  Collection *collection_parent,
                                  const char *name_custom)
{
  /* Determine new collection name. */
  char name[MAX_NAME];

  if (name_custom) {
    STRNCPY(name, name_custom);
  }
  else {
    BKE_collection_new_name_get(collection_parent, name);
  }

  /* Create new collection. */
  Collection *collection = BKE_libblock_alloc(bmain, ID_GR, name, 0);

  /* We increase collection user count when linking to Collections. */
  id_us_min(&collection->id);

  /* Optionally add to parent collection. */
  if (collection_parent) {
    collection_child_add(collection_parent, collection, 0, true);
  }

  return collection;
}
Exemplo n.º 6
0
bAction *add_empty_action(Main *bmain, const char name[])
{
	bAction *act;
	
	act = BKE_libblock_alloc(bmain, ID_AC, name);
	
	return act;
}	
Exemplo n.º 7
0
void *BKE_cachefile_add(Main *bmain, const char *name)
{
	CacheFile *cache_file = BKE_libblock_alloc(bmain, ID_CF, name, 0);

	BKE_cachefile_init(cache_file);

	return cache_file;
}
Exemplo n.º 8
0
FreestyleLineStyle *BKE_linestyle_new(struct Main *bmain, const char *name)
{
	FreestyleLineStyle *linestyle;

	linestyle = (FreestyleLineStyle *)BKE_libblock_alloc(bmain, ID_LS, name);

	BKE_linestyle_init(linestyle);

	return linestyle;
}
Exemplo n.º 9
0
Lattice *BKE_lattice_add(Main *bmain, const char *name)
{
  Lattice *lt;

  lt = BKE_libblock_alloc(bmain, ID_LT, name, 0);

  BKE_lattice_init(lt);

  return lt;
}
Exemplo n.º 10
0
Lamp *BKE_lamp_add(Main *bmain, const char *name)
{
	Lamp *la;

	la =  BKE_libblock_alloc(bmain, ID_LA, name);

	BKE_lamp_init(la);

	return la;
}
Exemplo n.º 11
0
Tex *BKE_texture_add(Main *bmain, const char *name)
{
	Tex *tex;

	tex = BKE_libblock_alloc(bmain, ID_TE, name, 0);
	
	BKE_texture_default(tex);
	
	return tex;
}
Exemplo n.º 12
0
MetaBall *BKE_mball_add(Main *bmain, const char *name)
{
	MetaBall *mb;

	mb = BKE_libblock_alloc(bmain, ID_MB, name);

	BKE_mball_init(mb);

	return mb;
}
Exemplo n.º 13
0
Light *BKE_light_add(Main *bmain, const char *name)
{
  Light *la;

  la = BKE_libblock_alloc(bmain, ID_LA, name, 0);

  BKE_light_init(la);

  return la;
}
Exemplo n.º 14
0
void *BKE_speaker_add(Main *bmain, const char *name)
{
  Speaker *spk;

  spk = BKE_libblock_alloc(bmain, ID_SPK, name, 0);

  BKE_speaker_init(spk);

  return spk;
}
Exemplo n.º 15
0
Tex *add_texture(Main *bmain, const char *name)
{
	Tex *tex;

	tex = BKE_libblock_alloc(&bmain->tex, ID_TE, name);
	
	default_tex(tex);
	
	return tex;
}
Exemplo n.º 16
0
void *BKE_camera_add(Main *bmain, const char *name)
{
	Camera *cam;

	cam =  BKE_libblock_alloc(bmain, ID_CA, name, 0);

	BKE_camera_init(cam);

	return cam;
}
Exemplo n.º 17
0
VFont *BKE_vfont_load(Main *bmain, const char *name)
{
	char filename[FILE_MAXFILE];
	VFont *vfont = NULL;
	PackedFile *pf;
	PackedFile *temp_pf = NULL;
	int is_builtin;
	
	if (STREQ(name, FO_BUILTIN_NAME)) {
		BLI_strncpy(filename, name, sizeof(filename));
		
		pf = get_builtin_packedfile();
		is_builtin = TRUE;
	}
	else {
		BLI_split_file_part(name, filename, sizeof(filename));
		pf = newPackedFile(NULL, name, bmain->name);
		temp_pf = newPackedFile(NULL, name, bmain->name);
		
		is_builtin = FALSE;
	}

	if (pf) {
		VFontData *vfd;

		vfd = BLI_vfontdata_from_freetypefont(pf);
		if (vfd) {
			vfont = BKE_libblock_alloc(&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)) {
				vfont->temp_pf = temp_pf;
			}
		}

		/* Free the packed file */
		if (!vfont || vfont->packedfile != pf) {
			freePackedFile(pf);
		}
	}
	
	return vfont;
}
Exemplo n.º 18
0
Brush *BKE_brush_add(Main *bmain, const char *name, short ob_mode)
{
	Brush *brush;

	brush = BKE_libblock_alloc(bmain, ID_BR, name);

	BKE_brush_init(brush);

	brush->ob_mode = ob_mode;

	return brush;
}
Exemplo n.º 19
0
FreestyleLineStyle *BKE_new_linestyle(const char *name, struct Main *main)
{
	FreestyleLineStyle *linestyle;

	if (!main)
		main = G.main;

	linestyle = (FreestyleLineStyle *)BKE_libblock_alloc(main, ID_LS, name);

	default_linestyle_settings(linestyle);

	return linestyle;
}
Exemplo n.º 20
0
Lamp *BKE_lamp_add(Main *bmain, const char *name)
{
	Lamp *la;
	
	la =  BKE_libblock_alloc(&bmain->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 = 0.1f;
	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;
	la->shadow_frustum_size = 10.0f;
	
	curvemapping_initialize(la->curfalloff);
	return la;
}
Exemplo n.º 21
0
Lattice *BKE_lattice_add(const char *name)
{
	Lattice *lt;
	
	lt = BKE_libblock_alloc(&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 */
	BKE_lattice_resize(lt, 2, 2, 2, NULL);  /* creates a uniform lattice */
		
	return lt;
}
Exemplo n.º 22
0
MetaBall *BKE_mball_add(Main *bmain, const char *name)
{
    MetaBall *mb;

    mb = BKE_libblock_alloc(bmain, ID_MB, name);

    mb->size[0] = mb->size[1] = mb->size[2] = 1.0;
    mb->texflag = MB_AUTOSPACE;

    mb->wiresize = 0.4f;
    mb->rendersize = 0.2f;
    mb->thresh = 0.6f;

    return mb;
}
Exemplo n.º 23
0
/* on startup, it adds all data, for matching */
void wm_add_default(bContext *C)
{
	wmWindowManager *wm = BKE_libblock_alloc(CTX_data_main(C), 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(wm, win); 
}
Exemplo n.º 24
0
/* add a new gp-datablock */
bGPdata *gpencil_data_addnew(const char name[])
{
	bGPdata *gpd;
	
	/* allocate memory for a new block */
	gpd = BKE_libblock_alloc(G.main, ID_GD, name);
	
	/* initial settings */
	gpd->flag = (GP_DATA_DISPINFO | GP_DATA_EXPAND);
	
	/* for now, stick to view is also enabled by default
	 * since this is more useful...
	 */
	gpd->flag |= GP_DATA_VIEWALIGN;
	
	return gpd;
}
Exemplo n.º 25
0
bSound *BKE_sound_new_buffer(struct Main *bmain, bSound *source)
{
	bSound *sound = NULL;

	char name[MAX_ID_NAME + 5];
	strcpy(name, "buf_");
	strcpy(name + 4, source->id.name);

	sound = BKE_libblock_alloc(bmain, ID_SO, name);

	sound->child_sound = source;
	sound->type = SOUND_TYPE_BUFFER;

	sound_load(bmain, sound);

	return sound;
}
Exemplo n.º 26
0
Brush *BKE_brush_add(Main *bmain, const char *name)
{
	Brush *brush;

	brush = BKE_libblock_alloc(bmain, ID_BR, name);

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

	brush_defaults(brush);

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

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

	return brush;
}
Exemplo n.º 27
0
void *BKE_camera_add(Main *bmain, const char *name)
{
	Camera *cam;
	
	cam =  BKE_libblock_alloc(bmain, ID_CA, name);

	cam->lens = 35.0f;
	cam->sensor_x = DEFAULT_SENSOR_WIDTH;
	cam->sensor_y = DEFAULT_SENSOR_HEIGHT;
	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;
}
Exemplo n.º 28
0
/* only image block itself */
static MovieClip *movieclip_alloc(const char *name)
{
    MovieClip *clip;

    clip = BKE_libblock_alloc(&G.main->movieclip, ID_MC, name);

    clip->aspx = clip->aspy = 1.0f;

    BKE_tracking_init_settings(&clip->tracking);

    clip->proxy.build_size_flag = IMB_PROXY_25;
    clip->proxy.build_tc_flag = IMB_TC_RECORD_RUN |
                                IMB_TC_FREE_RUN |
                                IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN |
                                IMB_TC_RECORD_RUN_NO_GAPS;
    clip->proxy.quality = 90;

    return clip;
}
Exemplo n.º 29
0
bSound *BKE_sound_new_file(struct Main *bmain, const char *filepath)
{
	bSound *sound;
	const char *path;
	char str[FILE_MAX];

	BLI_strncpy(str, filepath, sizeof(str));

	path = /*bmain ? bmain->name :*/ G.main->name;

	BLI_path_abs(str, path);

	sound = BKE_libblock_alloc(bmain, ID_SO, BLI_path_basename(filepath));
	BLI_strncpy(sound->name, filepath, FILE_MAX);
	/* sound->type = SOUND_TYPE_FILE; */ /* XXX unused currently */

	BKE_sound_load(bmain, sound);

	return sound;
}
Exemplo n.º 30
0
Mesh *BKE_mesh_add(Main *bmain, const char *name)
{
	Mesh *me;
	
	me = BKE_libblock_alloc(&bmain->mesh, ID_ME, name);
	
	me->size[0] = me->size[1] = me->size[2] = 1.0;
	me->smoothresh = 30;
	me->texflag = ME_AUTOSPACE;
	me->flag = ME_TWOSIDED;
	me->drawflag = ME_DRAWEDGES | ME_DRAWFACES | ME_DRAWCREASES;

	CustomData_reset(&me->vdata);
	CustomData_reset(&me->edata);
	CustomData_reset(&me->fdata);
	CustomData_reset(&me->pdata);
	CustomData_reset(&me->ldata);

	return me;
}