static int add_primitive_icosphere_exec(bContext *C, wmOperator *op)
{
	Object *obedit;
	BMEditMesh *em;
	float loc[3], rot[3], mat[4][4], dia;
	bool enter_editmode;
	bool was_editmode;
	unsigned int layer;

	ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
	obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, "Icosphere"), &dia, mat, &was_editmode, loc, rot, layer);
	em = BKE_editmesh_from_object(obedit);

	if (!EDBM_op_call_and_selectf(
	        em, op, "verts.out", false,
	        "create_icosphere subdivisions=%i diameter=%f matrix=%m4",
	        RNA_int_get(op->ptr, "subdivisions"),
	        RNA_float_get(op->ptr, "size"), mat))
	{
		return OPERATOR_CANCELLED;
	}

	make_prim_finish(C, obedit, was_editmode, enter_editmode);

	return OPERATOR_FINISHED;
}
Beispiel #2
0
void BKE_sequence_modifier_unique_name(Sequence *seq, SequenceModifierData *smd)
{
	const SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type);

	BLI_uniquename(&seq->modifiers, smd, CTX_DATA_(BLT_I18NCONTEXT_ID_SEQUENCE, smti->name), '.',
	               offsetof(SequenceModifierData, name), sizeof(smd->name));
}
static int add_primitive_monkey_exec(bContext *C, wmOperator *op)
{
	Object *obedit;
	BMEditMesh *em;
	float loc[3], rot[3], mat[4][4], dia;
	bool enter_editmode;
	bool is_view_aligned;
	unsigned int layer;
	bool was_editmode;

	ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, &is_view_aligned);
	if (!is_view_aligned)
		rot[0] += (float)M_PI / 2.0f;

	obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, "Suzanne"), &dia, mat, &was_editmode, loc, rot, layer);
	dia = RNA_float_get(op->ptr, "radius");
	mat[0][0] *= dia;
	mat[1][1] *= dia;
	mat[2][2] *= dia;

	em = BKE_editmesh_from_object(obedit);

	if (!EDBM_op_call_and_selectf(
	        em, op, "verts.out",  false,
	        "create_monkey matrix=%m4", mat))
	{
		return OPERATOR_CANCELLED;
	}

	make_prim_finish(C, obedit, was_editmode, enter_editmode);

	return OPERATOR_FINISHED;
}
static int add_primitive_cone_exec(bContext *C, wmOperator *op)
{
	Object *obedit;
	BMEditMesh *em;
	float loc[3], rot[3], mat[4][4], dia;
	bool enter_editmode;
	unsigned int layer;
	bool was_editmode;
	const int end_fill_type = RNA_enum_get(op->ptr, "end_fill_type");
	const bool cap_end = (end_fill_type != 0);
	const bool cap_tri = (end_fill_type == 2);

	ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
	obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, "Cone"), &dia, mat, &was_editmode, loc, rot, layer);
	em = BKE_editmesh_from_object(obedit);

	if (!EDBM_op_call_and_selectf(
	        em, op, "verts.out", false,
	        "create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b cap_tris=%b depth=%f matrix=%m4",
	        RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius1"),
	        RNA_float_get(op->ptr, "radius2"), cap_end, cap_tri, RNA_float_get(op->ptr, "depth"), mat))
	{
		return OPERATOR_CANCELLED;
	}

	make_prim_finish(C, obedit, was_editmode, enter_editmode);

	return OPERATOR_FINISHED;
}
static int add_primitive_cube_exec(bContext *C, wmOperator *op)
{
	Object *obedit;
	BMEditMesh *em;
	float loc[3], rot[3], mat[4][4], dia;
	bool enter_editmode;
	bool was_editmode;
	unsigned int layer;

	ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
	obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, "Cube"), &dia, mat, &was_editmode, loc, rot, layer);
	em = BKE_editmesh_from_object(obedit);

	if (!EDBM_op_call_and_selectf(
	        em, op, "verts.out", false,
	        "create_cube matrix=%m4 size=%f",
	        mat, RNA_float_get(op->ptr, "radius") * 2.0f))
	{
		return OPERATOR_CANCELLED;
	}

	/* BMESH_TODO make plane side this: M_SQRT2 - plane (diameter of 1.41 makes it unit size) */
	make_prim_finish(C, obedit, was_editmode, enter_editmode);

	return OPERATOR_FINISHED;
}
Beispiel #6
0
static const char *get_surf_defname(int type)
{
	int stype = type & CU_PRIMITIVE;

	switch (stype) {
		case CU_PRIM_CURVE: return CTX_DATA_(BLT_I18NCONTEXT_ID_CURVE, "SurfCurve");
		case CU_PRIM_CIRCLE: return CTX_DATA_(BLT_I18NCONTEXT_ID_CURVE, "SurfCircle");
		case CU_PRIM_PATCH: return CTX_DATA_(BLT_I18NCONTEXT_ID_CURVE, "SurfPatch");
		case CU_PRIM_SPHERE: return CTX_DATA_(BLT_I18NCONTEXT_ID_CURVE, "SurfSphere");
		case CU_PRIM_DONUT: return CTX_DATA_(BLT_I18NCONTEXT_ID_CURVE, "SurfTorus");
		default:
			return CTX_DATA_(BLT_I18NCONTEXT_ID_CURVE, "Surface");
	}
}
Beispiel #7
0
static void rna_ShapeKey_name_set(PointerRNA *ptr, const char *value)
{
	KeyBlock *kb = ptr->data;
	char oldname[sizeof(kb->name)];
	
	/* make a copy of the old name first */
	BLI_strncpy(oldname, kb->name, sizeof(kb->name));
	
	/* copy the new name into the name slot */
	BLI_strncpy_utf8(kb->name, value, sizeof(kb->name));
	
	/* make sure the name is truly unique */
	if (ptr->id.data) {
		Key *key = rna_ShapeKey_find_key(ptr->id.data);
		BLI_uniquename(&key->block, kb, CTX_DATA_(BLF_I18NCONTEXT_ID_SHAPEKEY, "Key"), '.',
		               offsetof(KeyBlock, name), sizeof(kb->name));
	}
	
	/* fix all the animation data which may link to this */
	BKE_all_animdata_fix_paths_rename(NULL, "key_blocks", oldname, kb->name);
}
Beispiel #8
0
static const char *get_curve_defname(int type)
{
	int stype = type & CU_PRIMITIVE;

	if ((type & CU_TYPE) == CU_BEZIER) {
		switch (stype) {
			case CU_PRIM_CURVE: return CTX_DATA_(BLT_I18NCONTEXT_ID_CURVE, "BezierCurve");
			case CU_PRIM_CIRCLE: return CTX_DATA_(BLT_I18NCONTEXT_ID_CURVE, "BezierCircle");
			case CU_PRIM_PATH: return CTX_DATA_(BLT_I18NCONTEXT_ID_CURVE, "CurvePath");
			default:
				return CTX_DATA_(BLT_I18NCONTEXT_ID_CURVE, "Curve");
		}
	}
	else {
		switch (stype) {
			case CU_PRIM_CURVE: return CTX_DATA_(BLT_I18NCONTEXT_ID_CURVE, "NurbsCurve");
			case CU_PRIM_CIRCLE: return CTX_DATA_(BLT_I18NCONTEXT_ID_CURVE, "NurbsCircle");
			case CU_PRIM_PATH: return CTX_DATA_(BLT_I18NCONTEXT_ID_CURVE, "NurbsPath");
			default:
				return CTX_DATA_(BLT_I18NCONTEXT_ID_CURVE, "Curve");
		}
	}
}
void tracks_map_merge(TracksMap *map, MovieTracking *tracking)
{
	MovieTrackingTrack *track;
	ListBase tracks = {NULL, NULL}, new_tracks = {NULL, NULL};
	ListBase *old_tracks;
	int a;

	if (map->is_camera) {
		old_tracks = &tracking->tracks;
	}
	else {
		MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, map->object_name);

		if (!object) {
			/* object was deleted by user, create new one */
			object = BKE_tracking_object_add(tracking, map->object_name);
		}

		old_tracks = &object->tracks;
	}

	/* duplicate currently operating tracks to temporary list.
	 * this is needed to keep names in unique state and it's faster to change names
	 * of currently operating tracks (if needed)
	 */
	for (a = 0; a < map->num_tracks; a++) {
		MovieTrackingTrack *old_track;
		bool mapped_to_old = false;

		track = &map->tracks[a];

		/* find original of operating track in list of previously displayed tracks */
		old_track = BLI_ghash_lookup(map->hash, track);
		if (old_track) {
			if (BLI_findindex(old_tracks, old_track) != -1) {
				BLI_remlink(old_tracks, old_track);

				BLI_spin_lock(&map->spin_lock);

				/* Copy flags like selection back to the track map. */
				track->flag = old_track->flag;
				track->pat_flag = old_track->pat_flag;
				track->search_flag = old_track->search_flag;

				/* Copy all the rest settings back from the map to the actual tracks. */
				MEM_freeN(old_track->markers);
				*old_track = *track;
				old_track->markers = MEM_dupallocN(old_track->markers);

				BLI_spin_unlock(&map->spin_lock);

				BLI_addtail(&tracks, old_track);

				mapped_to_old = true;
			}
		}

		if (mapped_to_old == false) {
			MovieTrackingTrack *new_track = BKE_tracking_track_duplicate(track);

			/* Update old-new track mapping */
			BLI_ghash_reinsert(map->hash, track, new_track, NULL, NULL);

			BLI_addtail(&tracks, new_track);
		}
	}

	/* move all tracks, which aren't operating */
	track = old_tracks->first;
	while (track) {
		MovieTrackingTrack *next = track->next;
		BLI_addtail(&new_tracks, track);
		track = next;
	}

	/* now move all tracks which are currently operating and keep their names unique */
	track = tracks.first;
	while (track) {
		MovieTrackingTrack *next = track->next;

		BLI_remlink(&tracks, track);

		track->next = track->prev = NULL;
		BLI_addtail(&new_tracks, track);

		BLI_uniquename(&new_tracks, track, CTX_DATA_(BLF_I18NCONTEXT_ID_MOVIECLIP, "Track"), '.',
		               offsetof(MovieTrackingTrack, name), sizeof(track->name));

		track = next;
	}

	*old_tracks = new_tracks;
}