Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_add.cc
| Show All 18 Lines | |||||
| #include "DNA_gpencil_modifier_types.h" | #include "DNA_gpencil_modifier_types.h" | ||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| #include "DNA_key_types.h" | #include "DNA_key_types.h" | ||||
| #include "DNA_light_types.h" | #include "DNA_light_types.h" | ||||
| #include "DNA_lightprobe_types.h" | #include "DNA_lightprobe_types.h" | ||||
| #include "DNA_material_types.h" | #include "DNA_material_types.h" | ||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_meta_types.h" | #include "DNA_meta_types.h" | ||||
| #include "DNA_modifier_types.h" | |||||
| #include "DNA_object_fluidsim_types.h" | #include "DNA_object_fluidsim_types.h" | ||||
| #include "DNA_object_force_types.h" | #include "DNA_object_force_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_pointcloud_types.h" | #include "DNA_pointcloud_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_vfont_types.h" | #include "DNA_vfont_types.h" | ||||
| #include "BLI_ghash.h" | #include "BLI_ghash.h" | ||||
| Show All 32 Lines | |||||
| #include "BKE_light.h" | #include "BKE_light.h" | ||||
| #include "BKE_lightprobe.h" | #include "BKE_lightprobe.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "BKE_mball.h" | #include "BKE_mball.h" | ||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "BKE_mesh_runtime.h" | #include "BKE_mesh_runtime.h" | ||||
| #include "BKE_nla.h" | #include "BKE_nla.h" | ||||
| #include "BKE_node.h" | |||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_particle.h" | #include "BKE_particle.h" | ||||
| #include "BKE_pointcloud.h" | #include "BKE_pointcloud.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_speaker.h" | #include "BKE_speaker.h" | ||||
| #include "BKE_vfont.h" | #include "BKE_vfont.h" | ||||
| #include "BKE_volume.h" | #include "BKE_volume.h" | ||||
| Show All 26 Lines | |||||
| #include "ED_select_utils.h" | #include "ED_select_utils.h" | ||||
| #include "ED_transform.h" | #include "ED_transform.h" | ||||
| #include "ED_view3d.h" | #include "ED_view3d.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "object_intern.h" | #include "object_intern.h" | ||||
| using blender::float3; | |||||
| using blender::float4x4; | |||||
| using blender::Vector; | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Local Enum Declarations | /** \name Local Enum Declarations | ||||
| * \{ */ | * \{ */ | ||||
| /* This is an exact copy of the define in `rna_light.c` | /* This is an exact copy of the define in `rna_light.c` | ||||
| * kept here because of linking order. | * kept here because of linking order. | ||||
| * Icons are only defined here */ | * Icons are only defined here */ | ||||
| const EnumPropertyItem rna_enum_light_type_items[] = { | const EnumPropertyItem rna_enum_light_type_items[] = { | ||||
| ▲ Show 20 Lines • Show All 1,940 Lines • ▼ Show 20 Lines | void OBJECT_OT_curves_random_add(wmOperatorType *ot) | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| ED_object_add_generic_props(ot, false); | ED_object_add_generic_props(ot, false); | ||||
| } | } | ||||
| static int object_curves_empty_hair_add_exec(bContext *C, wmOperator *op) | static int object_curves_empty_hair_add_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | |||||
| ushort local_view_bits; | ushort local_view_bits; | ||||
| float loc[3], rot[3]; | blender::float3 loc, rot; | ||||
| if (!ED_object_add_generic_get_opts( | if (!ED_object_add_generic_get_opts( | ||||
| C, op, 'Z', loc, rot, nullptr, nullptr, &local_view_bits, nullptr)) { | C, op, 'Z', loc, rot, nullptr, nullptr, &local_view_bits, nullptr)) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| Object *surface_ob = CTX_data_active_object(C); | Object *surface_ob = CTX_data_active_object(C); | ||||
| BLI_assert(surface_ob != nullptr); | |||||
| Object *object = ED_object_add_type(C, OB_CURVES, nullptr, loc, rot, false, local_view_bits); | Object *curves_ob = ED_object_add_type(C, OB_CURVES, nullptr, loc, rot, false, local_view_bits); | ||||
| if (surface_ob != nullptr && surface_ob->type == OB_MESH) { | /* Set surface object. */ | ||||
| Curves *curves_id = static_cast<Curves *>(object->data); | Curves *curves_id = static_cast<Curves *>(curves_ob->data); | ||||
| curves_id->surface = surface_ob; | curves_id->surface = surface_ob; | ||||
| id_us_plus(&surface_ob->id); | |||||
| /* Parent to surface object. */ | |||||
| ED_object_parent_set( | |||||
| op->reports, C, scene, curves_ob, surface_ob, PAR_OBJECT, false, true, nullptr); | |||||
| /* Decide which UV map to use for attachment. */ | |||||
| Mesh *surface_mesh = static_cast<Mesh *>(surface_ob->data); | Mesh *surface_mesh = static_cast<Mesh *>(surface_ob->data); | ||||
| const char *uv_name = CustomData_get_active_layer_name(&surface_mesh->ldata, CD_MLOOPUV); | const char *uv_name = CustomData_get_active_layer_name(&surface_mesh->ldata, CD_MLOOPUV); | ||||
| if (uv_name != nullptr) { | if (uv_name != nullptr) { | ||||
| curves_id->surface_uv_map = BLI_strdup(uv_name); | curves_id->surface_uv_map = BLI_strdup(uv_name); | ||||
| } | } | ||||
| } | |||||
| /* Add deformation modifier. */ | |||||
| blender::ed::curves::ensure_surface_deformation_node_exists(*C, *curves_ob); | |||||
| /* Make sure the surface object has a rest position attribute which is necessary for | |||||
| * deformations. */ | |||||
| surface_ob->modifier_flag |= OB_MODIFIER_FLAG_ADD_REST_POSITION; | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static bool object_curves_empty_hair_add_poll(bContext *C) | static bool object_curves_empty_hair_add_poll(bContext *C) | ||||
| { | { | ||||
| if (!U.experimental.use_new_curves_type) { | if (!U.experimental.use_new_curves_type) { | ||||
| return false; | return false; | ||||
| ▲ Show 20 Lines • Show All 2,114 Lines • Show Last 20 Lines | |||||