Curves: improve Add menu for new curves object
The goal is to make the Add menu more convenient for the new curves object. The following changes are done: * Add `curves` submenu. * Add an `Empty Hair` operator that also sets the surface object. * Rename the old operator to `Random`. It's mostly for testing at this point. Differential Revision: https://developer.blender.org/D14556
This commit is contained in:
parent
50869b408b
commit
434521a9e2
Notes:
blender-bot
2023-02-14 09:44:56 +01:00
Referenced by issue #96854, Add Menu for new curves object
|
@ -2052,6 +2052,19 @@ class VIEW3D_MT_curve_add(Menu):
|
|||
layout.operator("curve.primitive_nurbs_path_add", text="Path", icon='CURVE_PATH')
|
||||
|
||||
|
||||
class VIEW3D_MT_curves_add(Menu):
|
||||
bl_idname = "VIEW3D_MT_curves_add"
|
||||
bl_label = "Curves"
|
||||
|
||||
def draw(self, _context):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator_context = 'INVOKE_REGION_WIN'
|
||||
|
||||
layout.operator("object.curves_empty_hair_add", text="Empty Hair", icon='CURVES_DATA')
|
||||
layout.operator("object.curves_random_add", text="Random", icon='CURVES_DATA')
|
||||
|
||||
|
||||
class VIEW3D_MT_surface_add(Menu):
|
||||
bl_idname = "VIEW3D_MT_surface_add"
|
||||
bl_label = "Surface"
|
||||
|
@ -2204,12 +2217,12 @@ class VIEW3D_MT_add(Menu):
|
|||
|
||||
# layout.operator_menu_enum("object.curve_add", "type", text="Curve", icon='OUTLINER_OB_CURVE')
|
||||
layout.menu("VIEW3D_MT_curve_add", icon='OUTLINER_OB_CURVE')
|
||||
if context.preferences.experimental.use_new_curves_type:
|
||||
layout.menu("VIEW3D_MT_curves_add", icon='OUTLINER_OB_CURVES')
|
||||
# layout.operator_menu_enum("object.surface_add", "type", text="Surface", icon='OUTLINER_OB_SURFACE')
|
||||
layout.menu("VIEW3D_MT_surface_add", icon='OUTLINER_OB_SURFACE')
|
||||
layout.menu("VIEW3D_MT_metaball_add", text="Metaball", icon='OUTLINER_OB_META')
|
||||
layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT')
|
||||
if context.preferences.experimental.use_new_curves_type:
|
||||
layout.operator("object.hair_curves_add", text="Hair Curves", icon='OUTLINER_OB_CURVES')
|
||||
if context.preferences.experimental.use_new_point_cloud_type:
|
||||
layout.operator("object.pointcloud_add", text="Point Cloud", icon='OUTLINER_OB_POINTCLOUD')
|
||||
layout.menu("VIEW3D_MT_volume_add", text="Volume", icon='OUTLINER_OB_VOLUME')
|
||||
|
@ -7638,6 +7651,7 @@ classes = (
|
|||
VIEW3D_MT_angle_control,
|
||||
VIEW3D_MT_mesh_add,
|
||||
VIEW3D_MT_curve_add,
|
||||
VIEW3D_MT_curves_add,
|
||||
VIEW3D_MT_surface_add,
|
||||
VIEW3D_MT_edit_metaball_context_menu,
|
||||
VIEW3D_MT_metaball_add,
|
||||
|
|
|
@ -2044,10 +2044,10 @@ void OBJECT_OT_speaker_add(wmOperatorType *ot)
|
|||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Add Hair Curves Operator
|
||||
/** \name Add Curves Operator
|
||||
* \{ */
|
||||
|
||||
static bool object_hair_curves_add_poll(bContext *C)
|
||||
static bool object_curves_add_poll(bContext *C)
|
||||
{
|
||||
if (!U.experimental.use_new_curves_type) {
|
||||
return false;
|
||||
|
@ -2055,7 +2055,7 @@ static bool object_hair_curves_add_poll(bContext *C)
|
|||
return ED_operator_objectmode(C);
|
||||
}
|
||||
|
||||
static int object_hair_curves_add_exec(bContext *C, wmOperator *op)
|
||||
static int object_curves_random_add_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
using namespace blender;
|
||||
|
||||
|
@ -2075,16 +2075,16 @@ static int object_hair_curves_add_exec(bContext *C, wmOperator *op)
|
|||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void OBJECT_OT_hair_curves_add(wmOperatorType *ot)
|
||||
void OBJECT_OT_curves_random_add(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Add Hair Curves";
|
||||
ot->description = "Add a hair curves object to the scene";
|
||||
ot->idname = "OBJECT_OT_hair_curves_add";
|
||||
ot->name = "Add Random Curves";
|
||||
ot->description = "Add a curves object with random curves to the scene";
|
||||
ot->idname = "OBJECT_OT_curves_random_add";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = object_hair_curves_add_exec;
|
||||
ot->poll = object_hair_curves_add_poll;
|
||||
ot->exec = object_curves_random_add_exec;
|
||||
ot->poll = object_curves_add_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
@ -2092,6 +2092,43 @@ void OBJECT_OT_hair_curves_add(wmOperatorType *ot)
|
|||
ED_object_add_generic_props(ot, false);
|
||||
}
|
||||
|
||||
static int object_curves_empty_hair_add_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
ushort local_view_bits;
|
||||
float loc[3], rot[3];
|
||||
if (!ED_object_add_generic_get_opts(
|
||||
C, op, 'Z', loc, rot, nullptr, nullptr, &local_view_bits, nullptr)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
Object *surface_ob = CTX_data_active_object(C);
|
||||
|
||||
Object *object = ED_object_add_type(C, OB_CURVES, nullptr, loc, rot, false, local_view_bits);
|
||||
object->dtx |= OB_DRAWBOUNDOX; /* TODO: remove once there is actual drawing. */
|
||||
|
||||
if (surface_ob != nullptr && surface_ob->type == OB_MESH) {
|
||||
Curves *curves_id = static_cast<Curves *>(object->data);
|
||||
curves_id->surface = surface_ob;
|
||||
id_us_plus(&surface_ob->id);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void OBJECT_OT_curves_empty_hair_add(wmOperatorType *ot)
|
||||
{
|
||||
ot->name = "Add Empty Curves";
|
||||
ot->description = "Add an empty curve object to the scene with the selected mesh as surface";
|
||||
ot->idname = "OBJECT_OT_curves_empty_hair_add";
|
||||
|
||||
ot->exec = object_curves_empty_hair_add_exec;
|
||||
ot->poll = object_curves_add_poll;
|
||||
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
ED_object_add_generic_props(ot, false);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
|
|
@ -113,7 +113,8 @@ void OBJECT_OT_light_add(struct wmOperatorType *ot);
|
|||
void OBJECT_OT_effector_add(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_camera_add(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_speaker_add(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_hair_curves_add(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_curves_random_add(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_curves_empty_hair_add(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_pointcloud_add(struct wmOperatorType *ot);
|
||||
/**
|
||||
* Only used as menu.
|
||||
|
|
|
@ -89,7 +89,8 @@ void ED_operatortypes_object(void)
|
|||
WM_operatortype_append(OBJECT_OT_light_add);
|
||||
WM_operatortype_append(OBJECT_OT_camera_add);
|
||||
WM_operatortype_append(OBJECT_OT_speaker_add);
|
||||
WM_operatortype_append(OBJECT_OT_hair_curves_add);
|
||||
WM_operatortype_append(OBJECT_OT_curves_random_add);
|
||||
WM_operatortype_append(OBJECT_OT_curves_empty_hair_add);
|
||||
WM_operatortype_append(OBJECT_OT_pointcloud_add);
|
||||
WM_operatortype_append(OBJECT_OT_volume_add);
|
||||
WM_operatortype_append(OBJECT_OT_volume_import);
|
||||
|
|
Loading…
Reference in New Issue