コード例 #1
0
ファイル: mesh_data.c プロジェクト: rexbron/blender-ocio
static int vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op))
{
	Scene *scene= CTX_data_scene(C);
	Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
	Mesh *me= ob->data;

	if(!ED_mesh_color_add(C, scene, ob, me, NULL, TRUE))
		return OPERATOR_CANCELLED;

	return OPERATOR_FINISHED;
}
コード例 #2
0
static int output_toggle_exec(bContext *C, wmOperator *op)
{
	Object *ob = ED_object_context(C);
	Scene *scene = CTX_data_scene(C);
	DynamicPaintSurface *surface;
	DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint);
	int output= RNA_enum_get(op->ptr, "output"); /* currently only 1/0 */

	if (!pmd || !pmd->canvas) return OPERATOR_CANCELLED;
	surface = get_activeSurface(pmd->canvas);

	/* if type is already enabled, toggle it off */
	if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
		int exists = dynamicPaint_outputLayerExists(surface, ob, output);
		const char *name;
		
		if (output == 0)
			name = surface->output_name;
		else
			name = surface->output_name2;

		/* Vertex Color Layer */
		if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
			if (!exists)
				ED_mesh_color_add(C, scene, ob, ob->data, name, 1);
			else 
				ED_mesh_color_remove_named(C, ob, ob->data, name);
		}
		/* Vertex Weight Layer */
		else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
			if (!exists) {
				ED_vgroup_add_name(ob, name);
			}
			else {
				bDeformGroup *defgroup = defgroup_find_name(ob, name);
				if (defgroup) ED_vgroup_delete(ob, defgroup);
			}
		}
	}

	return OPERATOR_FINISHED;
}