Blender  V3.3
Classes
object_transform.cc File Reference
#include <cstdlib>
#include <cstring>
#include <numeric>
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
#include "DNA_collection_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_lattice_types.h"
#include "DNA_light_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BLI_array.hh"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_math_vector.hh"
#include "BLI_utildefines.h"
#include "BLI_vector.hh"
#include "BKE_armature.h"
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_curves.hh"
#include "BKE_editmesh.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_geom.h"
#include "BKE_idtype.h"
#include "BKE_lattice.h"
#include "BKE_layer.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_mball.h"
#include "BKE_mesh.h"
#include "BKE_multires.h"
#include "BKE_object.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_tracking.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "WM_api.h"
#include "WM_types.h"
#include "ED_armature.h"
#include "ED_gpencil.h"
#include "ED_keyframing.h"
#include "ED_mesh.h"
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_view3d.h"
#include "MEM_guardedalloc.h"
#include "object_intern.h"

Go to the source code of this file.

Classes

struct  XFormAxisItem
 
struct  XFormAxisData
 

Functions

Clear Transformation Utilities
static void object_clear_loc (Object *ob, const bool clear_delta)
 
static void object_clear_rot (Object *ob, const bool clear_delta)
 
static void object_clear_scale (Object *ob, const bool clear_delta)
 
static int object_clear_transform_generic_exec (bContext *C, wmOperator *op, void(*clear_func)(Object *, const bool), const char default_ksName[])
 
Clear Location Operator
static int object_location_clear_exec (bContext *C, wmOperator *op)
 
void OBJECT_OT_location_clear (wmOperatorType *ot)
 
Clear Rotation Operator
static int object_rotation_clear_exec (bContext *C, wmOperator *op)
 
void OBJECT_OT_rotation_clear (wmOperatorType *ot)
 
Clear Scale Operator
static int object_scale_clear_exec (bContext *C, wmOperator *op)
 
void OBJECT_OT_scale_clear (wmOperatorType *ot)
 
Clear Origin Operator
static int object_origin_clear_exec (bContext *C, wmOperator *UNUSED(op))
 
void OBJECT_OT_origin_clear (wmOperatorType *ot)
 
Apply Transformation Operator
static void ignore_parent_tx (Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob)
 
static void append_sorted_object_parent_hierarchy (Object *root_object, Object *object, Object **sorted_objects, int *object_index)
 
static Array< Object * > sorted_selected_editable_objects (bContext *C)
 
static bool apply_objects_internal_can_multiuser (bContext *C)
 
static bool apply_objects_internal_need_single_user (bContext *C)
 
static int apply_objects_internal (bContext *C, ReportList *reports, bool apply_loc, bool apply_rot, bool apply_scale, bool do_props, bool do_single_user)
 
static int visual_transform_apply_exec (bContext *C, wmOperator *UNUSED(op))
 
void OBJECT_OT_visual_transform_apply (wmOperatorType *ot)
 
static int object_transform_apply_exec (bContext *C, wmOperator *op)
 
static int object_transform_apply_invoke (bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 
void OBJECT_OT_transform_apply (wmOperatorType *ot)
 
Apply Parent Inverse Operator
static int object_parent_inverse_apply_exec (bContext *C, wmOperator *UNUSED(op))
 
void OBJECT_OT_parent_inverse_apply (wmOperatorType *ot)
 

Transform Axis Target

Note this is an experimental operator to point lights/cameras at objects. We may re-work how this behaves based on user feedback.

  • campbell.
#define USE_RELATIVE_ROTATION
 
#define USE_RENDER_OVERRIDE
 
#define USE_FAKE_DEPTH_INIT
 
static void object_transform_axis_target_calc_depth_init (XFormAxisData *xfd, const int mval[2])
 
static bool object_is_target_compat (const Object *ob)
 
static void object_transform_axis_target_free_data (wmOperator *op)
 
static void object_apply_rotation (Object *ob, const float rmat[3][3])
 
static void object_apply_location (Object *ob, const float loc[3])
 
static bool object_orient_to_location (Object *ob, const float rot_orig[3][3], const float axis[3], const float location[3], const bool z_flip)
 
static void object_transform_axis_target_cancel (bContext *C, wmOperator *op)
 
static int object_transform_axis_target_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
static int object_transform_axis_target_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
void OBJECT_OT_transform_axis_target (wmOperatorType *ot)
 

Set Object Center Operator

enum  {
  GEOMETRY_TO_ORIGIN = 0 , ORIGIN_TO_GEOMETRY , ORIGIN_TO_CURSOR , ORIGIN_TO_CENTER_OF_MASS_SURFACE ,
  ORIGIN_TO_CENTER_OF_MASS_VOLUME
}
 
static int object_origin_set_exec (bContext *C, wmOperator *op)
 
void OBJECT_OT_origin_set (wmOperatorType *ot)
 

Macro Definition Documentation

◆ USE_FAKE_DEPTH_INIT

#define USE_FAKE_DEPTH_INIT

Calculate a depth if the cursor isn't already over a depth (not essential but feels buggy without).

Definition at line 1834 of file object_transform.cc.

◆ USE_RELATIVE_ROTATION

#define USE_RELATIVE_ROTATION

When using multiple objects, apply their relative rotational offset to the active object.

Definition at line 1827 of file object_transform.cc.

◆ USE_RENDER_OVERRIDE

#define USE_RENDER_OVERRIDE

Disable overlays, ignoring user setting (light wire gets in the way).

Definition at line 1829 of file object_transform.cc.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
GEOMETRY_TO_ORIGIN 
ORIGIN_TO_GEOMETRY 
ORIGIN_TO_CURSOR 
ORIGIN_TO_CENTER_OF_MASS_SURFACE 
ORIGIN_TO_CENTER_OF_MASS_VOLUME 

Definition at line 1222 of file object_transform.cc.

Function Documentation

◆ append_sorted_object_parent_hierarchy()

static void append_sorted_object_parent_hierarchy ( Object root_object,
Object object,
Object **  sorted_objects,
int *  object_index 
)
static

Definition at line 547 of file object_transform.cc.

References ELEM, Object::id, LIB_TAG_DOIT, Object::parent, and ID::tag.

Referenced by sorted_selected_editable_objects().

◆ apply_objects_internal()

static int apply_objects_internal ( bContext C,
ReportList reports,
bool  apply_loc,
bool  apply_rot,
bool  apply_scale,
bool  do_props,
bool  do_single_user 
)
static

Definition at line 641 of file object_transform.cc.

References add_v3_v3v3(), apply_objects_internal_can_multiuser(), apply_objects_internal_need_single_user(), Light::area_shape, Light::area_size, Light::area_sizey, Light::area_sizez, BKE_armature_copy_bone_transforms(), BKE_armature_transform(), BKE_curve_transform_ex(), BKE_gpencil_transform(), BKE_idtype_idcode_to_name(), BKE_lattice_transform(), BKE_main_id_newptr_and_tag_clear(), BKE_mball_transform(), BKE_mesh_transform(), BKE_object_apply_mat4(), BKE_object_movieclip_get(), BKE_object_rot_to_mat3(), BKE_object_scale_to_mat3(), BKE_object_to_mat3(), BKE_object_transform_copy(), BKE_object_where_is_calc(), BKE_object_workob_calc_parent(), BKE_pose_where_is(), BKE_report(), BKE_reportf(), BKE_tracking_reconstruction_scale(), C, blender::bke::CurvesGeometry::calculate_bezier_auto_handles(), compare_ff_relative(), copy_m4_m3(), copy_m4_m4(), copy_v3_fl(), copy_v3_v3(), copy_v4_v4(), CTX_data_active_object(), CTX_DATA_BEGIN, CTX_DATA_END, CTX_data_ensure_evaluated_depsgraph(), CTX_data_main(), CTX_data_scene(), CU_3D, curves, Object::data, DEG_get_evaluated_object(), DEG_id_tag_update(), DEG_relations_tag_update(), depsgraph, ED_object_single_obdata_user(), ELEM, fabsf, ListBase::first, Curve::flag, Curve::fsize, GS, TextBox::h, bGPdata::id, Object::id, ID_GD, ID_IS_LINKED, ID_IS_OVERRIDE_LIBRARY, ID_REAL_USERS, ID_RECALC_GEOMETRY, ID_RECALC_TRANSFORM, id_us_min(), id_us_plus(), ignore_parent_tx(), invert_m3_m3(), invert_m4_m4(), blender::Array< T, InlineBufferCapacity, Allocator >::is_empty(), Curve::key, LA_AREA, LA_AREA_DISK, LA_AREA_ELLIPSE, LA_AREA_RECT, LA_AREA_SQUARE, bGPdata::layers, LISTBASE_FOREACH, Object::loc, mat3_to_scale(), max_fff(), mul_m3_m3m3(), mul_m3_v3(), mul_m4_m4_post(), multiresModifier_scale_disp(), ID::name, NC_OBJECT, NC_WINDOW, ND_TRANSFORM, OB_ARMATURE, OB_CAMERA, OB_CURVES, OB_CURVES_LEGACY, OB_EMPTY, OB_FONT, OB_GPENCIL, OB_LAMP, OB_LATTICE, OB_MBALL, OB_MESH, OB_SURF, Object::obmat, OPERATOR_CANCELLED, OPERATOR_FINISHED, Object::parentinv, Object::quat, Object::rot, Object::rotAngle, Object::rotAxis, RPT_ERROR, RPT_WARNING, Object::scale, scene, sorted_selected_editable_objects(), Curve::tb, Curve::totbox, MovieClip::tracking, blender::bke::CurvesGeometry::transform(), Light::type, unit_axis_angle(), unit_m3(), unit_qt(), TextBox::w, WM_event_add_notifier(), blender::bke::CurvesGeometry::wrap(), TextBox::x, TextBox::y, and zero_v3().

Referenced by object_transform_apply_exec().

◆ apply_objects_internal_can_multiuser()

static bool apply_objects_internal_can_multiuser ( bContext C)
static

Check if we need and can handle the special multiuser case.

Definition at line 596 of file object_transform.cc.

References C, CTX_data_active_object(), CTX_DATA_BEGIN, CTX_DATA_END, Object::data, ELEM, and ID_REAL_USERS.

Referenced by apply_objects_internal(), apply_objects_internal_need_single_user(), and object_transform_apply_invoke().

◆ apply_objects_internal_need_single_user()

static bool apply_objects_internal_need_single_user ( bContext C)
static

Check if the current selection need to be made into single user.

It assumes that all selected objects share the same object data.

Definition at line 631 of file object_transform.cc.

References apply_objects_internal_can_multiuser(), BLI_assert, C, CTX_data_active_object(), CTX_DATA_COUNT, Object::data, and ID_REAL_USERS.

Referenced by apply_objects_internal(), and object_transform_apply_invoke().

◆ ignore_parent_tx()

static void ignore_parent_tx ( Main bmain,
Depsgraph depsgraph,
Scene scene,
Object ob 
)
static

◆ object_apply_location()

static void object_apply_location ( Object ob,
const float  loc[3] 
)
static

◆ object_apply_rotation()

static void object_apply_rotation ( Object ob,
const float  rmat[3][3] 
)
static

◆ object_clear_loc()

static void object_clear_loc ( Object ob,
const bool  clear_delta 
)
static

◆ object_clear_rot()

static void object_clear_rot ( Object ob,
const bool  clear_delta 
)
static

◆ object_clear_scale()

static void object_clear_scale ( Object ob,
const bool  clear_delta 
)
static

◆ object_clear_transform_generic_exec()

static int object_clear_transform_generic_exec ( bContext C,
wmOperator op,
void(*)(Object *, const bool clear_func,
const char  default_ksName[] 
)
static

◆ object_is_target_compat()

static bool object_is_target_compat ( const Object ob)
static

◆ object_location_clear_exec()

static int object_location_clear_exec ( bContext C,
wmOperator op 
)
static

◆ object_orient_to_location()

static bool object_orient_to_location ( Object ob,
const float  rot_orig[3][3],
const float  axis[3],
const float  location[3],
const bool  z_flip 
)
static

◆ object_origin_clear_exec()

static int object_origin_clear_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ object_origin_set_exec()

static int object_origin_set_exec ( bContext C,
wmOperator op 
)
static

Definition at line 1230 of file object_transform.cc.

References add_v3_v3(), BKE_armature_copy_bone_transforms(), BKE_curve_center_bounds(), BKE_curve_center_median(), BKE_curve_translate(), BKE_gpencil_centroid_3d(), BKE_gpencil_layer_transform_matrix_get(), BKE_gpencil_stroke_geometry_update(), BKE_id_is_editable(), BKE_lattice_center_bounds(), BKE_lattice_center_median(), BKE_lattice_translate(), BKE_mball_center_bounds(), BKE_mball_center_median(), BKE_mball_translate(), BKE_mesh_center_bounds(), BKE_mesh_center_median(), BKE_mesh_center_of_surface(), BKE_mesh_center_of_volume(), BKE_mesh_translate(), BKE_object_batch_cache_dirty_tag(), BKE_object_minmax_dupli(), BKE_object_to_mat4(), BKE_object_transform_copy(), BKE_object_where_is_calc(), BKE_pose_where_is(), BKE_report(), BKE_reportf(), BMEditMesh::bm, BM_ITER_MESH, BM_VERTS_OF_MESH, C, BMVert::co, copy_m3_m4(), copy_v3_v3(), CTX_data_active_object(), CTX_data_edit_object(), CTX_data_ensure_evaluated_depsgraph(), CTX_data_main(), CTX_data_scene(), CU_3D, Scene::cursor, curves, blender::Array< T, InlineBufferCapacity, Allocator >::data(), Object::data, DEG_get_evaluated_object(), DEG_id_tag_update(), depsgraph, ED_armature_origin_set(), EDBM_mesh_normals_update(), Mesh::edit_mesh, ELEM, Curve::flag, Object::flag, float(), Curves::geometry, GEOMETRY_TO_ORIGIN, bArmature::id, Curve::id, Curves::id, bGPdata::id, Lattice::id, Mesh::id, MetaBall::id, Object::id, ID_IS_LINKED, ID_IS_OVERRIDE_LIBRARY, ID_REAL_USERS, ID_RECALC_COPY_ON_WRITE, ID_RECALC_GEOMETRY, ID_RECALC_TRANSFORM, ignore_parent_tx(), Object::imat, blender::Array< T, InlineBufferCapacity, Allocator >::index_range(), INIT_MINMAX, invert_m3_m3(), invert_m4_m4(), blender::Array< T, InlineBufferCapacity, Allocator >::is_empty(), bGPdata::layers, LIB_TAG_DOIT, LISTBASE_FOREACH, View3DCursor::location, madd_v3_v3fl(), max, mid_v3_v3v3(), blender::math::midpoint(), min, minmax_v3v3_v3(), mul_m3_v3(), mul_m4_v3(), mul_v3_m3v3(), mul_v3_m4v3(), mul_v3_mat3_m4v3(), NC_OBJECT, ND_TRANSFORM, negate_v3_v3(), OB_ARMATURE, OB_CURVES, OB_CURVES_LEGACY, OB_DONE, OB_DUPLICOLLECTION, OB_FONT, OB_GPENCIL, OB_LATTICE, OB_MBALL, OB_MESH, OB_SURF, Main::objects, Object::obmat, OPERATOR_CANCELLED, OPERATOR_FINISHED, ORIGIN_TO_CENTER_OF_MASS_SURFACE, ORIGIN_TO_CENTER_OF_MASS_VOLUME, ORIGIN_TO_CURSOR, ORIGIN_TO_GEOMETRY, positions, wmOperator::ptr, wmOperator::reports, RNA_enum_get(), RNA_property_enum_get(), RNA_property_enum_set(), RNA_property_is_set(), RNA_struct_find_property(), RPT_ERROR, RPT_WARNING, scene, blender::Array< T, InlineBufferCapacity, Allocator >::size(), sorted_selected_editable_objects(), sub_v3_v3(), sub_v3_v3v3(), ID::tag, Scene::toolsettings, BMesh::totvert, ToolSettings::transform_pivot_point, Object::type, V3D_AROUND_CENTER_BOUNDS, V3D_AROUND_CENTER_MEDIAN, BezTriple::vec, WM_event_add_notifier(), blender::bke::CurvesGeometry::wrap(), bGPDspoint::x, Curve::xof, Curve::yof, and zero_v3().

Referenced by OBJECT_OT_origin_set().

◆ OBJECT_OT_location_clear()

void OBJECT_OT_location_clear ( wmOperatorType ot)

◆ OBJECT_OT_origin_clear()

void OBJECT_OT_origin_clear ( wmOperatorType ot)

◆ OBJECT_OT_origin_set()

void OBJECT_OT_origin_set ( wmOperatorType ot)

◆ OBJECT_OT_parent_inverse_apply()

void OBJECT_OT_parent_inverse_apply ( wmOperatorType ot)

◆ OBJECT_OT_rotation_clear()

void OBJECT_OT_rotation_clear ( wmOperatorType ot)

◆ OBJECT_OT_scale_clear()

void OBJECT_OT_scale_clear ( wmOperatorType ot)

◆ OBJECT_OT_transform_apply()

void OBJECT_OT_transform_apply ( wmOperatorType ot)

◆ OBJECT_OT_transform_axis_target()

void OBJECT_OT_transform_axis_target ( wmOperatorType ot)

◆ OBJECT_OT_visual_transform_apply()

void OBJECT_OT_visual_transform_apply ( wmOperatorType ot)

◆ object_parent_inverse_apply_exec()

static int object_parent_inverse_apply_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ object_rotation_clear_exec()

static int object_rotation_clear_exec ( bContext C,
wmOperator op 
)
static

◆ object_scale_clear_exec()

static int object_scale_clear_exec ( bContext C,
wmOperator op 
)
static

◆ object_transform_apply_exec()

static int object_transform_apply_exec ( bContext C,
wmOperator op 
)
static

◆ object_transform_apply_invoke()

static int object_transform_apply_invoke ( bContext C,
wmOperator op,
const wmEvent UNUSEDevent 
)
static

◆ object_transform_axis_target_calc_depth_init()

static void object_transform_axis_target_calc_depth_init ( XFormAxisData xfd,
const int  mval[2] 
)
static

◆ object_transform_axis_target_cancel()

static void object_transform_axis_target_cancel ( bContext C,
wmOperator op 
)
static

◆ object_transform_axis_target_free_data()

static void object_transform_axis_target_free_data ( wmOperator op)
static

◆ object_transform_axis_target_invoke()

static int object_transform_axis_target_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ object_transform_axis_target_modal()

static int object_transform_axis_target_modal ( bContext C,
wmOperator op,
const wmEvent event 
)
static

Definition at line 2070 of file object_transform.cc.

References add_v3_v3(), C, copy_m3_m4(), copy_v3_v3(), wmOperator::customdata, DEG_id_tag_update(), XFormAxisData::depth, ViewDepths::depth_range, XFormAxisData::depths, dot_v3v3(), double(), ED_region_tag_redraw(), ED_view3d_depth_read_cached(), ED_view3d_depth_read_cached_normal(), ED_view3d_depth_unproject_v3(), ELEM, EVT_ESCKEY, EVT_PADENTER, EVT_RETKEY, fabsf, ViewDepths::h, Object::id, ID_RECALC_TRANSFORM, blender::Vector< T, InlineBufferCapacity, Allocator >::index_range(), XFormAxisData::init_event, invert_m3_m3(), XFormAxisData::is_depth_valid, XFormAxisData::is_normal_valid, XFormAxisData::is_translate, XFormAxisItem::is_z_flip, ISMOUSE_BUTTON, KM_CTRL, KM_RELEASE, LEFTMOUSE, len_v3v3(), madd_v3_v3fl(), MOUSEMOVE, mul_m3_m3m3(), mul_m3_v3(), wmEvent::mval, NC_OBJECT, ND_TRANSFORM, normal, XFormAxisData::normal, normalize_m3(), normalize_v3(), normalize_v3_v3(), XFormAxisItem::ob, object_apply_location(), XFormAxisData::object_data, object_orient_to_location(), object_transform_axis_target_calc_depth_init(), object_transform_axis_target_cancel(), object_transform_axis_target_free_data(), Object::obmat, OPERATOR_CANCELLED, OPERATOR_FINISHED, OPERATOR_RUNNING_MODAL, XFormAxisData::prev, ViewContext::region, RIGHTMOUSE, XFormAxisItem::rot_mat, blender::Vector< T, InlineBufferCapacity, Allocator >::size(), wmEvent::type, wmEvent::val, XFormAxisData::vc, view3d_operator_needs_opengl(), ViewDepths::w, WM_event_add_notifier(), x, XFormAxisItem::xform_dist, XFormAxisItem::xform_rot_offset, and y.

Referenced by OBJECT_OT_transform_axis_target().

◆ sorted_selected_editable_objects()

static Array<Object *> sorted_selected_editable_objects ( bContext C)
static

◆ visual_transform_apply_exec()

static int visual_transform_apply_exec ( bContext C,
wmOperator UNUSEDop 
)
static