2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-07-01 22:25:49 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-07-01 22:25:49 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/mesh/mesh_data.c
|
|
|
|
* \ingroup edmesh
|
|
|
|
*/
|
|
|
|
|
2009-07-01 22:25:49 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2012-02-19 22:17:30 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
2009-07-01 22:25:49 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
2009-11-10 19:54:59 +00:00
|
|
|
#include "DNA_view3d_types.h"
|
2009-07-01 22:25:49 +00:00
|
|
|
|
2013-03-04 18:36:37 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2012-09-03 22:04:14 +00:00
|
|
|
#include "BLI_path_util.h"
|
2011-11-17 05:03:07 +00:00
|
|
|
#include "BLI_array.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_math.h"
|
|
|
|
|
2009-07-01 22:25:49 +00:00
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_depsgraph.h"
|
2010-05-09 18:07:17 +00:00
|
|
|
#include "BKE_image.h"
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
#include "BKE_library.h"
|
2011-11-08 13:07:16 +00:00
|
|
|
#include "BKE_main.h"
|
2009-07-01 22:25:49 +00:00
|
|
|
#include "BKE_mesh.h"
|
2009-09-28 14:28:45 +00:00
|
|
|
#include "BKE_report.h"
|
2013-04-13 20:31:52 +00:00
|
|
|
#include "BKE_editmesh.h"
|
2009-07-01 22:25:49 +00:00
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "ED_mesh.h"
|
2009-08-15 20:36:15 +00:00
|
|
|
#include "ED_object.h"
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
#include "ED_uvedit.h"
|
2009-07-01 22:25:49 +00:00
|
|
|
#include "ED_view3d.h"
|
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
#include "mesh_intern.h" /* own include */
|
2009-07-01 22:25:49 +00:00
|
|
|
|
2012-12-19 04:49:32 +00:00
|
|
|
|
2012-09-21 03:41:59 +00:00
|
|
|
static CustomData *mesh_customdata_get_type(Mesh *me, const char htype, int *r_tot)
|
|
|
|
{
|
|
|
|
CustomData *data;
|
|
|
|
BMesh *bm = (me->edit_btmesh) ? me->edit_btmesh->bm : NULL;
|
|
|
|
int tot;
|
|
|
|
|
|
|
|
/* this */
|
|
|
|
switch (htype) {
|
|
|
|
case BM_VERT:
|
|
|
|
if (bm) {
|
|
|
|
data = &bm->vdata;
|
|
|
|
tot = bm->totvert;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
data = &me->vdata;
|
|
|
|
tot = me->totvert;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BM_EDGE:
|
|
|
|
if (bm) {
|
|
|
|
data = &bm->edata;
|
|
|
|
tot = bm->totedge;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
data = &me->edata;
|
|
|
|
tot = me->totedge;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BM_LOOP:
|
|
|
|
if (bm) {
|
|
|
|
data = &bm->ldata;
|
|
|
|
tot = bm->totloop;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
data = &me->ldata;
|
|
|
|
tot = me->totloop;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BM_FACE:
|
|
|
|
if (bm) {
|
|
|
|
data = &bm->pdata;
|
|
|
|
tot = bm->totface;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
data = &me->pdata;
|
|
|
|
tot = me->totpoly;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BLI_assert(0);
|
|
|
|
tot = 0;
|
|
|
|
data = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*r_tot = tot;
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2011-07-25 09:53:36 +00:00
|
|
|
#define GET_CD_DATA(me, data) (me->edit_btmesh ? &me->edit_btmesh->bm->data : &me->data)
|
2013-03-21 20:15:39 +00:00
|
|
|
static void delete_customdata_layer(Mesh *me, CustomDataLayer *layer)
|
2009-07-01 22:25:49 +00:00
|
|
|
{
|
2011-07-25 09:53:36 +00:00
|
|
|
CustomData *data;
|
2012-03-26 02:56:48 +00:00
|
|
|
void *actlayerdata, *rndlayerdata, *clonelayerdata, *stencillayerdata, *layerdata = layer->data;
|
|
|
|
int type = layer->type;
|
2011-07-25 09:53:36 +00:00
|
|
|
int index;
|
|
|
|
int i, actindex, rndindex, cloneindex, stencilindex, tot;
|
2012-03-24 11:02:28 +00:00
|
|
|
|
2011-07-25 09:53:36 +00:00
|
|
|
if (layer->type == CD_MLOOPCOL || layer->type == CD_MLOOPUV) {
|
2012-09-21 06:37:42 +00:00
|
|
|
data = mesh_customdata_get_type(me, BM_LOOP, &tot);
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-09-21 06:37:42 +00:00
|
|
|
data = mesh_customdata_get_type(me, BM_FACE, &tot);
|
2011-07-25 09:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
index = CustomData_get_layer_index(data, type);
|
|
|
|
|
2009-07-01 22:25:49 +00:00
|
|
|
/* ok, deleting a non-active layer needs to preserve the active layer indices.
|
2012-03-03 16:31:46 +00:00
|
|
|
* to do this, we store a pointer to the .data member of both layer and the active layer,
|
|
|
|
* (to detect if we're deleting the active layer or not), then use the active
|
|
|
|
* layer data pointer to find where the active layer has ended up.
|
|
|
|
*
|
|
|
|
* this is necessary because the deletion functions only support deleting the active
|
|
|
|
* layer. */
|
2009-07-01 22:25:49 +00:00
|
|
|
actlayerdata = data->layers[CustomData_get_active_layer_index(data, type)].data;
|
|
|
|
rndlayerdata = data->layers[CustomData_get_render_layer_index(data, type)].data;
|
|
|
|
clonelayerdata = data->layers[CustomData_get_clone_layer_index(data, type)].data;
|
2009-12-22 10:48:13 +00:00
|
|
|
stencillayerdata = data->layers[CustomData_get_stencil_layer_index(data, type)].data;
|
2009-07-01 22:25:49 +00:00
|
|
|
CustomData_set_layer_active(data, type, layer - &data->layers[index]);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (me->edit_btmesh) {
|
2012-02-12 10:51:45 +00:00
|
|
|
BM_data_layer_free(me->edit_btmesh->bm, data, type);
|
2009-07-01 22:25:49 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-07-25 09:53:36 +00:00
|
|
|
CustomData_free_layer_active(data, type, tot);
|
2013-03-17 19:55:10 +00:00
|
|
|
BKE_mesh_update_customdata_pointers(me, true);
|
2009-07-01 22:25:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* reconstruct active layer */
|
|
|
|
if (actlayerdata != layerdata) {
|
|
|
|
/* find index */
|
|
|
|
actindex = CustomData_get_layer_index(data, type);
|
2012-03-26 02:56:48 +00:00
|
|
|
for (i = actindex; i < data->totlayer; i++) {
|
2009-07-01 22:25:49 +00:00
|
|
|
if (data->layers[i].data == actlayerdata) {
|
|
|
|
actindex = i - actindex;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set index */
|
|
|
|
CustomData_set_layer_active(data, type, actindex);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rndlayerdata != layerdata) {
|
|
|
|
/* find index */
|
|
|
|
rndindex = CustomData_get_layer_index(data, type);
|
2012-03-26 02:56:48 +00:00
|
|
|
for (i = rndindex; i < data->totlayer; i++) {
|
2009-07-01 22:25:49 +00:00
|
|
|
if (data->layers[i].data == rndlayerdata) {
|
|
|
|
rndindex = i - rndindex;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set index */
|
|
|
|
CustomData_set_layer_render(data, type, rndindex);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (clonelayerdata != layerdata) {
|
|
|
|
/* find index */
|
|
|
|
cloneindex = CustomData_get_layer_index(data, type);
|
2012-03-26 02:56:48 +00:00
|
|
|
for (i = cloneindex; i < data->totlayer; i++) {
|
2009-07-01 22:25:49 +00:00
|
|
|
if (data->layers[i].data == clonelayerdata) {
|
|
|
|
cloneindex = i - cloneindex;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set index */
|
|
|
|
CustomData_set_layer_clone(data, type, cloneindex);
|
|
|
|
}
|
|
|
|
|
2009-12-22 10:48:13 +00:00
|
|
|
if (stencillayerdata != layerdata) {
|
2009-07-01 22:25:49 +00:00
|
|
|
/* find index */
|
2009-12-22 10:48:13 +00:00
|
|
|
stencilindex = CustomData_get_layer_index(data, type);
|
2012-03-26 02:56:48 +00:00
|
|
|
for (i = stencilindex; i < data->totlayer; i++) {
|
2009-12-22 10:48:13 +00:00
|
|
|
if (data->layers[i].data == stencillayerdata) {
|
|
|
|
stencilindex = i - stencilindex;
|
2009-07-01 22:25:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set index */
|
2009-12-22 10:48:13 +00:00
|
|
|
CustomData_set_layer_stencil(data, type, stencilindex);
|
2009-07-01 22:25:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-10 08:08:18 +00:00
|
|
|
static void mesh_uv_reset_array(float **fuv, const int len)
|
2011-11-17 05:03:07 +00:00
|
|
|
{
|
2013-05-10 08:08:18 +00:00
|
|
|
if (len == 3) {
|
|
|
|
fuv[0][0] = 0.0;
|
|
|
|
fuv[0][1] = 0.0;
|
2011-11-17 05:03:07 +00:00
|
|
|
|
2013-05-10 08:08:18 +00:00
|
|
|
fuv[1][0] = 1.0;
|
|
|
|
fuv[1][1] = 0.0;
|
2011-11-17 05:03:07 +00:00
|
|
|
|
2013-05-10 08:08:18 +00:00
|
|
|
fuv[2][0] = 1.0;
|
|
|
|
fuv[2][1] = 1.0;
|
|
|
|
}
|
|
|
|
else if (len == 4) {
|
|
|
|
fuv[0][0] = 0.0;
|
|
|
|
fuv[0][1] = 0.0;
|
2011-11-17 05:03:07 +00:00
|
|
|
|
2013-05-10 08:08:18 +00:00
|
|
|
fuv[1][0] = 1.0;
|
|
|
|
fuv[1][1] = 0.0;
|
2011-11-17 05:03:07 +00:00
|
|
|
|
2013-05-10 08:08:18 +00:00
|
|
|
fuv[2][0] = 1.0;
|
|
|
|
fuv[2][1] = 1.0;
|
2011-11-17 05:03:07 +00:00
|
|
|
|
2013-05-10 08:08:18 +00:00
|
|
|
fuv[3][0] = 0.0;
|
|
|
|
fuv[3][1] = 1.0;
|
|
|
|
/*make sure we ignore 2-sided faces*/
|
|
|
|
}
|
|
|
|
else if (len > 2) {
|
|
|
|
float fac = 0.0f, dfac = 1.0f / (float)len;
|
|
|
|
int i;
|
2011-11-17 05:03:07 +00:00
|
|
|
|
2013-05-10 08:08:18 +00:00
|
|
|
dfac *= (float)M_PI * 2.0f;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
fuv[i][0] = 0.5f * sinf(fac) + 0.5f;
|
|
|
|
fuv[i][1] = 0.5f * cosf(fac) + 0.5f;
|
|
|
|
|
|
|
|
fac += dfac;
|
2011-11-17 05:03:07 +00:00
|
|
|
}
|
|
|
|
}
|
2013-05-10 08:08:18 +00:00
|
|
|
}
|
2011-11-17 05:03:07 +00:00
|
|
|
|
2013-05-10 08:08:18 +00:00
|
|
|
static void mesh_uv_reset_bmface(BMFace *f, const int cd_loop_uv_offset)
|
|
|
|
{
|
|
|
|
float **fuv = BLI_array_alloca(fuv, f->len);
|
|
|
|
BMIter liter;
|
|
|
|
BMLoop *l;
|
|
|
|
int i;
|
2011-11-17 05:03:07 +00:00
|
|
|
|
2013-05-10 08:08:18 +00:00
|
|
|
BM_ITER_ELEM_INDEX (l, &liter, f, BM_LOOPS_OF_FACE, i) {
|
|
|
|
fuv[i] = ((MLoopUV *)BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset))->uv;
|
|
|
|
}
|
2011-11-17 05:03:07 +00:00
|
|
|
|
2013-05-10 08:08:18 +00:00
|
|
|
mesh_uv_reset_array(fuv, f->len);
|
|
|
|
}
|
2011-11-17 05:03:07 +00:00
|
|
|
|
2013-05-10 08:08:18 +00:00
|
|
|
static void mesh_uv_reset_mface(MPoly *mp, MLoopUV *mloopuv)
|
|
|
|
{
|
|
|
|
float **fuv = BLI_array_alloca(fuv, mp->totloop);
|
|
|
|
int i;
|
2011-11-17 05:03:07 +00:00
|
|
|
|
2013-05-10 08:08:18 +00:00
|
|
|
for (i = 0; i < mp->totloop; i++) {
|
|
|
|
fuv[i] = mloopuv[mp->loopstart + i].uv;
|
2011-11-17 05:03:07 +00:00
|
|
|
}
|
|
|
|
|
2013-05-10 08:08:18 +00:00
|
|
|
mesh_uv_reset_array(fuv, mp->totloop);
|
|
|
|
}
|
2011-11-17 05:03:07 +00:00
|
|
|
|
2013-05-10 08:08:18 +00:00
|
|
|
/* without bContext, called in uvedit */
|
|
|
|
void ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum)
|
|
|
|
{
|
|
|
|
BMEditMesh *em = me->edit_btmesh;
|
2011-11-17 05:03:07 +00:00
|
|
|
|
2013-05-10 08:08:18 +00:00
|
|
|
if (em) {
|
|
|
|
/* Collect BMesh UVs */
|
|
|
|
const int cd_loop_uv_offset = CustomData_get_n_offset(&em->bm->ldata, CD_MLOOPUV, layernum);
|
2011-11-17 05:03:07 +00:00
|
|
|
|
2013-05-10 08:08:18 +00:00
|
|
|
BMFace *efa;
|
|
|
|
BMIter iter;
|
2011-11-17 05:03:07 +00:00
|
|
|
|
2013-05-10 08:08:18 +00:00
|
|
|
BLI_assert(cd_loop_uv_offset != -1);
|
2011-11-17 05:03:07 +00:00
|
|
|
|
2013-05-10 08:08:18 +00:00
|
|
|
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
|
|
|
|
if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
|
|
|
|
continue;
|
2011-11-17 05:03:07 +00:00
|
|
|
|
2013-05-10 08:08:18 +00:00
|
|
|
mesh_uv_reset_bmface(efa, cd_loop_uv_offset);
|
|
|
|
}
|
2011-11-17 05:03:07 +00:00
|
|
|
}
|
2013-05-10 08:08:18 +00:00
|
|
|
else {
|
|
|
|
/* Collect Mesh UVs */
|
|
|
|
MLoopUV *mloopuv;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
BLI_assert(CustomData_has_layer(&me->ldata, CD_MLOOPUV));
|
|
|
|
mloopuv = CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, layernum);
|
2011-11-17 05:03:07 +00:00
|
|
|
|
2013-05-10 08:08:18 +00:00
|
|
|
for (i = 0; i < me->totpoly; i++) {
|
|
|
|
mesh_uv_reset_mface(&me->mpoly[i], mloopuv);
|
|
|
|
}
|
|
|
|
}
|
2011-11-17 05:03:07 +00:00
|
|
|
|
|
|
|
DAG_id_tag_update(&me->id, 0);
|
|
|
|
}
|
|
|
|
|
2013-04-05 14:58:30 +00:00
|
|
|
void ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me)
|
2012-03-26 02:39:05 +00:00
|
|
|
{
|
|
|
|
/* could be ldata or pdata */
|
|
|
|
CustomData *pdata = GET_CD_DATA(me, pdata);
|
|
|
|
const int layernum = CustomData_get_active_layer_index(pdata, CD_MTEXPOLY);
|
2013-04-05 14:58:30 +00:00
|
|
|
ED_mesh_uv_loop_reset_ex(me, layernum);
|
2012-11-03 14:31:28 +00:00
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
|
2012-03-26 02:39:05 +00:00
|
|
|
}
|
|
|
|
|
2012-03-26 05:28:00 +00:00
|
|
|
/* note: keep in sync with ED_mesh_color_add */
|
2013-03-21 20:54:48 +00:00
|
|
|
int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set)
|
2009-09-28 14:28:45 +00:00
|
|
|
{
|
2011-07-25 09:53:36 +00:00
|
|
|
BMEditMesh *em;
|
2012-05-22 12:03:56 +00:00
|
|
|
int layernum_dst;
|
2009-07-01 22:25:49 +00:00
|
|
|
|
2013-03-19 23:17:44 +00:00
|
|
|
bool is_init = false;
|
2012-03-26 05:28:00 +00:00
|
|
|
|
2011-11-20 16:21:13 +00:00
|
|
|
if (me->edit_btmesh) {
|
2012-03-26 02:56:48 +00:00
|
|
|
em = me->edit_btmesh;
|
2009-09-28 14:28:45 +00:00
|
|
|
|
2012-05-22 12:03:56 +00:00
|
|
|
layernum_dst = CustomData_number_of_layers(&em->bm->pdata, CD_MTEXPOLY);
|
|
|
|
if (layernum_dst >= MAX_MTFACE)
|
2012-02-01 18:25:13 +00:00
|
|
|
return -1;
|
2009-09-28 14:28:45 +00:00
|
|
|
|
2012-03-26 05:28:00 +00:00
|
|
|
/* CD_MTEXPOLY */
|
|
|
|
BM_data_layer_add_named(em->bm, &em->bm->pdata, CD_MTEXPOLY, name);
|
2011-11-20 16:21:13 +00:00
|
|
|
/* copy data from active UV */
|
2012-05-22 12:03:56 +00:00
|
|
|
if (layernum_dst) {
|
|
|
|
const int layernum_src = CustomData_get_active_layer(&em->bm->pdata, CD_MTEXPOLY);
|
|
|
|
BM_data_layer_copy(em->bm, &em->bm->pdata, CD_MTEXPOLY, layernum_src, layernum_dst);
|
2012-03-26 05:28:00 +00:00
|
|
|
}
|
2012-05-22 12:03:56 +00:00
|
|
|
if (active_set || layernum_dst == 0) {
|
|
|
|
CustomData_set_layer_active(&em->bm->pdata, CD_MTEXPOLY, layernum_dst);
|
2011-11-20 16:21:13 +00:00
|
|
|
}
|
2011-07-25 09:53:36 +00:00
|
|
|
|
2012-03-26 05:28:00 +00:00
|
|
|
/* CD_MLOOPUV */
|
|
|
|
BM_data_layer_add_named(em->bm, &em->bm->ldata, CD_MLOOPUV, name);
|
|
|
|
/* copy data from active UV */
|
2012-05-22 12:03:56 +00:00
|
|
|
if (layernum_dst) {
|
|
|
|
const int layernum_src = CustomData_get_active_layer(&em->bm->ldata, CD_MLOOPUV);
|
|
|
|
BM_data_layer_copy(em->bm, &em->bm->ldata, CD_MLOOPUV, layernum_src, layernum_dst);
|
2012-04-30 18:54:14 +00:00
|
|
|
|
2013-03-19 23:17:44 +00:00
|
|
|
is_init = true;
|
2012-03-26 05:28:00 +00:00
|
|
|
}
|
2012-05-22 12:03:56 +00:00
|
|
|
if (active_set || layernum_dst == 0) {
|
|
|
|
CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPUV, layernum_dst);
|
2011-11-20 16:21:13 +00:00
|
|
|
}
|
2009-09-28 14:28:45 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-05-22 12:03:56 +00:00
|
|
|
layernum_dst = CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY);
|
|
|
|
if (layernum_dst >= MAX_MTFACE)
|
2012-02-01 18:25:13 +00:00
|
|
|
return -1;
|
2009-09-28 14:28:45 +00:00
|
|
|
|
2011-11-20 16:21:13 +00:00
|
|
|
if (me->mtpoly) {
|
2011-07-25 09:53:36 +00:00
|
|
|
CustomData_add_layer_named(&me->pdata, CD_MTEXPOLY, CD_DUPLICATE, me->mtpoly, me->totpoly, name);
|
|
|
|
CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DUPLICATE, me->mloopuv, me->totloop, name);
|
2011-11-17 05:03:07 +00:00
|
|
|
CustomData_add_layer_named(&me->fdata, CD_MTFACE, CD_DUPLICATE, me->mtface, me->totface, name);
|
2013-03-19 23:17:44 +00:00
|
|
|
is_init = true;
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-07-25 09:53:36 +00:00
|
|
|
CustomData_add_layer_named(&me->pdata, CD_MTEXPOLY, CD_DEFAULT, NULL, me->totpoly, name);
|
|
|
|
CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, me->totloop, name);
|
2011-11-17 05:03:07 +00:00
|
|
|
CustomData_add_layer_named(&me->fdata, CD_MTFACE, CD_DEFAULT, NULL, me->totface, name);
|
2011-07-25 09:53:36 +00:00
|
|
|
}
|
|
|
|
|
2012-05-22 12:03:56 +00:00
|
|
|
if (active_set || layernum_dst == 0) {
|
|
|
|
CustomData_set_layer_active(&me->pdata, CD_MTEXPOLY, layernum_dst);
|
|
|
|
CustomData_set_layer_active(&me->ldata, CD_MLOOPUV, layernum_dst);
|
2011-11-17 05:03:07 +00:00
|
|
|
|
2012-05-22 12:03:56 +00:00
|
|
|
CustomData_set_layer_active(&me->fdata, CD_MTFACE, layernum_dst);
|
2011-07-25 09:53:36 +00:00
|
|
|
}
|
2011-09-01 09:11:00 +00:00
|
|
|
|
2013-03-17 19:55:10 +00:00
|
|
|
BKE_mesh_update_customdata_pointers(me, true);
|
2009-09-28 14:28:45 +00:00
|
|
|
}
|
|
|
|
|
2012-03-26 05:28:00 +00:00
|
|
|
/* don't overwrite our copied coords */
|
2013-03-19 23:17:44 +00:00
|
|
|
if (is_init == false) {
|
2012-11-03 14:31:28 +00:00
|
|
|
ED_mesh_uv_loop_reset_ex(me, layernum_dst);
|
2012-03-26 05:28:00 +00:00
|
|
|
}
|
2011-11-17 05:03:07 +00:00
|
|
|
|
2011-01-03 12:41:16 +00:00
|
|
|
DAG_id_tag_update(&me->id, 0);
|
2013-03-21 20:54:48 +00:00
|
|
|
WM_main_add_notifier(NC_GEOM | ND_DATA, me);
|
2009-09-28 14:28:45 +00:00
|
|
|
|
2012-05-22 12:03:56 +00:00
|
|
|
return layernum_dst;
|
2009-09-28 14:28:45 +00:00
|
|
|
}
|
|
|
|
|
2013-03-21 20:54:48 +00:00
|
|
|
bool ED_mesh_uv_texture_remove_index(Mesh *me, const int n)
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
{
|
2011-07-25 09:53:36 +00:00
|
|
|
CustomData *pdata = GET_CD_DATA(me, pdata), *ldata = GET_CD_DATA(me, ldata);
|
|
|
|
CustomDataLayer *cdlp, *cdlu;
|
2009-09-28 14:28:45 +00:00
|
|
|
int index;
|
|
|
|
|
2013-03-21 20:54:48 +00:00
|
|
|
index = CustomData_get_layer_index_n(pdata, CD_MTEXPOLY, n);
|
2012-03-26 02:56:48 +00:00
|
|
|
cdlp = (index == -1) ? NULL : &pdata->layers[index];
|
2009-09-28 14:28:45 +00:00
|
|
|
|
2013-03-21 20:54:48 +00:00
|
|
|
index = CustomData_get_layer_index_n(ldata, CD_MLOOPUV, n);
|
2012-03-26 02:56:48 +00:00
|
|
|
cdlu = (index == -1) ? NULL : &ldata->layers[index];
|
2013-03-21 20:54:48 +00:00
|
|
|
|
2011-07-25 09:53:36 +00:00
|
|
|
if (!cdlp || !cdlu)
|
2013-03-21 20:54:48 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
delete_customdata_layer(me, cdlp);
|
|
|
|
delete_customdata_layer(me, cdlu);
|
2009-09-28 14:28:45 +00:00
|
|
|
|
2011-01-03 12:41:16 +00:00
|
|
|
DAG_id_tag_update(&me->id, 0);
|
2013-03-21 20:54:48 +00:00
|
|
|
WM_main_add_notifier(NC_GEOM | ND_DATA, me);
|
2009-09-28 14:28:45 +00:00
|
|
|
|
2013-03-21 20:54:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool ED_mesh_uv_texture_remove_active(Mesh *me)
|
|
|
|
{
|
|
|
|
/* texpoly/uv are assumed to be in sync */
|
|
|
|
CustomData *pdata = GET_CD_DATA(me, pdata);
|
|
|
|
const int n = CustomData_get_active_layer(pdata, CD_MTEXPOLY);
|
|
|
|
|
|
|
|
/* double check active layers align! */
|
|
|
|
#ifdef DEBUG
|
|
|
|
CustomData *ldata = GET_CD_DATA(me, ldata);
|
|
|
|
BLI_assert(CustomData_get_active_layer(ldata, CD_MLOOPUV) == n);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (n != -1) {
|
|
|
|
return ED_mesh_uv_texture_remove_index(me, n);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool ED_mesh_uv_texture_remove_named(Mesh *me, const char *name)
|
|
|
|
{
|
|
|
|
/* texpoly/uv are assumed to be in sync */
|
|
|
|
CustomData *pdata = GET_CD_DATA(me, pdata);
|
|
|
|
const int n = CustomData_get_named_layer(pdata, CD_MTEXPOLY, name);
|
|
|
|
if (n != -1) {
|
|
|
|
return ED_mesh_uv_texture_remove_index(me, n);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
}
|
|
|
|
|
2012-03-26 05:28:00 +00:00
|
|
|
/* note: keep in sync with ED_mesh_uv_texture_add */
|
2013-03-21 20:54:48 +00:00
|
|
|
int ED_mesh_color_add(Mesh *me, const char *name, const bool active_set)
|
2009-07-01 22:25:49 +00:00
|
|
|
{
|
2011-07-25 09:53:36 +00:00
|
|
|
BMEditMesh *em;
|
2009-07-01 22:25:49 +00:00
|
|
|
int layernum;
|
|
|
|
|
2011-11-20 16:21:13 +00:00
|
|
|
if (me->edit_btmesh) {
|
2012-03-26 02:56:48 +00:00
|
|
|
em = me->edit_btmesh;
|
2009-07-01 22:25:49 +00:00
|
|
|
|
2012-03-26 02:56:48 +00:00
|
|
|
layernum = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPCOL);
|
2011-11-20 16:21:13 +00:00
|
|
|
if (layernum >= MAX_MCOL) {
|
2012-02-01 18:25:13 +00:00
|
|
|
return -1;
|
2011-11-20 16:21:13 +00:00
|
|
|
}
|
2009-07-01 22:25:49 +00:00
|
|
|
|
2012-03-26 05:28:00 +00:00
|
|
|
/* CD_MLOOPCOL */
|
|
|
|
BM_data_layer_add_named(em->bm, &em->bm->ldata, CD_MLOOPCOL, name);
|
2011-11-20 16:21:13 +00:00
|
|
|
/* copy data from active vertex color layer */
|
|
|
|
if (layernum) {
|
2012-04-30 18:54:14 +00:00
|
|
|
const int layernum_dst = CustomData_get_active_layer(&em->bm->ldata, CD_MLOOPCOL);
|
2013-01-10 13:59:52 +00:00
|
|
|
BM_data_layer_copy(em->bm, &em->bm->ldata, CD_MLOOPCOL, layernum, layernum_dst);
|
2011-11-20 16:21:13 +00:00
|
|
|
}
|
|
|
|
if (active_set || layernum == 0) {
|
2011-07-25 09:53:36 +00:00
|
|
|
CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPCOL, layernum);
|
2011-11-20 16:21:13 +00:00
|
|
|
}
|
2009-07-01 22:25:49 +00:00
|
|
|
}
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
else {
|
2012-03-26 02:56:48 +00:00
|
|
|
layernum = CustomData_number_of_layers(&me->ldata, CD_MLOOPCOL);
|
2011-11-20 16:21:13 +00:00
|
|
|
if (layernum >= CD_MLOOPCOL) {
|
2012-02-01 18:25:13 +00:00
|
|
|
return -1;
|
2011-11-20 16:21:13 +00:00
|
|
|
}
|
2009-09-28 14:28:45 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (me->mloopcol) {
|
2011-07-25 09:53:36 +00:00
|
|
|
CustomData_add_layer_named(&me->ldata, CD_MLOOPCOL, CD_DUPLICATE, me->mloopcol, me->totloop, name);
|
2012-03-15 05:40:33 +00:00
|
|
|
CustomData_add_layer_named(&me->fdata, CD_MCOL, CD_DUPLICATE, me->mcol, me->totface, name);
|
2011-11-17 05:03:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-07-25 09:53:36 +00:00
|
|
|
CustomData_add_layer_named(&me->ldata, CD_MLOOPCOL, CD_DEFAULT, NULL, me->totloop, name);
|
2011-11-17 05:03:07 +00:00
|
|
|
CustomData_add_layer_named(&me->fdata, CD_MCOL, CD_DEFAULT, NULL, me->totface, name);
|
|
|
|
}
|
2010-08-23 22:16:45 +00:00
|
|
|
|
2012-03-26 02:56:48 +00:00
|
|
|
if (active_set || layernum == 0) {
|
2011-07-25 09:53:36 +00:00
|
|
|
CustomData_set_layer_active(&me->ldata, CD_MLOOPCOL, layernum);
|
2011-11-17 05:03:07 +00:00
|
|
|
CustomData_set_layer_active(&me->fdata, CD_MCOL, layernum);
|
|
|
|
}
|
2009-07-01 22:25:49 +00:00
|
|
|
|
2013-03-17 19:55:10 +00:00
|
|
|
BKE_mesh_update_customdata_pointers(me, true);
|
2009-07-01 22:25:49 +00:00
|
|
|
}
|
|
|
|
|
2011-01-03 12:41:16 +00:00
|
|
|
DAG_id_tag_update(&me->id, 0);
|
2013-03-21 20:54:48 +00:00
|
|
|
WM_main_add_notifier(NC_GEOM | ND_DATA, me);
|
2009-07-01 22:25:49 +00:00
|
|
|
|
2012-02-01 18:25:13 +00:00
|
|
|
return layernum;
|
2009-09-28 14:28:45 +00:00
|
|
|
}
|
|
|
|
|
2013-03-21 20:15:39 +00:00
|
|
|
bool ED_mesh_color_remove_index(Mesh *me, const int n)
|
2009-09-28 14:28:45 +00:00
|
|
|
{
|
2012-03-24 10:41:42 +00:00
|
|
|
CustomData *ldata = GET_CD_DATA(me, ldata);
|
2009-09-28 14:28:45 +00:00
|
|
|
CustomDataLayer *cdl;
|
|
|
|
int index;
|
|
|
|
|
2013-03-21 20:15:39 +00:00
|
|
|
index = CustomData_get_layer_index_n(ldata, CD_MLOOPCOL, n);
|
2012-03-26 02:56:48 +00:00
|
|
|
cdl = (index == -1) ? NULL : &ldata->layers[index];
|
2009-09-28 14:28:45 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!cdl)
|
2013-03-21 20:15:39 +00:00
|
|
|
return false;
|
2009-09-28 14:28:45 +00:00
|
|
|
|
2013-03-21 20:15:39 +00:00
|
|
|
delete_customdata_layer(me, cdl);
|
2011-01-03 12:41:16 +00:00
|
|
|
DAG_id_tag_update(&me->id, 0);
|
2013-03-21 20:15:39 +00:00
|
|
|
WM_main_add_notifier(NC_GEOM | ND_DATA, me);
|
2009-09-28 14:28:45 +00:00
|
|
|
|
2013-03-21 20:15:39 +00:00
|
|
|
return true;
|
2009-09-28 14:28:45 +00:00
|
|
|
}
|
2013-03-21 20:15:39 +00:00
|
|
|
bool ED_mesh_color_remove_active(Mesh *me)
|
2011-08-03 18:31:48 +00:00
|
|
|
{
|
2012-03-24 10:41:42 +00:00
|
|
|
CustomData *ldata = GET_CD_DATA(me, ldata);
|
2013-03-21 20:15:39 +00:00
|
|
|
const int n = CustomData_get_active_layer(ldata, CD_MLOOPCOL);
|
|
|
|
if (n != -1) {
|
|
|
|
return ED_mesh_color_remove_index(me, n);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool ED_mesh_color_remove_named(Mesh *me, const char *name)
|
|
|
|
{
|
|
|
|
CustomData *ldata = GET_CD_DATA(me, ldata);
|
|
|
|
const int n = CustomData_get_named_layer(ldata, CD_MLOOPCOL, name);
|
|
|
|
if (n != -1) {
|
|
|
|
return ED_mesh_color_remove_index(me, n);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
2011-08-03 18:31:48 +00:00
|
|
|
}
|
|
|
|
|
2009-09-28 14:28:45 +00:00
|
|
|
/*********************** UV texture operators ************************/
|
|
|
|
|
|
|
|
static int layers_poll(bContext *C)
|
|
|
|
{
|
2012-03-26 02:56:48 +00:00
|
|
|
Object *ob = ED_object_context(C);
|
|
|
|
ID *data = (ob) ? ob->data : NULL;
|
|
|
|
return (ob && !ob->id.lib && ob->type == OB_MESH && data && !data->lib);
|
2009-09-28 14:28:45 +00:00
|
|
|
}
|
|
|
|
|
2012-03-23 21:25:07 +00:00
|
|
|
static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-09-28 14:28:45 +00:00
|
|
|
{
|
2012-03-26 02:56:48 +00:00
|
|
|
Object *ob = ED_object_context(C);
|
|
|
|
Mesh *me = ob->data;
|
2009-09-28 14:28:45 +00:00
|
|
|
|
2013-03-21 20:54:48 +00:00
|
|
|
if (ED_mesh_uv_texture_add(me, NULL, true) == -1)
|
2009-09-28 14:28:45 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2009-07-01 22:25:49 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MESH_OT_uv_texture_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add UV Map";
|
|
|
|
ot->description = "Add UV Map";
|
|
|
|
ot->idname = "MESH_OT_uv_texture_add";
|
2009-07-01 22:25:49 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = layers_poll;
|
2012-03-23 21:25:07 +00:00
|
|
|
ot->exec = mesh_uv_texture_add_exec;
|
2009-07-01 22:25:49 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-03-26 02:56:48 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-07-01 22:25:49 +00:00
|
|
|
}
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
{
|
2012-03-26 02:56:48 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
2013-02-05 14:33:55 +00:00
|
|
|
Base *base;
|
2012-03-26 02:56:48 +00:00
|
|
|
Image *ima = NULL;
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
Mesh *me;
|
|
|
|
Object *obedit;
|
2012-03-26 02:56:48 +00:00
|
|
|
int exitmode = 0;
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
|
2013-02-05 14:33:55 +00:00
|
|
|
if (v3d == NULL) {
|
|
|
|
BKE_report(op->reports, RPT_ERROR, "No 3D View Available");
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
base = ED_view3d_give_base_under_cursor(C, event->mval);
|
|
|
|
|
2010-05-10 08:05:31 +00:00
|
|
|
/* Check context */
|
2012-03-26 02:56:48 +00:00
|
|
|
if (base == NULL || base->object->type != OB_MESH) {
|
2012-10-18 16:25:58 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Not an object or mesh");
|
2010-05-10 08:05:31 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
/* check input variables */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
|
2010-05-09 18:07:17 +00:00
|
|
|
char path[FILE_MAX];
|
|
|
|
|
2010-06-14 03:52:10 +00:00
|
|
|
RNA_string_get(op->ptr, "filepath", path);
|
2012-05-05 14:52:04 +00:00
|
|
|
ima = BKE_image_load_exists(path);
|
2010-05-09 18:07:17 +00:00
|
|
|
}
|
|
|
|
else {
|
2013-02-05 14:33:55 +00:00
|
|
|
char name[MAX_ID_NAME - 2];
|
2010-05-09 18:07:17 +00:00
|
|
|
RNA_string_get(op->ptr, "name", name);
|
2012-05-05 17:00:11 +00:00
|
|
|
ima = (Image *)BKE_libblock_find_name(ID_IM, name);
|
2010-05-10 08:05:31 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!ima) {
|
2012-10-18 16:25:58 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Not an image");
|
2010-05-10 08:05:31 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
}
|
|
|
|
|
2011-07-25 09:53:36 +00:00
|
|
|
/* put mesh in editmode */
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
|
2012-03-26 02:56:48 +00:00
|
|
|
obedit = base->object;
|
|
|
|
me = obedit->data;
|
|
|
|
if (me->edit_btmesh == NULL) {
|
2012-03-27 04:46:52 +00:00
|
|
|
EDBM_mesh_make(scene->toolsettings, scene, obedit);
|
2012-03-26 02:56:48 +00:00
|
|
|
exitmode = 1;
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
}
|
2012-03-26 02:56:48 +00:00
|
|
|
if (me->edit_btmesh == NULL)
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2011-11-08 13:07:16 +00:00
|
|
|
ED_uvedit_assign_image(bmain, scene, obedit, ima, NULL);
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (exitmode) {
|
2012-03-29 01:41:56 +00:00
|
|
|
EDBM_mesh_load(obedit);
|
2012-03-27 04:46:52 +00:00
|
|
|
EDBM_mesh_free(me->edit_btmesh);
|
2011-07-25 09:53:36 +00:00
|
|
|
MEM_freeN(me->edit_btmesh);
|
2012-03-26 02:56:48 +00:00
|
|
|
me->edit_btmesh = NULL;
|
2012-02-12 11:21:35 +00:00
|
|
|
|
|
|
|
/* load_editMesh free's pointers used by CustomData layers which might be used by DerivedMesh too,
|
|
|
|
* so signal to re-create DerivedMesh here (sergey) */
|
|
|
|
DAG_id_tag_update(&me->id, 0);
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
}
|
|
|
|
|
2011-01-29 17:56:34 +00:00
|
|
|
/* dummie drop support; ensure view shows a result :) */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (v3d)
|
2011-01-29 17:56:34 +00:00
|
|
|
v3d->flag2 |= V3D_SOLID_TEX;
|
|
|
|
|
2012-03-26 02:56:48 +00:00
|
|
|
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MESH_OT_drop_named_image(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2013-02-05 14:38:19 +00:00
|
|
|
ot->name = "Drop Image to Mesh UV Map";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->description = "Assign Image to active UV Map, or create an UV Map";
|
|
|
|
ot->idname = "MESH_OT_drop_named_image";
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = layers_poll;
|
|
|
|
ot->invoke = drop_named_image_invoke;
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
|
|
|
|
/* flags */
|
2013-02-05 14:38:19 +00:00
|
|
|
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
|
|
|
|
/* properties */
|
2012-03-26 02:56:48 +00:00
|
|
|
RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME - 2, "Name", "Image name to assign");
|
2010-06-14 03:52:10 +00:00
|
|
|
RNA_def_string(ot->srna, "filepath", "Path", FILE_MAX, "Filepath", "Path to image file");
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
}
|
|
|
|
|
2012-03-23 21:25:07 +00:00
|
|
|
static int mesh_uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-07-01 22:25:49 +00:00
|
|
|
{
|
2012-03-26 02:56:48 +00:00
|
|
|
Object *ob = ED_object_context(C);
|
|
|
|
Mesh *me = ob->data;
|
2009-07-01 22:25:49 +00:00
|
|
|
|
2013-03-21 20:54:48 +00:00
|
|
|
if (!ED_mesh_uv_texture_remove_active(me))
|
2009-07-01 22:25:49 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MESH_OT_uv_texture_remove(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Remove UV Map";
|
|
|
|
ot->description = "Remove UV Map";
|
|
|
|
ot->idname = "MESH_OT_uv_texture_remove";
|
2009-07-01 22:25:49 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = layers_poll;
|
2012-03-23 21:25:07 +00:00
|
|
|
ot->exec = mesh_uv_texture_remove_exec;
|
2009-07-01 22:25:49 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-03-26 02:56:48 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-07-01 22:25:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************** vertex color operators ************************/
|
|
|
|
|
2012-03-23 21:25:07 +00:00
|
|
|
static int mesh_vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-07-01 22:25:49 +00:00
|
|
|
{
|
2012-03-26 02:56:48 +00:00
|
|
|
Object *ob = ED_object_context(C);
|
|
|
|
Mesh *me = ob->data;
|
2009-07-01 22:25:49 +00:00
|
|
|
|
2013-03-21 20:54:48 +00:00
|
|
|
if (ED_mesh_color_add(me, NULL, true) == -1)
|
2009-09-28 14:28:45 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2009-07-01 22:25:49 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MESH_OT_vertex_color_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Vertex Color";
|
|
|
|
ot->description = "Add vertex color layer";
|
|
|
|
ot->idname = "MESH_OT_vertex_color_add";
|
2009-07-01 22:25:49 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = layers_poll;
|
2012-03-23 21:25:07 +00:00
|
|
|
ot->exec = mesh_vertex_color_add_exec;
|
2009-07-01 22:25:49 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-03-26 02:56:48 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-07-01 22:25:49 +00:00
|
|
|
}
|
|
|
|
|
2012-03-23 21:25:07 +00:00
|
|
|
static int mesh_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-07-01 22:25:49 +00:00
|
|
|
{
|
2012-03-26 02:56:48 +00:00
|
|
|
Object *ob = ED_object_context(C);
|
|
|
|
Mesh *me = ob->data;
|
2009-07-01 22:25:49 +00:00
|
|
|
|
2013-03-21 20:15:39 +00:00
|
|
|
if (!ED_mesh_color_remove_active(me))
|
2009-07-01 22:25:49 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MESH_OT_vertex_color_remove(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Remove Vertex Color";
|
|
|
|
ot->description = "Remove vertex color layer";
|
|
|
|
ot->idname = "MESH_OT_vertex_color_remove";
|
2009-07-01 22:25:49 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-23 21:25:07 +00:00
|
|
|
ot->exec = mesh_vertex_color_remove_exec;
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = layers_poll;
|
2009-07-01 22:25:49 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-03-26 02:56:48 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-07-01 22:25:49 +00:00
|
|
|
}
|
|
|
|
|
2012-09-21 03:41:59 +00:00
|
|
|
/* *** CustomData clear functions, we need an operator for each *** */
|
|
|
|
|
|
|
|
static int mesh_customdata_clear_exec__internal(bContext *C,
|
|
|
|
char htype, int type)
|
2009-07-01 22:25:49 +00:00
|
|
|
{
|
2012-09-21 03:41:59 +00:00
|
|
|
Object *obedit = ED_object_context(C);
|
|
|
|
Mesh *me = obedit->data;
|
2009-07-01 22:25:49 +00:00
|
|
|
|
2012-09-21 03:41:59 +00:00
|
|
|
int tot;
|
|
|
|
CustomData *data = mesh_customdata_get_type(me, htype, &tot);
|
|
|
|
|
2013-03-19 23:17:44 +00:00
|
|
|
BLI_assert(CustomData_layertype_is_singleton(type) == true);
|
2009-07-01 22:25:49 +00:00
|
|
|
|
2012-09-24 10:57:44 +00:00
|
|
|
if (CustomData_has_layer(data, type)) {
|
2012-10-01 04:00:41 +00:00
|
|
|
if (me->edit_btmesh) {
|
|
|
|
BM_data_layer_free(me->edit_btmesh->bm, data, type);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
CustomData_free_layers(data, type, tot);
|
|
|
|
}
|
2009-07-01 22:25:49 +00:00
|
|
|
|
2012-09-24 10:57:44 +00:00
|
|
|
DAG_id_tag_update(&me->id, 0);
|
|
|
|
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
|
2009-07-01 22:25:49 +00:00
|
|
|
|
2012-09-24 10:57:44 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2009-07-01 22:25:49 +00:00
|
|
|
}
|
|
|
|
|
2012-09-21 03:41:59 +00:00
|
|
|
/* Clear Mask */
|
|
|
|
static int mesh_customdata_clear_mask_poll(bContext *C)
|
|
|
|
{
|
|
|
|
Object *ob = ED_object_context(C);
|
|
|
|
if (ob && ob->type == OB_MESH) {
|
|
|
|
Mesh *me = ob->data;
|
2012-09-23 02:31:30 +00:00
|
|
|
|
|
|
|
/* special case - can't run this if we're in sculpt mode */
|
|
|
|
if (ob->mode & OB_MODE_SCULPT) {
|
2013-03-19 23:17:44 +00:00
|
|
|
return false;
|
2012-09-23 02:31:30 +00:00
|
|
|
}
|
|
|
|
|
2012-09-21 03:41:59 +00:00
|
|
|
if (me->id.lib == NULL) {
|
|
|
|
CustomData *data = GET_CD_DATA(me, vdata);
|
|
|
|
if (CustomData_has_layer(data, CD_PAINT_MASK)) {
|
2013-03-19 23:17:44 +00:00
|
|
|
return true;
|
2012-09-21 03:41:59 +00:00
|
|
|
}
|
2012-09-24 10:57:44 +00:00
|
|
|
data = GET_CD_DATA(me, ldata);
|
|
|
|
if (CustomData_has_layer(data, CD_GRID_PAINT_MASK)) {
|
2013-03-19 23:17:44 +00:00
|
|
|
return true;
|
2012-09-24 10:57:44 +00:00
|
|
|
}
|
2012-09-21 03:41:59 +00:00
|
|
|
}
|
|
|
|
}
|
2013-03-19 23:17:44 +00:00
|
|
|
return false;
|
2012-09-21 03:41:59 +00:00
|
|
|
}
|
|
|
|
static int mesh_customdata_clear_mask_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
2012-09-24 10:57:44 +00:00
|
|
|
int ret_a = mesh_customdata_clear_exec__internal(C, BM_VERT, CD_PAINT_MASK);
|
|
|
|
int ret_b = mesh_customdata_clear_exec__internal(C, BM_LOOP, CD_GRID_PAINT_MASK);
|
|
|
|
|
|
|
|
if (ret_a == OPERATOR_FINISHED ||
|
|
|
|
ret_b == OPERATOR_FINISHED)
|
|
|
|
{
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2012-09-21 03:41:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MESH_OT_customdata_clear_mask(wmOperatorType *ot)
|
2009-07-01 22:25:49 +00:00
|
|
|
{
|
2012-09-21 03:41:59 +00:00
|
|
|
|
2009-07-01 22:25:49 +00:00
|
|
|
/* identifiers */
|
2012-09-21 03:41:59 +00:00
|
|
|
ot->name = "Clear Sculpt-Mask Data";
|
|
|
|
ot->idname = "MESH_OT_customdata_clear_mask";
|
|
|
|
ot->description = "Clear vertex sculpt masking data from the mesh";
|
|
|
|
|
2009-07-01 22:25:49 +00:00
|
|
|
/* api callbacks */
|
2012-09-21 03:41:59 +00:00
|
|
|
ot->exec = mesh_customdata_clear_mask_exec;
|
|
|
|
ot->poll = mesh_customdata_clear_mask_poll;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
}
|
|
|
|
|
2012-09-21 21:43:56 +00:00
|
|
|
/* Clear Skin */
|
|
|
|
static int mesh_customdata_clear_skin_poll(bContext *C)
|
|
|
|
{
|
|
|
|
Object *ob = ED_object_context(C);
|
|
|
|
|
|
|
|
if (ob && ob->type == OB_MESH) {
|
|
|
|
Mesh *me = ob->data;
|
|
|
|
if (me->id.lib == NULL) {
|
|
|
|
CustomData *data = GET_CD_DATA(me, vdata);
|
|
|
|
if (CustomData_has_layer(data, CD_MVERT_SKIN)) {
|
2013-03-19 23:17:44 +00:00
|
|
|
return true;
|
2012-09-21 21:43:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-03-19 23:17:44 +00:00
|
|
|
return false;
|
2012-09-21 21:43:56 +00:00
|
|
|
}
|
|
|
|
static int mesh_customdata_clear_skin_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
return mesh_customdata_clear_exec__internal(C, BM_VERT, CD_MVERT_SKIN);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MESH_OT_customdata_clear_skin(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Clear Skin Data";
|
|
|
|
ot->idname = "MESH_OT_customdata_clear_skin";
|
|
|
|
ot->description = "Clear vertex skin layer";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = mesh_customdata_clear_skin_exec;
|
|
|
|
ot->poll = mesh_customdata_clear_skin_poll;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
}
|
|
|
|
|
2009-09-28 14:28:45 +00:00
|
|
|
/************************** Add Geometry Layers *************************/
|
|
|
|
|
2012-03-02 14:46:14 +00:00
|
|
|
void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges, int calc_tessface)
|
2009-09-28 14:28:45 +00:00
|
|
|
{
|
2011-10-30 01:14:50 +00:00
|
|
|
int *polyindex = NULL;
|
|
|
|
float (*face_nors)[3];
|
2013-03-19 23:17:44 +00:00
|
|
|
bool tessface_input = false;
|
2011-10-30 01:14:50 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mesh->totface > 0 && mesh->totpoly == 0) {
|
2012-03-27 01:28:25 +00:00
|
|
|
BKE_mesh_convert_mfaces_to_mpolys(mesh);
|
2011-08-01 11:53:55 +00:00
|
|
|
|
2012-03-18 07:38:51 +00:00
|
|
|
/* would only be converting back again, don't bother */
|
2013-03-19 23:17:44 +00:00
|
|
|
tessface_input = true;
|
2012-03-02 14:46:14 +00:00
|
|
|
}
|
|
|
|
|
2012-04-18 09:04:07 +00:00
|
|
|
if (calc_edges || ((mesh->totpoly || mesh->totface) && mesh->totedge == 0))
|
2013-03-16 01:19:03 +00:00
|
|
|
BKE_mesh_calc_edges(mesh, calc_edges, true);
|
2011-10-09 16:59:48 +00:00
|
|
|
|
2012-03-02 14:46:14 +00:00
|
|
|
if (calc_tessface) {
|
2013-03-19 23:17:44 +00:00
|
|
|
if (tessface_input == false) {
|
2012-03-15 05:40:33 +00:00
|
|
|
BKE_mesh_tessface_calc(mesh);
|
|
|
|
}
|
2012-03-02 14:46:14 +00:00
|
|
|
}
|
2012-03-04 00:16:50 +00:00
|
|
|
else {
|
|
|
|
/* default state is not to have tessface's so make sure this is the case */
|
|
|
|
BKE_mesh_tessface_clear(mesh);
|
|
|
|
}
|
2011-10-14 02:30:58 +00:00
|
|
|
|
2012-03-04 00:16:50 +00:00
|
|
|
/* note on this if/else - looks like these layers are not needed
|
|
|
|
* so rather then add poly-index layer and calculate normals for it
|
|
|
|
* calculate normals only for the mvert's. - campbell */
|
2012-03-05 11:49:24 +00:00
|
|
|
#ifdef USE_BMESH_MPOLY_NORMALS
|
2012-10-30 19:20:17 +00:00
|
|
|
polyindex = CustomData_get_layer(&mesh->fdata, CD_ORIGINDEX);
|
2012-03-18 07:38:51 +00:00
|
|
|
/* add a normals layer for tessellated faces, a tessface normal will
|
|
|
|
* contain the normal of the poly the face was tessellated from. */
|
2011-10-30 01:14:50 +00:00
|
|
|
face_nors = CustomData_add_layer(&mesh->fdata, CD_NORMAL, CD_CALLOC, NULL, mesh->totface);
|
|
|
|
|
2012-05-05 21:28:12 +00:00
|
|
|
BKE_mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert,
|
|
|
|
mesh->mloop, mesh->mpoly,
|
|
|
|
mesh->totloop, mesh->totpoly,
|
|
|
|
NULL /* polyNors_r */,
|
|
|
|
mesh->mface, mesh->totface,
|
2013-03-19 23:17:44 +00:00
|
|
|
polyindex, face_nors, false);
|
2012-03-05 11:49:24 +00:00
|
|
|
#else
|
2012-05-05 21:28:12 +00:00
|
|
|
BKE_mesh_calc_normals(mesh->mvert, mesh->totvert,
|
|
|
|
mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
|
|
|
|
NULL);
|
2012-03-05 11:49:24 +00:00
|
|
|
(void)polyindex;
|
|
|
|
(void)face_nors;
|
2012-03-04 00:16:50 +00:00
|
|
|
#endif
|
2011-10-30 01:14:50 +00:00
|
|
|
|
2011-01-03 12:41:16 +00:00
|
|
|
DAG_id_tag_update(&mesh->id, 0);
|
2012-03-26 02:56:48 +00:00
|
|
|
WM_event_add_notifier(C, NC_GEOM | ND_DATA, mesh);
|
2009-09-28 14:28:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mesh_add_verts(Mesh *mesh, int len)
|
|
|
|
{
|
|
|
|
CustomData vdata;
|
|
|
|
MVert *mvert;
|
|
|
|
int i, totvert;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (len == 0)
|
2009-09-28 14:28:45 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-26 02:56:48 +00:00
|
|
|
totvert = mesh->totvert + len;
|
2009-09-28 14:28:45 +00:00
|
|
|
CustomData_copy(&mesh->vdata, &vdata, CD_MASK_MESH, CD_DEFAULT, totvert);
|
|
|
|
CustomData_copy_data(&mesh->vdata, &vdata, 0, 0, mesh->totvert);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!CustomData_has_layer(&vdata, CD_MVERT))
|
2009-09-28 14:28:45 +00:00
|
|
|
CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, NULL, totvert);
|
|
|
|
|
|
|
|
CustomData_free(&mesh->vdata, mesh->totvert);
|
2012-03-26 02:56:48 +00:00
|
|
|
mesh->vdata = vdata;
|
2013-03-17 19:55:10 +00:00
|
|
|
BKE_mesh_update_customdata_pointers(mesh, false);
|
2009-09-28 14:28:45 +00:00
|
|
|
|
|
|
|
/* scan the input list and insert the new vertices */
|
|
|
|
|
2012-10-31 09:50:24 +00:00
|
|
|
/* set default flags */
|
2012-03-26 02:56:48 +00:00
|
|
|
mvert = &mesh->mvert[mesh->totvert];
|
|
|
|
for (i = 0; i < len; i++, mvert++)
|
2009-09-28 14:28:45 +00:00
|
|
|
mvert->flag |= SELECT;
|
|
|
|
|
|
|
|
/* set final vertex list size */
|
2012-03-26 02:56:48 +00:00
|
|
|
mesh->totvert = totvert;
|
2009-09-28 14:28:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ED_mesh_transform(Mesh *me, float *mat)
|
|
|
|
{
|
|
|
|
int i;
|
2012-03-26 02:56:48 +00:00
|
|
|
MVert *mvert = me->mvert;
|
2009-09-28 14:28:45 +00:00
|
|
|
|
2012-03-26 02:56:48 +00:00
|
|
|
for (i = 0; i < me->totvert; i++, mvert++)
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3((float (*)[4])mat, mvert->co);
|
2009-09-28 14:28:45 +00:00
|
|
|
|
2012-04-22 00:27:38 +00:00
|
|
|
/* don't update normals, caller can do this explicitly */
|
2009-09-28 14:28:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mesh_add_edges(Mesh *mesh, int len)
|
|
|
|
{
|
|
|
|
CustomData edata;
|
|
|
|
MEdge *medge;
|
|
|
|
int i, totedge;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (len == 0)
|
2009-09-28 14:28:45 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-26 02:56:48 +00:00
|
|
|
totedge = mesh->totedge + len;
|
2009-09-28 14:28:45 +00:00
|
|
|
|
|
|
|
/* update customdata */
|
|
|
|
CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH, CD_DEFAULT, totedge);
|
|
|
|
CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!CustomData_has_layer(&edata, CD_MEDGE))
|
2009-09-28 14:28:45 +00:00
|
|
|
CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
|
|
|
|
|
|
|
|
CustomData_free(&mesh->edata, mesh->totedge);
|
2012-03-26 02:56:48 +00:00
|
|
|
mesh->edata = edata;
|
2013-03-17 19:55:10 +00:00
|
|
|
BKE_mesh_update_customdata_pointers(mesh, false); /* new edges don't change tessellation */
|
2009-09-28 14:28:45 +00:00
|
|
|
|
|
|
|
/* set default flags */
|
2012-03-26 02:56:48 +00:00
|
|
|
medge = &mesh->medge[mesh->totedge];
|
|
|
|
for (i = 0; i < len; i++, medge++)
|
|
|
|
medge->flag = ME_EDGEDRAW | ME_EDGERENDER | SELECT;
|
2009-09-28 14:28:45 +00:00
|
|
|
|
2012-03-26 02:56:48 +00:00
|
|
|
mesh->totedge = totedge;
|
2009-09-28 14:28:45 +00:00
|
|
|
}
|
|
|
|
|
2012-03-26 04:32:04 +00:00
|
|
|
static void mesh_add_tessfaces(Mesh *mesh, int len)
|
2009-09-28 14:28:45 +00:00
|
|
|
{
|
|
|
|
CustomData fdata;
|
|
|
|
MFace *mface;
|
|
|
|
int i, totface;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (len == 0)
|
2009-09-28 14:28:45 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-26 02:56:48 +00:00
|
|
|
totface = mesh->totface + len; /* new face count */
|
2009-09-28 14:28:45 +00:00
|
|
|
|
|
|
|
/* update customdata */
|
|
|
|
CustomData_copy(&mesh->fdata, &fdata, CD_MASK_MESH, CD_DEFAULT, totface);
|
|
|
|
CustomData_copy_data(&mesh->fdata, &fdata, 0, 0, mesh->totface);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!CustomData_has_layer(&fdata, CD_MFACE))
|
2009-09-28 14:28:45 +00:00
|
|
|
CustomData_add_layer(&fdata, CD_MFACE, CD_CALLOC, NULL, totface);
|
|
|
|
|
|
|
|
CustomData_free(&mesh->fdata, mesh->totface);
|
2012-03-26 02:56:48 +00:00
|
|
|
mesh->fdata = fdata;
|
2013-03-17 19:55:10 +00:00
|
|
|
BKE_mesh_update_customdata_pointers(mesh, true);
|
2009-09-28 14:28:45 +00:00
|
|
|
|
|
|
|
/* set default flags */
|
2012-03-26 02:56:48 +00:00
|
|
|
mface = &mesh->mface[mesh->totface];
|
|
|
|
for (i = 0; i < len; i++, mface++)
|
|
|
|
mface->flag = ME_FACE_SEL;
|
2009-09-28 14:28:45 +00:00
|
|
|
|
2012-03-26 02:56:48 +00:00
|
|
|
mesh->totface = totface;
|
2009-09-28 14:28:45 +00:00
|
|
|
}
|
|
|
|
|
2011-09-01 09:11:00 +00:00
|
|
|
static void mesh_add_loops(Mesh *mesh, int len)
|
|
|
|
{
|
|
|
|
CustomData ldata;
|
2011-09-07 06:49:20 +00:00
|
|
|
int totloop;
|
2011-09-01 09:11:00 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (len == 0)
|
2011-09-01 09:11:00 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-26 02:56:48 +00:00
|
|
|
totloop = mesh->totloop + len; /* new face count */
|
2011-09-01 09:11:00 +00:00
|
|
|
|
|
|
|
/* update customdata */
|
|
|
|
CustomData_copy(&mesh->ldata, &ldata, CD_MASK_MESH, CD_DEFAULT, totloop);
|
|
|
|
CustomData_copy_data(&mesh->ldata, &ldata, 0, 0, mesh->totloop);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!CustomData_has_layer(&ldata, CD_MLOOP))
|
2011-09-01 09:11:00 +00:00
|
|
|
CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, NULL, totloop);
|
|
|
|
|
|
|
|
CustomData_free(&mesh->ldata, mesh->totloop);
|
2012-03-26 02:56:48 +00:00
|
|
|
mesh->ldata = ldata;
|
2013-03-17 19:55:10 +00:00
|
|
|
BKE_mesh_update_customdata_pointers(mesh, true);
|
2011-09-01 09:11:00 +00:00
|
|
|
|
2012-03-26 02:56:48 +00:00
|
|
|
mesh->totloop = totloop;
|
2011-09-01 09:11:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mesh_add_polys(Mesh *mesh, int len)
|
|
|
|
{
|
|
|
|
CustomData pdata;
|
|
|
|
MPoly *mpoly;
|
|
|
|
int i, totpoly;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (len == 0)
|
2011-09-01 09:11:00 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-26 02:56:48 +00:00
|
|
|
totpoly = mesh->totpoly + len; /* new face count */
|
2011-09-01 09:11:00 +00:00
|
|
|
|
|
|
|
/* update customdata */
|
|
|
|
CustomData_copy(&mesh->pdata, &pdata, CD_MASK_MESH, CD_DEFAULT, totpoly);
|
|
|
|
CustomData_copy_data(&mesh->pdata, &pdata, 0, 0, mesh->totpoly);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!CustomData_has_layer(&pdata, CD_MPOLY))
|
2011-09-01 09:11:00 +00:00
|
|
|
CustomData_add_layer(&pdata, CD_MPOLY, CD_CALLOC, NULL, totpoly);
|
|
|
|
|
|
|
|
CustomData_free(&mesh->pdata, mesh->totpoly);
|
2012-03-26 02:56:48 +00:00
|
|
|
mesh->pdata = pdata;
|
2013-03-17 19:55:10 +00:00
|
|
|
BKE_mesh_update_customdata_pointers(mesh, true);
|
2011-09-01 09:11:00 +00:00
|
|
|
|
|
|
|
/* set default flags */
|
2012-03-26 02:56:48 +00:00
|
|
|
mpoly = &mesh->mpoly[mesh->totpoly];
|
|
|
|
for (i = 0; i < len; i++, mpoly++)
|
|
|
|
mpoly->flag = ME_FACE_SEL;
|
2011-09-01 09:11:00 +00:00
|
|
|
|
2012-03-26 02:56:48 +00:00
|
|
|
mesh->totpoly = totpoly;
|
2011-09-01 09:11:00 +00:00
|
|
|
}
|
|
|
|
|
2012-01-20 02:10:09 +00:00
|
|
|
static void mesh_remove_verts(Mesh *mesh, int len)
|
|
|
|
{
|
|
|
|
int totvert;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (len == 0)
|
2012-01-20 02:10:09 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-26 02:56:48 +00:00
|
|
|
totvert = mesh->totvert - len;
|
2012-01-20 02:10:09 +00:00
|
|
|
CustomData_free_elem(&mesh->vdata, totvert, len);
|
|
|
|
|
|
|
|
/* set final vertex list size */
|
2012-03-26 02:56:48 +00:00
|
|
|
mesh->totvert = totvert;
|
2012-01-20 02:10:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mesh_remove_edges(Mesh *mesh, int len)
|
|
|
|
{
|
|
|
|
int totedge;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (len == 0)
|
2012-01-20 02:10:09 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-26 02:56:48 +00:00
|
|
|
totedge = mesh->totedge - len;
|
2012-01-20 02:10:09 +00:00
|
|
|
CustomData_free_elem(&mesh->edata, totedge, len);
|
|
|
|
|
2012-03-26 02:56:48 +00:00
|
|
|
mesh->totedge = totedge;
|
2012-01-20 02:10:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mesh_remove_faces(Mesh *mesh, int len)
|
|
|
|
{
|
|
|
|
int totface;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (len == 0)
|
2012-01-20 02:10:09 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-26 02:56:48 +00:00
|
|
|
totface = mesh->totface - len; /* new face count */
|
2012-01-20 02:10:09 +00:00
|
|
|
CustomData_free_elem(&mesh->fdata, totface, len);
|
|
|
|
|
2012-03-26 02:56:48 +00:00
|
|
|
mesh->totface = totface;
|
2012-01-20 02:10:09 +00:00
|
|
|
}
|
|
|
|
|
2012-03-03 16:31:46 +00:00
|
|
|
#if 0
|
2009-09-28 14:28:45 +00:00
|
|
|
void ED_mesh_geometry_add(Mesh *mesh, ReportList *reports, int verts, int edges, int faces)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mesh->edit_btmesh) {
|
2012-10-18 16:25:58 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Cannot add geometry in edit mode");
|
2009-09-28 14:28:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (verts)
|
2009-09-28 14:28:45 +00:00
|
|
|
mesh_add_verts(mesh, verts);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (edges)
|
2009-09-28 14:28:45 +00:00
|
|
|
mesh_add_edges(mesh, edges);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (faces)
|
2009-09-28 14:28:45 +00:00
|
|
|
mesh_add_faces(mesh, faces);
|
|
|
|
}
|
2012-03-03 16:31:46 +00:00
|
|
|
#endif
|
2010-08-26 22:44:05 +00:00
|
|
|
|
2012-03-26 04:32:04 +00:00
|
|
|
void ED_mesh_tessfaces_add(Mesh *mesh, ReportList *reports, int count)
|
2010-08-26 22:44:05 +00:00
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mesh->edit_btmesh) {
|
2012-10-18 16:25:58 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Cannot add tessfaces in edit mode");
|
2010-08-26 22:44:05 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-09-01 09:11:00 +00:00
|
|
|
|
2012-03-26 04:32:04 +00:00
|
|
|
if (mesh->mpoly) {
|
2012-10-18 16:25:58 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Cannot add tessfaces to a mesh that already has polygons");
|
2012-03-26 04:32:04 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mesh_add_tessfaces(mesh, count);
|
2010-08-26 22:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ED_mesh_edges_add(Mesh *mesh, ReportList *reports, int count)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mesh->edit_btmesh) {
|
2012-10-18 16:25:58 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Cannot add edges in edit mode");
|
2012-03-26 02:56:48 +00:00
|
|
|
return;
|
2010-08-26 22:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mesh_add_edges(mesh, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_mesh_vertices_add(Mesh *mesh, ReportList *reports, int count)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mesh->edit_btmesh) {
|
2012-10-18 16:25:58 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Cannot add vertices in edit mode");
|
2010-08-26 22:44:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mesh_add_verts(mesh, count);
|
|
|
|
}
|
2009-09-28 14:28:45 +00:00
|
|
|
|
2012-01-20 02:10:09 +00:00
|
|
|
void ED_mesh_faces_remove(Mesh *mesh, ReportList *reports, int count)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mesh->edit_btmesh) {
|
2012-10-18 16:25:58 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Cannot remove faces in edit mode");
|
2012-01-20 02:10:09 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (count > mesh->totface) {
|
2012-10-18 16:25:58 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Cannot remove more faces than the mesh contains");
|
2012-01-20 02:10:09 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mesh_remove_faces(mesh, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_mesh_edges_remove(Mesh *mesh, ReportList *reports, int count)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mesh->edit_btmesh) {
|
2012-10-18 16:25:58 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Cannot remove edges in edit mode");
|
2012-01-20 02:10:09 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (count > mesh->totedge) {
|
2012-10-18 16:25:58 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Cannot remove more edges than the mesh contains");
|
2012-01-20 02:10:09 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mesh_remove_edges(mesh, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_mesh_vertices_remove(Mesh *mesh, ReportList *reports, int count)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mesh->edit_btmesh) {
|
2012-10-18 16:25:58 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Cannot remove vertices in edit mode");
|
2012-01-20 02:10:09 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (count > mesh->totvert) {
|
2012-10-18 16:25:58 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Cannot remove more vertices than the mesh contains");
|
2012-01-20 02:10:09 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mesh_remove_verts(mesh, count);
|
|
|
|
}
|
|
|
|
|
2011-09-01 09:11:00 +00:00
|
|
|
void ED_mesh_loops_add(Mesh *mesh, ReportList *reports, int count)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mesh->edit_btmesh) {
|
2012-10-18 16:25:58 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Cannot add loops in edit mode");
|
2012-03-26 02:56:48 +00:00
|
|
|
return;
|
2011-09-01 09:11:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mesh_add_loops(mesh, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_mesh_polys_add(Mesh *mesh, ReportList *reports, int count)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mesh->edit_btmesh) {
|
2012-10-18 16:25:58 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Cannot add polygons in edit mode");
|
2011-09-01 09:11:00 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mesh_add_polys(mesh, count);
|
|
|
|
}
|
|
|
|
|
2011-07-25 09:53:36 +00:00
|
|
|
void ED_mesh_calc_normals(Mesh *mesh)
|
2009-09-28 14:28:45 +00:00
|
|
|
{
|
2012-03-05 11:49:24 +00:00
|
|
|
#ifdef USE_BMESH_MPOLY_NORMALS
|
2012-05-05 21:28:12 +00:00
|
|
|
BKE_mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert,
|
|
|
|
mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
|
2013-03-19 23:17:44 +00:00
|
|
|
NULL, NULL, 0, NULL, NULL, false);
|
2012-03-05 11:49:24 +00:00
|
|
|
#else
|
2012-05-05 21:28:12 +00:00
|
|
|
BKE_mesh_calc_normals(mesh->mvert, mesh->totvert,
|
|
|
|
mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
|
|
|
|
NULL);
|
2012-03-05 11:49:24 +00:00
|
|
|
#endif
|
2009-09-28 14:28:45 +00:00
|
|
|
}
|
2012-03-29 13:44:30 +00:00
|
|
|
|
|
|
|
void ED_mesh_calc_tessface(Mesh *mesh)
|
|
|
|
{
|
|
|
|
if (mesh->edit_btmesh) {
|
2013-04-16 05:59:48 +00:00
|
|
|
BKE_editmesh_tessface_calc(mesh->edit_btmesh);
|
2012-03-29 13:44:30 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
BKE_mesh_tessface_calc(mesh);
|
|
|
|
}
|
|
|
|
}
|