diff options
Diffstat (limited to 'source/blender/editors/mesh/editmesh_add.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_add.c | 109 |
1 files changed, 58 insertions, 51 deletions
diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index 0cf4ac48bf7..fdaddec5246 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -64,7 +64,7 @@ static Object *make_prim_init(bContext *C, const char *idname, *state = 0; if (obedit == NULL || obedit->type != OB_MESH) { obedit = ED_object_add_type(C, OB_MESH, loc, rot, FALSE, layer); - + rename_id((ID *)obedit, idname); rename_id((ID *)obedit->data, idname); @@ -103,7 +103,7 @@ static int add_primitive_plane_exec(bContext *C, wmOperator *op) int enter_editmode; int state; unsigned int layer; - + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); obedit = make_prim_init(C, "Plane", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); @@ -125,11 +125,12 @@ void MESH_OT_primitive_plane_add(wmOperatorType *ot) ot->name = "Add Plane"; ot->description = "Construct a filled planar mesh with 4 vertices"; ot->idname = "MESH_OT_primitive_plane_add"; - + /* api callbacks */ + ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_plane_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -144,7 +145,7 @@ static int add_primitive_cube_exec(bContext *C, wmOperator *op) int enter_editmode; int state; unsigned int layer; - + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); obedit = make_prim_init(C, "Cube", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); @@ -152,7 +153,7 @@ static int add_primitive_cube_exec(bContext *C, wmOperator *op) if (!EDBM_op_call_and_selectf(em, op, "vertout", "create_cube mat=%m4 size=%f", mat, dia * 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, &state, enter_editmode); @@ -165,11 +166,12 @@ void MESH_OT_primitive_cube_add(wmOperatorType *ot) ot->name = "Add Cube"; ot->description = "Construct a cube mesh"; ot->idname = "MESH_OT_primitive_cube_add"; - + /* api callbacks */ + ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_cube_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -190,10 +192,10 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op) int enter_editmode; int state, cap_end, cap_tri; unsigned int layer; - + cap_end = RNA_enum_get(op->ptr, "fill_type"); cap_tri = (cap_end == 2); - + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); obedit = make_prim_init(C, "Circle", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); @@ -205,9 +207,9 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op) { return OPERATOR_CANCELLED; } - + make_prim_finish(C, obedit, &state, enter_editmode); - + return OPERATOR_FINISHED; } @@ -219,14 +221,15 @@ void MESH_OT_primitive_circle_add(wmOperatorType *ot) ot->name = "Add Circle"; ot->description = "Construct a circle mesh"; ot->idname = "MESH_OT_primitive_circle_add"; - + /* api callbacks */ + ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_circle_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_int(ot->srna, "vertices", 32, 3, INT_MAX, "Vertices", "", 3, 500); prop = RNA_def_float(ot->srna, "radius", 1.0f, 0.0, FLT_MAX, "Radius", "", 0.001, 100.00); @@ -244,10 +247,10 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op) int enter_editmode; int state, cap_end, cap_tri; unsigned int layer; - + cap_end = RNA_enum_get(op->ptr, "end_fill_type"); cap_tri = (cap_end == 2); - + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); obedit = make_prim_init(C, "Cylinder", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); @@ -263,9 +266,9 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op) { return OPERATOR_CANCELLED; } - + make_prim_finish(C, obedit, &state, enter_editmode); - + return OPERATOR_FINISHED; } @@ -277,14 +280,15 @@ void MESH_OT_primitive_cylinder_add(wmOperatorType *ot) ot->name = "Add Cylinder"; ot->description = "Construct a cylinder mesh"; ot->idname = "MESH_OT_primitive_cylinder_add"; - + /* api callbacks */ + ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_cylinder_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_int(ot->srna, "vertices", 32, 3, INT_MAX, "Vertices", "", 3, 500); prop = RNA_def_float(ot->srna, "radius", 1.0f, 0.0, FLT_MAX, "Radius", "", 0.001, 100.00); @@ -304,10 +308,10 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op) int enter_editmode; int state, cap_end, cap_tri; unsigned int layer; - + cap_end = RNA_enum_get(op->ptr, "end_fill_type"); cap_tri = (cap_end == 2); - + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); obedit = make_prim_init(C, "Cone", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); @@ -320,7 +324,7 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op) { return OPERATOR_CANCELLED; } - + make_prim_finish(C, obedit, &state, enter_editmode); return OPERATOR_FINISHED; @@ -334,14 +338,15 @@ void MESH_OT_primitive_cone_add(wmOperatorType *ot) ot->name = "Add Cone"; ot->description = "Construct a conic mesh"; ot->idname = "MESH_OT_primitive_cone_add"; - + /* api callbacks */ + ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_cone_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_int(ot->srna, "vertices", 32, 3, INT_MAX, "Vertices", "", 3, 500); prop = RNA_def_float(ot->srna, "radius1", 1.0f, 0.0, FLT_MAX, "Radius 1", "", 0.001, 100.00); @@ -363,7 +368,7 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op) int enter_editmode; int state; unsigned int layer; - + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); obedit = make_prim_init(C, "Grid", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); @@ -376,9 +381,8 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op) { return OPERATOR_CANCELLED; } - + make_prim_finish(C, obedit, &state, enter_editmode); - return OPERATOR_FINISHED; } @@ -390,14 +394,15 @@ void MESH_OT_primitive_grid_add(wmOperatorType *ot) ot->name = "Add Grid"; ot->description = "Construct a grid mesh"; ot->idname = "MESH_OT_primitive_grid_add"; - + /* api callbacks */ + ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_grid_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_int(ot->srna, "x_subdivisions", 10, 3, INT_MAX, "X Subdivisions", "", 3, 1000); RNA_def_int(ot->srna, "y_subdivisions", 10, 3, INT_MAX, "Y Subdivisions", "", 3, 1000); @@ -415,20 +420,19 @@ static int add_primitive_monkey_exec(bContext *C, wmOperator *op) int enter_editmode; int state, view_aligned; unsigned int layer; - + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, &view_aligned); if (!view_aligned) rot[0] += (float)M_PI / 2.0f; - + obedit = make_prim_init(C, "Monkey", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf(em, op, "vertout", "create_monkey mat=%m4", mat)) { return OPERATOR_CANCELLED; } - + make_prim_finish(C, obedit, &state, enter_editmode); - return OPERATOR_FINISHED; } @@ -438,11 +442,12 @@ void MESH_OT_primitive_monkey_add(wmOperatorType *ot) ot->name = "Add Monkey"; ot->description = "Construct a Suzanne mesh"; ot->idname = "MESH_OT_primitive_monkey_add"; - + /* api callbacks */ + ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_monkey_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -457,7 +462,7 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op) int enter_editmode; int state; unsigned int layer; - + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); obedit = make_prim_init(C, "Sphere", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); @@ -469,7 +474,7 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op) { return OPERATOR_CANCELLED; } - + make_prim_finish(C, obedit, &state, enter_editmode); return OPERATOR_FINISHED; @@ -483,14 +488,15 @@ void MESH_OT_primitive_uv_sphere_add(wmOperatorType *ot) ot->name = "Add UV Sphere"; ot->description = "Construct a UV sphere mesh"; ot->idname = "MESH_OT_primitive_uv_sphere_add"; - + /* api callbacks */ + ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_uvsphere_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_int(ot->srna, "segments", 32, 3, INT_MAX, "Segments", "", 3, 500); RNA_def_int(ot->srna, "ring_count", 16, 3, INT_MAX, "Rings", "", 3, 500); @@ -508,7 +514,7 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op) int enter_editmode; int state; unsigned int layer; - + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); obedit = make_prim_init(C, "Icosphere", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); @@ -521,10 +527,10 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op) { return OPERATOR_CANCELLED; } - + make_prim_finish(C, obedit, &state, enter_editmode); - return OPERATOR_FINISHED; + return OPERATOR_FINISHED; } void MESH_OT_primitive_ico_sphere_add(wmOperatorType *ot) @@ -535,14 +541,15 @@ void MESH_OT_primitive_ico_sphere_add(wmOperatorType *ot) ot->name = "Add Ico Sphere"; ot->description = "Construct an Icosphere mesh"; ot->idname = "MESH_OT_primitive_ico_sphere_add"; - + /* api callbacks */ + ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_icosphere_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_int(ot->srna, "subdivisions", 2, 1, INT_MAX, "Subdivisions", "", 1, 8); prop = RNA_def_float(ot->srna, "size", 1.0f, 0.0f, FLT_MAX, "Size", "", 0.001f, 100.00); |