Пример #1
0
void RenderLayersBaseProg::initExecution()
{
	Scene *scene = this->getScene();
	Render *re = (scene) ? RE_GetRender(scene->id.name) : NULL;
	RenderResult *rr = NULL;
	
	if (re)
		rr = RE_AcquireResultRead(re);
	
	if (rr) {
		SceneRenderLayer *srl = (SceneRenderLayer *)BLI_findlink(&scene->r.layers, getLayerId());
		if (srl) {

			RenderLayer *rl = RE_GetRenderLayer(rr, srl->name);
			if (rl && rl->rectf) {
				this->m_inputBuffer = RE_RenderLayerGetPass(rl, this->m_renderpass);

				if (this->m_inputBuffer == NULL && this->m_renderpass == SCE_PASS_COMBINED) {
					this->m_inputBuffer = rl->rectf;
				}
			}
		}
	}
	if (re) {
		RE_ReleaseResult(re);
		re = NULL;
	}
}
Пример #2
0
static int add_empty_ks_path_exec (bContext *C, wmOperator *op)
{
	Scene *scene= CTX_data_scene(C);
	KeyingSet *ks;
	KS_Path *ksp;
	
	/* verify the Keying Set to use:
	 *	- use the active one
	 *	- return error if it doesn't exist
	 */
	if (scene->active_keyingset == 0) {
		BKE_report(op->reports, RPT_ERROR, "No active Keying Set to add empty path to");
		return OPERATOR_CANCELLED;
	}
	else
		ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
	
	/* don't use the API method for this, since that checks on values... */
	ksp= MEM_callocN(sizeof(KS_Path), "KeyingSetPath Empty");
	BLI_addtail(&ks->paths, ksp);
	ks->active_path= BLI_countlist(&ks->paths);
	
	ksp->groupmode= KSP_GROUP_KSNAME; // XXX?
	
	return OPERATOR_FINISHED;
}
Пример #3
0
void cache_pointdensity(Render *re, Tex *tex)
{
	PointDensity *pd = tex->pd;
	
	if (!pd)
		return;

	if (pd->point_tree) {
		BLI_bvhtree_free(pd->point_tree);
		pd->point_tree = NULL;
	}
	
	if (pd->source == TEX_PD_PSYS) {
		Object *ob = pd->object;
		ParticleSystem *psys;

		if (!ob || !pd->psys) return;

		psys= BLI_findlink(&ob->particlesystem, pd->psys-1);
		if (!psys) return;
		
		pointdensity_cache_psys(re, pd, ob, psys);
	}
	else if (pd->source == TEX_PD_OBJECT) {
		Object *ob = pd->object;
		if (ob && ob->type == OB_MESH)
			pointdensity_cache_object(re, pd, ob);
	}
}
Пример #4
0
/* Get the active Keying Set for the Scene provided */
KeyingSet *ANIM_scene_get_active_keyingset (Scene *scene)
{
	/* if no scene, we've got no hope of finding the Keying Set */
	if (scene == NULL)
		return NULL;
	
	/* currently, there are several possibilities here:
	 *	-   0: no active keying set
	 *	- > 0: one of the user-defined Keying Sets, but indices start from 0 (hence the -1)
	 *	- < 0: a builtin keying set
	 */
	if (scene->active_keyingset > 0)
		return BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
	else
		return BLI_findlink(&builtin_keyingsets, (-scene->active_keyingset)-1);
}
Пример #5
0
/* note, must be freed */
int *defgroup_flip_map_single(Object *ob, int *flip_map_len, const bool use_default, int defgroup)
{
	int defbase_tot = *flip_map_len = BLI_countlist(&ob->defbase);

	if (defbase_tot == 0) {
		return NULL;
	}
	else {
		bDeformGroup *dg;
		char name_flip[sizeof(dg->name)];
		int i, flip_num, *map = MEM_mallocN(defbase_tot * sizeof(int), __func__);

		for (i = 0; i < defbase_tot; i++) {
			map[i] = use_default ? i : -1;
		}

		dg = BLI_findlink(&ob->defbase, defgroup);

		BKE_deform_flip_side_name(name_flip, dg->name, false);
		if (!STREQ(name_flip, dg->name)) {
			flip_num = defgroup_name_index(ob, name_flip);

			if (flip_num != -1) {
				map[defgroup] = flip_num;
				map[flip_num] = defgroup;
			}
		}

		return map;
	}
}
Пример #6
0
static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob)
{	
//XXX no longer used - to be removed - replaced by game_properties_copy_exec
	bProperty *prop;
	Base *base;
	int nr, tot=0;
	char *str;
	
	prop= ob->prop.first;
	while (prop) {
		tot++;
		prop= prop->next;
	}
	
	str= MEM_callocN(50 + 33*tot, "copymenu prop");
	
	if (tot)
		strcpy(str, "Copy Property %t|Replace All|Merge All|%l");
	else
		strcpy(str, "Copy Property %t|Clear All (no properties on active)");
	
	tot= 0;	
	prop= ob->prop.first;
	while (prop) {
		tot++;
		strcat(str, "|");
		strcat(str, prop->name);
		prop= prop->next;
	}

	nr= pupmenu(str);
	
	if ( nr==1 || nr==2 ) {
		for (base= FIRSTBASE; base; base= base->next) {
			if ((base != BASACT) &&(TESTBASELIB(v3d, base))) {
				if (nr==1) { /* replace */
					copy_properties( &base->object->prop, &ob->prop );
				}
				else {
					for (prop = ob->prop.first; prop; prop= prop->next ) {
						set_ob_property(base->object, prop);
					}
				}
			}
		}
	}
	else if (nr>0) {
		prop = BLI_findlink(&ob->prop, nr-4); /* account for first 3 menu items & menu index starting at 1*/
		
		if (prop) {
			for (base= FIRSTBASE; base; base= base->next) {
				if ((base != BASACT) &&(TESTBASELIB(v3d, base))) {
					set_ob_property(base->object, prop);
				}
			}
		}
	}
	MEM_freeN(str);
	
}
Пример #7
0
static bool isDisabled(ModifierData *md, int useRenderParams)
{
	ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md;
	ParticleSystem *psys;
	ModifierData *ob_md;
	
	if (!pimd->ob)
		return true;
	
	psys = BLI_findlink(&pimd->ob->particlesystem, pimd->psys - 1);
	if (psys == NULL)
		return true;
	
	/* If the psys modifier is disabled we cannot use its data.
	 * First look up the psys modifier from the object, then check if it is enabled.
	 */
	for (ob_md = pimd->ob->modifiers.first; ob_md; ob_md = ob_md->next) {
		if (ob_md->type == eModifierType_ParticleSystem) {
			ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)ob_md;
			if (psmd->psys == psys) {
				int required_mode;
				
				if (useRenderParams) required_mode = eModifierMode_Render;
				else required_mode = eModifierMode_Realtime;
				
				if (!modifier_isEnabled(md->scene, ob_md, required_mode))
					return true;
				
				break;
			}
		}
	}
	
	return false;
}
Пример #8
0
static int mask_layer_move_exec(bContext *C, wmOperator *op)
{
	Mask *mask = CTX_data_edit_mask(C);
	MaskLayer *mask_layer = BLI_findlink(&mask->masklayers, mask->masklay_act);
	MaskLayer *mask_layer_other;
	int direction = RNA_enum_get(op->ptr, "direction");

	if (!mask_layer)
		return OPERATOR_CANCELLED;

	if (direction == -1) {
		mask_layer_other = mask_layer->prev;

		if (!mask_layer_other)
			return OPERATOR_CANCELLED;

		BLI_remlink(&mask->masklayers, mask_layer);
		BLI_insertlinkbefore(&mask->masklayers, mask_layer_other, mask_layer);
		mask->masklay_act--;
	}
	else if (direction == 1) {
		mask_layer_other = mask_layer->next;

		if (!mask_layer_other)
			return OPERATOR_CANCELLED;

		BLI_remlink(&mask->masklayers, mask_layer);
		BLI_insertlinkafter(&mask->masklayers, mask_layer_other, mask_layer);
		mask->masklay_act++;
	}

	return OPERATOR_FINISHED;
}
Пример #9
0
static void wm_method_draw_stereo3d_anaglyph(wmWindow *win)
{
	wmDrawData *drawdata;
	int view, bit;

	for (view = 0; view < 2; view ++) {
		drawdata = BLI_findlink(&win->drawdata, (view * 2) + 1);

		bit = view + 1;
		switch (win->stereo3d_format->anaglyph_type) {
			case S3D_ANAGLYPH_REDCYAN:
				glColorMask((1&bit) ? GL_TRUE : GL_FALSE,
				            (2&bit) ? GL_TRUE : GL_FALSE,
				            (2&bit) ? GL_TRUE : GL_FALSE,
				            GL_FALSE);
				break;
			case S3D_ANAGLYPH_GREENMAGENTA:
				glColorMask((2&bit) ? GL_TRUE : GL_FALSE,
				            (1&bit) ? GL_TRUE : GL_FALSE,
				            (2&bit) ? GL_TRUE : GL_FALSE,
				            GL_FALSE);
				break;
			case S3D_ANAGLYPH_YELLOWBLUE:
				glColorMask((1&bit) ? GL_TRUE : GL_FALSE,
				            (1&bit) ? GL_TRUE : GL_FALSE,
				            (2&bit) ? GL_TRUE : GL_FALSE,
				            GL_FALSE);
				break;
		}

		wm_triple_draw_textures(win, drawdata->triple, 1.0f);

		glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
	}
}
Пример #10
0
/* note, must be freed */
int *defgroup_flip_map_single(Object *ob, int *flip_map_len, int use_default, int defgroup)
{
	int defbase_tot= *flip_map_len= BLI_countlist(&ob->defbase);

	if (defbase_tot==0) {
		return NULL;
	}
	else {
		bDeformGroup *dg;
		char name[sizeof(dg->name)];
		int i, flip_num, *map= MEM_mallocN(defbase_tot * sizeof(int), __func__);

		for (i=0; i < defbase_tot; i++) {
			if (use_default) map[i]= i;
			else             map[i]= -1;
		}

		dg= BLI_findlink(&ob->defbase, defgroup);

		flip_side_name(name, dg->name, FALSE);
		if (strcmp(name, dg->name)) {
			flip_num= defgroup_name_index(ob, name);

			if (flip_num >= 0) {
				map[defgroup]= flip_num;
				map[flip_num]= defgroup;
			}
		}

		return map;
	}
}
Пример #11
0
static void do_node_add_group(bContext *C, void *UNUSED(arg), int event)
{
	SpaceNode *snode = CTX_wm_space_node(C);
	Main *bmain = CTX_data_main(C);
	Scene *scene = CTX_data_scene(C);
	bNodeTemplate ntemp;
	
	if (event >= 0) {
		ntemp.ngroup = BLI_findlink(&G.main->nodetree, event);
		ntemp.type = ntemp.ngroup->nodetype;
	}
	else {
		ntemp.type = -event;
		switch (ntemp.type) {
			case NODE_GROUP:
				ntemp.ngroup = ntreeAddTree("Group", snode->treetype, ntemp.type);
				break;
			default:
				ntemp.ngroup = NULL;
		}
	}
	if (!ntemp.ngroup)
		return;
	
	ntemp.main = bmain;
	ntemp.scene = scene;
	
	do_node_add(C, &ntemp);
}
Пример #12
0
static int return_editmesh_vgroup(Object *obedit, EditMesh *em, char *name, float *cent)
{
	MDeformVert *dvert;
	EditVert *eve;
	int i, totvert=0;
	
	cent[0]= cent[1]= cent[2]= 0.0;
	
	if(obedit->actdef) {
		
		/* find the vertices */
		for(eve= em->verts.first; eve; eve= eve->next) {
			dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);

			if(dvert) {
				for(i=0; i<dvert->totweight; i++){
					if(dvert->dw[i].def_nr == (obedit->actdef-1)) {
						totvert++;
						add_v3_v3(cent, eve->co);
					}
				}
			}
		}
		if(totvert) {
			bDeformGroup *defGroup = BLI_findlink(&obedit->defbase, obedit->actdef-1);
			strcpy(name, defGroup->name);
			mul_v3_fl(cent, 1.0f/(float)totvert);
			return 1;
		}
	}
	
	return 0;
}	
Пример #13
0
static int object_hook_select_exec(bContext *C, wmOperator *op)
{
	PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier);
	int num= RNA_enum_get(op->ptr, "modifier");
	Object *ob=NULL;
	HookModifierData *hmd=NULL;
	
	if (ptr.data) {		/* if modifier context is available, use that */
		ob = ptr.id.data;
		hmd= ptr.data;
	} 
	else {			/* use the provided property */
		ob = CTX_data_edit_object(C);
		hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num);
	}
	if (!ob || !hmd) {
		BKE_report(op->reports, RPT_ERROR, "Couldn't find hook modifier");
		return OPERATOR_CANCELLED;
	}
	
	/* select functionality */
	object_hook_select(ob, hmd);
	
	WM_event_add_notifier(C, NC_GEOM|ND_SELECT, ob->data);
	
	return OPERATOR_FINISHED;
}
Пример #14
0
static int object_hook_recenter_exec(bContext *C, wmOperator *op)
{
	PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier);
	int num= RNA_enum_get(op->ptr, "modifier");
	Object *ob=NULL;
	HookModifierData *hmd=NULL;
	Scene *scene = CTX_data_scene(C);
	float bmat[3][3], imat[3][3];
	
	if (ptr.data) {		/* if modifier context is available, use that */
		ob = ptr.id.data;
		hmd= ptr.data;
	} 
	else {			/* use the provided property */
		ob = CTX_data_edit_object(C);
		hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num);
	}
	if (!ob || !hmd) {
		BKE_report(op->reports, RPT_ERROR, "Couldn't find hook modifier");
		return OPERATOR_CANCELLED;
	}
	
	/* recenter functionality */
	copy_m3_m4(bmat, ob->obmat);
	invert_m3_m3(imat, bmat);
	
	sub_v3_v3v3(hmd->cent, scene->cursor, ob->obmat[3]);
	mul_m3_v3(imat, hmd->cent);
	
	DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
	WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
	
	return OPERATOR_FINISHED;
}
Пример #15
0
/**
 * Takes a cursor (row, character) and returns x,y pixel coords.
 */
bool ED_text_region_location_from_cursor(SpaceText *st, ARegion *ar, const int cursor_co[2], int r_pixel_co[2])
{
	TextLine *line = NULL;

	if (!st->text) {
		goto error;
	}

	line = BLI_findlink(&st->text->lines, cursor_co[0]);
	if (!line || (cursor_co[1] < 0) || (cursor_co[1] > line->len)) {
		goto error;
	}
	else {
		int offl, offc;
		int linenr_offset = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
		/* handle tabs as well! */
		int char_pos = text_get_char_pos(st, line->line, cursor_co[1]);

		wrap_offset(st, ar, line, cursor_co[1], &offl, &offc);
		r_pixel_co[0] = (char_pos + offc - st->left) * st->cwidth + linenr_offset;
		r_pixel_co[1] = (cursor_co[0] + offl - st->top) * (st->lheight_dpi + TXT_LINE_SPACING);
		r_pixel_co[1] = (ar->winy - (r_pixel_co[1] + TXT_OFFSET)) - st->lheight_dpi;
	}
	return true;


error:
	r_pixel_co[0] = r_pixel_co[1] = -1;
	return false;
}
Пример #16
0
/* returns the active pose for a poselib */
static TimeMarker *poselib_get_active_pose(bAction *act)
{	
	if ((act) && (act->active_marker))
		return BLI_findlink(&act->markers, act->active_marker - 1);
	else
		return NULL;
}
Пример #17
0
static void do_node_add_group(bContext *C, void *UNUSED(arg), int event)
{
	SpaceNode *snode= CTX_wm_space_node(C);
	bNodeTemplate ntemp;
	
	if (event>=0) {
		ntemp.ngroup= BLI_findlink(&G.main->nodetree, event);
		ntemp.type = ntemp.ngroup->nodetype;
	}
	else {
		ntemp.type = -event;
		switch (ntemp.type) {
		case NODE_GROUP:
			ntemp.ngroup = ntreeAddTree("Group", snode->treetype, ntemp.type);
			break;
		case NODE_FORLOOP:
			ntemp.ngroup = ntreeAddTree("For Loop", snode->treetype, ntemp.type);
			break;
		case NODE_WHILELOOP:
			ntemp.ngroup = ntreeAddTree("While Loop", snode->treetype, ntemp.type);
			break;
		default:
			ntemp.ngroup = NULL;
		}
	}
	if (!ntemp.ngroup)
		return;
	
	do_node_add(C, &ntemp);
}
Пример #18
0
static int poselib_remove_exec(bContext *C, wmOperator *op)
{
	Object *ob = get_poselib_object(C);
	bAction *act = (ob) ? ob->poselib : NULL;
	TimeMarker *marker;
	int marker_index;
	FCurve *fcu;
	PropertyRNA *prop;

	/* check if valid poselib */
	if (act == NULL) {
		BKE_report(op->reports, RPT_ERROR, "Object does not have pose lib data");
		return OPERATOR_CANCELLED;
	}

	prop = RNA_struct_find_property(op->ptr, "pose");
	if (RNA_property_is_set(op->ptr, prop)) {
		marker_index = RNA_property_enum_get(op->ptr, prop);
	}
	else {
		marker_index = act->active_marker - 1;
	}

	/* get index (and pointer) of pose to remove */
	marker = BLI_findlink(&act->markers, marker_index);
	if (marker == NULL) {
		BKE_reportf(op->reports, RPT_ERROR, "Invalid pose specified %d", marker_index);
		return OPERATOR_CANCELLED;
	}
	
	/* remove relevant keyframes */
	for (fcu = act->curves.first; fcu; fcu = fcu->next) {
		BezTriple *bezt;
		unsigned int i;
		
		if (fcu->bezt) {
			for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
				/* check if remove */
				if (IS_EQF(bezt->vec[1][0], (float)marker->frame)) {
					delete_fcurve_key(fcu, i, 1);
					break;
				}
			}
		}
	}
	
	/* remove poselib from list */
	BLI_freelinkN(&act->markers, marker);
	
	/* fix active pose number */
	act->active_marker = 0;
	
	/* send notifiers for this - using keyframe editing notifiers, since action 
	 * may be being shown in anim editors as active action 
	 */
	WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
	
	/* done */
	return OPERATOR_FINISHED;
}
Пример #19
0
static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int *indices, int totindex,
                                           float weight, int assignmode)
{
	if (ob->type != OB_MESH) {
		BKE_report(reports, RPT_ERROR, "Object should be of mesh type");
		return;
	}

	Mesh *me = (Mesh *)ob->data;
	int group_index = BLI_findlink(&ob->defbase, group);
	if (group_index == -1) {
		BKE_report(reports, RPT_ERROR, "No vertex groups assigned to mesh");
		return;
	}

	if (assignmode != WEIGHT_REPLACE && assignmode != WEIGHT_ADD && assignmode != WEIGHT_SUBTRACT) {
		BKE_report(reports, RPT_ERROR, "Bad assignment mode");
		return;
	}

	/* makes a set of dVerts corresponding to the mVerts */
	if (!me->dvert)
		create_dverts(&me->id);

	/* loop list adding verts to group  */
	for (i = 0; i < totindex; i++) {
		if (i < 0 || i >= me->totvert) {
			BKE_report(reports, RPT_ERROR, "Bad vertex index in list");
			return;
		}

		add_vert_defnr(ob, group_index, i, weight, assignmode);
	}
}
Пример #20
0
static int poselib_rename_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
	Object *ob = get_poselib_object(C);
	bAction *act = (ob) ? ob->poselib : NULL;
	TimeMarker *marker;
	
	/* check if valid poselib */
	if (act == NULL) {
		BKE_report(op->reports, RPT_ERROR, "Object does not have pose lib data");
		return OPERATOR_CANCELLED;
	}
	
	/* get index (and pointer) of pose to remove */
	marker = BLI_findlink(&act->markers, act->active_marker - 1);
	if (marker == NULL) {
		BKE_report(op->reports, RPT_ERROR, "Invalid index for pose");
		return OPERATOR_CANCELLED;
	}
	else {
		/* use the existing name of the marker as the name, and use the active marker as the one to rename */
		RNA_enum_set(op->ptr, "pose", act->active_marker - 1);
		RNA_string_set(op->ptr, "name", marker->name);
	}
	
	/* part to sync with other similar operators... */
	return WM_operator_props_popup_confirm(C, op, event);
}
Пример #21
0
static void rna_GPencil_active_layer_index_set(PointerRNA *ptr, int value)
{
	bGPdata *gpd   = (bGPdata *)ptr->id.data;
	bGPDlayer *gpl = BLI_findlink(&gpd->layers, value);

	gpencil_layer_setactive(gpd, gpl);
}
Пример #22
0
static int poselib_rename_exec(bContext *C, wmOperator *op)
{
	Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
	bAction *act = (ob) ? ob->poselib : NULL;
	TimeMarker *marker;
	char newname[64];
	
	/* check if valid poselib */
	if (act == NULL) {
		BKE_report(op->reports, RPT_ERROR, "Object does not have pose lib data");
		return OPERATOR_CANCELLED;
	}
	
	/* get index (and pointer) of pose to remove */
	marker = BLI_findlink(&act->markers, RNA_enum_get(op->ptr, "pose"));
	if (marker == NULL) {
		BKE_report(op->reports, RPT_ERROR, "Invalid index for pose");
		return OPERATOR_CANCELLED;
	}
	
	/* get new name */
	RNA_string_get(op->ptr, "name", newname);
	
	/* copy name and validate it */
	BLI_strncpy(marker->name, newname, sizeof(marker->name));
	BLI_uniquename(&act->markers, marker, DATA_("Pose"), '.', offsetof(TimeMarker, name), sizeof(marker->name));
	
	/* send notifiers for this - using keyframe editing notifiers, since action 
	 * may be being shown in anim editors as active action 
	 */
	WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
	
	/* done */
	return OPERATOR_FINISHED;
}
Пример #23
0
bool ED_texture_context_check_linestyle(const bContext *C)
{
#ifdef WITH_FREESTYLE
	Scene *scene = CTX_data_scene(C);
	SceneRenderLayer *actsrl;
	FreestyleConfig *config;
	FreestyleLineSet *lineset;
	FreestyleLineStyle *linestyle;

	if (scene && (scene->r.mode & R_EDGE_FRS)) {
		actsrl = BLI_findlink(&scene->r.layers, scene->r.actlay);
		config = &actsrl->freestyleConfig;
		if (config->mode == FREESTYLE_CONTROL_EDITOR_MODE) {
			lineset = BKE_freestyle_lineset_get_active(config);
			if (lineset) {
				linestyle = lineset->linestyle;
				return linestyle && (linestyle->flag & LS_TEXTURE);
			}
		}
	}
#else
	(void)C;
#endif
	return false;
}
Пример #24
0
static int group_instance_add_exec(bContext *C, wmOperator *op)
{
	Group *group= BLI_findlink(&CTX_data_main(C)->group, RNA_enum_get(op->ptr, "group"));

	int enter_editmode;
	unsigned int layer;
	float loc[3], rot[3];
	
	object_add_generic_invoke_options(C, op);
	if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
		return OPERATOR_CANCELLED;

	if(group) {
		Main *bmain= CTX_data_main(C);
		Scene *scene= CTX_data_scene(C);
		Object *ob= ED_object_add_type(C, OB_EMPTY, loc, rot, FALSE, layer);
		rename_id(&ob->id, group->id.name+2);
		ob->dup_group= group;
		ob->transflag |= OB_DUPLIGROUP;
		id_lib_extern(&group->id);

		/* works without this except if you try render right after, see: 22027 */
		DAG_scene_sort(bmain, scene);

		WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, CTX_data_scene(C));

		return OPERATOR_FINISHED;
	}

	return OPERATOR_CANCELLED;
}
Пример #25
0
static int remove_active_keyingset_exec (bContext *C, wmOperator *op)
{
	Scene *scene= CTX_data_scene(C);
	KeyingSet *ks;
	
	/* verify the Keying Set to use:
	 *	- use the active one
	 *	- return error if it doesn't exist
	 */
	if (scene->active_keyingset == 0) {
		BKE_report(op->reports, RPT_ERROR, "No active Keying Set to remove");
		return OPERATOR_CANCELLED;
	}
	else
		ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
	
	/* free KeyingSet's data, then remove it from the scene */
	BKE_keyingset_free(ks);
	BLI_freelinkN(&scene->keyingsets, ks);
	
	/* the active one should now be the previously second-to-last one */
	scene->active_keyingset--;
	
	/* send notifiers */
	WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL);
	
	return OPERATOR_FINISHED;
}
Пример #26
0
void RenderLayersProg::determineResolution(unsigned int resolution[2],
                                           unsigned int /*preferredResolution*/[2])
{
  Scene *sce = this->getScene();
  Render *re = (sce) ? RE_GetSceneRender(sce) : NULL;
  RenderResult *rr = NULL;

  resolution[0] = 0;
  resolution[1] = 0;

  if (re) {
    rr = RE_AcquireResultRead(re);
  }

  if (rr) {
    ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&sce->view_layers, getLayerId());
    if (view_layer) {
      RenderLayer *rl = RE_GetRenderLayer(rr, view_layer->name);
      if (rl) {
        resolution[0] = rl->rectx;
        resolution[1] = rl->recty;
      }
    }
  }

  if (re) {
    RE_ReleaseResult(re);
  }
}
Пример #27
0
static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op)
{
	ListBase *markers = ED_context_get_markers(C);
	Scene *scene_to = BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene"));
	TimeMarker *marker, *marker_new;

	if (scene_to == NULL) {
		BKE_report(op->reports, RPT_ERROR, "Scene not found");
		return OPERATOR_CANCELLED;
	}

	if (scene_to == CTX_data_scene(C)) {
		BKE_report(op->reports, RPT_ERROR, "Cannot re-link markers into the same scene");
		return OPERATOR_CANCELLED;
	}

	/* copy markers */
	for (marker = markers->first; marker; marker = marker->next) {
		if (marker->flag & SELECT) {
			marker_new = MEM_dupallocN(marker);
			marker_new->prev = marker_new->next = NULL;
			
			BLI_addtail(&scene_to->markers, marker_new);
		}
	}

	return OPERATOR_FINISHED;
}
Пример #28
0
void RenderLayersProg::initExecution()
{
  Scene *scene = this->getScene();
  Render *re = (scene) ? RE_GetSceneRender(scene) : NULL;
  RenderResult *rr = NULL;

  if (re) {
    rr = RE_AcquireResultRead(re);
  }

  if (rr) {
    ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&scene->view_layers, getLayerId());
    if (view_layer) {

      RenderLayer *rl = RE_GetRenderLayer(rr, view_layer->name);
      if (rl) {
        this->m_inputBuffer = RE_RenderLayerGetPass(
            rl, this->m_passName.c_str(), this->m_viewName);
      }
    }
  }
  if (re) {
    RE_ReleaseResult(re);
    re = NULL;
  }
}
Пример #29
0
/**
 * Run after saving a file to refresh the #BLENDER_HISTORY_FILE list.
 */
static void wm_history_file_update(void)
{
	RecentFile *recent;

	/* no write history for recovered startup files */
	if (G.main->name[0] == 0)
		return;

	recent = G.recent_files.first;
	/* refresh recent-files.txt of recent opened files, when current file was changed */
	if (!(recent) || (BLI_path_cmp(recent->filepath, G.main->name) != 0)) {

		recent = wm_file_history_find(G.main->name);
		if (recent) {
			BLI_remlink(&G.recent_files, recent);
		}
		else {
			RecentFile *recent_next;
			for (recent = BLI_findlink(&G.recent_files, U.recent_files - 1); recent; recent = recent_next) {
				recent_next = recent->next;
				wm_history_file_free(recent);
			}
			recent = wm_history_file_new(G.main->name);
		}

		/* add current file to the beginning of list */
		BLI_addhead(&(G.recent_files), recent);

		/* write current file to recent-files.txt */
		wm_history_file_write();

		/* also update most recent files on System */
		GHOST_addToSystemRecentFiles(G.main->name);
	}
}
Пример #30
0
void RenderLayersBaseProg::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
{
	Scene *sce = this->getScene();
	Render *re = (sce) ? RE_GetRender(sce->id.name) : NULL;
	RenderResult *rr = NULL;
	
	resolution[0] = 0;
	resolution[1] = 0;
	
	if (re)
		rr = RE_AcquireResultRead(re);
	
	if (rr) {
		SceneRenderLayer *srl   = (SceneRenderLayer *)BLI_findlink(&sce->r.layers, getLayerId());
		if (srl) {
			RenderLayer *rl = RE_GetRenderLayer(rr, srl->name);
			if (rl && rl->rectf) {
				resolution[0] = rl->rectx;
				resolution[1] = rl->recty;
			}
		}
	}
	
	if (re)
		RE_ReleaseResult(re);

}