2011-10-24 23:32:24 +00:00
|
|
|
/*
|
2010-01-28 00:45:30 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2012-02-11 04:16:17 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2010-01-28 00:45:30 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2004 by Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): Joseph Eagar
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2012-02-19 17:11:40 +00:00
|
|
|
/** \file blender/editors/mesh/editmesh_add.c
|
|
|
|
* \ingroup edmesh
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
#include "DNA_meshdata_types.h"
|
2010-01-28 00:45:30 +00:00
|
|
|
#include "DNA_object_types.h"
|
2013-06-25 09:27:31 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2010-01-28 00:45:30 +00:00
|
|
|
|
2015-02-10 02:38:21 +11:00
|
|
|
#include "BLI_math.h"
|
2010-01-28 00:45:30 +00:00
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2013-03-20 18:42:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
#include "BKE_context.h"
|
2012-02-16 19:13:04 +00:00
|
|
|
#include "BKE_library.h"
|
2013-04-13 20:31:52 +00:00
|
|
|
#include "BKE_editmesh.h"
|
2010-01-28 00:45:30 +00:00
|
|
|
|
2013-03-07 02:44:55 +00:00
|
|
|
#include "RNA_define.h"
|
|
|
|
#include "RNA_access.h"
|
2010-01-28 00:45:30 +00:00
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "ED_mesh.h"
|
|
|
|
#include "ED_screen.h"
|
|
|
|
#include "ED_object.h"
|
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
|
|
|
#include "ED_uvedit.h"
|
2010-01-28 00:45:30 +00:00
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
#include "mesh_intern.h" /* own include */
|
2012-03-27 04:46:52 +00:00
|
|
|
|
2015-06-21 16:06:44 +02:00
|
|
|
|
|
|
|
#define MESH_ADD_VERTS_MAXI 10000000
|
|
|
|
|
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* ********* add primitive operators ************* */
|
|
|
|
|
2012-09-23 07:18:50 +00:00
|
|
|
static Object *make_prim_init(bContext *C, const char *idname,
|
2012-12-11 14:29:01 +00:00
|
|
|
float *dia, float mat[4][4],
|
2013-04-15 04:34:14 +00:00
|
|
|
bool *was_editmode, const float loc[3], const float rot[3], const unsigned int layer)
|
2010-01-28 00:45:30 +00:00
|
|
|
{
|
2012-03-24 02:51:46 +00:00
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
2010-01-28 00:45:30 +00:00
|
|
|
|
2013-04-15 04:34:14 +00:00
|
|
|
*was_editmode = false;
|
2012-03-24 02:51:46 +00:00
|
|
|
if (obedit == NULL || obedit->type != OB_MESH) {
|
2015-05-04 12:25:33 +10:00
|
|
|
obedit = ED_object_add_type(C, OB_MESH, idname, loc, rot, false, layer);
|
2012-02-16 19:13:04 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* create editmode */
|
2013-03-21 14:18:17 +00:00
|
|
|
ED_object_editmode_enter(C, EM_DO_UNDO | EM_IGNORE_LAYER); /* rare cases the active layer is messed up */
|
2013-04-15 04:34:14 +00:00
|
|
|
*was_editmode = true;
|
2010-01-28 00:45:30 +00:00
|
|
|
}
|
|
|
|
|
2015-02-10 02:38:21 +11:00
|
|
|
*dia = ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
|
2012-09-23 07:18:50 +00:00
|
|
|
|
|
|
|
return obedit;
|
2010-01-28 00:45:30 +00:00
|
|
|
}
|
|
|
|
|
2013-04-15 04:34:14 +00:00
|
|
|
static void make_prim_finish(bContext *C, Object *obedit, bool was_editmode, int enter_editmode)
|
2010-01-28 00:45:30 +00:00
|
|
|
{
|
2013-04-16 05:59:48 +00:00
|
|
|
BMEditMesh *em = BKE_editmesh_from_object(obedit);
|
2014-01-28 03:52:21 +11:00
|
|
|
const bool exit_editmode = ((was_editmode == true) && (enter_editmode == false));
|
2010-01-28 00:45:30 +00:00
|
|
|
|
2011-10-06 02:29:39 +00:00
|
|
|
/* Primitive has all verts selected, use vert select flush
|
2012-02-10 06:16:21 +00:00
|
|
|
* to push this up to edges & faces. */
|
|
|
|
EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX);
|
2011-06-21 00:03:38 +00:00
|
|
|
|
2012-11-29 02:37:39 +00:00
|
|
|
/* only recalc editmode tessface if we are staying in editmode */
|
2013-03-19 23:17:44 +00:00
|
|
|
EDBM_update_generic(em, !exit_editmode, true);
|
2010-01-28 00:45:30 +00:00
|
|
|
|
|
|
|
/* userdef */
|
2012-12-03 02:26:13 +00:00
|
|
|
if (exit_editmode) {
|
2013-03-21 14:18:17 +00:00
|
|
|
ED_object_editmode_exit(C, EM_FREEDATA); /* adding EM_DO_UNDO messes up operator redo */
|
2010-01-28 00:45:30 +00:00
|
|
|
}
|
2012-03-26 02:56:48 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit);
|
2010-01-28 00:45:30 +00:00
|
|
|
}
|
2012-02-19 17:11:40 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
static int add_primitive_plane_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
Object *obedit;
|
|
|
|
BMEditMesh *em;
|
2012-03-28 22:11:19 +00:00
|
|
|
float loc[3], rot[3], mat[4][4], dia;
|
2013-04-15 04:34:14 +00:00
|
|
|
bool enter_editmode;
|
|
|
|
bool was_editmode;
|
2011-03-25 00:32:38 +00:00
|
|
|
unsigned int layer;
|
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
|
|
|
const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs");
|
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 12:59:09 +00:00
|
|
|
|
2013-09-16 04:19:48 +00:00
|
|
|
WM_operator_view3d_unit_defaults(C, op);
|
2014-01-16 23:50:35 +11:00
|
|
|
ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &layer, NULL);
|
2015-08-16 17:32:01 +10:00
|
|
|
obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Plane"), &dia, mat, &was_editmode, loc, rot, layer);
|
2013-04-16 05:59:48 +00:00
|
|
|
em = BKE_editmesh_from_object(obedit);
|
2010-01-28 00:45:30 +00:00
|
|
|
|
2015-12-06 11:17:17 +11:00
|
|
|
if (calc_uvs) {
|
|
|
|
ED_mesh_uv_texture_ensure(obedit->data, NULL);
|
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
|
|
|
}
|
|
|
|
|
2013-07-25 07:00:07 +00:00
|
|
|
if (!EDBM_op_call_and_selectf(
|
|
|
|
em, op, "verts.out", false,
|
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
|
|
|
"create_grid x_segments=%i y_segments=%i size=%f matrix=%m4 calc_uvs=%b",
|
|
|
|
1, 1, RNA_float_get(op->ptr, "radius"), mat, calc_uvs))
|
2012-02-20 01:52:35 +00:00
|
|
|
{
|
2010-01-28 00:45:30 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2012-02-20 01:52:35 +00:00
|
|
|
}
|
2012-02-05 22:27:44 +00:00
|
|
|
|
2013-04-15 04:34:14 +00:00
|
|
|
make_prim_finish(C, obedit, was_editmode, enter_editmode);
|
2010-01-28 00:45:30 +00:00
|
|
|
|
2012-03-27 05:03:23 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2010-01-28 00:45:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MESH_OT_primitive_plane_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Plane";
|
|
|
|
ot->description = "Construct a filled planar mesh with 4 vertices";
|
|
|
|
ot->idname = "MESH_OT_primitive_plane_add";
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = add_primitive_plane_exec;
|
|
|
|
ot->poll = ED_operator_scene_editable;
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* flags */
|
2012-03-26 02:56:48 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2010-01-28 00:45:30 +00:00
|
|
|
|
2013-09-16 00:18:09 +00:00
|
|
|
ED_object_add_unit_props(ot);
|
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
|
|
|
ED_object_add_mesh_props(ot);
|
2013-03-19 23:17:44 +00:00
|
|
|
ED_object_add_generic_props(ot, true);
|
2010-01-28 00:45:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int add_primitive_cube_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
Object *obedit;
|
|
|
|
BMEditMesh *em;
|
|
|
|
float loc[3], rot[3], mat[4][4], dia;
|
2013-04-15 04:34:14 +00:00
|
|
|
bool enter_editmode;
|
|
|
|
bool was_editmode;
|
2011-03-25 00:32:38 +00:00
|
|
|
unsigned int layer;
|
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
|
|
|
const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs");
|
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 12:59:09 +00:00
|
|
|
|
2013-09-16 04:19:48 +00:00
|
|
|
WM_operator_view3d_unit_defaults(C, op);
|
2014-01-16 23:50:35 +11:00
|
|
|
ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &layer, NULL);
|
2015-08-16 17:32:01 +10:00
|
|
|
obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Cube"), &dia, mat, &was_editmode, loc, rot, layer);
|
2013-04-16 05:59:48 +00:00
|
|
|
em = BKE_editmesh_from_object(obedit);
|
2010-01-28 00:45:30 +00:00
|
|
|
|
2015-12-06 11:17:17 +11:00
|
|
|
if (calc_uvs) {
|
|
|
|
ED_mesh_uv_texture_ensure(obedit->data, NULL);
|
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
|
|
|
}
|
|
|
|
|
2013-07-25 07:00:07 +00:00
|
|
|
if (!EDBM_op_call_and_selectf(
|
|
|
|
em, op, "verts.out", false,
|
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
|
|
|
"create_cube matrix=%m4 size=%f calc_uvs=%b",
|
|
|
|
mat, RNA_float_get(op->ptr, "radius") * 2.0f, calc_uvs))
|
2013-05-28 23:07:16 +00:00
|
|
|
{
|
2010-01-28 00:45:30 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2012-02-20 01:52:35 +00: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 12:59:09 +00:00
|
|
|
|
2011-12-08 00:28:42 +00:00
|
|
|
/* BMESH_TODO make plane side this: M_SQRT2 - plane (diameter of 1.41 makes it unit size) */
|
2013-04-15 04:34:14 +00:00
|
|
|
make_prim_finish(C, obedit, was_editmode, enter_editmode);
|
2010-01-28 00:45:30 +00:00
|
|
|
|
2012-02-19 17:11:40 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2010-01-28 00:45:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MESH_OT_primitive_cube_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Cube";
|
|
|
|
ot->description = "Construct a cube mesh";
|
|
|
|
ot->idname = "MESH_OT_primitive_cube_add";
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = add_primitive_cube_exec;
|
|
|
|
ot->poll = ED_operator_scene_editable;
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* flags */
|
2012-03-26 02:56:48 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2010-01-28 00:45:30 +00:00
|
|
|
|
2013-09-16 00:18:09 +00:00
|
|
|
ED_object_add_unit_props(ot);
|
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
|
|
|
ED_object_add_mesh_props(ot);
|
2013-03-19 23:17:44 +00:00
|
|
|
ED_object_add_generic_props(ot, true);
|
2010-01-28 00:45:30 +00:00
|
|
|
}
|
|
|
|
|
2012-03-26 02:56:48 +00:00
|
|
|
static const EnumPropertyItem fill_type_items[] = {
|
2011-05-01 18:53:18 +00:00
|
|
|
{0, "NOTHING", 0, "Nothing", "Don't fill at all"},
|
|
|
|
{1, "NGON", 0, "Ngon", "Use ngons"},
|
|
|
|
{2, "TRIFAN", 0, "Triangle Fan", "Use triangle fans"},
|
|
|
|
{0, NULL, 0, NULL, NULL}};
|
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
static int add_primitive_circle_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2011-05-01 18:53:18 +00:00
|
|
|
Object *obedit;
|
|
|
|
BMEditMesh *em;
|
|
|
|
float loc[3], rot[3], mat[4][4], dia;
|
2013-04-15 04:34:14 +00:00
|
|
|
bool enter_editmode;
|
|
|
|
int cap_end, cap_tri;
|
2011-05-01 18:53:18 +00:00
|
|
|
unsigned int layer;
|
2013-04-15 04:34:14 +00:00
|
|
|
bool was_editmode;
|
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
|
|
|
const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs");
|
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 12:59:09 +00:00
|
|
|
|
2011-05-01 18:53:18 +00:00
|
|
|
cap_end = RNA_enum_get(op->ptr, "fill_type");
|
2012-03-24 02:51:46 +00:00
|
|
|
cap_tri = (cap_end == 2);
|
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 12:59:09 +00:00
|
|
|
|
2013-09-16 04:19:48 +00:00
|
|
|
WM_operator_view3d_unit_defaults(C, op);
|
2014-01-16 23:50:35 +11:00
|
|
|
ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &layer, NULL);
|
2015-08-16 17:32:01 +10:00
|
|
|
obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Circle"), &dia, mat, &was_editmode, loc, rot, layer);
|
2013-04-16 05:59:48 +00:00
|
|
|
em = BKE_editmesh_from_object(obedit);
|
2011-05-01 18:53:18 +00:00
|
|
|
|
2015-12-06 11:17:17 +11:00
|
|
|
if (calc_uvs) {
|
|
|
|
ED_mesh_uv_texture_ensure(obedit->data, NULL);
|
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
|
|
|
}
|
|
|
|
|
2013-07-25 07:00:07 +00:00
|
|
|
if (!EDBM_op_call_and_selectf(
|
|
|
|
em, op, "verts.out", false,
|
2017-10-04 18:01:53 +11:00
|
|
|
"create_circle segments=%i radius=%f cap_ends=%b cap_tris=%b matrix=%m4 calc_uvs=%b",
|
2013-07-25 07:00:07 +00:00
|
|
|
RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius"),
|
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
|
|
|
cap_end, cap_tri, mat, calc_uvs))
|
2012-02-20 01:52:35 +00:00
|
|
|
{
|
2011-05-01 18:53:18 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2012-02-20 01:52:35 +00: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 12:59:09 +00:00
|
|
|
|
2013-04-15 04:34:14 +00:00
|
|
|
make_prim_finish(C, obedit, was_editmode, 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 12:59:09 +00:00
|
|
|
|
2011-05-01 18:53:18 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2010-01-28 00:45:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MESH_OT_primitive_circle_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Circle";
|
|
|
|
ot->description = "Construct a circle mesh";
|
|
|
|
ot->idname = "MESH_OT_primitive_circle_add";
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = add_primitive_circle_exec;
|
|
|
|
ot->poll = ED_operator_scene_editable;
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* flags */
|
2012-03-26 02:56:48 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* props */
|
2015-06-21 16:06:44 +02:00
|
|
|
RNA_def_int(ot->srna, "vertices", 32, 3, MESH_ADD_VERTS_MAXI, "Vertices", "", 3, 500);
|
2013-09-16 00:18:09 +00:00
|
|
|
ED_object_add_unit_props(ot);
|
2011-05-07 02:48:14 +00:00
|
|
|
RNA_def_enum(ot->srna, "fill_type", fill_type_items, 0, "Fill Type", "");
|
2010-01-28 00:45:30 +00: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
|
|
|
ED_object_add_mesh_props(ot);
|
2013-03-19 23:17:44 +00:00
|
|
|
ED_object_add_generic_props(ot, true);
|
2010-01-28 00:45:30 +00:00
|
|
|
}
|
|
|
|
|
2010-09-07 05:47:34 +00:00
|
|
|
static int add_primitive_cylinder_exec(bContext *C, wmOperator *op)
|
2010-01-28 00:45:30 +00:00
|
|
|
{
|
2010-02-18 10:09:52 +00:00
|
|
|
Object *obedit;
|
|
|
|
BMEditMesh *em;
|
|
|
|
float loc[3], rot[3], mat[4][4], dia;
|
2013-04-15 04:34:14 +00:00
|
|
|
bool enter_editmode;
|
2011-03-25 00:32:38 +00:00
|
|
|
unsigned int layer;
|
2013-04-15 04:34:14 +00:00
|
|
|
bool was_editmode;
|
2013-04-15 08:43:17 +00:00
|
|
|
const int end_fill_type = RNA_enum_get(op->ptr, "end_fill_type");
|
|
|
|
const bool cap_end = (end_fill_type != 0);
|
|
|
|
const bool cap_tri = (end_fill_type == 2);
|
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
|
|
|
const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs");
|
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 12:59:09 +00:00
|
|
|
|
2013-09-16 04:19:48 +00:00
|
|
|
WM_operator_view3d_unit_defaults(C, op);
|
2014-01-16 23:50:35 +11:00
|
|
|
ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &layer, NULL);
|
2015-08-16 17:32:01 +10:00
|
|
|
obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Cylinder"), &dia, mat, &was_editmode, loc, rot, layer);
|
2013-04-16 05:59:48 +00:00
|
|
|
em = BKE_editmesh_from_object(obedit);
|
2010-01-28 00:45:30 +00:00
|
|
|
|
2015-12-06 11:17:17 +11:00
|
|
|
if (calc_uvs) {
|
|
|
|
ED_mesh_uv_texture_ensure(obedit->data, NULL);
|
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
|
|
|
}
|
|
|
|
|
2012-03-27 04:46:52 +00:00
|
|
|
if (!EDBM_op_call_and_selectf(
|
2013-07-25 07:00:07 +00:00
|
|
|
em, op, "verts.out", false,
|
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
|
|
|
"create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b cap_tris=%b depth=%f matrix=%m4 calc_uvs=%b",
|
2012-02-20 01:52:35 +00:00
|
|
|
RNA_int_get(op->ptr, "vertices"),
|
2012-12-09 10:48:18 +00:00
|
|
|
RNA_float_get(op->ptr, "radius"),
|
|
|
|
RNA_float_get(op->ptr, "radius"),
|
2012-02-20 01:52:35 +00:00
|
|
|
cap_end, cap_tri,
|
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
|
|
|
RNA_float_get(op->ptr, "depth"), mat, calc_uvs))
|
2012-02-20 01:52:35 +00:00
|
|
|
{
|
2010-02-18 10:09:52 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2012-02-20 01:52:35 +00: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 12:59:09 +00:00
|
|
|
|
2013-04-15 04:34:14 +00:00
|
|
|
make_prim_finish(C, obedit, was_editmode, 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 12:59:09 +00:00
|
|
|
|
2011-02-27 06:19:40 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2010-01-28 00:45:30 +00:00
|
|
|
}
|
|
|
|
|
2010-09-07 05:47:34 +00:00
|
|
|
void MESH_OT_primitive_cylinder_add(wmOperatorType *ot)
|
2010-01-28 00:45:30 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Cylinder";
|
|
|
|
ot->description = "Construct a cylinder mesh";
|
|
|
|
ot->idname = "MESH_OT_primitive_cylinder_add";
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = add_primitive_cylinder_exec;
|
|
|
|
ot->poll = ED_operator_scene_editable;
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* flags */
|
2012-03-26 02:56:48 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* props */
|
2015-06-21 16:06:44 +02:00
|
|
|
RNA_def_int(ot->srna, "vertices", 32, 3, MESH_ADD_VERTS_MAXI, "Vertices", "", 3, 500);
|
2013-09-16 00:18:09 +00:00
|
|
|
ED_object_add_unit_props(ot);
|
2015-12-01 00:58:09 +01:00
|
|
|
RNA_def_float_distance(ot->srna, "depth", 2.0f, 0.0, OBJECT_ADD_SIZE_MAXF, "Depth", "", 0.001, 100.00);
|
2011-05-07 02:48:14 +00:00
|
|
|
RNA_def_enum(ot->srna, "end_fill_type", fill_type_items, 1, "Cap Fill Type", "");
|
2010-01-28 00:45:30 +00: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
|
|
|
ED_object_add_mesh_props(ot);
|
2013-03-19 23:17:44 +00:00
|
|
|
ED_object_add_generic_props(ot, true);
|
2010-01-28 00:45:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int add_primitive_cone_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2010-02-18 10:09:52 +00:00
|
|
|
Object *obedit;
|
|
|
|
BMEditMesh *em;
|
|
|
|
float loc[3], rot[3], mat[4][4], dia;
|
2013-04-15 04:34:14 +00:00
|
|
|
bool enter_editmode;
|
2011-03-25 00:32:38 +00:00
|
|
|
unsigned int layer;
|
2013-04-15 04:34:14 +00:00
|
|
|
bool was_editmode;
|
2013-04-15 08:43:17 +00:00
|
|
|
const int end_fill_type = RNA_enum_get(op->ptr, "end_fill_type");
|
|
|
|
const bool cap_end = (end_fill_type != 0);
|
|
|
|
const bool cap_tri = (end_fill_type == 2);
|
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
|
|
|
const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs");
|
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 12:59:09 +00:00
|
|
|
|
2013-09-16 04:19:48 +00:00
|
|
|
WM_operator_view3d_unit_defaults(C, op);
|
2014-01-16 23:50:35 +11:00
|
|
|
ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &layer, NULL);
|
2015-08-16 17:32:01 +10:00
|
|
|
obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Cone"), &dia, mat, &was_editmode, loc, rot, layer);
|
2013-04-16 05:59:48 +00:00
|
|
|
em = BKE_editmesh_from_object(obedit);
|
2010-01-28 00:45:30 +00:00
|
|
|
|
2015-12-06 11:17:17 +11:00
|
|
|
if (calc_uvs) {
|
|
|
|
ED_mesh_uv_texture_ensure(obedit->data, NULL);
|
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
|
|
|
}
|
|
|
|
|
2012-03-27 04:46:52 +00:00
|
|
|
if (!EDBM_op_call_and_selectf(
|
2013-07-25 07:00:07 +00:00
|
|
|
em, op, "verts.out", false,
|
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
|
|
|
"create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b cap_tris=%b depth=%f matrix=%m4 calc_uvs=%b",
|
2012-12-09 10:48:18 +00:00
|
|
|
RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius1"),
|
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
|
|
|
RNA_float_get(op->ptr, "radius2"), cap_end, cap_tri, RNA_float_get(op->ptr, "depth"), mat, calc_uvs))
|
2012-02-20 01:52:35 +00:00
|
|
|
{
|
2010-02-18 10:09:52 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2012-02-20 01:52:35 +00: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 12:59:09 +00:00
|
|
|
|
2013-04-15 04:34:14 +00:00
|
|
|
make_prim_finish(C, obedit, was_editmode, enter_editmode);
|
2010-02-18 10:09:52 +00:00
|
|
|
|
2012-03-02 21:14:37 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2010-01-28 00:45:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MESH_OT_primitive_cone_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Cone";
|
|
|
|
ot->description = "Construct a conic mesh";
|
|
|
|
ot->idname = "MESH_OT_primitive_cone_add";
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = add_primitive_cone_exec;
|
|
|
|
ot->poll = ED_operator_scene_editable;
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* flags */
|
2012-03-26 02:56:48 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* props */
|
2015-06-21 16:06:44 +02:00
|
|
|
RNA_def_int(ot->srna, "vertices", 32, 3, MESH_ADD_VERTS_MAXI, "Vertices", "", 3, 500);
|
2015-12-01 00:58:09 +01:00
|
|
|
RNA_def_float_distance(ot->srna, "radius1", 1.0f, 0.0, OBJECT_ADD_SIZE_MAXF, "Radius 1", "", 0.001, 100.00);
|
2017-06-18 02:07:22 +10:00
|
|
|
RNA_def_float_distance(ot->srna, "radius2", 0.0f, 0.0, OBJECT_ADD_SIZE_MAXF, "Radius 2", "", 0.0, 100.00);
|
2015-12-01 00:58:09 +01:00
|
|
|
RNA_def_float_distance(ot->srna, "depth", 2.0f, 0.0, OBJECT_ADD_SIZE_MAXF, "Depth", "", 0.001, 100.00);
|
2011-05-07 02:48:14 +00:00
|
|
|
RNA_def_enum(ot->srna, "end_fill_type", fill_type_items, 1, "Base Fill Type", "");
|
2012-02-19 17:11:40 +00: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
|
|
|
ED_object_add_mesh_props(ot);
|
2013-03-19 23:17:44 +00:00
|
|
|
ED_object_add_generic_props(ot, true);
|
2010-01-28 00:45:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int add_primitive_grid_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2010-02-18 10:09:52 +00:00
|
|
|
Object *obedit;
|
|
|
|
BMEditMesh *em;
|
2012-03-28 22:11:19 +00:00
|
|
|
float loc[3], rot[3], mat[4][4], dia;
|
2013-04-15 04:34:14 +00:00
|
|
|
bool enter_editmode;
|
|
|
|
bool was_editmode;
|
2011-03-25 00:32:38 +00:00
|
|
|
unsigned int layer;
|
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
|
|
|
const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs");
|
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 12:59:09 +00:00
|
|
|
|
2013-09-16 04:19:48 +00:00
|
|
|
WM_operator_view3d_unit_defaults(C, op);
|
2014-01-16 23:50:35 +11:00
|
|
|
ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &layer, NULL);
|
2015-08-16 17:32:01 +10:00
|
|
|
obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Grid"), &dia, mat, &was_editmode, loc, rot, layer);
|
2013-04-16 05:59:48 +00:00
|
|
|
em = BKE_editmesh_from_object(obedit);
|
2010-01-28 00:45:30 +00:00
|
|
|
|
2015-12-06 11:17:17 +11:00
|
|
|
if (calc_uvs) {
|
|
|
|
ED_mesh_uv_texture_ensure(obedit->data, NULL);
|
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
|
|
|
}
|
|
|
|
|
2013-07-25 07:00:07 +00:00
|
|
|
if (!EDBM_op_call_and_selectf(
|
|
|
|
em, op, "verts.out", false,
|
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
|
|
|
"create_grid x_segments=%i y_segments=%i size=%f matrix=%m4 calc_uvs=%b",
|
2013-07-25 07:00:07 +00:00
|
|
|
RNA_int_get(op->ptr, "x_subdivisions"),
|
|
|
|
RNA_int_get(op->ptr, "y_subdivisions"),
|
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
|
|
|
RNA_float_get(op->ptr, "radius"), mat, calc_uvs))
|
2010-02-18 10:09:52 +00:00
|
|
|
{
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
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 12:59:09 +00:00
|
|
|
|
2013-04-15 04:34:14 +00:00
|
|
|
make_prim_finish(C, obedit, was_editmode, 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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MESH_OT_primitive_grid_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Grid";
|
|
|
|
ot->description = "Construct a grid mesh";
|
|
|
|
ot->idname = "MESH_OT_primitive_grid_add";
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = add_primitive_grid_exec;
|
|
|
|
ot->poll = ED_operator_scene_editable;
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* flags */
|
2012-03-26 02:56:48 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* props */
|
2015-06-21 16:06:44 +02:00
|
|
|
/* Note that if you use MESH_ADD_VERTS_MAXI for both x and y at the same time you will still reach
|
|
|
|
* impossible values (10^12 vertices or so...). */
|
|
|
|
RNA_def_int(ot->srna, "x_subdivisions", 10, 2, MESH_ADD_VERTS_MAXI, "X Subdivisions", "", 2, 1000);
|
|
|
|
RNA_def_int(ot->srna, "y_subdivisions", 10, 2, MESH_ADD_VERTS_MAXI, "Y Subdivisions", "", 2, 1000);
|
2013-09-16 00:18:09 +00:00
|
|
|
ED_object_add_unit_props(ot);
|
2010-01-28 00:45:30 +00: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
|
|
|
ED_object_add_mesh_props(ot);
|
2013-03-19 23:17:44 +00:00
|
|
|
ED_object_add_generic_props(ot, true);
|
2010-01-28 00:45:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int add_primitive_monkey_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2010-02-18 10:09:52 +00:00
|
|
|
Object *obedit;
|
|
|
|
BMEditMesh *em;
|
2015-02-10 03:00:37 +11:00
|
|
|
float mat[4][4];
|
2015-02-10 02:38:21 +11:00
|
|
|
float loc[3], rot[3];
|
|
|
|
float dia;
|
2013-04-15 04:34:14 +00:00
|
|
|
bool enter_editmode;
|
2011-03-25 00:32:38 +00:00
|
|
|
unsigned int layer;
|
2013-04-15 04:34:14 +00:00
|
|
|
bool was_editmode;
|
2016-09-24 16:08:10 +02:00
|
|
|
const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs");
|
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 12:59:09 +00:00
|
|
|
|
2013-09-16 04:19:48 +00:00
|
|
|
WM_operator_view3d_unit_defaults(C, op);
|
2014-01-16 23:50:35 +11:00
|
|
|
ED_object_add_generic_get_opts(C, op, 'Y', 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 12:59:09 +00:00
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Suzanne"), &dia, mat, &was_editmode, loc, rot, layer);
|
2013-05-28 23:07:16 +00:00
|
|
|
dia = RNA_float_get(op->ptr, "radius");
|
2015-02-10 03:00:37 +11:00
|
|
|
mul_mat3_m4_fl(mat, dia);
|
2012-10-19 12:53:03 +00:00
|
|
|
|
2013-04-16 05:59:48 +00:00
|
|
|
em = BKE_editmesh_from_object(obedit);
|
2010-01-28 00:45:30 +00:00
|
|
|
|
2016-09-24 16:08:10 +02:00
|
|
|
if (calc_uvs) {
|
|
|
|
ED_mesh_uv_texture_ensure(obedit->data, NULL);
|
|
|
|
}
|
|
|
|
|
2013-07-25 07:00:07 +00:00
|
|
|
if (!EDBM_op_call_and_selectf(
|
|
|
|
em, op, "verts.out", false,
|
2016-09-24 16:08:10 +02:00
|
|
|
"create_monkey matrix=%m4 calc_uvs=%b", mat, calc_uvs))
|
2013-07-25 07:00:07 +00:00
|
|
|
{
|
2010-02-18 10:09:52 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
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 12:59:09 +00:00
|
|
|
|
2013-04-15 04:34:14 +00:00
|
|
|
make_prim_finish(C, obedit, was_editmode, 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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MESH_OT_primitive_monkey_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Monkey";
|
|
|
|
ot->description = "Construct a Suzanne mesh";
|
|
|
|
ot->idname = "MESH_OT_primitive_monkey_add";
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = add_primitive_monkey_exec;
|
|
|
|
ot->poll = ED_operator_scene_editable;
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* flags */
|
2013-09-16 00:18:09 +00:00
|
|
|
ED_object_add_unit_props(ot);
|
2012-03-26 02:56:48 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2010-01-28 00:45:30 +00:00
|
|
|
|
2016-09-24 16:08:10 +02:00
|
|
|
/* props */
|
|
|
|
ED_object_add_mesh_props(ot);
|
2013-03-19 23:17:44 +00:00
|
|
|
ED_object_add_generic_props(ot, true);
|
2010-01-28 00:45:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
Object *obedit;
|
|
|
|
BMEditMesh *em;
|
|
|
|
float loc[3], rot[3], mat[4][4], dia;
|
2013-04-15 04:34:14 +00:00
|
|
|
bool enter_editmode;
|
|
|
|
bool was_editmode;
|
2011-03-25 00:32:38 +00:00
|
|
|
unsigned int layer;
|
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
|
|
|
const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs");
|
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 12:59:09 +00:00
|
|
|
|
2013-09-16 04:19:48 +00:00
|
|
|
WM_operator_view3d_unit_defaults(C, op);
|
2014-01-16 23:50:35 +11:00
|
|
|
ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &layer, NULL);
|
2015-08-16 17:32:01 +10:00
|
|
|
obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Sphere"), &dia, mat, &was_editmode, loc, rot, layer);
|
2013-04-16 05:59:48 +00:00
|
|
|
em = BKE_editmesh_from_object(obedit);
|
2010-01-28 00:45:30 +00:00
|
|
|
|
2015-12-06 11:17:17 +11:00
|
|
|
if (calc_uvs) {
|
|
|
|
ED_mesh_uv_texture_ensure(obedit->data, NULL);
|
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
|
|
|
}
|
|
|
|
|
2013-07-25 07:00:07 +00:00
|
|
|
if (!EDBM_op_call_and_selectf(
|
|
|
|
em, op, "verts.out", false,
|
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
|
|
|
"create_uvsphere u_segments=%i v_segments=%i diameter=%f matrix=%m4 calc_uvs=%b",
|
2013-07-25 07:00:07 +00:00
|
|
|
RNA_int_get(op->ptr, "segments"), RNA_int_get(op->ptr, "ring_count"),
|
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
|
|
|
RNA_float_get(op->ptr, "size"), mat, calc_uvs))
|
2012-02-20 01:52:35 +00:00
|
|
|
{
|
2010-01-28 00:45:30 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2012-02-20 01:52:35 +00: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 12:59:09 +00:00
|
|
|
|
2013-04-15 04:34:14 +00:00
|
|
|
make_prim_finish(C, obedit, was_editmode, enter_editmode);
|
2010-01-28 00:45:30 +00:00
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2010-01-28 00:45:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MESH_OT_primitive_uv_sphere_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add UV Sphere";
|
|
|
|
ot->description = "Construct a UV sphere mesh";
|
|
|
|
ot->idname = "MESH_OT_primitive_uv_sphere_add";
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = add_primitive_uvsphere_exec;
|
|
|
|
ot->poll = ED_operator_scene_editable;
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* flags */
|
2012-03-26 02:56:48 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* props */
|
2015-06-21 16:06:44 +02:00
|
|
|
RNA_def_int(ot->srna, "segments", 32, 3, MESH_ADD_VERTS_MAXI / 100, "Segments", "", 3, 500);
|
|
|
|
RNA_def_int(ot->srna, "ring_count", 16, 3, MESH_ADD_VERTS_MAXI / 100, "Rings", "", 3, 500);
|
2015-12-01 00:58:09 +01:00
|
|
|
RNA_def_float_distance(ot->srna, "size", 1.0f, 0.0, OBJECT_ADD_SIZE_MAXF, "Size", "", 0.001, 100.00);
|
2010-01-28 00:45:30 +00: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
|
|
|
ED_object_add_mesh_props(ot);
|
2013-03-19 23:17:44 +00:00
|
|
|
ED_object_add_generic_props(ot, true);
|
2010-01-28 00:45:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int add_primitive_icosphere_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2010-02-18 10:09:52 +00:00
|
|
|
Object *obedit;
|
|
|
|
BMEditMesh *em;
|
|
|
|
float loc[3], rot[3], mat[4][4], dia;
|
2013-04-15 04:34:14 +00:00
|
|
|
bool enter_editmode;
|
|
|
|
bool was_editmode;
|
2011-03-25 00:32:38 +00:00
|
|
|
unsigned int layer;
|
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
|
|
|
const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs");
|
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 12:59:09 +00:00
|
|
|
|
2013-09-16 04:19:48 +00:00
|
|
|
WM_operator_view3d_unit_defaults(C, op);
|
2014-01-16 23:50:35 +11:00
|
|
|
ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &layer, NULL);
|
2015-08-16 17:32:01 +10:00
|
|
|
obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Icosphere"), &dia, mat, &was_editmode, loc, rot, layer);
|
2013-04-16 05:59:48 +00:00
|
|
|
em = BKE_editmesh_from_object(obedit);
|
2010-02-18 10:09:52 +00:00
|
|
|
|
2015-12-06 11:17:17 +11:00
|
|
|
if (calc_uvs) {
|
|
|
|
ED_mesh_uv_texture_ensure(obedit->data, NULL);
|
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
|
|
|
}
|
|
|
|
|
2012-03-27 04:46:52 +00:00
|
|
|
if (!EDBM_op_call_and_selectf(
|
2013-07-25 07:00:07 +00:00
|
|
|
em, op, "verts.out", false,
|
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
|
|
|
"create_icosphere subdivisions=%i diameter=%f matrix=%m4 calc_uvs=%b",
|
2012-02-20 01:52:35 +00:00
|
|
|
RNA_int_get(op->ptr, "subdivisions"),
|
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
|
|
|
RNA_float_get(op->ptr, "size"), mat, calc_uvs))
|
2012-02-20 01:52:35 +00:00
|
|
|
{
|
2010-02-18 10:09:52 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
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 12:59:09 +00:00
|
|
|
|
2013-04-15 04:34:14 +00:00
|
|
|
make_prim_finish(C, obedit, was_editmode, enter_editmode);
|
2010-01-28 00:45:30 +00: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 12:59:09 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2010-01-28 00:45:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MESH_OT_primitive_ico_sphere_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Ico Sphere";
|
|
|
|
ot->description = "Construct an Icosphere mesh";
|
|
|
|
ot->idname = "MESH_OT_primitive_ico_sphere_add";
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = add_primitive_icosphere_exec;
|
|
|
|
ot->poll = ED_operator_scene_editable;
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* flags */
|
2012-03-26 02:56:48 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
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 12:59:09 +00:00
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
/* props */
|
2015-06-21 16:06:44 +02:00
|
|
|
RNA_def_int(ot->srna, "subdivisions", 2, 1, 10, "Subdivisions", "", 1, 8);
|
2015-12-01 00:58:09 +01:00
|
|
|
RNA_def_float_distance(ot->srna, "size", 1.0f, 0.0f, OBJECT_ADD_SIZE_MAXF, "Size", "", 0.001f, 100.00);
|
2010-01-28 00:45:30 +00: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
|
|
|
ED_object_add_mesh_props(ot);
|
2013-03-19 23:17:44 +00:00
|
|
|
ED_object_add_generic_props(ot, true);
|
2010-01-28 00:45:30 +00:00
|
|
|
}
|