2011-02-23 11:52:22 +01: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 13:52:56 +02: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 14:34:04 +01: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 13:52:56 +02: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 21:29:51 +01:00
|
|
|
/** \file blender/editors/object/object_add.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 13:52:56 +02:00
|
|
|
#include <stdlib.h>
|
2009-10-07 16:40:27 +02: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 13:52:56 +02:00
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2011-08-07 14:43:44 +02:00
|
|
|
#include "DNA_anim_types.h"
|
2014-08-28 12:24:43 +02:00
|
|
|
#include "DNA_camera_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 13:52:56 +02:00
|
|
|
#include "DNA_curve_types.h"
|
|
|
|
#include "DNA_group_types.h"
|
2009-09-21 12:54:15 +02:00
|
|
|
#include "DNA_lamp_types.h"
|
2011-08-16 03:02:26 +02:00
|
|
|
#include "DNA_key_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 13:52:56 +02:00
|
|
|
#include "DNA_material_types.h"
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
#include "DNA_meta_types.h"
|
|
|
|
#include "DNA_object_fluidsim.h"
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-10-01 00:10:14 +02:00
|
|
|
#include "DNA_object_force.h"
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
#include "DNA_object_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 13:52:56 +02:00
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_vfont_types.h"
|
2012-01-22 00:57:28 +01:00
|
|
|
#include "DNA_actuator_types.h"
|
2016-08-03 23:31:48 +02:00
|
|
|
#include "DNA_gpencil_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 13:52:56 +02:00
|
|
|
|
2013-03-04 20:27:51 +01:00
|
|
|
#include "BLI_utildefines.h"
|
2011-12-17 00:56:18 +01:00
|
|
|
#include "BLI_ghash.h"
|
|
|
|
#include "BLI_listbase.h"
|
2009-11-10 21:43:45 +01:00
|
|
|
#include "BLI_math.h"
|
2011-11-07 06:28:26 +01:00
|
|
|
#include "BLI_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 13:52:56 +02:00
|
|
|
|
2015-08-16 09:32:01 +02:00
|
|
|
#include "BLT_translation.h"
|
2013-03-10 15:57:19 +01:00
|
|
|
|
2015-05-12 10:13:36 +02:00
|
|
|
#include "BKE_action.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 13:52:56 +02:00
|
|
|
#include "BKE_anim.h"
|
2010-11-09 10:53:17 +01:00
|
|
|
#include "BKE_animsys.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 13:52:56 +02:00
|
|
|
#include "BKE_armature.h"
|
2011-11-05 14:00:39 +01:00
|
|
|
#include "BKE_camera.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 13:52:56 +02:00
|
|
|
#include "BKE_context.h"
|
2017-02-27 17:46:21 +01:00
|
|
|
#include "BKE_constraint.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 13:52:56 +02:00
|
|
|
#include "BKE_curve.h"
|
|
|
|
#include "BKE_depsgraph.h"
|
|
|
|
#include "BKE_DerivedMesh.h"
|
|
|
|
#include "BKE_displist.h"
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-10-01 00:10:14 +02:00
|
|
|
#include "BKE_effect.h"
|
2014-01-09 18:34:52 +01:00
|
|
|
#include "BKE_font.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 13:52:56 +02:00
|
|
|
#include "BKE_group.h"
|
2011-11-05 14:11:49 +01:00
|
|
|
#include "BKE_lamp.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 13:52:56 +02:00
|
|
|
#include "BKE_lattice.h"
|
|
|
|
#include "BKE_library.h"
|
"Fix" crash when deleting linked object which has indirect usages.
This is in fact very hairy situation here... Objects are only refcounted by scenes,
any other usage is 'free', which means once all object instanciations are gone Blender
considers it can delete it.
There is a trap here though: indirect usages. Typically, we should never modify linked data
(because it is essencially useless, changes would be ignored and ost on next reload or
even undo/redo). This means indirect usages are not affected by default 'safe' remapping/unlinking.
For unlinking preceeding deletion however, this is not acceptable - we are likely to end with
a zero-user ID (aka deletable one) which is still actually used by other linked data.
Solution choosen here is double:
I) From 'user-space' (i.e. outliner, operators...), we check for cases where deleting datablocks
should not be allowed (indirect data or indirectly used data), and abort (with report) if needed.
II) From 'lower' level (BKE_library_remap and RNA), we also unlink from linked data,
which makes actual deletion possible and safe.
Note that with previous behavior (2.77 one), linked object would be deleted, including from linked data -
but then, once file is saved and reloaded, indirect usage would link back the deleted object,
without any instanciation in scene, which made it somehow virtual and unreachable...
With new behavior, this is no more possible, but on the other hand it means that in situations of dependency cycles
(two linked objects using each other), linked objects become impossible to delete (from user space).
Not sure what's best here, behavior with those corner cases of library linking is very poorly defined... :(
2016-07-01 17:51:08 +02:00
|
|
|
#include "BKE_library_query.h"
|
2016-12-12 14:58:10 +01:00
|
|
|
#include "BKE_library_remap.h"
|
2011-08-16 03:02:26 +02:00
|
|
|
#include "BKE_key.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 13:52:56 +02:00
|
|
|
#include "BKE_main.h"
|
|
|
|
#include "BKE_material.h"
|
|
|
|
#include "BKE_mball.h"
|
|
|
|
#include "BKE_mesh.h"
|
2011-08-07 14:43:44 +02:00
|
|
|
#include "BKE_nla.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 13:52:56 +02:00
|
|
|
#include "BKE_object.h"
|
|
|
|
#include "BKE_particle.h"
|
|
|
|
#include "BKE_report.h"
|
|
|
|
#include "BKE_sca.h"
|
2011-11-08 12:38:16 +01:00
|
|
|
#include "BKE_scene.h"
|
2014-09-02 12:45:28 +02:00
|
|
|
#include "BKE_screen.h"
|
2011-08-04 09:12:03 +02:00
|
|
|
#include "BKE_speaker.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 13:52:56 +02:00
|
|
|
#include "BKE_texture.h"
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
#include "RNA_define.h"
|
|
|
|
#include "RNA_enum_types.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "ED_armature.h"
|
|
|
|
#include "ED_curve.h"
|
|
|
|
#include "ED_mball.h"
|
|
|
|
#include "ED_mesh.h"
|
2011-11-08 12:38:16 +01:00
|
|
|
#include "ED_node.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 13:52:56 +02:00
|
|
|
#include "ED_object.h"
|
2013-04-09 03:43:39 +02:00
|
|
|
#include "ED_physics.h"
|
2010-02-13 14:49:27 +01:00
|
|
|
#include "ED_render.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 13:52:56 +02:00
|
|
|
#include "ED_screen.h"
|
|
|
|
#include "ED_transform.h"
|
2010-03-17 01:05:40 +01:00
|
|
|
#include "ED_view3d.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 13:52:56 +02:00
|
|
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
2012-08-02 17:49:20 +02:00
|
|
|
#include "GPU_material.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 13:52:56 +02:00
|
|
|
#include "object_intern.h"
|
|
|
|
|
2012-05-26 02:41:11 +02:00
|
|
|
/* this is an exact copy of the define in rna_lamp.c
|
2012-10-05 09:05:52 +02:00
|
|
|
* kept here because of linking order.
|
2012-06-14 15:54:55 +02:00
|
|
|
* Icons are only defined here */
|
2015-11-23 03:49:52 +01:00
|
|
|
EnumPropertyItem rna_enum_lamp_type_items[] = {
|
2012-06-14 15:54:55 +02:00
|
|
|
{LA_LOCAL, "POINT", ICON_LAMP_POINT, "Point", "Omnidirectional point light source"},
|
|
|
|
{LA_SUN, "SUN", ICON_LAMP_SUN, "Sun", "Constant direction parallel ray light source"},
|
|
|
|
{LA_SPOT, "SPOT", ICON_LAMP_SPOT, "Spot", "Directional cone light source"},
|
|
|
|
{LA_HEMI, "HEMI", ICON_LAMP_HEMI, "Hemi", "180 degree constant light source"},
|
|
|
|
{LA_AREA, "AREA", ICON_LAMP_AREA, "Area", "Directional area light source"},
|
2012-05-26 02:41:11 +02:00
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2012-10-05 09:05:52 +02:00
|
|
|
/* copy from rna_object_force.c */
|
|
|
|
static EnumPropertyItem field_type_items[] = {
|
|
|
|
{PFIELD_FORCE, "FORCE", ICON_FORCE_FORCE, "Force", ""},
|
|
|
|
{PFIELD_WIND, "WIND", ICON_FORCE_WIND, "Wind", ""},
|
|
|
|
{PFIELD_VORTEX, "VORTEX", ICON_FORCE_VORTEX, "Vortex", ""},
|
|
|
|
{PFIELD_MAGNET, "MAGNET", ICON_FORCE_MAGNETIC, "Magnetic", ""},
|
|
|
|
{PFIELD_HARMONIC, "HARMONIC", ICON_FORCE_HARMONIC, "Harmonic", ""},
|
|
|
|
{PFIELD_CHARGE, "CHARGE", ICON_FORCE_CHARGE, "Charge", ""},
|
|
|
|
{PFIELD_LENNARDJ, "LENNARDJ", ICON_FORCE_LENNARDJONES, "Lennard-Jones", ""},
|
|
|
|
{PFIELD_TEXTURE, "TEXTURE", ICON_FORCE_TEXTURE, "Texture", ""},
|
|
|
|
{PFIELD_GUIDE, "GUIDE", ICON_FORCE_CURVE, "Curve Guide", ""},
|
|
|
|
{PFIELD_BOID, "BOID", ICON_FORCE_BOID, "Boid", ""},
|
|
|
|
{PFIELD_TURBULENCE, "TURBULENCE", ICON_FORCE_TURBULENCE, "Turbulence", ""},
|
|
|
|
{PFIELD_DRAG, "DRAG", ICON_FORCE_DRAG, "Drag", ""},
|
2012-10-10 15:18:07 +02:00
|
|
|
{PFIELD_SMOKEFLOW, "SMOKE", ICON_FORCE_SMOKEFLOW, "Smoke Flow", ""},
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/************************** Exported *****************************/
|
|
|
|
|
2012-05-27 00:21:56 +02:00
|
|
|
void ED_object_location_from_view(bContext *C, float loc[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 13:52:56 +02:00
|
|
|
{
|
2012-04-28 17:42:27 +02:00
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2012-12-17 06:38:50 +01:00
|
|
|
const float *cursor;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2013-10-26 06:07:18 +02:00
|
|
|
cursor = ED_view3d_cursor3d_get(scene, v3d);
|
2010-03-18 02:26:56 +01:00
|
|
|
|
|
|
|
copy_v3_v3(loc, cursor);
|
2009-12-28 05:09:46 +01:00
|
|
|
}
|
|
|
|
|
2014-01-16 13:50:35 +01:00
|
|
|
void ED_object_rotation_from_view(bContext *C, float rot[3], const char align_axis)
|
2009-12-28 05:09:46 +01:00
|
|
|
{
|
2012-04-28 17:42:27 +02:00
|
|
|
RegionView3D *rv3d = CTX_wm_region_view3d(C);
|
2014-01-16 13:50:35 +01:00
|
|
|
|
|
|
|
BLI_assert(align_axis >= 'X' && align_axis <= 'Z');
|
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (rv3d) {
|
2010-11-18 01:26:00 +01:00
|
|
|
float quat[4];
|
2014-01-16 13:50:35 +01:00
|
|
|
|
|
|
|
switch (align_axis) {
|
|
|
|
case 'X':
|
|
|
|
{
|
|
|
|
float quat_y[4];
|
2015-01-31 07:23:30 +01:00
|
|
|
axis_angle_to_quat(quat_y, rv3d->viewinv[1], -M_PI_2);
|
2014-01-16 13:50:35 +01:00
|
|
|
mul_qt_qtqt(quat, rv3d->viewquat, quat_y);
|
|
|
|
quat[0] = -quat[0];
|
|
|
|
|
|
|
|
quat_to_eul(rot, quat);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'Y':
|
|
|
|
{
|
|
|
|
copy_qt_qt(quat, rv3d->viewquat);
|
|
|
|
quat[0] = -quat[0];
|
|
|
|
|
|
|
|
quat_to_eul(rot, quat);
|
2015-01-31 07:23:30 +01:00
|
|
|
rot[0] -= (float)M_PI_2;
|
2014-01-16 13:50:35 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'Z':
|
|
|
|
{
|
|
|
|
copy_qt_qt(quat, rv3d->viewquat);
|
|
|
|
quat[0] = -quat[0];
|
|
|
|
|
|
|
|
quat_to_eul(rot, quat);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-18 01:26:00 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
zero_v3(rot);
|
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 13:52:56 +02:00
|
|
|
}
|
2009-12-28 05:09:46 +01:00
|
|
|
}
|
|
|
|
|
2012-05-27 00:21:56 +02:00
|
|
|
void ED_object_base_init_transform(bContext *C, Base *base, const float loc[3], const float rot[3])
|
2009-12-28 05:09:46 +01:00
|
|
|
{
|
2012-04-28 17:42:27 +02:00
|
|
|
Object *ob = base->object;
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2009-12-28 05:09:46 +01:00
|
|
|
if (!scene) return;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2009-12-28 05:09:46 +01:00
|
|
|
if (loc)
|
|
|
|
copy_v3_v3(ob->loc, loc);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2009-12-28 05:09:46 +01:00
|
|
|
if (rot)
|
|
|
|
copy_v3_v3(ob->rot, rot);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-05-05 16:03:12 +02:00
|
|
|
BKE_object_where_is_calc(scene, 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 13:52:56 +02:00
|
|
|
}
|
|
|
|
|
2012-10-05 09:05:52 +02:00
|
|
|
/* Uses context to figure out transform for primitive.
|
|
|
|
* Returns standard diameter. */
|
2015-02-09 16:38:21 +01:00
|
|
|
float ED_object_new_primitive_matrix(
|
|
|
|
bContext *C, Object *obedit,
|
|
|
|
const float loc[3], const float rot[3], float primmat[4][4])
|
2010-01-12 02:50:34 +01:00
|
|
|
{
|
2012-05-31 18:04:03 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2012-02-23 03:23:42 +01:00
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
2010-01-12 02:50:34 +01:00
|
|
|
float mat[3][3], rmat[3][3], cmat[3][3], imat[3][3];
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2010-01-12 02:50:34 +01:00
|
|
|
unit_m4(primmat);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2010-01-12 02:50:34 +01:00
|
|
|
eul_to_mat3(rmat, rot);
|
|
|
|
invert_m3(rmat);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2010-01-12 02:50:34 +01:00
|
|
|
/* inverse transform for initial rotation and object */
|
|
|
|
copy_m3_m4(mat, obedit->obmat);
|
|
|
|
mul_m3_m3m3(cmat, rmat, mat);
|
|
|
|
invert_m3_m3(imat, cmat);
|
|
|
|
copy_m4_m3(primmat, imat);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2010-01-12 02:50:34 +01:00
|
|
|
/* center */
|
2010-06-09 21:20:05 +02:00
|
|
|
copy_v3_v3(primmat[3], loc);
|
|
|
|
sub_v3_v3v3(primmat[3], primmat[3], obedit->obmat[3]);
|
2010-01-12 02:50:34 +01:00
|
|
|
invert_m3_m3(imat, mat);
|
|
|
|
mul_m3_v3(imat, primmat[3]);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-12-09 11:48:18 +01:00
|
|
|
{
|
|
|
|
const float dia = v3d ? ED_view3d_grid_scale(scene, v3d, NULL) : ED_scene_grid_scale(scene, NULL);
|
2012-10-19 14:53:03 +02:00
|
|
|
return dia;
|
|
|
|
}
|
2012-05-31 18:04:03 +02:00
|
|
|
|
2013-07-16 13:42:07 +02:00
|
|
|
// return 1.0f;
|
2010-01-12 02:50:34 +01: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 13:52:56 +02:00
|
|
|
/********************* Add Object Operator ********************/
|
|
|
|
|
2012-09-15 03:52:28 +02:00
|
|
|
static void view_align_update(struct Main *UNUSED(main), struct Scene *UNUSED(scene), struct PointerRNA *ptr)
|
2011-10-06 14:51:33 +02:00
|
|
|
{
|
|
|
|
RNA_struct_idprops_unset(ptr, "rotation");
|
|
|
|
}
|
|
|
|
|
2013-09-16 02:18:09 +02:00
|
|
|
void ED_object_add_unit_props(wmOperatorType *ot)
|
|
|
|
{
|
2015-12-01 00:58:09 +01:00
|
|
|
RNA_def_float_distance(ot->srna, "radius", 1.0f, 0.0, OBJECT_ADD_SIZE_MAXF, "Radius", "", 0.001, 100.00);
|
2013-09-16 02:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ED_object_add_generic_props(wmOperatorType *ot, bool do_editmode)
|
2009-11-02 17:07:49 +01:00
|
|
|
{
|
2010-01-21 05:54:52 +01:00
|
|
|
PropertyRNA *prop;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2011-04-01 15:56:01 +02:00
|
|
|
/* note: this property gets hidden for add-camera operator */
|
2012-01-11 21:14:15 +01:00
|
|
|
prop = RNA_def_boolean(ot->srna, "view_align", 0, "Align to View", "Align the new object to the view");
|
2011-10-06 14:51:33 +02:00
|
|
|
RNA_def_property_update_runtime(prop, view_align_update);
|
2009-11-02 17:07:49 +01:00
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (do_editmode) {
|
2012-01-11 21:14:15 +01:00
|
|
|
prop = RNA_def_boolean(ot->srna, "enter_editmode", 0, "Enter Editmode",
|
2012-04-28 17:42:27 +02:00
|
|
|
"Enter editmode when adding this object");
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2010-04-12 02:40:56 +02:00
|
|
|
}
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2015-06-21 16:06:44 +02:00
|
|
|
prop = RNA_def_float_vector_xyz(ot->srna, "location", 3, NULL, -OBJECT_ADD_SIZE_MAXF, OBJECT_ADD_SIZE_MAXF,
|
|
|
|
"Location", "Location for the newly added object", -1000.0f, 1000.0f);
|
2012-01-11 21:14:15 +01:00
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2015-06-21 16:06:44 +02:00
|
|
|
prop = RNA_def_float_rotation(ot->srna, "rotation", 3, NULL, -OBJECT_ADD_SIZE_MAXF, OBJECT_ADD_SIZE_MAXF,
|
|
|
|
"Rotation", "Rotation for the newly added object",
|
|
|
|
DEG2RADF(-360.0f), DEG2RADF(360.0f));
|
2012-01-11 21:14:15 +01:00
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2010-08-18 09:45:32 +02:00
|
|
|
prop = RNA_def_boolean_layer_member(ot->srna, "layers", 20, NULL, "Layer", "");
|
2012-04-28 17:42:27 +02:00
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2009-11-02 17:07:49 +01:00
|
|
|
}
|
|
|
|
|
Fix T37879: Default UV generation for mesh primitives.
Adds default-generated UVs to mesh primitives (cone, cylinder, icosphere, uvsphere, cube, circle, grid)
when they are added to the scene, since some of them can be pretty awkward to unwrap manually.
Original patch: Liam Mitchell (CommanderCorianderSalamander).
Main review work: Campbell Barton (campbellbarton).
Finalization, fixes and cleanup: Bastien Montagne (mont29).
Reviewers: mont29, #mesh_modeling, campbellbarton
Reviewed By: mont29, campbellbarton
Subscribers: lkruel, campbellbarton, michaelknubben, kevindietrich
Maniphest Tasks: T37879
Differential Revision: https://developer.blender.org/D481
2015-12-04 23:49:55 +01:00
|
|
|
void ED_object_add_mesh_props(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
RNA_def_boolean(ot->srna, "calc_uvs", false, "Generate UVs", "Generate a default UV map");
|
|
|
|
}
|
|
|
|
|
2014-01-16 13:50:35 +01:00
|
|
|
bool ED_object_add_generic_get_opts(bContext *C, wmOperator *op, const char view_align_axis,
|
|
|
|
float loc[3], float rot[3],
|
2013-09-16 02:18:09 +02:00
|
|
|
bool *enter_editmode, unsigned int *layer, bool *is_view_aligned)
|
2009-11-02 17:07:49 +01:00
|
|
|
{
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
2013-07-13 07:46:48 +02:00
|
|
|
unsigned int _layer;
|
2015-02-17 03:09:21 +01:00
|
|
|
PropertyRNA *prop;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2015-02-17 03:09:21 +01:00
|
|
|
/* Switch to Edit mode? optional prop */
|
|
|
|
if ((prop = RNA_struct_find_property(op->ptr, "enter_editmode"))) {
|
2013-04-15 06:34:14 +02:00
|
|
|
bool _enter_editmode;
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
if (!enter_editmode)
|
|
|
|
enter_editmode = &_enter_editmode;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2015-02-17 03:09:21 +01:00
|
|
|
if (RNA_property_is_set(op->ptr, prop) && enter_editmode)
|
|
|
|
*enter_editmode = RNA_property_boolean_get(op->ptr, prop);
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
else {
|
2012-11-29 03:37:39 +01:00
|
|
|
*enter_editmode = (U.flag & USER_ADD_EDITMODE) != 0;
|
2015-02-17 03:09:21 +01:00
|
|
|
RNA_property_boolean_set(op->ptr, prop, *enter_editmode);
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
}
|
2009-12-28 05:09:46 +01:00
|
|
|
}
|
2012-10-05 09:05:52 +02:00
|
|
|
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
/* Get layers! */
|
|
|
|
{
|
|
|
|
int a, layer_values[20];
|
|
|
|
if (!layer)
|
|
|
|
layer = &_layer;
|
|
|
|
|
2015-02-17 03:09:21 +01:00
|
|
|
prop = RNA_struct_find_property(op->ptr, "layers");
|
|
|
|
if (RNA_property_is_set(op->ptr, prop)) {
|
|
|
|
RNA_property_boolean_get_array(op->ptr, prop, layer_values);
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
*layer = 0;
|
|
|
|
for (a = 0; a < 20; a++) {
|
|
|
|
if (layer_values[a])
|
|
|
|
*layer |= (1 << a);
|
|
|
|
}
|
2010-07-05 18:20:52 +02:00
|
|
|
}
|
|
|
|
else {
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2014-09-02 12:45:28 +02:00
|
|
|
*layer = BKE_screen_view3d_layer_active_ex(v3d, scene, false);
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
for (a = 0; a < 20; a++) {
|
2015-02-20 16:08:42 +01:00
|
|
|
layer_values[a] = (*layer & (1 << a)) != 0;
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
}
|
2015-02-17 03:09:21 +01:00
|
|
|
RNA_property_boolean_set_array(op->ptr, prop, layer_values);
|
2010-01-21 05:54:52 +01:00
|
|
|
}
|
2012-01-13 11:14:48 +01:00
|
|
|
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
/* in local view we additionally add local view layers,
|
|
|
|
* not part of operator properties */
|
|
|
|
if (v3d && v3d->localvd)
|
|
|
|
*layer |= v3d->lay;
|
2010-01-21 05:54:52 +01:00
|
|
|
}
|
2012-10-05 09:05:52 +02:00
|
|
|
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
/* Location! */
|
|
|
|
{
|
|
|
|
float _loc[3];
|
|
|
|
if (!loc)
|
|
|
|
loc = _loc;
|
2010-06-14 17:39:50 +02:00
|
|
|
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
if (RNA_struct_property_is_set(op->ptr, "location")) {
|
|
|
|
RNA_float_get_array(op->ptr, "location", loc);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ED_object_location_from_view(C, loc);
|
|
|
|
RNA_float_set_array(op->ptr, "location", loc);
|
2010-06-14 17:39:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
/* Rotation! */
|
|
|
|
{
|
2013-04-15 06:34:14 +02:00
|
|
|
bool _is_view_aligned;
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
float _rot[3];
|
|
|
|
if (!is_view_aligned)
|
|
|
|
is_view_aligned = &_is_view_aligned;
|
|
|
|
if (!rot)
|
|
|
|
rot = _rot;
|
|
|
|
|
|
|
|
if (RNA_struct_property_is_set(op->ptr, "rotation"))
|
2013-04-15 06:34:14 +02:00
|
|
|
*is_view_aligned = false;
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
else if (RNA_struct_property_is_set(op->ptr, "view_align"))
|
|
|
|
*is_view_aligned = RNA_boolean_get(op->ptr, "view_align");
|
|
|
|
else {
|
2013-07-10 10:01:06 +02:00
|
|
|
*is_view_aligned = (U.flag & USER_ADD_VIEWALIGNED) != 0;
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
RNA_boolean_set(op->ptr, "view_align", *is_view_aligned);
|
|
|
|
}
|
2012-10-05 09:05:52 +02:00
|
|
|
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
if (*is_view_aligned) {
|
2014-01-16 13:50:35 +01:00
|
|
|
ED_object_rotation_from_view(C, rot, view_align_axis);
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
RNA_float_set_array(op->ptr, "rotation", rot);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
RNA_float_get_array(op->ptr, "rotation", rot);
|
2011-08-30 16:41:23 +02:00
|
|
|
}
|
2010-06-14 17:39:50 +02:00
|
|
|
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
if (layer && *layer == 0) {
|
2010-06-14 17:39:50 +02:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Property 'layer' has no values set");
|
2013-09-16 02:18:09 +02:00
|
|
|
return false;
|
2010-06-14 17:39:50 +02:00
|
|
|
}
|
|
|
|
|
2013-09-16 02:18:09 +02:00
|
|
|
return true;
|
2009-11-02 17:07:49 +01:00
|
|
|
}
|
|
|
|
|
2012-10-05 09:05:52 +02:00
|
|
|
/* For object add primitive operators.
|
|
|
|
* Do not call undo push in this function (users of this function have to). */
|
2015-05-04 04:25:33 +02:00
|
|
|
Object *ED_object_add_type(
|
|
|
|
bContext *C,
|
|
|
|
int type, const char *name,
|
|
|
|
const float loc[3], const float rot[3],
|
|
|
|
bool enter_editmode, unsigned int layer)
|
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 13:52:56 +02:00
|
|
|
{
|
2012-04-28 17:42:27 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = CTX_data_scene(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 13:52:56 +02:00
|
|
|
Object *ob;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-10-10 15:18:07 +02:00
|
|
|
/* for as long scene has editmode... */
|
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 13:52:56 +02:00
|
|
|
if (CTX_data_edit_object(C))
|
2013-03-21 15:18:17 +01:00
|
|
|
ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); /* freedata, and undo */
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* deselects all, sets scene->basact */
|
2015-05-04 04:25:33 +02:00
|
|
|
ob = BKE_object_add(bmain, scene, type, name);
|
2010-01-21 05:54:52 +01:00
|
|
|
BASACT->lay = ob->lay = layer;
|
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 13:52:56 +02:00
|
|
|
/* editor level activate, notifiers */
|
|
|
|
ED_base_object_activate(C, BASACT);
|
|
|
|
|
|
|
|
/* more editor stuff */
|
2009-12-28 05:09:46 +01:00
|
|
|
ED_object_base_init_transform(C, BASACT, loc, rot);
|
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 13:52:56 +02:00
|
|
|
|
2013-04-09 07:02:10 +02:00
|
|
|
/* Ignore collisions by default for non-mesh objects */
|
|
|
|
if (type != OB_MESH) {
|
|
|
|
ob->body_type = OB_BODY_TYPE_NO_COLLISION;
|
|
|
|
ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_OCCLUDER | OB_DYNAMIC | OB_NAVMESH); /* copied from rna_object.c */
|
|
|
|
}
|
|
|
|
|
2011-11-08 12:38:16 +01:00
|
|
|
DAG_id_type_tag(bmain, ID_OB);
|
2013-02-21 20:33:04 +01:00
|
|
|
DAG_relations_tag_update(bmain);
|
2011-11-29 02:05:26 +01:00
|
|
|
if (ob->data) {
|
|
|
|
ED_render_id_flush_update(bmain, 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 13:52:56 +02:00
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (enter_editmode)
|
2013-03-21 15:18:17 +01:00
|
|
|
ED_object_editmode_enter(C, EM_IGNORE_LAYER);
|
2009-11-02 17:07:49 +01:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene);
|
2010-09-07 07:47:34 +02: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 13:52:56 +02:00
|
|
|
return ob;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* for object add operator */
|
|
|
|
static int object_add_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2014-09-01 12:09:31 +02:00
|
|
|
Object *ob;
|
2013-04-15 06:34:14 +02:00
|
|
|
bool enter_editmode;
|
2010-01-21 05:54:52 +01:00
|
|
|
unsigned int layer;
|
2014-10-28 15:53:31 +01:00
|
|
|
float loc[3], rot[3], radius;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2014-09-01 12:09:31 +02:00
|
|
|
WM_operator_view3d_unit_defaults(C, op);
|
2014-01-16 13:50:35 +01:00
|
|
|
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &layer, NULL))
|
2010-06-14 17:39:50 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2014-10-28 15:53:31 +01:00
|
|
|
radius = RNA_float_get(op->ptr, "radius");
|
2015-05-04 04:25:33 +02:00
|
|
|
ob = ED_object_add_type(C, RNA_enum_get(op->ptr, "type"), NULL, loc, rot, enter_editmode, layer);
|
2014-10-28 15:53:31 +01:00
|
|
|
|
|
|
|
if (ob->type == OB_LATTICE) {
|
|
|
|
/* lattice is a special case!
|
|
|
|
* we never want to scale the obdata since that is the rest-state */
|
|
|
|
copy_v3_fl(ob->size, radius);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BKE_object_obdata_size_init(ob, radius);
|
|
|
|
}
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->name = "Add Object";
|
2010-02-10 22:15:44 +01:00
|
|
|
ot->description = "Add an object to the scene";
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->idname = "OBJECT_OT_add";
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* api callbacks */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->exec = object_add_exec;
|
|
|
|
ot->poll = ED_operator_objectmode;
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* flags */
|
2012-04-28 17:42:27 +02:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2014-09-01 12:09:31 +02:00
|
|
|
/* properties */
|
|
|
|
ED_object_add_unit_props(ot);
|
2015-11-23 03:49:52 +01:00
|
|
|
RNA_def_enum(ot->srna, "type", rna_enum_object_type_items, 0, "Type", "");
|
2009-11-02 17:07:49 +01:00
|
|
|
|
2014-04-01 02:34:00 +02:00
|
|
|
ED_object_add_generic_props(ot, 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 13:52:56 +02:00
|
|
|
}
|
|
|
|
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-10-01 00:10:14 +02:00
|
|
|
/********************* Add Effector Operator ********************/
|
|
|
|
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
/* for object add operator */
|
|
|
|
static int effector_add_exec(bContext *C, wmOperator *op)
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-10-01 00:10:14 +02:00
|
|
|
{
|
|
|
|
Object *ob;
|
2013-04-15 06:34:14 +02:00
|
|
|
int type;
|
|
|
|
bool enter_editmode;
|
2010-01-21 05:54:52 +01:00
|
|
|
unsigned int layer;
|
2009-12-28 05:09:46 +01:00
|
|
|
float loc[3], rot[3];
|
2010-01-12 02:50:34 +01:00
|
|
|
float mat[4][4];
|
2014-09-01 12:09:31 +02:00
|
|
|
float dia;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2014-09-01 12:09:31 +02:00
|
|
|
WM_operator_view3d_unit_defaults(C, op);
|
2014-01-16 13:50:35 +01:00
|
|
|
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &layer, NULL))
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
type = RNA_enum_get(op->ptr, "type");
|
2014-09-01 12:09:31 +02:00
|
|
|
dia = RNA_float_get(op->ptr, "radius");
|
2009-11-02 17:07:49 +01:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
if (type == PFIELD_GUIDE) {
|
2014-01-27 05:18:40 +01:00
|
|
|
Curve *cu;
|
2015-08-16 09:32:01 +02:00
|
|
|
const char *name = CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "CurveGuide");
|
2015-05-04 04:25:33 +02:00
|
|
|
ob = ED_object_add_type(C, OB_CURVE, name, loc, rot, false, layer);
|
2009-11-02 17:07:49 +01:00
|
|
|
|
2014-01-27 05:18:40 +01:00
|
|
|
cu = ob->data;
|
|
|
|
cu->flag |= CU_PATH | CU_3D;
|
2013-03-21 15:18:17 +01:00
|
|
|
ED_object_editmode_enter(C, 0);
|
2015-02-09 16:38:21 +01:00
|
|
|
ED_object_new_primitive_matrix(C, ob, loc, rot, mat);
|
2015-11-18 02:20:28 +01:00
|
|
|
BLI_addtail(&cu->editnurb->nurbs, ED_curve_add_nurbs_primitive(C, ob, mat, CU_NURBS | CU_PRIM_PATH, dia));
|
2012-03-24 07:38:07 +01:00
|
|
|
if (!enter_editmode)
|
2013-03-21 15:18:17 +01:00
|
|
|
ED_object_editmode_exit(C, EM_FREEDATA);
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-10-01 00:10:14 +02:00
|
|
|
}
|
2009-11-02 12:37:35 +01:00
|
|
|
else {
|
2015-08-16 09:32:01 +02:00
|
|
|
const char *name = CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Field");
|
2015-05-04 04:25:33 +02:00
|
|
|
ob = ED_object_add_type(C, OB_EMPTY, name, loc, rot, false, layer);
|
2014-09-01 12:09:31 +02:00
|
|
|
BKE_object_obdata_size_init(ob, dia);
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
if (ELEM(type, PFIELD_WIND, PFIELD_VORTEX))
|
|
|
|
ob->empty_drawtype = OB_SINGLE_ARROW;
|
2009-11-02 12:37:35 +01:00
|
|
|
}
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-10-01 00:10:14 +02:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
ob->pd = object_add_collision_fields(type);
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-10-01 00:10:14 +02:00
|
|
|
|
2013-02-21 20:33:04 +01:00
|
|
|
DAG_relations_tag_update(CTX_data_main(C));
|
2011-02-07 12:55:24 +01:00
|
|
|
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-10-01 00:10:14 +02:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_effector_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->name = "Add Effector";
|
2010-02-10 22:15:44 +01:00
|
|
|
ot->description = "Add an empty object with a physics effector to the scene";
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->idname = "OBJECT_OT_effector_add";
|
2012-10-05 09:05:52 +02:00
|
|
|
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-10-01 00:10:14 +02:00
|
|
|
/* api callbacks */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->exec = effector_add_exec;
|
|
|
|
ot->poll = ED_operator_objectmode;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-10-01 00:10:14 +02:00
|
|
|
/* flags */
|
2012-04-28 17:42:27 +02:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2014-09-01 12:09:31 +02:00
|
|
|
/* properties */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->prop = RNA_def_enum(ot->srna, "type", field_type_items, 0, "Type", "");
|
2009-11-02 17:07:49 +01:00
|
|
|
|
2014-09-01 12:09:31 +02:00
|
|
|
ED_object_add_unit_props(ot);
|
2014-04-01 02:34:00 +02:00
|
|
|
ED_object_add_generic_props(ot, true);
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-10-01 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2012-10-05 09:05:52 +02:00
|
|
|
/********************* Add Camera Operator ********************/
|
2010-01-11 07:57:41 +01:00
|
|
|
|
|
|
|
static int object_camera_add_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
2012-04-28 17:42:27 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2010-01-11 07:57:41 +01:00
|
|
|
Object *ob;
|
2014-08-28 12:24:43 +02:00
|
|
|
Camera *cam;
|
2013-04-15 06:34:14 +02:00
|
|
|
bool enter_editmode;
|
2010-01-21 05:54:52 +01:00
|
|
|
unsigned int layer;
|
2010-01-11 07:57:41 +01:00
|
|
|
float loc[3], rot[3];
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2010-01-11 07:57:41 +01:00
|
|
|
/* force view align for cameras */
|
2014-04-01 02:34:00 +02:00
|
|
|
RNA_boolean_set(op->ptr, "view_align", true);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2014-01-16 13:50:35 +01:00
|
|
|
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &layer, NULL))
|
2010-06-14 17:39:50 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
2010-01-11 07:57:41 +01:00
|
|
|
|
2015-05-04 04:25:33 +02:00
|
|
|
ob = ED_object_add_type(C, OB_CAMERA, NULL, loc, rot, false, layer);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2010-01-11 07:57:41 +01:00
|
|
|
if (v3d) {
|
|
|
|
if (v3d->camera == NULL)
|
|
|
|
v3d->camera = ob;
|
2012-04-28 17:42:27 +02:00
|
|
|
if (v3d->scenelock && scene->camera == NULL) {
|
2010-01-11 07:57:41 +01:00
|
|
|
scene->camera = ob;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-28 12:24:43 +02:00
|
|
|
cam = ob->data;
|
|
|
|
cam->drawsize = v3d ? ED_view3d_grid_scale(scene, v3d, NULL) : ED_scene_grid_scale(scene, NULL);
|
|
|
|
|
2010-01-11 07:57:41 +01:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_camera_add(wmOperatorType *ot)
|
|
|
|
{
|
2011-04-01 15:56:01 +02:00
|
|
|
PropertyRNA *prop;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2010-01-11 07:57:41 +01:00
|
|
|
/* identifiers */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->name = "Add Camera";
|
2010-02-10 22:15:44 +01:00
|
|
|
ot->description = "Add a camera object to the scene";
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->idname = "OBJECT_OT_camera_add";
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2010-01-11 07:57:41 +01:00
|
|
|
/* api callbacks */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->exec = object_camera_add_exec;
|
|
|
|
ot->poll = ED_operator_objectmode;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2010-01-11 07:57:41 +01:00
|
|
|
/* flags */
|
2012-04-28 17:42:27 +02:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2014-04-01 02:34:00 +02:00
|
|
|
ED_object_add_generic_props(ot, true);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2011-04-01 15:56:01 +02:00
|
|
|
/* hide this for cameras, default */
|
2012-04-28 17:42:27 +02:00
|
|
|
prop = RNA_struct_type_find_property(ot->srna, "view_align");
|
2011-04-01 15:56:01 +02:00
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN);
|
2010-01-11 07:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-05 09:05:52 +02:00
|
|
|
/********************* Add Metaball Operator ********************/
|
|
|
|
|
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 13:52:56 +02:00
|
|
|
static int object_metaball_add_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-04-28 17:42:27 +02:00
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
2013-04-15 06:34:14 +02:00
|
|
|
bool newob = false;
|
|
|
|
bool enter_editmode;
|
2010-01-21 05:54:52 +01:00
|
|
|
unsigned int layer;
|
2009-12-28 05:09:46 +01:00
|
|
|
float loc[3], rot[3];
|
2010-01-12 02:50:34 +01:00
|
|
|
float mat[4][4];
|
2012-10-19 14:53:03 +02:00
|
|
|
float dia;
|
2012-07-07 01:56:59 +02:00
|
|
|
|
2013-09-16 06:19:48 +02:00
|
|
|
WM_operator_view3d_unit_defaults(C, op);
|
2014-01-16 13:50:35 +01:00
|
|
|
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &layer, NULL))
|
2010-06-14 17:39:50 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
if (obedit == NULL || obedit->type != OB_MBALL) {
|
2015-05-04 04:25:33 +02:00
|
|
|
obedit = ED_object_add_type(C, OB_MBALL, NULL, loc, rot, true, layer);
|
2013-04-15 06:34:14 +02:00
|
|
|
newob = 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 13:52:56 +02:00
|
|
|
}
|
2013-09-16 06:19:48 +02:00
|
|
|
else {
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
DAG_id_tag_update(&obedit->id, OB_RECALC_DATA);
|
2013-09-16 06:19:48 +02:00
|
|
|
}
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2015-02-09 16:38:21 +01:00
|
|
|
ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
|
2013-09-16 06:19:48 +02:00
|
|
|
dia = RNA_float_get(op->ptr, "radius");
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2015-11-18 02:20:28 +01:00
|
|
|
ED_mball_add_primitive(C, obedit, mat, dia, RNA_enum_get(op->ptr, "type"));
|
2010-08-23 02:57:19 +02: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 13:52:56 +02:00
|
|
|
/* userdef */
|
2009-11-02 17:07:49 +01:00
|
|
|
if (newob && !enter_editmode) {
|
2013-03-21 15:18:17 +01:00
|
|
|
ED_object_editmode_exit(C, EM_FREEDATA);
|
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 13:52:56 +02:00
|
|
|
}
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit);
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_metaball_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->name = "Add Metaball";
|
|
|
|
ot->description = "Add an metaball object to the scene";
|
|
|
|
ot->idname = "OBJECT_OT_metaball_add";
|
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 13:52:56 +02:00
|
|
|
|
|
|
|
/* api callbacks */
|
2013-09-16 06:19:48 +02:00
|
|
|
ot->invoke = WM_menu_invoke;
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->exec = object_metaball_add_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 13:52:56 +02:00
|
|
|
|
|
|
|
/* flags */
|
2012-04-28 17:42:27 +02:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2015-11-23 03:49:52 +01:00
|
|
|
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_metaelem_type_items, 0, "Primitive", "");
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
|
2013-09-16 06:19:48 +02:00
|
|
|
ED_object_add_unit_props(ot);
|
2014-04-01 02:34:00 +02:00
|
|
|
ED_object_add_generic_props(ot, 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 13:52:56 +02:00
|
|
|
}
|
2010-01-11 07:57:41 +01:00
|
|
|
|
2012-10-05 09:05:52 +02:00
|
|
|
/********************* Add Text Operator ********************/
|
|
|
|
|
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 13:52:56 +02:00
|
|
|
static int object_add_text_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-04-28 17:42:27 +02:00
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
2013-04-15 06:34:14 +02:00
|
|
|
bool enter_editmode;
|
2010-01-21 05:54:52 +01:00
|
|
|
unsigned int layer;
|
2009-12-28 05:09:46 +01:00
|
|
|
float loc[3], rot[3];
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2014-09-01 12:09:31 +02:00
|
|
|
WM_operator_view3d_unit_defaults(C, op);
|
2014-01-16 13:50:35 +01:00
|
|
|
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &layer, NULL))
|
2010-06-14 17:39:50 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
if (obedit && obedit->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 13:52:56 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2015-05-04 04:25:33 +02:00
|
|
|
obedit = ED_object_add_type(C, OB_FONT, NULL, loc, rot, enter_editmode, layer);
|
2014-09-01 12:09:31 +02:00
|
|
|
BKE_object_obdata_size_init(obedit, RNA_float_get(op->ptr, "radius"));
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit);
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_text_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->name = "Add Text";
|
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 13:52:56 +02:00
|
|
|
ot->description = "Add a text object to the scene";
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->idname = "OBJECT_OT_text_add";
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* api callbacks */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->exec = object_add_text_exec;
|
|
|
|
ot->poll = ED_operator_objectmode;
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* flags */
|
2012-04-28 17:42:27 +02:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2014-09-01 12:09:31 +02:00
|
|
|
|
|
|
|
/* properties */
|
|
|
|
ED_object_add_unit_props(ot);
|
2014-04-01 02:34:00 +02:00
|
|
|
ED_object_add_generic_props(ot, 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 13:52:56 +02:00
|
|
|
}
|
|
|
|
|
2012-10-05 09:05:52 +02:00
|
|
|
/********************* Add Armature Operator ********************/
|
|
|
|
|
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 13:52:56 +02:00
|
|
|
static int object_armature_add_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-04-28 17:42:27 +02:00
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
|
|
|
RegionView3D *rv3d = CTX_wm_region_view3d(C);
|
2013-04-15 06:34:14 +02:00
|
|
|
bool newob = false;
|
|
|
|
bool enter_editmode;
|
2010-01-21 05:54:52 +01:00
|
|
|
unsigned int layer;
|
2014-09-01 12:09:31 +02:00
|
|
|
float loc[3], rot[3], dia;
|
2013-07-04 16:59:26 +02:00
|
|
|
bool view_aligned = rv3d && (U.flag & USER_ADD_VIEWALIGNED);
|
2012-07-07 01:56:59 +02:00
|
|
|
|
2014-09-01 12:09:31 +02:00
|
|
|
WM_operator_view3d_unit_defaults(C, op);
|
2014-01-16 13:50:35 +01:00
|
|
|
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &layer, NULL))
|
2010-06-14 17:39:50 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
2012-07-07 01:56:59 +02:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
if ((obedit == NULL) || (obedit->type != OB_ARMATURE)) {
|
2015-05-04 04:25:33 +02:00
|
|
|
obedit = ED_object_add_type(C, OB_ARMATURE, NULL, loc, rot, true, layer);
|
2013-03-21 15:18:17 +01:00
|
|
|
ED_object_editmode_enter(C, 0);
|
2013-04-15 06:34:14 +02:00
|
|
|
newob = 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 13:52:56 +02:00
|
|
|
}
|
2013-03-09 04:46:30 +01:00
|
|
|
else {
|
|
|
|
DAG_id_tag_update(&obedit->id, OB_RECALC_DATA);
|
|
|
|
}
|
2012-07-07 01:56:59 +02:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
if (obedit == NULL) {
|
2011-06-05 01:02:44 +02:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Cannot create editmode armature");
|
2009-10-30 14:08:58 +01:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2014-09-01 12:09:31 +02:00
|
|
|
dia = RNA_float_get(op->ptr, "radius");
|
|
|
|
ED_armature_edit_bone_add_primitive(obedit, dia, view_aligned);
|
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 13:52:56 +02:00
|
|
|
|
|
|
|
/* userdef */
|
2010-01-30 10:34:54 +01:00
|
|
|
if (newob && !enter_editmode)
|
2013-03-21 15:18:17 +01:00
|
|
|
ED_object_editmode_exit(C, EM_FREEDATA);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit);
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_armature_add(wmOperatorType *ot)
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* identifiers */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->name = "Add Armature";
|
2010-02-10 22:15:44 +01:00
|
|
|
ot->description = "Add an armature object to the scene";
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->idname = "OBJECT_OT_armature_add";
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* api callbacks */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->exec = object_armature_add_exec;
|
|
|
|
ot->poll = ED_operator_objectmode;
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* flags */
|
2012-04-28 17:42:27 +02:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2014-09-01 12:09:31 +02:00
|
|
|
|
|
|
|
/* properties */
|
|
|
|
ED_object_add_unit_props(ot);
|
2014-04-01 02:34:00 +02:00
|
|
|
ED_object_add_generic_props(ot, 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 13:52:56 +02:00
|
|
|
}
|
|
|
|
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
/********************* Add Empty Operator ********************/
|
|
|
|
|
|
|
|
static int object_empty_add_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
Object *ob;
|
|
|
|
int type = RNA_enum_get(op->ptr, "type");
|
|
|
|
unsigned int layer;
|
|
|
|
float loc[3], rot[3];
|
|
|
|
|
2014-09-01 12:09:31 +02:00
|
|
|
WM_operator_view3d_unit_defaults(C, op);
|
2014-01-16 13:50:35 +01:00
|
|
|
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, &layer, NULL))
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2015-05-04 04:25:33 +02:00
|
|
|
ob = ED_object_add_type(C, OB_EMPTY, NULL, loc, rot, false, layer);
|
2014-01-13 21:57:05 +01:00
|
|
|
|
|
|
|
BKE_object_empty_draw_type_set(ob, type);
|
2014-09-01 12:09:31 +02:00
|
|
|
BKE_object_obdata_size_init(ob, RNA_float_get(op->ptr, "radius"));
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_empty_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Add Empty";
|
|
|
|
ot->description = "Add an empty object to the scene";
|
|
|
|
ot->idname = "OBJECT_OT_empty_add";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
ot->exec = object_empty_add_exec;
|
|
|
|
ot->poll = ED_operator_objectmode;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
|
|
|
|
/* properties */
|
2015-11-23 03:49:52 +01:00
|
|
|
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_object_empty_drawtype_items, 0, "Type", "");
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
|
2014-09-01 12:09:31 +02:00
|
|
|
ED_object_add_unit_props(ot);
|
2014-04-01 02:34:00 +02:00
|
|
|
ED_object_add_generic_props(ot, false);
|
Clean up in "add object" code:
* Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()!
* Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps).
* Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype.
* And some general code cleanup (like trailing spaces, empty lines, ...).
Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ).
2012-10-05 14:59:09 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 10:03:46 +01:00
|
|
|
static int empty_drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2013-02-25 00:18:21 +01:00
|
|
|
{
|
2014-05-07 08:53:58 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
2013-02-25 00:18:21 +01:00
|
|
|
Base *base = NULL;
|
|
|
|
Image *ima = NULL;
|
|
|
|
Object *ob = NULL;
|
|
|
|
|
2014-11-23 22:48:48 +01:00
|
|
|
ima = (Image *)WM_operator_drop_load_path(C, op, ID_IM);
|
|
|
|
if (!ima) {
|
2013-02-25 00:18:21 +01:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2014-11-23 22:48:48 +01:00
|
|
|
/* handled below */
|
|
|
|
id_us_min((ID *)ima);
|
2013-02-25 00:18:21 +01:00
|
|
|
|
|
|
|
base = ED_view3d_give_base_under_cursor(C, event->mval);
|
|
|
|
|
|
|
|
/* if empty under cursor, then set object */
|
|
|
|
if (base && base->object->type == OB_EMPTY) {
|
|
|
|
ob = base->object;
|
2014-05-07 08:53:58 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
|
2013-02-25 00:18:21 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* add new empty */
|
|
|
|
unsigned int layer;
|
2013-02-25 01:45:20 +01:00
|
|
|
float rot[3];
|
2013-02-25 00:18:21 +01:00
|
|
|
|
2014-01-16 13:50:35 +01:00
|
|
|
if (!ED_object_add_generic_get_opts(C, op, 'Z', NULL, rot, NULL, &layer, NULL))
|
2013-02-25 00:18:21 +01:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2015-05-04 04:25:33 +02:00
|
|
|
ob = ED_object_add_type(C, OB_EMPTY, NULL, NULL, rot, false, layer);
|
2013-02-25 01:45:20 +01:00
|
|
|
|
|
|
|
/* add under the mouse */
|
|
|
|
ED_object_location_from_view(C, ob->loc);
|
|
|
|
ED_view3d_cursor3d_position(C, ob->loc, event->mval);
|
2013-02-25 00:18:21 +01:00
|
|
|
}
|
|
|
|
|
2014-05-07 08:53:58 +02:00
|
|
|
BKE_object_empty_draw_type_set(ob, OB_EMPTY_IMAGE);
|
|
|
|
|
|
|
|
id_us_min(ob->data);
|
2013-02-25 00:18:21 +01:00
|
|
|
ob->data = ima;
|
2014-05-07 08:53:58 +02:00
|
|
|
id_us_plus(ob->data);
|
2013-02-25 00:18:21 +01:00
|
|
|
|
2013-03-02 13:05:25 +01:00
|
|
|
return OPERATOR_FINISHED;
|
2013-02-25 00:18:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_drop_named_image(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Add Empty Image/Drop Image To Empty";
|
|
|
|
ot->description = "Add an empty image type to scene with data";
|
|
|
|
ot->idname = "OBJECT_OT_drop_named_image";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->invoke = empty_drop_named_image_invoke;
|
|
|
|
ot->poll = ED_operator_objectmode;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
|
|
|
|
/* properties */
|
2014-01-16 11:43:22 +01:00
|
|
|
prop = RNA_def_string(ot->srna, "filepath", NULL, FILE_MAX, "Filepath", "Path to image file");
|
2013-02-25 00:18:21 +01:00
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2014-11-30 17:18:03 +01:00
|
|
|
RNA_def_boolean(ot->srna, "relative_path", true, "Relative Path", "Select the file relative to the blend file");
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2014-01-16 11:43:22 +01:00
|
|
|
prop = RNA_def_string(ot->srna, "name", NULL, MAX_ID_NAME - 2, "Name", "Image name to assign");
|
2013-02-25 00:18:21 +01:00
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2014-04-01 02:34:00 +02:00
|
|
|
ED_object_add_generic_props(ot, false);
|
2013-02-25 00:18:21 +01:00
|
|
|
}
|
|
|
|
|
2012-10-05 09:05:52 +02:00
|
|
|
/********************* Add Lamp Operator ********************/
|
|
|
|
|
2010-12-03 18:05:21 +01:00
|
|
|
static const char *get_lamp_defname(int type)
|
2010-06-27 09:45:57 +02:00
|
|
|
{
|
|
|
|
switch (type) {
|
2015-08-16 09:32:01 +02:00
|
|
|
case LA_LOCAL: return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Point");
|
|
|
|
case LA_SUN: return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Sun");
|
|
|
|
case LA_SPOT: return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Spot");
|
|
|
|
case LA_HEMI: return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Hemi");
|
|
|
|
case LA_AREA: return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Area");
|
2010-06-27 09:45:57 +02:00
|
|
|
default:
|
2015-08-16 09:32:01 +02:00
|
|
|
return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Lamp");
|
2010-06-27 09:45:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-21 12:54:15 +02:00
|
|
|
static int object_lamp_add_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-04-28 17:42:27 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2009-09-21 12:54:15 +02:00
|
|
|
Object *ob;
|
2011-11-08 12:38:16 +01:00
|
|
|
Lamp *la;
|
2012-04-28 17:42:27 +02:00
|
|
|
int type = RNA_enum_get(op->ptr, "type");
|
2010-01-21 05:54:52 +01:00
|
|
|
unsigned int layer;
|
2009-12-28 05:09:46 +01:00
|
|
|
float loc[3], rot[3];
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2014-09-01 12:09:31 +02:00
|
|
|
WM_operator_view3d_unit_defaults(C, op);
|
2014-01-16 13:50:35 +01:00
|
|
|
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, &layer, NULL))
|
2010-06-14 17:39:50 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
2009-09-21 12:54:15 +02:00
|
|
|
|
2015-05-04 04:25:33 +02:00
|
|
|
ob = ED_object_add_type(C, OB_LAMP, get_lamp_defname(type), loc, rot, false, layer);
|
2014-09-01 12:09:31 +02:00
|
|
|
BKE_object_obdata_size_init(ob, RNA_float_get(op->ptr, "radius"));
|
2011-11-08 12:38:16 +01:00
|
|
|
|
2014-09-01 12:09:31 +02:00
|
|
|
la = (Lamp *)ob->data;
|
2012-04-28 17:42:27 +02:00
|
|
|
la->type = type;
|
2011-11-08 12:38:16 +01:00
|
|
|
|
2012-05-05 16:33:36 +02:00
|
|
|
if (BKE_scene_use_new_shading_nodes(scene)) {
|
2013-03-18 17:34:57 +01:00
|
|
|
ED_node_shader_default(C, &la->id);
|
2014-04-01 02:34:00 +02:00
|
|
|
la->use_nodes = true;
|
2011-11-08 12:38:16 +01:00
|
|
|
}
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2009-09-21 12:54:15 +02:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_lamp_add(wmOperatorType *ot)
|
2012-05-26 02:06:30 +02:00
|
|
|
{
|
2009-09-21 12:54:15 +02:00
|
|
|
/* identifiers */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->name = "Add Lamp";
|
2010-02-10 22:15:44 +01:00
|
|
|
ot->description = "Add a lamp object to the scene";
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->idname = "OBJECT_OT_lamp_add";
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2009-09-21 12:54:15 +02:00
|
|
|
/* api callbacks */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
ot->exec = object_lamp_add_exec;
|
|
|
|
ot->poll = ED_operator_objectmode;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2009-09-21 12:54:15 +02:00
|
|
|
/* flags */
|
2012-04-28 17:42:27 +02:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-09-21 12:54:15 +02:00
|
|
|
|
|
|
|
/* properties */
|
2015-11-23 03:49:52 +01:00
|
|
|
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_lamp_type_items, 0, "Type", "");
|
2015-08-16 09:32:01 +02:00
|
|
|
RNA_def_property_translation_context(ot->prop, BLT_I18NCONTEXT_ID_LAMP);
|
2009-11-02 17:07:49 +01:00
|
|
|
|
2014-09-01 12:09:31 +02:00
|
|
|
ED_object_add_unit_props(ot);
|
2014-04-01 02:34:00 +02:00
|
|
|
ED_object_add_generic_props(ot, false);
|
2009-09-21 12:54:15 +02:00
|
|
|
}
|
|
|
|
|
2012-10-05 09:05:52 +02:00
|
|
|
/********************* Add Group Instance Operator ********************/
|
|
|
|
|
2009-10-07 16:40:27 +02:00
|
|
|
static int group_instance_add_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-12-22 19:34:17 +01:00
|
|
|
Group *group;
|
2010-01-21 05:54:52 +01:00
|
|
|
unsigned int layer;
|
2009-12-28 05:09:46 +01:00
|
|
|
float loc[3], rot[3];
|
2012-12-22 19:34:17 +01:00
|
|
|
|
|
|
|
if (RNA_struct_property_is_set(op->ptr, "name")) {
|
|
|
|
char name[MAX_ID_NAME - 2];
|
2012-12-26 17:24:50 +01:00
|
|
|
|
2012-12-22 19:34:17 +01:00
|
|
|
RNA_string_get(op->ptr, "name", name);
|
|
|
|
group = (Group *)BKE_libblock_find_name(ID_GR, name);
|
2012-12-26 17:24:50 +01:00
|
|
|
|
|
|
|
if (0 == RNA_struct_property_is_set(op->ptr, "location")) {
|
2017-10-14 08:29:54 +02:00
|
|
|
const wmEvent *event = CTX_wm_window(C)->eventstate;
|
2014-12-17 13:47:14 +01:00
|
|
|
ARegion *ar = CTX_wm_region(C);
|
|
|
|
const int mval[2] = {event->x - ar->winrct.xmin,
|
|
|
|
event->y - ar->winrct.ymin};
|
2012-12-26 17:24:50 +01:00
|
|
|
ED_object_location_from_view(C, loc);
|
2014-12-17 13:47:14 +01:00
|
|
|
ED_view3d_cursor3d_position(C, loc, mval);
|
2012-12-26 17:24:50 +01:00
|
|
|
RNA_float_set_array(op->ptr, "location", loc);
|
|
|
|
}
|
2012-12-22 19:34:17 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
group = BLI_findlink(&CTX_data_main(C)->group, RNA_enum_get(op->ptr, "group"));
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2014-01-16 13:50:35 +01:00
|
|
|
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, &layer, NULL))
|
2010-06-14 17:39:50 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
2009-11-02 17:07:49 +01:00
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (group) {
|
2012-04-28 17:42:27 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2015-05-04 04:25:33 +02:00
|
|
|
Object *ob = ED_object_add_type(C, OB_EMPTY, group->id.name + 2, loc, rot, false, layer);
|
2012-04-28 17:42:27 +02:00
|
|
|
ob->dup_group = group;
|
2009-10-07 16:40:27 +02:00
|
|
|
ob->transflag |= OB_DUPLIGROUP;
|
2016-09-03 11:47:17 +02:00
|
|
|
id_us_plus(&group->id);
|
2009-10-07 16:40:27 +02:00
|
|
|
|
2010-07-27 06:02:09 +02:00
|
|
|
/* works without this except if you try render right after, see: 22027 */
|
2013-02-21 20:33:04 +01:00
|
|
|
DAG_relations_tag_update(bmain);
|
2010-07-27 06:02:09 +02:00
|
|
|
|
2013-02-21 20:33:04 +01:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
|
2009-10-07 16:40:27 +02:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
2012-10-05 09:05:52 +02:00
|
|
|
/* only used as menu */
|
|
|
|
void OBJECT_OT_group_instance_add(wmOperatorType *ot)
|
|
|
|
{
|
2014-05-05 07:09:29 +02:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-10-05 09:05:52 +02:00
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Add Group Instance";
|
|
|
|
ot->description = "Add a dupligroup instance";
|
|
|
|
ot->idname = "OBJECT_OT_group_instance_add";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->invoke = WM_enum_search_invoke;
|
|
|
|
ot->exec = group_instance_add_exec;
|
|
|
|
ot->poll = ED_operator_objectmode;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
|
|
|
|
/* properties */
|
2012-12-22 19:34:17 +01:00
|
|
|
RNA_def_string(ot->srna, "name", "Group", MAX_ID_NAME - 2, "Name", "Group name to add");
|
2014-05-05 07:09:29 +02:00
|
|
|
prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "");
|
|
|
|
RNA_def_enum_funcs(prop, RNA_group_itemf);
|
|
|
|
RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
|
|
|
|
ot->prop = prop;
|
2014-04-01 02:34:00 +02:00
|
|
|
ED_object_add_generic_props(ot, false);
|
2012-10-05 09:05:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************* Add Speaker Operator ********************/
|
|
|
|
|
2011-08-01 13:44:20 +02:00
|
|
|
static int object_speaker_add_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
Object *ob;
|
|
|
|
unsigned int layer;
|
|
|
|
float loc[3], rot[3];
|
2011-08-09 10:38:14 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2011-08-01 13:44:20 +02:00
|
|
|
|
2014-01-16 13:50:35 +01:00
|
|
|
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, &layer, NULL))
|
2011-08-01 13:44:20 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2015-05-04 04:25:33 +02:00
|
|
|
ob = ED_object_add_type(C, OB_SPEAKER, NULL, loc, rot, false, layer);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2011-08-07 14:43:44 +02:00
|
|
|
/* to make it easier to start using this immediately in NLA, a default sound clip is created
|
|
|
|
* ready to be moved around to retime the sound and/or make new sound clips
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
/* create new data for NLA hierarchy */
|
2015-04-04 06:13:56 +02:00
|
|
|
AnimData *adt = BKE_animdata_add_id(&ob->id);
|
2011-08-07 14:43:44 +02:00
|
|
|
NlaTrack *nlt = add_nlatrack(adt, NULL);
|
2014-04-29 23:48:54 +02:00
|
|
|
NlaStrip *strip = add_nla_soundstrip(scene, ob->data);
|
2011-08-09 10:38:14 +02:00
|
|
|
strip->start = CFRA;
|
|
|
|
strip->end += strip->start;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2011-08-07 14:43:44 +02:00
|
|
|
/* hook them up */
|
|
|
|
BKE_nlatrack_add_strip(nlt, strip);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2011-08-07 14:43:44 +02:00
|
|
|
/* auto-name the strip, and give the track an interesting name */
|
2013-12-02 23:12:44 +01:00
|
|
|
BLI_strncpy(nlt->name, DATA_("SoundTrack"), sizeof(nlt->name));
|
2011-08-07 14:43:44 +02:00
|
|
|
BKE_nlastrip_validate_name(adt, strip);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
|
2011-08-07 14:43:44 +02:00
|
|
|
}
|
2011-08-01 13:44:20 +02:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_speaker_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->name = "Add Speaker";
|
2011-08-01 13:44:20 +02:00
|
|
|
ot->description = "Add a speaker object to the scene";
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->idname = "OBJECT_OT_speaker_add";
|
2011-08-01 13:44:20 +02:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->exec = object_speaker_add_exec;
|
|
|
|
ot->poll = ED_operator_objectmode;
|
2011-08-01 13:44:20 +02:00
|
|
|
|
|
|
|
/* flags */
|
2012-04-28 17:42:27 +02:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2011-08-01 13:44:20 +02:00
|
|
|
|
2014-04-01 02:34:00 +02:00
|
|
|
ED_object_add_generic_props(ot, true);
|
2011-08-01 13:44:20 +02: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 13:52:56 +02:00
|
|
|
/**************************** Delete Object *************************/
|
|
|
|
|
2012-08-02 17:49:20 +02:00
|
|
|
static void object_delete_check_glsl_update(Object *ob)
|
|
|
|
{
|
|
|
|
/* some objects could affect on GLSL shading, make sure GLSL settings
|
|
|
|
* are being tagged to be updated when object is removing from scene
|
|
|
|
*/
|
|
|
|
if (ob->type == OB_LAMP) {
|
2012-10-05 09:05:52 +02:00
|
|
|
if (ob->gpulamp.first)
|
2012-08-02 17:49:20 +02:00
|
|
|
GPU_lamp_free(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 13:52:56 +02:00
|
|
|
/* remove base from a specific scene */
|
|
|
|
/* note: now unlinks constraints as well */
|
2010-08-01 14:47:49 +02:00
|
|
|
void ED_base_object_free_and_unlink(Main *bmain, Scene *scene, Base *base)
|
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 13:52:56 +02:00
|
|
|
{
|
2017-01-04 10:25:27 +01:00
|
|
|
if (BKE_library_ID_is_indirectly_used(bmain, base->object) &&
|
|
|
|
ID_REAL_USERS(base->object) <= 1 && ID_EXTRA_USERS(base->object) == 0)
|
|
|
|
{
|
"Fix" crash when deleting linked object which has indirect usages.
This is in fact very hairy situation here... Objects are only refcounted by scenes,
any other usage is 'free', which means once all object instanciations are gone Blender
considers it can delete it.
There is a trap here though: indirect usages. Typically, we should never modify linked data
(because it is essencially useless, changes would be ignored and ost on next reload or
even undo/redo). This means indirect usages are not affected by default 'safe' remapping/unlinking.
For unlinking preceeding deletion however, this is not acceptable - we are likely to end with
a zero-user ID (aka deletable one) which is still actually used by other linked data.
Solution choosen here is double:
I) From 'user-space' (i.e. outliner, operators...), we check for cases where deleting datablocks
should not be allowed (indirect data or indirectly used data), and abort (with report) if needed.
II) From 'lower' level (BKE_library_remap and RNA), we also unlink from linked data,
which makes actual deletion possible and safe.
Note that with previous behavior (2.77 one), linked object would be deleted, including from linked data -
but then, once file is saved and reloaded, indirect usage would link back the deleted object,
without any instanciation in scene, which made it somehow virtual and unreachable...
With new behavior, this is no more possible, but on the other hand it means that in situations of dependency cycles
(two linked objects using each other), linked objects become impossible to delete (from user space).
Not sure what's best here, behavior with those corner cases of library linking is very poorly defined... :(
2016-07-01 17:51:08 +02:00
|
|
|
/* We cannot delete indirectly used object... */
|
|
|
|
printf("WARNING, undeletable object '%s', should have been catched before reaching this function!",
|
|
|
|
base->object->id.name + 2);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-26 18:38:45 +01:00
|
|
|
BKE_scene_base_unlink(scene, base);
|
2012-08-02 17:49:20 +02:00
|
|
|
object_delete_check_glsl_update(base->object);
|
2014-01-15 16:37:03 +01:00
|
|
|
BKE_libblock_free_us(bmain, base->object);
|
2013-01-26 18:38:45 +01:00
|
|
|
MEM_freeN(base);
|
"Fix" crash when deleting linked object which has indirect usages.
This is in fact very hairy situation here... Objects are only refcounted by scenes,
any other usage is 'free', which means once all object instanciations are gone Blender
considers it can delete it.
There is a trap here though: indirect usages. Typically, we should never modify linked data
(because it is essencially useless, changes would be ignored and ost on next reload or
even undo/redo). This means indirect usages are not affected by default 'safe' remapping/unlinking.
For unlinking preceeding deletion however, this is not acceptable - we are likely to end with
a zero-user ID (aka deletable one) which is still actually used by other linked data.
Solution choosen here is double:
I) From 'user-space' (i.e. outliner, operators...), we check for cases where deleting datablocks
should not be allowed (indirect data or indirectly used data), and abort (with report) if needed.
II) From 'lower' level (BKE_library_remap and RNA), we also unlink from linked data,
which makes actual deletion possible and safe.
Note that with previous behavior (2.77 one), linked object would be deleted, including from linked data -
but then, once file is saved and reloaded, indirect usage would link back the deleted object,
without any instanciation in scene, which made it somehow virtual and unreachable...
With new behavior, this is no more possible, but on the other hand it means that in situations of dependency cycles
(two linked objects using each other), linked objects become impossible to delete (from user space).
Not sure what's best here, behavior with those corner cases of library linking is very poorly defined... :(
2016-07-01 17:51:08 +02:00
|
|
|
DAG_id_type_tag(bmain, ID_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 13:52:56 +02:00
|
|
|
}
|
|
|
|
|
2011-11-15 05:11:01 +01:00
|
|
|
static int object_delete_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 13:52:56 +02:00
|
|
|
{
|
2012-04-28 17:42:27 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2012-12-17 13:03:31 +01:00
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
wmWindow *win;
|
2014-04-01 02:34:00 +02:00
|
|
|
const bool use_global = RNA_boolean_get(op->ptr, "use_global");
|
2013-12-20 01:38:07 +01:00
|
|
|
bool changed = false;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (CTX_data_edit_object(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 13:52:56 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-04-30 18:22:40 +02:00
|
|
|
CTX_DATA_BEGIN (C, Base *, base, selected_bases)
|
|
|
|
{
|
"Fix" crash when deleting linked object which has indirect usages.
This is in fact very hairy situation here... Objects are only refcounted by scenes,
any other usage is 'free', which means once all object instanciations are gone Blender
considers it can delete it.
There is a trap here though: indirect usages. Typically, we should never modify linked data
(because it is essencially useless, changes would be ignored and ost on next reload or
even undo/redo). This means indirect usages are not affected by default 'safe' remapping/unlinking.
For unlinking preceeding deletion however, this is not acceptable - we are likely to end with
a zero-user ID (aka deletable one) which is still actually used by other linked data.
Solution choosen here is double:
I) From 'user-space' (i.e. outliner, operators...), we check for cases where deleting datablocks
should not be allowed (indirect data or indirectly used data), and abort (with report) if needed.
II) From 'lower' level (BKE_library_remap and RNA), we also unlink from linked data,
which makes actual deletion possible and safe.
Note that with previous behavior (2.77 one), linked object would be deleted, including from linked data -
but then, once file is saved and reloaded, indirect usage would link back the deleted object,
without any instanciation in scene, which made it somehow virtual and unreachable...
With new behavior, this is no more possible, but on the other hand it means that in situations of dependency cycles
(two linked objects using each other), linked objects become impossible to delete (from user space).
Not sure what's best here, behavior with those corner cases of library linking is very poorly defined... :(
2016-07-01 17:51:08 +02:00
|
|
|
const bool is_indirectly_used = BKE_library_ID_is_indirectly_used(bmain, base->object);
|
|
|
|
if (base->object->id.tag & LIB_TAG_INDIRECT) {
|
|
|
|
/* Can this case ever happen? */
|
|
|
|
BKE_reportf(op->reports, RPT_WARNING, "Cannot delete indirectly linked object '%s'", base->object->id.name + 2);
|
|
|
|
continue;
|
|
|
|
}
|
2017-01-04 10:25:27 +01:00
|
|
|
else if (is_indirectly_used && ID_REAL_USERS(base->object) <= 1 && ID_EXTRA_USERS(base->object) == 0) {
|
"Fix" crash when deleting linked object which has indirect usages.
This is in fact very hairy situation here... Objects are only refcounted by scenes,
any other usage is 'free', which means once all object instanciations are gone Blender
considers it can delete it.
There is a trap here though: indirect usages. Typically, we should never modify linked data
(because it is essencially useless, changes would be ignored and ost on next reload or
even undo/redo). This means indirect usages are not affected by default 'safe' remapping/unlinking.
For unlinking preceeding deletion however, this is not acceptable - we are likely to end with
a zero-user ID (aka deletable one) which is still actually used by other linked data.
Solution choosen here is double:
I) From 'user-space' (i.e. outliner, operators...), we check for cases where deleting datablocks
should not be allowed (indirect data or indirectly used data), and abort (with report) if needed.
II) From 'lower' level (BKE_library_remap and RNA), we also unlink from linked data,
which makes actual deletion possible and safe.
Note that with previous behavior (2.77 one), linked object would be deleted, including from linked data -
but then, once file is saved and reloaded, indirect usage would link back the deleted object,
without any instanciation in scene, which made it somehow virtual and unreachable...
With new behavior, this is no more possible, but on the other hand it means that in situations of dependency cycles
(two linked objects using each other), linked objects become impossible to delete (from user space).
Not sure what's best here, behavior with those corner cases of library linking is very poorly defined... :(
2016-07-01 17:51:08 +02:00
|
|
|
BKE_reportf(op->reports, RPT_WARNING,
|
2016-08-03 23:31:48 +02:00
|
|
|
"Cannot delete object '%s' from scene '%s', indirectly used objects need at least one user",
|
|
|
|
base->object->id.name + 2, scene->id.name + 2);
|
"Fix" crash when deleting linked object which has indirect usages.
This is in fact very hairy situation here... Objects are only refcounted by scenes,
any other usage is 'free', which means once all object instanciations are gone Blender
considers it can delete it.
There is a trap here though: indirect usages. Typically, we should never modify linked data
(because it is essencially useless, changes would be ignored and ost on next reload or
even undo/redo). This means indirect usages are not affected by default 'safe' remapping/unlinking.
For unlinking preceeding deletion however, this is not acceptable - we are likely to end with
a zero-user ID (aka deletable one) which is still actually used by other linked data.
Solution choosen here is double:
I) From 'user-space' (i.e. outliner, operators...), we check for cases where deleting datablocks
should not be allowed (indirect data or indirectly used data), and abort (with report) if needed.
II) From 'lower' level (BKE_library_remap and RNA), we also unlink from linked data,
which makes actual deletion possible and safe.
Note that with previous behavior (2.77 one), linked object would be deleted, including from linked data -
but then, once file is saved and reloaded, indirect usage would link back the deleted object,
without any instanciation in scene, which made it somehow virtual and unreachable...
With new behavior, this is no more possible, but on the other hand it means that in situations of dependency cycles
(two linked objects using each other), linked objects become impossible to delete (from user space).
Not sure what's best here, behavior with those corner cases of library linking is very poorly defined... :(
2016-07-01 17:51:08 +02:00
|
|
|
continue;
|
|
|
|
}
|
2017-04-19 22:07:57 +02:00
|
|
|
|
|
|
|
/* This is sort of a quick hack to address T51243 - Proper thing to do here would be to nuke most of all this
|
|
|
|
* custom scene/object/base handling, and use generic lib remap/query for that.
|
|
|
|
* But this is for later (aka 2.8, once layers & co are settled and working).
|
|
|
|
*/
|
|
|
|
if (use_global && base->object->id.lib == NULL) {
|
|
|
|
/* We want to nuke the object, let's nuke it the easy way (not for linked data though)... */
|
|
|
|
BKE_libblock_delete(bmain, &base->object->id);
|
|
|
|
changed = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-08-03 23:31:48 +02:00
|
|
|
/* remove from Grease Pencil parent */
|
2017-04-19 22:07:57 +02:00
|
|
|
/* XXX This is likely not correct? Will also remove parent from grease pencil from other scenes,
|
|
|
|
* even when use_global is false... */
|
2016-08-03 23:31:48 +02:00
|
|
|
for (bGPdata *gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) {
|
|
|
|
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
|
|
|
|
if (gpl->parent != NULL) {
|
|
|
|
Object *ob = gpl->parent;
|
|
|
|
Object *curob = base->object;
|
|
|
|
if (ob == curob) {
|
|
|
|
gpl->parent = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
"Fix" crash when deleting linked object which has indirect usages.
This is in fact very hairy situation here... Objects are only refcounted by scenes,
any other usage is 'free', which means once all object instanciations are gone Blender
considers it can delete it.
There is a trap here though: indirect usages. Typically, we should never modify linked data
(because it is essencially useless, changes would be ignored and ost on next reload or
even undo/redo). This means indirect usages are not affected by default 'safe' remapping/unlinking.
For unlinking preceeding deletion however, this is not acceptable - we are likely to end with
a zero-user ID (aka deletable one) which is still actually used by other linked data.
Solution choosen here is double:
I) From 'user-space' (i.e. outliner, operators...), we check for cases where deleting datablocks
should not be allowed (indirect data or indirectly used data), and abort (with report) if needed.
II) From 'lower' level (BKE_library_remap and RNA), we also unlink from linked data,
which makes actual deletion possible and safe.
Note that with previous behavior (2.77 one), linked object would be deleted, including from linked data -
but then, once file is saved and reloaded, indirect usage would link back the deleted object,
without any instanciation in scene, which made it somehow virtual and unreachable...
With new behavior, this is no more possible, but on the other hand it means that in situations of dependency cycles
(two linked objects using each other), linked objects become impossible to delete (from user space).
Not sure what's best here, behavior with those corner cases of library linking is very poorly defined... :(
2016-07-01 17:51:08 +02:00
|
|
|
|
2010-10-13 21:56:53 +02:00
|
|
|
/* deselect object -- it could be used in other scenes */
|
|
|
|
base->object->flag &= ~SELECT;
|
|
|
|
|
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 13:52:56 +02:00
|
|
|
/* remove from current scene only */
|
2010-08-01 14:47:49 +02:00
|
|
|
ED_base_object_free_and_unlink(bmain, scene, base);
|
2013-12-20 01:38:07 +01:00
|
|
|
changed = true;
|
2011-11-15 05:11:01 +01:00
|
|
|
|
|
|
|
if (use_global) {
|
|
|
|
Scene *scene_iter;
|
|
|
|
Base *base_other;
|
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
for (scene_iter = bmain->scene.first; scene_iter; scene_iter = scene_iter->id.next) {
|
2016-07-06 14:11:01 +02:00
|
|
|
if (scene_iter != scene && !ID_IS_LINKED_DATABLOCK(scene_iter)) {
|
2012-05-05 16:33:36 +02:00
|
|
|
base_other = BKE_scene_base_find(scene_iter, base->object);
|
2011-11-15 05:11:01 +01:00
|
|
|
if (base_other) {
|
2017-01-04 10:25:27 +01:00
|
|
|
if (is_indirectly_used && ID_REAL_USERS(base->object) <= 1 && ID_EXTRA_USERS(base->object) == 0) {
|
"Fix" crash when deleting linked object which has indirect usages.
This is in fact very hairy situation here... Objects are only refcounted by scenes,
any other usage is 'free', which means once all object instanciations are gone Blender
considers it can delete it.
There is a trap here though: indirect usages. Typically, we should never modify linked data
(because it is essencially useless, changes would be ignored and ost on next reload or
even undo/redo). This means indirect usages are not affected by default 'safe' remapping/unlinking.
For unlinking preceeding deletion however, this is not acceptable - we are likely to end with
a zero-user ID (aka deletable one) which is still actually used by other linked data.
Solution choosen here is double:
I) From 'user-space' (i.e. outliner, operators...), we check for cases where deleting datablocks
should not be allowed (indirect data or indirectly used data), and abort (with report) if needed.
II) From 'lower' level (BKE_library_remap and RNA), we also unlink from linked data,
which makes actual deletion possible and safe.
Note that with previous behavior (2.77 one), linked object would be deleted, including from linked data -
but then, once file is saved and reloaded, indirect usage would link back the deleted object,
without any instanciation in scene, which made it somehow virtual and unreachable...
With new behavior, this is no more possible, but on the other hand it means that in situations of dependency cycles
(two linked objects using each other), linked objects become impossible to delete (from user space).
Not sure what's best here, behavior with those corner cases of library linking is very poorly defined... :(
2016-07-01 17:51:08 +02:00
|
|
|
BKE_reportf(op->reports, RPT_WARNING,
|
|
|
|
"Cannot delete object '%s' from scene '%s', indirectly used objects need at least one user",
|
|
|
|
base->object->id.name + 2, scene_iter->id.name + 2);
|
|
|
|
break;
|
|
|
|
}
|
2011-11-15 05:11:01 +01:00
|
|
|
ED_base_object_free_and_unlink(bmain, scene_iter, base_other);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* end global */
|
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 13:52:56 +02:00
|
|
|
}
|
|
|
|
CTX_DATA_END;
|
|
|
|
|
2013-12-20 01:38:07 +01:00
|
|
|
if (!changed)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2012-12-17 13:03:31 +01:00
|
|
|
/* delete has to handle all open scenes */
|
2016-02-22 12:09:36 +01:00
|
|
|
BKE_main_id_tag_listbase(&bmain->scene, LIB_TAG_DOIT, true);
|
2012-12-17 13:03:31 +01:00
|
|
|
for (win = wm->windows.first; win; win = win->next) {
|
|
|
|
scene = win->screen->scene;
|
|
|
|
|
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 (scene->id.tag & LIB_TAG_DOIT) {
|
|
|
|
scene->id.tag &= ~LIB_TAG_DOIT;
|
2012-12-17 13:03:31 +01:00
|
|
|
|
2013-02-21 20:33:04 +01:00
|
|
|
DAG_relations_tag_update(bmain);
|
2012-12-17 13:03:31 +01:00
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene);
|
|
|
|
}
|
|
|
|
}
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_delete(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->name = "Delete";
|
2010-02-10 22:15:44 +01:00
|
|
|
ot->description = "Delete selected objects";
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->idname = "OBJECT_OT_delete";
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* api callbacks */
|
2013-12-20 01:38:07 +01:00
|
|
|
ot->invoke = WM_operator_confirm;
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->exec = object_delete_exec;
|
|
|
|
ot->poll = ED_operator_objectmode;
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* flags */
|
2012-04-28 17:42:27 +02:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2011-11-15 05:11:01 +01:00
|
|
|
|
2011-12-09 11:19:11 +01:00
|
|
|
RNA_def_boolean(ot->srna, "use_global", 0, "Delete Globally", "Remove object from all scenes");
|
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 13:52:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************** Copy Utilities ******************************/
|
|
|
|
|
|
|
|
/* after copying objects, copied data should get new pointers */
|
2015-10-08 11:29:49 +02:00
|
|
|
static void copy_object_set_idnew(bContext *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 13:52:56 +02:00
|
|
|
{
|
2012-04-28 17:42:27 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-04-30 18:22:40 +02:00
|
|
|
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
|
|
|
|
{
|
2016-12-12 14:58:10 +01:00
|
|
|
BKE_libblock_relink_to_newid(&ob->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 13:52:56 +02:00
|
|
|
}
|
|
|
|
CTX_DATA_END;
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
set_sca_new_poins();
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2013-12-30 03:25:27 +01:00
|
|
|
BKE_main_id_clear_newpoins(bmain);
|
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 13:52:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************* Make Duplicates Real ************************/
|
|
|
|
|
2014-12-08 16:13:27 +01:00
|
|
|
/**
|
2016-11-22 17:38:43 +01:00
|
|
|
* \note regarding hashing dupli-objects when using OB_DUPLIGROUP, skip the first member of #DupliObject.persistent_id
|
2014-12-12 11:15:38 +01:00
|
|
|
* since its a unique index and we only want to know if the group objects are from the same dupli-group instance.
|
2014-12-08 16:13:27 +01:00
|
|
|
*/
|
2016-11-22 17:38:43 +01:00
|
|
|
static unsigned int dupliobject_group_hash(const void *ptr)
|
2014-12-08 16:13:27 +01:00
|
|
|
{
|
|
|
|
const DupliObject *dob = ptr;
|
|
|
|
unsigned int hash = BLI_ghashutil_ptrhash(dob->ob);
|
|
|
|
unsigned int i;
|
|
|
|
for (i = 1; (i < MAX_DUPLI_RECUR) && dob->persistent_id[i] != INT_MAX; i++) {
|
|
|
|
hash ^= (dob->persistent_id[i] ^ i);
|
|
|
|
}
|
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
|
2016-11-22 17:38:43 +01:00
|
|
|
/**
|
|
|
|
* \note regarding hashing dupli-objects when NOT using OB_DUPLIGROUP, include the first member of #DupliObject.persistent_id
|
|
|
|
* since its the index of the vertex/face the object is instantiated on and we want to identify objects on the same vertex/face.
|
|
|
|
*/
|
|
|
|
static unsigned int dupliobject_hash(const void *ptr)
|
|
|
|
{
|
|
|
|
const DupliObject *dob = ptr;
|
|
|
|
unsigned int hash = BLI_ghashutil_ptrhash(dob->ob);
|
|
|
|
hash ^= (dob->persistent_id[0] ^ 0);
|
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compare function that matches dupliobject_group_hash */
|
|
|
|
static bool dupliobject_group_cmp(const void *a_, const void *b_)
|
2014-12-08 16:13:27 +01:00
|
|
|
{
|
|
|
|
const DupliObject *a = a_;
|
|
|
|
const DupliObject *b = b_;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (a->ob != b->ob) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; (i < MAX_DUPLI_RECUR); i++) {
|
|
|
|
if (a->persistent_id[i] != b->persistent_id[i]) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (a->persistent_id[i] == INT_MAX) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* matching */
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-11-22 17:38:43 +01:00
|
|
|
/* Compare function that matches dupliobject_hash */
|
|
|
|
static bool dupliobject_cmp(const void *a_, const void *b_)
|
|
|
|
{
|
|
|
|
const DupliObject *a = a_;
|
|
|
|
const DupliObject *b = b_;
|
|
|
|
|
|
|
|
if (a->ob != b->ob) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a->persistent_id[0] != b->persistent_id[0]) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* matching */
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-11-07 06:28:26 +01:00
|
|
|
static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
|
2014-04-11 03:25:41 +02:00
|
|
|
const bool use_base_parent,
|
|
|
|
const bool use_hierarchy)
|
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 13:52:56 +02:00
|
|
|
{
|
2013-10-22 17:19:37 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2017-08-08 16:08:24 +02:00
|
|
|
ListBase *lb_duplis;
|
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 13:52:56 +02:00
|
|
|
DupliObject *dob;
|
2017-08-08 16:08:24 +02:00
|
|
|
GHash *dupli_gh, *parent_gh = NULL;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2017-08-08 16:08:24 +02:00
|
|
|
if (!(base->object->transflag & OB_DUPLI)) {
|
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 13:52:56 +02:00
|
|
|
return;
|
2017-08-08 16:08:24 +02:00
|
|
|
}
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2017-08-08 16:08:24 +02:00
|
|
|
lb_duplis = object_duplilist(bmain->eval_ctx, scene, base->object);
|
2011-12-17 00:56:18 +01:00
|
|
|
|
2017-08-08 16:01:48 +02:00
|
|
|
dupli_gh = BLI_ghash_ptr_new(__func__);
|
|
|
|
if (use_hierarchy) {
|
|
|
|
if (base->object->transflag & OB_DUPLIGROUP) {
|
|
|
|
parent_gh = BLI_ghash_new(dupliobject_group_hash, dupliobject_group_cmp, __func__);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
parent_gh = BLI_ghash_new(dupliobject_hash, dupliobject_cmp, __func__);
|
2016-11-04 08:30:22 +01:00
|
|
|
}
|
2011-12-17 00:56:18 +01:00
|
|
|
}
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2017-08-08 16:08:24 +02:00
|
|
|
for (dob = lb_duplis->first; dob; dob = dob->next) {
|
|
|
|
Object *ob_src = dob->ob;
|
|
|
|
Object *ob_dst = ID_NEW_SET(dob->ob, BKE_object_copy(bmain, ob_src));
|
|
|
|
Base *base_dst;
|
2013-10-22 17:19:37 +02: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 13:52:56 +02:00
|
|
|
/* font duplis can have a totcol without material, we get them from parent
|
2012-03-03 17:31:46 +01:00
|
|
|
* should be implemented better...
|
|
|
|
*/
|
2017-08-08 16:08:24 +02:00
|
|
|
if (ob_dst->mat == NULL) {
|
|
|
|
ob_dst->totcol = 0;
|
|
|
|
}
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2017-08-08 16:08:24 +02:00
|
|
|
base_dst = MEM_dupallocN(base);
|
|
|
|
base_dst->flag &= ~(OB_FROMDUPLI | OB_FROMGROUP);
|
|
|
|
ob_dst->flag = base_dst->flag;
|
|
|
|
base_dst->lay = base->lay;
|
|
|
|
BLI_addhead(&scene->base, base_dst); /* addhead: othwise eternal loop */
|
|
|
|
base_dst->object = ob_dst;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2011-02-16 22:54:41 +01:00
|
|
|
/* make sure apply works */
|
2017-08-08 16:08:24 +02:00
|
|
|
BKE_animdata_free(&ob_dst->id, true);
|
|
|
|
ob_dst->adt = NULL;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2014-03-11 19:54:12 +01:00
|
|
|
/* Proxies are not to be copied. */
|
2017-08-08 16:08:24 +02:00
|
|
|
ob_dst->proxy_from = NULL;
|
|
|
|
ob_dst->proxy_group = NULL;
|
|
|
|
ob_dst->proxy = NULL;
|
2014-03-11 19:54:12 +01:00
|
|
|
|
2017-08-08 16:08:24 +02:00
|
|
|
ob_dst->parent = NULL;
|
|
|
|
BKE_constraints_free(&ob_dst->constraints);
|
|
|
|
ob_dst->curve_cache = NULL;
|
|
|
|
ob_dst->transflag &= ~OB_DUPLI;
|
|
|
|
ob_dst->lay = base->lay;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2017-08-08 16:08:24 +02:00
|
|
|
copy_m4_m4(ob_dst->obmat, dob->mat);
|
|
|
|
BKE_object_apply_mat4(ob_dst, ob_dst->obmat, false, false);
|
2011-12-17 00:56:18 +01:00
|
|
|
|
2017-08-08 16:08:24 +02:00
|
|
|
BLI_ghash_insert(dupli_gh, dob, ob_dst);
|
2016-11-04 08:30:22 +01:00
|
|
|
if (parent_gh) {
|
|
|
|
void **val;
|
|
|
|
/* Due to nature of hash/comparison of this ghash, a lot of duplis may be considered as 'the same',
|
|
|
|
* this avoids trying to insert same key several time and raise asserts in debug builds... */
|
|
|
|
if (!BLI_ghash_ensure_p(parent_gh, dob, &val)) {
|
2017-08-08 16:08:24 +02:00
|
|
|
*val = ob_dst;
|
2016-11-04 08:30:22 +01:00
|
|
|
}
|
|
|
|
}
|
2017-08-08 16:01:48 +02:00
|
|
|
}
|
|
|
|
|
2017-08-08 16:08:24 +02:00
|
|
|
for (dob = lb_duplis->first; dob; dob = dob->next) {
|
2017-08-08 16:01:48 +02:00
|
|
|
Object *ob_src = dob->ob;
|
|
|
|
Object *ob_dst = BLI_ghash_lookup(dupli_gh, dob);
|
2014-02-17 18:45:29 +01:00
|
|
|
|
2016-11-30 15:25:54 +01:00
|
|
|
/* Remap new object to itself, and clear again newid pointer of orig object. */
|
2017-08-08 16:01:48 +02:00
|
|
|
BKE_libblock_relink_to_newid(&ob_dst->id);
|
|
|
|
set_sca_new_poins_ob(ob_dst);
|
2016-11-30 15:25:54 +01:00
|
|
|
|
2017-08-08 16:01:48 +02:00
|
|
|
DAG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2017-08-08 16:01:48 +02:00
|
|
|
if (use_hierarchy) {
|
2011-11-07 06:28:26 +01:00
|
|
|
/* original parents */
|
2012-04-28 17:42:27 +02:00
|
|
|
Object *ob_src_par = ob_src->parent;
|
|
|
|
Object *ob_dst_par = NULL;
|
2011-11-07 06:28:26 +01:00
|
|
|
|
2011-12-17 00:56:18 +01:00
|
|
|
/* find parent that was also made real */
|
2012-03-24 07:38:07 +01:00
|
|
|
if (ob_src_par) {
|
2014-12-08 16:13:27 +01:00
|
|
|
/* OK to keep most of the members uninitialized,
|
|
|
|
* they won't be read, this is simply for a hash lookup. */
|
|
|
|
DupliObject dob_key;
|
|
|
|
dob_key.ob = ob_src_par;
|
2016-11-22 17:38:43 +01:00
|
|
|
if (base->object->transflag & OB_DUPLIGROUP) {
|
|
|
|
memcpy(&dob_key.persistent_id[1],
|
2017-08-08 16:01:48 +02:00
|
|
|
&dob->persistent_id[1],
|
|
|
|
sizeof(dob->persistent_id[1]) * (MAX_DUPLI_RECUR - 1));
|
2016-11-22 17:38:43 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
dob_key.persistent_id[0] = dob->persistent_id[0];
|
|
|
|
}
|
2014-12-08 16:13:27 +01:00
|
|
|
ob_dst_par = BLI_ghash_lookup(parent_gh, &dob_key);
|
2011-12-17 00:56:18 +01:00
|
|
|
}
|
2011-11-07 06:28:26 +01:00
|
|
|
|
2011-12-17 00:56:18 +01:00
|
|
|
if (ob_dst_par) {
|
2011-11-07 06:28:26 +01:00
|
|
|
/* allow for all possible parent types */
|
2012-04-28 17:42:27 +02:00
|
|
|
ob_dst->partype = ob_src->partype;
|
2011-11-07 06:28:26 +01:00
|
|
|
BLI_strncpy(ob_dst->parsubstr, ob_src->parsubstr, sizeof(ob_dst->parsubstr));
|
2012-04-28 17:42:27 +02:00
|
|
|
ob_dst->par1 = ob_src->par1;
|
|
|
|
ob_dst->par2 = ob_src->par2;
|
|
|
|
ob_dst->par3 = ob_src->par3;
|
2011-11-07 06:28:26 +01:00
|
|
|
|
|
|
|
copy_m4_m4(ob_dst->parentinv, ob_src->parentinv);
|
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
ob_dst->parent = ob_dst_par;
|
2011-11-07 06:28:26 +01:00
|
|
|
}
|
|
|
|
else if (use_base_parent) {
|
2012-04-28 17:42:27 +02:00
|
|
|
ob_dst->parent = base->object;
|
|
|
|
ob_dst->partype = PAROBJECT;
|
2011-11-07 06:28:26 +01:00
|
|
|
}
|
|
|
|
}
|
2017-08-08 16:01:48 +02:00
|
|
|
else if (use_base_parent) {
|
|
|
|
/* since we are ignoring the internal hierarchy - parent all to the
|
|
|
|
* base object */
|
2012-04-28 17:42:27 +02:00
|
|
|
ob_dst->parent = base->object;
|
|
|
|
ob_dst->partype = PAROBJECT;
|
2017-08-08 16:01:48 +02:00
|
|
|
}
|
2011-11-07 06:28:26 +01:00
|
|
|
|
2017-08-08 16:01:48 +02:00
|
|
|
if (ob_dst->parent) {
|
|
|
|
/* note, this may be the parent of other objects, but it should
|
|
|
|
* still work out ok */
|
2014-04-01 02:34:00 +02:00
|
|
|
BKE_object_apply_mat4(ob_dst, dob->mat, false, true);
|
2017-08-08 16:01:48 +02:00
|
|
|
|
|
|
|
/* to set ob_dst->orig and in case theres any other discrepicies */
|
2011-11-07 06:28:26 +01:00
|
|
|
DAG_id_tag_update(&ob_dst->id, OB_RECALC_OB);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-22 17:19:37 +02:00
|
|
|
if (base->object->transflag & OB_DUPLIGROUP && base->object->dup_group) {
|
2017-08-08 16:08:24 +02:00
|
|
|
for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
|
|
|
|
if (ob->proxy_group == base->object) {
|
|
|
|
ob->proxy = NULL;
|
|
|
|
ob->proxy_from = NULL;
|
|
|
|
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
|
2013-10-22 17:19:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-08 16:01:48 +02:00
|
|
|
BLI_ghash_free(dupli_gh, NULL, NULL);
|
2017-08-08 16:08:24 +02:00
|
|
|
if (parent_gh) {
|
2014-12-08 16:13:27 +01:00
|
|
|
BLI_ghash_free(parent_gh, NULL, NULL);
|
2017-08-08 16:08:24 +02:00
|
|
|
}
|
2011-12-17 00:56:18 +01:00
|
|
|
|
2017-08-08 16:08:24 +02:00
|
|
|
free_object_duplilist(lb_duplis);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2017-08-08 16:01:48 +02:00
|
|
|
BKE_main_id_clear_newpoins(bmain);
|
|
|
|
|
2011-11-07 06:28:26 +01:00
|
|
|
base->object->transflag &= ~OB_DUPLI;
|
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 13:52:56 +02:00
|
|
|
}
|
|
|
|
|
2011-11-07 06:28:26 +01:00
|
|
|
static int object_duplicates_make_real_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 13:52:56 +02:00
|
|
|
{
|
2012-04-28 17:42:27 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2011-11-07 06:28:26 +01:00
|
|
|
|
2014-04-11 03:25:41 +02:00
|
|
|
const bool use_base_parent = RNA_boolean_get(op->ptr, "use_base_parent");
|
|
|
|
const bool use_hierarchy = RNA_boolean_get(op->ptr, "use_hierarchy");
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2013-12-30 03:25:27 +01:00
|
|
|
BKE_main_id_clear_newpoins(bmain);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-04-30 18:22:40 +02:00
|
|
|
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
|
|
|
|
{
|
2011-11-07 06:28:26 +01:00
|
|
|
make_object_duplilist_real(C, scene, base, use_base_parent, use_hierarchy);
|
2010-10-07 14:18:09 +02:00
|
|
|
|
|
|
|
/* dependencies were changed */
|
2012-04-28 17:42:27 +02:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, base->object);
|
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 13:52:56 +02:00
|
|
|
}
|
|
|
|
CTX_DATA_END;
|
|
|
|
|
2013-02-21 20:33:04 +01:00
|
|
|
DAG_relations_tag_update(bmain);
|
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 13:52:56 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE, scene);
|
2012-04-28 17:42:27 +02:00
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_duplicates_make_real(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->name = "Make Duplicates Real";
|
2010-02-10 22:15:44 +01:00
|
|
|
ot->description = "Make dupli objects attached to this object real";
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->idname = "OBJECT_OT_duplicates_make_real";
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* api callbacks */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->exec = object_duplicates_make_real_exec;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->poll = ED_operator_objectmode;
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* flags */
|
2012-04-28 17:42:27 +02:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2011-11-07 06:28:26 +01:00
|
|
|
|
|
|
|
RNA_def_boolean(ot->srna, "use_base_parent", 0, "Parent", "Parent newly created objects to the original duplicator");
|
|
|
|
RNA_def_boolean(ot->srna, "use_hierarchy", 0, "Keep Hierarchy", "Maintain parent child relationships");
|
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 13:52:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************** Convert **************************/
|
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
static EnumPropertyItem convert_target_items[] = {
|
2009-10-10 12:49:17 +02:00
|
|
|
{OB_CURVE, "CURVE", ICON_OUTLINER_OB_CURVE, "Curve from Mesh/Text", ""},
|
2010-06-04 18:21:04 +02:00
|
|
|
{OB_MESH, "MESH", ICON_OUTLINER_OB_MESH, "Mesh from Curve/Meta/Surf/Text", ""},
|
2012-04-28 17:42:27 +02: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 13:52:56 +02:00
|
|
|
|
2014-03-12 08:59:45 +01:00
|
|
|
static void convert_ensure_curve_cache(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 13:52:56 +02:00
|
|
|
{
|
2014-03-12 08:59:45 +01:00
|
|
|
if (ob->curve_cache == NULL) {
|
|
|
|
/* Force creation. This is normally not needed but on operator
|
|
|
|
* redo we might end up with an object which isn't evaluated yet.
|
|
|
|
*/
|
2014-07-19 17:30:29 +02:00
|
|
|
if (ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) {
|
2014-04-01 02:34:00 +02:00
|
|
|
BKE_displist_make_curveTypes(scene, ob, false);
|
2014-03-12 08:59:45 +01:00
|
|
|
}
|
|
|
|
else if (ob->type == OB_MBALL) {
|
|
|
|
BKE_displist_make_mball(bmain->eval_ctx, scene, 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 13:52:56 +02:00
|
|
|
|
2014-03-12 08:59:45 +01:00
|
|
|
static void curvetomesh(Main *bmain, Scene *scene, Object *ob)
|
|
|
|
{
|
|
|
|
convert_ensure_curve_cache(bmain, scene, ob);
|
2012-05-05 23:28:12 +02:00
|
|
|
BKE_mesh_from_nurbs(ob); /* also does users */
|
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 13:52:56 +02:00
|
|
|
|
2014-03-30 22:55:10 +02:00
|
|
|
if (ob->type == OB_MESH) {
|
2012-05-05 16:03:12 +02:00
|
|
|
BKE_object_free_modifiers(ob);
|
2014-03-30 22:55:10 +02:00
|
|
|
|
|
|
|
/* Game engine defaults for mesh objects */
|
|
|
|
ob->body_type = OB_BODY_TYPE_STATIC;
|
|
|
|
ob->gameflag = OB_PROP | OB_COLLISION;
|
|
|
|
}
|
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 13:52:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int convert_poll(bContext *C)
|
|
|
|
{
|
2012-04-28 17:42:27 +02:00
|
|
|
Object *obact = CTX_data_active_object(C);
|
|
|
|
Scene *scene = CTX_data_scene(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 13:52:56 +02:00
|
|
|
|
2016-07-06 14:11:01 +02:00
|
|
|
return (!ID_IS_LINKED_DATABLOCK(scene) && obact && scene->obedit != obact &&
|
|
|
|
(obact->flag & SELECT) && !ID_IS_LINKED_DATABLOCK(obact));
|
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 13:52:56 +02:00
|
|
|
}
|
|
|
|
|
2010-03-07 06:04:22 +01:00
|
|
|
/* Helper for convert_exec */
|
2016-07-10 14:52:00 +02:00
|
|
|
static Base *duplibase_for_convert(Main *bmain, Scene *scene, Base *base, Object *ob)
|
2010-03-07 06:04:22 +01:00
|
|
|
{
|
|
|
|
Object *obn;
|
|
|
|
Base *basen;
|
|
|
|
|
|
|
|
if (ob == NULL) {
|
2012-04-28 17:42:27 +02:00
|
|
|
ob = base->object;
|
2010-03-07 06:04:22 +01:00
|
|
|
}
|
|
|
|
|
2016-07-10 14:52:00 +02:00
|
|
|
obn = BKE_object_copy(bmain, ob);
|
2013-02-21 20:33:04 +01:00
|
|
|
DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
|
2010-03-07 06:04:22 +01:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
basen = MEM_mallocN(sizeof(Base), "duplibase");
|
|
|
|
*basen = *base;
|
|
|
|
BLI_addhead(&scene->base, basen); /* addhead: otherwise eternal loop */
|
|
|
|
basen->object = obn;
|
2010-03-07 06:04:22 +01:00
|
|
|
basen->flag |= SELECT;
|
|
|
|
obn->flag |= SELECT;
|
|
|
|
base->flag &= ~SELECT;
|
|
|
|
ob->flag &= ~SELECT;
|
|
|
|
|
|
|
|
return basen;
|
|
|
|
}
|
|
|
|
|
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 13:52:56 +02:00
|
|
|
static int convert_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-04-28 17:42:27 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2013-07-27 11:20:10 +02:00
|
|
|
Base *basen = NULL, *basact = NULL;
|
2012-04-28 17:42:27 +02:00
|
|
|
Object *ob, *ob1, *newob, *obact = CTX_data_active_object(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 13:52:56 +02:00
|
|
|
DerivedMesh *dm;
|
|
|
|
Curve *cu;
|
|
|
|
Nurb *nu;
|
|
|
|
MetaBall *mb;
|
|
|
|
Mesh *me;
|
2012-04-28 17:42:27 +02:00
|
|
|
const short target = RNA_enum_get(op->ptr, "target");
|
2017-06-15 15:40:24 +02:00
|
|
|
bool keep_original = RNA_boolean_get(op->ptr, "keep_original");
|
2012-04-28 17:42:27 +02:00
|
|
|
int a, mballConverted = 0;
|
2010-03-08 15:35:38 +01: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 13:52:56 +02:00
|
|
|
/* don't forget multiple users! */
|
|
|
|
|
2012-04-30 18:22:40 +02:00
|
|
|
{
|
2015-03-06 12:44:56 +01:00
|
|
|
Base *base;
|
2010-12-20 08:21:08 +01:00
|
|
|
|
2015-03-06 12:44:56 +01:00
|
|
|
for (base = scene->base.first; base; base = base->next) {
|
|
|
|
ob = base->object;
|
|
|
|
ob->flag &= ~OB_DONE;
|
|
|
|
|
|
|
|
/* flag data thats not been edited (only needed for !keep_original) */
|
|
|
|
if (ob->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 *)ob->data)->tag |= LIB_TAG_DOIT;
|
2015-03-06 12:44:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* possible metaball basis is not in this scene */
|
|
|
|
if (ob->type == OB_MBALL && target == OB_MESH) {
|
|
|
|
if (BKE_mball_is_basis(ob) == false) {
|
|
|
|
Object *ob_basis;
|
|
|
|
ob_basis = BKE_mball_basis_find(scene, ob);
|
|
|
|
if (ob_basis) {
|
|
|
|
ob_basis->flag &= ~OB_DONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-12-20 08:21:08 +01: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 13:52:56 +02:00
|
|
|
}
|
|
|
|
|
2017-03-16 23:58:05 +01:00
|
|
|
ListBase selected_editable_bases = CTX_data_collection_get(C, "selected_editable_bases");
|
|
|
|
|
|
|
|
/* Ensure we get all meshes calculated with a sufficient data-mask,
|
|
|
|
* needed since re-evaluating single modifiers causes bugs if they depend
|
|
|
|
* on other objects data masks too, see: T50950. */
|
2012-04-30 18:22:40 +02:00
|
|
|
{
|
2017-03-16 23:58:05 +01:00
|
|
|
for (CollectionPointerLink *link = selected_editable_bases.first; link; link = link->next) {
|
|
|
|
Base *base = link->ptr.data;
|
2017-06-15 15:40:24 +02:00
|
|
|
ob = base->object;
|
|
|
|
|
|
|
|
/* The way object type conversion works currently (enforcing conversion of *all* objetcs using converted
|
|
|
|
* obdata, even some un-selected/hidden/inother scene ones, sounds totally bad to me.
|
|
|
|
* However, changing this is more design than bugfix, not to mention convoluted code below,
|
|
|
|
* so that will be for later.
|
|
|
|
* But at the very least, do not do that with linked IDs! */
|
2017-07-21 10:24:20 +02:00
|
|
|
if ((ID_IS_LINKED_DATABLOCK(ob) || (ob->data && ID_IS_LINKED_DATABLOCK(ob->data))) && !keep_original) {
|
2017-06-15 15:40:24 +02:00
|
|
|
keep_original = true;
|
|
|
|
BKE_reportf(op->reports, RPT_INFO,
|
|
|
|
"Converting some linked object/object data, enforcing 'Keep Original' option to True");
|
|
|
|
}
|
|
|
|
|
2017-03-16 23:58:05 +01:00
|
|
|
DAG_id_tag_update(&base->object->id, OB_RECALC_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t customdata_mask_prev = scene->customdata_mask;
|
|
|
|
scene->customdata_mask |= CD_MASK_MESH;
|
|
|
|
BKE_scene_update_tagged(bmain->eval_ctx, bmain, scene);
|
|
|
|
scene->customdata_mask = customdata_mask_prev;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (CollectionPointerLink *link = selected_editable_bases.first; link; link = link->next) {
|
|
|
|
Base *base = link->ptr.data;
|
2012-04-28 17:42:27 +02:00
|
|
|
ob = base->object;
|
2010-03-07 06:04:22 +01:00
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (ob->flag & OB_DONE || !IS_TAGGED(ob->data)) {
|
2010-03-07 06:04:22 +01:00
|
|
|
if (ob->type != target) {
|
|
|
|
base->flag &= ~SELECT;
|
|
|
|
ob->flag &= ~SELECT;
|
|
|
|
}
|
2011-02-10 05:48:49 +01:00
|
|
|
|
|
|
|
/* obdata already modified */
|
2012-03-24 07:38:07 +01:00
|
|
|
if (!IS_TAGGED(ob->data)) {
|
2011-02-10 05:48:49 +01:00
|
|
|
/* When 2 objects with linked data are selected, converting both
|
|
|
|
* would keep modifiers on all but the converted object [#26003] */
|
2012-03-24 07:38:07 +01:00
|
|
|
if (ob->type == OB_MESH) {
|
2012-05-05 16:03:12 +02:00
|
|
|
BKE_object_free_modifiers(ob); /* after derivedmesh calls! */
|
2011-02-10 05:48:49 +01:00
|
|
|
}
|
|
|
|
}
|
2010-03-07 06:04:22 +01:00
|
|
|
}
|
2012-04-28 17:42:27 +02:00
|
|
|
else if (ob->type == OB_MESH && target == OB_CURVE) {
|
2009-10-10 00:09:48 +02:00
|
|
|
ob->flag |= OB_DONE;
|
2009-10-10 12:49:17 +02:00
|
|
|
|
2010-03-07 06:04:22 +01:00
|
|
|
if (keep_original) {
|
2016-07-10 14:52:00 +02:00
|
|
|
basen = duplibase_for_convert(bmain, scene, base, NULL);
|
2012-04-28 17:42:27 +02:00
|
|
|
newob = basen->object;
|
2009-10-10 12:49:17 +02:00
|
|
|
|
2010-03-07 06:04:22 +01:00
|
|
|
/* decrement original mesh's usage count */
|
2012-04-28 17:42:27 +02:00
|
|
|
me = newob->data;
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(&me->id);
|
2009-10-10 12:49:17 +02:00
|
|
|
|
2010-03-07 06:04:22 +01:00
|
|
|
/* make a new copy of the mesh */
|
2016-07-10 14:52:00 +02:00
|
|
|
newob->data = BKE_mesh_copy(bmain, me);
|
2012-03-24 07:38:07 +01:00
|
|
|
}
|
|
|
|
else {
|
2010-03-07 06:04:22 +01:00
|
|
|
newob = ob;
|
|
|
|
}
|
|
|
|
|
2013-03-14 19:35:21 +01:00
|
|
|
BKE_mesh_to_curve(scene, newob);
|
2009-10-10 12:49:17 +02:00
|
|
|
|
2013-04-09 03:43:39 +02:00
|
|
|
if (newob->type == OB_CURVE) {
|
2012-05-05 16:03:12 +02:00
|
|
|
BKE_object_free_modifiers(newob); /* after derivedmesh calls! */
|
2016-06-06 14:37:15 +02:00
|
|
|
ED_rigidbody_object_remove(bmain, scene, newob);
|
2013-04-09 03:43:39 +02:00
|
|
|
}
|
2009-10-10 00:09:48 +02:00
|
|
|
}
|
2017-03-17 00:10:55 +01:00
|
|
|
else if (ob->type == OB_MESH) {
|
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 13:52:56 +02:00
|
|
|
ob->flag |= OB_DONE;
|
|
|
|
|
2010-03-07 06:04:22 +01:00
|
|
|
if (keep_original) {
|
2016-07-10 14:52:00 +02:00
|
|
|
basen = duplibase_for_convert(bmain, scene, base, NULL);
|
2012-04-28 17:42:27 +02:00
|
|
|
newob = basen->object;
|
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 13:52:56 +02:00
|
|
|
|
2010-03-07 06:04:22 +01:00
|
|
|
/* decrement original mesh's usage count */
|
2012-04-28 17:42:27 +02:00
|
|
|
me = newob->data;
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(&me->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 13:52:56 +02:00
|
|
|
|
2010-03-07 06:04:22 +01:00
|
|
|
/* make a new copy of the mesh */
|
2016-07-10 14:52:00 +02:00
|
|
|
newob->data = BKE_mesh_copy(bmain, me);
|
2012-03-24 07:38:07 +01:00
|
|
|
}
|
|
|
|
else {
|
2010-03-07 06:04:22 +01:00
|
|
|
newob = ob;
|
2013-02-21 20:33:04 +01:00
|
|
|
DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
|
2010-03-07 06:04:22 +01: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 13:52:56 +02:00
|
|
|
|
|
|
|
/* make new mesh data from the original copy */
|
2010-03-02 16:33:33 +01:00
|
|
|
/* note: get the mesh from the original, not from the copy in some
|
|
|
|
* cases this doesnt give correct results (when MDEF is used for eg)
|
|
|
|
*/
|
2012-04-28 17:42:27 +02:00
|
|
|
dm = mesh_get_derived_final(scene, newob, CD_MASK_MESH);
|
2009-10-10 00:09:48 +02:00
|
|
|
|
2015-02-18 20:00:23 +01:00
|
|
|
DM_to_mesh(dm, newob->data, newob, CD_MASK_MESH, 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 13:52:56 +02:00
|
|
|
|
2012-03-02 17:05:54 +01:00
|
|
|
/* re-tessellation is called by DM_to_mesh */
|
2011-10-18 13:28:39 +02:00
|
|
|
|
2012-05-05 16:03:12 +02:00
|
|
|
BKE_object_free_modifiers(newob); /* after derivedmesh calls! */
|
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 13:52:56 +02:00
|
|
|
}
|
2012-04-28 17:42:27 +02: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 13:52:56 +02:00
|
|
|
ob->flag |= OB_DONE;
|
|
|
|
|
2010-03-07 06:04:22 +01:00
|
|
|
if (keep_original) {
|
2016-07-10 14:52:00 +02:00
|
|
|
basen = duplibase_for_convert(bmain, scene, base, NULL);
|
2012-04-28 17:42:27 +02:00
|
|
|
newob = basen->object;
|
2010-03-07 06:04:22 +01:00
|
|
|
|
|
|
|
/* decrement original curve's usage count */
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(&((Curve *)newob->data)->id);
|
2010-03-07 06:04:22 +01:00
|
|
|
|
|
|
|
/* make a new copy of the curve */
|
2016-07-10 14:52:00 +02:00
|
|
|
newob->data = BKE_curve_copy(bmain, ob->data);
|
2012-03-24 07:38:07 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-04-28 17:42:27 +02:00
|
|
|
newob = ob;
|
2010-03-07 06:04:22 +01:00
|
|
|
}
|
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
cu = newob->data;
|
2010-03-07 06:04:22 +01:00
|
|
|
|
2014-01-09 18:34:52 +01:00
|
|
|
/* TODO(sergey): Ideally DAG will create nurbs list for a curve data
|
|
|
|
* datablock, but for until we've got granular update
|
|
|
|
* lets take care by selves.
|
|
|
|
*/
|
2014-01-09 19:03:49 +01:00
|
|
|
BKE_vfont_to_curve(bmain, newob, FO_EDIT);
|
2010-03-07 06:04:22 +01:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
newob->type = OB_CURVE;
|
|
|
|
cu->type = OB_CURVE;
|
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 13:52:56 +02:00
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (cu->vfont) {
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(&cu->vfont->id);
|
2012-04-28 17:42:27 +02:00
|
|
|
cu->vfont = 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 13:52:56 +02:00
|
|
|
}
|
2012-03-24 07:38:07 +01:00
|
|
|
if (cu->vfontb) {
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(&cu->vfontb->id);
|
2012-04-28 17:42:27 +02:00
|
|
|
cu->vfontb = 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 13:52:56 +02:00
|
|
|
}
|
2012-03-24 07:38:07 +01:00
|
|
|
if (cu->vfonti) {
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(&cu->vfonti->id);
|
2012-04-28 17:42:27 +02:00
|
|
|
cu->vfonti = 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 13:52:56 +02:00
|
|
|
}
|
2012-03-24 07:38:07 +01:00
|
|
|
if (cu->vfontbi) {
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(&cu->vfontbi->id);
|
2012-04-28 17:42:27 +02:00
|
|
|
cu->vfontbi = NULL;
|
2010-03-07 06:04:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!keep_original) {
|
|
|
|
/* other users */
|
2012-04-28 17:42:27 +02:00
|
|
|
if (cu->id.us > 1) {
|
|
|
|
for (ob1 = bmain->object.first; ob1; ob1 = ob1->id.next) {
|
|
|
|
if (ob1->data == ob->data) {
|
|
|
|
ob1->type = OB_CURVE;
|
2013-02-21 20:33:04 +01:00
|
|
|
DAG_id_tag_update(&ob1->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
|
2010-03-07 06:04:22 +01: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 13:52:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
for (nu = cu->nurb.first; nu; nu = nu->next)
|
|
|
|
nu->charidx = 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 13:52:56 +02:00
|
|
|
|
2013-11-06 02:45:15 +01:00
|
|
|
cu->flag &= ~CU_3D;
|
|
|
|
BKE_curve_curve_dimension_update(cu);
|
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (target == OB_MESH) {
|
2014-03-12 08:59:45 +01:00
|
|
|
curvetomesh(bmain, scene, newob);
|
2011-01-05 11:40:38 +01:00
|
|
|
|
|
|
|
/* meshes doesn't use displist */
|
2013-08-19 11:25:24 +02:00
|
|
|
BKE_object_free_curve_cache(newob);
|
2011-01-05 11:40:38 +01: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 13:52:56 +02:00
|
|
|
}
|
2012-03-24 07:38:07 +01:00
|
|
|
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
|
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 13:52:56 +02:00
|
|
|
ob->flag |= OB_DONE;
|
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (target == OB_MESH) {
|
2010-03-07 06:04:22 +01:00
|
|
|
if (keep_original) {
|
2016-07-10 14:52:00 +02:00
|
|
|
basen = duplibase_for_convert(bmain, scene, base, NULL);
|
2012-04-28 17:42:27 +02:00
|
|
|
newob = basen->object;
|
2010-03-07 06:04:22 +01:00
|
|
|
|
|
|
|
/* decrement original curve's usage count */
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(&((Curve *)newob->data)->id);
|
2010-03-07 06:04:22 +01:00
|
|
|
|
|
|
|
/* make a new copy of the curve */
|
2016-07-10 14:52:00 +02:00
|
|
|
newob->data = BKE_curve_copy(bmain, ob->data);
|
2012-03-24 07:38:07 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-04-28 17:42:27 +02:00
|
|
|
newob = ob;
|
2010-03-07 06:04:22 +01:00
|
|
|
}
|
|
|
|
|
2014-03-12 08:59:45 +01:00
|
|
|
curvetomesh(bmain, scene, newob);
|
2014-01-09 18:11:50 +01:00
|
|
|
|
|
|
|
/* meshes doesn't use displist */
|
|
|
|
BKE_object_free_curve_cache(newob);
|
2010-03-07 06:04:22 +01: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 13:52:56 +02:00
|
|
|
}
|
2012-04-28 17:42:27 +02:00
|
|
|
else if (ob->type == OB_MBALL && target == OB_MESH) {
|
2010-03-07 06:04:22 +01:00
|
|
|
Object *baseob;
|
|
|
|
|
|
|
|
base->flag &= ~SELECT;
|
|
|
|
ob->flag &= ~SELECT;
|
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 13:52:56 +02:00
|
|
|
|
2012-05-07 08:38:41 +02:00
|
|
|
baseob = BKE_mball_basis_find(scene, ob);
|
2010-03-07 06:04:22 +01:00
|
|
|
|
|
|
|
if (ob != baseob) {
|
|
|
|
/* if motherball is converting it would be marked as done later */
|
|
|
|
ob->flag |= OB_DONE;
|
|
|
|
}
|
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (!(baseob->flag & OB_DONE)) {
|
2010-03-07 06:04:22 +01:00
|
|
|
baseob->flag |= OB_DONE;
|
|
|
|
|
2016-07-10 14:52:00 +02:00
|
|
|
basen = duplibase_for_convert(bmain, scene, base, baseob);
|
2012-04-28 17:42:27 +02:00
|
|
|
newob = basen->object;
|
2010-03-07 06:04:22 +01:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
mb = newob->data;
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(&mb->id);
|
2010-03-07 06:04:22 +01:00
|
|
|
|
2013-02-05 13:46:15 +01:00
|
|
|
newob->data = BKE_mesh_add(bmain, "Mesh");
|
2012-04-28 17:42:27 +02:00
|
|
|
newob->type = OB_MESH;
|
2010-03-07 06:04:22 +01:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
me = newob->data;
|
|
|
|
me->totcol = mb->totcol;
|
2012-03-24 07:38:07 +01:00
|
|
|
if (newob->totcol) {
|
2012-04-28 17:42:27 +02:00
|
|
|
me->mat = MEM_dupallocN(mb->mat);
|
|
|
|
for (a = 0; a < newob->totcol; a++) id_us_plus((ID *)me->mat[a]);
|
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 13:52:56 +02:00
|
|
|
}
|
2010-03-07 06:04:22 +01:00
|
|
|
|
2014-03-12 08:59:45 +01:00
|
|
|
convert_ensure_curve_cache(bmain, scene, baseob);
|
2013-08-19 11:25:24 +02:00
|
|
|
BKE_mesh_from_metaball(&baseob->curve_cache->disp, newob->data);
|
2010-03-07 06:04:22 +01:00
|
|
|
|
|
|
|
if (obact->type == OB_MBALL) {
|
2012-04-28 17:42:27 +02:00
|
|
|
basact = basen;
|
2010-03-07 06:04:22 +01:00
|
|
|
}
|
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
mballConverted = 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 13:52:56 +02:00
|
|
|
}
|
|
|
|
}
|
2010-12-20 08:21:08 +01: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 13:52:56 +02:00
|
|
|
continue;
|
2010-12-20 08:21:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tag obdata if it was been 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 13:52:56 +02:00
|
|
|
|
|
|
|
/* If the original object is active then make this object active */
|
2012-03-24 07:38:07 +01:00
|
|
|
if (basen) {
|
|
|
|
if (ob == obact) {
|
2010-03-03 19:49:26 +01:00
|
|
|
/* store new active base to update BASACT */
|
2012-04-28 17:42:27 +02:00
|
|
|
basact = basen;
|
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 13:52:56 +02:00
|
|
|
}
|
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
basen = 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 13:52:56 +02:00
|
|
|
}
|
|
|
|
|
2010-12-20 08:21:08 +01:00
|
|
|
if (!keep_original && (ob->flag & OB_DONE)) {
|
2010-12-05 19:59:23 +01:00
|
|
|
DAG_id_tag_update(&ob->id, OB_RECALC_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 *)ob->data)->tag &= ~LIB_TAG_DOIT; /* flag not to convert this datablock again */
|
2010-03-30 20:10:05 +02: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 13:52:56 +02:00
|
|
|
}
|
2017-03-16 23:58:05 +01:00
|
|
|
BLI_freelistN(&selected_editable_bases);
|
2010-03-07 06:04:22 +01:00
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (!keep_original) {
|
2010-03-07 06:04:22 +01:00
|
|
|
if (mballConverted) {
|
2015-03-06 12:44:56 +01:00
|
|
|
Base *base, *base_next;
|
|
|
|
|
|
|
|
for (base = scene->base.first; base; base = base_next) {
|
|
|
|
base_next = base->next;
|
2010-03-07 06:04:22 +01:00
|
|
|
|
2015-03-06 12:44:56 +01:00
|
|
|
ob = base->object;
|
2010-03-07 06:04:22 +01:00
|
|
|
if (ob->type == OB_MBALL) {
|
2015-03-06 12:44:56 +01:00
|
|
|
if (ob->flag & OB_DONE) {
|
|
|
|
Object *ob_basis = NULL;
|
|
|
|
if (BKE_mball_is_basis(ob) ||
|
|
|
|
((ob_basis = BKE_mball_basis_find(scene, ob)) && (ob_basis->flag & OB_DONE)))
|
|
|
|
{
|
|
|
|
ED_base_object_free_and_unlink(bmain, scene, base);
|
|
|
|
}
|
|
|
|
}
|
2010-03-07 06:04:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* delete object should renew depsgraph */
|
2013-02-21 20:33:04 +01:00
|
|
|
DAG_relations_tag_update(bmain);
|
2010-03-07 06:04:22 +01: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 13:52:56 +02:00
|
|
|
|
2013-03-21 15:18:17 +01:00
|
|
|
// XXX ED_object_editmode_enter(C, 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 13:52:56 +02:00
|
|
|
// XXX exit_editmode(C, EM_FREEDATA|EM_WAITCURSOR); /* freedata, but no undo */
|
2010-03-03 19:49:26 +01:00
|
|
|
|
|
|
|
if (basact) {
|
|
|
|
/* active base was changed */
|
2010-03-07 06:04:22 +01:00
|
|
|
ED_base_object_activate(C, basact);
|
2012-04-28 17:42:27 +02:00
|
|
|
BASACT = basact;
|
2012-03-24 07:38:07 +01:00
|
|
|
}
|
|
|
|
else if (BASACT->object->flag & OB_DONE) {
|
2012-04-28 17:42:27 +02:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, BASACT->object);
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_DATA, BASACT->object);
|
2010-03-03 19:49:26 +01: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 13:52:56 +02:00
|
|
|
|
2013-02-21 20:33:04 +01:00
|
|
|
DAG_relations_tag_update(bmain);
|
2012-04-28 17:42:27 +02:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, scene);
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
|
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 13:52:56 +02:00
|
|
|
|
2009-10-10 12:49:17 +02:00
|
|
|
return OPERATOR_FINISHED;
|
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 13:52:56 +02:00
|
|
|
}
|
|
|
|
|
2009-10-10 12:49:17 +02: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 13:52:56 +02:00
|
|
|
void OBJECT_OT_convert(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->name = "Convert to";
|
2010-02-10 22:15:44 +01:00
|
|
|
ot->description = "Convert selected objects to another type";
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->idname = "OBJECT_OT_convert";
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* api callbacks */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
ot->exec = convert_exec;
|
|
|
|
ot->poll = convert_poll;
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* flags */
|
2012-04-28 17:42:27 +02: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 13:52:56 +02:00
|
|
|
|
|
|
|
/* properties */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->prop = RNA_def_enum(ot->srna, "target", convert_target_items, OB_MESH, "Target", "Type of object to convert to");
|
2011-06-05 01:02:44 +02:00
|
|
|
RNA_def_boolean(ot->srna, "keep_original", 0, "Keep Original", "Keep original objects instead of replacing them");
|
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 13:52:56 +02:00
|
|
|
}
|
|
|
|
|
2009-09-10 16:20:21 +02:00
|
|
|
/**************************** Duplicate ************************/
|
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 13:52:56 +02:00
|
|
|
|
|
|
|
/*
|
2012-03-03 17:31:46 +01:00
|
|
|
* dupflag: a flag made from constants declared in DNA_userdef_types.h
|
2013-06-26 00:58:23 +02:00
|
|
|
* The flag tells adduplicate() whether to copy data linked to the object, or to reference the existing data.
|
2012-03-03 17:31:46 +01:00
|
|
|
* U.dupflag for default operations or you can construct a flag as python does
|
|
|
|
* if the dupflag is 0 then no data will be copied (linked duplicate) */
|
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 13:52:56 +02:00
|
|
|
|
|
|
|
/* used below, assumes id.new is correct */
|
|
|
|
/* leaves selection of base/object unaltered */
|
2016-11-30 15:25:54 +01:00
|
|
|
/* Does set ID->newid pointers. */
|
2010-08-01 14:47:49 +02:00
|
|
|
static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base, int dupflag)
|
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 13:52:56 +02:00
|
|
|
{
|
2016-11-30 15:25:54 +01:00
|
|
|
#define ID_NEW_REMAP_US(a) if ( (a)->id.newid) { (a) = (void *)(a)->id.newid; (a)->id.us++; }
|
|
|
|
#define ID_NEW_REMAP_US2(a) if (((ID *)a)->newid) { (a) = ((ID *)a)->newid; ((ID *)a)->us++; }
|
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
Base *basen = 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 13:52:56 +02:00
|
|
|
Material ***matarar;
|
|
|
|
Object *ob, *obn;
|
|
|
|
ID *id;
|
|
|
|
int a, didit;
|
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
ob = base->object;
|
2012-03-24 07:38:07 +01:00
|
|
|
if (ob->mode & OB_MODE_POSE) {
|
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 13:52:56 +02:00
|
|
|
; /* nothing? */
|
|
|
|
}
|
|
|
|
else {
|
2016-11-30 15:25:54 +01:00
|
|
|
obn = ID_NEW_SET(ob, BKE_object_copy(bmain, ob));
|
2013-02-21 20:33:04 +01:00
|
|
|
DAG_id_tag_update(&obn->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
basen = MEM_mallocN(sizeof(Base), "duplibase");
|
|
|
|
*basen = *base;
|
|
|
|
BLI_addhead(&scene->base, basen); /* addhead: prevent eternal loop */
|
|
|
|
basen->object = obn;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2013-01-23 06:56:44 +01:00
|
|
|
/* 1) duplis should end up in same group as the original
|
|
|
|
* 2) Rigid Body sim participants MUST always be part of a group...
|
|
|
|
*/
|
|
|
|
// XXX: is 2) really a good measure here?
|
2013-01-23 06:56:56 +01:00
|
|
|
if ((basen->flag & OB_FROMGROUP) || ob->rigidbody_object || ob->rigidbody_constraint) {
|
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 13:52:56 +02:00
|
|
|
Group *group;
|
2012-04-28 17:42:27 +02:00
|
|
|
for (group = bmain->group.first; group; group = group->id.next) {
|
2013-04-03 13:28:42 +02:00
|
|
|
if (BKE_group_object_exists(group, ob))
|
|
|
|
BKE_group_object_add(group, obn, scene, basen);
|
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 13:52:56 +02:00
|
|
|
}
|
|
|
|
}
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* duplicates using userflags */
|
2012-03-24 07:38:07 +01:00
|
|
|
if (dupflag & USER_DUP_ACT) {
|
2016-11-30 15:25:54 +01:00
|
|
|
BKE_animdata_copy_id_action(&obn->id, true);
|
2010-11-09 10:53:17 +01:00
|
|
|
}
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (dupflag & USER_DUP_MAT) {
|
2012-04-28 17:42:27 +02:00
|
|
|
for (a = 0; a < obn->totcol; a++) {
|
|
|
|
id = (ID *)obn->mat[a];
|
2012-03-24 07:38:07 +01:00
|
|
|
if (id) {
|
2016-11-30 15:25:54 +01:00
|
|
|
ID_NEW_REMAP_US(obn->mat[a])
|
|
|
|
else {
|
|
|
|
obn->mat[a] = ID_NEW_SET(obn->mat[a], BKE_material_copy(bmain, obn->mat[a]));
|
|
|
|
}
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(id);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (dupflag & USER_DUP_ACT) {
|
2016-11-30 15:25:54 +01:00
|
|
|
BKE_animdata_copy_id_action(&obn->mat[a]->id, true);
|
2010-11-09 10:53:17 +01: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 13:52:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-24 07:38:07 +01:00
|
|
|
if (dupflag & USER_DUP_PSYS) {
|
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 13:52:56 +02:00
|
|
|
ParticleSystem *psys;
|
2012-04-28 17:42:27 +02:00
|
|
|
for (psys = obn->particlesystem.first; psys; psys = psys->next) {
|
|
|
|
id = (ID *) psys->part;
|
2012-03-24 07:38:07 +01:00
|
|
|
if (id) {
|
2016-11-30 15:25:54 +01:00
|
|
|
ID_NEW_REMAP_US(psys->part)
|
|
|
|
else {
|
|
|
|
psys->part = ID_NEW_SET(psys->part, BKE_particlesettings_copy(bmain, psys->part));
|
|
|
|
}
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (dupflag & USER_DUP_ACT) {
|
2016-11-30 15:25:54 +01:00
|
|
|
BKE_animdata_copy_id_action(&psys->part->id, true);
|
2010-11-09 10:53:17 +01:00
|
|
|
}
|
|
|
|
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(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 13:52:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
id = obn->data;
|
|
|
|
didit = 0;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-04-28 08:31:57 +02:00
|
|
|
switch (obn->type) {
|
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 13:52:56 +02:00
|
|
|
case OB_MESH:
|
2012-03-24 07:38:07 +01:00
|
|
|
if (dupflag & USER_DUP_MESH) {
|
2016-11-30 15:25:54 +01:00
|
|
|
ID_NEW_REMAP_US2(obn->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 13:52:56 +02:00
|
|
|
else {
|
2016-11-30 15:25:54 +01:00
|
|
|
obn->data = ID_NEW_SET(obn->data, BKE_mesh_copy(bmain, obn->data));
|
2012-04-28 17:42:27 +02:00
|
|
|
didit = 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 13:52:56 +02:00
|
|
|
}
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(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 13:52:56 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OB_CURVE:
|
2012-03-24 07:38:07 +01:00
|
|
|
if (dupflag & USER_DUP_CURVE) {
|
2016-11-30 15:25:54 +01:00
|
|
|
ID_NEW_REMAP_US2(obn->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 13:52:56 +02:00
|
|
|
else {
|
2016-11-30 15:25:54 +01:00
|
|
|
obn->data = ID_NEW_SET(obn->data, BKE_curve_copy(bmain, obn->data));
|
2012-04-28 17:42:27 +02:00
|
|
|
didit = 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 13:52:56 +02:00
|
|
|
}
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(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 13:52:56 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OB_SURF:
|
2012-03-24 07:38:07 +01:00
|
|
|
if (dupflag & USER_DUP_SURF) {
|
2016-11-30 15:25:54 +01:00
|
|
|
ID_NEW_REMAP_US2(obn->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 13:52:56 +02:00
|
|
|
else {
|
2016-11-30 15:25:54 +01:00
|
|
|
obn->data = ID_NEW_SET(obn->data, BKE_curve_copy(bmain, obn->data));
|
2012-04-28 17:42:27 +02:00
|
|
|
didit = 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 13:52:56 +02:00
|
|
|
}
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(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 13:52:56 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OB_FONT:
|
2012-03-24 07:38:07 +01:00
|
|
|
if (dupflag & USER_DUP_FONT) {
|
2016-11-30 15:25:54 +01:00
|
|
|
ID_NEW_REMAP_US2(obn->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 13:52:56 +02:00
|
|
|
else {
|
2016-11-30 15:25:54 +01:00
|
|
|
obn->data = ID_NEW_SET(obn->data, BKE_curve_copy(bmain, obn->data));
|
2012-04-28 17:42:27 +02:00
|
|
|
didit = 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 13:52:56 +02:00
|
|
|
}
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(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 13:52:56 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OB_MBALL:
|
2012-03-24 07:38:07 +01:00
|
|
|
if (dupflag & USER_DUP_MBALL) {
|
2016-11-30 15:25:54 +01:00
|
|
|
ID_NEW_REMAP_US2(obn->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 13:52:56 +02:00
|
|
|
else {
|
2016-11-30 15:25:54 +01:00
|
|
|
obn->data = ID_NEW_SET(obn->data, BKE_mball_copy(bmain, obn->data));
|
2012-04-28 17:42:27 +02:00
|
|
|
didit = 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 13:52:56 +02:00
|
|
|
}
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(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 13:52:56 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OB_LAMP:
|
2012-03-24 07:38:07 +01:00
|
|
|
if (dupflag & USER_DUP_LAMP) {
|
2016-11-30 15:25:54 +01:00
|
|
|
ID_NEW_REMAP_US2(obn->data)
|
2010-11-09 10:53:17 +01:00
|
|
|
else {
|
2016-11-30 15:25:54 +01:00
|
|
|
obn->data = ID_NEW_SET(obn->data, BKE_lamp_copy(bmain, obn->data));
|
2012-04-28 17:42:27 +02:00
|
|
|
didit = 1;
|
2010-11-09 10:53:17 +01:00
|
|
|
}
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(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 13:52:56 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OB_ARMATURE:
|
2013-02-21 20:33:04 +01:00
|
|
|
DAG_id_tag_update(&obn->id, OB_RECALC_DATA);
|
2012-10-05 09:05:52 +02:00
|
|
|
if (obn->pose)
|
2015-05-12 10:13:36 +02:00
|
|
|
BKE_pose_tag_recalc(bmain, obn->pose);
|
2012-04-28 17:42:27 +02:00
|
|
|
if (dupflag & USER_DUP_ARM) {
|
2016-11-30 15:25:54 +01:00
|
|
|
ID_NEW_REMAP_US2(obn->data)
|
2012-04-28 17:42:27 +02:00
|
|
|
else {
|
2016-11-30 15:25:54 +01:00
|
|
|
obn->data = ID_NEW_SET(obn->data, BKE_armature_copy(bmain, obn->data));
|
2012-05-05 18:03:57 +02:00
|
|
|
BKE_pose_rebuild(obn, obn->data);
|
2012-04-28 17:42:27 +02:00
|
|
|
didit = 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 13:52:56 +02:00
|
|
|
}
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(id);
|
2012-04-28 17:42:27 +02: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 13:52:56 +02:00
|
|
|
case OB_LATTICE:
|
2012-04-28 17:42:27 +02:00
|
|
|
if (dupflag != 0) {
|
2016-11-30 15:25:54 +01:00
|
|
|
ID_NEW_REMAP_US2(obn->data)
|
2010-11-09 10:53:17 +01:00
|
|
|
else {
|
2016-11-30 15:25:54 +01:00
|
|
|
obn->data = ID_NEW_SET(obn->data, BKE_lattice_copy(bmain, obn->data));
|
2012-04-28 17:42:27 +02:00
|
|
|
didit = 1;
|
2010-11-09 10:53:17 +01:00
|
|
|
}
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(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 13:52:56 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OB_CAMERA:
|
2012-04-28 17:42:27 +02:00
|
|
|
if (dupflag != 0) {
|
2016-11-30 15:25:54 +01:00
|
|
|
ID_NEW_REMAP_US2(obn->data)
|
2010-11-09 10:53:17 +01:00
|
|
|
else {
|
2016-11-30 15:25:54 +01:00
|
|
|
obn->data = ID_NEW_SET(obn->data, BKE_camera_copy(bmain, obn->data));
|
2012-04-28 17:42:27 +02:00
|
|
|
didit = 1;
|
2010-11-09 10:53:17 +01:00
|
|
|
}
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(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 13:52:56 +02:00
|
|
|
}
|
|
|
|
break;
|
2011-08-01 13:44:20 +02:00
|
|
|
case OB_SPEAKER:
|
2012-04-28 17:42:27 +02:00
|
|
|
if (dupflag != 0) {
|
2016-11-30 15:25:54 +01:00
|
|
|
ID_NEW_REMAP_US2(obn->data)
|
2011-08-01 13:44:20 +02:00
|
|
|
else {
|
2016-11-30 15:25:54 +01:00
|
|
|
obn->data = ID_NEW_SET(obn->data, BKE_speaker_copy(bmain, obn->data));
|
2012-04-28 17:42:27 +02:00
|
|
|
didit = 1;
|
2011-08-01 13:44:20 +02:00
|
|
|
}
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(id);
|
2011-08-01 13:44:20 +02: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 13:52:56 +02:00
|
|
|
}
|
2010-11-09 10:53:17 +01:00
|
|
|
|
|
|
|
/* check if obdata is copied */
|
2012-03-24 07:38:07 +01:00
|
|
|
if (didit) {
|
2012-09-19 12:12:07 +02:00
|
|
|
Key *key = BKE_key_from_object(obn);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2017-08-30 17:24:06 +02:00
|
|
|
Key *oldkey = BKE_key_from_object(ob);
|
|
|
|
if (oldkey != NULL) {
|
|
|
|
ID_NEW_SET(oldkey, key);
|
|
|
|
}
|
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (dupflag & USER_DUP_ACT) {
|
2012-01-22 01:53:53 +01:00
|
|
|
bActuator *act;
|
|
|
|
|
2016-11-30 15:25:54 +01:00
|
|
|
BKE_animdata_copy_id_action((ID *)obn->data, true);
|
2012-03-24 07:38:07 +01:00
|
|
|
if (key) {
|
2016-11-30 15:25:54 +01:00
|
|
|
BKE_animdata_copy_id_action((ID *)key, true);
|
2012-01-22 01:53:53 +01:00
|
|
|
}
|
|
|
|
|
2012-01-22 00:57:28 +01:00
|
|
|
/* Update the duplicated action in the action actuators */
|
2016-11-30 15:25:54 +01:00
|
|
|
/* XXX TODO this code is all wrong! actact->act is user-refcounted (see readfile.c),
|
|
|
|
* and what about other ID pointers of other BGE logic bricks,
|
|
|
|
* and since this is object-level, why is it only ran if obdata was duplicated??? -mont29 */
|
2012-01-22 01:53:53 +01:00
|
|
|
for (act = obn->actuators.first; act; act = act->next) {
|
2012-03-24 07:38:07 +01:00
|
|
|
if (act->type == ACT_ACTION) {
|
2012-04-28 17:42:27 +02:00
|
|
|
bActionActuator *actact = (bActionActuator *) act->data;
|
2012-03-24 07:38:07 +01:00
|
|
|
if (ob->adt && actact->act == ob->adt->action) {
|
2012-01-22 00:57:28 +01:00
|
|
|
actact->act = obn->adt->action;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-11-09 10:53:17 +01:00
|
|
|
}
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (dupflag & USER_DUP_MAT) {
|
2012-04-28 17:42:27 +02:00
|
|
|
matarar = give_matarar(obn);
|
2012-03-24 07:38:07 +01:00
|
|
|
if (matarar) {
|
2012-04-28 17:42:27 +02:00
|
|
|
for (a = 0; a < obn->totcol; a++) {
|
|
|
|
id = (ID *)(*matarar)[a];
|
2012-03-24 07:38:07 +01:00
|
|
|
if (id) {
|
2016-11-30 15:25:54 +01:00
|
|
|
ID_NEW_REMAP_US((*matarar)[a])
|
|
|
|
else {
|
|
|
|
(*matarar)[a] = ID_NEW_SET((*matarar)[a], BKE_material_copy(bmain, (*matarar)[a]));
|
|
|
|
}
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(id);
|
2010-11-09 10:53:17 +01: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 13:52:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return basen;
|
2016-11-30 15:25:54 +01:00
|
|
|
|
|
|
|
#undef ID_NEW_REMAP_US
|
|
|
|
#undef ID_NEW_REMAP_US2
|
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 13:52:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* single object duplicate, if dupflag==0, fully linked, else it uses the flags given */
|
2011-04-07 10:23:00 +02:00
|
|
|
/* leaves selection of base/object unaltered.
|
2012-07-19 12:23:25 +02:00
|
|
|
* note: don't call this within a loop since clear_* funcs loop over the entire database.
|
2013-02-21 20:33:04 +01:00
|
|
|
* note: caller must do DAG_relations_tag_update(bmain);
|
2012-07-19 12:23:25 +02:00
|
|
|
* this is not done automatic since we may duplicate many objects in a batch */
|
2010-08-01 14:47:49 +02:00
|
|
|
Base *ED_object_add_duplicate(Main *bmain, Scene *scene, Base *base, int dupflag)
|
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 13:52:56 +02:00
|
|
|
{
|
|
|
|
Base *basen;
|
2010-02-13 14:49:27 +01:00
|
|
|
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 13:52:56 +02:00
|
|
|
|
2016-11-30 15:25:54 +01:00
|
|
|
clear_sca_new_poins(); /* BGE logic */
|
2010-03-27 11:43:04 +01:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
basen = object_add_duplicate_internal(bmain, scene, base, dupflag);
|
2010-03-27 11:43:04 +01:00
|
|
|
if (basen == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
ob = basen->object;
|
2010-03-27 11:43:04 +01:00
|
|
|
|
2011-04-07 10:23:00 +02:00
|
|
|
/* link own references to the newly duplicated data [#26816] */
|
2016-12-12 14:58:10 +01:00
|
|
|
BKE_libblock_relink_to_newid(&ob->id);
|
2011-04-07 10:23:00 +02:00
|
|
|
set_sca_new_poins_ob(ob);
|
|
|
|
|
2013-02-21 20:33:04 +01:00
|
|
|
/* DAG_relations_tag_update(bmain); */ /* caller must do */
|
2012-07-19 12:23:25 +02:00
|
|
|
|
2011-11-29 02:05:26 +01:00
|
|
|
if (ob->data) {
|
|
|
|
ED_render_id_flush_update(bmain, ob->data);
|
|
|
|
}
|
2010-03-27 11:43:04 +01:00
|
|
|
|
2016-11-30 15:25:54 +01:00
|
|
|
BKE_main_id_clear_newpoins(bmain);
|
|
|
|
|
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 13:52:56 +02:00
|
|
|
return basen;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* contextual operator dupli */
|
|
|
|
static int duplicate_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-04-28 17:42:27 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2014-02-03 08:55:59 +01:00
|
|
|
const bool linked = RNA_boolean_get(op->ptr, "linked");
|
2012-04-28 17:42:27 +02:00
|
|
|
int dupflag = (linked) ? 0 : U.dupflag;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2016-11-30 15:25:54 +01:00
|
|
|
clear_sca_new_poins(); /* BGE logic */
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2013-06-28 21:33:58 +02:00
|
|
|
CTX_DATA_BEGIN (C, Base *, base, selected_bases)
|
2012-04-30 18:22:40 +02:00
|
|
|
{
|
2012-04-28 17:42:27 +02:00
|
|
|
Base *basen = object_add_duplicate_internal(bmain, scene, base, dupflag);
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* note that this is safe to do with this context iterator,
|
2012-03-03 17:31:46 +01:00
|
|
|
* the list is made in advance */
|
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 13:52:56 +02:00
|
|
|
ED_base_object_select(base, BA_DESELECT);
|
|
|
|
|
2010-03-27 11:43:04 +01:00
|
|
|
if (basen == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
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 13:52:56 +02:00
|
|
|
/* new object becomes active */
|
2012-04-28 17:42:27 +02:00
|
|
|
if (BASACT == base)
|
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 13:52:56 +02:00
|
|
|
ED_base_object_activate(C, basen);
|
2010-12-07 01:48:36 +01:00
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (basen->object->data) {
|
2010-12-07 01:48:36 +01:00
|
|
|
DAG_id_tag_update(basen->object->data, 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 13:52:56 +02:00
|
|
|
}
|
|
|
|
CTX_DATA_END;
|
|
|
|
|
2015-10-08 11:29:49 +02:00
|
|
|
copy_object_set_idnew(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 13:52:56 +02:00
|
|
|
|
2016-11-30 15:25:54 +01:00
|
|
|
BKE_main_id_clear_newpoins(bmain);
|
|
|
|
|
2013-02-21 20:33:04 +01:00
|
|
|
DAG_relations_tag_update(bmain);
|
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 13:52:56 +02:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
|
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 13:52:56 +02:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_duplicate(wmOperatorType *ot)
|
|
|
|
{
|
2010-06-06 17:38:50 +02:00
|
|
|
PropertyRNA *prop;
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* identifiers */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->name = "Duplicate Objects";
|
2010-02-10 22:15:44 +01:00
|
|
|
ot->description = "Duplicate selected objects";
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->idname = "OBJECT_OT_duplicate";
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* api callbacks */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->exec = duplicate_exec;
|
|
|
|
ot->poll = ED_operator_objectmode;
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* flags */
|
2012-04-28 17:42:27 +02:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* to give to transform */
|
2011-06-05 01:02:44 +02:00
|
|
|
RNA_def_boolean(ot->srna, "linked", 0, "Linked", "Duplicate object but not object data, linking to the original data");
|
2015-11-23 03:49:52 +01:00
|
|
|
prop = RNA_def_enum(ot->srna, "mode", rna_enum_transform_mode_types, TFM_TRANSLATION, "Mode", "");
|
2010-06-06 17:38:50 +02:00
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN);
|
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 13:52:56 +02:00
|
|
|
}
|
|
|
|
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 19:18:21 +01:00
|
|
|
/* **************** add named object, for dragdrop ************* */
|
|
|
|
|
|
|
|
static int add_named_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2013-02-06 03:48:03 +01:00
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2013-04-15 06:34:14 +02:00
|
|
|
const wmEvent *event = win ? win->eventstate : NULL;
|
2012-04-28 17:42:27 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2014-09-02 12:45:28 +02:00
|
|
|
View3D *v3d = CTX_wm_view3d(C); /* may be NULL */
|
2012-04-28 17:42:27 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 19:18:21 +01:00
|
|
|
Base *basen, *base;
|
|
|
|
Object *ob;
|
2014-02-03 08:55:59 +01:00
|
|
|
const bool linked = RNA_boolean_get(op->ptr, "linked");
|
2012-04-28 17:42:27 +02:00
|
|
|
int dupflag = (linked) ? 0 : U.dupflag;
|
|
|
|
char name[MAX_ID_NAME - 2];
|
2010-03-27 11:43:04 +01:00
|
|
|
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 19:18:21 +01:00
|
|
|
/* find object, create fake base */
|
|
|
|
RNA_string_get(op->ptr, "name", name);
|
2012-05-05 19:00:11 +02:00
|
|
|
ob = (Object *)BKE_libblock_find_name(ID_OB, name);
|
2014-02-17 23:22:43 +01:00
|
|
|
|
|
|
|
if (ob == NULL) {
|
|
|
|
BKE_report(op->reports, RPT_ERROR, "Object not found");
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 19:18:21 +01:00
|
|
|
return OPERATOR_CANCELLED;
|
2014-02-17 23:22:43 +01:00
|
|
|
}
|
2010-03-27 11:43:04 +01:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
base = MEM_callocN(sizeof(Base), "duplibase");
|
|
|
|
base->object = ob;
|
|
|
|
base->flag = ob->flag;
|
2010-03-27 11:43:04 +01:00
|
|
|
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 19:18:21 +01:00
|
|
|
/* prepare dupli */
|
2016-11-30 15:25:54 +01:00
|
|
|
clear_sca_new_poins(); /* BGE logic */
|
2010-03-27 11:43:04 +01:00
|
|
|
|
2012-04-28 17:42:27 +02:00
|
|
|
basen = object_add_duplicate_internal(bmain, scene, base, dupflag);
|
2010-03-27 11:43:04 +01:00
|
|
|
|
|
|
|
if (basen == NULL) {
|
|
|
|
MEM_freeN(base);
|
2014-02-17 23:22:43 +01:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Object could not be duplicated");
|
2010-03-27 11:43:04 +01:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
2014-09-02 12:45:28 +02:00
|
|
|
basen->lay = basen->object->lay = BKE_screen_view3d_layer_active(v3d, scene);
|
2013-02-27 05:57:53 +01:00
|
|
|
basen->object->restrictflag &= ~OB_RESTRICT_VIEW;
|
2010-03-27 11:43:04 +01:00
|
|
|
|
2013-02-06 03:48:03 +01:00
|
|
|
if (event) {
|
2013-02-25 01:45:20 +01:00
|
|
|
ARegion *ar = CTX_wm_region(C);
|
|
|
|
const int mval[2] = {event->x - ar->winrct.xmin,
|
|
|
|
event->y - ar->winrct.ymin};
|
2013-02-06 03:48:03 +01:00
|
|
|
ED_object_location_from_view(C, basen->object->loc);
|
2013-02-25 01:45:20 +01:00
|
|
|
ED_view3d_cursor3d_position(C, basen->object->loc, mval);
|
2013-02-06 03:48:03 +01:00
|
|
|
}
|
2012-12-26 17:24:50 +01:00
|
|
|
|
2013-02-27 11:19:31 +01:00
|
|
|
ED_base_object_select(basen, BA_SELECT);
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 19:18:21 +01:00
|
|
|
ED_base_object_activate(C, basen);
|
2010-03-27 11:43:04 +01:00
|
|
|
|
2015-10-08 11:29:49 +02:00
|
|
|
copy_object_set_idnew(C);
|
2010-03-27 11:43:04 +01:00
|
|
|
|
2016-11-30 15:25:54 +01:00
|
|
|
BKE_main_id_clear_newpoins(bmain);
|
|
|
|
|
2013-02-21 20:33:04 +01:00
|
|
|
DAG_relations_tag_update(bmain);
|
2010-03-27 11:43:04 +01:00
|
|
|
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 19:18:21 +01:00
|
|
|
MEM_freeN(base);
|
2010-03-27 11:43:04 +01:00
|
|
|
|
2014-12-17 13:47:14 +01:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT | ND_OB_ACTIVE, scene);
|
2010-03-27 11:43:04 +01:00
|
|
|
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 19:18:21 +01:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_add_named(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->name = "Add Named Object";
|
2010-02-10 22:15:44 +01:00
|
|
|
ot->description = "Add named object";
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->idname = "OBJECT_OT_add_named";
|
2012-10-05 09:05:52 +02:00
|
|
|
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 19:18:21 +01:00
|
|
|
/* api callbacks */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->exec = add_named_exec;
|
|
|
|
ot->poll = ED_operator_objectmode;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 19:18:21 +01:00
|
|
|
/* flags */
|
2012-04-28 17:42:27 +02:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2011-06-05 01:02:44 +02:00
|
|
|
RNA_def_boolean(ot->srna, "linked", 0, "Linked", "Duplicate object but not object data, linking to the original data");
|
2014-01-16 11:43:22 +01:00
|
|
|
RNA_def_string(ot->srna, "name", NULL, MAX_ID_NAME - 2, "Name", "Object name to add");
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 19:18:21 +01: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 13:52:56 +02:00
|
|
|
/**************************** Join *************************/
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2009-11-28 05:04:01 +01:00
|
|
|
static int join_poll(bContext *C)
|
|
|
|
{
|
2012-04-28 17:42:27 +02:00
|
|
|
Object *ob = CTX_data_active_object(C);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2016-07-06 14:11:01 +02:00
|
|
|
if (!ob || ID_IS_LINKED_DATABLOCK(ob)) return 0;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2014-07-19 17:30:29 +02:00
|
|
|
if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_ARMATURE))
|
2009-11-28 05:04:01 +01:00
|
|
|
return ED_operator_screenactive(C);
|
|
|
|
else
|
|
|
|
return 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 13:52:56 +02:00
|
|
|
static int join_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-04-28 17:42:27 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
Object *ob = CTX_data_active_object(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 13:52:56 +02:00
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (scene->obedit) {
|
2012-10-26 19:32:50 +02:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "This data does not support joining 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 13:52:56 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2012-05-05 16:03:12 +02:00
|
|
|
else if (BKE_object_obdata_is_libdata(ob)) {
|
2012-10-26 19:32:50 +02:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Cannot edit external libdata");
|
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 13:52:56 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2011-05-09 04:45:52 +02:00
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (ob->type == OB_MESH)
|
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 13:52:56 +02:00
|
|
|
return join_mesh_exec(C, op);
|
2012-03-24 07:38:07 +01:00
|
|
|
else if (ELEM(ob->type, OB_CURVE, OB_SURF))
|
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 13:52:56 +02:00
|
|
|
return join_curve_exec(C, op);
|
2012-03-24 07:38:07 +01:00
|
|
|
else if (ob->type == OB_ARMATURE)
|
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 13:52:56 +02:00
|
|
|
return join_armature_exec(C, op);
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_join(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->name = "Join";
|
2010-02-10 22:15:44 +01:00
|
|
|
ot->description = "Join selected objects into active object";
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->idname = "OBJECT_OT_join";
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* api callbacks */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->exec = join_exec;
|
|
|
|
ot->poll = join_poll;
|
2012-10-05 09:05:52 +02: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 13:52:56 +02:00
|
|
|
/* flags */
|
2012-04-28 17:42:27 +02: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 13:52:56 +02:00
|
|
|
}
|
|
|
|
|
2009-11-28 05:04:01 +01:00
|
|
|
/**************************** Join as Shape Key*************************/
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2009-11-28 05:04:01 +01:00
|
|
|
static int join_shapes_poll(bContext *C)
|
|
|
|
{
|
2012-04-28 17:42:27 +02:00
|
|
|
Object *ob = CTX_data_active_object(C);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2016-07-06 14:11:01 +02:00
|
|
|
if (!ob || ID_IS_LINKED_DATABLOCK(ob)) return 0;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2009-11-28 05:04:01 +01:00
|
|
|
/* only meshes supported at the moment */
|
|
|
|
if (ob->type == OB_MESH)
|
|
|
|
return ED_operator_screenactive(C);
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int join_shapes_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-04-28 17:42:27 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
Object *ob = CTX_data_active_object(C);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (scene->obedit) {
|
2012-10-26 19:32:50 +02:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "This data does not support joining in edit mode");
|
2009-11-28 05:04:01 +01:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2012-05-05 16:03:12 +02:00
|
|
|
else if (BKE_object_obdata_is_libdata(ob)) {
|
2012-10-26 19:32:50 +02:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Cannot edit external libdata");
|
2009-11-28 05:04:01 +01:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (ob->type == OB_MESH)
|
2009-11-28 05:04:01 +01:00
|
|
|
return join_mesh_shapes_exec(C, op);
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2009-11-28 05:04:01 +01:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_join_shapes(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->name = "Join as Shapes";
|
2010-02-10 22:15:44 +01:00
|
|
|
ot->description = "Merge selected objects to shapes of active object";
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->idname = "OBJECT_OT_join_shapes";
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2009-11-28 05:04:01 +01:00
|
|
|
/* api callbacks */
|
2012-03-22 08:26:09 +01:00
|
|
|
ot->exec = join_shapes_exec;
|
|
|
|
ot->poll = join_shapes_poll;
|
2012-10-05 09:05:52 +02:00
|
|
|
|
2009-11-28 05:04:01 +01:00
|
|
|
/* flags */
|
2012-04-28 17:42:27 +02:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-11-28 05:04:01 +01:00
|
|
|
}
|