2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation, 2002-2008 full recode
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/object/object_transform.c
|
|
|
|
* \ingroup edobj
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
#include <stdlib.h>
|
2009-11-23 15:08:42 +00:00
|
|
|
#include <string.h>
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2009-11-23 11:58:30 +00:00
|
|
|
#include "DNA_anim_types.h"
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
#include "DNA_armature_types.h"
|
2012-02-19 22:17:30 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
2012-02-26 08:55:31 +00:00
|
|
|
#include "DNA_meta_types.h"
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
2010-08-03 00:56:43 +00:00
|
|
|
#include "DNA_group_types.h"
|
2012-03-20 23:09:28 +00:00
|
|
|
#include "DNA_lattice_types.h"
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
#include "BLI_listbase.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_curve.h"
|
|
|
|
#include "BKE_depsgraph.h"
|
|
|
|
#include "BKE_main.h"
|
2013-09-18 22:45:14 +00:00
|
|
|
#include "BKE_idcode.h"
|
2012-02-26 08:55:31 +00:00
|
|
|
#include "BKE_mball.h"
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
#include "BKE_mesh.h"
|
|
|
|
#include "BKE_object.h"
|
|
|
|
#include "BKE_report.h"
|
2013-04-13 20:31:52 +00:00
|
|
|
#include "BKE_editmesh.h"
|
2010-10-25 08:03:05 +00:00
|
|
|
#include "BKE_multires.h"
|
2011-04-20 04:11:12 +00:00
|
|
|
#include "BKE_armature.h"
|
2013-02-01 16:03:42 +00:00
|
|
|
#include "BKE_lattice.h"
|
2013-05-13 13:37:05 +00:00
|
|
|
#include "BKE_tracking.h"
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "ED_armature.h"
|
2009-11-23 11:58:30 +00:00
|
|
|
#include "ED_keyframing.h"
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
#include "ED_mesh.h"
|
|
|
|
#include "ED_screen.h"
|
|
|
|
#include "ED_view3d.h"
|
|
|
|
|
|
|
|
#include "object_intern.h"
|
|
|
|
|
|
|
|
/*************************** Clear Transformation ****************************/
|
|
|
|
|
2011-01-26 09:27:43 +00:00
|
|
|
/* clear location of object */
|
2016-07-09 11:52:09 +12:00
|
|
|
static void object_clear_loc(Object *ob, const bool clear_delta)
|
2011-01-26 09:27:43 +00:00
|
|
|
{
|
|
|
|
/* clear location if not locked */
|
2016-07-09 11:52:09 +12:00
|
|
|
if ((ob->protectflag & OB_LOCK_LOCX) == 0) {
|
|
|
|
ob->loc[0] = 0.0f;
|
|
|
|
if (clear_delta) ob->dloc[0] = 0.0f;
|
|
|
|
}
|
|
|
|
if ((ob->protectflag & OB_LOCK_LOCY) == 0) {
|
|
|
|
ob->loc[1] = 0.0f;
|
|
|
|
if (clear_delta) ob->dloc[1] = 0.0f;
|
|
|
|
}
|
|
|
|
if ((ob->protectflag & OB_LOCK_LOCZ) == 0) {
|
|
|
|
ob->loc[2] = 0.0f;
|
|
|
|
if (clear_delta) ob->dloc[2] = 0.0f;
|
|
|
|
}
|
2011-01-26 09:27:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* clear rotation of object */
|
2016-07-09 11:52:09 +12:00
|
|
|
static void object_clear_rot(Object *ob, const bool clear_delta)
|
2011-01-26 09:27:43 +00:00
|
|
|
{
|
|
|
|
/* clear rotations that aren't locked */
|
2012-04-28 15:42:27 +00:00
|
|
|
if (ob->protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) {
|
2011-01-26 09:27:43 +00:00
|
|
|
if (ob->protectflag & OB_LOCK_ROT4D) {
|
|
|
|
/* perform clamping on a component by component basis */
|
|
|
|
if (ob->rotmode == ROT_MODE_AXISANGLE) {
|
2016-07-09 11:52:09 +12:00
|
|
|
if ((ob->protectflag & OB_LOCK_ROTW) == 0) {
|
|
|
|
ob->rotAngle = 0.0f;
|
|
|
|
if (clear_delta) ob->drotAngle = 0.0f;
|
|
|
|
}
|
|
|
|
if ((ob->protectflag & OB_LOCK_ROTX) == 0) {
|
|
|
|
ob->rotAxis[0] = 0.0f;
|
|
|
|
if (clear_delta) ob->drotAxis[0] = 0.0f;
|
|
|
|
}
|
|
|
|
if ((ob->protectflag & OB_LOCK_ROTY) == 0) {
|
|
|
|
ob->rotAxis[1] = 0.0f;
|
|
|
|
if (clear_delta) ob->drotAxis[1] = 0.0f;
|
|
|
|
}
|
|
|
|
if ((ob->protectflag & OB_LOCK_ROTZ) == 0) {
|
|
|
|
ob->rotAxis[2] = 0.0f;
|
|
|
|
if (clear_delta) ob->drotAxis[2] = 0.0f;
|
|
|
|
}
|
2011-01-26 09:27:43 +00:00
|
|
|
|
|
|
|
/* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */
|
2011-03-27 14:59:55 +00:00
|
|
|
if (IS_EQF(ob->rotAxis[0], ob->rotAxis[1]) && IS_EQF(ob->rotAxis[1], ob->rotAxis[2]))
|
2011-01-26 09:27:43 +00:00
|
|
|
ob->rotAxis[1] = 1.0f;
|
2016-07-09 11:52:09 +12:00
|
|
|
if (IS_EQF(ob->drotAxis[0], ob->drotAxis[1]) && IS_EQF(ob->drotAxis[1], ob->drotAxis[2]) && clear_delta)
|
2012-04-28 15:42:27 +00:00
|
|
|
ob->drotAxis[1] = 1.0f;
|
2011-01-26 09:27:43 +00:00
|
|
|
}
|
|
|
|
else if (ob->rotmode == ROT_MODE_QUAT) {
|
2016-07-09 11:52:09 +12:00
|
|
|
if ((ob->protectflag & OB_LOCK_ROTW) == 0) {
|
|
|
|
ob->quat[0] = 1.0f;
|
|
|
|
if (clear_delta) ob->dquat[0] = 1.0f;
|
|
|
|
}
|
2016-07-11 08:45:00 +10:00
|
|
|
if ((ob->protectflag & OB_LOCK_ROTX) == 0) {
|
2016-07-09 11:52:09 +12:00
|
|
|
ob->quat[1] = 0.0f;
|
|
|
|
if (clear_delta) ob->dquat[1] = 0.0f;
|
2016-07-11 08:45:00 +10:00
|
|
|
}
|
|
|
|
if ((ob->protectflag & OB_LOCK_ROTY) == 0) {
|
2016-07-09 11:52:09 +12:00
|
|
|
ob->quat[2] = 0.0f;
|
|
|
|
if (clear_delta) ob->dquat[2] = 0.0f;
|
2016-07-11 08:45:00 +10:00
|
|
|
}
|
|
|
|
if ((ob->protectflag & OB_LOCK_ROTZ) == 0) {
|
2016-07-09 11:52:09 +12:00
|
|
|
ob->quat[3] = 0.0f;
|
|
|
|
if (clear_delta) ob->dquat[3] = 0.0f;
|
2016-07-11 08:45:00 +10:00
|
|
|
}
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO: does this quat need normalizing now? */
|
2011-01-26 09:27:43 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* the flag may have been set for the other modes, so just ignore the extra flag... */
|
2016-07-09 11:52:09 +12:00
|
|
|
if ((ob->protectflag & OB_LOCK_ROTX) == 0) {
|
|
|
|
ob->rot[0] = 0.0f;
|
|
|
|
if (clear_delta) ob->drot[0] = 0.0f;
|
|
|
|
}
|
|
|
|
if ((ob->protectflag & OB_LOCK_ROTY) == 0) {
|
|
|
|
ob->rot[1] = 0.0f;
|
|
|
|
if (clear_delta) ob->drot[1] = 0.0f;
|
|
|
|
}
|
|
|
|
if ((ob->protectflag & OB_LOCK_ROTZ) == 0) {
|
|
|
|
ob->rot[2] = 0.0f;
|
|
|
|
if (clear_delta) ob->drot[2] = 0.0f;
|
|
|
|
}
|
2011-01-26 09:27:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* perform clamping using euler form (3-components) */
|
2012-07-06 23:56:59 +00:00
|
|
|
/* FIXME: deltas are not handled for these cases yet... */
|
2011-01-26 09:27:43 +00:00
|
|
|
float eul[3], oldeul[3], quat1[4] = {0};
|
|
|
|
|
|
|
|
if (ob->rotmode == ROT_MODE_QUAT) {
|
2011-11-06 16:34:44 +00:00
|
|
|
copy_qt_qt(quat1, ob->quat);
|
2011-01-26 09:27:43 +00:00
|
|
|
quat_to_eul(oldeul, ob->quat);
|
|
|
|
}
|
|
|
|
else if (ob->rotmode == ROT_MODE_AXISANGLE) {
|
|
|
|
axis_angle_to_eulO(oldeul, EULER_ORDER_DEFAULT, ob->rotAxis, ob->rotAngle);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
copy_v3_v3(oldeul, ob->rot);
|
|
|
|
}
|
|
|
|
|
2012-04-28 15:42:27 +00:00
|
|
|
eul[0] = eul[1] = eul[2] = 0.0f;
|
2011-01-26 09:27:43 +00:00
|
|
|
|
|
|
|
if (ob->protectflag & OB_LOCK_ROTX)
|
2012-04-28 15:42:27 +00:00
|
|
|
eul[0] = oldeul[0];
|
2011-01-26 09:27:43 +00:00
|
|
|
if (ob->protectflag & OB_LOCK_ROTY)
|
2012-04-28 15:42:27 +00:00
|
|
|
eul[1] = oldeul[1];
|
2011-01-26 09:27:43 +00:00
|
|
|
if (ob->protectflag & OB_LOCK_ROTZ)
|
2012-04-28 15:42:27 +00:00
|
|
|
eul[2] = oldeul[2];
|
2011-01-26 09:27:43 +00:00
|
|
|
|
|
|
|
if (ob->rotmode == ROT_MODE_QUAT) {
|
|
|
|
eul_to_quat(ob->quat, eul);
|
|
|
|
/* quaternions flip w sign to accumulate rotations correctly */
|
2012-04-28 15:42:27 +00:00
|
|
|
if ((quat1[0] < 0.0f && ob->quat[0] > 0.0f) || (quat1[0] > 0.0f && ob->quat[0] < 0.0f)) {
|
2011-01-26 09:27:43 +00:00
|
|
|
mul_qt_fl(ob->quat, -1.0f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ob->rotmode == ROT_MODE_AXISANGLE) {
|
2012-04-28 15:42:27 +00:00
|
|
|
eulO_to_axis_angle(ob->rotAxis, &ob->rotAngle, eul, EULER_ORDER_DEFAULT);
|
2011-01-26 09:27:43 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
copy_v3_v3(ob->rot, eul);
|
|
|
|
}
|
|
|
|
}
|
2012-04-28 15:42:27 +00:00
|
|
|
} // Duplicated in source/blender/editors/armature/editarmature.c
|
2012-10-21 05:46:41 +00:00
|
|
|
else {
|
2011-01-26 09:27:43 +00:00
|
|
|
if (ob->rotmode == ROT_MODE_QUAT) {
|
2011-02-02 00:40:55 +00:00
|
|
|
unit_qt(ob->quat);
|
2016-07-09 11:52:09 +12:00
|
|
|
if (clear_delta) unit_qt(ob->dquat);
|
2011-01-26 09:27:43 +00:00
|
|
|
}
|
|
|
|
else if (ob->rotmode == ROT_MODE_AXISANGLE) {
|
2011-02-02 00:40:55 +00:00
|
|
|
unit_axis_angle(ob->rotAxis, &ob->rotAngle);
|
2016-07-09 11:52:09 +12:00
|
|
|
if (clear_delta) unit_axis_angle(ob->drotAxis, &ob->drotAngle);
|
2011-01-26 09:27:43 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-02-02 00:40:55 +00:00
|
|
|
zero_v3(ob->rot);
|
2016-07-09 11:52:09 +12:00
|
|
|
if (clear_delta) zero_v3(ob->drot);
|
2011-01-26 09:27:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clear scale of object */
|
2016-07-09 11:52:09 +12:00
|
|
|
static void object_clear_scale(Object *ob, const bool clear_delta)
|
2011-01-26 09:27:43 +00:00
|
|
|
{
|
|
|
|
/* clear scale factors which are not locked */
|
2012-04-28 15:42:27 +00:00
|
|
|
if ((ob->protectflag & OB_LOCK_SCALEX) == 0) {
|
|
|
|
ob->size[0] = 1.0f;
|
2016-07-09 11:52:09 +12:00
|
|
|
if (clear_delta) ob->dscale[0] = 1.0f;
|
2011-01-26 09:27:43 +00:00
|
|
|
}
|
2012-04-28 15:42:27 +00:00
|
|
|
if ((ob->protectflag & OB_LOCK_SCALEY) == 0) {
|
|
|
|
ob->size[1] = 1.0f;
|
2016-07-09 11:52:09 +12:00
|
|
|
if (clear_delta) ob->dscale[1] = 1.0f;
|
2011-01-26 09:27:43 +00:00
|
|
|
}
|
2012-04-28 15:42:27 +00:00
|
|
|
if ((ob->protectflag & OB_LOCK_SCALEZ) == 0) {
|
|
|
|
ob->size[2] = 1.0f;
|
2016-07-09 11:52:09 +12:00
|
|
|
if (clear_delta) ob->dscale[2] = 1.0f;
|
2011-01-26 09:27:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------- */
|
|
|
|
|
|
|
|
/* generic exec for clear-transform operators */
|
|
|
|
static int object_clear_transform_generic_exec(bContext *C, wmOperator *op,
|
2016-07-09 11:52:09 +12:00
|
|
|
void (*clear_func)(Object *, const bool),
|
|
|
|
const char default_ksName[])
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
{
|
2012-04-28 15:42:27 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2011-01-26 09:27:43 +00:00
|
|
|
KeyingSet *ks;
|
2016-07-09 11:52:09 +12:00
|
|
|
const bool clear_delta = RNA_boolean_get(op->ptr, "clear_delta");
|
2009-11-23 11:58:30 +00:00
|
|
|
|
2011-01-26 09:27:43 +00:00
|
|
|
/* sanity checks */
|
2012-03-25 22:35:18 +00:00
|
|
|
if (ELEM(NULL, clear_func, default_ksName)) {
|
2012-10-26 17:32:50 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Programming error: missing clear transform function or keying set name");
|
2011-01-26 09:27:43 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2010-09-07 03:58:50 +00:00
|
|
|
|
2010-09-30 11:56:39 +00:00
|
|
|
/* get KeyingSet to use */
|
2011-01-26 09:27:43 +00:00
|
|
|
ks = ANIM_get_keyingset_for_autokeying(scene, default_ksName);
|
2009-11-23 11:58:30 +00:00
|
|
|
|
2011-01-26 09:27:43 +00:00
|
|
|
/* operate on selected objects only if they aren't in weight-paint mode
|
|
|
|
* (so that object-transform clearing won't be applied at same time as bone-clearing)
|
|
|
|
*/
|
2012-04-30 16:22:40 +00:00
|
|
|
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
|
|
|
|
{
|
== Massive Keying Sets Recode ==
After a few days of wrong turns and learning the finer points of RNA-type-subclassing the hard way, this commit finally presents a refactored version of the Keying Sets system (now version 2) based on some requirements from Cessen.
For a more thorough discussion of this commit, see
http://sites.google.com/site/aligorith/keyingsets_2.pdf?attredirects=0&d=1
------
The main highlight of this refactor is that relative Keying Sets have now been recoded so that Python callbacks are run to generate the Keying Set's list of paths everytime the Keying Set is used (to insert or delete keyframes), allowing complex heuristics to be used to determine whether a property gets keyframed based on the current context. These checks may include checking on selection status of related entities, or transform locks.
Built-In KeyingSets have also been recoded, and moved from C and out into Python. These are now coded as Relative Keying Sets, and can to some extent serve as basis for adding new relative Keying Sets. However, these have mostly been coded in a slightly 'modular' way which may be confusing for those not so familiar with Python in general. A usable template will be added soon for more general usage.
Keyframing settings (i.e. 'visual', 'needed') can now be specified on a per-path basis now, which is especially useful for Absolute Keying Sets, where control over this is often beneficial.
Most of the places where Auto-Keyframing is performed have been tidied up for consistency. I'm sure quite a few issues still exist there, but these I'll clean up over the next few days.
2010-03-16 06:18:49 +00:00
|
|
|
if (!(ob->mode & OB_MODE_WEIGHT_PAINT)) {
|
2011-01-26 09:27:43 +00:00
|
|
|
/* run provided clearing function */
|
2016-07-09 11:52:09 +12:00
|
|
|
clear_func(ob, clear_delta);
|
|
|
|
|
2011-10-10 12:56:21 +00:00
|
|
|
ED_autokeyframe_object(C, scene, ob, ks);
|
2016-07-09 11:52:09 +12:00
|
|
|
|
2011-01-26 09:27:43 +00:00
|
|
|
/* tag for updates */
|
2011-08-12 18:06:05 +00:00
|
|
|
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
CTX_DATA_END;
|
|
|
|
|
2009-12-13 11:49:17 +00:00
|
|
|
/* this is needed so children are also updated */
|
2012-04-28 15:42:27 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
|
2009-12-13 11:49:17 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2011-01-26 09:27:43 +00:00
|
|
|
/* --------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static int object_location_clear_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2011-10-23 05:08:02 +00:00
|
|
|
return object_clear_transform_generic_exec(C, op, object_clear_loc, ANIM_KS_LOCATION_ID);
|
2011-01-26 09:27:43 +00:00
|
|
|
}
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
void OBJECT_OT_location_clear(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Clear Location";
|
2010-02-10 21:15:44 +00:00
|
|
|
ot->description = "Clear the object's location";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "OBJECT_OT_location_clear";
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = object_location_clear_exec;
|
|
|
|
ot->poll = ED_operator_scene_editable;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-04-28 15:42:27 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2016-07-09 11:52:09 +12:00
|
|
|
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
ot->prop = RNA_def_boolean(ot->srna, "clear_delta", false, "Clear Delta",
|
|
|
|
"Clear delta location in addition to clearing the normal location transform");
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int object_rotation_clear_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2011-10-23 05:08:02 +00:00
|
|
|
return object_clear_transform_generic_exec(C, op, object_clear_rot, ANIM_KS_ROTATION_ID);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_rotation_clear(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Clear Rotation";
|
2010-02-10 21:15:44 +00:00
|
|
|
ot->description = "Clear the object's rotation";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "OBJECT_OT_rotation_clear";
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = object_rotation_clear_exec;
|
|
|
|
ot->poll = ED_operator_scene_editable;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-04-28 15:42:27 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2016-07-09 11:52:09 +12:00
|
|
|
|
|
|
|
/* properties */
|
|
|
|
ot->prop = RNA_def_boolean(ot->srna, "clear_delta", false, "Clear Delta",
|
|
|
|
"Clear delta rotation in addition to clearing the normal rotation transform");
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int object_scale_clear_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2011-10-23 05:08:02 +00:00
|
|
|
return object_clear_transform_generic_exec(C, op, object_clear_scale, ANIM_KS_SCALING_ID);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_scale_clear(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Clear Scale";
|
2010-02-10 21:15:44 +00:00
|
|
|
ot->description = "Clear the object's scale";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "OBJECT_OT_scale_clear";
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = object_scale_clear_exec;
|
|
|
|
ot->poll = ED_operator_scene_editable;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-04-28 15:42:27 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2016-07-09 11:52:09 +12:00
|
|
|
|
|
|
|
/* properties */
|
|
|
|
ot->prop = RNA_def_boolean(ot->srna, "clear_delta", false, "Clear Delta",
|
|
|
|
"Clear delta scale in addition to clearing the normal scale transform");
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
|
2011-01-26 09:27:43 +00:00
|
|
|
/* --------------- */
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int object_origin_clear_exec(bContext *C, wmOperator *UNUSED(op))
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
{
|
2011-01-26 10:25:15 +00:00
|
|
|
float *v1, *v3;
|
|
|
|
float mat[3][3];
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2012-04-30 16:22:40 +00:00
|
|
|
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
|
|
|
|
{
|
2011-01-26 10:25:15 +00:00
|
|
|
if (ob->parent) {
|
|
|
|
/* vectors pointed to by v1 and v3 will get modified */
|
2012-04-28 15:42:27 +00:00
|
|
|
v1 = ob->loc;
|
|
|
|
v3 = ob->parentinv[3];
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m3_m4(mat, ob->parentinv);
|
2010-07-23 23:48:21 +00:00
|
|
|
negate_v3_v3(v3, v1);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m3_v3(mat, v3);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
2011-08-12 18:06:05 +00:00
|
|
|
|
|
|
|
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
CTX_DATA_END;
|
|
|
|
|
2012-04-28 15:42:27 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_origin_clear(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Clear Origin";
|
2010-02-10 21:15:44 +00:00
|
|
|
ot->description = "Clear the object's origin";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "OBJECT_OT_origin_clear";
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = object_origin_clear_exec;
|
|
|
|
ot->poll = ED_operator_scene_editable;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-04-28 15:42:27 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************** Apply Transformation ****************************/
|
|
|
|
|
|
|
|
/* use this when the loc/size/rot of the parent has changed but the children
|
2012-05-16 23:37:23 +00:00
|
|
|
* should stay in the same place, e.g. for apply-size-rot or object center */
|
2012-04-28 15:42:27 +00:00
|
|
|
static void ignore_parent_tx(Main *bmain, Scene *scene, Object *ob)
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
{
|
|
|
|
Object workob;
|
|
|
|
Object *ob_child;
|
|
|
|
|
|
|
|
/* a change was made, adjust the children to compensate */
|
2012-04-28 15:42:27 +00:00
|
|
|
for (ob_child = bmain->object.first; ob_child; ob_child = ob_child->id.next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ob_child->parent == ob) {
|
2014-04-01 11:34:00 +11:00
|
|
|
BKE_object_apply_mat4(ob_child, ob_child->obmat, true, false);
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_object_workob_calc_parent(scene, ob_child, &workob);
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(ob_child->parentinv, workob.obmat);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-11 22:16:44 +10:00
|
|
|
static int apply_objects_internal(
|
|
|
|
bContext *C, ReportList *reports,
|
|
|
|
bool apply_loc, bool apply_rot, bool apply_scale,
|
|
|
|
bool do_props)
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
{
|
2012-04-28 15:42:27 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2012-10-12 14:35:10 +00:00
|
|
|
float rsmat[3][3], obmat[3][3], iobmat[3][3], mat[4][4], scale;
|
2013-11-26 06:39:14 +11:00
|
|
|
bool changed = true;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
/* first check if we can execute */
|
2012-04-30 16:22:40 +00:00
|
|
|
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
|
|
|
|
{
|
2015-10-12 12:34:17 +11:00
|
|
|
if (ELEM(ob->type, OB_MESH, OB_ARMATURE, OB_LATTICE, OB_MBALL, OB_CURVE, OB_SURF, OB_FONT)) {
|
2013-09-18 22:45:14 +00:00
|
|
|
ID *obdata = ob->data;
|
|
|
|
if (ID_REAL_USERS(obdata) > 1) {
|
|
|
|
BKE_reportf(reports, RPT_ERROR,
|
|
|
|
"Cannot apply to a multi user: Object \"%s\", %s \"%s\", aborting",
|
|
|
|
ob->id.name + 2, BKE_idcode_to_name(GS(obdata->name)), obdata->name + 2);
|
2013-11-26 06:39:14 +11:00
|
|
|
changed = false;
|
2012-03-20 23:09:28 +00:00
|
|
|
}
|
2013-09-18 22:45:14 +00:00
|
|
|
|
2017-11-06 17:17:10 +01:00
|
|
|
if (ID_IS_LINKED(obdata)) {
|
2013-09-18 22:45:14 +00:00
|
|
|
BKE_reportf(reports, RPT_ERROR,
|
|
|
|
"Cannot apply to library data: Object \"%s\", %s \"%s\", aborting",
|
|
|
|
ob->id.name + 2, BKE_idcode_to_name(GS(obdata->name)), obdata->name + 2);
|
2013-11-26 06:39:14 +11:00
|
|
|
changed = false;
|
2013-02-11 10:56:21 +00:00
|
|
|
}
|
|
|
|
}
|
2011-04-20 04:11:12 +00:00
|
|
|
|
2013-09-18 22:45:14 +00:00
|
|
|
if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
|
|
|
|
ID *obdata = ob->data;
|
|
|
|
Curve *cu;
|
2011-04-20 04:11:12 +00:00
|
|
|
|
2012-04-28 15:42:27 +00:00
|
|
|
cu = ob->data;
|
2011-04-20 04:11:12 +00:00
|
|
|
|
2013-02-19 14:19:53 +00:00
|
|
|
if (((ob->type == OB_CURVE) && !(cu->flag & CU_3D)) && (apply_rot || apply_loc)) {
|
2013-09-18 22:45:14 +00:00
|
|
|
BKE_reportf(reports, RPT_ERROR,
|
|
|
|
"Rotation/Location can't apply to a 2D curve: Object \"%s\", %s \"%s\", aborting",
|
|
|
|
ob->id.name + 2, BKE_idcode_to_name(GS(obdata->name)), obdata->name + 2);
|
2013-11-26 06:39:14 +11:00
|
|
|
changed = false;
|
2010-06-11 13:00:24 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cu->key) {
|
2013-09-18 22:45:14 +00:00
|
|
|
BKE_reportf(reports, RPT_ERROR,
|
|
|
|
"Can't apply to a curve with shape-keys: Object \"%s\", %s \"%s\", aborting",
|
|
|
|
ob->id.name + 2, BKE_idcode_to_name(GS(obdata->name)), obdata->name + 2);
|
2013-11-26 06:39:14 +11:00
|
|
|
changed = false;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
}
|
2015-10-12 12:34:17 +11:00
|
|
|
|
|
|
|
if (ob->type == OB_FONT) {
|
|
|
|
if (apply_rot || apply_loc) {
|
|
|
|
BKE_reportf(reports, RPT_ERROR,
|
|
|
|
"Font's can only have scale applied: \"%s\"",
|
|
|
|
ob->id.name + 2);
|
|
|
|
changed = false;
|
|
|
|
}
|
|
|
|
}
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
CTX_DATA_END;
|
|
|
|
|
2013-11-26 06:39:14 +11:00
|
|
|
if (!changed)
|
2012-05-20 11:06:46 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2013-11-26 06:39:14 +11:00
|
|
|
changed = false;
|
2012-05-20 11:06:46 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* now execute */
|
2012-04-30 16:22:40 +00:00
|
|
|
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
|
|
|
|
{
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
/* calculate rotation/scale matrix */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (apply_scale && apply_rot)
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_object_to_mat3(ob, rsmat);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (apply_scale)
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_object_scale_to_mat3(ob, rsmat);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (apply_rot) {
|
2010-10-14 02:05:37 +00:00
|
|
|
float tmat[3][3], timat[3][3];
|
|
|
|
|
|
|
|
/* simple rotation matrix */
|
2014-04-01 11:34:00 +11:00
|
|
|
BKE_object_rot_to_mat3(ob, rsmat, true);
|
2010-10-14 02:05:37 +00:00
|
|
|
|
|
|
|
/* correct for scale, note mul_m3_m3m3 has swapped args! */
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_object_scale_to_mat3(ob, tmat);
|
2010-10-14 02:05:37 +00:00
|
|
|
invert_m3_m3(timat, tmat);
|
|
|
|
mul_m3_m3m3(rsmat, timat, rsmat);
|
|
|
|
mul_m3_m3m3(rsmat, rsmat, tmat);
|
|
|
|
}
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
else
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m3(rsmat);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m3(mat, rsmat);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
/* calculate translation */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (apply_loc) {
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_v3_v3(mat[3], ob->loc);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!(apply_scale && apply_rot)) {
|
2012-10-12 14:35:10 +00:00
|
|
|
float tmat[3][3];
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* correct for scale and rotation that is still applied */
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_object_to_mat3(ob, obmat);
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m3_m3(iobmat, obmat);
|
|
|
|
mul_m3_m3m3(tmat, rsmat, iobmat);
|
|
|
|
mul_m3_v3(tmat, mat[3]);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* apply to object data */
|
2012-04-28 15:42:27 +00:00
|
|
|
if (ob->type == OB_MESH) {
|
|
|
|
Mesh *me = ob->data;
|
2011-04-20 04:11:12 +00:00
|
|
|
|
2012-08-11 16:20:30 +00:00
|
|
|
if (apply_scale)
|
|
|
|
multiresModifier_scale_disp(scene, ob);
|
2010-10-25 08:03:05 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* adjust data */
|
2014-09-01 20:09:31 +10:00
|
|
|
BKE_mesh_transform(me, mat, true);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
/* update normals */
|
2013-05-28 14:23:07 +00:00
|
|
|
BKE_mesh_calc_normals(me);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
2012-04-28 15:42:27 +00:00
|
|
|
else if (ob->type == OB_ARMATURE) {
|
2017-08-11 22:16:44 +10:00
|
|
|
ED_armature_apply_transform(ob, mat, do_props);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
2012-03-20 23:09:28 +00:00
|
|
|
else if (ob->type == OB_LATTICE) {
|
|
|
|
Lattice *lt = ob->data;
|
2014-09-01 20:09:31 +10:00
|
|
|
|
|
|
|
BKE_lattice_transform(lt, mat, true);
|
2012-03-20 23:09:28 +00:00
|
|
|
}
|
2013-02-11 10:56:21 +00:00
|
|
|
else if (ob->type == OB_MBALL) {
|
|
|
|
MetaBall *mb = ob->data;
|
2017-08-11 22:16:44 +10:00
|
|
|
BKE_mball_transform(mb, mat, do_props);
|
2013-02-11 10:56:21 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
|
2012-04-28 15:42:27 +00:00
|
|
|
Curve *cu = ob->data;
|
2009-11-10 20:43:45 +00:00
|
|
|
scale = mat3_to_scale(rsmat);
|
2017-08-11 22:16:44 +10:00
|
|
|
BKE_curve_transform_ex(cu, mat, true, do_props, scale);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
2015-10-12 12:34:17 +11:00
|
|
|
else if (ob->type == OB_FONT) {
|
|
|
|
Curve *cu = ob->data;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
scale = mat3_to_scale(rsmat);
|
|
|
|
|
|
|
|
for (i = 0; i < cu->totbox; i++) {
|
|
|
|
TextBox *tb = &cu->tb[i];
|
|
|
|
tb->x *= scale;
|
|
|
|
tb->y *= scale;
|
|
|
|
tb->w *= scale;
|
|
|
|
tb->h *= scale;
|
|
|
|
}
|
|
|
|
|
2017-08-11 22:16:44 +10:00
|
|
|
if (do_props) {
|
|
|
|
cu->fsize *= scale;
|
|
|
|
}
|
2015-10-12 12:34:17 +11:00
|
|
|
}
|
2013-05-13 13:37:05 +00:00
|
|
|
else if (ob->type == OB_CAMERA) {
|
2013-09-09 11:37:37 +00:00
|
|
|
MovieClip *clip = BKE_object_movieclip_get(scene, ob, false);
|
2013-05-13 13:37:05 +00:00
|
|
|
|
|
|
|
/* applying scale on camera actually scales clip's reconstruction.
|
|
|
|
* of there's clip assigned to camera nothing to do actually.
|
|
|
|
*/
|
|
|
|
if (!clip)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (apply_scale)
|
|
|
|
BKE_tracking_reconstruction_scale(&clip->tracking, ob->size);
|
|
|
|
}
|
2013-09-02 22:57:22 +00:00
|
|
|
else if (ob->type == OB_EMPTY) {
|
|
|
|
/* It's possible for empties too, even though they don't
|
|
|
|
* really have obdata, since we can simply apply the maximum
|
|
|
|
* scaling to the empty's drawsize.
|
|
|
|
*
|
|
|
|
* Core Assumptions:
|
|
|
|
* 1) Most scaled empties have uniform scaling
|
|
|
|
* (i.e. for visibility reasons), AND/OR
|
|
|
|
* 2) Preserving non-uniform scaling is not that important,
|
|
|
|
* and is something that many users would be willing to
|
|
|
|
* sacrifice for having an easy way to do this.
|
|
|
|
*/
|
2014-05-05 15:41:08 +10:00
|
|
|
|
|
|
|
if ((apply_loc == false) &&
|
|
|
|
(apply_rot == false) &&
|
|
|
|
(apply_scale == true))
|
|
|
|
{
|
|
|
|
float max_scale = max_fff(fabsf(ob->size[0]), fabsf(ob->size[1]), fabsf(ob->size[2]));
|
|
|
|
ob->empty_drawsize *= max_scale;
|
|
|
|
}
|
2013-09-02 22:57:22 +00:00
|
|
|
}
|
2013-05-13 13:37:05 +00:00
|
|
|
else {
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
continue;
|
2013-05-13 13:37:05 +00:00
|
|
|
}
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (apply_loc)
|
2011-02-02 00:40:55 +00:00
|
|
|
zero_v3(ob->loc);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (apply_scale)
|
2012-04-28 15:42:27 +00:00
|
|
|
ob->size[0] = ob->size[1] = ob->size[2] = 1.0f;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (apply_rot) {
|
2011-02-02 00:40:55 +00:00
|
|
|
zero_v3(ob->rot);
|
|
|
|
unit_qt(ob->quat);
|
|
|
|
unit_axis_angle(ob->rotAxis, &ob->rotAngle);
|
2009-11-22 06:19:30 +00:00
|
|
|
}
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_object_where_is_calc(scene, ob);
|
2012-04-28 15:42:27 +00:00
|
|
|
if (ob->type == OB_ARMATURE) {
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_pose_where_is(scene, ob); /* needed for bone parents */
|
2011-04-20 04:11:12 +00:00
|
|
|
}
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
ignore_parent_tx(bmain, scene, ob);
|
|
|
|
|
2012-04-28 15:42:27 +00:00
|
|
|
DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2013-11-26 06:39:14 +11:00
|
|
|
changed = true;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
CTX_DATA_END;
|
|
|
|
|
2013-11-26 06:39:14 +11:00
|
|
|
if (!changed) {
|
2013-08-28 04:17:48 +00:00
|
|
|
BKE_report(reports, RPT_WARNING, "Objects have no data to transform");
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2013-08-28 04:17:48 +00:00
|
|
|
}
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2012-04-28 15:42:27 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
{
|
2012-04-28 15:42:27 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2013-11-26 06:39:14 +11:00
|
|
|
bool changed = false;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2012-04-30 16:22:40 +00:00
|
|
|
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
|
|
|
|
{
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_object_where_is_calc(scene, ob);
|
2014-04-01 11:34:00 +11:00
|
|
|
BKE_object_apply_mat4(ob, ob->obmat, true, true);
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_object_where_is_calc(scene, ob);
|
2010-11-08 22:32:28 +00:00
|
|
|
|
|
|
|
/* update for any children that may get moved */
|
2010-12-05 18:59:23 +00:00
|
|
|
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
|
2010-11-08 22:32:28 +00:00
|
|
|
|
2013-11-26 06:39:14 +11:00
|
|
|
changed = true;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
CTX_DATA_END;
|
|
|
|
|
2013-11-26 06:39:14 +11:00
|
|
|
if (!changed)
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2012-04-28 15:42:27 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_visual_transform_apply(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Apply Visual Transform";
|
2010-02-10 21:15:44 +00:00
|
|
|
ot->description = "Apply the object's visual transformation to its data";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "OBJECT_OT_visual_transform_apply";
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = visual_transform_apply_exec;
|
|
|
|
ot->poll = ED_operator_scene_editable;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-04-28 15:42:27 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
|
2011-05-03 07:09:02 +00:00
|
|
|
static int object_transform_apply_exec(bContext *C, wmOperator *op)
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
{
|
2014-04-11 11:25:41 +10:00
|
|
|
const bool loc = RNA_boolean_get(op->ptr, "location");
|
|
|
|
const bool rot = RNA_boolean_get(op->ptr, "rotation");
|
|
|
|
const bool sca = RNA_boolean_get(op->ptr, "scale");
|
2017-08-11 22:16:44 +10:00
|
|
|
const bool do_props = RNA_boolean_get(op->ptr, "properties");
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (loc || rot || sca) {
|
2017-08-11 22:16:44 +10:00
|
|
|
return apply_objects_internal(C, op->reports, loc, rot, sca, do_props);
|
2011-05-03 07:09:02 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-02-27 13:39:35 +11:00
|
|
|
/* allow for redo */
|
|
|
|
return OPERATOR_FINISHED;
|
2011-05-03 07:09:02 +00:00
|
|
|
}
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
|
2011-05-03 07:09:02 +00:00
|
|
|
void OBJECT_OT_transform_apply(wmOperatorType *ot)
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Apply Object Transform";
|
2011-05-03 07:09:02 +00:00
|
|
|
ot->description = "Apply the object's transformation to its data";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "OBJECT_OT_transform_apply";
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = object_transform_apply_exec;
|
|
|
|
ot->poll = ED_operator_objectmode;
|
2011-05-03 07:09:02 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* flags */
|
2012-04-28 15:42:27 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2011-05-03 07:09:02 +00:00
|
|
|
|
|
|
|
RNA_def_boolean(ot->srna, "location", 0, "Location", "");
|
|
|
|
RNA_def_boolean(ot->srna, "rotation", 0, "Rotation", "");
|
|
|
|
RNA_def_boolean(ot->srna, "scale", 0, "Scale", "");
|
2017-08-11 22:16:44 +10:00
|
|
|
RNA_def_boolean(ot->srna, "properties", true, "Apply Properties",
|
|
|
|
"Modify properties such as curve vertex radius, font size and bone envelope");
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************* Set Object Center ************************/
|
|
|
|
|
2010-08-01 11:00:36 +00:00
|
|
|
enum {
|
2012-04-28 15:42:27 +00:00
|
|
|
GEOMETRY_TO_ORIGIN = 0,
|
2010-08-01 11:00:36 +00:00
|
|
|
ORIGIN_TO_GEOMETRY,
|
2012-10-20 16:48:54 +00:00
|
|
|
ORIGIN_TO_CURSOR,
|
2017-08-21 15:06:07 +10:00
|
|
|
ORIGIN_TO_CENTER_OF_MASS_SURFACE,
|
|
|
|
ORIGIN_TO_CENTER_OF_MASS_VOLUME,
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
};
|
|
|
|
|
2009-12-03 21:56:04 +00:00
|
|
|
static int object_origin_set_exec(bContext *C, wmOperator *op)
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
{
|
2012-04-28 15:42:27 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2013-07-15 01:34:59 +00:00
|
|
|
Object *obact = CTX_data_active_object(C);
|
2012-04-28 15:42:27 +00:00
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
2010-07-23 23:48:21 +00:00
|
|
|
Object *tob;
|
2012-05-13 11:14:43 +00:00
|
|
|
float cursor[3], cent[3], cent_neg[3], centn[3];
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
int centermode = RNA_enum_get(op->ptr, "type");
|
2010-08-01 11:00:36 +00:00
|
|
|
int around = RNA_enum_get(op->ptr, "center"); /* initialized from v3d->around */
|
|
|
|
|
2013-07-15 01:34:59 +00:00
|
|
|
ListBase ctx_data_list;
|
|
|
|
CollectionPointerLink *ctx_ob;
|
|
|
|
CollectionPointerLink *ctx_ob_act = NULL;
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* keep track of what is changed */
|
2012-04-28 15:42:27 +00:00
|
|
|
int tot_change = 0, tot_lib_error = 0, tot_multiuser_arm_error = 0;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2010-08-01 11:00:36 +00:00
|
|
|
if (obedit && centermode != GEOMETRY_TO_ORIGIN) {
|
2012-10-26 17:32:50 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in edit mode");
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2010-07-31 10:58:10 +00:00
|
|
|
}
|
2010-08-01 11:00:36 +00:00
|
|
|
else {
|
2012-03-18 07:38:51 +00:00
|
|
|
/* get the view settings if 'around' isn't set and the view is available */
|
2012-04-28 15:42:27 +00:00
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
2013-10-26 04:07:18 +00:00
|
|
|
copy_v3_v3(cursor, ED_view3d_cursor3d_get(scene, v3d));
|
2012-03-24 06:38:07 +00:00
|
|
|
if (v3d && !RNA_struct_property_is_set(op->ptr, "center"))
|
2012-04-28 15:42:27 +00:00
|
|
|
around = v3d->around;
|
2010-08-01 11:00:36 +00:00
|
|
|
}
|
2011-05-09 02:45:52 +00:00
|
|
|
|
2010-07-31 10:58:10 +00:00
|
|
|
zero_v3(cent);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (obedit) {
|
2012-04-28 15:42:27 +00:00
|
|
|
if (obedit->type == OB_MESH) {
|
|
|
|
Mesh *me = obedit->data;
|
2010-01-28 00:45:30 +00:00
|
|
|
BMEditMesh *em = me->edit_btmesh;
|
|
|
|
BMVert *eve;
|
|
|
|
BMIter iter;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (centermode == ORIGIN_TO_CURSOR) {
|
2010-09-04 05:31:25 +00:00
|
|
|
copy_v3_v3(cent, cursor);
|
|
|
|
invert_m4_m4(obedit->imat, obedit->obmat);
|
|
|
|
mul_m4_v3(obedit->imat, cent);
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2015-12-01 18:52:24 +11:00
|
|
|
if (around == V3D_AROUND_CENTER_MEAN) {
|
2013-02-06 02:48:03 +00:00
|
|
|
if (em->bm->totvert) {
|
|
|
|
const float total_div = 1.0f / (float)em->bm->totvert;
|
|
|
|
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
|
|
|
|
madd_v3_v3fl(cent, eve->co, total_div);
|
|
|
|
}
|
2010-09-04 05:31:25 +00:00
|
|
|
}
|
2012-05-13 11:14:43 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
float min[3], max[3];
|
|
|
|
INIT_MINMAX(min, max);
|
|
|
|
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
|
2012-05-13 11:05:52 +00:00
|
|
|
minmax_v3v3_v3(min, max, eve->co);
|
2010-09-04 05:31:25 +00:00
|
|
|
}
|
2012-05-13 11:14:43 +00:00
|
|
|
mid_v3_v3v3(cent, min, max);
|
2010-08-01 11:00:36 +00:00
|
|
|
}
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
|
2012-04-19 13:47:58 +00:00
|
|
|
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
|
2010-08-01 11:00:36 +00:00
|
|
|
sub_v3_v3(eve->co, cent);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
2011-05-09 02:45:52 +00:00
|
|
|
|
2012-03-27 04:46:52 +00:00
|
|
|
EDBM_mesh_normals_update(em);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
tot_change++;
|
2011-02-27 06:19:40 +00:00
|
|
|
DAG_id_tag_update(&obedit->id, OB_RECALC_DATA);
|
2012-04-28 15:42:27 +00:00
|
|
|
}
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
2010-08-01 11:00:36 +00:00
|
|
|
|
2013-07-15 01:34:59 +00:00
|
|
|
CTX_data_selected_editable_objects(C, &ctx_data_list);
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* reset flags */
|
2013-07-15 01:34:59 +00:00
|
|
|
for (ctx_ob = ctx_data_list.first;
|
|
|
|
ctx_ob;
|
|
|
|
ctx_ob = ctx_ob->next)
|
2012-04-30 16:22:40 +00:00
|
|
|
{
|
2013-07-15 01:34:59 +00:00
|
|
|
Object *ob = ctx_ob->ptr.data;
|
2012-04-28 15:42:27 +00:00
|
|
|
ob->flag &= ~OB_DONE;
|
2013-07-15 01:34:59 +00:00
|
|
|
|
|
|
|
/* move active first */
|
|
|
|
if (ob == obact) {
|
|
|
|
ctx_ob_act = ctx_ob;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ctx_ob_act) {
|
2014-07-30 15:01:16 +10:00
|
|
|
BLI_listbase_rotate_first(&ctx_data_list, (LinkData *)ctx_ob_act);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
2010-07-23 23:48:21 +00:00
|
|
|
|
2012-04-28 15:42:27 +00:00
|
|
|
for (tob = bmain->object.first; tob; tob = tob->id.next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (tob->data)
|
Split id->flag in two, persistent flags and runtime tags.
This is purely internal sanitizing/cleanup, no change in behavior is expected at all.
This change was also needed because we were getting short on ID flags, and
future enhancement of 'user_one' ID behavior requires two new ones.
id->flag remains for persistent data (fakeuser only, so far!), this also allows us
100% backward & forward compatibility.
New id->tag is used for most flags. Though written in .blend files, its content
is cleared at read time.
Note that .blend file version was bumped, so that we can clear runtimeflags from
old .blends, important in case we add new persistent flags in future.
Also, behavior of tags (either status ones, or whether they need to be cleared before/after use)
has been added as comments to their declaration.
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D1683
2015-12-27 11:53:50 +01:00
|
|
|
((ID *)tob->data)->tag &= ~LIB_TAG_DOIT;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (tob->dup_group)
|
Split id->flag in two, persistent flags and runtime tags.
This is purely internal sanitizing/cleanup, no change in behavior is expected at all.
This change was also needed because we were getting short on ID flags, and
future enhancement of 'user_one' ID behavior requires two new ones.
id->flag remains for persistent data (fakeuser only, so far!), this also allows us
100% backward & forward compatibility.
New id->tag is used for most flags. Though written in .blend files, its content
is cleared at read time.
Note that .blend file version was bumped, so that we can clear runtimeflags from
old .blends, important in case we add new persistent flags in future.
Also, behavior of tags (either status ones, or whether they need to be cleared before/after use)
has been added as comments to their declaration.
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D1683
2015-12-27 11:53:50 +01:00
|
|
|
((ID *)tob->dup_group)->tag &= ~LIB_TAG_DOIT;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
2010-08-01 11:00:36 +00:00
|
|
|
|
2013-07-15 01:34:59 +00:00
|
|
|
for (ctx_ob = ctx_data_list.first;
|
|
|
|
ctx_ob;
|
|
|
|
ctx_ob = ctx_ob->next)
|
2012-04-30 16:22:40 +00:00
|
|
|
{
|
2013-07-15 01:34:59 +00:00
|
|
|
Object *ob = ctx_ob->ptr.data;
|
|
|
|
|
2012-04-28 15:42:27 +00:00
|
|
|
if ((ob->flag & OB_DONE) == 0) {
|
2014-02-03 18:55:59 +11:00
|
|
|
bool do_inverse_offset = false;
|
2009-10-29 09:14:20 +00:00
|
|
|
ob->flag |= OB_DONE;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (centermode == ORIGIN_TO_CURSOR) {
|
2010-08-03 00:56:43 +00:00
|
|
|
copy_v3_v3(cent, cursor);
|
|
|
|
invert_m4_m4(ob->imat, ob->obmat);
|
|
|
|
mul_m4_v3(ob->imat, cent);
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ob->data == NULL) {
|
2010-08-03 00:56:43 +00:00
|
|
|
/* special support for dupligroups */
|
Split id->flag in two, persistent flags and runtime tags.
This is purely internal sanitizing/cleanup, no change in behavior is expected at all.
This change was also needed because we were getting short on ID flags, and
future enhancement of 'user_one' ID behavior requires two new ones.
id->flag remains for persistent data (fakeuser only, so far!), this also allows us
100% backward & forward compatibility.
New id->tag is used for most flags. Though written in .blend files, its content
is cleared at read time.
Note that .blend file version was bumped, so that we can clear runtimeflags from
old .blends, important in case we add new persistent flags in future.
Also, behavior of tags (either status ones, or whether they need to be cleared before/after use)
has been added as comments to their declaration.
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D1683
2015-12-27 11:53:50 +01:00
|
|
|
if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group && (ob->dup_group->id.tag & LIB_TAG_DOIT) == 0) {
|
2017-11-06 17:17:10 +01:00
|
|
|
if (ID_IS_LINKED(ob->dup_group)) {
|
2010-08-03 00:56:43 +00:00
|
|
|
tot_lib_error++;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
2010-08-03 00:56:43 +00:00
|
|
|
else {
|
2012-05-13 11:14:43 +00:00
|
|
|
if (centermode == ORIGIN_TO_CURSOR) {
|
|
|
|
/* done */
|
|
|
|
}
|
2010-08-03 00:56:43 +00:00
|
|
|
else {
|
2012-05-13 11:14:43 +00:00
|
|
|
float min[3], max[3];
|
2010-08-03 00:56:43 +00:00
|
|
|
/* only bounds support */
|
|
|
|
INIT_MINMAX(min, max);
|
2014-04-01 11:34:00 +11:00
|
|
|
BKE_object_minmax_dupli(scene, ob, min, max, true);
|
2010-08-03 00:56:43 +00:00
|
|
|
mid_v3_v3v3(cent, min, max);
|
|
|
|
invert_m4_m4(ob->imat, ob->obmat);
|
|
|
|
mul_m4_v3(ob->imat, cent);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
|
2010-08-03 00:56:43 +00:00
|
|
|
add_v3_v3(ob->dup_group->dupli_ofs, cent);
|
|
|
|
|
|
|
|
tot_change++;
|
Split id->flag in two, persistent flags and runtime tags.
This is purely internal sanitizing/cleanup, no change in behavior is expected at all.
This change was also needed because we were getting short on ID flags, and
future enhancement of 'user_one' ID behavior requires two new ones.
id->flag remains for persistent data (fakeuser only, so far!), this also allows us
100% backward & forward compatibility.
New id->tag is used for most flags. Though written in .blend files, its content
is cleared at read time.
Note that .blend file version was bumped, so that we can clear runtimeflags from
old .blends, important in case we add new persistent flags in future.
Also, behavior of tags (either status ones, or whether they need to be cleared before/after use)
has been added as comments to their declaration.
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D1683
2015-12-27 11:53:50 +01:00
|
|
|
ob->dup_group->id.tag |= LIB_TAG_DOIT;
|
2014-04-01 11:34:00 +11:00
|
|
|
do_inverse_offset = true;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-11-06 17:17:10 +01:00
|
|
|
else if (ID_IS_LINKED(ob->data)) {
|
2010-08-01 11:00:36 +00:00
|
|
|
tot_lib_error++;
|
|
|
|
}
|
2010-07-23 23:48:21 +00:00
|
|
|
|
2012-04-28 15:42:27 +00:00
|
|
|
if (obedit == NULL && ob->type == OB_MESH) {
|
|
|
|
Mesh *me = ob->data;
|
2010-08-01 11:00:36 +00:00
|
|
|
|
2017-08-21 15:06:07 +10:00
|
|
|
if (centermode == ORIGIN_TO_CURSOR) {
|
|
|
|
/* done */
|
|
|
|
}
|
|
|
|
else if (centermode == ORIGIN_TO_CENTER_OF_MASS_SURFACE) {
|
|
|
|
BKE_mesh_center_of_surface(me, cent);
|
|
|
|
}
|
|
|
|
else if (centermode == ORIGIN_TO_CENTER_OF_MASS_VOLUME) {
|
|
|
|
BKE_mesh_center_of_volume(me, cent);
|
|
|
|
}
|
|
|
|
else if (around == V3D_AROUND_CENTER_MEAN) {
|
|
|
|
BKE_mesh_center_median(me, cent);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BKE_mesh_center_bounds(me, cent);
|
|
|
|
}
|
2010-08-01 11:00:36 +00:00
|
|
|
|
|
|
|
negate_v3_v3(cent_neg, cent);
|
2012-05-05 21:28:12 +00:00
|
|
|
BKE_mesh_translate(me, cent_neg, 1);
|
2010-08-01 11:00:36 +00:00
|
|
|
|
|
|
|
tot_change++;
|
Split id->flag in two, persistent flags and runtime tags.
This is purely internal sanitizing/cleanup, no change in behavior is expected at all.
This change was also needed because we were getting short on ID flags, and
future enhancement of 'user_one' ID behavior requires two new ones.
id->flag remains for persistent data (fakeuser only, so far!), this also allows us
100% backward & forward compatibility.
New id->tag is used for most flags. Though written in .blend files, its content
is cleared at read time.
Note that .blend file version was bumped, so that we can clear runtimeflags from
old .blends, important in case we add new persistent flags in future.
Also, behavior of tags (either status ones, or whether they need to be cleared before/after use)
has been added as comments to their declaration.
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D1683
2015-12-27 11:53:50 +01:00
|
|
|
me->id.tag |= LIB_TAG_DOIT;
|
2014-04-01 11:34:00 +11:00
|
|
|
do_inverse_offset = true;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
2009-10-29 09:14:20 +00:00
|
|
|
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
|
2012-04-28 15:42:27 +00:00
|
|
|
Curve *cu = ob->data;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2015-12-01 18:52:24 +11:00
|
|
|
if (centermode == ORIGIN_TO_CURSOR) { /* done */ }
|
|
|
|
else if (around == V3D_AROUND_CENTER_MEAN) { BKE_curve_center_median(cu, cent); }
|
|
|
|
else { BKE_curve_center_bounds(cu, cent); }
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2010-08-01 11:00:36 +00:00
|
|
|
/* don't allow Z change if curve is 2D */
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((ob->type == OB_CURVE) && !(cu->flag & CU_3D))
|
2010-08-01 11:00:36 +00:00
|
|
|
cent[2] = 0.0;
|
2010-07-23 23:48:21 +00:00
|
|
|
|
2010-08-01 11:00:36 +00:00
|
|
|
negate_v3_v3(cent_neg, cent);
|
2012-04-28 16:49:00 +00:00
|
|
|
BKE_curve_translate(cu, cent_neg, 1);
|
2010-08-01 11:00:36 +00:00
|
|
|
|
|
|
|
tot_change++;
|
Split id->flag in two, persistent flags and runtime tags.
This is purely internal sanitizing/cleanup, no change in behavior is expected at all.
This change was also needed because we were getting short on ID flags, and
future enhancement of 'user_one' ID behavior requires two new ones.
id->flag remains for persistent data (fakeuser only, so far!), this also allows us
100% backward & forward compatibility.
New id->tag is used for most flags. Though written in .blend files, its content
is cleared at read time.
Note that .blend file version was bumped, so that we can clear runtimeflags from
old .blends, important in case we add new persistent flags in future.
Also, behavior of tags (either status ones, or whether they need to be cleared before/after use)
has been added as comments to their declaration.
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D1683
2015-12-27 11:53:50 +01:00
|
|
|
cu->id.tag |= LIB_TAG_DOIT;
|
2014-04-01 11:34:00 +11:00
|
|
|
do_inverse_offset = true;
|
2010-08-01 11:00:36 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (obedit) {
|
2010-08-01 11:00:36 +00:00
|
|
|
if (centermode == GEOMETRY_TO_ORIGIN) {
|
2010-12-05 18:59:23 +00:00
|
|
|
DAG_id_tag_update(&obedit->id, OB_RECALC_DATA);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
2010-08-01 11:00:36 +00:00
|
|
|
break;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-28 15:42:27 +00:00
|
|
|
else if (ob->type == OB_FONT) {
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* get from bb */
|
2010-08-01 11:00:36 +00:00
|
|
|
|
2012-04-28 15:42:27 +00:00
|
|
|
Curve *cu = ob->data;
|
2010-08-01 11:00:36 +00:00
|
|
|
|
2014-04-16 13:18:42 +10:00
|
|
|
if (ob->bb == NULL && (centermode != ORIGIN_TO_CURSOR)) {
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* do nothing*/
|
2010-08-01 11:00:36 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (centermode == ORIGIN_TO_CURSOR) {
|
2010-08-03 00:56:43 +00:00
|
|
|
/* done */
|
2010-08-01 11:00:36 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-04-16 13:18:42 +10:00
|
|
|
/* extra 0.5 is the height o above line */
|
|
|
|
cent[0] = 0.5f * (ob->bb->vec[4][0] + ob->bb->vec[0][0]);
|
|
|
|
cent[1] = 0.5f * (ob->bb->vec[0][1] + ob->bb->vec[2][1]);
|
2010-08-01 11:00:36 +00:00
|
|
|
}
|
|
|
|
|
2012-04-28 15:42:27 +00:00
|
|
|
cent[2] = 0.0f;
|
2010-08-01 11:00:36 +00:00
|
|
|
|
2017-07-17 12:56:12 +02:00
|
|
|
cu->xof = cu->xof - cent[0];
|
|
|
|
cu->yof = cu->yof - cent[1];
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
tot_change++;
|
Split id->flag in two, persistent flags and runtime tags.
This is purely internal sanitizing/cleanup, no change in behavior is expected at all.
This change was also needed because we were getting short on ID flags, and
future enhancement of 'user_one' ID behavior requires two new ones.
id->flag remains for persistent data (fakeuser only, so far!), this also allows us
100% backward & forward compatibility.
New id->tag is used for most flags. Though written in .blend files, its content
is cleared at read time.
Note that .blend file version was bumped, so that we can clear runtimeflags from
old .blends, important in case we add new persistent flags in future.
Also, behavior of tags (either status ones, or whether they need to be cleared before/after use)
has been added as comments to their declaration.
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D1683
2015-12-27 11:53:50 +01:00
|
|
|
cu->id.tag |= LIB_TAG_DOIT;
|
2014-04-01 11:34:00 +11:00
|
|
|
do_inverse_offset = true;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-28 15:42:27 +00:00
|
|
|
else if (ob->type == OB_ARMATURE) {
|
2009-10-29 09:14:20 +00:00
|
|
|
bArmature *arm = ob->data;
|
2010-08-01 11:00:36 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ID_REAL_USERS(arm) > 1) {
|
2012-03-03 16:31:46 +00:00
|
|
|
#if 0
|
2012-10-26 17:32:50 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Cannot apply to a multi user armature");
|
2012-03-03 16:31:46 +00:00
|
|
|
return;
|
|
|
|
#endif
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
tot_multiuser_arm_error++;
|
2010-08-01 11:00:36 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Function to recenter armatures in editarmature.c
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
* Bone + object locations are handled there.
|
|
|
|
*/
|
2013-02-27 23:56:51 +00:00
|
|
|
ED_armature_origin_set(scene, ob, cursor, centermode, around);
|
2010-07-23 23:48:21 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
tot_change++;
|
Split id->flag in two, persistent flags and runtime tags.
This is purely internal sanitizing/cleanup, no change in behavior is expected at all.
This change was also needed because we were getting short on ID flags, and
future enhancement of 'user_one' ID behavior requires two new ones.
id->flag remains for persistent data (fakeuser only, so far!), this also allows us
100% backward & forward compatibility.
New id->tag is used for most flags. Though written in .blend files, its content
is cleared at read time.
Note that .blend file version was bumped, so that we can clear runtimeflags from
old .blends, important in case we add new persistent flags in future.
Also, behavior of tags (either status ones, or whether they need to be cleared before/after use)
has been added as comments to their declaration.
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D1683
2015-12-27 11:53:50 +01:00
|
|
|
arm->id.tag |= LIB_TAG_DOIT;
|
2014-04-01 11:34:00 +11:00
|
|
|
/* do_inverse_offset = true; */ /* docenter_armature() handles this */
|
2010-08-01 11:00:36 +00:00
|
|
|
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_object_where_is_calc(scene, ob);
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_pose_where_is(scene, ob); /* needed for bone parents */
|
2011-04-20 04:11:12 +00:00
|
|
|
|
2009-10-29 09:14:20 +00:00
|
|
|
ignore_parent_tx(bmain, scene, ob);
|
2010-08-01 11:00:36 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (obedit)
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-02-26 08:55:31 +00:00
|
|
|
else if (ob->type == OB_MBALL) {
|
|
|
|
MetaBall *mb = ob->data;
|
|
|
|
|
2015-12-01 18:52:24 +11:00
|
|
|
if (centermode == ORIGIN_TO_CURSOR) { /* done */ }
|
|
|
|
else if (around == V3D_AROUND_CENTER_MEAN) { BKE_mball_center_median(mb, cent); }
|
|
|
|
else { BKE_mball_center_bounds(mb, cent); }
|
2012-02-26 08:55:31 +00:00
|
|
|
|
|
|
|
negate_v3_v3(cent_neg, cent);
|
2012-05-07 06:38:41 +00:00
|
|
|
BKE_mball_translate(mb, cent_neg);
|
2012-02-26 08:55:31 +00:00
|
|
|
|
|
|
|
tot_change++;
|
Split id->flag in two, persistent flags and runtime tags.
This is purely internal sanitizing/cleanup, no change in behavior is expected at all.
This change was also needed because we were getting short on ID flags, and
future enhancement of 'user_one' ID behavior requires two new ones.
id->flag remains for persistent data (fakeuser only, so far!), this also allows us
100% backward & forward compatibility.
New id->tag is used for most flags. Though written in .blend files, its content
is cleared at read time.
Note that .blend file version was bumped, so that we can clear runtimeflags from
old .blends, important in case we add new persistent flags in future.
Also, behavior of tags (either status ones, or whether they need to be cleared before/after use)
has been added as comments to their declaration.
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D1683
2015-12-27 11:53:50 +01:00
|
|
|
mb->id.tag |= LIB_TAG_DOIT;
|
2014-04-01 11:34:00 +11:00
|
|
|
do_inverse_offset = true;
|
2012-02-26 08:55:31 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (obedit) {
|
2012-02-26 08:55:31 +00:00
|
|
|
if (centermode == GEOMETRY_TO_ORIGIN) {
|
|
|
|
DAG_id_tag_update(&obedit->id, OB_RECALC_DATA);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-02-01 15:17:39 +00:00
|
|
|
else if (ob->type == OB_LATTICE) {
|
|
|
|
Lattice *lt = ob->data;
|
|
|
|
|
2015-12-01 18:52:24 +11:00
|
|
|
if (centermode == ORIGIN_TO_CURSOR) { /* done */ }
|
|
|
|
else if (around == V3D_AROUND_CENTER_MEAN) { BKE_lattice_center_median(lt, cent); }
|
|
|
|
else { BKE_lattice_center_bounds(lt, cent); }
|
2013-02-01 15:17:39 +00:00
|
|
|
|
|
|
|
negate_v3_v3(cent_neg, cent);
|
|
|
|
BKE_lattice_translate(lt, cent_neg, 1);
|
|
|
|
|
|
|
|
tot_change++;
|
Split id->flag in two, persistent flags and runtime tags.
This is purely internal sanitizing/cleanup, no change in behavior is expected at all.
This change was also needed because we were getting short on ID flags, and
future enhancement of 'user_one' ID behavior requires two new ones.
id->flag remains for persistent data (fakeuser only, so far!), this also allows us
100% backward & forward compatibility.
New id->tag is used for most flags. Though written in .blend files, its content
is cleared at read time.
Note that .blend file version was bumped, so that we can clear runtimeflags from
old .blends, important in case we add new persistent flags in future.
Also, behavior of tags (either status ones, or whether they need to be cleared before/after use)
has been added as comments to their declaration.
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D1683
2015-12-27 11:53:50 +01:00
|
|
|
lt->id.tag |= LIB_TAG_DOIT;
|
2014-04-01 11:34:00 +11:00
|
|
|
do_inverse_offset = true;
|
2013-02-01 15:17:39 +00:00
|
|
|
}
|
2010-08-01 11:00:36 +00:00
|
|
|
|
|
|
|
/* offset other selected objects */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (do_inverse_offset && (centermode != GEOMETRY_TO_ORIGIN)) {
|
2012-10-12 14:35:10 +00:00
|
|
|
CollectionPointerLink *ctx_link_other;
|
2012-11-04 12:33:58 +00:00
|
|
|
float obmat[4][4];
|
2012-10-12 14:35:10 +00:00
|
|
|
|
2010-08-01 11:00:36 +00:00
|
|
|
/* was the object data modified
|
|
|
|
* note: the functions above must set 'cent' */
|
2012-11-04 12:33:58 +00:00
|
|
|
|
|
|
|
/* convert the offset to parent space */
|
|
|
|
BKE_object_to_mat4(ob, obmat);
|
2015-04-27 23:23:04 +10:00
|
|
|
mul_v3_mat3_m4v3(centn, obmat, cent); /* omit translation part */
|
2012-11-04 12:33:58 +00:00
|
|
|
|
2010-08-03 00:56:43 +00:00
|
|
|
add_v3_v3(ob->loc, centn);
|
2010-08-01 11:00:36 +00:00
|
|
|
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_object_where_is_calc(scene, ob);
|
2012-04-28 15:42:27 +00:00
|
|
|
if (ob->type == OB_ARMATURE) {
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_pose_where_is(scene, ob); /* needed for bone parents */
|
2011-04-20 04:11:12 +00:00
|
|
|
}
|
|
|
|
|
2010-08-03 00:56:43 +00:00
|
|
|
ignore_parent_tx(bmain, scene, ob);
|
|
|
|
|
|
|
|
/* other users? */
|
2012-10-12 14:35:10 +00:00
|
|
|
//CTX_DATA_BEGIN (C, Object *, ob_other, selected_editable_objects)
|
|
|
|
//{
|
|
|
|
|
|
|
|
/* use existing context looper */
|
|
|
|
for (ctx_link_other = ctx_data_list.first;
|
|
|
|
ctx_link_other;
|
|
|
|
ctx_link_other = ctx_link_other->next)
|
2012-04-30 16:22:40 +00:00
|
|
|
{
|
2012-10-12 14:35:10 +00:00
|
|
|
Object *ob_other = ctx_link_other->ptr.data;
|
|
|
|
|
2012-04-28 15:14:16 +00:00
|
|
|
if ((ob_other->flag & OB_DONE) == 0 &&
|
|
|
|
((ob->data && (ob->data == ob_other->data)) ||
|
|
|
|
(ob->dup_group == ob_other->dup_group &&
|
|
|
|
(ob->transflag | ob_other->transflag) & OB_DUPLIGROUP)))
|
|
|
|
{
|
2010-08-03 00:56:43 +00:00
|
|
|
ob_other->flag |= OB_DONE;
|
2012-04-28 15:42:27 +00:00
|
|
|
DAG_id_tag_update(&ob_other->id, OB_RECALC_OB | OB_RECALC_DATA);
|
2010-08-03 00:56:43 +00:00
|
|
|
|
2015-04-27 23:23:04 +10:00
|
|
|
mul_v3_mat3_m4v3(centn, ob_other->obmat, cent); /* omit translation part */
|
2010-08-03 00:56:43 +00:00
|
|
|
add_v3_v3(ob_other->loc, centn);
|
|
|
|
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_object_where_is_calc(scene, ob_other);
|
2012-04-28 15:42:27 +00:00
|
|
|
if (ob_other->type == OB_ARMATURE) {
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_pose_where_is(scene, ob_other); /* needed for bone parents */
|
2011-04-20 04:11:12 +00:00
|
|
|
}
|
2010-08-03 00:56:43 +00:00
|
|
|
ignore_parent_tx(bmain, scene, ob_other);
|
2010-08-01 11:00:36 +00:00
|
|
|
}
|
|
|
|
}
|
2012-10-12 14:35:10 +00:00
|
|
|
//CTX_DATA_END;
|
2010-08-01 11:00:36 +00:00
|
|
|
}
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-15 01:34:59 +00:00
|
|
|
BLI_freelistN(&ctx_data_list);
|
2010-07-23 23:48:21 +00:00
|
|
|
|
2012-04-28 15:42:27 +00:00
|
|
|
for (tob = bmain->object.first; tob; tob = tob->id.next)
|
Split id->flag in two, persistent flags and runtime tags.
This is purely internal sanitizing/cleanup, no change in behavior is expected at all.
This change was also needed because we were getting short on ID flags, and
future enhancement of 'user_one' ID behavior requires two new ones.
id->flag remains for persistent data (fakeuser only, so far!), this also allows us
100% backward & forward compatibility.
New id->tag is used for most flags. Though written in .blend files, its content
is cleared at read time.
Note that .blend file version was bumped, so that we can clear runtimeflags from
old .blends, important in case we add new persistent flags in future.
Also, behavior of tags (either status ones, or whether they need to be cleared before/after use)
has been added as comments to their declaration.
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D1683
2015-12-27 11:53:50 +01:00
|
|
|
if (tob->data && (((ID *)tob->data)->tag & LIB_TAG_DOIT))
|
2012-04-28 15:42:27 +00:00
|
|
|
DAG_id_tag_update(&tob->id, OB_RECALC_OB | OB_RECALC_DATA);
|
2010-08-01 11:00:36 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if (tot_change) {
|
2012-04-28 15:42:27 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
2010-08-01 11:00:36 +00:00
|
|
|
|
2010-07-20 10:41:08 +00:00
|
|
|
/* Warn if any errors occurred */
|
2012-04-28 15:42:27 +00:00
|
|
|
if (tot_lib_error + tot_multiuser_arm_error) {
|
2012-10-14 15:29:09 +00:00
|
|
|
BKE_reportf(op->reports, RPT_WARNING, "%i object(s) not centered, %i changed:", tot_lib_error + tot_multiuser_arm_error, tot_change);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if (tot_lib_error)
|
2012-10-14 15:29:09 +00:00
|
|
|
BKE_reportf(op->reports, RPT_WARNING, "|%i linked library object(s)", tot_lib_error);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if (tot_multiuser_arm_error)
|
2012-04-28 15:42:27 +00:00
|
|
|
BKE_reportf(op->reports, RPT_WARNING, "|%i multiuser armature object(s)", tot_multiuser_arm_error);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
2010-08-01 11:00:36 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2009-12-03 21:56:04 +00:00
|
|
|
void OBJECT_OT_origin_set(wmOperatorType *ot)
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
{
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem prop_set_center_types[] = {
|
2010-08-01 11:00:36 +00:00
|
|
|
{GEOMETRY_TO_ORIGIN, "GEOMETRY_ORIGIN", 0, "Geometry to Origin", "Move object geometry to object origin"},
|
2012-10-08 21:03:35 +00:00
|
|
|
{ORIGIN_TO_GEOMETRY, "ORIGIN_GEOMETRY", 0, "Origin to Geometry",
|
2017-08-21 15:06:07 +10:00
|
|
|
"Calculate the center of geometry based on the current pivot point (median, otherwise bounding-box)"},
|
2012-10-08 21:03:35 +00:00
|
|
|
{ORIGIN_TO_CURSOR, "ORIGIN_CURSOR", 0, "Origin to 3D Cursor",
|
2017-08-21 15:06:07 +10:00
|
|
|
"Move object origin to position of the 3D cursor"},
|
|
|
|
/* Intentional naming mismatch since some scripts refer to this. */
|
|
|
|
{ORIGIN_TO_CENTER_OF_MASS_SURFACE, "ORIGIN_CENTER_OF_MASS", 0, "Origin to Center of Mass (Surface)",
|
2017-08-21 15:24:40 +10:00
|
|
|
"Calculate the center of mass from the surface area"},
|
2017-08-21 15:06:07 +10:00
|
|
|
{ORIGIN_TO_CENTER_OF_MASS_VOLUME, "ORIGIN_CENTER_OF_VOLUME", 0, "Origin to Center of Mass (Volume)",
|
|
|
|
"Calculate the center of mass from the volume (must be manifold geometry with consistent normals)"},
|
2010-08-01 11:00:36 +00:00
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem prop_set_bounds_types[] = {
|
2015-12-01 18:52:24 +11:00
|
|
|
{V3D_AROUND_CENTER_MEAN, "MEDIAN", 0, "Median Center", ""},
|
|
|
|
{V3D_AROUND_CENTER_BOUNDS, "BOUNDS", 0, "Bounds Center", ""},
|
2010-08-01 11:00:36 +00:00
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Set Origin";
|
2012-10-08 21:03:35 +00:00
|
|
|
ot->description = "Set the object's origin, by either moving the data, or set to center of data, or use 3D cursor";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "OBJECT_OT_origin_set";
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
ot->exec = object_origin_set_exec;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_scene_editable;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-04-28 15:42:27 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->prop = RNA_def_enum(ot->srna, "type", prop_set_center_types, 0, "Type", "");
|
2015-12-01 18:52:24 +11:00
|
|
|
RNA_def_enum(ot->srna, "center", prop_set_bounds_types, V3D_AROUND_CENTER_MEAN, "Center", "");
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|