Blender V5.0
object_add.cc File Reference
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <optional>
#include "DNA_anim_types.h"
#include "DNA_camera_types.h"
#include "DNA_collection_types.h"
#include "DNA_curve_types.h"
#include "DNA_gpencil_legacy_types.h"
#include "DNA_key_types.h"
#include "DNA_light_types.h"
#include "DNA_lightprobe_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_force_types.h"
#include "DNA_object_types.h"
#include "DNA_pointcloud_types.h"
#include "DNA_scene_types.h"
#include "DNA_vfont_types.h"
#include "BLI_array_utils.hh"
#include "BLI_bounds.hh"
#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "BLI_math_color.h"
#include "BLI_math_matrix.h"
#include "BLI_math_matrix_types.hh"
#include "BLI_math_rotation.h"
#include "BLI_math_vector_types.hh"
#include "BLI_rand.hh"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_utildefines.h"
#include "BLI_vector.hh"
#include "BLT_translation.hh"
#include "BKE_action.hh"
#include "BKE_anim_data.hh"
#include "BKE_anonymous_attribute_id.hh"
#include "BKE_armature.hh"
#include "BKE_camera.h"
#include "BKE_collection.hh"
#include "BKE_constraint.h"
#include "BKE_context.hh"
#include "BKE_curve.hh"
#include "BKE_curve_legacy_convert.hh"
#include "BKE_curve_to_mesh.hh"
#include "BKE_curves.h"
#include "BKE_curves.hh"
#include "BKE_customdata.hh"
#include "BKE_deform.hh"
#include "BKE_displist.h"
#include "BKE_duplilist.hh"
#include "BKE_effect.h"
#include "BKE_geometry_set.hh"
#include "BKE_geometry_set_instances.hh"
#include "BKE_grease_pencil.hh"
#include "BKE_key.hh"
#include "BKE_lattice.hh"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_override.hh"
#include "BKE_lib_query.hh"
#include "BKE_lib_remap.hh"
#include "BKE_library.hh"
#include "BKE_light.h"
#include "BKE_lightprobe.h"
#include "BKE_main.hh"
#include "BKE_material.hh"
#include "BKE_mball.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_runtime.hh"
#include "BKE_modifier.hh"
#include "BKE_nla.hh"
#include "BKE_node.hh"
#include "BKE_object.hh"
#include "BKE_object_types.hh"
#include "BKE_particle.h"
#include "BKE_pointcloud.hh"
#include "BKE_report.hh"
#include "BKE_scene.hh"
#include "BKE_speaker.h"
#include "BKE_vfont.hh"
#include "BKE_volume.hh"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_build.hh"
#include "DEG_depsgraph_query.hh"
#include "GEO_join_geometries.hh"
#include "GEO_mesh_to_curve.hh"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "RNA_enum_types.hh"
#include "UI_interface_layout.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "ED_armature.hh"
#include "ED_curve.hh"
#include "ED_curves.hh"
#include "ED_gpencil_legacy.hh"
#include "ED_grease_pencil.hh"
#include "ED_mball.hh"
#include "ED_mesh.hh"
#include "ED_node.hh"
#include "ED_object.hh"
#include "ED_outliner.hh"
#include "ED_physics.hh"
#include "ED_pointcloud.hh"
#include "ED_render.hh"
#include "ED_screen.hh"
#include "ED_select_utils.hh"
#include "ED_transform.hh"
#include "ED_view3d.hh"
#include "ANIM_bone_collections.hh"
#include "UI_resources.hh"
#include "object_intern.hh"

Go to the source code of this file.

Classes

struct  blender::ed::object::CollectionAddInfo
struct  blender::ed::object::ObjectConversionInfo
class  blender::ed::object::FillColorRecord

Namespaces

namespace  blender
namespace  blender::ed
namespace  blender::ed::object

Macros

#define CURVE_VFONT_CLEAR(vfont_member)

Functions

Local Helpers
static void blender::ed::object::object_add_drop_xy_props (wmOperatorType *ot)
static bool blender::ed::object::object_add_drop_xy_is_set (const wmOperator *op)
static bool blender::ed::object::object_add_drop_xy_get (bContext *C, wmOperator *op, int(*r_mval)[2])
static wmOperatorStatus blender::ed::object::object_add_drop_xy_generic_invoke (bContext *C, wmOperator *op, const wmEvent *event)
Public Add Object API
void blender::ed::object::location_from_view (bContext *C, float loc[3])
void blender::ed::object::rotation_from_quat (float rot[3], const float quat[4], char align_axis)
void blender::ed::object::rotation_from_view (bContext *C, float rot[3], char align_axis)
void blender::ed::object::init_transform_on_add (Object *object, const float loc[3], const float rot[3])
float blender::ed::object::new_primitive_matrix (bContext *C, Object *obedit, const float loc[3], const float rot[3], const float scale[3], float primmat[4][4])
Add Object Operator
static void blender::ed::object::view_align_update (Main *, Scene *, PointerRNA *ptr)
void blender::ed::object::add_unit_props_size (wmOperatorType *ot)
void blender::ed::object::add_unit_props_radius_ex (wmOperatorType *ot, float default_value)
void blender::ed::object::add_unit_props_radius (wmOperatorType *ot)
void blender::ed::object::add_generic_props (wmOperatorType *ot, bool do_editmode)
void blender::ed::object::add_mesh_props (wmOperatorType *ot)
void blender::ed::object::add_generic_get_opts (bContext *C, wmOperator *op, char view_align_axis, float r_loc[3], float r_rot[3], float r_scale[3], bool *r_enter_editmode, unsigned short *r_local_view_bits, bool *r_is_view_aligned)
Objectblender::ed::object::add_type_with_obdata (bContext *C, int type, const char *name, const float loc[3], const float rot[3], bool enter_editmode, ushort local_view_bits, ID *obdata)
Objectblender::ed::object::add_type (bContext *C, int type, const char *name, const float loc[3], const float rot[3], bool enter_editmode, unsigned short local_view_bits) ATTR_NONNULL(1) ATTR_RETURNS_NONNULL
static bool blender::ed::object::object_can_have_lattice_modifier (const Object *ob)
static wmOperatorStatus blender::ed::object::object_add_exec (bContext *C, wmOperator *op)
void blender::ed::object::OBJECT_OT_add (wmOperatorType *ot)
Add Lattice Deformation to Selected Operator
static std::optional< Bounds< float3 > > blender::ed::object::lattice_add_to_selected_collect_targets_and_calc_bounds (bContext *C, const float orientation_matrix[3][3], Vector< Object * > &r_targets)
static wmOperatorStatus blender::ed::object::lattice_add_to_selected_exec (bContext *C, wmOperator *op)
static bool blender::ed::object::object_add_to_selected_poll_property (const bContext *, wmOperator *op, const PropertyRNA *prop)
void blender::ed::object::OBJECT_OT_lattice_add_to_selected (wmOperatorType *ot)
Add Probe Operator
static const char * blender::ed::object::get_lightprobe_defname (int type)
static wmOperatorStatus blender::ed::object::lightprobe_add_exec (bContext *C, wmOperator *op)
void blender::ed::object::OBJECT_OT_lightprobe_add (wmOperatorType *ot)
Add Effector Operator
static const char * blender::ed::object::get_effector_defname (ePFieldType type)
static wmOperatorStatus blender::ed::object::effector_add_exec (bContext *C, wmOperator *op)
void blender::ed::object::OBJECT_OT_effector_add (wmOperatorType *ot)
Add Camera Operator
static wmOperatorStatus blender::ed::object::object_camera_add_exec (bContext *C, wmOperator *op)
void blender::ed::object::OBJECT_OT_camera_add (wmOperatorType *ot)
Add Metaball Operator
static wmOperatorStatus blender::ed::object::object_metaball_add_exec (bContext *C, wmOperator *op)
void blender::ed::object::OBJECT_OT_metaball_add (wmOperatorType *ot)
Add Text Operator
static wmOperatorStatus blender::ed::object::object_add_text_exec (bContext *C, wmOperator *op)
void blender::ed::object::OBJECT_OT_text_add (wmOperatorType *ot)
Add Armature Operator
static wmOperatorStatus blender::ed::object::object_armature_add_exec (bContext *C, wmOperator *op)
void blender::ed::object::OBJECT_OT_armature_add (wmOperatorType *ot)
Add Empty Operator
static wmOperatorStatus blender::ed::object::object_empty_add_exec (bContext *C, wmOperator *op)
void blender::ed::object::OBJECT_OT_empty_add (wmOperatorType *ot)
static wmOperatorStatus blender::ed::object::object_image_add_exec (bContext *C, wmOperator *op)
static wmOperatorStatus blender::ed::object::object_image_add_invoke (bContext *C, wmOperator *op, const wmEvent *event)
static bool blender::ed::object::object_image_add_poll (bContext *C)
void blender::ed::object::OBJECT_OT_empty_image_add (wmOperatorType *ot)
Add Light Operator
static const char * blender::ed::object::get_light_defname (int type)
static wmOperatorStatus blender::ed::object::object_light_add_exec (bContext *C, wmOperator *op)
void blender::ed::object::OBJECT_OT_light_add (wmOperatorType *ot)
Add Collection Instance Operator
static std::optional< CollectionAddInfoblender::ed::object::collection_add_info_get_from_op (bContext *C, wmOperator *op)
static wmOperatorStatus blender::ed::object::collection_instance_add_exec (bContext *C, wmOperator *op)
static wmOperatorStatus blender::ed::object::object_instance_add_invoke (bContext *C, wmOperator *op, const wmEvent *event)
void blender::ed::object::OBJECT_OT_collection_instance_add (wmOperatorType *ot)
Collection Drop Operator

Internal operator for collection dropping.

Warning
This is tied closely together to the drop-box callbacks, so it shouldn't be used on its own.

The drop-box callback imports the collection, links it into the view-layer, selects all imported objects (which may include peripheral objects like parents or boolean-objects of an object in the collection) and activates one. Only the callback has enough info to do this reliably. Based on the instancing operator option, this operator then does one of two things:

  • Instancing enabled: Unlink the collection again, and instead add a collection instance empty at the drop position.
  • Instancing disabled: Transform the objects to the drop position, keeping all relative transforms of the objects to each other as is.
static wmOperatorStatus blender::ed::object::collection_drop_exec (bContext *C, wmOperator *op)
void blender::ed::object::OBJECT_OT_collection_external_asset_drop (wmOperatorType *ot)
Add Data Instance Operator

Use for dropping ID's from the outliner.

static wmOperatorStatus blender::ed::object::object_data_instance_add_exec (bContext *C, wmOperator *op)
void blender::ed::object::OBJECT_OT_data_instance_add (wmOperatorType *ot)
Add Speaker Operator
static wmOperatorStatus blender::ed::object::object_speaker_add_exec (bContext *C, wmOperator *op)
void blender::ed::object::OBJECT_OT_speaker_add (wmOperatorType *ot)
Add Curves Operator
static wmOperatorStatus blender::ed::object::object_curves_random_add_exec (bContext *C, wmOperator *op)
void blender::ed::object::OBJECT_OT_curves_random_add (wmOperatorType *ot)
static wmOperatorStatus blender::ed::object::object_curves_empty_hair_add_exec (bContext *C, wmOperator *op)
static bool blender::ed::object::object_curves_empty_hair_add_poll (bContext *C)
void blender::ed::object::OBJECT_OT_curves_empty_hair_add (wmOperatorType *ot)
Add Point Cloud Operator
static wmOperatorStatus blender::ed::object::object_pointcloud_add_exec (bContext *C, wmOperator *op)
void blender::ed::object::OBJECT_OT_pointcloud_random_add (wmOperatorType *ot)
Delete Object Operator
void blender::ed::object::base_free_and_unlink (Main *bmain, Scene *scene, Object *ob)
void blender::ed::object::base_free_and_unlink_no_indirect_check (Main *bmain, Scene *scene, Object *ob)
static wmOperatorStatus blender::ed::object::object_delete_exec (bContext *C, wmOperator *op)
static wmOperatorStatus blender::ed::object::object_delete_invoke (bContext *C, wmOperator *op, const wmEvent *)
void blender::ed::object::OBJECT_OT_delete (wmOperatorType *ot)
Copy Object Utilities
static void blender::ed::object::copy_object_set_idnew (bContext *C)
Make Instanced Objects Real Operator
static uint blender::ed::object::dupliobject_hash (const void *ptr)
static uint blender::ed::object::dupliobject_instancer_hash (const void *ptr)
static bool blender::ed::object::dupliobject_cmp (const void *a_, const void *b_)
static bool blender::ed::object::dupliobject_instancer_cmp (const void *a_, const void *b_)
static void blender::ed::object::make_object_duplilist_real (bContext *C, Depsgraph *depsgraph, Scene *scene, Base *base, const bool use_base_parent, const bool use_hierarchy)
static wmOperatorStatus blender::ed::object::object_duplicates_make_real_exec (bContext *C, wmOperator *op)
void blender::ed::object::OBJECT_OT_duplicates_make_real (wmOperatorType *ot)
Duplicate Object Operator
static void blender::ed::object::object_add_sync_base_collection (Main *bmain, Scene *scene, ViewLayer *view_layer, Base *base_src, Object *object_new)
static void blender::ed::object::object_add_sync_local_view (Base *base_src, Base *base_new)
static void blender::ed::object::object_add_sync_rigid_body (Main *bmain, Object *object_src, Object *object_new)
static void blender::ed::object::object_add_duplicate_internal (Main *bmain, Object *ob, const eDupli_ID_Flags dupflag, const eLibIDDuplicateFlags duplicate_options, Object **r_ob_new)
static Baseblender::ed::object::object_add_duplicate_internal (Main *bmain, Scene *scene, ViewLayer *view_layer, Object *ob, const eDupli_ID_Flags dupflag, const eLibIDDuplicateFlags duplicate_options, Object **r_ob_new)
Baseblender::ed::object::add_duplicate (Main *bmain, Scene *scene, ViewLayer *view_layer, Base *base, eDupli_ID_Flags dupflag)
static wmOperatorStatus blender::ed::object::duplicate_exec (bContext *C, wmOperator *op)
void blender::ed::object::OBJECT_OT_duplicate (wmOperatorType *ot)
Add Named Object Operator

Use for drag & drop.

static wmOperatorStatus blender::ed::object::object_add_named_exec (bContext *C, wmOperator *op)
void blender::ed::object::OBJECT_OT_add_named (wmOperatorType *ot)
Transform Object to Mouse Operator
static wmOperatorStatus blender::ed::object::object_transform_to_mouse_exec (bContext *C, wmOperator *op)
void blender::ed::object::OBJECT_OT_transform_to_mouse (wmOperatorType *ot)
Join Object Operator
static bool blender::ed::object::object_join_poll (bContext *C)
static wmOperatorStatus blender::ed::object::object_join_exec (bContext *C, wmOperator *op)
void blender::ed::object::OBJECT_OT_join (wmOperatorType *ot)
Join Key Data Operators
static bool blender::ed::object::active_shape_key_editable_poll (bContext *C)
static wmOperatorStatus blender::ed::object::join_shapes_exec (bContext *C, wmOperator *op)
void blender::ed::object::OBJECT_OT_join_shapes (wmOperatorType *ot)
static wmOperatorStatus blender::ed::object::update_all_shape_keys_exec (bContext *C, wmOperator *op)
static bool blender::ed::object::object_update_shapes_poll (bContext *C)
void blender::ed::object::OBJECT_OT_update_shapes (wmOperatorType *ot)

Variables

const EnumPropertyItem rna_enum_light_type_items []

Local Enum Declarations

enum  { blender::ed::object::ALIGN_WORLD = 0 , blender::ed::object::ALIGN_VIEW , blender::ed::object::ALIGN_CURSOR }
static const EnumPropertyItem blender::ed::object::field_type_items []
static EnumPropertyItem blender::ed::object::lightprobe_type_items []
static const EnumPropertyItem blender::ed::object::align_options []

Add Grease Pencil Operator

static EnumPropertyItem blender::ed::object::rna_enum_gpencil_add_stroke_depth_order_items []
static wmOperatorStatus blender::ed::object::object_grease_pencil_add_exec (bContext *C, wmOperator *op)
static wmOperatorStatus blender::ed::object::object_grease_pencil_add_invoke (bContext *C, wmOperator *op, const wmEvent *)
void blender::ed::object::OBJECT_OT_grease_pencil_add (wmOperatorType *ot)

Data Convert Operator

static const EnumPropertyItem blender::ed::object::convert_target_items []
static const EnumPropertyItemblender::ed::object::convert_target_itemf (bContext *C, PointerRNA *, PropertyRNA *, bool *r_free)
static void blender::ed::object::object_data_convert_curve_to_mesh (Main *bmain, Depsgraph *depsgraph, Object *ob)
static bool blender::ed::object::object_convert_poll (bContext *C)
static Baseblender::ed::object::duplibase_for_convert (Main *bmain, Depsgraph *depsgraph, Scene *scene, ViewLayer *view_layer, Base *base, Object *ob)
static Objectblender::ed::object::get_object_for_conversion (Base &base, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_mesh_to_curves_legacy (Base &base, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_curves_component_to_curves (Base &base, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_grease_pencil_component_to_curves (Base &base, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_mesh_to_curves (Base &base, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_mesh_to_pointcloud (Base &base, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_mesh_to_mesh (Base &base, ObjectConversionInfo &info, Base **r_new_base)
static int blender::ed::object::mesh_to_grease_pencil_add_material (Main &bmain, Object &ob_grease_pencil, const StringRefNull name, const std::optional< float4 > &stroke_color, const std::optional< float4 > &fill_color)
static VectorSet< FillColorRecordblender::ed::object::mesh_to_grease_pencil_get_material_list (Object &ob_mesh, const Mesh &mesh, Array< int > &material_remap)
static void blender::ed::object::mesh_data_to_grease_pencil (const Mesh &mesh_eval, GreasePencil &grease_pencil, const int current_frame, const bool generate_faces, const float stroke_radius, const float offset, const Array< int > &material_remap)
static Objectblender::ed::object::convert_mesh_to_grease_pencil (Base &base, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_mesh (Base &base, const ObjectType target, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_curves_to_mesh (Base &base, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_curves_to_grease_pencil (Base &base, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_curves (Base &base, const ObjectType target, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_grease_pencil_to_mesh (Base &base, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_grease_pencil (Base &base, const ObjectType target, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_font_to_curve_legacy_generic (Object *ob, Object *newob, ObjectConversionInfo &info)
static Objectblender::ed::object::convert_font_to_curves_legacy (Base &base, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_font_to_curves (Base &base, ObjectConversionInfo &info, Base **r_new_base)
static void blender::ed::object::add_grease_pencil_materials_for_conversion (Main &bmain, ID &from_id, Object &gp_object, const bool use_fill)
static Objectblender::ed::object::convert_font_to_grease_pencil (Base &base, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_font_to_mesh (Base &base, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_font (Base &base, const short target, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_curves_legacy_to_mesh (Base &base, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_curves_legacy_to_curves (Base &base, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_curves_legacy_to_grease_pencil (Base &base, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_curves_legacy (Base &base, const ObjectType target, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_mball_to_mesh (Base &base, ObjectConversionInfo &info, bool &r_mball_converted, Base **r_new_base, Base **r_act_base)
static Objectblender::ed::object::convert_mball (Base &base, const ObjectType target, ObjectConversionInfo &info, bool &r_mball_converted, Base **r_new_base, Base **r_act_base)
static Objectblender::ed::object::convert_pointcloud_to_mesh (Base &base, ObjectConversionInfo &info, Base **r_new_base)
static Objectblender::ed::object::convert_pointcloud (Base &base, const ObjectType target, ObjectConversionInfo &info, Base **r_new_base)
static wmOperatorStatus blender::ed::object::object_convert_exec (bContext *C, wmOperator *op)
static void blender::ed::object::object_convert_ui (bContext *, wmOperator *op)
void blender::ed::object::OBJECT_OT_convert (wmOperatorType *ot)

Macro Definition Documentation

◆ CURVE_VFONT_CLEAR

#define CURVE_VFONT_CLEAR ( vfont_member)
Value:
if (cu->vfont_member) { \
id_us_min(&cu->vfont_member->id); \
cu->vfont_member = nullptr; \
} \
((void)0)

Referenced by blender::ed::object::convert_font_to_curve_legacy_generic().

Variable Documentation

◆ rna_enum_light_type_items

const EnumPropertyItem rna_enum_light_type_items[]
Initial value:
= {
{LA_LOCAL, "POINT", ICON_LIGHT_POINT, "Point", "Omnidirectional point light source"},
{LA_SUN, "SUN", ICON_LIGHT_SUN, "Sun", "Constant direction parallel ray light source"},
{LA_SPOT, "SPOT", ICON_LIGHT_SPOT, "Spot", "Directional cone light source"},
{LA_AREA, "AREA", ICON_LIGHT_AREA, "Area", "Directional area light source"},
{0, nullptr, 0, nullptr, nullptr},
}
@ LA_AREA
@ LA_LOCAL
@ LA_SPOT
@ LA_SUN

Definition at line 138 of file object_add.cc.

Referenced by blender::ed::object::OBJECT_OT_light_add(), rna_def_light(), and RNA_def_main_lights().