Compare commits
1 Commits
soc-2022-s
...
template-o
Author | SHA1 | Date | |
---|---|---|---|
753dd8f09a |
@@ -1396,6 +1396,7 @@ class VIEW3D_MT_mesh_add(Menu):
|
||||
|
||||
layout.operator("mesh.primitive_plane_add", text="Plane", icon='MESH_PLANE')
|
||||
layout.operator("mesh.primitive_cube_add", text="Cube", icon='MESH_CUBE')
|
||||
layout.operator("mesh.primitive_wedge_add", text="Wedge", icon='MESH_DATA') # XXX, no icon
|
||||
layout.operator("mesh.primitive_circle_add", text="Circle", icon='MESH_CIRCLE')
|
||||
layout.operator("mesh.primitive_uv_sphere_add", text="UV Sphere", icon='MESH_UVSPHERE')
|
||||
layout.operator("mesh.primitive_ico_sphere_add", text="Ico Sphere", icon='MESH_ICOSPHERE')
|
||||
|
@@ -1720,6 +1720,27 @@ static BMOpDefine bmo_create_cube_def = {
|
||||
BMO_OPTYPE_FLAG_SELECT_FLUSH),
|
||||
};
|
||||
|
||||
/*
|
||||
*Create Wedge
|
||||
*
|
||||
* Creates a wedge.
|
||||
*/
|
||||
static BMOpDefine bmo_create_wedge_def = {
|
||||
"create_wedge",
|
||||
/* slots_in */
|
||||
{{"size", BMO_OP_SLOT_FLT}, /* size of the wedge */
|
||||
{"matrix", BMO_OP_SLOT_MAT}, /* matrix to multiply the new geometry with */
|
||||
{{'\0'}},
|
||||
},
|
||||
/* slots_out */
|
||||
{{"verts.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}}, /* output verts */
|
||||
{{'\0'}},
|
||||
},
|
||||
bmo_create_wedge_exec,
|
||||
(BMO_OPTYPE_FLAG_NORMALS_CALC |
|
||||
BMO_OPTYPE_FLAG_SELECT_FLUSH),
|
||||
};
|
||||
|
||||
static BMO_FlagSet bmo_enum_bevel_offset_type[] = {
|
||||
{BEVEL_AMT_OFFSET, "OFFSET"},
|
||||
{BEVEL_AMT_WIDTH, "WIDTH"},
|
||||
@@ -2087,6 +2108,7 @@ const BMOpDefine *bmo_opdefines[] = {
|
||||
&bmo_create_circle_def,
|
||||
&bmo_create_cone_def,
|
||||
&bmo_create_cube_def,
|
||||
&bmo_create_wedge_def,
|
||||
&bmo_create_grid_def,
|
||||
&bmo_create_icosphere_def,
|
||||
&bmo_create_monkey_def,
|
||||
|
@@ -43,6 +43,7 @@ void bmo_convex_hull_exec(BMesh *bm, BMOperator *op);
|
||||
void bmo_create_circle_exec(BMesh *bm, BMOperator *op);
|
||||
void bmo_create_cone_exec(BMesh *bm, BMOperator *op);
|
||||
void bmo_create_cube_exec(BMesh *bm, BMOperator *op);
|
||||
void bmo_create_wedge_exec(BMesh *bm, BMOperator *op);
|
||||
void bmo_create_grid_exec(BMesh *bm, BMOperator *op);
|
||||
void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op);
|
||||
void bmo_create_monkey_exec(BMesh *bm, BMOperator *op);
|
||||
|
@@ -1684,6 +1684,69 @@ void bmo_create_cube_exec(BMesh *bm, BMOperator *op)
|
||||
BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK);
|
||||
}
|
||||
|
||||
void bmo_create_wedge_exec(BMesh *bm, BMOperator *op)
|
||||
{
|
||||
BMVert * v1, *v2, *v3, *v4, *v5, *v6;
|
||||
float vec[3], mat[4][4], off = BMO_slot_float_get(op->slots_in, "size") / 2.0f;
|
||||
|
||||
BMO_slot_mat4_get(op->slots_in, "matrix", mat);
|
||||
|
||||
if (!off) off = 0.5f;
|
||||
|
||||
vec[0] = off;
|
||||
vec[1] = off;
|
||||
vec[2] = -off;
|
||||
mul_m4_v3(mat, vec);
|
||||
v1 = BM_vert_create(bm, vec, NULL, BM_CREATE_NOP);
|
||||
BMO_elem_flag_enable(bm, v1, VERT_MARK);
|
||||
|
||||
vec[0] = off;
|
||||
vec[1] = -off;
|
||||
vec[2] = -off;
|
||||
mul_m4_v3(mat, vec);
|
||||
v2 = BM_vert_create(bm, vec, NULL, BM_CREATE_NOP);
|
||||
BMO_elem_flag_enable(bm, v2, VERT_MARK);
|
||||
|
||||
vec[0] = -off;
|
||||
vec[1] = -off;
|
||||
vec[2] = off;
|
||||
mul_m4_v3(mat, vec);
|
||||
v3 = BM_vert_create(bm, vec, NULL, BM_CREATE_NOP);
|
||||
BMO_elem_flag_enable(bm, v3, VERT_MARK);
|
||||
|
||||
vec[0] = -off;
|
||||
vec[1] = off;
|
||||
vec[2] = off;
|
||||
mul_m4_v3(mat, vec);
|
||||
v4 = BM_vert_create(bm, vec, NULL, BM_CREATE_NOP);
|
||||
BMO_elem_flag_enable(bm, v4, VERT_MARK);
|
||||
|
||||
vec[0] = off;
|
||||
vec[1] = off;
|
||||
vec[2] = off;
|
||||
mul_m4_v3(mat, vec);
|
||||
v5 = BM_vert_create(bm, vec, NULL, BM_CREATE_NOP);
|
||||
BMO_elem_flag_enable(bm, v5, VERT_MARK);
|
||||
|
||||
vec[0] = off;
|
||||
vec[1] = -off;
|
||||
vec[2] = off;
|
||||
mul_m4_v3(mat, vec);
|
||||
v6 = BM_vert_create(bm, vec, NULL, BM_CREATE_NOP);
|
||||
BMO_elem_flag_enable(bm, v6, VERT_MARK);
|
||||
|
||||
/* the four sides */
|
||||
BM_face_create_quad_tri(bm, v3, v4, v1, v2, NULL, false);
|
||||
BM_face_create_quad_tri(bm, v4, v5, v1, NULL, NULL, false);
|
||||
BM_face_create_quad_tri(bm, v5, v6, v2, v1, NULL, false);
|
||||
BM_face_create_quad_tri(bm, v6, v3, v2, NULL, NULL, false);
|
||||
|
||||
/* top */
|
||||
BM_face_create_quad_tri(bm, v6, v5, v4, v3, NULL, false);
|
||||
|
||||
BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills first available UVmap with cube-like UVs for all faces OpFlag-ged by given flag.
|
||||
*
|
||||
|
@@ -204,6 +204,54 @@ void MESH_OT_primitive_cube_add(wmOperatorType *ot)
|
||||
ED_object_add_generic_props(ot, true);
|
||||
}
|
||||
|
||||
static int add_primitive_wedge_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
MakePrimitiveData creation_data;
|
||||
Object *obedit;
|
||||
BMEditMesh *em;
|
||||
float loc[3], rot[3];
|
||||
bool enter_editmode;
|
||||
ushort local_view_bits;
|
||||
|
||||
WM_operator_view3d_unit_defaults(C, op);
|
||||
ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL);
|
||||
obedit = make_prim_init(
|
||||
C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Wedge"),
|
||||
loc, rot, local_view_bits, &creation_data);
|
||||
|
||||
em = BKE_editmesh_from_object(obedit);
|
||||
|
||||
if (!EDBM_op_call_and_selectf(
|
||||
em, op, "verts.out", false,
|
||||
"create_wedge matrix=%m4 size=%f",
|
||||
creation_data.mat, RNA_float_get(op->ptr, "size") * 2.0f))
|
||||
{
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
make_prim_finish(C, obedit, &creation_data, enter_editmode);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void MESH_OT_primitive_wedge_add(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Add Wedge";
|
||||
ot->description = "Construct a wedge mesh";
|
||||
ot->idname = "MESH_OT_primitive_wedge_add";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = add_primitive_wedge_exec;
|
||||
ot->poll = ED_operator_scene_editable;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
ED_object_add_unit_props_size(ot);
|
||||
ED_object_add_generic_props(ot, true);
|
||||
}
|
||||
|
||||
static const EnumPropertyItem fill_type_items[] = {
|
||||
{0, "NOTHING", 0, "Nothing", "Don't fill at all"},
|
||||
{1, "NGON", 0, "Ngon", "Use ngons"},
|
||||
|
@@ -76,6 +76,7 @@ struct BMElem *EDBM_elem_from_index_any(struct BMEditMesh *em, int index);
|
||||
/* *** editmesh_add.c *** */
|
||||
void MESH_OT_primitive_plane_add(struct wmOperatorType *ot);
|
||||
void MESH_OT_primitive_cube_add(struct wmOperatorType *ot);
|
||||
void MESH_OT_primitive_wedge_add(struct wmOperatorType *ot);
|
||||
void MESH_OT_primitive_circle_add(struct wmOperatorType *ot);
|
||||
void MESH_OT_primitive_cylinder_add(struct wmOperatorType *ot);
|
||||
void MESH_OT_primitive_cone_add(struct wmOperatorType *ot);
|
||||
|
@@ -63,6 +63,7 @@ void ED_operatortypes_mesh(void)
|
||||
WM_operatortype_append(MESH_OT_edges_select_sharp);
|
||||
WM_operatortype_append(MESH_OT_primitive_plane_add);
|
||||
WM_operatortype_append(MESH_OT_primitive_cube_add);
|
||||
WM_operatortype_append(MESH_OT_primitive_wedge_add);
|
||||
WM_operatortype_append(MESH_OT_primitive_circle_add);
|
||||
WM_operatortype_append(MESH_OT_primitive_cylinder_add);
|
||||
WM_operatortype_append(MESH_OT_primitive_cone_add);
|
||||
|
Reference in New Issue
Block a user