Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/curves/intern/curves_ops.cc
| Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | |||||
| * `cu`: Local space of the curves object that is being edited. | * `cu`: Local space of the curves object that is being edited. | ||||
| * `su`: Local space of the surface object. | * `su`: Local space of the surface object. | ||||
| * `wo`: World space. | * `wo`: World space. | ||||
| * `ha`: Local space of an individual hair in the legacy hair system. | * `ha`: Local space of an individual hair in the legacy hair system. | ||||
| */ | */ | ||||
| namespace blender::ed::curves { | namespace blender::ed::curves { | ||||
| static bool object_has_editable_curves(const Main &bmain, const Object &object) | bool object_has_editable_curves(const Main &bmain, const Object &object) | ||||
| { | { | ||||
| if (object.type != OB_CURVES) { | if (object.type != OB_CURVES) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (!ELEM(object.mode, OB_MODE_SCULPT_CURVES, OB_MODE_EDIT)) { | if (!ELEM(object.mode, OB_MODE_SCULPT_CURVES, OB_MODE_EDIT)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (!BKE_id_is_editable(&bmain, static_cast<const ID *>(object.data))) { | if (!BKE_id_is_editable(&bmain, static_cast<const ID *>(object.data))) { | ||||
| Show All 18 Lines | if (object_has_editable_curves(bmain, *object)) { | ||||
| unique_curves.add(static_cast<Curves *>(object->data)); | unique_curves.add(static_cast<Curves *>(object->data)); | ||||
| } | } | ||||
| } | } | ||||
| CTX_DATA_END; | CTX_DATA_END; | ||||
| return unique_curves; | return unique_curves; | ||||
| } | } | ||||
| static bool curves_poll_impl(bContext *C, const bool check_editable, const bool check_surface) | static bool curves_poll_impl(bContext *C, | ||||
| const bool check_editable, | |||||
| const bool check_surface, | |||||
| const bool check_edit_mode) | |||||
| { | { | ||||
| Object *object = CTX_data_active_object(C); | Object *object = CTX_data_active_object(C); | ||||
| if (object == nullptr || object->type != OB_CURVES) { | if (object == nullptr || object->type != OB_CURVES) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (check_editable) { | if (check_editable) { | ||||
| if (!ED_operator_object_active_editable_ex(C, object)) { | if (!ED_operator_object_active_editable_ex(C, object)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| if (check_surface) { | if (check_surface) { | ||||
| Curves &curves = *static_cast<Curves *>(object->data); | Curves &curves = *static_cast<Curves *>(object->data); | ||||
| if (curves.surface == nullptr || curves.surface->type != OB_MESH) { | if (curves.surface == nullptr || curves.surface->type != OB_MESH) { | ||||
| CTX_wm_operator_poll_msg_set(C, "Curves must have a mesh surface object set"); | CTX_wm_operator_poll_msg_set(C, "Curves must have a mesh surface object set"); | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| if (check_edit_mode) { | |||||
| if ((object->mode & OB_MODE_EDIT) == 0) { | |||||
| return false; | |||||
| } | |||||
| } | |||||
| return true; | return true; | ||||
| } | } | ||||
| bool editable_curves_in_edit_mode_poll(bContext *C) | |||||
| { | |||||
| return curves_poll_impl(C, true, false, true); | |||||
| } | |||||
| bool editable_curves_with_surface_poll(bContext *C) | bool editable_curves_with_surface_poll(bContext *C) | ||||
| { | { | ||||
| return curves_poll_impl(C, true, true); | return curves_poll_impl(C, true, true, false); | ||||
| } | } | ||||
| bool curves_with_surface_poll(bContext *C) | bool curves_with_surface_poll(bContext *C) | ||||
| { | { | ||||
| return curves_poll_impl(C, false, true); | return curves_poll_impl(C, false, true, false); | ||||
| } | } | ||||
| bool editable_curves_poll(bContext *C) | bool editable_curves_poll(bContext *C) | ||||
| { | { | ||||
| return curves_poll_impl(C, false, false); | return curves_poll_impl(C, false, false, false); | ||||
| } | } | ||||
| bool curves_poll(bContext *C) | bool curves_poll(bContext *C) | ||||
| { | { | ||||
| return curves_poll_impl(C, false, false); | return curves_poll_impl(C, false, false, false); | ||||
| } | } | ||||
| using bke::CurvesGeometry; | using bke::CurvesGeometry; | ||||
| namespace convert_to_particle_system { | namespace convert_to_particle_system { | ||||
| static int find_mface_for_root_position(const Span<float3> positions, | static int find_mface_for_root_position(const Span<float3> positions, | ||||
| const MFace *mface, | const MFace *mface, | ||||
| ▲ Show 20 Lines • Show All 893 Lines • Show Last 20 Lines | |||||