2009-09-13 16:15:26 +00:00
|
|
|
/**
|
2010-03-21 01:14:04 +00:00
|
|
|
* $Id$
|
2009-09-13 16:15:26 +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-09-13 16:15:26 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2007 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Contributor(s): Joseph Eagar, Joshua Leung
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <float.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "DNA_ID.h"
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_userdef_types.h"
|
|
|
|
#include "DNA_windowmanager_types.h"
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "PIL_time.h"
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_dynstr.h" /*for WM_operator_pystring */
|
|
|
|
#include "BLI_editVert.h"
|
2010-01-26 11:25:39 +00:00
|
|
|
#include "BLI_math.h"
|
2009-09-13 16:15:26 +00:00
|
|
|
|
|
|
|
#include "BKE_blender.h"
|
|
|
|
#include "BKE_context.h"
|
2009-10-01 16:37:08 +00:00
|
|
|
#include "BKE_depsgraph.h"
|
2009-09-13 16:15:26 +00:00
|
|
|
#include "BKE_scene.h"
|
|
|
|
#include "BKE_mesh.h"
|
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
#include "BIF_glutil.h" /* for paint cursor */
|
|
|
|
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
|
|
|
|
#include "ED_screen.h"
|
|
|
|
#include "ED_space_api.h"
|
|
|
|
#include "ED_view3d.h"
|
|
|
|
#include "ED_mesh.h"
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "mesh_intern.h"
|
|
|
|
|
|
|
|
/* ringsel operator */
|
|
|
|
|
|
|
|
/* struct for properties used while drawing */
|
|
|
|
typedef struct tringselOpData {
|
|
|
|
ARegion *ar; /* region that ringsel was activated in */
|
|
|
|
void *draw_handle; /* for drawing preview loop */
|
|
|
|
|
|
|
|
float (*edges)[2][3];
|
|
|
|
int totedge;
|
|
|
|
|
|
|
|
ViewContext vc;
|
|
|
|
|
|
|
|
Object *ob;
|
|
|
|
EditMesh *em;
|
|
|
|
EditEdge *eed;
|
|
|
|
|
|
|
|
int extend;
|
2009-09-16 09:55:06 +00:00
|
|
|
int do_cut;
|
2009-09-13 16:15:26 +00:00
|
|
|
} tringselOpData;
|
|
|
|
|
|
|
|
/* modal loop selection drawing callback */
|
2010-10-16 14:32:17 +00:00
|
|
|
static void ringsel_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *arg)
|
2009-09-13 16:15:26 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
tringselOpData *lcd = arg;
|
|
|
|
|
2010-01-10 19:56:22 +00:00
|
|
|
if (lcd->totedge > 0) {
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
2009-09-13 16:15:26 +00:00
|
|
|
|
2010-01-10 19:56:22 +00:00
|
|
|
glPushMatrix();
|
|
|
|
glMultMatrixf(lcd->ob->obmat);
|
2009-09-13 16:15:26 +00:00
|
|
|
|
2010-01-10 19:56:22 +00:00
|
|
|
glColor3ub(255, 0, 255);
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for (i=0; i<lcd->totedge; i++) {
|
|
|
|
glVertex3fv(lcd->edges[i][0]);
|
|
|
|
glVertex3fv(lcd->edges[i][1]);
|
|
|
|
}
|
|
|
|
glEnd();
|
2009-09-13 16:15:26 +00:00
|
|
|
|
2010-01-10 19:56:22 +00:00
|
|
|
glPopMatrix();
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
}
|
2009-09-13 16:15:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void edgering_sel(tringselOpData *lcd, int previewlines, int select)
|
|
|
|
{
|
|
|
|
EditMesh *em = lcd->em;
|
|
|
|
EditEdge *startedge = lcd->eed;
|
|
|
|
EditEdge *eed;
|
|
|
|
EditFace *efa;
|
|
|
|
EditVert *v[2][2];
|
|
|
|
float (*edges)[2][3] = NULL;
|
|
|
|
V_DYNDECLARE(edges);
|
|
|
|
float co[2][3];
|
2009-09-17 14:46:22 +00:00
|
|
|
int looking=1, i, tot=0;
|
2009-09-13 16:15:26 +00:00
|
|
|
|
|
|
|
if (!startedge)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (lcd->edges) {
|
|
|
|
MEM_freeN(lcd->edges);
|
|
|
|
lcd->edges = NULL;
|
|
|
|
lcd->totedge = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!lcd->extend) {
|
|
|
|
EM_clear_flag_all(lcd->em, SELECT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* in eed->f1 we put the valence (amount of faces in edge) */
|
|
|
|
/* in eed->f2 we put tagged flag as correct loop */
|
|
|
|
/* in efa->f1 we put tagged flag as correct to select */
|
|
|
|
|
|
|
|
for(eed= em->edges.first; eed; eed= eed->next) {
|
|
|
|
eed->f1= 0;
|
|
|
|
eed->f2= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(efa= em->faces.first; efa; efa= efa->next) {
|
|
|
|
efa->f1= 0;
|
|
|
|
if(efa->h==0) {
|
|
|
|
efa->e1->f1++;
|
|
|
|
efa->e2->f1++;
|
|
|
|
efa->e3->f1++;
|
|
|
|
if(efa->e4) efa->e4->f1++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// tag startedge OK
|
|
|
|
startedge->f2= 1;
|
|
|
|
|
|
|
|
while(looking) {
|
|
|
|
looking= 0;
|
|
|
|
|
|
|
|
for(efa= em->faces.first; efa; efa= efa->next) {
|
|
|
|
if(efa->e4 && efa->f1==0 && efa->h == 0) { // not done quad
|
|
|
|
if(efa->e1->f1<=2 && efa->e2->f1<=2 && efa->e3->f1<=2 && efa->e4->f1<=2) { // valence ok
|
|
|
|
|
|
|
|
// if edge tagged, select opposing edge and mark face ok
|
|
|
|
if(efa->e1->f2) {
|
|
|
|
efa->e3->f2= 1;
|
|
|
|
efa->f1= 1;
|
|
|
|
looking= 1;
|
|
|
|
}
|
|
|
|
else if(efa->e2->f2) {
|
|
|
|
efa->e4->f2= 1;
|
|
|
|
efa->f1= 1;
|
|
|
|
looking= 1;
|
|
|
|
}
|
|
|
|
if(efa->e3->f2) {
|
|
|
|
efa->e1->f2= 1;
|
|
|
|
efa->f1= 1;
|
|
|
|
looking= 1;
|
|
|
|
}
|
|
|
|
if(efa->e4->f2) {
|
|
|
|
efa->e2->f2= 1;
|
|
|
|
efa->f1= 1;
|
|
|
|
looking= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(previewlines > 0 && !select){
|
|
|
|
for(efa= em->faces.first; efa; efa= efa->next) {
|
|
|
|
if(efa->v4 == NULL) { continue; }
|
|
|
|
if(efa->h == 0){
|
|
|
|
if(efa->e1->f2 == 1){
|
|
|
|
if(efa->e1->h == 1 || efa->e3->h == 1 )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
v[0][0] = efa->v1;
|
|
|
|
v[0][1] = efa->v2;
|
|
|
|
v[1][0] = efa->v4;
|
|
|
|
v[1][1] = efa->v3;
|
|
|
|
} else if(efa->e2->f2 == 1){
|
|
|
|
if(efa->e2->h == 1 || efa->e4->h == 1)
|
|
|
|
continue;
|
|
|
|
v[0][0] = efa->v2;
|
|
|
|
v[0][1] = efa->v3;
|
|
|
|
v[1][0] = efa->v1;
|
|
|
|
v[1][1] = efa->v4;
|
|
|
|
} else { continue; }
|
|
|
|
|
|
|
|
for(i=1;i<=previewlines;i++){
|
|
|
|
co[0][0] = (v[0][1]->co[0] - v[0][0]->co[0])*(i/((float)previewlines+1))+v[0][0]->co[0];
|
|
|
|
co[0][1] = (v[0][1]->co[1] - v[0][0]->co[1])*(i/((float)previewlines+1))+v[0][0]->co[1];
|
|
|
|
co[0][2] = (v[0][1]->co[2] - v[0][0]->co[2])*(i/((float)previewlines+1))+v[0][0]->co[2];
|
|
|
|
|
|
|
|
co[1][0] = (v[1][1]->co[0] - v[1][0]->co[0])*(i/((float)previewlines+1))+v[1][0]->co[0];
|
|
|
|
co[1][1] = (v[1][1]->co[1] - v[1][0]->co[1])*(i/((float)previewlines+1))+v[1][0]->co[1];
|
|
|
|
co[1][2] = (v[1][1]->co[2] - v[1][0]->co[2])*(i/((float)previewlines+1))+v[1][0]->co[2];
|
|
|
|
|
|
|
|
V_GROW(edges);
|
|
|
|
VECCOPY(edges[tot][0], co[0]);
|
|
|
|
VECCOPY(edges[tot][1], co[1]);
|
|
|
|
tot++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
select = (startedge->f & SELECT) == 0;
|
|
|
|
|
|
|
|
/* select the edges */
|
|
|
|
for(eed= em->edges.first; eed; eed= eed->next) {
|
|
|
|
if(eed->f2) EM_select_edge(eed, select);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lcd->edges = edges;
|
|
|
|
lcd->totedge = tot;
|
|
|
|
}
|
|
|
|
|
2010-10-16 14:32:17 +00:00
|
|
|
static void ringsel_find_edge(tringselOpData *lcd, int cuts)
|
2009-09-13 16:15:26 +00:00
|
|
|
{
|
2010-01-10 19:56:22 +00:00
|
|
|
if (lcd->eed) {
|
2009-10-01 16:37:08 +00:00
|
|
|
edgering_sel(lcd, cuts, 0);
|
2010-09-24 10:49:29 +00:00
|
|
|
} else if(lcd->edges) {
|
2010-01-10 19:56:22 +00:00
|
|
|
MEM_freeN(lcd->edges);
|
|
|
|
lcd->edges = NULL;
|
|
|
|
lcd->totedge = 0;
|
|
|
|
}
|
2009-09-13 16:15:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ringsel_finish(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
tringselOpData *lcd= op->customdata;
|
2010-02-07 01:01:32 +00:00
|
|
|
int cuts= (lcd->do_cut)? RNA_int_get(op->ptr,"number_cuts"): 0;
|
2009-09-13 16:15:26 +00:00
|
|
|
|
2009-09-16 09:55:06 +00:00
|
|
|
if (lcd->eed) {
|
2009-10-01 16:37:08 +00:00
|
|
|
edgering_sel(lcd, cuts, 1);
|
2009-09-16 09:55:06 +00:00
|
|
|
if (lcd->do_cut) {
|
|
|
|
EditMesh *em = BKE_mesh_get_editmesh(lcd->ob->data);
|
2010-04-05 04:58:17 +00:00
|
|
|
esubdivideflag(lcd->ob, em, SELECT, 0.0f, 0.0f, 0, cuts, 0, SUBDIV_SELECT_LOOPCUT);
|
2010-04-16 08:14:20 +00:00
|
|
|
|
|
|
|
/* force edge slide to edge select mode in in face select mode */
|
|
|
|
if (em->selectmode & SCE_SELECT_FACE) {
|
|
|
|
if (em->selectmode == SCE_SELECT_FACE)
|
|
|
|
em->selectmode = SCE_SELECT_EDGE;
|
|
|
|
else
|
|
|
|
em->selectmode &= ~SCE_SELECT_FACE;
|
|
|
|
CTX_data_tool_settings(C)->selectmode= em->selectmode;
|
|
|
|
EM_selectmode_set(em);
|
2010-09-01 17:03:31 +00:00
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE|ND_TOOLSETTINGS, CTX_data_scene(C));
|
2010-04-16 08:14:20 +00:00
|
|
|
}
|
2009-09-28 03:28:28 +00:00
|
|
|
|
|
|
|
DAG_id_flush_update(lcd->ob->data, OB_RECALC_DATA);
|
2010-02-07 01:01:32 +00:00
|
|
|
WM_event_add_notifier(C, NC_GEOM|ND_DATA, lcd->ob->data);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
EM_selectmode_flush(lcd->em);
|
|
|
|
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, lcd->ob->data);
|
2009-09-16 09:55:06 +00:00
|
|
|
}
|
|
|
|
}
|
2009-09-13 16:15:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* called when modal loop selection is done... */
|
2010-10-16 14:32:17 +00:00
|
|
|
static void ringsel_exit(wmOperator *op)
|
2009-09-13 16:15:26 +00:00
|
|
|
{
|
|
|
|
tringselOpData *lcd= op->customdata;
|
|
|
|
|
|
|
|
/* deactivate the extra drawing stuff in 3D-View */
|
|
|
|
ED_region_draw_cb_exit(lcd->ar->type, lcd->draw_handle);
|
|
|
|
|
|
|
|
if (lcd->edges)
|
|
|
|
MEM_freeN(lcd->edges);
|
|
|
|
|
|
|
|
ED_region_tag_redraw(lcd->ar);
|
|
|
|
|
|
|
|
/* free the custom data */
|
|
|
|
MEM_freeN(lcd);
|
|
|
|
op->customdata= NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* called when modal loop selection gets set up... */
|
2009-09-16 09:55:06 +00:00
|
|
|
static int ringsel_init (bContext *C, wmOperator *op, int do_cut)
|
2009-09-13 16:15:26 +00:00
|
|
|
{
|
|
|
|
tringselOpData *lcd;
|
|
|
|
|
|
|
|
/* alloc new customdata */
|
|
|
|
lcd= op->customdata= MEM_callocN(sizeof(tringselOpData), "ringsel Modal Op Data");
|
|
|
|
|
|
|
|
/* assign the drawing handle for drawing preview line... */
|
|
|
|
lcd->ar= CTX_wm_region(C);
|
2009-10-20 21:05:22 +00:00
|
|
|
lcd->draw_handle= ED_region_draw_cb_activate(lcd->ar->type, ringsel_draw, lcd, REGION_DRAW_POST_VIEW);
|
2009-09-13 16:15:26 +00:00
|
|
|
lcd->ob = CTX_data_edit_object(C);
|
|
|
|
lcd->em= BKE_mesh_get_editmesh((Mesh *)lcd->ob->data);
|
2009-09-16 09:55:06 +00:00
|
|
|
lcd->extend = do_cut ? 0 : RNA_boolean_get(op->ptr, "extend");
|
|
|
|
lcd->do_cut = do_cut;
|
2009-09-13 16:15:26 +00:00
|
|
|
em_setup_viewcontext(C, &lcd->vc);
|
|
|
|
|
|
|
|
ED_region_tag_redraw(lcd->ar);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-10-16 14:32:17 +00:00
|
|
|
static int ringcut_cancel (bContext *UNUSED(C), wmOperator *op)
|
2009-09-13 16:15:26 +00:00
|
|
|
{
|
|
|
|
/* this is just a wrapper around exit() */
|
2010-10-16 14:32:17 +00:00
|
|
|
ringsel_exit(op);
|
2009-09-13 16:15:26 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ringsel_invoke (bContext *C, wmOperator *op, wmEvent *evt)
|
|
|
|
{
|
|
|
|
tringselOpData *lcd;
|
|
|
|
EditEdge *edge;
|
|
|
|
int dist = 75;
|
2010-01-16 00:59:59 +00:00
|
|
|
|
2009-09-13 16:15:26 +00:00
|
|
|
view3d_operator_needs_opengl(C);
|
|
|
|
|
2009-09-16 09:55:06 +00:00
|
|
|
if (!ringsel_init(C, op, 0))
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2010-01-16 00:59:59 +00:00
|
|
|
lcd = op->customdata;
|
|
|
|
|
|
|
|
if (lcd->em->selectmode == SCE_SELECT_FACE) {
|
2010-10-16 14:32:17 +00:00
|
|
|
ringsel_exit(op);
|
2010-02-07 10:30:28 +00:00
|
|
|
WM_operator_name_call(C, "MESH_OT_loop_select", WM_OP_INVOKE_REGION_WIN, NULL);
|
2010-01-16 00:59:59 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2009-09-16 09:55:06 +00:00
|
|
|
|
|
|
|
lcd->vc.mval[0] = evt->mval[0];
|
|
|
|
lcd->vc.mval[1] = evt->mval[1];
|
|
|
|
|
|
|
|
edge = findnearestedge(&lcd->vc, &dist);
|
2010-02-07 01:01:32 +00:00
|
|
|
if(!edge) {
|
2010-10-16 14:32:17 +00:00
|
|
|
ringsel_exit(op);
|
2010-02-07 01:01:32 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2009-09-16 09:55:06 +00:00
|
|
|
}
|
|
|
|
|
2010-02-07 01:01:32 +00:00
|
|
|
lcd->eed = edge;
|
2010-10-16 14:32:17 +00:00
|
|
|
ringsel_find_edge(lcd, 1);
|
2010-02-07 01:01:32 +00:00
|
|
|
|
|
|
|
ringsel_finish(C, op);
|
2010-10-16 14:32:17 +00:00
|
|
|
ringsel_exit(op);
|
2009-09-16 09:55:06 +00:00
|
|
|
|
2010-02-07 01:01:32 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
2009-09-16 09:55:06 +00:00
|
|
|
|
|
|
|
static int ringcut_invoke (bContext *C, wmOperator *op, wmEvent *evt)
|
|
|
|
{
|
|
|
|
tringselOpData *lcd;
|
|
|
|
EditEdge *edge;
|
|
|
|
int dist = 75;
|
|
|
|
|
|
|
|
view3d_operator_needs_opengl(C);
|
|
|
|
|
|
|
|
if (!ringsel_init(C, op, 1))
|
2009-09-13 16:15:26 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
/* add a modal handler for this operator - handles loop selection */
|
2009-09-18 12:43:36 +00:00
|
|
|
WM_event_add_modal_handler(C, op);
|
2009-09-13 16:15:26 +00:00
|
|
|
|
|
|
|
lcd = op->customdata;
|
|
|
|
lcd->vc.mval[0] = evt->mval[0];
|
|
|
|
lcd->vc.mval[1] = evt->mval[1];
|
|
|
|
|
|
|
|
edge = findnearestedge(&lcd->vc, &dist);
|
|
|
|
if (edge != lcd->eed) {
|
|
|
|
lcd->eed = edge;
|
2010-10-16 14:32:17 +00:00
|
|
|
ringsel_find_edge(lcd, 1);
|
2009-09-13 16:15:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
2010-02-07 01:01:32 +00:00
|
|
|
static int ringcut_modal (bContext *C, wmOperator *op, wmEvent *event)
|
2009-09-13 16:15:26 +00:00
|
|
|
{
|
2009-10-01 16:37:08 +00:00
|
|
|
int cuts= RNA_int_get(op->ptr,"number_cuts");
|
2009-09-13 16:15:26 +00:00
|
|
|
tringselOpData *lcd= op->customdata;
|
|
|
|
|
|
|
|
view3d_operator_needs_opengl(C);
|
|
|
|
|
2009-10-01 16:37:08 +00:00
|
|
|
|
2009-09-13 16:15:26 +00:00
|
|
|
switch (event->type) {
|
|
|
|
case LEFTMOUSE: /* confirm */ // XXX hardcoded
|
2010-04-21 04:21:27 +00:00
|
|
|
if (event->val == KM_PRESS) {
|
2009-09-13 16:15:26 +00:00
|
|
|
/* finish */
|
|
|
|
ED_region_tag_redraw(lcd->ar);
|
2009-10-09 23:34:52 +00:00
|
|
|
|
2009-09-13 16:15:26 +00:00
|
|
|
ringsel_finish(C, op);
|
2010-10-16 14:32:17 +00:00
|
|
|
ringsel_exit(op);
|
2009-09-13 16:15:26 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
2009-10-09 23:34:52 +00:00
|
|
|
|
|
|
|
ED_region_tag_redraw(lcd->ar);
|
|
|
|
break;
|
|
|
|
case RIGHTMOUSE: /* abort */ // XXX hardcoded
|
|
|
|
case ESCKEY:
|
|
|
|
if (event->val == KM_RELEASE) {
|
|
|
|
/* cancel */
|
|
|
|
ED_region_tag_redraw(lcd->ar);
|
|
|
|
|
2010-02-07 01:01:32 +00:00
|
|
|
return ringcut_cancel(C, op);
|
2009-10-09 23:34:52 +00:00
|
|
|
}
|
|
|
|
|
2009-10-01 16:37:08 +00:00
|
|
|
ED_region_tag_redraw(lcd->ar);
|
|
|
|
break;
|
|
|
|
case WHEELUPMOUSE: /* change number of cuts */
|
2009-12-21 02:39:39 +00:00
|
|
|
case PAGEUPKEY:
|
|
|
|
if (event->val == KM_PRESS) {
|
|
|
|
cuts++;
|
2010-02-07 01:01:32 +00:00
|
|
|
RNA_int_set(op->ptr, "number_cuts",cuts);
|
2010-10-16 14:32:17 +00:00
|
|
|
ringsel_find_edge(lcd, cuts);
|
2009-12-21 02:39:39 +00:00
|
|
|
|
|
|
|
ED_region_tag_redraw(lcd->ar);
|
|
|
|
}
|
2009-10-01 16:37:08 +00:00
|
|
|
break;
|
|
|
|
case WHEELDOWNMOUSE: /* change number of cuts */
|
2009-12-21 02:39:39 +00:00
|
|
|
case PAGEDOWNKEY:
|
|
|
|
if (event->val == KM_PRESS) {
|
|
|
|
cuts=MAX2(cuts-1,1);
|
|
|
|
RNA_int_set(op->ptr,"number_cuts",cuts);
|
2010-10-16 14:32:17 +00:00
|
|
|
ringsel_find_edge(lcd, cuts);
|
2009-12-21 02:39:39 +00:00
|
|
|
|
|
|
|
ED_region_tag_redraw(lcd->ar);
|
|
|
|
}
|
2009-09-13 16:15:26 +00:00
|
|
|
break;
|
|
|
|
case MOUSEMOVE: { /* mouse moved somewhere to select another loop */
|
|
|
|
int dist = 75;
|
|
|
|
EditEdge *edge;
|
|
|
|
|
|
|
|
lcd->vc.mval[0] = event->mval[0];
|
|
|
|
lcd->vc.mval[1] = event->mval[1];
|
|
|
|
edge = findnearestedge(&lcd->vc, &dist);
|
|
|
|
|
|
|
|
if (edge != lcd->eed) {
|
|
|
|
lcd->eed = edge;
|
2010-10-16 14:32:17 +00:00
|
|
|
ringsel_find_edge(lcd, cuts);
|
2009-09-13 16:15:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ED_region_tag_redraw(lcd->ar);
|
|
|
|
break;
|
2009-10-01 16:37:08 +00:00
|
|
|
}
|
2009-09-13 16:15:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* keep going until the user confirms */
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MESH_OT_edgering_select (wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* description */
|
2009-09-16 09:55:06 +00:00
|
|
|
ot->name= "Edge Ring Select";
|
2009-09-13 16:15:26 +00:00
|
|
|
ot->idname= "MESH_OT_edgering_select";
|
2009-09-16 09:55:06 +00:00
|
|
|
ot->description= "Select an edge ring";
|
2009-09-13 16:15:26 +00:00
|
|
|
|
|
|
|
/* callbacks */
|
|
|
|
ot->invoke= ringsel_invoke;
|
2009-12-06 17:38:39 +00:00
|
|
|
ot->poll= ED_operator_editmesh_view3d;
|
2009-09-13 16:15:26 +00:00
|
|
|
|
|
|
|
/* flags */
|
2010-02-07 01:01:32 +00:00
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
2009-09-13 16:15:26 +00:00
|
|
|
|
|
|
|
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection");
|
|
|
|
}
|
2009-09-16 09:55:06 +00:00
|
|
|
|
|
|
|
void MESH_OT_loopcut (wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* description */
|
|
|
|
ot->name= "Loop Cut";
|
|
|
|
ot->idname= "MESH_OT_loopcut";
|
2010-02-10 21:15:44 +00:00
|
|
|
ot->description= "Add a new loop between existing loops";
|
2009-09-16 09:55:06 +00:00
|
|
|
|
|
|
|
/* callbacks */
|
|
|
|
ot->invoke= ringcut_invoke;
|
2010-02-07 01:01:32 +00:00
|
|
|
ot->modal= ringcut_modal;
|
|
|
|
ot->cancel= ringcut_cancel;
|
2010-10-08 11:33:10 +00:00
|
|
|
ot->poll= ED_operator_editmesh_view3d;
|
2009-09-16 09:55:06 +00:00
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
|
2009-10-01 16:37:08 +00:00
|
|
|
|
|
|
|
/* properties */
|
2009-10-19 12:13:32 +00:00
|
|
|
RNA_def_int(ot->srna, "number_cuts", 1, 1, INT_MAX, "Number of Cuts", "", 1, 10);
|
2009-09-16 09:55:06 +00:00
|
|
|
}
|