=bmesh=
Fixed some bugs with mesh primitive add operators. Suzanne now faces forward, instead of down. Cylinder and circle both now work. Cone lets you adjust the diameter at both ends now. I also reorganized the walker code, to be more maintainable and understandable.
This commit is contained in:
@@ -84,7 +84,6 @@ set(SRC
|
||||
intern/bmesh_mods.c
|
||||
intern/bmesh_structure.h
|
||||
intern/bmesh_construct.c
|
||||
intern/bmesh_walkers.c
|
||||
intern/bmesh_to_editmesh.c
|
||||
intern/bmesh_operators_private.h
|
||||
intern/editmesh_to_bmesh.c
|
||||
@@ -96,6 +95,9 @@ set(SRC
|
||||
intern/bmesh_eulers.c
|
||||
intern/bmesh_operators.c
|
||||
intern/bmesh_private.h
|
||||
intern/bmesh_walkers.c
|
||||
intern/bmesh_walkers_impl.c
|
||||
intern/bmesh_walkers_private.h
|
||||
bmesh_error.h
|
||||
bmesh_queries.h
|
||||
bmesh.h
|
||||
|
||||
@@ -24,11 +24,6 @@
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2004 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The Original Code is: all of this file.
|
||||
*
|
||||
* Contributor(s): Geoffrey Bantle, Levi Schooley.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef BM_OPERATORS_H
|
||||
#define BM_OPERATORS_H
|
||||
|
||||
/*see comments in intern/bmesh_opdefines.c for documentation of specific operators*/
|
||||
|
||||
/*--------defines/enumerations for specific operators-------*/
|
||||
|
||||
/*del operator "context" slot values*/
|
||||
|
||||
@@ -9,15 +9,17 @@
|
||||
|
||||
/*Walkers*/
|
||||
typedef struct BMWalker {
|
||||
BLI_mempool *stack;
|
||||
BMesh *bm;
|
||||
void *currentstate;
|
||||
void (*begin) (struct BMWalker *walker, void *start);
|
||||
void *(*yield)(struct BMWalker *walker);
|
||||
void *(*step) (struct BMWalker *walker);
|
||||
void *(*yield)(struct BMWalker *walker);
|
||||
int structsize;
|
||||
int flag;
|
||||
|
||||
BMesh *bm;
|
||||
BLI_mempool *stack;
|
||||
void *currentstate;
|
||||
int restrictflag;
|
||||
GHash *visithash;
|
||||
int flag;
|
||||
} BMWalker;
|
||||
|
||||
/*initialize a walker. searchmask restricts some (not all) walkers to
|
||||
@@ -27,6 +29,12 @@ void *BMW_Begin(BMWalker *walker, void *start);
|
||||
void *BMW_Step(struct BMWalker *walker);
|
||||
void BMW_End(struct BMWalker *walker);
|
||||
|
||||
/*these are used by custom walkers*/
|
||||
void BMW_pushstate(BMWalker *walker);
|
||||
void BMW_popstate(BMWalker *walker);
|
||||
void *BMW_walk(BMWalker *walker);
|
||||
void BMW_reset(BMWalker *walker);
|
||||
|
||||
/*
|
||||
example of usage, walking over an island of tool flagged faces:
|
||||
|
||||
@@ -67,7 +75,9 @@ enum {
|
||||
BMW_ISLANDBOUND,
|
||||
/*walk over all faces in an island of tool flagged faces.*/
|
||||
BMW_ISLAND,
|
||||
/*do not intitialze function pointers and struct size in BMW_Init*/
|
||||
BMW_CUSTOM,
|
||||
BMW_MAXWALKERS,
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -897,6 +897,7 @@ BMOpDefine def_create_cone = {
|
||||
"create_cone",
|
||||
{{BMOP_OPSLOT_ELEMENT_BUF, "vertout"}, //output verts
|
||||
{BMOP_OPSLOT_INT, "cap_ends"}, //wheter or not to fill in the ends with faces
|
||||
{BMOP_OPSLOT_INT, "cap_tris"}, //fill ends with triangles instead of ngons
|
||||
{BMOP_OPSLOT_INT, "segments"},
|
||||
{BMOP_OPSLOT_FLT, "diameter1"}, //diameter of one end
|
||||
{BMOP_OPSLOT_FLT, "diameter2"}, //diameter of the opposite
|
||||
@@ -907,6 +908,22 @@ BMOpDefine def_create_cone = {
|
||||
0,
|
||||
};
|
||||
|
||||
/*
|
||||
Creates a circle
|
||||
*/
|
||||
BMOpDefine def_create_circle = {
|
||||
"create_circle",
|
||||
{{BMOP_OPSLOT_ELEMENT_BUF, "vertout"}, //output verts
|
||||
{BMOP_OPSLOT_INT, "cap_ends"}, //wheter or not to fill in the ends with faces
|
||||
{BMOP_OPSLOT_INT, "cap_tris"}, //fill ends with triangles instead of ngons
|
||||
{BMOP_OPSLOT_INT, "segments"},
|
||||
{BMOP_OPSLOT_FLT, "diameter"}, //diameter of one end
|
||||
{BMOP_OPSLOT_MAT, "mat"}, //matrix to multiply the new geometry with--
|
||||
{0, /*null-terminating sentinel*/}},
|
||||
bmesh_create_circle_exec,
|
||||
0,
|
||||
};
|
||||
|
||||
/*
|
||||
Create Cone
|
||||
|
||||
@@ -1025,8 +1042,9 @@ BMOpDefine *opdefines[] = {
|
||||
&def_create_grid,
|
||||
&def_create_icosphere,
|
||||
&def_create_monkey,
|
||||
&def_create_cone,
|
||||
&def_create_cube,
|
||||
&def_create_circle,
|
||||
&def_create_cone,
|
||||
&def_join_triangles,
|
||||
&def_bevel,
|
||||
&def_beautify_fill,
|
||||
|
||||
@@ -71,5 +71,6 @@ void bmesh_jointriangles_exec(BMesh *bm, BMOperator *op);
|
||||
void bmesh_bevel_exec(BMesh *bm, BMOperator *op);
|
||||
void bmesh_beautify_fill_exec(BMesh *bm, BMOperator *op);
|
||||
void bmesh_triangle_fill_exec(BMesh *bm, BMOperator *op);
|
||||
void bmesh_create_circle_exec(BMesh *bm, BMOperator *op);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,34 @@
|
||||
/**
|
||||
* bmesh_walkers.c april 2011
|
||||
*
|
||||
* BMesh Walker API.
|
||||
*
|
||||
* $Id: $
|
||||
*
|
||||
* ***** 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. The Blender
|
||||
* Foundation also sells licenses for use in proprietary software under
|
||||
* the Blender License. See http://www.blender.org/BL/ for information
|
||||
* about this.
|
||||
*
|
||||
* 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,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Contributor(s): Joseph Eagar, Geoffrey Bantle, Levi Schooley.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -10,11 +41,11 @@
|
||||
#include "BLI_mempool.h"
|
||||
#include "BLI_array.h"
|
||||
|
||||
#include "bmesh_private.h"
|
||||
#include "bmesh_walkers.h"
|
||||
|
||||
#include "bmesh.h"
|
||||
|
||||
#include "bmesh_private.h"
|
||||
#include "bmesh_walkers_private.h"
|
||||
|
||||
/*
|
||||
- joeedh -
|
||||
design notes:
|
||||
@@ -37,102 +68,6 @@
|
||||
for if walkers fail.
|
||||
*/
|
||||
|
||||
typedef struct shellWalker{
|
||||
struct shellWalker *prev;
|
||||
BMVert *base;
|
||||
BMEdge *curedge, *current;
|
||||
} shellWalker;
|
||||
|
||||
typedef struct islandboundWalker {
|
||||
struct islandboundWalker *prev;
|
||||
BMLoop *base;
|
||||
BMVert *lastv;
|
||||
BMLoop *curloop;
|
||||
} islandboundWalker;
|
||||
|
||||
typedef struct islandWalker {
|
||||
struct islandWalker * prev;
|
||||
BMFace *cur;
|
||||
} islandWalker;
|
||||
|
||||
typedef struct loopWalker {
|
||||
struct loopWalker * prev;
|
||||
BMEdge *cur, *start;
|
||||
BMVert *lastv, *startv;
|
||||
int startrad, stage2;
|
||||
} loopWalker;
|
||||
|
||||
typedef struct faceloopWalker {
|
||||
struct faceloopWalker * prev;
|
||||
BMLoop *l;
|
||||
int nocalc;
|
||||
} faceloopWalker;
|
||||
|
||||
typedef struct edgeringWalker {
|
||||
struct edgeringWalker * prev;
|
||||
BMLoop *l;
|
||||
} edgeringWalker;
|
||||
|
||||
typedef struct uvedgeWalker {
|
||||
struct uvedgeWalker *prev;
|
||||
BMLoop *l;
|
||||
} uvedgeWalker;
|
||||
|
||||
/* NOTE: this comment is out of date, update it - joeedh
|
||||
* BMWalker - change this to use the filters functions.
|
||||
*
|
||||
* A generic structure for maintaing the state and callbacks nessecary for walking over
|
||||
* the surface of a mesh. An example of usage:
|
||||
*
|
||||
* BMEdge *edge;
|
||||
* BMWalker *walker = BMW_create(BM_SHELLWALKER, BM_SELECT);
|
||||
* walker->begin(walker, vert);
|
||||
* for(edge = BMW_walk(walker); edge; edge = bmeshWwalker_walk(walker)){
|
||||
* bmesh_select_edge(edge);
|
||||
* }
|
||||
* BMW_free(walker);
|
||||
*
|
||||
* The above example creates a walker that walks over the surface a mesh by starting at
|
||||
* a vertex and traveling across its edges to other vertices, and repeating the process
|
||||
* over and over again until it has visited each vertex in the shell. An additional restriction
|
||||
* is passed into the BMW_create function stating that we are only interested
|
||||
* in walking over edges that have been flagged with the bitmask 'BM_SELECT'.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*Forward declerations*/
|
||||
static void *BMW_walk(struct BMWalker *walker);
|
||||
static void BMW_popstate(struct BMWalker *walker);
|
||||
static void BMW_pushstate(struct BMWalker *walker);
|
||||
|
||||
static void shellWalker_begin(struct BMWalker *walker, void *data);
|
||||
static void *shellWalker_yield(struct BMWalker *walker);
|
||||
static void *shellWalker_step(struct BMWalker *walker);
|
||||
|
||||
static void islandboundWalker_begin(BMWalker *walker, void *data);
|
||||
static void *islandboundWalker_yield(BMWalker *walker);
|
||||
static void *islandboundWalker_step(BMWalker *walker);
|
||||
|
||||
static void islandWalker_begin(BMWalker *walker, void *data);
|
||||
static void *islandWalker_yield(BMWalker *walker);
|
||||
static void *islandWalker_step(BMWalker *walker);
|
||||
|
||||
static void loopWalker_begin(BMWalker *walker, void *data);
|
||||
static void *loopWalker_yield(BMWalker *walker);
|
||||
static void *loopWalker_step(BMWalker *walker);
|
||||
|
||||
static void faceloopWalker_begin(BMWalker *walker, void *data);
|
||||
static void *faceloopWalker_yield(BMWalker *walker);
|
||||
static void *faceloopWalker_step(BMWalker *walker);
|
||||
|
||||
static void edgeringWalker_begin(BMWalker *walker, void *data);
|
||||
static void *edgeringWalker_yield(BMWalker *walker);
|
||||
static void *edgeringWalker_step(BMWalker *walker);
|
||||
|
||||
static void uvedgeWalker_begin(BMWalker *walker, void *data);
|
||||
static void *uvedgeWalker_yield(BMWalker *walker);
|
||||
static void *uvedgeWalker_step(BMWalker *walker);
|
||||
|
||||
/* Pointer hiding*/
|
||||
typedef struct bmesh_walkerGeneric{
|
||||
@@ -157,62 +92,26 @@ void *BMW_Begin(BMWalker *walker, void *start) {
|
||||
|
||||
void BMW_Init(BMWalker *walker, BMesh *bm, int type, int searchmask, int flag)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
memset(walker, 0, sizeof(BMWalker));
|
||||
|
||||
walker->flag = flag;
|
||||
walker->bm = bm;
|
||||
walker->restrictflag = searchmask;
|
||||
walker->visithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh walkers 1");
|
||||
|
||||
switch(type){
|
||||
case BMW_SHELL:
|
||||
walker->begin = shellWalker_begin;
|
||||
walker->step = shellWalker_step;
|
||||
walker->yield = shellWalker_yield;
|
||||
size = sizeof(shellWalker);
|
||||
break;
|
||||
case BMW_ISLANDBOUND:
|
||||
walker->begin = islandboundWalker_begin;
|
||||
walker->step = islandboundWalker_step;
|
||||
walker->yield = islandboundWalker_yield;
|
||||
size = sizeof(islandboundWalker);
|
||||
break;
|
||||
case BMW_ISLAND:
|
||||
walker->begin = islandWalker_begin;
|
||||
walker->step = islandWalker_step;
|
||||
walker->yield = islandWalker_yield;
|
||||
size = sizeof(islandWalker);
|
||||
break;
|
||||
case BMW_LOOP:
|
||||
walker->begin = loopWalker_begin;
|
||||
walker->step = loopWalker_step;
|
||||
walker->yield = loopWalker_yield;
|
||||
size = sizeof(loopWalker);
|
||||
break;
|
||||
case BMW_FACELOOP:
|
||||
walker->begin = faceloopWalker_begin;
|
||||
walker->step = faceloopWalker_step;
|
||||
walker->yield = faceloopWalker_yield;
|
||||
size = sizeof(faceloopWalker);
|
||||
break;
|
||||
case BMW_EDGERING:
|
||||
walker->begin = edgeringWalker_begin;
|
||||
walker->step = edgeringWalker_step;
|
||||
walker->yield = edgeringWalker_yield;
|
||||
size = sizeof(edgeringWalker);
|
||||
break;
|
||||
case BMW_LOOPDATA_ISLAND:
|
||||
walker->begin = uvedgeWalker_begin;
|
||||
walker->step = uvedgeWalker_step;
|
||||
walker->yield = uvedgeWalker_yield;
|
||||
size = sizeof(uvedgeWalker);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
if (type >= BMW_MAXWALKERS || type < 0) {
|
||||
bmesh_error();
|
||||
printf(stderr, "Invalid walker type in BMW_Init; type: %d, searchmask: %d, flag: %d\n", type, searchmask, flag);
|
||||
}
|
||||
walker->stack = BLI_mempool_create(size, 100, 100, 1, 0);
|
||||
|
||||
if (type != BMW_CUSTOM) {
|
||||
walker->begin = bm_walker_types[type]->begin;
|
||||
walker->yield = bm_walker_types[type]->yield;
|
||||
walker->step = bm_walker_types[type]->step;
|
||||
walker->structsize = bm_walker_types[type]->structsize;
|
||||
}
|
||||
|
||||
walker->stack = BLI_mempool_create(walker->structsize, 100, 100, 1, 0);
|
||||
walker->currentstate = NULL;
|
||||
}
|
||||
|
||||
@@ -254,7 +153,7 @@ void *BMW_Step(BMWalker *walker)
|
||||
*
|
||||
*/
|
||||
|
||||
static void *BMW_walk(BMWalker *walker)
|
||||
void *BMW_walk(BMWalker *walker)
|
||||
{
|
||||
void *current = NULL;
|
||||
|
||||
@@ -273,7 +172,7 @@ static void *BMW_walk(BMWalker *walker)
|
||||
*
|
||||
*/
|
||||
|
||||
static void BMW_popstate(BMWalker *walker)
|
||||
void BMW_popstate(BMWalker *walker)
|
||||
{
|
||||
void *oldstate;
|
||||
oldstate = walker->currentstate;
|
||||
@@ -290,7 +189,7 @@ static void BMW_popstate(BMWalker *walker)
|
||||
*
|
||||
*/
|
||||
|
||||
static void BMW_pushstate(BMWalker *walker)
|
||||
void BMW_pushstate(BMWalker *walker)
|
||||
{
|
||||
bmesh_walkerGeneric *newstate;
|
||||
newstate = BLI_mempool_alloc(walker->stack);
|
||||
@@ -303,617 +202,3 @@ void BMW_reset(BMWalker *walker) {
|
||||
BMW_popstate(walker);
|
||||
}
|
||||
}
|
||||
|
||||
/* Shell Walker:
|
||||
*
|
||||
* Starts at a vertex on the mesh and walks over the 'shell' it belongs
|
||||
* to via visiting connected edges.
|
||||
*
|
||||
* TODO:
|
||||
*
|
||||
* Add restriction flag/callback for wire edges.
|
||||
*
|
||||
*/
|
||||
|
||||
static void shellWalker_begin(BMWalker *walker, void *data){
|
||||
BMIter eiter;
|
||||
BMEdge *e;
|
||||
BMVert *v = data;
|
||||
shellWalker *shellWalk = NULL;
|
||||
|
||||
if (!v->e)
|
||||
return;
|
||||
|
||||
if (walker->restrictflag) {
|
||||
BM_ITER(e, &eiter, walker->bm, BM_EDGES_OF_VERT, v) {
|
||||
if (BMO_TestFlag(walker->bm, e, walker->restrictflag))
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
e = v->e;
|
||||
}
|
||||
|
||||
if (!e)
|
||||
return;
|
||||
|
||||
if (BLI_ghash_haskey(walker->visithash, e))
|
||||
return;
|
||||
|
||||
BMW_pushstate(walker);
|
||||
|
||||
shellWalk = walker->currentstate;
|
||||
shellWalk->base = v;
|
||||
shellWalk->curedge = e;
|
||||
BLI_ghash_insert(walker->visithash, e, NULL);
|
||||
}
|
||||
|
||||
static void *shellWalker_yield(BMWalker *walker)
|
||||
{
|
||||
shellWalker *shellWalk = walker->currentstate;
|
||||
return shellWalk->curedge;
|
||||
}
|
||||
|
||||
static void *shellWalker_step(BMWalker *walker)
|
||||
{
|
||||
shellWalker *swalk = walker->currentstate;
|
||||
BMEdge *e, *e2;
|
||||
BMVert *v;
|
||||
BMIter iter;
|
||||
int i;
|
||||
|
||||
BMW_popstate(walker);
|
||||
|
||||
e = swalk->curedge;
|
||||
for (i=0; i<2; i++) {
|
||||
v = i ? e->v2 : e->v1;
|
||||
BM_ITER(e2, &iter, walker->bm, BM_EDGES_OF_VERT, v) {
|
||||
if (walker->restrictflag && !BMO_TestFlag(walker->bm, e2, walker->restrictflag))
|
||||
continue;
|
||||
if (BLI_ghash_haskey(walker->visithash, e2))
|
||||
continue;
|
||||
|
||||
BMW_pushstate(walker);
|
||||
BLI_ghash_insert(walker->visithash, e2, NULL);
|
||||
|
||||
swalk = walker->currentstate;
|
||||
swalk->curedge = e2;
|
||||
}
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void *shellWalker_step(BMWalker *walker)
|
||||
{
|
||||
BMEdge *curedge, *next = NULL;
|
||||
BMVert *ov = NULL;
|
||||
int restrictpass = 1;
|
||||
shellWalker shellWalk = *((shellWalker*)walker->currentstate);
|
||||
|
||||
if (!BLI_ghash_haskey(walker->visithash, shellWalk.base))
|
||||
BLI_ghash_insert(walker->visithash, shellWalk.base, NULL);
|
||||
|
||||
BMW_popstate(walker);
|
||||
|
||||
|
||||
/*find the next edge whose other vertex has not been visited*/
|
||||
curedge = shellWalk.curedge;
|
||||
do{
|
||||
if (!BLI_ghash_haskey(walker->visithash, curedge)) {
|
||||
if(!walker->restrictflag || (walker->restrictflag &&
|
||||
BMO_TestFlag(walker->bm, curedge, walker->restrictflag)))
|
||||
{
|
||||
ov = BM_OtherEdgeVert(curedge, shellWalk.base);
|
||||
|
||||
/*push a new state onto the stack*/
|
||||
BMW_pushstate(walker);
|
||||
BLI_ghash_insert(walker->visithash, curedge, NULL);
|
||||
|
||||
/*populate the new state*/
|
||||
|
||||
((shellWalker*)walker->currentstate)->base = ov;
|
||||
((shellWalker*)walker->currentstate)->curedge = curedge;
|
||||
}
|
||||
}
|
||||
curedge = bmesh_disk_nextedge(curedge, shellWalk.base);
|
||||
}while(curedge != shellWalk.curedge);
|
||||
|
||||
return shellWalk.curedge;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Island Boundary Walker:
|
||||
*
|
||||
* Starts at a edge on the mesh and walks over the boundary of an
|
||||
* island it belongs to.
|
||||
*
|
||||
* TODO:
|
||||
*
|
||||
* Add restriction flag/callback for wire edges.
|
||||
*
|
||||
*/
|
||||
|
||||
static void islandboundWalker_begin(BMWalker *walker, void *data){
|
||||
BMLoop *l = data;
|
||||
islandboundWalker *iwalk = NULL;
|
||||
|
||||
BMW_pushstate(walker);
|
||||
|
||||
iwalk = walker->currentstate;
|
||||
|
||||
iwalk->base = iwalk->curloop = l;
|
||||
iwalk->lastv = l->v;
|
||||
|
||||
BLI_ghash_insert(walker->visithash, data, NULL);
|
||||
|
||||
}
|
||||
|
||||
static void *islandboundWalker_yield(BMWalker *walker)
|
||||
{
|
||||
islandboundWalker *iwalk = walker->currentstate;
|
||||
|
||||
return iwalk->curloop;
|
||||
}
|
||||
|
||||
static void *islandboundWalker_step(BMWalker *walker)
|
||||
{
|
||||
islandboundWalker *iwalk = walker->currentstate, owalk;
|
||||
BMVert *v;
|
||||
BMEdge *e = iwalk->curloop->e;
|
||||
BMFace *f;
|
||||
BMLoop *l = iwalk->curloop;
|
||||
/* int found=0; */
|
||||
|
||||
owalk = *iwalk;
|
||||
|
||||
if (iwalk->lastv == e->v1) v = e->v2;
|
||||
else v = e->v1;
|
||||
|
||||
if (BM_Nonmanifold_Vert(walker->bm, v)) {
|
||||
BMW_reset(walker);
|
||||
BMO_RaiseError(walker->bm, NULL,BMERR_WALKER_FAILED,
|
||||
"Non-manifold vert"
|
||||
" while searching region boundary");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*pop off current state*/
|
||||
BMW_popstate(walker);
|
||||
|
||||
f = l->f;
|
||||
|
||||
while (1) {
|
||||
l = BM_OtherFaceLoop(e, f, v);
|
||||
if (bmesh_radial_nextloop(l) != l) {
|
||||
l = bmesh_radial_nextloop(l);
|
||||
f = l->f;
|
||||
e = l->e;
|
||||
if(!BMO_TestFlag(walker->bm, f, walker->restrictflag)){
|
||||
l = l->radial_next;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
f = l->f;
|
||||
e = l->e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (l == owalk.curloop) return NULL;
|
||||
if (BLI_ghash_haskey(walker->visithash, l)) return owalk.curloop;
|
||||
|
||||
BLI_ghash_insert(walker->visithash, l, NULL);
|
||||
BMW_pushstate(walker);
|
||||
iwalk = walker->currentstate;
|
||||
iwalk->base = owalk.base;
|
||||
|
||||
//if (!BMO_TestFlag(walker->bm, l->f, walker->restrictflag))
|
||||
// iwalk->curloop = l->radial_next;
|
||||
iwalk->curloop = l; //else iwalk->curloop = l;
|
||||
iwalk->lastv = v;
|
||||
|
||||
return owalk.curloop;
|
||||
}
|
||||
|
||||
|
||||
/* Island Walker:
|
||||
*
|
||||
* Starts at a tool flagged-face and walks over the face region
|
||||
*
|
||||
* TODO:
|
||||
*
|
||||
* Add restriction flag/callback for wire edges.
|
||||
*
|
||||
*/
|
||||
|
||||
static void islandWalker_begin(BMWalker *walker, void *data){
|
||||
islandWalker *iwalk = NULL;
|
||||
|
||||
BMW_pushstate(walker);
|
||||
|
||||
iwalk = walker->currentstate;
|
||||
BLI_ghash_insert(walker->visithash, data, NULL);
|
||||
|
||||
iwalk->cur = data;
|
||||
}
|
||||
|
||||
static void *islandWalker_yield(BMWalker *walker)
|
||||
{
|
||||
islandWalker *iwalk = walker->currentstate;
|
||||
|
||||
return iwalk->cur;
|
||||
}
|
||||
|
||||
static void *islandWalker_step(BMWalker *walker)
|
||||
{
|
||||
islandWalker *iwalk = walker->currentstate, *owalk;
|
||||
BMIter iter, liter;
|
||||
BMFace *f, *curf = iwalk->cur;
|
||||
BMLoop *l;
|
||||
owalk = iwalk;
|
||||
|
||||
BMW_popstate(walker);
|
||||
|
||||
l = BMIter_New(&liter, walker->bm, BM_LOOPS_OF_FACE, iwalk->cur);
|
||||
for (; l; l=BMIter_Step(&liter)) {
|
||||
f = BMIter_New(&iter, walker->bm, BM_FACES_OF_EDGE, l->e);
|
||||
for (; f; f=BMIter_Step(&iter)) {
|
||||
if (!BMO_TestFlag(walker->bm, f, walker->restrictflag))
|
||||
continue;
|
||||
if (BLI_ghash_haskey(walker->visithash, f)) continue;
|
||||
|
||||
BMW_pushstate(walker);
|
||||
iwalk = walker->currentstate;
|
||||
iwalk->cur = f;
|
||||
BLI_ghash_insert(walker->visithash, f, NULL);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return curf;
|
||||
}
|
||||
|
||||
|
||||
/* Island Walker:
|
||||
*
|
||||
* Starts at a tool flagged-face and walks over the face region
|
||||
*
|
||||
* TODO:
|
||||
*
|
||||
* Add restriction flag/callback for wire edges.
|
||||
*
|
||||
*/
|
||||
|
||||
static void loopWalker_begin(BMWalker *walker, void *data){
|
||||
loopWalker *lwalk = NULL, owalk;
|
||||
BMEdge *e = data;
|
||||
BMVert *v;
|
||||
int /* found=1, */ val;
|
||||
|
||||
v = e->v1;
|
||||
|
||||
val = BM_Vert_EdgeCount(v);
|
||||
|
||||
BMW_pushstate(walker);
|
||||
|
||||
lwalk = walker->currentstate;
|
||||
BLI_ghash_insert(walker->visithash, e, NULL);
|
||||
|
||||
lwalk->cur = lwalk->start = e;
|
||||
lwalk->lastv = lwalk->startv = v;
|
||||
lwalk->stage2 = 0;
|
||||
lwalk->startrad = BM_Edge_FaceCount(e);
|
||||
|
||||
/*rewind*/
|
||||
while (walker->currentstate) {
|
||||
owalk = *((loopWalker*)walker->currentstate);
|
||||
BMW_walk(walker);
|
||||
}
|
||||
|
||||
BMW_pushstate(walker);
|
||||
lwalk = walker->currentstate;
|
||||
*lwalk = owalk;
|
||||
|
||||
if (lwalk->lastv == owalk.cur->v1) lwalk->lastv = owalk.cur->v2;
|
||||
else lwalk->lastv = owalk.cur->v1;
|
||||
|
||||
lwalk->startv = lwalk->lastv;
|
||||
|
||||
BLI_ghash_free(walker->visithash, NULL, NULL);
|
||||
walker->visithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh walkers 2");
|
||||
BLI_ghash_insert(walker->visithash, owalk.cur, NULL);
|
||||
}
|
||||
|
||||
static void *loopWalker_yield(BMWalker *walker)
|
||||
{
|
||||
loopWalker *lwalk = walker->currentstate;
|
||||
|
||||
return lwalk->cur;
|
||||
}
|
||||
|
||||
static void *loopWalker_step(BMWalker *walker)
|
||||
{
|
||||
loopWalker *lwalk = walker->currentstate, owalk;
|
||||
BMEdge *e = lwalk->cur /* , *nexte = NULL */;
|
||||
BMLoop *l, *l2;
|
||||
BMVert *v;
|
||||
int val, rlen /* , found=0 */, i=0, stopi;
|
||||
|
||||
owalk = *lwalk;
|
||||
|
||||
if (e->v1 == lwalk->lastv) v = e->v2;
|
||||
else v = e->v1;
|
||||
|
||||
val = BM_Vert_EdgeCount(v);
|
||||
|
||||
BMW_popstate(walker);
|
||||
|
||||
rlen = owalk.startrad;
|
||||
l = e->l;
|
||||
if (!l)
|
||||
return owalk.cur;
|
||||
|
||||
if (val == 4 || val == 2 || rlen == 1) {
|
||||
i = 0;
|
||||
stopi = val / 2;
|
||||
while (1) {
|
||||
if (rlen != 1 && i == stopi) break;
|
||||
|
||||
l = BM_OtherFaceLoop(l->e, l->f, v);
|
||||
|
||||
if (!l)
|
||||
break;
|
||||
|
||||
l2 = bmesh_radial_nextloop(l);
|
||||
|
||||
if (l2 == l) {
|
||||
break;
|
||||
}
|
||||
|
||||
l = l2;
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!l)
|
||||
return owalk.cur;
|
||||
|
||||
if (l != e->l && !BLI_ghash_haskey(walker->visithash, l->e)) {
|
||||
if (!(rlen != 1 && i != stopi)) {
|
||||
BMW_pushstate(walker);
|
||||
lwalk = walker->currentstate;
|
||||
*lwalk = owalk;
|
||||
lwalk->cur = l->e;
|
||||
lwalk->lastv = v;
|
||||
BLI_ghash_insert(walker->visithash, l->e, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return owalk.cur;
|
||||
}
|
||||
|
||||
static void faceloopWalker_begin(BMWalker *walker, void *data)
|
||||
{
|
||||
faceloopWalker *lwalk, owalk;
|
||||
BMEdge *e = data;
|
||||
|
||||
BMW_pushstate(walker);
|
||||
|
||||
if (!e->l) return;
|
||||
|
||||
lwalk = walker->currentstate;
|
||||
lwalk->l = e->l;
|
||||
lwalk->nocalc = 0;
|
||||
BLI_ghash_insert(walker->visithash, lwalk->l->f, NULL);
|
||||
|
||||
/*rewind*/
|
||||
while (walker->currentstate) {
|
||||
owalk = *((faceloopWalker*)walker->currentstate);
|
||||
BMW_walk(walker);
|
||||
}
|
||||
|
||||
BMW_pushstate(walker);
|
||||
lwalk = walker->currentstate;
|
||||
*lwalk = owalk;
|
||||
lwalk->nocalc = 0;
|
||||
|
||||
BLI_ghash_free(walker->visithash, NULL, NULL);
|
||||
walker->visithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh walkers 3");
|
||||
BLI_ghash_insert(walker->visithash, lwalk->l->f, NULL);
|
||||
}
|
||||
|
||||
static void *faceloopWalker_yield(BMWalker *walker)
|
||||
{
|
||||
faceloopWalker *lwalk = walker->currentstate;
|
||||
|
||||
if (!lwalk) return NULL;
|
||||
|
||||
return lwalk->l->f;
|
||||
}
|
||||
|
||||
static void *faceloopWalker_step(BMWalker *walker)
|
||||
{
|
||||
faceloopWalker *lwalk = walker->currentstate;
|
||||
BMFace *f = lwalk->l->f;
|
||||
BMLoop *l = lwalk->l, *origl = lwalk->l;
|
||||
|
||||
BMW_popstate(walker);
|
||||
|
||||
l = l->radial_next;
|
||||
|
||||
if (lwalk->nocalc)
|
||||
return f;
|
||||
|
||||
if (BLI_ghash_haskey(walker->visithash, l->f)) {
|
||||
l = lwalk->l;
|
||||
l = l->next->next;
|
||||
if (l == l->radial_next) {
|
||||
l = l->prev->prev;
|
||||
}
|
||||
l = l->radial_next;
|
||||
}
|
||||
|
||||
if (!BLI_ghash_haskey(walker->visithash, l->f)) {
|
||||
BMW_pushstate(walker);
|
||||
lwalk = walker->currentstate;
|
||||
lwalk->l = l;
|
||||
|
||||
if (l->f->len != 4) {
|
||||
lwalk->nocalc = 1;
|
||||
lwalk->l = origl;
|
||||
} else
|
||||
lwalk->nocalc = 0;
|
||||
|
||||
BLI_ghash_insert(walker->visithash, l->f, NULL);
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
static void edgeringWalker_begin(BMWalker *walker, void *data)
|
||||
{
|
||||
edgeringWalker *lwalk, owalk;
|
||||
BMEdge *e = data;
|
||||
|
||||
if (!e->l) return;
|
||||
|
||||
BMW_pushstate(walker);
|
||||
|
||||
lwalk = walker->currentstate;
|
||||
lwalk->l = e->l;
|
||||
BLI_ghash_insert(walker->visithash, lwalk->l->e, NULL);
|
||||
|
||||
/*rewind*/
|
||||
while (walker->currentstate) {
|
||||
owalk = *((edgeringWalker*)walker->currentstate);
|
||||
BMW_walk(walker);
|
||||
}
|
||||
|
||||
BMW_pushstate(walker);
|
||||
lwalk = walker->currentstate;
|
||||
*lwalk = owalk;
|
||||
|
||||
if (lwalk->l->f->len != 4)
|
||||
lwalk->l = lwalk->l->radial_next;
|
||||
|
||||
BLI_ghash_free(walker->visithash, NULL, NULL);
|
||||
walker->visithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh walkers 4");
|
||||
BLI_ghash_insert(walker->visithash, lwalk->l->e, NULL);
|
||||
}
|
||||
|
||||
static void *edgeringWalker_yield(BMWalker *walker)
|
||||
{
|
||||
edgeringWalker *lwalk = walker->currentstate;
|
||||
|
||||
if (!lwalk) return NULL;
|
||||
|
||||
return lwalk->l->e;
|
||||
}
|
||||
|
||||
static void *edgeringWalker_step(BMWalker *walker)
|
||||
{
|
||||
edgeringWalker *lwalk = walker->currentstate;
|
||||
BMEdge *e = lwalk->l->e;
|
||||
BMLoop *l = lwalk->l /* , *origl = lwalk->l */;
|
||||
|
||||
BMW_popstate(walker);
|
||||
|
||||
l = l->radial_next;
|
||||
l = l->next->next;
|
||||
|
||||
if (l->f->len != 4) {
|
||||
l = lwalk->l->next->next;
|
||||
}
|
||||
|
||||
if (l->f->len == 4 && !BLI_ghash_haskey(walker->visithash, l->e)) {
|
||||
BMW_pushstate(walker);
|
||||
lwalk = walker->currentstate;
|
||||
lwalk->l = l;
|
||||
|
||||
BLI_ghash_insert(walker->visithash, l->e, NULL);
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
static void uvedgeWalker_begin(BMWalker *walker, void *data)
|
||||
{
|
||||
uvedgeWalker *lwalk;
|
||||
BMLoop *l = data;
|
||||
|
||||
if (BLI_ghash_haskey(walker->visithash, l))
|
||||
return;
|
||||
|
||||
BMW_pushstate(walker);
|
||||
lwalk = walker->currentstate;
|
||||
lwalk->l = l;
|
||||
BLI_ghash_insert(walker->visithash, l, NULL);
|
||||
}
|
||||
|
||||
static void *uvedgeWalker_yield(BMWalker *walker)
|
||||
{
|
||||
uvedgeWalker *lwalk = walker->currentstate;
|
||||
|
||||
if (!lwalk) return NULL;
|
||||
|
||||
return lwalk->l;
|
||||
}
|
||||
|
||||
static void *uvedgeWalker_step(BMWalker *walker)
|
||||
{
|
||||
uvedgeWalker *lwalk = walker->currentstate;
|
||||
BMLoop *l, *l2, *l3, *nl, *cl;
|
||||
BMIter liter;
|
||||
void *d1, *d2;
|
||||
int i, j, rlen, type;
|
||||
|
||||
l = lwalk->l;
|
||||
nl = l->next;
|
||||
type = walker->bm->ldata.layers[walker->flag].type;
|
||||
|
||||
BMW_popstate(walker);
|
||||
|
||||
if (walker->restrictflag && !BMO_TestFlag(walker->bm, l->e, walker->restrictflag))
|
||||
return l;
|
||||
|
||||
/*go over loops around l->v and nl->v and see which ones share l and nl's
|
||||
mloopuv's coordinates. in addition, push on l->next if necassary.*/
|
||||
for (i=0; i<2; i++) {
|
||||
cl = i ? nl : l;
|
||||
BM_ITER(l2, &liter, walker->bm, BM_LOOPS_OF_VERT, cl->v) {
|
||||
d1 = CustomData_bmesh_get_layer_n(&walker->bm->ldata,
|
||||
cl->head.data, walker->flag);
|
||||
|
||||
rlen = BM_Edge_FaceCount(l2->e);
|
||||
for (j=0; j<rlen; j++) {
|
||||
if (BLI_ghash_haskey(walker->visithash, l2))
|
||||
continue;
|
||||
if (walker->restrictflag && !(BMO_TestFlag(walker->bm, l2->e, walker->restrictflag)))
|
||||
{
|
||||
if (l2->v != cl->v)
|
||||
continue;
|
||||
}
|
||||
|
||||
l3 = l2->v != cl->v ? (BMLoop*)l2->next : l2;
|
||||
d2 = CustomData_bmesh_get_layer_n(&walker->bm->ldata,
|
||||
l3->head.data, walker->flag);
|
||||
|
||||
if (!CustomData_data_equals(type, d1, d2))
|
||||
continue;
|
||||
|
||||
BMW_pushstate(walker);
|
||||
BLI_ghash_insert(walker->visithash, l2, NULL);
|
||||
lwalk = walker->currentstate;
|
||||
|
||||
lwalk->l = l2;
|
||||
|
||||
l2 = l2->radial_next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
726
source/blender/bmesh/intern/bmesh_walkers_impl.c
Normal file
726
source/blender/bmesh/intern/bmesh_walkers_impl.c
Normal file
@@ -0,0 +1,726 @@
|
||||
/**
|
||||
* bmesh_walkers_impl.c april 2011
|
||||
*
|
||||
* BMesh Walker Code.
|
||||
*
|
||||
* $Id: $
|
||||
*
|
||||
* ***** 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. The Blender
|
||||
* Foundation also sells licenses for use in proprietary software under
|
||||
* the Blender License. See http://www.blender.org/BL/ for information
|
||||
* about this.
|
||||
*
|
||||
* 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,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Contributor(s): Joseph Eagar, Geoffrey Bantle, Levi Schooley.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "BKE_utildefines.h"
|
||||
#include "BKE_customdata.h"
|
||||
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_mesh_types.h"
|
||||
|
||||
#include "BLI_mempool.h"
|
||||
#include "BLI_array.h"
|
||||
|
||||
#include "bmesh.h"
|
||||
|
||||
#include "bmesh_private.h"
|
||||
#include "bmesh_walkers_private.h"
|
||||
|
||||
/* Shell Walker:
|
||||
*
|
||||
* Starts at a vertex on the mesh and walks over the 'shell' it belongs
|
||||
* to via visiting connected edges.
|
||||
*
|
||||
* TODO:
|
||||
*
|
||||
* Add restriction flag/callback for wire edges.
|
||||
*
|
||||
*/
|
||||
|
||||
static void shellWalker_begin(BMWalker *walker, void *data){
|
||||
BMIter eiter;
|
||||
BMEdge *e;
|
||||
BMVert *v = data;
|
||||
shellWalker *shellWalk = NULL;
|
||||
|
||||
if (!v->e)
|
||||
return;
|
||||
|
||||
if (walker->restrictflag) {
|
||||
BM_ITER(e, &eiter, walker->bm, BM_EDGES_OF_VERT, v) {
|
||||
if (BMO_TestFlag(walker->bm, e, walker->restrictflag))
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
e = v->e;
|
||||
}
|
||||
|
||||
if (!e)
|
||||
return;
|
||||
|
||||
if (BLI_ghash_haskey(walker->visithash, e))
|
||||
return;
|
||||
|
||||
BMW_pushstate(walker);
|
||||
|
||||
shellWalk = walker->currentstate;
|
||||
shellWalk->base = v;
|
||||
shellWalk->curedge = e;
|
||||
BLI_ghash_insert(walker->visithash, e, NULL);
|
||||
}
|
||||
|
||||
static void *shellWalker_yield(BMWalker *walker)
|
||||
{
|
||||
shellWalker *shellWalk = walker->currentstate;
|
||||
return shellWalk->curedge;
|
||||
}
|
||||
|
||||
static void *shellWalker_step(BMWalker *walker)
|
||||
{
|
||||
shellWalker *swalk = walker->currentstate;
|
||||
BMEdge *e, *e2;
|
||||
BMVert *v;
|
||||
BMIter iter;
|
||||
int i;
|
||||
|
||||
BMW_popstate(walker);
|
||||
|
||||
e = swalk->curedge;
|
||||
for (i=0; i<2; i++) {
|
||||
v = i ? e->v2 : e->v1;
|
||||
BM_ITER(e2, &iter, walker->bm, BM_EDGES_OF_VERT, v) {
|
||||
if (walker->restrictflag && !BMO_TestFlag(walker->bm, e2, walker->restrictflag))
|
||||
continue;
|
||||
if (BLI_ghash_haskey(walker->visithash, e2))
|
||||
continue;
|
||||
|
||||
BMW_pushstate(walker);
|
||||
BLI_ghash_insert(walker->visithash, e2, NULL);
|
||||
|
||||
swalk = walker->currentstate;
|
||||
swalk->curedge = e2;
|
||||
}
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void *shellWalker_step(BMWalker *walker)
|
||||
{
|
||||
BMEdge *curedge, *next = NULL;
|
||||
BMVert *ov = NULL;
|
||||
int restrictpass = 1;
|
||||
shellWalker shellWalk = *((shellWalker*)walker->currentstate);
|
||||
|
||||
if (!BLI_ghash_haskey(walker->visithash, shellWalk.base))
|
||||
BLI_ghash_insert(walker->visithash, shellWalk.base, NULL);
|
||||
|
||||
BMW_popstate(walker);
|
||||
|
||||
|
||||
/*find the next edge whose other vertex has not been visited*/
|
||||
curedge = shellWalk.curedge;
|
||||
do{
|
||||
if (!BLI_ghash_haskey(walker->visithash, curedge)) {
|
||||
if(!walker->restrictflag || (walker->restrictflag &&
|
||||
BMO_TestFlag(walker->bm, curedge, walker->restrictflag)))
|
||||
{
|
||||
ov = BM_OtherEdgeVert(curedge, shellWalk.base);
|
||||
|
||||
/*push a new state onto the stack*/
|
||||
BMW_pushstate(walker);
|
||||
BLI_ghash_insert(walker->visithash, curedge, NULL);
|
||||
|
||||
/*populate the new state*/
|
||||
|
||||
((shellWalker*)walker->currentstate)->base = ov;
|
||||
((shellWalker*)walker->currentstate)->curedge = curedge;
|
||||
}
|
||||
}
|
||||
curedge = bmesh_disk_nextedge(curedge, shellWalk.base);
|
||||
}while(curedge != shellWalk.curedge);
|
||||
|
||||
return shellWalk.curedge;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Island Boundary Walker:
|
||||
*
|
||||
* Starts at a edge on the mesh and walks over the boundary of an
|
||||
* island it belongs to.
|
||||
*
|
||||
* TODO:
|
||||
*
|
||||
* Add restriction flag/callback for wire edges.
|
||||
*
|
||||
*/
|
||||
|
||||
static void islandboundWalker_begin(BMWalker *walker, void *data){
|
||||
BMLoop *l = data;
|
||||
islandboundWalker *iwalk = NULL;
|
||||
|
||||
BMW_pushstate(walker);
|
||||
|
||||
iwalk = walker->currentstate;
|
||||
|
||||
iwalk->base = iwalk->curloop = l;
|
||||
iwalk->lastv = l->v;
|
||||
|
||||
BLI_ghash_insert(walker->visithash, data, NULL);
|
||||
|
||||
}
|
||||
|
||||
static void *islandboundWalker_yield(BMWalker *walker)
|
||||
{
|
||||
islandboundWalker *iwalk = walker->currentstate;
|
||||
|
||||
return iwalk->curloop;
|
||||
}
|
||||
|
||||
static void *islandboundWalker_step(BMWalker *walker)
|
||||
{
|
||||
islandboundWalker *iwalk = walker->currentstate, owalk;
|
||||
BMVert *v;
|
||||
BMEdge *e = iwalk->curloop->e;
|
||||
BMFace *f;
|
||||
BMLoop *l = iwalk->curloop;
|
||||
/* int found=0; */
|
||||
|
||||
owalk = *iwalk;
|
||||
|
||||
if (iwalk->lastv == e->v1) v = e->v2;
|
||||
else v = e->v1;
|
||||
|
||||
if (BM_Nonmanifold_Vert(walker->bm, v)) {
|
||||
BMW_reset(walker);
|
||||
BMO_RaiseError(walker->bm, NULL,BMERR_WALKER_FAILED,
|
||||
"Non-manifold vert"
|
||||
" while searching region boundary");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*pop off current state*/
|
||||
BMW_popstate(walker);
|
||||
|
||||
f = l->f;
|
||||
|
||||
while (1) {
|
||||
l = BM_OtherFaceLoop(e, f, v);
|
||||
if (bmesh_radial_nextloop(l) != l) {
|
||||
l = bmesh_radial_nextloop(l);
|
||||
f = l->f;
|
||||
e = l->e;
|
||||
if(!BMO_TestFlag(walker->bm, f, walker->restrictflag)){
|
||||
l = l->radial_next;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
f = l->f;
|
||||
e = l->e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (l == owalk.curloop) return NULL;
|
||||
if (BLI_ghash_haskey(walker->visithash, l)) return owalk.curloop;
|
||||
|
||||
BLI_ghash_insert(walker->visithash, l, NULL);
|
||||
BMW_pushstate(walker);
|
||||
iwalk = walker->currentstate;
|
||||
iwalk->base = owalk.base;
|
||||
|
||||
//if (!BMO_TestFlag(walker->bm, l->f, walker->restrictflag))
|
||||
// iwalk->curloop = l->radial_next;
|
||||
iwalk->curloop = l; //else iwalk->curloop = l;
|
||||
iwalk->lastv = v;
|
||||
|
||||
return owalk.curloop;
|
||||
}
|
||||
|
||||
|
||||
/* Island Walker:
|
||||
*
|
||||
* Starts at a tool flagged-face and walks over the face region
|
||||
*
|
||||
* TODO:
|
||||
*
|
||||
* Add restriction flag/callback for wire edges.
|
||||
*
|
||||
*/
|
||||
|
||||
static void islandWalker_begin(BMWalker *walker, void *data){
|
||||
islandWalker *iwalk = NULL;
|
||||
|
||||
BMW_pushstate(walker);
|
||||
|
||||
iwalk = walker->currentstate;
|
||||
BLI_ghash_insert(walker->visithash, data, NULL);
|
||||
|
||||
iwalk->cur = data;
|
||||
}
|
||||
|
||||
static void *islandWalker_yield(BMWalker *walker)
|
||||
{
|
||||
islandWalker *iwalk = walker->currentstate;
|
||||
|
||||
return iwalk->cur;
|
||||
}
|
||||
|
||||
static void *islandWalker_step(BMWalker *walker)
|
||||
{
|
||||
islandWalker *iwalk = walker->currentstate, *owalk;
|
||||
BMIter iter, liter;
|
||||
BMFace *f, *curf = iwalk->cur;
|
||||
BMLoop *l;
|
||||
owalk = iwalk;
|
||||
|
||||
BMW_popstate(walker);
|
||||
|
||||
l = BMIter_New(&liter, walker->bm, BM_LOOPS_OF_FACE, iwalk->cur);
|
||||
for (; l; l=BMIter_Step(&liter)) {
|
||||
f = BMIter_New(&iter, walker->bm, BM_FACES_OF_EDGE, l->e);
|
||||
for (; f; f=BMIter_Step(&iter)) {
|
||||
if (!BMO_TestFlag(walker->bm, f, walker->restrictflag))
|
||||
continue;
|
||||
if (BLI_ghash_haskey(walker->visithash, f)) continue;
|
||||
|
||||
BMW_pushstate(walker);
|
||||
iwalk = walker->currentstate;
|
||||
iwalk->cur = f;
|
||||
BLI_ghash_insert(walker->visithash, f, NULL);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return curf;
|
||||
}
|
||||
|
||||
|
||||
/* Island Walker:
|
||||
*
|
||||
* Starts at a tool flagged-face and walks over the face region
|
||||
*
|
||||
* TODO:
|
||||
*
|
||||
* Add restriction flag/callback for wire edges.
|
||||
*
|
||||
*/
|
||||
|
||||
static void loopWalker_begin(BMWalker *walker, void *data){
|
||||
loopWalker *lwalk = NULL, owalk;
|
||||
BMEdge *e = data;
|
||||
BMVert *v;
|
||||
int /* found=1, */ val;
|
||||
|
||||
v = e->v1;
|
||||
|
||||
val = BM_Vert_EdgeCount(v);
|
||||
|
||||
BMW_pushstate(walker);
|
||||
|
||||
lwalk = walker->currentstate;
|
||||
BLI_ghash_insert(walker->visithash, e, NULL);
|
||||
|
||||
lwalk->cur = lwalk->start = e;
|
||||
lwalk->lastv = lwalk->startv = v;
|
||||
lwalk->stage2 = 0;
|
||||
lwalk->startrad = BM_Edge_FaceCount(e);
|
||||
|
||||
/*rewind*/
|
||||
while (walker->currentstate) {
|
||||
owalk = *((loopWalker*)walker->currentstate);
|
||||
BMW_walk(walker);
|
||||
}
|
||||
|
||||
BMW_pushstate(walker);
|
||||
lwalk = walker->currentstate;
|
||||
*lwalk = owalk;
|
||||
|
||||
if (lwalk->lastv == owalk.cur->v1) lwalk->lastv = owalk.cur->v2;
|
||||
else lwalk->lastv = owalk.cur->v1;
|
||||
|
||||
lwalk->startv = lwalk->lastv;
|
||||
|
||||
BLI_ghash_free(walker->visithash, NULL, NULL);
|
||||
walker->visithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh walkers 2");
|
||||
BLI_ghash_insert(walker->visithash, owalk.cur, NULL);
|
||||
}
|
||||
|
||||
static void *loopWalker_yield(BMWalker *walker)
|
||||
{
|
||||
loopWalker *lwalk = walker->currentstate;
|
||||
|
||||
return lwalk->cur;
|
||||
}
|
||||
|
||||
static void *loopWalker_step(BMWalker *walker)
|
||||
{
|
||||
loopWalker *lwalk = walker->currentstate, owalk;
|
||||
BMEdge *e = lwalk->cur /* , *nexte = NULL */;
|
||||
BMLoop *l, *l2;
|
||||
BMVert *v;
|
||||
int val, rlen /* , found=0 */, i=0, stopi;
|
||||
|
||||
owalk = *lwalk;
|
||||
|
||||
if (e->v1 == lwalk->lastv) v = e->v2;
|
||||
else v = e->v1;
|
||||
|
||||
val = BM_Vert_EdgeCount(v);
|
||||
|
||||
BMW_popstate(walker);
|
||||
|
||||
rlen = owalk.startrad;
|
||||
l = e->l;
|
||||
if (!l)
|
||||
return owalk.cur;
|
||||
|
||||
if (val == 4 || val == 2 || rlen == 1) {
|
||||
i = 0;
|
||||
stopi = val / 2;
|
||||
while (1) {
|
||||
if (rlen != 1 && i == stopi) break;
|
||||
|
||||
l = BM_OtherFaceLoop(l->e, l->f, v);
|
||||
|
||||
if (!l)
|
||||
break;
|
||||
|
||||
l2 = bmesh_radial_nextloop(l);
|
||||
|
||||
if (l2 == l) {
|
||||
break;
|
||||
}
|
||||
|
||||
l = l2;
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!l)
|
||||
return owalk.cur;
|
||||
|
||||
if (l != e->l && !BLI_ghash_haskey(walker->visithash, l->e)) {
|
||||
if (!(rlen != 1 && i != stopi)) {
|
||||
BMW_pushstate(walker);
|
||||
lwalk = walker->currentstate;
|
||||
*lwalk = owalk;
|
||||
lwalk->cur = l->e;
|
||||
lwalk->lastv = v;
|
||||
BLI_ghash_insert(walker->visithash, l->e, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return owalk.cur;
|
||||
}
|
||||
|
||||
static void faceloopWalker_begin(BMWalker *walker, void *data)
|
||||
{
|
||||
faceloopWalker *lwalk, owalk;
|
||||
BMEdge *e = data;
|
||||
|
||||
BMW_pushstate(walker);
|
||||
|
||||
if (!e->l) return;
|
||||
|
||||
lwalk = walker->currentstate;
|
||||
lwalk->l = e->l;
|
||||
lwalk->nocalc = 0;
|
||||
BLI_ghash_insert(walker->visithash, lwalk->l->f, NULL);
|
||||
|
||||
/*rewind*/
|
||||
while (walker->currentstate) {
|
||||
owalk = *((faceloopWalker*)walker->currentstate);
|
||||
BMW_walk(walker);
|
||||
}
|
||||
|
||||
BMW_pushstate(walker);
|
||||
lwalk = walker->currentstate;
|
||||
*lwalk = owalk;
|
||||
lwalk->nocalc = 0;
|
||||
|
||||
BLI_ghash_free(walker->visithash, NULL, NULL);
|
||||
walker->visithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh walkers 3");
|
||||
BLI_ghash_insert(walker->visithash, lwalk->l->f, NULL);
|
||||
}
|
||||
|
||||
static void *faceloopWalker_yield(BMWalker *walker)
|
||||
{
|
||||
faceloopWalker *lwalk = walker->currentstate;
|
||||
|
||||
if (!lwalk) return NULL;
|
||||
|
||||
return lwalk->l->f;
|
||||
}
|
||||
|
||||
static void *faceloopWalker_step(BMWalker *walker)
|
||||
{
|
||||
faceloopWalker *lwalk = walker->currentstate;
|
||||
BMFace *f = lwalk->l->f;
|
||||
BMLoop *l = lwalk->l, *origl = lwalk->l;
|
||||
|
||||
BMW_popstate(walker);
|
||||
|
||||
l = l->radial_next;
|
||||
|
||||
if (lwalk->nocalc)
|
||||
return f;
|
||||
|
||||
if (BLI_ghash_haskey(walker->visithash, l->f)) {
|
||||
l = lwalk->l;
|
||||
l = l->next->next;
|
||||
if (l == l->radial_next) {
|
||||
l = l->prev->prev;
|
||||
}
|
||||
l = l->radial_next;
|
||||
}
|
||||
|
||||
if (!BLI_ghash_haskey(walker->visithash, l->f)) {
|
||||
BMW_pushstate(walker);
|
||||
lwalk = walker->currentstate;
|
||||
lwalk->l = l;
|
||||
|
||||
if (l->f->len != 4) {
|
||||
lwalk->nocalc = 1;
|
||||
lwalk->l = origl;
|
||||
} else
|
||||
lwalk->nocalc = 0;
|
||||
|
||||
BLI_ghash_insert(walker->visithash, l->f, NULL);
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
static void edgeringWalker_begin(BMWalker *walker, void *data)
|
||||
{
|
||||
edgeringWalker *lwalk, owalk;
|
||||
BMEdge *e = data;
|
||||
|
||||
if (!e->l) return;
|
||||
|
||||
BMW_pushstate(walker);
|
||||
|
||||
lwalk = walker->currentstate;
|
||||
lwalk->l = e->l;
|
||||
BLI_ghash_insert(walker->visithash, lwalk->l->e, NULL);
|
||||
|
||||
/*rewind*/
|
||||
while (walker->currentstate) {
|
||||
owalk = *((edgeringWalker*)walker->currentstate);
|
||||
BMW_walk(walker);
|
||||
}
|
||||
|
||||
BMW_pushstate(walker);
|
||||
lwalk = walker->currentstate;
|
||||
*lwalk = owalk;
|
||||
|
||||
if (lwalk->l->f->len != 4)
|
||||
lwalk->l = lwalk->l->radial_next;
|
||||
|
||||
BLI_ghash_free(walker->visithash, NULL, NULL);
|
||||
walker->visithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh walkers 4");
|
||||
BLI_ghash_insert(walker->visithash, lwalk->l->e, NULL);
|
||||
}
|
||||
|
||||
static void *edgeringWalker_yield(BMWalker *walker)
|
||||
{
|
||||
edgeringWalker *lwalk = walker->currentstate;
|
||||
|
||||
if (!lwalk) return NULL;
|
||||
|
||||
return lwalk->l->e;
|
||||
}
|
||||
|
||||
static void *edgeringWalker_step(BMWalker *walker)
|
||||
{
|
||||
edgeringWalker *lwalk = walker->currentstate;
|
||||
BMEdge *e = lwalk->l->e;
|
||||
BMLoop *l = lwalk->l /* , *origl = lwalk->l */;
|
||||
|
||||
BMW_popstate(walker);
|
||||
|
||||
l = l->radial_next;
|
||||
l = l->next->next;
|
||||
|
||||
if (l->f->len != 4) {
|
||||
l = lwalk->l->next->next;
|
||||
}
|
||||
|
||||
if (l->f->len == 4 && !BLI_ghash_haskey(walker->visithash, l->e)) {
|
||||
BMW_pushstate(walker);
|
||||
lwalk = walker->currentstate;
|
||||
lwalk->l = l;
|
||||
|
||||
BLI_ghash_insert(walker->visithash, l->e, NULL);
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
static void uvedgeWalker_begin(BMWalker *walker, void *data)
|
||||
{
|
||||
uvedgeWalker *lwalk;
|
||||
BMLoop *l = data;
|
||||
|
||||
if (BLI_ghash_haskey(walker->visithash, l))
|
||||
return;
|
||||
|
||||
BMW_pushstate(walker);
|
||||
lwalk = walker->currentstate;
|
||||
lwalk->l = l;
|
||||
BLI_ghash_insert(walker->visithash, l, NULL);
|
||||
}
|
||||
|
||||
static void *uvedgeWalker_yield(BMWalker *walker)
|
||||
{
|
||||
uvedgeWalker *lwalk = walker->currentstate;
|
||||
|
||||
if (!lwalk) return NULL;
|
||||
|
||||
return lwalk->l;
|
||||
}
|
||||
|
||||
static void *uvedgeWalker_step(BMWalker *walker)
|
||||
{
|
||||
uvedgeWalker *lwalk = walker->currentstate;
|
||||
BMLoop *l, *l2, *l3, *nl, *cl;
|
||||
BMIter liter;
|
||||
void *d1, *d2;
|
||||
int i, j, rlen, type;
|
||||
|
||||
l = lwalk->l;
|
||||
nl = l->next;
|
||||
type = walker->bm->ldata.layers[walker->flag].type;
|
||||
|
||||
BMW_popstate(walker);
|
||||
|
||||
if (walker->restrictflag && !BMO_TestFlag(walker->bm, l->e, walker->restrictflag))
|
||||
return l;
|
||||
|
||||
/*go over loops around l->v and nl->v and see which ones share l and nl's
|
||||
mloopuv's coordinates. in addition, push on l->next if necassary.*/
|
||||
for (i=0; i<2; i++) {
|
||||
cl = i ? nl : l;
|
||||
BM_ITER(l2, &liter, walker->bm, BM_LOOPS_OF_VERT, cl->v) {
|
||||
d1 = CustomData_bmesh_get_layer_n(&walker->bm->ldata,
|
||||
cl->head.data, walker->flag);
|
||||
|
||||
rlen = BM_Edge_FaceCount(l2->e);
|
||||
for (j=0; j<rlen; j++) {
|
||||
if (BLI_ghash_haskey(walker->visithash, l2))
|
||||
continue;
|
||||
if (walker->restrictflag && !(BMO_TestFlag(walker->bm, l2->e, walker->restrictflag)))
|
||||
{
|
||||
if (l2->v != cl->v)
|
||||
continue;
|
||||
}
|
||||
|
||||
l3 = l2->v != cl->v ? (BMLoop*)l2->next : l2;
|
||||
d2 = CustomData_bmesh_get_layer_n(&walker->bm->ldata,
|
||||
l3->head.data, walker->flag);
|
||||
|
||||
if (!CustomData_data_equals(type, d1, d2))
|
||||
continue;
|
||||
|
||||
BMW_pushstate(walker);
|
||||
BLI_ghash_insert(walker->visithash, l2, NULL);
|
||||
lwalk = walker->currentstate;
|
||||
|
||||
lwalk->l = l2;
|
||||
|
||||
l2 = l2->radial_next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
BMWalker shell_walker_type = {
|
||||
shellWalker_begin,
|
||||
shellWalker_step,
|
||||
shellWalker_yield,
|
||||
sizeof(shellWalker),
|
||||
};
|
||||
|
||||
BMWalker islandbound_walker_type = {
|
||||
islandboundWalker_begin,
|
||||
islandboundWalker_step,
|
||||
islandboundWalker_yield,
|
||||
sizeof(islandboundWalker),
|
||||
};
|
||||
|
||||
|
||||
BMWalker island_walker_type = {
|
||||
islandWalker_begin,
|
||||
islandWalker_step,
|
||||
islandWalker_yield,
|
||||
sizeof(islandWalker),
|
||||
};
|
||||
|
||||
BMWalker loop_walker_type = {
|
||||
loopWalker_begin,
|
||||
loopWalker_step,
|
||||
loopWalker_yield,
|
||||
sizeof(loopWalker),
|
||||
};
|
||||
|
||||
|
||||
BMWalker faceloop_walker_type = {
|
||||
faceloopWalker_begin,
|
||||
faceloopWalker_step,
|
||||
faceloopWalker_yield,
|
||||
sizeof(faceloopWalker),
|
||||
};
|
||||
|
||||
BMWalker edgering_walker_type = {
|
||||
edgeringWalker_begin,
|
||||
edgeringWalker_step,
|
||||
edgeringWalker_yield,
|
||||
sizeof(edgeringWalker),
|
||||
};
|
||||
|
||||
BMWalker loopdata_region_walker_type = {
|
||||
uvedgeWalker_begin,
|
||||
uvedgeWalker_step,
|
||||
uvedgeWalker_yield,
|
||||
sizeof(uvedgeWalker),
|
||||
};
|
||||
|
||||
BMWalker *bm_walker_types[] = {
|
||||
&shell_walker_type,
|
||||
&loop_walker_type,
|
||||
&faceloop_walker_type,
|
||||
&edgering_walker_type,
|
||||
&loopdata_region_walker_type,
|
||||
&islandbound_walker_type,
|
||||
&island_walker_type,
|
||||
};
|
||||
|
||||
int bm_totwalkers = sizeof(bm_walker_types) / sizeof(*bm_walker_types);
|
||||
|
||||
|
||||
74
source/blender/bmesh/intern/bmesh_walkers_private.h
Normal file
74
source/blender/bmesh/intern/bmesh_walkers_private.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* bmesh_walkers_private.h april 2011
|
||||
*
|
||||
* BMesh walker API.
|
||||
*
|
||||
* $Id: $
|
||||
*
|
||||
* ***** 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. The Blender
|
||||
* Foundation also sells licenses for use in proprietary software under
|
||||
* the Blender License. See http://www.blender.org/BL/ for information
|
||||
* about this.
|
||||
*
|
||||
* 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,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Contributor(s): Joseph Eagar, Geoffrey Bantle.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
extern BMWalker *bm_walker_types[];
|
||||
extern int bm_totwalkers;
|
||||
|
||||
typedef struct shellWalker{
|
||||
struct shellWalker *prev;
|
||||
BMVert *base;
|
||||
BMEdge *curedge, *current;
|
||||
} shellWalker;
|
||||
|
||||
typedef struct islandboundWalker {
|
||||
struct islandboundWalker *prev;
|
||||
BMLoop *base;
|
||||
BMVert *lastv;
|
||||
BMLoop *curloop;
|
||||
} islandboundWalker;
|
||||
|
||||
typedef struct islandWalker {
|
||||
struct islandWalker * prev;
|
||||
BMFace *cur;
|
||||
} islandWalker;
|
||||
|
||||
typedef struct loopWalker {
|
||||
struct loopWalker * prev;
|
||||
BMEdge *cur, *start;
|
||||
BMVert *lastv, *startv;
|
||||
int startrad, stage2;
|
||||
} loopWalker;
|
||||
|
||||
typedef struct faceloopWalker {
|
||||
struct faceloopWalker * prev;
|
||||
BMLoop *l;
|
||||
int nocalc;
|
||||
} faceloopWalker;
|
||||
|
||||
typedef struct edgeringWalker {
|
||||
struct edgeringWalker * prev;
|
||||
BMLoop *l;
|
||||
} edgeringWalker;
|
||||
|
||||
typedef struct uvedgeWalker {
|
||||
struct uvedgeWalker *prev;
|
||||
BMLoop *l;
|
||||
} uvedgeWalker;
|
||||
@@ -214,6 +214,7 @@ signed char monkeyf[250][4]= {
|
||||
#define EDGE_MARK 2
|
||||
|
||||
#define FACE_MARK 1
|
||||
#define FACE_NEW 2
|
||||
|
||||
void bmesh_create_grid_exec(BMesh *bm, BMOperator *op)
|
||||
{
|
||||
@@ -442,6 +443,76 @@ void bmesh_create_monkey_exec(BMesh *bm, BMOperator *op)
|
||||
BMO_Flag_To_Slot(bm, op, "vertout", VERT_MARK, BM_VERT);
|
||||
}
|
||||
|
||||
|
||||
void bmesh_create_circle_exec(BMesh *bm, BMOperator *op)
|
||||
{
|
||||
BMVert *v1, *lastv1=NULL, *cent1, *firstv1=NULL;
|
||||
float vec[3], mat[4][4], phi, phid;
|
||||
float dia = BMO_Get_Float(op, "diameter");
|
||||
int cap_ends = BMO_Get_Int(op, "cap_ends"), segs=BMO_Get_Int(op, "segments");
|
||||
int cap_tris=BMO_Get_Int(op, "cap_tris");
|
||||
int a;
|
||||
|
||||
if (!segs)
|
||||
return;
|
||||
|
||||
BMO_Get_Mat4(op, "mat", mat);
|
||||
|
||||
phid= 2.0f*(float)M_PI/segs;
|
||||
phi= .25f*(float)M_PI;
|
||||
|
||||
if (cap_ends) {
|
||||
vec[0] = vec[1] = 0.0f;
|
||||
vec[2] = 0.0;
|
||||
mul_m4_v3(mat, vec);
|
||||
|
||||
cent1 = BM_Make_Vert(bm, vec, NULL);
|
||||
}
|
||||
|
||||
for (a=0; a<segs; a++, phi+=phid) {
|
||||
vec[0]= dia*sin(phi);
|
||||
vec[1]= dia*cos(phi);
|
||||
vec[2]= 0.0f;
|
||||
mul_m4_v3(mat, vec);
|
||||
v1 = BM_Make_Vert(bm, vec, NULL);
|
||||
|
||||
BMO_SetFlag(bm, v1, VERT_MARK);
|
||||
|
||||
if (lastv1)
|
||||
BM_Make_Edge(bm, v1, lastv1, NULL, 0);
|
||||
|
||||
if (a && cap_ends) {
|
||||
BMFace *f;
|
||||
|
||||
f = BM_Make_QuadTri(bm, cent1, lastv1, v1, NULL, NULL, 0);
|
||||
BMO_SetFlag(bm, f, FACE_NEW);
|
||||
}
|
||||
|
||||
if (!firstv1)
|
||||
firstv1 = v1;
|
||||
|
||||
lastv1 = v1;
|
||||
}
|
||||
|
||||
if (!a)
|
||||
return;
|
||||
|
||||
BM_Make_Edge(bm, lastv1, firstv1, NULL, 0);
|
||||
|
||||
if (cap_ends) {
|
||||
BMFace *f;
|
||||
|
||||
f = BM_Make_QuadTri(bm, cent1, firstv1, v1, NULL, NULL, 0);
|
||||
BMO_SetFlag(bm, f, FACE_NEW);
|
||||
}
|
||||
|
||||
if (!cap_tris) {
|
||||
BMO_CallOpf(bm, "dissolvefaces faces=%ff", FACE_NEW);
|
||||
}
|
||||
|
||||
BMO_Flag_To_Slot(bm, op, "vertout", VERT_MARK, BM_VERT);
|
||||
}
|
||||
|
||||
void bmesh_create_cone_exec(BMesh *bm, BMOperator *op)
|
||||
{
|
||||
BMVert *v1, *v2, *lastv1=NULL, *lastv2=NULL, *cent1, *cent2, *firstv1, *firstv2;
|
||||
@@ -450,8 +521,12 @@ void bmesh_create_cone_exec(BMesh *bm, BMOperator *op)
|
||||
float dia2 = BMO_Get_Float(op, "diameter2");
|
||||
float depth = BMO_Get_Float(op, "depth");
|
||||
int cap_ends = BMO_Get_Int(op, "cap_ends"), segs=BMO_Get_Int(op, "segments");
|
||||
int cap_tris=BMO_Get_Int(op, "cap_tris");
|
||||
int a;
|
||||
|
||||
|
||||
if (!segs)
|
||||
return;
|
||||
|
||||
BMO_Get_Mat4(op, "mat", mat);
|
||||
|
||||
phid= 2.0f*(float)M_PI/segs;
|
||||
@@ -461,11 +536,14 @@ void bmesh_create_cone_exec(BMesh *bm, BMOperator *op)
|
||||
if (cap_ends) {
|
||||
vec[0] = vec[1] = 0.0f;
|
||||
vec[2] = -depth;
|
||||
|
||||
mul_m4_v3(mat, vec);
|
||||
|
||||
cent1 = BM_Make_Vert(bm, vec, NULL);
|
||||
|
||||
vec[0] = vec[1] = 0.0f;
|
||||
vec[2] = depth;
|
||||
mul_m4_v3(mat, vec);
|
||||
|
||||
cent2 = BM_Make_Vert(bm, vec, NULL);
|
||||
|
||||
BMO_SetFlag(bm, cent1, VERT_MARK);
|
||||
@@ -490,7 +568,12 @@ void bmesh_create_cone_exec(BMesh *bm, BMOperator *op)
|
||||
|
||||
if (a) {
|
||||
if (cap_ends) {
|
||||
BM_Make_QuadTri(bm, cent1, lastv1, v1, NULL, NULL, 0);
|
||||
BMFace *f;
|
||||
|
||||
f = BM_Make_QuadTri(bm, cent1, lastv1, v1, NULL, NULL, 0);
|
||||
BMO_SetFlag(bm, f, FACE_NEW);
|
||||
f = BM_Make_QuadTri(bm, v2, lastv2, cent2, NULL, NULL, 0);
|
||||
BMO_SetFlag(bm, f, FACE_NEW);
|
||||
}
|
||||
BM_Make_QuadTri(bm, lastv1, lastv2, v2, v1, NULL, 0);
|
||||
} else {
|
||||
@@ -506,9 +589,18 @@ void bmesh_create_cone_exec(BMesh *bm, BMOperator *op)
|
||||
return;
|
||||
|
||||
if (cap_ends) {
|
||||
BM_Make_QuadTri(bm, cent1, firstv1, v1, NULL, NULL, 0);
|
||||
BMFace *f;
|
||||
|
||||
f = BM_Make_QuadTri(bm, cent1, firstv1, v1, NULL, NULL, 0);
|
||||
BMO_SetFlag(bm, f, FACE_NEW);
|
||||
f = BM_Make_QuadTri(bm, v2, firstv2, cent2, NULL, NULL, 0);
|
||||
BMO_SetFlag(bm, f, FACE_NEW);
|
||||
}
|
||||
|
||||
|
||||
if (!cap_tris) {
|
||||
BMO_CallOpf(bm, "dissolvefaces faces=%ff", FACE_NEW);
|
||||
}
|
||||
|
||||
BM_Make_QuadTri(bm, firstv1, firstv2, v2, v1, NULL, 0);
|
||||
|
||||
BMO_CallOpf(bm, "removedoubles verts=%fv dist=%f", VERT_MARK, 0.000001);
|
||||
|
||||
@@ -6547,7 +6547,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
|
||||
float loc[3], rot[3];
|
||||
float mat[4][4];
|
||||
|
||||
if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
|
||||
if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
if (!isSurf) { /* adding curve */
|
||||
|
||||
@@ -104,8 +104,11 @@ float ED_object_new_primitive_matrix(struct bContext *C, struct Object *editob,
|
||||
|
||||
void ED_object_add_generic_props(struct wmOperatorType *ot, int do_editmode);
|
||||
int ED_object_add_generic_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
|
||||
int ED_object_add_generic_get_opts(struct bContext *C, struct wmOperator *op, float *loc, float *rot, int *enter_editmode, unsigned int *layer);
|
||||
struct Object *ED_object_add_type(struct bContext *C, int type, float *loc, float *rot, int enter_editmode, unsigned int layer);
|
||||
int ED_object_add_generic_get_opts(struct bContext *C, struct wmOperator *op,
|
||||
float *loc, float *rot, int *enter_editmode, unsigned int *layer, int *is_view_aligned);
|
||||
|
||||
struct Object *ED_object_add_type(struct bContext *C, int type, float *loc,
|
||||
float *rot, int enter_editmode, unsigned int layer);
|
||||
|
||||
void ED_object_single_users(struct Main *bmain, struct Scene *scene, int full);
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ static int add_primitive_plane_exec(bContext *C, wmOperator *op)
|
||||
int state;
|
||||
unsigned int layer;
|
||||
|
||||
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer);
|
||||
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
|
||||
make_prim_init(C, &dia, mat, &state, loc, rot, layer);
|
||||
|
||||
obedit = CTX_data_edit_object(C);
|
||||
@@ -211,7 +211,7 @@ static int add_primitive_cube_exec(bContext *C, wmOperator *op)
|
||||
int state;
|
||||
unsigned int layer;
|
||||
|
||||
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer);
|
||||
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
|
||||
make_prim_init(C, &dia, mat, &state, loc, rot, layer);
|
||||
|
||||
obedit= CTX_data_edit_object(C);
|
||||
@@ -245,20 +245,41 @@ void MESH_OT_primitive_cube_add(wmOperatorType *ot)
|
||||
ED_object_add_generic_props(ot, TRUE);
|
||||
}
|
||||
|
||||
static const EnumPropertyItem fill_type_items[]= {
|
||||
{0, "NOTHING", 0, "Nothing", "Don't fill at all"},
|
||||
{1, "NGON", 0, "Ngon", "Use ngons"},
|
||||
{2, "TRIFAN", 0, "Triangle Fan", "Use triangle fans"},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
static int add_primitive_circle_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
#if 0
|
||||
Object *obedit;
|
||||
Mesh *me;
|
||||
BMEditMesh *em;
|
||||
float loc[3], rot[3], mat[4][4], dia;
|
||||
int enter_editmode;
|
||||
float loc[3], rot[3];
|
||||
int state, cap_end, cap_tri;
|
||||
unsigned int layer;
|
||||
|
||||
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode);
|
||||
cap_end = RNA_enum_get(op->ptr, "fill_type");
|
||||
cap_tri = cap_end==2;
|
||||
|
||||
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
|
||||
make_prim_init(C, &dia, mat, &state, loc, rot, layer);
|
||||
|
||||
make_prim_ext(C, loc, rot, enter_editmode,
|
||||
PRIM_CIRCLE, RNA_int_get(op->ptr, "vertices"), 0, 0,
|
||||
RNA_float_get(op->ptr,"radius"), 0.0f, 0,
|
||||
RNA_boolean_get(op->ptr, "fill"));
|
||||
#endif
|
||||
return OPERATOR_FINISHED;
|
||||
obedit = CTX_data_edit_object(C);
|
||||
me = obedit->data;
|
||||
em = me->edit_btmesh;
|
||||
|
||||
if (!EDBM_CallAndSelectOpf(em, op, "vertout",
|
||||
"create_circle segments=%i diameter=%f cap_ends=%i cap_tris=%i mat=%m4",
|
||||
RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius"),
|
||||
cap_end, cap_tri, mat))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
make_prim_finish(C, &state, enter_editmode);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void MESH_OT_primitive_circle_add(wmOperatorType *ot)
|
||||
@@ -279,7 +300,7 @@ void MESH_OT_primitive_circle_add(wmOperatorType *ot)
|
||||
/* props */
|
||||
RNA_def_int(ot->srna, "vertices", 32, INT_MIN, INT_MAX, "Vertices", "", 3, 500);
|
||||
RNA_def_float(ot->srna, "radius", 1.0f, 0.0, FLT_MAX, "Radius", "", 0.001, 100.00);
|
||||
RNA_def_boolean(ot->srna, "fill", 0, "Fill", "");
|
||||
RNA_def_enum(ot->srna, "fill_type", &fill_type_items, 0, "Fill Type", "");
|
||||
|
||||
ED_object_add_generic_props(ot, TRUE);
|
||||
}
|
||||
@@ -291,10 +312,13 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op)
|
||||
BMEditMesh *em;
|
||||
float loc[3], rot[3], mat[4][4], dia;
|
||||
int enter_editmode;
|
||||
int state;
|
||||
int state, cap_end, cap_tri;
|
||||
unsigned int layer;
|
||||
|
||||
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer);
|
||||
cap_end = RNA_enum_get(op->ptr, "end_fill_type");
|
||||
cap_tri = cap_end==2;
|
||||
|
||||
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
|
||||
make_prim_init(C, &dia, mat, &state, loc, rot, layer);
|
||||
|
||||
obedit = CTX_data_edit_object(C);
|
||||
@@ -302,9 +326,9 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op)
|
||||
em = me->edit_btmesh;
|
||||
|
||||
if (!EDBM_CallAndSelectOpf(em, op, "vertout",
|
||||
"create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%i depth=%f mat=%m4",
|
||||
"create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%i cap_tris=%i depth=%f mat=%m4",
|
||||
RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius"),
|
||||
RNA_float_get(op->ptr, "radius"), (int)RNA_boolean_get(op->ptr, "cap_end"), RNA_float_get(op->ptr, "depth"), mat))
|
||||
RNA_float_get(op->ptr, "radius"), cap_end, cap_tri, RNA_float_get(op->ptr, "depth"), mat))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
make_prim_finish(C, &state, enter_editmode);
|
||||
@@ -317,7 +341,7 @@ void MESH_OT_primitive_cylinder_add(wmOperatorType *ot)
|
||||
/* identifiers */
|
||||
ot->name= "Add Tube";
|
||||
ot->description= "Construct a tube mesh.";
|
||||
ot->idname= "MESH_OT_primitive_tube_add";
|
||||
ot->idname= "MESH_OT_primitive_cylinder_add";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= ED_object_add_generic_invoke;
|
||||
@@ -331,7 +355,7 @@ void MESH_OT_primitive_cylinder_add(wmOperatorType *ot)
|
||||
RNA_def_int(ot->srna, "vertices", 32, INT_MIN, INT_MAX, "Vertices", "", 2, 500);
|
||||
RNA_def_float(ot->srna, "radius", 1.0f, 0.0, FLT_MAX, "Radius", "", 0.001, 100.00);
|
||||
RNA_def_float(ot->srna, "depth", 1.0f, 0.0, FLT_MAX, "Depth", "", 0.001, 100.00);
|
||||
RNA_def_boolean(ot->srna, "cap_ends", 1, "Cap Ends", "");
|
||||
RNA_def_enum(ot->srna, "end_fill_type", &fill_type_items, 1, "Cap Fill Type", "");
|
||||
|
||||
ED_object_add_generic_props(ot, TRUE);
|
||||
}
|
||||
@@ -343,10 +367,13 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op)
|
||||
BMEditMesh *em;
|
||||
float loc[3], rot[3], mat[4][4], dia;
|
||||
int enter_editmode;
|
||||
int state;
|
||||
int state, cap_end, cap_tri;
|
||||
unsigned int layer;
|
||||
|
||||
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer);
|
||||
cap_end = RNA_enum_get(op->ptr, "end_fill_type");
|
||||
cap_tri = cap_end==2;
|
||||
|
||||
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
|
||||
make_prim_init(C, &dia, mat, &state, loc, rot, layer);
|
||||
|
||||
obedit = CTX_data_edit_object(C);
|
||||
@@ -354,9 +381,9 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op)
|
||||
em = me->edit_btmesh;
|
||||
|
||||
if (!EDBM_CallAndSelectOpf(em, op, "vertout",
|
||||
"create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%i depth=%f mat=%m4",
|
||||
RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius"),
|
||||
0.0f, (int)RNA_boolean_get(op->ptr, "cap_end"), RNA_float_get(op->ptr, "depth"), mat))
|
||||
"create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%i cap_tris=%i depth=%f mat=%m4",
|
||||
RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius1"),
|
||||
RNA_float_get(op->ptr, "radius2"), cap_end, cap_tri, RNA_float_get(op->ptr, "depth"), mat))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
make_prim_finish(C, &state, enter_editmode);
|
||||
@@ -381,10 +408,11 @@ void MESH_OT_primitive_cone_add(wmOperatorType *ot)
|
||||
|
||||
/* props */
|
||||
RNA_def_int(ot->srna, "vertices", 32, INT_MIN, INT_MAX, "Vertices", "", 2, 500);
|
||||
RNA_def_float(ot->srna, "radius", 1.0f, 0.0, FLT_MAX, "Radius", "", 0.001, 100.00);
|
||||
RNA_def_float(ot->srna, "radius1", 1.0f, 0.0, FLT_MAX, "Radius 1", "", 0.001, 100.00);
|
||||
RNA_def_float(ot->srna, "radius2", 0.0f, 0.0, FLT_MAX, "Radius 2", "", 0.001, 100.00);
|
||||
RNA_def_float(ot->srna, "depth", 1.0f, 0.0, FLT_MAX, "Depth", "", 0.001, 100.00);
|
||||
RNA_def_boolean(ot->srna, "cap_end", 0, "Cap End", "");
|
||||
|
||||
RNA_def_enum(ot->srna, "end_fill_type", &fill_type_items, 1, "Base Fill Type", "");
|
||||
|
||||
ED_object_add_generic_props(ot, TRUE);
|
||||
}
|
||||
|
||||
@@ -398,7 +426,7 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op)
|
||||
int state;
|
||||
unsigned int layer;
|
||||
|
||||
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer);
|
||||
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
|
||||
make_prim_init(C, &dia, mat, &state, loc, rot, layer);
|
||||
|
||||
obedit = CTX_data_edit_object(C);
|
||||
@@ -448,10 +476,13 @@ static int add_primitive_monkey_exec(bContext *C, wmOperator *op)
|
||||
BMEditMesh *em;
|
||||
float loc[3], rot[3], mat[4][4], dia;
|
||||
int enter_editmode;
|
||||
int state;
|
||||
int state, view_aligned;
|
||||
unsigned int layer;
|
||||
|
||||
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer);
|
||||
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, &view_aligned);
|
||||
if (!view_aligned)
|
||||
rot[0] += M_PI/2.0f;
|
||||
|
||||
make_prim_init(C, &dia, mat, &state, loc, rot, layer);
|
||||
|
||||
obedit = CTX_data_edit_object(C);
|
||||
@@ -495,7 +526,7 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op)
|
||||
int state;
|
||||
unsigned int layer;
|
||||
|
||||
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer);
|
||||
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
|
||||
make_prim_init(C, &dia, mat, &state, loc, rot, layer);
|
||||
|
||||
obedit = CTX_data_edit_object(C);
|
||||
@@ -546,7 +577,7 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op)
|
||||
int state;
|
||||
unsigned int layer;
|
||||
|
||||
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer);
|
||||
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
|
||||
make_prim_init(C, &dia, mat, &state, loc, rot, layer);
|
||||
|
||||
obedit = CTX_data_edit_object(C);
|
||||
|
||||
@@ -229,7 +229,8 @@ int ED_object_add_generic_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(ev
|
||||
return op->type->exec(C, op);
|
||||
}
|
||||
|
||||
int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, float *rot, int *enter_editmode, unsigned int *layer)
|
||||
int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc,
|
||||
float *rot, int *enter_editmode, unsigned int *layer, int *is_view_aligned)
|
||||
{
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
int a, layer_values[20];
|
||||
@@ -275,7 +276,9 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, floa
|
||||
else
|
||||
RNA_float_get_array(op->ptr, "rotation", rot);
|
||||
|
||||
|
||||
if (is_view_aligned)
|
||||
*is_view_aligned = view_align;
|
||||
|
||||
RNA_float_get_array(op->ptr, "location", loc);
|
||||
|
||||
if(*layer == 0) {
|
||||
@@ -288,7 +291,8 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, floa
|
||||
|
||||
/* for object add primitive operators */
|
||||
/* do not call undo push in this function (users of this function have to) */
|
||||
Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot, int enter_editmode, unsigned int layer)
|
||||
Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot,
|
||||
int enter_editmode, unsigned int layer)
|
||||
{
|
||||
Main *bmain= CTX_data_main(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
@@ -325,7 +329,7 @@ static int object_add_exec(bContext *C, wmOperator *op)
|
||||
unsigned int layer;
|
||||
float loc[3], rot[3];
|
||||
|
||||
if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
|
||||
if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
ED_object_add_type(C, RNA_enum_get(op->ptr, "type"), loc, rot, enter_editmode, layer);
|
||||
@@ -382,7 +386,7 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type)
|
||||
|
||||
object_add_generic_invoke_options(C, op);
|
||||
|
||||
if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
|
||||
if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
|
||||
return NULL;
|
||||
|
||||
if(type==PFIELD_GUIDE) {
|
||||
@@ -462,7 +466,7 @@ static int object_camera_add_exec(bContext *C, wmOperator *op)
|
||||
|
||||
object_add_generic_invoke_options(C, op);
|
||||
|
||||
if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
|
||||
if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
ob= ED_object_add_type(C, OB_CAMERA, loc, rot, FALSE, layer);
|
||||
@@ -516,7 +520,7 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op)
|
||||
|
||||
object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called
|
||||
|
||||
if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
|
||||
if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
if(obedit==NULL || obedit->type!=OB_MBALL) {
|
||||
@@ -585,7 +589,7 @@ static int object_add_text_exec(bContext *C, wmOperator *op)
|
||||
float loc[3], rot[3];
|
||||
|
||||
object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called
|
||||
if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
|
||||
if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
if(obedit && obedit->type==OB_FONT)
|
||||
@@ -626,7 +630,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op)
|
||||
float loc[3], rot[3];
|
||||
|
||||
object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called
|
||||
if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
|
||||
if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
if ((obedit==NULL) || (obedit->type != OB_ARMATURE)) {
|
||||
@@ -692,7 +696,7 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op)
|
||||
float loc[3], rot[3];
|
||||
|
||||
object_add_generic_invoke_options(C, op);
|
||||
if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
|
||||
if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
ob= ED_object_add_type(C, OB_LAMP, loc, rot, FALSE, layer);
|
||||
@@ -741,7 +745,7 @@ static int group_instance_add_exec(bContext *C, wmOperator *op)
|
||||
float loc[3], rot[3];
|
||||
|
||||
object_add_generic_invoke_options(C, op);
|
||||
if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
|
||||
if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
if(group) {
|
||||
|
||||
Reference in New Issue
Block a user