Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
/**
|
|
|
|
|
* $Id:
|
|
|
|
|
*
|
|
|
|
|
* ***** BEGIN GPL/BL DUAL 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.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2004 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
2005-07-13 15:20:40 +00:00
|
|
|
* Contributor(s): Johnny Matthews.
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
*
|
|
|
|
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
editmesh_tool.c: UI called tools for editmesh, geometry changes here, otherwise in mods.c
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
#include "BMF_Api.h"
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
|
#include "DNA_material_types.h"
|
|
|
|
|
#include "DNA_meshdata_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
#include "DNA_view3d_types.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
#include "BLI_arithb.h"
|
|
|
|
|
#include "BLI_editVert.h"
|
|
|
|
|
#include "BLI_rand.h"
|
2005-07-13 15:20:40 +00:00
|
|
|
#include "BLI_ghash.h"
|
|
|
|
|
#include "BLI_linklist.h"
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
#include "BKE_depsgraph.h"
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_library.h"
|
|
|
|
|
#include "BKE_mesh.h"
|
|
|
|
|
#include "BKE_object.h"
|
|
|
|
|
#include "BKE_utildefines.h"
|
|
|
|
|
|
|
|
|
|
#include "BIF_cursors.h"
|
|
|
|
|
#include "BIF_editmesh.h"
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
|
#include "BIF_graphics.h"
|
|
|
|
|
#include "BIF_interface.h"
|
|
|
|
|
#include "BIF_mywindow.h"
|
|
|
|
|
#include "BIF_screen.h"
|
|
|
|
|
#include "BIF_space.h"
|
|
|
|
|
#include "BIF_resources.h"
|
|
|
|
|
#include "BIF_toolbox.h"
|
2005-03-14 14:16:59 +00:00
|
|
|
#include "BIF_transform.h"
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
#include "BDR_drawobject.h"
|
|
|
|
|
#include "BDR_editobject.h"
|
|
|
|
|
|
|
|
|
|
#include "BSE_view.h"
|
|
|
|
|
#include "BSE_edit.h"
|
|
|
|
|
|
|
|
|
|
#include "mydevice.h"
|
|
|
|
|
#include "blendef.h"
|
|
|
|
|
|
|
|
|
|
#include "editmesh.h"
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
#include "MTC_vectorops.h"
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 16:33:30 +00:00
|
|
|
#include "PIL_time.h"
|
|
|
|
|
|
2005-03-09 19:45:59 +00:00
|
|
|
/* local prototypes ---------------*/
|
|
|
|
|
void bevel_menu(void);
|
2005-07-13 15:20:40 +00:00
|
|
|
static void free_tagged_edgelist(EditEdge *eed);
|
|
|
|
|
static void free_tagged_facelist(EditFace *efa);
|
2005-08-10 03:51:34 +00:00
|
|
|
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
/********* qsort routines *********/
|
|
|
|
|
|
|
|
|
|
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
typedef struct xvertsort {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
float x;
|
|
|
|
|
EditVert *v1;
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
} xvertsort;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
static int vergxco(const void *v1, const void *v2)
|
|
|
|
|
{
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
const xvertsort *x1=v1, *x2=v2;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
if( x1->x > x2->x ) return 1;
|
|
|
|
|
else if( x1->x < x2->x) return -1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct facesort {
|
2005-07-14 13:12:29 +00:00
|
|
|
unsigned long x;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
struct EditFace *efa;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int vergface(const void *v1, const void *v2)
|
|
|
|
|
{
|
|
|
|
|
const struct facesort *x1=v1, *x2=v2;
|
|
|
|
|
|
|
|
|
|
if( x1->x > x2->x ) return 1;
|
|
|
|
|
else if( x1->x < x2->x) return -1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* *********************************** */
|
|
|
|
|
|
2005-08-17 13:26:42 +00:00
|
|
|
void convert_to_triface(int direction)
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
{
|
|
|
|
|
EditMesh *em = G.editMesh;
|
|
|
|
|
EditFace *efa, *efan, *next;
|
2005-08-17 13:26:42 +00:00
|
|
|
float fac;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
efa= em->faces.last;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
while(efa) {
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
next= efa->prev;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
if(efa->v4) {
|
2005-08-17 13:26:42 +00:00
|
|
|
if(efa->f & SELECT) {
|
2005-08-14 10:58:17 +00:00
|
|
|
/* choose shortest diagonal for split */
|
2005-08-17 13:26:42 +00:00
|
|
|
fac= VecLenf(efa->v1->co, efa->v3->co) - VecLenf(efa->v2->co, efa->v4->co);
|
|
|
|
|
/* this makes sure exact squares get split different in both cases */
|
|
|
|
|
if( (direction==0 && fac<FLT_EPSILON) || (direction && fac>0.0f) ) {
|
2005-08-14 10:58:17 +00:00
|
|
|
|
|
|
|
|
efan= addfacelist(efa->v1, efa->v2, efa->v3, 0, efa, NULL);
|
|
|
|
|
if(efa->f & SELECT) EM_select_face(efan, 1);
|
|
|
|
|
efan= addfacelist(efa->v1, efa->v3, efa->v4, 0, efa, NULL);
|
|
|
|
|
if(efa->f & SELECT) EM_select_face(efan, 1);
|
|
|
|
|
|
|
|
|
|
efan->tf.uv[1][0]= efan->tf.uv[2][0];
|
|
|
|
|
efan->tf.uv[1][1]= efan->tf.uv[2][1];
|
|
|
|
|
efan->tf.uv[2][0]= efan->tf.uv[3][0];
|
|
|
|
|
efan->tf.uv[2][1]= efan->tf.uv[3][1];
|
|
|
|
|
|
|
|
|
|
efan->tf.col[1]= efan->tf.col[2];
|
|
|
|
|
efan->tf.col[2]= efan->tf.col[3];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
efan= addfacelist(efa->v1, efa->v2, efa->v4, 0, efa, NULL);
|
|
|
|
|
if(efa->f & SELECT) EM_select_face(efan, 1);
|
|
|
|
|
|
|
|
|
|
efan->tf.uv[2][0]= efan->tf.uv[3][0];
|
|
|
|
|
efan->tf.uv[2][1]= efan->tf.uv[3][1];
|
|
|
|
|
efan->tf.col[2]= efan->tf.col[3];
|
|
|
|
|
|
|
|
|
|
efan= addfacelist(efa->v2, efa->v3, efa->v4, 0, efa, NULL);
|
|
|
|
|
if(efa->f & SELECT) EM_select_face(efan, 1);
|
|
|
|
|
|
|
|
|
|
efan->tf.uv[0][0]= efan->tf.uv[1][0];
|
|
|
|
|
efan->tf.uv[0][1]= efan->tf.uv[1][1];
|
|
|
|
|
efan->tf.uv[1][0]= efan->tf.uv[2][0];
|
|
|
|
|
efan->tf.uv[1][1]= efan->tf.uv[2][1];
|
|
|
|
|
efan->tf.uv[2][0]= efan->tf.uv[3][0];
|
|
|
|
|
efan->tf.uv[2][1]= efan->tf.uv[3][1];
|
|
|
|
|
|
|
|
|
|
efan->tf.col[0]= efan->tf.col[1];
|
|
|
|
|
efan->tf.col[1]= efan->tf.col[2];
|
|
|
|
|
efan->tf.col[2]= efan->tf.col[3];
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
BLI_remlink(&em->faces, efa);
|
|
|
|
|
free_editface(efa);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
efa= next;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-24 16:06:20 +00:00
|
|
|
EM_fgon_flags(); // redo flags and indices for fgons
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
BIF_undo_push("Convert Quads to Triangles");
|
|
|
|
|
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-24 16:29:10 +00:00
|
|
|
int removedoublesflag(short flag, float limit) /* return amount */
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
{
|
|
|
|
|
EditMesh *em = G.editMesh;
|
|
|
|
|
/* all verts with (flag & 'flag') are being evaluated */
|
|
|
|
|
EditVert *eve, *v1, *nextve;
|
|
|
|
|
EditEdge *eed, *e1, *nexted;
|
|
|
|
|
EditFace *efa, *nextvl;
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
xvertsort *sortblock, *sb, *sb1;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
struct facesort *vlsortblock, *vsb, *vsb1;
|
|
|
|
|
float dist;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
int a, b, test, amount;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
/* flag 128 is cleared, count */
|
|
|
|
|
eve= em->verts.first;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
amount= 0;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
while(eve) {
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
eve->f &= ~128;
|
2005-06-07 13:04:31 +00:00
|
|
|
if(eve->h==0 && (eve->f & flag)) amount++;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
eve= eve->next;
|
|
|
|
|
}
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if(amount==0) return 0;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
/* allocate memory and qsort */
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
sb= sortblock= MEM_mallocN(sizeof(xvertsort)*amount,"sortremovedoub");
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
eve= em->verts.first;
|
|
|
|
|
while(eve) {
|
2005-06-07 13:04:31 +00:00
|
|
|
if(eve->h==0 && (eve->f & flag)) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
sb->x= eve->co[0]+eve->co[1]+eve->co[2];
|
|
|
|
|
sb->v1= eve;
|
|
|
|
|
sb++;
|
|
|
|
|
}
|
|
|
|
|
eve= eve->next;
|
|
|
|
|
}
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
qsort(sortblock, amount, sizeof(xvertsort), vergxco);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
/* test for doubles */
|
|
|
|
|
sb= sortblock;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
for(a=0; a<amount; a++) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
eve= sb->v1;
|
|
|
|
|
if( (eve->f & 128)==0 ) {
|
|
|
|
|
sb1= sb+1;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
for(b=a+1; b<amount; b++) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
/* first test: simpel dist */
|
|
|
|
|
dist= sb1->x - sb->x;
|
|
|
|
|
if(dist > limit) break;
|
|
|
|
|
|
|
|
|
|
/* second test: is vertex allowed */
|
|
|
|
|
v1= sb1->v1;
|
|
|
|
|
if( (v1->f & 128)==0 ) {
|
|
|
|
|
|
2005-05-13 10:20:10 +00:00
|
|
|
dist= (float)fabs(v1->co[0]-eve->co[0]);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
if(dist<=limit) {
|
2005-05-13 10:20:10 +00:00
|
|
|
dist= (float)fabs(v1->co[1]-eve->co[1]);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
if(dist<=limit) {
|
2005-05-13 10:20:10 +00:00
|
|
|
dist= (float)fabs(v1->co[2]-eve->co[2]);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
if(dist<=limit) {
|
|
|
|
|
v1->f|= 128;
|
|
|
|
|
v1->vn= eve;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sb1++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sb++;
|
|
|
|
|
}
|
|
|
|
|
MEM_freeN(sortblock);
|
|
|
|
|
|
|
|
|
|
/* test edges and insert again */
|
|
|
|
|
eed= em->edges.first;
|
|
|
|
|
while(eed) {
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
eed->f2= 0;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
eed= eed->next;
|
|
|
|
|
}
|
|
|
|
|
eed= em->edges.last;
|
|
|
|
|
while(eed) {
|
|
|
|
|
nexted= eed->prev;
|
|
|
|
|
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if(eed->f2==0) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
if( (eed->v1->f & 128) || (eed->v2->f & 128) ) {
|
|
|
|
|
remedge(eed);
|
|
|
|
|
|
|
|
|
|
if(eed->v1->f & 128) eed->v1= eed->v1->vn;
|
|
|
|
|
if(eed->v2->f & 128) eed->v2= eed->v2->vn;
|
|
|
|
|
e1= addedgelist(eed->v1, eed->v2, eed);
|
|
|
|
|
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if(e1) e1->f2= 1;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
if(e1!=eed) free_editedge(eed);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
eed= nexted;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* first count amount of test faces */
|
|
|
|
|
efa= (struct EditFace *)em->faces.first;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
amount= 0;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
while(efa) {
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
efa->f1= 0;
|
|
|
|
|
if(efa->v1->f & 128) efa->f1= 1;
|
|
|
|
|
else if(efa->v2->f & 128) efa->f1= 1;
|
|
|
|
|
else if(efa->v3->f & 128) efa->f1= 1;
|
|
|
|
|
else if(efa->v4 && (efa->v4->f & 128)) efa->f1= 1;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if(efa->f1==1) amount++;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
efa= efa->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* test faces for double vertices, and if needed remove them */
|
|
|
|
|
efa= (struct EditFace *)em->faces.first;
|
|
|
|
|
while(efa) {
|
|
|
|
|
nextvl= efa->next;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if(efa->f1==1) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
if(efa->v1->f & 128) efa->v1= efa->v1->vn;
|
|
|
|
|
if(efa->v2->f & 128) efa->v2= efa->v2->vn;
|
|
|
|
|
if(efa->v3->f & 128) efa->v3= efa->v3->vn;
|
|
|
|
|
if(efa->v4 && (efa->v4->f & 128)) efa->v4= efa->v4->vn;
|
|
|
|
|
|
|
|
|
|
test= 0;
|
|
|
|
|
if(efa->v1==efa->v2) test+=1;
|
|
|
|
|
if(efa->v2==efa->v3) test+=2;
|
|
|
|
|
if(efa->v3==efa->v1) test+=4;
|
|
|
|
|
if(efa->v4==efa->v1) test+=8;
|
|
|
|
|
if(efa->v3==efa->v4) test+=16;
|
|
|
|
|
if(efa->v2==efa->v4) test+=32;
|
|
|
|
|
|
|
|
|
|
if(test) {
|
|
|
|
|
if(efa->v4) {
|
|
|
|
|
if(test==1 || test==2) {
|
|
|
|
|
efa->v2= efa->v3;
|
|
|
|
|
efa->v3= efa->v4;
|
|
|
|
|
efa->v4= 0;
|
|
|
|
|
test= 0;
|
|
|
|
|
}
|
|
|
|
|
else if(test==8 || test==16) {
|
|
|
|
|
efa->v4= 0;
|
|
|
|
|
test= 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_remlink(&em->faces, efa);
|
|
|
|
|
free_editface(efa);
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
amount--;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_remlink(&em->faces, efa);
|
|
|
|
|
free_editface(efa);
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
amount--;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(test==0) {
|
|
|
|
|
/* set edge pointers */
|
|
|
|
|
efa->e1= findedgelist(efa->v1, efa->v2);
|
|
|
|
|
efa->e2= findedgelist(efa->v2, efa->v3);
|
|
|
|
|
if(efa->v4==0) {
|
|
|
|
|
efa->e3= findedgelist(efa->v3, efa->v1);
|
|
|
|
|
efa->e4= 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
efa->e3= findedgelist(efa->v3, efa->v4);
|
|
|
|
|
efa->e4= findedgelist(efa->v4, efa->v1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
efa= nextvl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* double faces: sort block */
|
|
|
|
|
/* count again, now all selected faces */
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
amount= 0;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
efa= em->faces.first;
|
|
|
|
|
while(efa) {
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
efa->f1= 0;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
if(faceselectedAND(efa, 1)) {
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
efa->f1= 1;
|
|
|
|
|
amount++;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
efa= efa->next;
|
|
|
|
|
}
|
|
|
|
|
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if(amount) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
/* double faces: sort block */
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
vsb= vlsortblock= MEM_mallocN(sizeof(struct facesort)*amount, "sortremovedoub");
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
efa= em->faces.first;
|
|
|
|
|
while(efa) {
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if(efa->f1 & 1) {
|
2005-07-14 13:12:29 +00:00
|
|
|
if(efa->v4) vsb->x= (unsigned long) MIN4( (unsigned long)efa->v1, (unsigned long)efa->v2, (unsigned long)efa->v3, (unsigned long)efa->v4);
|
|
|
|
|
else vsb->x= (unsigned long) MIN3( (unsigned long)efa->v1, (unsigned long)efa->v2, (unsigned long)efa->v3);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
vsb->efa= efa;
|
|
|
|
|
vsb++;
|
|
|
|
|
}
|
|
|
|
|
efa= efa->next;
|
|
|
|
|
}
|
|
|
|
|
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
qsort(vlsortblock, amount, sizeof(struct facesort), vergface);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
vsb= vlsortblock;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
for(a=0; a<amount; a++) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
efa= vsb->efa;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if( (efa->f1 & 128)==0 ) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
vsb1= vsb+1;
|
|
|
|
|
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
for(b=a+1; b<amount; b++) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
/* first test: same pointer? */
|
|
|
|
|
if(vsb->x != vsb1->x) break;
|
|
|
|
|
|
|
|
|
|
/* second test: is test permitted? */
|
|
|
|
|
efa= vsb1->efa;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if( (efa->f1 & 128)==0 ) {
|
|
|
|
|
if( compareface(efa, vsb->efa)) efa->f1 |= 128;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
vsb1++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
vsb++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MEM_freeN(vlsortblock);
|
|
|
|
|
|
|
|
|
|
/* remove double faces */
|
|
|
|
|
efa= (struct EditFace *)em->faces.first;
|
|
|
|
|
while(efa) {
|
|
|
|
|
nextvl= efa->next;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if(efa->f1 & 128) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
BLI_remlink(&em->faces, efa);
|
|
|
|
|
free_editface(efa);
|
|
|
|
|
}
|
|
|
|
|
efa= nextvl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* remove double vertices */
|
|
|
|
|
a= 0;
|
|
|
|
|
eve= (struct EditVert *)em->verts.first;
|
|
|
|
|
while(eve) {
|
|
|
|
|
nextve= eve->next;
|
|
|
|
|
if(eve->f & flag) {
|
|
|
|
|
if(eve->f & 128) {
|
|
|
|
|
a++;
|
|
|
|
|
BLI_remlink(&em->verts, eve);
|
|
|
|
|
free_editvert(eve);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
eve= nextve;
|
|
|
|
|
}
|
2004-09-24 16:06:20 +00:00
|
|
|
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
return a; /* amount */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* called from buttons */
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
static void xsortvert_flag__doSetX(void *userData, EditVert *eve, int x, int y, int index)
|
|
|
|
|
{
|
|
|
|
|
xvertsort *sortblock = userData;
|
|
|
|
|
|
|
|
|
|
sortblock[index].x = x;
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
void xsortvert_flag(int flag)
|
|
|
|
|
{
|
|
|
|
|
EditMesh *em = G.editMesh;
|
|
|
|
|
/* all verts with (flag & 'flag') are sorted */
|
|
|
|
|
EditVert *eve;
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
xvertsort *sortblock;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
ListBase tbase;
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
int i, amount = BLI_countlist(&em->verts);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
sortblock = MEM_callocN(sizeof(xvertsort)*amount,"xsort");
|
|
|
|
|
for (i=0,eve=em->verts.first; eve; i++,eve=eve->next)
|
|
|
|
|
if(eve->f & flag)
|
|
|
|
|
sortblock[i].v1 = eve;
|
|
|
|
|
mesh_foreachScreenVert(xsortvert_flag__doSetX, sortblock, 0);
|
|
|
|
|
qsort(sortblock, amount, sizeof(xvertsort), vergxco);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
/* make temporal listbase */
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
tbase.first= tbase.last= 0;
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
for (i=0; i<amount; i++) {
|
|
|
|
|
eve = sortblock[i].v1;
|
|
|
|
|
|
|
|
|
|
if (eve) {
|
|
|
|
|
BLI_remlink(&em->verts, eve);
|
|
|
|
|
BLI_addtail(&tbase, eve);
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addlisttolist(&em->verts, &tbase);
|
|
|
|
|
|
|
|
|
|
MEM_freeN(sortblock);
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
BIF_undo_push("Xsort");
|
|
|
|
|
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* called from buttons */
|
|
|
|
|
void hashvert_flag(int flag)
|
|
|
|
|
{
|
|
|
|
|
/* switch vertex order using hash table */
|
|
|
|
|
EditMesh *em = G.editMesh;
|
|
|
|
|
EditVert *eve;
|
|
|
|
|
struct xvertsort *sortblock, *sb, onth, *newsort;
|
|
|
|
|
ListBase tbase;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
int amount, a, b;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
/* count */
|
|
|
|
|
eve= em->verts.first;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
amount= 0;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
while(eve) {
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if(eve->f & flag) amount++;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
eve= eve->next;
|
|
|
|
|
}
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if(amount==0) return;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
/* allocate memory */
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
sb= sortblock= (struct xvertsort *)MEM_mallocN(sizeof(struct xvertsort)*amount,"sortremovedoub");
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
eve= em->verts.first;
|
|
|
|
|
while(eve) {
|
|
|
|
|
if(eve->f & flag) {
|
|
|
|
|
sb->v1= eve;
|
|
|
|
|
sb++;
|
|
|
|
|
}
|
|
|
|
|
eve= eve->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLI_srand(1);
|
|
|
|
|
|
|
|
|
|
sb= sortblock;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
for(a=0; a<amount; a++, sb++) {
|
2005-05-13 10:20:10 +00:00
|
|
|
b= (int)(amount*BLI_drand());
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if(b>=0 && b<amount) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
newsort= sortblock+b;
|
|
|
|
|
onth= *sb;
|
|
|
|
|
*sb= *newsort;
|
|
|
|
|
*newsort= onth;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* make temporal listbase */
|
|
|
|
|
tbase.first= tbase.last= 0;
|
|
|
|
|
sb= sortblock;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
while(amount--) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
eve= sb->v1;
|
|
|
|
|
BLI_remlink(&em->verts, eve);
|
|
|
|
|
BLI_addtail(&tbase, eve);
|
|
|
|
|
sb++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addlisttolist(&em->verts, &tbase);
|
|
|
|
|
|
|
|
|
|
MEM_freeN(sortblock);
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
BIF_undo_push("Hash");
|
|
|
|
|
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-14 14:16:59 +00:00
|
|
|
/* generic extern called extruder */
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
void extrude_mesh(void)
|
|
|
|
|
{
|
2005-03-14 14:16:59 +00:00
|
|
|
float nor[3]= {0.0, 0.0, 0.0};
|
|
|
|
|
short nr, transmode= 0;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
TEST_EDITMESH
|
|
|
|
|
|
2005-05-07 15:50:09 +00:00
|
|
|
if(G.scene->selectmode & SCE_SELECT_VERTEX) {
|
|
|
|
|
if(G.totvertsel==0) nr= 0;
|
|
|
|
|
else if(G.totvertsel==1) nr= 4;
|
|
|
|
|
else if(G.totedgesel==0) nr= 4;
|
|
|
|
|
else if(G.totfacesel==0)
|
|
|
|
|
nr= pupmenu("Extrude %t|Only Edges%x3|Only Vertices%x4");
|
|
|
|
|
else if(G.totfacesel==1)
|
2005-05-29 23:40:35 +00:00
|
|
|
nr= pupmenu("Extrude %t|Region %x1|Only Edges%x3|Only Vertices%x4");
|
2005-05-07 15:50:09 +00:00
|
|
|
else
|
|
|
|
|
nr= pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3|Only Vertices%x4");
|
|
|
|
|
}
|
|
|
|
|
else if(G.scene->selectmode & SCE_SELECT_EDGE) {
|
|
|
|
|
if (G.totedgesel==0) nr = 0;
|
|
|
|
|
else if (G.totedgesel==1) nr = 3;
|
|
|
|
|
else if(G.totfacesel==0) nr = 3;
|
|
|
|
|
else if(G.totfacesel==1)
|
|
|
|
|
nr= pupmenu("Extrude %t|Region %x1|Only Edges%x3");
|
|
|
|
|
else
|
|
|
|
|
nr= pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (G.totfacesel == 0) nr = 0;
|
|
|
|
|
else if (G.totfacesel == 1) nr = 1;
|
|
|
|
|
else
|
|
|
|
|
nr= pupmenu("Extrude %t|Region %x1||Individual Faces %x2");
|
|
|
|
|
}
|
2004-10-18 22:47:26 +00:00
|
|
|
|
|
|
|
|
if(nr<1) return;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
|
2005-03-14 14:16:59 +00:00
|
|
|
if(nr==1) transmode= extrudeflag(SELECT, nor);
|
|
|
|
|
else if(nr==4) transmode= extrudeflag_verts_indiv(SELECT, nor);
|
|
|
|
|
else if(nr==3) transmode= extrudeflag_edges_indiv(SELECT, nor);
|
|
|
|
|
else transmode= extrudeflag_face_indiv(SELECT, nor);
|
2004-10-18 22:47:26 +00:00
|
|
|
|
2005-03-14 14:16:59 +00:00
|
|
|
if(transmode==0) {
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
error("No valid selection");
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2004-09-24 16:06:20 +00:00
|
|
|
EM_fgon_flags();
|
2004-09-30 20:38:35 +00:00
|
|
|
countall();
|
2005-03-14 14:16:59 +00:00
|
|
|
|
2005-08-06 19:13:13 +00:00
|
|
|
/* We need to force immediate calculation here because
|
|
|
|
|
* transform may use derived objects (which are now stale).
|
|
|
|
|
*
|
|
|
|
|
* This shouldn't be necessary, derived queries should be
|
|
|
|
|
* automatically building this data if invalid. Or something.
|
|
|
|
|
*/
|
|
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
|
|
|
|
object_handle_update(G.obedit);
|
|
|
|
|
|
2005-03-14 14:16:59 +00:00
|
|
|
/* individual faces? */
|
2005-05-08 12:00:28 +00:00
|
|
|
BIF_TransformSetUndo("Extrude");
|
2005-03-14 14:16:59 +00:00
|
|
|
if(nr==2) {
|
2005-07-23 19:03:43 +00:00
|
|
|
initTransform(TFM_SHRINKFATTEN, CTX_NO_PET);
|
2005-05-10 04:21:11 +00:00
|
|
|
Transform();
|
2005-03-14 14:16:59 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2005-05-10 04:21:11 +00:00
|
|
|
initTransform(TFM_TRANSLATION, CTX_NO_PET);
|
2005-03-16 21:55:57 +00:00
|
|
|
if(transmode=='n') {
|
|
|
|
|
Mat4MulVecfl(G.obedit->obmat, nor);
|
|
|
|
|
VecSubf(nor, nor, G.obedit->obmat[3]);
|
2005-03-21 17:52:45 +00:00
|
|
|
BIF_setSingleAxisConstraint(nor, NULL);
|
2005-03-16 21:55:57 +00:00
|
|
|
}
|
2005-05-10 04:21:11 +00:00
|
|
|
Transform();
|
2005-03-14 14:16:59 +00:00
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void split_mesh(void)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
TEST_EDITMESH
|
|
|
|
|
|
|
|
|
|
if(okee(" Split ")==0) return;
|
|
|
|
|
|
|
|
|
|
waitcursor(1);
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
/* make duplicate first */
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
adduplicateflag(SELECT);
|
|
|
|
|
/* old faces have flag 128 set, delete them */
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
delfaceflag(128);
|
|
|
|
|
|
|
|
|
|
waitcursor(0);
|
|
|
|
|
|
|
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
2004-12-15 11:36:46 +00:00
|
|
|
BIF_undo_push("Split");
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void extrude_repeat_mesh(int steps, float offs)
|
|
|
|
|
{
|
2005-03-14 14:16:59 +00:00
|
|
|
float dvec[3], tmat[3][3], bmat[3][3], nor[3]= {0.0, 0.0, 0.0};
|
2005-07-25 10:58:21 +00:00
|
|
|
short a;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
TEST_EDITMESH
|
|
|
|
|
|
|
|
|
|
/* dvec */
|
|
|
|
|
dvec[0]= G.vd->persinv[2][0];
|
|
|
|
|
dvec[1]= G.vd->persinv[2][1];
|
|
|
|
|
dvec[2]= G.vd->persinv[2][2];
|
|
|
|
|
Normalise(dvec);
|
|
|
|
|
dvec[0]*= offs;
|
|
|
|
|
dvec[1]*= offs;
|
|
|
|
|
dvec[2]*= offs;
|
|
|
|
|
|
|
|
|
|
/* base correction */
|
|
|
|
|
Mat3CpyMat4(bmat, G.obedit->obmat);
|
|
|
|
|
Mat3Inv(tmat, bmat);
|
|
|
|
|
Mat3MulVecfl(tmat, dvec);
|
|
|
|
|
|
2005-07-25 10:58:21 +00:00
|
|
|
for(a=0; a<steps; a++) {
|
|
|
|
|
extrudeflag(SELECT, nor);
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
translateflag(SELECT, dvec);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
2004-09-24 16:06:20 +00:00
|
|
|
|
2005-07-25 10:58:21 +00:00
|
|
|
recalc_editnormals();
|
|
|
|
|
|
2004-09-24 16:06:20 +00:00
|
|
|
EM_fgon_flags();
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
countall();
|
2005-07-25 10:58:21 +00:00
|
|
|
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
2005-07-25 10:58:21 +00:00
|
|
|
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
BIF_undo_push("Extrude Repeat");
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void spin_mesh(int steps,int degr,float *dvec, int mode)
|
|
|
|
|
{
|
|
|
|
|
extern short editbutflag;
|
|
|
|
|
EditMesh *em = G.editMesh;
|
|
|
|
|
EditVert *eve,*nextve;
|
2005-03-14 14:16:59 +00:00
|
|
|
float nor[3]= {0.0, 0.0, 0.0};
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
float *curs, si,n[3],q[4],cmat[3][3],imat[3][3], tmat[3][3];
|
|
|
|
|
float cent[3],bmat[3][3];
|
|
|
|
|
float phi;
|
|
|
|
|
short a,ok;
|
|
|
|
|
|
|
|
|
|
TEST_EDITMESH
|
|
|
|
|
|
|
|
|
|
/* imat and centre and size */
|
|
|
|
|
Mat3CpyMat4(bmat, G.obedit->obmat);
|
|
|
|
|
Mat3Inv(imat,bmat);
|
|
|
|
|
|
|
|
|
|
curs= give_cursor();
|
|
|
|
|
VECCOPY(cent, curs);
|
|
|
|
|
cent[0]-= G.obedit->obmat[3][0];
|
|
|
|
|
cent[1]-= G.obedit->obmat[3][1];
|
|
|
|
|
cent[2]-= G.obedit->obmat[3][2];
|
|
|
|
|
Mat3MulVecfl(imat, cent);
|
|
|
|
|
|
2005-05-13 10:20:10 +00:00
|
|
|
phi= (float)(degr*M_PI/360.0);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
phi/= steps;
|
|
|
|
|
if(editbutflag & B_CLOCKWISE) phi= -phi;
|
|
|
|
|
|
|
|
|
|
if(dvec) {
|
|
|
|
|
n[0]=n[1]= 0.0;
|
|
|
|
|
n[2]= 1.0;
|
|
|
|
|
} else {
|
|
|
|
|
n[0]= G.vd->viewinv[2][0];
|
|
|
|
|
n[1]= G.vd->viewinv[2][1];
|
|
|
|
|
n[2]= G.vd->viewinv[2][2];
|
|
|
|
|
Normalise(n);
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-13 10:20:10 +00:00
|
|
|
q[0]= (float)cos(phi);
|
|
|
|
|
si= (float)sin(phi);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
q[1]= n[0]*si;
|
|
|
|
|
q[2]= n[1]*si;
|
|
|
|
|
q[3]= n[2]*si;
|
|
|
|
|
QuatToMat3(q, cmat);
|
|
|
|
|
|
|
|
|
|
Mat3MulMat3(tmat,cmat,bmat);
|
|
|
|
|
Mat3MulMat3(bmat,imat,tmat);
|
|
|
|
|
|
|
|
|
|
if(mode==0) if(editbutflag & B_KEEPORIG) adduplicateflag(1);
|
|
|
|
|
ok= 1;
|
|
|
|
|
|
|
|
|
|
for(a=0;a<steps;a++) {
|
2005-03-14 14:16:59 +00:00
|
|
|
if(mode==0) ok= extrudeflag(SELECT, nor);
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
else adduplicateflag(SELECT);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
if(ok==0) {
|
|
|
|
|
error("No valid vertices are selected");
|
|
|
|
|
break;
|
|
|
|
|
}
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
rotateflag(SELECT, cent, bmat);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
if(dvec) {
|
|
|
|
|
Mat3MulVecfl(bmat,dvec);
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
translateflag(SELECT, dvec);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ok==0) {
|
|
|
|
|
/* no vertices or only loose ones selected, remove duplicates */
|
|
|
|
|
eve= em->verts.first;
|
|
|
|
|
while(eve) {
|
|
|
|
|
nextve= eve->next;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if(eve->f & SELECT) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
BLI_remlink(&em->verts,eve);
|
|
|
|
|
free_editvert(eve);
|
|
|
|
|
}
|
|
|
|
|
eve= nextve;
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-07-25 10:58:21 +00:00
|
|
|
recalc_editnormals();
|
|
|
|
|
|
2004-09-24 16:06:20 +00:00
|
|
|
EM_fgon_flags();
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
2004-09-24 16:06:20 +00:00
|
|
|
|
|
|
|
|
if(dvec==NULL) BIF_undo_push("Spin");
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void screw_mesh(int steps,int turns)
|
|
|
|
|
{
|
|
|
|
|
EditMesh *em = G.editMesh;
|
|
|
|
|
EditVert *eve,*v1=0,*v2=0;
|
|
|
|
|
EditEdge *eed;
|
|
|
|
|
float dvec[3], nor[3];
|
|
|
|
|
|
|
|
|
|
TEST_EDITMESH
|
|
|
|
|
|
|
|
|
|
/* first condition: we need frontview! */
|
|
|
|
|
if(G.vd->view!=1) {
|
|
|
|
|
error("Must be in Front View");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* clear flags */
|
|
|
|
|
eve= em->verts.first;
|
|
|
|
|
while(eve) {
|
|
|
|
|
eve->f1= 0;
|
|
|
|
|
eve= eve->next;
|
|
|
|
|
}
|
|
|
|
|
/* edges set flags in verts */
|
|
|
|
|
eed= em->edges.first;
|
|
|
|
|
while(eed) {
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if(eed->v1->f & SELECT) {
|
|
|
|
|
if(eed->v2->f & SELECT) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
/* watch: f1 is a byte */
|
|
|
|
|
if(eed->v1->f1<2) eed->v1->f1++;
|
|
|
|
|
if(eed->v2->f1<2) eed->v2->f1++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
eed= eed->next;
|
|
|
|
|
}
|
|
|
|
|
/* find two vertices with eve->f1==1, more or less is wrong */
|
|
|
|
|
eve= em->verts.first;
|
|
|
|
|
while(eve) {
|
|
|
|
|
if(eve->f1==1) {
|
|
|
|
|
if(v1==0) v1= eve;
|
|
|
|
|
else if(v2==0) v2= eve;
|
|
|
|
|
else {
|
|
|
|
|
v1=0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
eve= eve->next;
|
|
|
|
|
}
|
|
|
|
|
if(v1==0 || v2==0) {
|
|
|
|
|
error("No curve is selected");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* calculate dvec */
|
|
|
|
|
dvec[0]= ( (v1->co[0]- v2->co[0]) )/(steps);
|
|
|
|
|
dvec[1]= ( (v1->co[1]- v2->co[1]) )/(steps);
|
|
|
|
|
dvec[2]= ( (v1->co[2]- v2->co[2]) )/(steps);
|
|
|
|
|
|
|
|
|
|
VECCOPY(nor, G.obedit->obmat[2]);
|
|
|
|
|
|
|
|
|
|
if(nor[0]*dvec[0]+nor[1]*dvec[1]+nor[2]*dvec[2]>0.000) {
|
|
|
|
|
dvec[0]= -dvec[0];
|
|
|
|
|
dvec[1]= -dvec[1];
|
|
|
|
|
dvec[2]= -dvec[2];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spin_mesh(turns*steps, turns*360, dvec, 0);
|
|
|
|
|
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
BIF_undo_push("Spin");
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void erase_edges(ListBase *l)
|
|
|
|
|
{
|
|
|
|
|
EditEdge *ed, *nexted;
|
|
|
|
|
|
|
|
|
|
ed = (EditEdge *) l->first;
|
|
|
|
|
while(ed) {
|
|
|
|
|
nexted= ed->next;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if( (ed->v1->f & SELECT) || (ed->v2->f & SELECT) ) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
remedge(ed);
|
|
|
|
|
free_editedge(ed);
|
|
|
|
|
}
|
|
|
|
|
ed= nexted;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void erase_faces(ListBase *l)
|
|
|
|
|
{
|
|
|
|
|
EditFace *f, *nextf;
|
|
|
|
|
|
|
|
|
|
f = (EditFace *) l->first;
|
|
|
|
|
|
|
|
|
|
while(f) {
|
|
|
|
|
nextf= f->next;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if( faceselectedOR(f, SELECT) ) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
BLI_remlink(l, f);
|
|
|
|
|
free_editface(f);
|
|
|
|
|
}
|
|
|
|
|
f = nextf;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void erase_vertices(ListBase *l)
|
|
|
|
|
{
|
|
|
|
|
EditVert *v, *nextv;
|
|
|
|
|
|
|
|
|
|
v = (EditVert *) l->first;
|
|
|
|
|
while(v) {
|
|
|
|
|
nextv= v->next;
|
|
|
|
|
if(v->f & 1) {
|
|
|
|
|
BLI_remlink(l, v);
|
|
|
|
|
free_editvert(v);
|
|
|
|
|
}
|
|
|
|
|
v = nextv;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void delete_mesh(void)
|
|
|
|
|
{
|
|
|
|
|
EditMesh *em = G.editMesh;
|
|
|
|
|
EditFace *efa, *nextvl;
|
|
|
|
|
EditVert *eve,*nextve;
|
|
|
|
|
EditEdge *eed,*nexted;
|
|
|
|
|
short event;
|
|
|
|
|
int count;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
char *str="Erase";
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
TEST_EDITMESH
|
|
|
|
|
|
|
|
|
|
event= pupmenu("Erase %t|Vertices%x10|Edges%x1|Faces%x2|All%x3|Edges & Faces%x4|Only Faces%x5");
|
|
|
|
|
if(event<1) return;
|
|
|
|
|
|
|
|
|
|
if(event==10 ) {
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
str= "Erase Vertices";
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
erase_edges(&em->edges);
|
|
|
|
|
erase_faces(&em->faces);
|
|
|
|
|
erase_vertices(&em->verts);
|
|
|
|
|
}
|
|
|
|
|
else if(event==4) {
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
str= "Erase Edges & Faces";
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
efa= em->faces.first;
|
|
|
|
|
while(efa) {
|
|
|
|
|
nextvl= efa->next;
|
2004-09-24 18:17:23 +00:00
|
|
|
/* delete only faces with 1 or more edges selected */
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
count= 0;
|
2004-09-24 18:17:23 +00:00
|
|
|
if(efa->e1->f & SELECT) count++;
|
|
|
|
|
if(efa->e2->f & SELECT) count++;
|
|
|
|
|
if(efa->e3->f & SELECT) count++;
|
|
|
|
|
if(efa->e4 && (efa->e4->f & SELECT)) count++;
|
|
|
|
|
if(count) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
BLI_remlink(&em->faces, efa);
|
|
|
|
|
free_editface(efa);
|
|
|
|
|
}
|
|
|
|
|
efa= nextvl;
|
|
|
|
|
}
|
|
|
|
|
eed= em->edges.first;
|
|
|
|
|
while(eed) {
|
|
|
|
|
nexted= eed->next;
|
2004-09-24 18:17:23 +00:00
|
|
|
if(eed->f & SELECT) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
remedge(eed);
|
|
|
|
|
free_editedge(eed);
|
|
|
|
|
}
|
|
|
|
|
eed= nexted;
|
|
|
|
|
}
|
|
|
|
|
efa= em->faces.first;
|
|
|
|
|
while(efa) {
|
|
|
|
|
nextvl= efa->next;
|
|
|
|
|
event=0;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if( efa->v1->f & SELECT) event++;
|
|
|
|
|
if( efa->v2->f & SELECT) event++;
|
|
|
|
|
if( efa->v3->f & SELECT) event++;
|
|
|
|
|
if(efa->v4 && (efa->v4->f & SELECT)) event++;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
if(event>1) {
|
|
|
|
|
BLI_remlink(&em->faces, efa);
|
|
|
|
|
free_editface(efa);
|
|
|
|
|
}
|
|
|
|
|
efa= nextvl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(event==1) {
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
str= "Erase Edges";
|
2004-09-24 18:17:23 +00:00
|
|
|
// faces first
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
efa= em->faces.first;
|
|
|
|
|
while(efa) {
|
|
|
|
|
nextvl= efa->next;
|
|
|
|
|
event=0;
|
2004-09-24 18:17:23 +00:00
|
|
|
if( efa->e1->f & SELECT) event++;
|
|
|
|
|
if( efa->e2->f & SELECT) event++;
|
|
|
|
|
if( efa->e3->f & SELECT) event++;
|
|
|
|
|
if(efa->e4 && (efa->e4->f & SELECT)) event++;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2004-09-24 18:17:23 +00:00
|
|
|
if(event) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
BLI_remlink(&em->faces, efa);
|
|
|
|
|
free_editface(efa);
|
|
|
|
|
}
|
|
|
|
|
efa= nextvl;
|
|
|
|
|
}
|
2004-09-24 18:17:23 +00:00
|
|
|
eed= em->edges.first;
|
|
|
|
|
while(eed) {
|
|
|
|
|
nexted= eed->next;
|
|
|
|
|
if(eed->f & SELECT) {
|
|
|
|
|
remedge(eed);
|
|
|
|
|
free_editedge(eed);
|
|
|
|
|
}
|
|
|
|
|
eed= nexted;
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
/* to remove loose vertices: */
|
|
|
|
|
eed= em->edges.first;
|
|
|
|
|
while(eed) {
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if( eed->v1->f & SELECT) eed->v1->f-=SELECT;
|
|
|
|
|
if( eed->v2->f & SELECT) eed->v2->f-=SELECT;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
eed= eed->next;
|
|
|
|
|
}
|
|
|
|
|
eve= em->verts.first;
|
|
|
|
|
while(eve) {
|
|
|
|
|
nextve= eve->next;
|
2004-09-24 18:17:23 +00:00
|
|
|
if(eve->f & SELECT) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
BLI_remlink(&em->verts,eve);
|
|
|
|
|
free_editvert(eve);
|
|
|
|
|
}
|
|
|
|
|
eve= nextve;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if(event==2) {
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
str="Erase Faces";
|
|
|
|
|
delfaceflag(SELECT);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
else if(event==3) {
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
str= "Erase All";
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
if(em->verts.first) free_vertlist(&em->verts);
|
|
|
|
|
if(em->edges.first) free_edgelist(&em->edges);
|
|
|
|
|
if(em->faces.first) free_facelist(&em->faces);
|
|
|
|
|
}
|
|
|
|
|
else if(event==5) {
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
str= "Erase Only Faces";
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
efa= em->faces.first;
|
|
|
|
|
while(efa) {
|
|
|
|
|
nextvl= efa->next;
|
2004-09-24 18:17:23 +00:00
|
|
|
if(efa->f & SELECT) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
BLI_remlink(&em->faces, efa);
|
|
|
|
|
free_editface(efa);
|
|
|
|
|
}
|
|
|
|
|
efa= nextvl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-24 16:06:20 +00:00
|
|
|
EM_fgon_flags(); // redo flags and indices for fgons
|
|
|
|
|
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
BIF_undo_push(str);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Got this from scanfill.c. You will need to juggle around the
|
|
|
|
|
* callbacks for the scanfill.c code a bit for this to work. */
|
|
|
|
|
void fill_mesh(void)
|
|
|
|
|
{
|
|
|
|
|
EditMesh *em = G.editMesh;
|
|
|
|
|
EditVert *eve,*v1;
|
|
|
|
|
EditEdge *eed,*e1,*nexted;
|
2004-10-13 19:39:26 +00:00
|
|
|
EditFace *efa,*nextvl, *efan;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
short ok;
|
|
|
|
|
|
|
|
|
|
if(G.obedit==0 || (G.obedit->type!=OB_MESH)) return;
|
|
|
|
|
|
|
|
|
|
waitcursor(1);
|
|
|
|
|
|
|
|
|
|
/* copy all selected vertices */
|
|
|
|
|
eve= em->verts.first;
|
|
|
|
|
while(eve) {
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if(eve->f & SELECT) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
v1= BLI_addfillvert(eve->co);
|
|
|
|
|
eve->vn= v1;
|
|
|
|
|
v1->vn= eve;
|
2005-07-10 09:32:30 +00:00
|
|
|
v1->xs= 0; // used for counting edges
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
eve= eve->next;
|
|
|
|
|
}
|
|
|
|
|
/* copy all selected edges */
|
|
|
|
|
eed= em->edges.first;
|
|
|
|
|
while(eed) {
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
if( (eed->v1->f & SELECT) && (eed->v2->f & SELECT) ) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
e1= BLI_addfilledge(eed->v1->vn, eed->v2->vn);
|
2005-07-10 09:32:30 +00:00
|
|
|
e1->v1->xs++;
|
|
|
|
|
e1->v2->xs++;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
eed= eed->next;
|
|
|
|
|
}
|
2004-10-13 19:39:26 +00:00
|
|
|
/* from all selected faces: remove vertices and edges to prevent doubles */
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
/* all edges add values, faces subtract,
|
2005-07-10 09:32:30 +00:00
|
|
|
then remove edges with vertices ->xs<2 */
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
efa= em->faces.first;
|
|
|
|
|
ok= 0;
|
|
|
|
|
while(efa) {
|
|
|
|
|
nextvl= efa->next;
|
|
|
|
|
if( faceselectedAND(efa, 1) ) {
|
2005-07-10 09:32:30 +00:00
|
|
|
efa->v1->vn->xs--;
|
|
|
|
|
efa->v2->vn->xs--;
|
|
|
|
|
efa->v3->vn->xs--;
|
|
|
|
|
if(efa->v4) efa->v4->vn->xs--;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
ok= 1;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
efa= nextvl;
|
|
|
|
|
}
|
|
|
|
|
if(ok) { /* there are faces selected */
|
|
|
|
|
eed= filledgebase.first;
|
|
|
|
|
while(eed) {
|
|
|
|
|
nexted= eed->next;
|
2005-07-10 09:32:30 +00:00
|
|
|
if(eed->v1->xs<2 || eed->v2->xs<2) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
BLI_remlink(&filledgebase,eed);
|
|
|
|
|
}
|
|
|
|
|
eed= nexted;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-08-14 06:08:41 +00:00
|
|
|
if(BLI_edgefill(0, (G.obedit && G.obedit->actcol)?(G.obedit->actcol-1):0)) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
efa= fillfacebase.first;
|
|
|
|
|
while(efa) {
|
2004-12-01 22:35:42 +00:00
|
|
|
efan= addfacelist(efa->v3->vn, efa->v2->vn, efa->v1->vn, 0, NULL, NULL); // normals default pointing up
|
2004-10-13 19:39:26 +00:00
|
|
|
EM_select_face(efan, 1);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
efa= efa->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLI_end_edgefill();
|
|
|
|
|
|
|
|
|
|
waitcursor(0);
|
2004-09-24 18:17:23 +00:00
|
|
|
EM_select_flush();
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
BIF_undo_push("Fill");
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/*--------------Edge Based Subdivide------------------*/
|
2005-08-07 21:47:08 +00:00
|
|
|
#define EDGENEW 2
|
|
|
|
|
#define FACENEW 2
|
2005-07-13 15:20:40 +00:00
|
|
|
#define EDGEINNER 4
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-08-05 15:08:43 +00:00
|
|
|
static void alter_co(float* co,EditEdge *edge,float rad,int beauty,float perc)
|
2005-07-17 15:45:35 +00:00
|
|
|
{
|
2005-08-07 21:47:08 +00:00
|
|
|
float vec1[3],fac;
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
if(rad > 0.0) { /* subdivide sphere */
|
|
|
|
|
Normalise(co);
|
|
|
|
|
co[0]*= rad;
|
|
|
|
|
co[1]*= rad;
|
|
|
|
|
co[2]*= rad;
|
|
|
|
|
}
|
|
|
|
|
else if(rad< 0.0) { /* fractal subdivide */
|
|
|
|
|
fac= rad* VecLenf(edge->v1->co, edge->v2->co);
|
|
|
|
|
vec1[0]= fac*(float)(0.5-BLI_drand());
|
|
|
|
|
vec1[1]= fac*(float)(0.5-BLI_drand());
|
|
|
|
|
vec1[2]= fac*(float)(0.5-BLI_drand());
|
|
|
|
|
VecAddf(co, co, vec1);
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
if(beauty & B_SMOOTH) {
|
|
|
|
|
float len, fac, nor[3], nor1[3], nor2[3];
|
|
|
|
|
|
|
|
|
|
VecSubf(nor, edge->v1->co, edge->v2->co);
|
|
|
|
|
len= 0.5f*Normalise(nor);
|
|
|
|
|
|
|
|
|
|
VECCOPY(nor1, edge->v1->no);
|
|
|
|
|
VECCOPY(nor2, edge->v2->no);
|
|
|
|
|
|
|
|
|
|
/* cosine angle */
|
|
|
|
|
fac= nor[0]*nor1[0] + nor[1]*nor1[1] + nor[2]*nor1[2] ;
|
|
|
|
|
|
|
|
|
|
vec1[0]= fac*nor1[0];
|
|
|
|
|
vec1[1]= fac*nor1[1];
|
|
|
|
|
vec1[2]= fac*nor1[2];
|
|
|
|
|
|
|
|
|
|
/* cosine angle */
|
|
|
|
|
fac= -nor[0]*nor2[0] - nor[1]*nor2[1] - nor[2]*nor2[2] ;
|
|
|
|
|
|
|
|
|
|
vec1[0]+= fac*nor2[0];
|
|
|
|
|
vec1[1]+= fac*nor2[1];
|
|
|
|
|
vec1[2]+= fac*nor2[2];
|
|
|
|
|
|
|
|
|
|
if(perc > .5){
|
|
|
|
|
perc = 1-perc;
|
|
|
|
|
}
|
|
|
|
|
perc /= 2;
|
|
|
|
|
|
|
|
|
|
vec1[0]*= perc*len;
|
|
|
|
|
vec1[1]*= perc*len;
|
|
|
|
|
vec1[2]*= perc*len;
|
|
|
|
|
|
|
|
|
|
co[0] += vec1[0];
|
|
|
|
|
co[1] += vec1[1];
|
|
|
|
|
co[2] += vec1[2];
|
|
|
|
|
}
|
2005-01-12 22:28:13 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-17 15:45:35 +00:00
|
|
|
static void flipvertarray(EditVert** arr, short size)
|
|
|
|
|
{
|
|
|
|
|
EditVert *hold;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for(i=0;i<size/2;i++){
|
|
|
|
|
hold = arr[i];
|
|
|
|
|
arr[i] = arr[size-i-1];
|
|
|
|
|
arr[size-i-1] = hold;
|
|
|
|
|
}
|
2005-01-12 22:28:13 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-23 14:39:59 +00:00
|
|
|
static int VecEqual(float *a, float *b){
|
2005-08-07 21:47:08 +00:00
|
|
|
if( a[0] == b[0] &&
|
|
|
|
|
(a[1] == b[1] &&
|
|
|
|
|
a[2] == b[2])){
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2005-07-23 14:39:59 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static void set_uv_vcol(EditFace *efa, float *co, float *uv, char *col)
|
|
|
|
|
{
|
2005-08-07 21:47:08 +00:00
|
|
|
EditVert *v1,*v2,*v3,*v4;
|
|
|
|
|
float xn, yn, zn;
|
|
|
|
|
float t00, t01, t10, t11;
|
|
|
|
|
float detsh, u, v, l;
|
|
|
|
|
int fac;
|
|
|
|
|
short i, j;
|
|
|
|
|
char *cp0, *cp1, *cp2;
|
|
|
|
|
char *hold;
|
|
|
|
|
|
|
|
|
|
//First Check for exact match between co and efa verts
|
|
|
|
|
if(VecEqual(co,efa->v1->co)){
|
|
|
|
|
uv[0] = efa->tf.uv[0][0];
|
|
|
|
|
uv[1] = efa->tf.uv[0][1];
|
|
|
|
|
|
|
|
|
|
hold = (char*)&efa->tf.col[0];
|
|
|
|
|
col[0]= hold[0];
|
|
|
|
|
col[1]= hold[1];
|
|
|
|
|
col[2]= hold[2];
|
|
|
|
|
col[3]= hold[3];
|
|
|
|
|
return;
|
|
|
|
|
} else if(VecEqual(co,efa->v2->co)){
|
|
|
|
|
uv[0] = efa->tf.uv[1][0];
|
|
|
|
|
uv[1] = efa->tf.uv[1][1];
|
|
|
|
|
|
|
|
|
|
hold = (char*)&efa->tf.col[1];
|
|
|
|
|
col[0]= hold[0];
|
|
|
|
|
col[1]= hold[1];
|
|
|
|
|
col[2]= hold[2];
|
|
|
|
|
col[3]= hold[3];
|
|
|
|
|
return;
|
|
|
|
|
} else if(VecEqual(co,efa->v3->co)){
|
|
|
|
|
uv[0] = efa->tf.uv[2][0];
|
|
|
|
|
uv[1] = efa->tf.uv[2][1];
|
|
|
|
|
|
|
|
|
|
hold = (char*)&efa->tf.col[2];
|
|
|
|
|
col[0]= hold[0];
|
|
|
|
|
col[1]= hold[1];
|
|
|
|
|
col[2]= hold[2];
|
|
|
|
|
col[3]= hold[3];
|
|
|
|
|
return;
|
|
|
|
|
} else if(efa->v4 && VecEqual(co,efa->v4->co)){
|
|
|
|
|
uv[0] = efa->tf.uv[3][0];
|
|
|
|
|
uv[1] = efa->tf.uv[3][1];
|
|
|
|
|
|
|
|
|
|
hold = (char*)&efa->tf.col[3];
|
|
|
|
|
col[0]= hold[0];
|
|
|
|
|
col[1]= hold[1];
|
|
|
|
|
col[2]= hold[2];
|
|
|
|
|
col[3]= hold[3];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* define best projection of face XY, XZ or YZ */
|
|
|
|
|
xn= fabs(efa->n[0]);
|
|
|
|
|
yn= fabs(efa->n[1]);
|
|
|
|
|
zn= fabs(efa->n[2]);
|
|
|
|
|
if(zn>=xn && zn>=yn) {i= 0; j= 1;}
|
|
|
|
|
else if(yn>=xn && yn>=zn) {i= 0; j= 2;}
|
|
|
|
|
else {i= 1; j= 2;}
|
|
|
|
|
|
|
|
|
|
/* calculate u and v */
|
|
|
|
|
v1= efa->v1;
|
|
|
|
|
v2= efa->v2;
|
|
|
|
|
v3= efa->v3;
|
|
|
|
|
|
|
|
|
|
t00= v3->co[i]-v1->co[i]; t01= v3->co[j]-v1->co[j];
|
|
|
|
|
t10= v3->co[i]-v2->co[i]; t11= v3->co[j]-v2->co[j];
|
|
|
|
|
|
|
|
|
|
detsh= 1.0/(t00*t11-t10*t01); /* potential danger */
|
|
|
|
|
t00*= detsh; t01*=detsh;
|
|
|
|
|
t10*=detsh; t11*=detsh;
|
|
|
|
|
|
|
|
|
|
u= (co[i]-v3->co[i])*t11-(co[j]-v3->co[j])*t10;
|
|
|
|
|
v= (co[j]-v3->co[j])*t00-(co[i]-v3->co[i])*t01;
|
|
|
|
|
|
|
|
|
|
/* btw; u and v range from -1 to 0 */
|
|
|
|
|
|
|
|
|
|
/* interpolate */
|
|
|
|
|
l= 1.0+u+v;
|
|
|
|
|
/* outside triangle? */
|
|
|
|
|
// printf("l: %f\n",l);
|
|
|
|
|
if(efa->v4 && l >= 0.5) {
|
|
|
|
|
// printf("outside\n");
|
|
|
|
|
/* do it all over, but now with vertex 2 replaced with 4 */
|
|
|
|
|
|
|
|
|
|
/* calculate u and v */
|
|
|
|
|
v1= efa->v1;
|
|
|
|
|
v4= efa->v4;
|
|
|
|
|
v3= efa->v3;
|
|
|
|
|
|
|
|
|
|
t00= v3->co[i]-v1->co[i]; t01= v3->co[j]-v1->co[j];
|
|
|
|
|
t10= v3->co[i]-v4->co[i]; t11= v3->co[j]-v4->co[j];
|
|
|
|
|
|
|
|
|
|
detsh= 1.0/(t00*t11-t10*t01); /* potential danger */
|
|
|
|
|
t00*= detsh; t01*=detsh;
|
|
|
|
|
t10*=detsh; t11*=detsh;
|
|
|
|
|
|
|
|
|
|
u= (co[i]-v3->co[i])*t11-(co[j]-v3->co[j])*t10;
|
|
|
|
|
v= (co[j]-v3->co[j])*t00-(co[i]-v3->co[i])*t01;
|
|
|
|
|
|
|
|
|
|
/* btw; u and v range from -1 to 0 */
|
|
|
|
|
|
|
|
|
|
/* interpolate */
|
|
|
|
|
l= 1.0+u+v;
|
|
|
|
|
uv[0] = (l*efa->tf.uv[2][0] - u*efa->tf.uv[0][0] - v*efa->tf.uv[3][0]);
|
|
|
|
|
uv[1] = (l*efa->tf.uv[2][1] - u*efa->tf.uv[0][1] - v*efa->tf.uv[3][1]);
|
|
|
|
|
|
|
|
|
|
cp0= (char*)&(efa->tf.col[0]);
|
|
|
|
|
cp1= (char*)&(efa->tf.col[3]);
|
|
|
|
|
cp2= (char*)&(efa->tf.col[2]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(i=0; i<4; i++) {
|
|
|
|
|
fac= (int)(l*cp2[i] - u*cp0[i] - v*cp1[i]);
|
|
|
|
|
col[i]= CLAMPIS(fac, 0, 255);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// printf("inside\n");
|
|
|
|
|
//new = l*vertex3_val - u*vertex1_val - v*vertex2_val;
|
|
|
|
|
uv[0] = (l*efa->tf.uv[2][0] - u*efa->tf.uv[0][0] - v*efa->tf.uv[1][0]);
|
|
|
|
|
uv[1] = (l*efa->tf.uv[2][1] - u*efa->tf.uv[0][1] - v*efa->tf.uv[1][1]);
|
|
|
|
|
|
|
|
|
|
cp0= (char*)&(efa->tf.col[0]);
|
|
|
|
|
cp1= (char*)&(efa->tf.col[1]);
|
|
|
|
|
cp2= (char*)&(efa->tf.col[2]);
|
|
|
|
|
|
|
|
|
|
for(i=0; i<4; i++) {
|
|
|
|
|
fac= (int)(l*cp2[i] - u*cp0[i] - v*cp1[i]);
|
|
|
|
|
col[i]= CLAMPIS(fac, 0, 255);
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
}
|
2005-01-12 22:28:13 +00:00
|
|
|
|
2005-07-17 15:45:35 +00:00
|
|
|
static void facecopy(EditFace *source,EditFace *target)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
set_uv_vcol(source,target->v1->co,target->tf.uv[0],(char*)&target->tf.col[0]);
|
|
|
|
|
set_uv_vcol(source,target->v2->co,target->tf.uv[1],(char*)&target->tf.col[1]);
|
|
|
|
|
set_uv_vcol(source,target->v3->co,target->tf.uv[2],(char*)&target->tf.col[2]);
|
|
|
|
|
if(target->v4){
|
|
|
|
|
set_uv_vcol(source,target->v4->co,target->tf.uv[3],(char*)&target->tf.col[3]);
|
|
|
|
|
}
|
2005-01-12 22:28:13 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
target->mat_nr = source->mat_nr;
|
|
|
|
|
target->tf.flag = source->tf.flag;
|
2005-07-13 15:20:40 +00:00
|
|
|
target->tf.transp = source->tf.transp;
|
2005-08-07 21:47:08 +00:00
|
|
|
target->tf.mode = source->tf.mode;
|
|
|
|
|
target->tf.tile = source->tf.tile;
|
2005-07-13 15:20:40 +00:00
|
|
|
target->tf.unwrap = source->tf.unwrap;
|
|
|
|
|
target->tf.tpage = source->tf.tpage;
|
2005-08-07 21:47:08 +00:00
|
|
|
target->flag = source->flag;
|
|
|
|
|
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-08-08 15:59:05 +00:00
|
|
|
static void fill_quad_single(EditFace *efa, struct GHash *gh, int numcuts, int seltype)
|
2005-07-17 15:45:35 +00:00
|
|
|
{
|
|
|
|
|
EditEdge *cedge=NULL;
|
|
|
|
|
EditVert *v[4], **verts;
|
|
|
|
|
EditFace *hold;
|
|
|
|
|
short start=0, end, left, right, vertsize,i;
|
|
|
|
|
|
|
|
|
|
v[0] = efa->v1;
|
|
|
|
|
v[1] = efa->v2;
|
|
|
|
|
v[2] = efa->v3;
|
2005-08-07 21:47:08 +00:00
|
|
|
v[3] = efa->v4;
|
2005-07-17 15:45:35 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
if(efa->e1->f & SELECT) { cedge = efa->e1; start = 0;}
|
|
|
|
|
else if(efa->e2->f & SELECT) { cedge = efa->e2; start = 1;}
|
|
|
|
|
else if(efa->e3->f & SELECT) { cedge = efa->e3; start = 2;}
|
|
|
|
|
else if(efa->e4->f & SELECT) { cedge = efa->e4; start = 3;}
|
2005-07-17 15:45:35 +00:00
|
|
|
|
|
|
|
|
// Point verts to the array of new verts for cedge
|
|
|
|
|
verts = BLI_ghash_lookup(gh, cedge);
|
|
|
|
|
//This is the index size of the verts array
|
|
|
|
|
vertsize = numcuts+2;
|
|
|
|
|
|
|
|
|
|
// Is the original v1 the same as the first vert on the selected edge?
|
|
|
|
|
// if not, the edge is running the opposite direction in this face so flip
|
|
|
|
|
// the array to the correct direction
|
|
|
|
|
|
|
|
|
|
if(verts[0] != v[start]){flipvertarray(verts,numcuts+2);}
|
2005-08-07 21:47:08 +00:00
|
|
|
end = (start+1)%4;
|
2005-07-17 15:45:35 +00:00
|
|
|
left = (start+2)%4;
|
|
|
|
|
right = (start+3)%4;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
We should have something like this now
|
|
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
end start
|
2005-07-17 15:45:35 +00:00
|
|
|
3 2 1 0
|
|
|
|
|
|---*---*---|
|
2005-08-07 21:47:08 +00:00
|
|
|
| |
|
|
|
|
|
| |
|
|
|
|
|
| |
|
|
|
|
|
-------------
|
|
|
|
|
left right
|
2005-07-17 15:45:35 +00:00
|
|
|
|
|
|
|
|
where start,end,left, right are indexes of EditFace->v1, etc (stored in v)
|
|
|
|
|
and 0,1,2... are the indexes of the new verts stored in verts
|
|
|
|
|
|
|
|
|
|
We will fill this case like this or this depending on even or odd cuts
|
|
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
|---*---*---| |---*---|
|
|
|
|
|
| / \ | | / \ |
|
|
|
|
|
| / \ | | / \ |
|
|
|
|
|
|/ \| |/ \|
|
|
|
|
|
------------- ---------
|
2005-07-17 15:45:35 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Make center face
|
|
|
|
|
if(vertsize % 2 == 0){
|
|
|
|
|
hold = addfacelist(verts[(vertsize-1)/2],verts[((vertsize-1)/2)+1],v[left],v[right], NULL,NULL);
|
2005-08-02 18:20:36 +00:00
|
|
|
hold->e2->f2 |= EDGEINNER;
|
|
|
|
|
hold->e4->f2 |= EDGEINNER;
|
2005-07-17 15:45:35 +00:00
|
|
|
}else{
|
2005-08-02 18:20:36 +00:00
|
|
|
hold = addfacelist(verts[(vertsize-1)/2],v[left],v[right],NULL, NULL,NULL);
|
|
|
|
|
hold->e1->f2 |= EDGEINNER;
|
2005-08-07 21:47:08 +00:00
|
|
|
hold->e3->f2 |= EDGEINNER;
|
2005-07-17 15:45:35 +00:00
|
|
|
}
|
|
|
|
|
facecopy(efa,hold);
|
|
|
|
|
|
|
|
|
|
// Make side faces
|
|
|
|
|
for(i=0;i<(vertsize-1)/2;i++){
|
|
|
|
|
hold = addfacelist(verts[i],verts[i+1],v[right],NULL,NULL,NULL);
|
|
|
|
|
facecopy(efa,hold);
|
2005-08-02 18:20:36 +00:00
|
|
|
if(i+1 != (vertsize-1)/2){
|
2005-08-08 15:59:05 +00:00
|
|
|
if(seltype == SUBDIV_SELECT_INNER){
|
|
|
|
|
hold->e2->f2 |= EDGEINNER;
|
|
|
|
|
}
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
2005-07-17 15:45:35 +00:00
|
|
|
hold = addfacelist(verts[vertsize-2-i],verts[vertsize-1-i],v[left],NULL,NULL,NULL);
|
|
|
|
|
facecopy(efa,hold);
|
2005-08-02 18:20:36 +00:00
|
|
|
if(i+1 != (vertsize-1)/2){
|
2005-08-08 15:59:05 +00:00
|
|
|
if(seltype == SUBDIV_SELECT_INNER){
|
2005-08-07 21:47:08 +00:00
|
|
|
hold->e3->f2 |= EDGEINNER;
|
2005-08-08 15:59:05 +00:00
|
|
|
}
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-08-08 15:59:05 +00:00
|
|
|
static void fill_tri_single(EditFace *efa, struct GHash *gh, int numcuts, int seltype)
|
2005-07-17 15:45:35 +00:00
|
|
|
{
|
|
|
|
|
EditEdge *cedge=NULL;
|
|
|
|
|
EditVert *v[3], **verts;
|
|
|
|
|
EditFace *hold;
|
|
|
|
|
short start=0, end, op, vertsize,i;
|
|
|
|
|
|
|
|
|
|
v[0] = efa->v1;
|
|
|
|
|
v[1] = efa->v2;
|
2005-08-07 21:47:08 +00:00
|
|
|
v[2] = efa->v3;
|
2005-07-17 15:45:35 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
if(efa->e1->f & SELECT) { cedge = efa->e1; start = 0;}
|
|
|
|
|
else if(efa->e2->f & SELECT) { cedge = efa->e2; start = 1;}
|
|
|
|
|
else if(efa->e3->f & SELECT) { cedge = efa->e3; start = 2;}
|
2005-07-17 15:45:35 +00:00
|
|
|
|
|
|
|
|
// Point verts to the array of new verts for cedge
|
|
|
|
|
verts = BLI_ghash_lookup(gh, cedge);
|
|
|
|
|
//This is the index size of the verts array
|
|
|
|
|
vertsize = numcuts+2;
|
|
|
|
|
|
|
|
|
|
// Is the original v1 the same as the first vert on the selected edge?
|
|
|
|
|
// if not, the edge is running the opposite direction in this face so flip
|
|
|
|
|
// the array to the correct direction
|
|
|
|
|
|
|
|
|
|
if(verts[0] != v[start]){flipvertarray(verts,numcuts+2);}
|
2005-08-07 21:47:08 +00:00
|
|
|
end = (start+1)%3;
|
|
|
|
|
op = (start+2)%3;
|
2005-07-17 15:45:35 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
We should have something like this now
|
|
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
end start
|
2005-07-17 15:45:35 +00:00
|
|
|
3 2 1 0
|
|
|
|
|
|---*---*---|
|
2005-08-07 21:47:08 +00:00
|
|
|
\ |
|
|
|
|
|
\ |
|
|
|
|
|
\ |
|
|
|
|
|
\ |
|
2005-07-17 15:45:35 +00:00
|
|
|
\ |
|
|
|
|
|
\ |
|
|
|
|
|
|op
|
|
|
|
|
|
|
|
|
|
where start,end,op are indexes of EditFace->v1, etc (stored in v)
|
|
|
|
|
and 0,1,2... are the indexes of the new verts stored in verts
|
|
|
|
|
|
|
|
|
|
We will fill this case like this or this depending on even or odd cuts
|
|
|
|
|
|
|
|
|
|
3 2 1 0
|
|
|
|
|
|---*---*---|
|
2005-08-07 21:47:08 +00:00
|
|
|
\ \ \ |
|
|
|
|
|
\ \ \ |
|
2005-07-17 15:45:35 +00:00
|
|
|
\ \ \ |
|
|
|
|
|
\ \ \|
|
|
|
|
|
\ \\|
|
|
|
|
|
\ |
|
|
|
|
|
|op
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Make side faces
|
|
|
|
|
for(i=0;i<(vertsize-1);i++){
|
|
|
|
|
hold = addfacelist(verts[i],verts[i+1],v[op],NULL,NULL,NULL);
|
2005-08-02 18:20:36 +00:00
|
|
|
if(i+1 != vertsize-1){
|
2005-08-08 15:59:05 +00:00
|
|
|
if(seltype == SUBDIV_SELECT_INNER){
|
2005-08-07 21:47:08 +00:00
|
|
|
hold->e2->f2 |= EDGEINNER;
|
2005-08-08 15:59:05 +00:00
|
|
|
}
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
2005-07-17 15:45:35 +00:00
|
|
|
facecopy(efa,hold);
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-17 15:45:35 +00:00
|
|
|
static void fill_quad_double_op(EditFace *efa, struct GHash *gh, int numcuts)
|
|
|
|
|
{
|
|
|
|
|
EditEdge *cedge[2]={NULL, NULL};
|
|
|
|
|
EditVert *v[4], **verts[2];
|
|
|
|
|
EditFace *hold;
|
|
|
|
|
short start=0, end, left, right, vertsize,i;
|
|
|
|
|
|
|
|
|
|
v[0] = efa->v1;
|
|
|
|
|
v[1] = efa->v2;
|
|
|
|
|
v[2] = efa->v3;
|
2005-08-07 21:47:08 +00:00
|
|
|
v[3] = efa->v4;
|
2005-07-17 15:45:35 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
if(efa->e1->f & SELECT) { cedge[0] = efa->e1; cedge[1] = efa->e3; start = 0;}
|
|
|
|
|
else if(efa->e2->f & SELECT) { cedge[0] = efa->e2; cedge[1] = efa->e4; start = 1;}
|
2005-07-17 15:45:35 +00:00
|
|
|
|
|
|
|
|
// Point verts[0] and [1] to the array of new verts for cedge[0] and cedge[1]
|
|
|
|
|
verts[0] = BLI_ghash_lookup(gh, cedge[0]);
|
|
|
|
|
verts[1] = BLI_ghash_lookup(gh, cedge[1]);
|
|
|
|
|
//This is the index size of the verts array
|
|
|
|
|
vertsize = numcuts+2;
|
|
|
|
|
|
|
|
|
|
// Is the original v1 the same as the first vert on the selected edge?
|
|
|
|
|
// if not, the edge is running the opposite direction in this face so flip
|
|
|
|
|
// the array to the correct direction
|
|
|
|
|
|
|
|
|
|
if(verts[0][0] != v[start]){flipvertarray(verts[0],numcuts+2);}
|
2005-08-07 21:47:08 +00:00
|
|
|
end = (start+1)%4;
|
2005-07-17 15:45:35 +00:00
|
|
|
left = (start+2)%4;
|
|
|
|
|
right = (start+3)%4;
|
2005-08-07 21:47:08 +00:00
|
|
|
if(verts[1][0] != v[left]){flipvertarray(verts[1],numcuts+2);}
|
2005-07-17 15:45:35 +00:00
|
|
|
/*
|
|
|
|
|
We should have something like this now
|
|
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
end start
|
2005-07-17 15:45:35 +00:00
|
|
|
3 2 1 0
|
|
|
|
|
|---*---*---|
|
2005-08-07 21:47:08 +00:00
|
|
|
| |
|
|
|
|
|
| |
|
|
|
|
|
| |
|
|
|
|
|
|---*---*---|
|
2005-07-17 15:45:35 +00:00
|
|
|
0 1 2 3
|
2005-08-07 21:47:08 +00:00
|
|
|
left right
|
2005-07-17 15:45:35 +00:00
|
|
|
|
|
|
|
|
We will fill this case like this or this depending on even or odd cuts
|
|
|
|
|
|
|
|
|
|
|---*---*---|
|
|
|
|
|
| | | |
|
2005-08-07 21:47:08 +00:00
|
|
|
| | | |
|
2005-07-17 15:45:35 +00:00
|
|
|
| | | |
|
|
|
|
|
|---*---*---|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Make side faces
|
|
|
|
|
for(i=0;i<vertsize-1;i++){
|
|
|
|
|
hold = addfacelist(verts[0][i],verts[0][i+1],verts[1][vertsize-2-i],verts[1][vertsize-1-i],NULL,NULL);
|
|
|
|
|
if(i < vertsize-2){
|
|
|
|
|
hold->e2->f2 |= EDGEINNER;
|
|
|
|
|
}
|
|
|
|
|
facecopy(efa,hold);
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
2005-05-13 10:20:10 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
|
2005-07-17 15:45:35 +00:00
|
|
|
static void fill_quad_double_adj(EditFace *efa, struct GHash *gh, int numcuts)
|
|
|
|
|
{
|
|
|
|
|
EditEdge *cedge[2]={NULL, NULL};
|
|
|
|
|
EditVert *v[4], **verts[2];
|
|
|
|
|
EditFace *hold;
|
|
|
|
|
short start=0, start2=0, vertsize,i;
|
|
|
|
|
|
|
|
|
|
v[0] = efa->v1;
|
|
|
|
|
v[1] = efa->v2;
|
|
|
|
|
v[2] = efa->v3;
|
2005-08-07 21:47:08 +00:00
|
|
|
v[3] = efa->v4;
|
2005-07-17 15:45:35 +00:00
|
|
|
|
|
|
|
|
if(efa->e1->f & SELECT && efa->e2->f & SELECT) {cedge[0] = efa->e1; cedge[1] = efa->e2; start = 0; start2 = 1;}
|
|
|
|
|
if(efa->e2->f & SELECT && efa->e3->f & SELECT) {cedge[0] = efa->e2; cedge[1] = efa->e3; start = 1; start2 = 2;}
|
|
|
|
|
if(efa->e3->f & SELECT && efa->e4->f & SELECT) {cedge[0] = efa->e3; cedge[1] = efa->e4; start = 2; start2 = 3;}
|
|
|
|
|
if(efa->e4->f & SELECT && efa->e1->f & SELECT) {cedge[0] = efa->e4; cedge[1] = efa->e1; start = 3; start2 = 0;}
|
|
|
|
|
|
|
|
|
|
// Point verts[0] and [1] to the array of new verts for cedge[0] and cedge[1]
|
|
|
|
|
verts[0] = BLI_ghash_lookup(gh, cedge[0]);
|
|
|
|
|
verts[1] = BLI_ghash_lookup(gh, cedge[1]);
|
|
|
|
|
//This is the index size of the verts array
|
|
|
|
|
vertsize = numcuts+2;
|
|
|
|
|
|
|
|
|
|
// Is the original v1 the same as the first vert on the selected edge?
|
|
|
|
|
// if not, the edge is running the opposite direction in this face so flip
|
|
|
|
|
// the array to the correct direction
|
|
|
|
|
|
|
|
|
|
if(verts[0][0] != v[start]){flipvertarray(verts[0],numcuts+2);}
|
2005-08-07 21:47:08 +00:00
|
|
|
if(verts[1][0] != v[start2]){flipvertarray(verts[1],numcuts+2);}
|
2005-07-17 15:45:35 +00:00
|
|
|
/*
|
|
|
|
|
We should have something like this now
|
|
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
end start
|
2005-07-17 15:45:35 +00:00
|
|
|
3 2 1 0
|
|
|
|
|
start2 0|---*---*---|
|
2005-08-07 21:47:08 +00:00
|
|
|
| |
|
|
|
|
|
1* |
|
|
|
|
|
| |
|
|
|
|
|
2* |
|
|
|
|
|
| |
|
2005-07-17 15:45:35 +00:00
|
|
|
end2 3|-----------|
|
|
|
|
|
|
|
|
|
|
We will fill this case like this or this depending on even or odd cuts
|
|
|
|
|
|---*---*---|
|
|
|
|
|
| / / / |
|
|
|
|
|
* / / |
|
2005-08-07 21:47:08 +00:00
|
|
|
| / / |
|
|
|
|
|
* / |
|
|
|
|
|
| / |
|
2005-07-17 15:45:35 +00:00
|
|
|
|-----------|
|
|
|
|
|
*/
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-17 15:45:35 +00:00
|
|
|
// Make outside tris
|
|
|
|
|
hold = addfacelist(verts[0][vertsize-2],verts[0][vertsize-1],verts[1][1],NULL,NULL,NULL);
|
2005-08-02 18:20:36 +00:00
|
|
|
hold->e3->f2 |= EDGEINNER;
|
2005-08-07 21:47:08 +00:00
|
|
|
facecopy(efa,hold);
|
2005-08-02 18:20:36 +00:00
|
|
|
hold = addfacelist(verts[0][0],verts[1][vertsize-1],v[(start2+2)%4],NULL,NULL,NULL);
|
|
|
|
|
hold->e1->f2 |= EDGEINNER;
|
2005-08-07 21:47:08 +00:00
|
|
|
facecopy(efa,hold);
|
2005-07-17 15:45:35 +00:00
|
|
|
// Make side faces
|
|
|
|
|
|
|
|
|
|
for(i=0;i<numcuts;i++){
|
|
|
|
|
hold = addfacelist(verts[0][i],verts[0][i+1],verts[1][vertsize-1-(i+1)],verts[1][vertsize-1-i],NULL,NULL);
|
2005-08-02 18:20:36 +00:00
|
|
|
hold->e2->f2 |= EDGEINNER;
|
2005-07-17 15:45:35 +00:00
|
|
|
facecopy(efa,hold);
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-17 15:45:35 +00:00
|
|
|
static void fill_tri_double(EditFace *efa, struct GHash *gh, int numcuts)
|
|
|
|
|
{
|
|
|
|
|
EditEdge *cedge[2]={NULL, NULL};
|
|
|
|
|
EditVert *v[3], **verts[2];
|
|
|
|
|
EditFace *hold;
|
|
|
|
|
short start=0, start2=0, vertsize,i;
|
|
|
|
|
|
|
|
|
|
v[0] = efa->v1;
|
|
|
|
|
v[1] = efa->v2;
|
|
|
|
|
v[2] = efa->v3;
|
|
|
|
|
|
|
|
|
|
if(efa->e1->f & SELECT && efa->e2->f & SELECT) {cedge[0] = efa->e1; cedge[1] = efa->e2; start = 0; start2 = 1;}
|
|
|
|
|
if(efa->e2->f & SELECT && efa->e3->f & SELECT) {cedge[0] = efa->e2; cedge[1] = efa->e3; start = 1; start2 = 2;}
|
|
|
|
|
if(efa->e3->f & SELECT && efa->e1->f & SELECT) {cedge[0] = efa->e3; cedge[1] = efa->e1; start = 2; start2 = 0;}
|
|
|
|
|
|
|
|
|
|
// Point verts[0] and [1] to the array of new verts for cedge[0] and cedge[1]
|
|
|
|
|
verts[0] = BLI_ghash_lookup(gh, cedge[0]);
|
|
|
|
|
verts[1] = BLI_ghash_lookup(gh, cedge[1]);
|
|
|
|
|
//This is the index size of the verts array
|
|
|
|
|
vertsize = numcuts+2;
|
|
|
|
|
|
|
|
|
|
// Is the original v1 the same as the first vert on the selected edge?
|
|
|
|
|
// if not, the edge is running the opposite direction in this face so flip
|
|
|
|
|
// the array to the correct direction
|
|
|
|
|
|
|
|
|
|
if(verts[0][0] != v[start]){flipvertarray(verts[0],numcuts+2);}
|
2005-08-07 21:47:08 +00:00
|
|
|
if(verts[1][0] != v[start2]){flipvertarray(verts[1],numcuts+2);}
|
2005-07-17 15:45:35 +00:00
|
|
|
/*
|
|
|
|
|
We should have something like this now
|
|
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
end start
|
2005-07-17 15:45:35 +00:00
|
|
|
3 2 1 0
|
|
|
|
|
start2 0|---*---*---|
|
2005-08-07 21:47:08 +00:00
|
|
|
| /
|
|
|
|
|
1* /
|
|
|
|
|
| /
|
|
|
|
|
2* /
|
|
|
|
|
| /
|
2005-07-17 15:45:35 +00:00
|
|
|
end2 3|
|
|
|
|
|
|
|
|
|
|
We will fill this case like this or this depending on even or odd cuts
|
|
|
|
|
|---*---*---|
|
|
|
|
|
| / / /
|
|
|
|
|
* / /
|
2005-08-07 21:47:08 +00:00
|
|
|
| / /
|
|
|
|
|
* /
|
|
|
|
|
| /
|
2005-07-17 15:45:35 +00:00
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Make outside tri
|
|
|
|
|
hold = addfacelist(verts[0][vertsize-2],verts[0][vertsize-1],verts[1][1],NULL,NULL,NULL);
|
2005-08-02 18:20:36 +00:00
|
|
|
hold->e3->f2 |= EDGEINNER;
|
2005-08-07 21:47:08 +00:00
|
|
|
facecopy(efa,hold);
|
2005-07-17 15:45:35 +00:00
|
|
|
// Make side faces
|
|
|
|
|
|
|
|
|
|
for(i=0;i<numcuts;i++){
|
|
|
|
|
hold = addfacelist(verts[0][i],verts[0][i+1],verts[1][vertsize-1-(i+1)],verts[1][vertsize-1-i],NULL,NULL);
|
2005-08-02 18:20:36 +00:00
|
|
|
hold->e2->f2 |= EDGEINNER;
|
2005-07-17 15:45:35 +00:00
|
|
|
facecopy(efa,hold);
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
2005-05-13 10:20:10 +00:00
|
|
|
}
|
2005-01-12 22:28:13 +00:00
|
|
|
|
2005-07-17 15:45:35 +00:00
|
|
|
static void fill_quad_triple(EditFace *efa, struct GHash *gh, int numcuts)
|
|
|
|
|
{
|
|
|
|
|
EditEdge *cedge[3];
|
|
|
|
|
EditVert *v[4], **verts[3];
|
|
|
|
|
EditFace *hold;
|
|
|
|
|
short start=0, start2=0, start3=0, vertsize, i, repeats;
|
|
|
|
|
|
|
|
|
|
v[0] = efa->v1;
|
|
|
|
|
v[1] = efa->v2;
|
|
|
|
|
v[2] = efa->v3;
|
2005-08-07 21:47:08 +00:00
|
|
|
v[3] = efa->v4;
|
2005-07-17 15:45:35 +00:00
|
|
|
|
|
|
|
|
if(!(efa->e1->f & SELECT)) {
|
|
|
|
|
cedge[0] = efa->e2;
|
|
|
|
|
cedge[1] = efa->e3;
|
|
|
|
|
cedge[2] = efa->e4;
|
|
|
|
|
start = 1;start2 = 2;start3 = 3;
|
|
|
|
|
}
|
|
|
|
|
if(!(efa->e2->f & SELECT)) {
|
|
|
|
|
cedge[0] = efa->e3;
|
|
|
|
|
cedge[1] = efa->e4;
|
|
|
|
|
cedge[2] = efa->e1;
|
|
|
|
|
start = 2;start2 = 3;start3 = 0;
|
|
|
|
|
}
|
|
|
|
|
if(!(efa->e3->f & SELECT)) {
|
|
|
|
|
cedge[0] = efa->e4;
|
|
|
|
|
cedge[1] = efa->e1;
|
|
|
|
|
cedge[2] = efa->e2;
|
|
|
|
|
start = 3;start2 = 0;start3 = 1;
|
|
|
|
|
}
|
|
|
|
|
if(!(efa->e4->f & SELECT)) {
|
|
|
|
|
cedge[0] = efa->e1;
|
|
|
|
|
cedge[1] = efa->e2;
|
|
|
|
|
cedge[2] = efa->e3;
|
|
|
|
|
start = 0;start2 = 1;start3 = 2;
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
2005-07-17 15:45:35 +00:00
|
|
|
// Point verts[0] and [1] to the array of new verts for cedge[0] and cedge[1]
|
|
|
|
|
verts[0] = BLI_ghash_lookup(gh, cedge[0]);
|
|
|
|
|
verts[1] = BLI_ghash_lookup(gh, cedge[1]);
|
|
|
|
|
verts[2] = BLI_ghash_lookup(gh, cedge[2]);
|
|
|
|
|
//This is the index size of the verts array
|
|
|
|
|
vertsize = numcuts+2;
|
|
|
|
|
|
|
|
|
|
// Is the original v1 the same as the first vert on the selected edge?
|
|
|
|
|
// if not, the edge is running the opposite direction in this face so flip
|
|
|
|
|
// the array to the correct direction
|
|
|
|
|
|
|
|
|
|
if(verts[0][0] != v[start]) {flipvertarray(verts[0],numcuts+2);}
|
|
|
|
|
if(verts[1][0] != v[start2]){flipvertarray(verts[1],numcuts+2);}
|
|
|
|
|
if(verts[2][0] != v[start3]){flipvertarray(verts[2],numcuts+2);}
|
|
|
|
|
/*
|
|
|
|
|
We should have something like this now
|
|
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
start2
|
2005-07-17 15:45:35 +00:00
|
|
|
3 2 1 0
|
|
|
|
|
start3 0|---*---*---|3
|
2005-08-07 21:47:08 +00:00
|
|
|
| |
|
|
|
|
|
1* *2
|
|
|
|
|
| |
|
|
|
|
|
2* *1
|
|
|
|
|
| |
|
2005-07-17 15:45:35 +00:00
|
|
|
3|-----------|0 start
|
|
|
|
|
|
|
|
|
|
We will fill this case like this or this depending on even or odd cuts
|
|
|
|
|
there are a couple of differences. For odd cuts, there is a tri in the
|
|
|
|
|
middle as well as 1 quad at the bottom (not including the extra quads
|
2005-08-07 21:47:08 +00:00
|
|
|
for odd cuts > 1
|
2005-07-17 15:45:35 +00:00
|
|
|
|
|
|
|
|
For even cuts, there is a quad in the middle and 2 quads on the bottom
|
|
|
|
|
|
|
|
|
|
they are numbered here for clarity
|
|
|
|
|
|
|
|
|
|
1 outer tris and bottom quads
|
|
|
|
|
2 inner tri or quad
|
|
|
|
|
3 repeating quads
|
|
|
|
|
|
|
|
|
|
|---*---*---*---|
|
|
|
|
|
|1/ / \ \ 1|
|
2005-08-07 21:47:08 +00:00
|
|
|
|/ 3 / \ 3 \|
|
|
|
|
|
* / 2 \ *
|
|
|
|
|
| / \ |
|
|
|
|
|
|/ \ |
|
2005-07-17 15:45:35 +00:00
|
|
|
*---------------*
|
2005-08-07 21:47:08 +00:00
|
|
|
| 3 |
|
|
|
|
|
| |
|
2005-07-17 15:45:35 +00:00
|
|
|
*---------------*
|
2005-08-07 21:47:08 +00:00
|
|
|
| |
|
|
|
|
|
| 1 |
|
|
|
|
|
| |
|
2005-07-17 15:45:35 +00:00
|
|
|
|---------------|
|
|
|
|
|
|
|
|
|
|
|---*---*---*---*---|
|
2005-08-07 21:47:08 +00:00
|
|
|
| 1/ / \ \ 1|
|
|
|
|
|
| / / \ \ |
|
|
|
|
|
|/ 3 / \ 3 \|
|
|
|
|
|
* / \ *
|
|
|
|
|
| / \ |
|
|
|
|
|
| / 2 \ |
|
|
|
|
|
|/ \|
|
2005-07-17 15:45:35 +00:00
|
|
|
*-------------------*
|
2005-08-07 21:47:08 +00:00
|
|
|
| |
|
|
|
|
|
| 3 |
|
|
|
|
|
| |
|
2005-07-17 15:45:35 +00:00
|
|
|
*-------------------*
|
2005-08-07 21:47:08 +00:00
|
|
|
| |
|
|
|
|
|
| 1 |
|
|
|
|
|
| |
|
2005-07-17 15:45:35 +00:00
|
|
|
*-------------------*
|
2005-08-07 21:47:08 +00:00
|
|
|
| |
|
|
|
|
|
| 1 |
|
|
|
|
|
| |
|
2005-07-17 15:45:35 +00:00
|
|
|
|-------------------|
|
|
|
|
|
|
|
|
|
|
*/
|
2005-07-13 15:20:40 +00:00
|
|
|
|
2005-07-17 15:45:35 +00:00
|
|
|
// Make outside tris
|
|
|
|
|
hold = addfacelist(verts[0][vertsize-2],verts[0][vertsize-1],verts[1][1],NULL,NULL,NULL);
|
2005-08-02 18:20:36 +00:00
|
|
|
hold->e3->f2 |= EDGEINNER;
|
2005-08-07 21:47:08 +00:00
|
|
|
facecopy(efa,hold);
|
2005-07-17 15:45:35 +00:00
|
|
|
hold = addfacelist(verts[1][vertsize-2],verts[1][vertsize-1],verts[2][1],NULL,NULL,NULL);
|
2005-08-02 18:20:36 +00:00
|
|
|
hold->e3->f2 |= EDGEINNER;
|
2005-08-07 21:47:08 +00:00
|
|
|
facecopy(efa,hold);
|
2005-07-17 15:45:35 +00:00
|
|
|
// Make bottom quad
|
|
|
|
|
hold = addfacelist(verts[0][0],verts[0][1],verts[2][vertsize-2],verts[2][vertsize-1],NULL,NULL);
|
2005-08-02 18:20:36 +00:00
|
|
|
hold->e2->f2 |= EDGEINNER;
|
2005-08-07 21:47:08 +00:00
|
|
|
facecopy(efa,hold);
|
2005-07-17 15:45:35 +00:00
|
|
|
//If it is even cuts, add the 2nd lower quad
|
|
|
|
|
if(numcuts % 2 == 0){
|
|
|
|
|
hold = addfacelist(verts[0][1],verts[0][2],verts[2][vertsize-3],verts[2][vertsize-2],NULL,NULL);
|
2005-08-02 18:20:36 +00:00
|
|
|
hold->e2->f2 |= EDGEINNER;
|
2005-08-07 21:47:08 +00:00
|
|
|
facecopy(efa,hold);
|
2005-07-17 15:45:35 +00:00
|
|
|
// Also Make inner quad
|
2005-08-07 21:47:08 +00:00
|
|
|
hold = addfacelist(verts[1][numcuts/2],verts[1][(numcuts/2)+1],verts[2][numcuts/2],verts[0][(numcuts/2)+1],NULL,NULL);
|
2005-08-02 18:20:36 +00:00
|
|
|
hold->e3->f2 |= EDGEINNER;
|
2005-08-07 21:47:08 +00:00
|
|
|
facecopy(efa,hold);
|
2005-07-17 15:45:35 +00:00
|
|
|
repeats = (numcuts / 2) -1;
|
|
|
|
|
} else {
|
2005-08-07 21:47:08 +00:00
|
|
|
// Make inner tri
|
|
|
|
|
hold = addfacelist(verts[1][(numcuts/2)+1],verts[2][(numcuts/2)+1],verts[0][(numcuts/2)+1],NULL,NULL,NULL);
|
2005-08-02 18:20:36 +00:00
|
|
|
hold->e2->f2 |= EDGEINNER;
|
2005-08-07 21:47:08 +00:00
|
|
|
facecopy(efa,hold);
|
2005-07-17 15:45:35 +00:00
|
|
|
repeats = ((numcuts+1) / 2)-1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// cuts for 1 and 2 do not have the repeating quads
|
|
|
|
|
if(numcuts < 3){repeats = 0;}
|
|
|
|
|
for(i=0;i<repeats;i++){
|
|
|
|
|
//Make side repeating Quads
|
2005-08-02 18:20:36 +00:00
|
|
|
hold = addfacelist(verts[1][i+1],verts[1][i+2],verts[0][vertsize-i-3],verts[0][vertsize-i-2],NULL,NULL);
|
2005-08-07 21:47:08 +00:00
|
|
|
hold->e2->f2 |= EDGEINNER;
|
|
|
|
|
facecopy(efa,hold);
|
|
|
|
|
hold = addfacelist(verts[1][vertsize-i-3],verts[1][vertsize-i-2],verts[2][i+1],verts[2][i+2],NULL,NULL);
|
2005-08-02 18:20:36 +00:00
|
|
|
hold->e4->f2 |= EDGEINNER;
|
2005-07-17 15:45:35 +00:00
|
|
|
facecopy(efa,hold);
|
|
|
|
|
}
|
|
|
|
|
// Do repeating bottom quads
|
|
|
|
|
for(i=0;i<repeats;i++){
|
2005-08-07 21:47:08 +00:00
|
|
|
if(numcuts % 2 == 1){
|
2005-07-17 15:45:35 +00:00
|
|
|
hold = addfacelist(verts[0][1+i],verts[0][2+i],verts[2][vertsize-3-i],verts[2][vertsize-2-i],NULL,NULL);
|
|
|
|
|
} else {
|
2005-08-07 21:47:08 +00:00
|
|
|
hold = addfacelist(verts[0][2+i],verts[0][3+i],verts[2][vertsize-4-i],verts[2][vertsize-3-i],NULL,NULL);
|
2005-07-17 15:45:35 +00:00
|
|
|
}
|
2005-08-02 18:20:36 +00:00
|
|
|
hold->e2->f2 |= EDGEINNER;
|
2005-08-07 21:47:08 +00:00
|
|
|
facecopy(efa,hold);
|
|
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-17 15:45:35 +00:00
|
|
|
static void fill_quad_quadruple(EditFace *efa, struct GHash *gh, int numcuts,float rad,int beauty)
|
|
|
|
|
{
|
|
|
|
|
EditVert **verts[4], ***innerverts;
|
|
|
|
|
short vertsize, i, j;
|
2005-08-07 21:47:08 +00:00
|
|
|
float co[3];
|
|
|
|
|
EditFace *hold;
|
2005-07-17 15:45:35 +00:00
|
|
|
EditEdge temp;
|
|
|
|
|
// Point verts[0] and [1] to the array of new verts for cedge[0] and cedge[1]
|
|
|
|
|
verts[0] = BLI_ghash_lookup(gh, efa->e1);
|
|
|
|
|
verts[1] = BLI_ghash_lookup(gh, efa->e2);
|
|
|
|
|
verts[2] = BLI_ghash_lookup(gh, efa->e3);
|
|
|
|
|
verts[3] = BLI_ghash_lookup(gh, efa->e4);
|
|
|
|
|
|
|
|
|
|
//This is the index size of the verts array
|
|
|
|
|
vertsize = numcuts+2;
|
|
|
|
|
|
|
|
|
|
// Is the original v1 the same as the first vert on the selected edge?
|
|
|
|
|
// if not, the edge is running the opposite direction in this face so flip
|
|
|
|
|
// the array to the correct direction
|
|
|
|
|
|
|
|
|
|
if(verts[0][0] != efa->v1) {flipvertarray(verts[0],numcuts+2);}
|
|
|
|
|
if(verts[1][0] != efa->v2) {flipvertarray(verts[1],numcuts+2);}
|
|
|
|
|
if(verts[2][0] == efa->v3) {flipvertarray(verts[2],numcuts+2);}
|
2005-08-07 21:47:08 +00:00
|
|
|
if(verts[3][0] == efa->v4) {flipvertarray(verts[3],numcuts+2);}
|
2005-07-17 15:45:35 +00:00
|
|
|
/*
|
|
|
|
|
We should have something like this now
|
|
|
|
|
1
|
|
|
|
|
|
|
|
|
|
3 2 1 0
|
|
|
|
|
0|---*---*---|0
|
2005-08-07 21:47:08 +00:00
|
|
|
| |
|
|
|
|
|
1* *1
|
|
|
|
|
2 | | 4
|
|
|
|
|
2* *2
|
|
|
|
|
| |
|
|
|
|
|
3|---*---*---|3
|
2005-07-17 15:45:35 +00:00
|
|
|
3 2 1 0
|
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
// we will fill a 2 dim array of editvert*s to make filling easier
|
|
|
|
|
// the innervert order is shown
|
|
|
|
|
|
|
|
|
|
0 0---1---2---3
|
|
|
|
|
| | | |
|
|
|
|
|
1 0---1---2---3
|
|
|
|
|
| | | |
|
2005-08-07 21:47:08 +00:00
|
|
|
2 0---1---2---3
|
2005-07-17 15:45:35 +00:00
|
|
|
| | | |
|
|
|
|
|
3 0---1---2---3
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
innerverts = MEM_mallocN(sizeof(EditVert*)*(numcuts+2),"quad-quad subdiv inner verts outer array");
|
|
|
|
|
for(i=0;i<numcuts+2;i++){
|
|
|
|
|
innerverts[i] = MEM_mallocN(sizeof(EditVert*)*(numcuts+2),"quad-quad subdiv inner verts inner array");
|
|
|
|
|
}
|
|
|
|
|
// first row is e1 last row is e3
|
|
|
|
|
for(i=0;i<numcuts+2;i++){
|
2005-08-07 21:47:08 +00:00
|
|
|
innerverts[0][i] = verts[0][(numcuts+1)-i];
|
2005-07-17 15:45:35 +00:00
|
|
|
innerverts[numcuts+1][i] = verts[2][(numcuts+1)-i];
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
2005-07-17 15:45:35 +00:00
|
|
|
for(i=1;i<=numcuts;i++){
|
2005-08-07 21:47:08 +00:00
|
|
|
innerverts[i][0] = verts[1][i];
|
2005-07-17 15:45:35 +00:00
|
|
|
innerverts[i][numcuts+1] = verts[3][i];
|
|
|
|
|
for(j=1;j<=numcuts;j++){
|
|
|
|
|
co[0] = ((verts[1][i]->co[0] - verts[3][i]->co[0]) * (j /(float)(numcuts+1))) + verts[3][i]->co[0];
|
|
|
|
|
co[1] = ((verts[1][i]->co[1] - verts[3][i]->co[1]) * (j /(float)(numcuts+1))) + verts[3][i]->co[1];
|
2005-08-07 21:47:08 +00:00
|
|
|
co[2] = ((verts[1][i]->co[2] - verts[3][i]->co[2]) * (j /(float)(numcuts+1))) + verts[3][i]->co[2];
|
2005-07-17 15:45:35 +00:00
|
|
|
|
|
|
|
|
temp.v1 = innerverts[i][0];
|
|
|
|
|
temp.v2 = innerverts[i][numcuts+1];
|
|
|
|
|
|
|
|
|
|
// Call alter co for things like fractal and smooth
|
2005-08-05 15:08:43 +00:00
|
|
|
alter_co(co,&temp,rad,beauty,j/(float)(numcuts+1));
|
2005-07-17 15:45:35 +00:00
|
|
|
|
|
|
|
|
innerverts[i][(numcuts+1)-j] = addvertlist(co);
|
|
|
|
|
|
|
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-07-17 15:45:35 +00:00
|
|
|
// Fill with faces
|
|
|
|
|
for(i=0;i<numcuts+1;i++){
|
|
|
|
|
for(j=0;j<numcuts+1;j++){
|
2005-08-07 21:47:08 +00:00
|
|
|
hold = addfacelist(innerverts[i][j+1],innerverts[i][j],innerverts[i+1][j],innerverts[i+1][j+1],NULL,NULL);
|
|
|
|
|
hold->e1->f2 = EDGENEW;
|
2005-07-17 15:45:35 +00:00
|
|
|
hold->e2->f2 = EDGENEW;
|
2005-08-07 21:47:08 +00:00
|
|
|
hold->e3->f2 = EDGENEW;
|
2005-07-17 15:45:35 +00:00
|
|
|
hold->e4->f2 = EDGENEW;
|
2005-08-02 18:20:36 +00:00
|
|
|
|
|
|
|
|
if(i != 0){ hold->e1->f2 |= EDGEINNER; }
|
2005-08-07 21:47:08 +00:00
|
|
|
if(j != 0){ hold->e2->f2 |= EDGEINNER; }
|
|
|
|
|
if(i != numcuts){ hold->e3->f2 |= EDGEINNER; }
|
|
|
|
|
if(j != numcuts){ hold->e4->f2 |= EDGEINNER; }
|
2005-08-02 18:20:36 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
facecopy(efa,hold);
|
|
|
|
|
}
|
2005-07-17 15:45:35 +00:00
|
|
|
}
|
|
|
|
|
// Clean up our dynamic multi-dim array
|
|
|
|
|
for(i=0;i<numcuts+2;i++){
|
|
|
|
|
MEM_freeN(innerverts[i]);
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
2005-07-17 15:45:35 +00:00
|
|
|
MEM_freeN(innerverts);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void fill_tri_triple(EditFace *efa, struct GHash *gh, int numcuts,float rad,int beauty)
|
|
|
|
|
{
|
|
|
|
|
EditVert **verts[3], ***innerverts;
|
|
|
|
|
short vertsize, i, j;
|
2005-08-07 21:47:08 +00:00
|
|
|
float co[3];
|
2005-07-17 15:45:35 +00:00
|
|
|
EditFace *hold;
|
|
|
|
|
EditEdge temp;
|
|
|
|
|
|
|
|
|
|
// Point verts[0] and [1] to the array of new verts for cedge[0] and cedge[1]
|
|
|
|
|
verts[0] = BLI_ghash_lookup(gh, efa->e1);
|
|
|
|
|
verts[1] = BLI_ghash_lookup(gh, efa->e2);
|
|
|
|
|
verts[2] = BLI_ghash_lookup(gh, efa->e3);
|
|
|
|
|
|
|
|
|
|
//This is the index size of the verts array
|
|
|
|
|
vertsize = numcuts+2;
|
|
|
|
|
|
|
|
|
|
// Is the original v1 the same as the first vert on the selected edge?
|
|
|
|
|
// if not, the edge is running the opposite direction in this face so flip
|
|
|
|
|
// the array to the correct direction
|
|
|
|
|
|
|
|
|
|
if(verts[0][0] != efa->v1) {flipvertarray(verts[0],numcuts+2);}
|
|
|
|
|
if(verts[1][0] != efa->v2) {flipvertarray(verts[1],numcuts+2);}
|
|
|
|
|
if(verts[2][0] != efa->v3) {flipvertarray(verts[2],numcuts+2);}
|
|
|
|
|
/*
|
|
|
|
|
We should have something like this now
|
|
|
|
|
3
|
|
|
|
|
|
|
|
|
|
3 2 1 0
|
|
|
|
|
0|---*---*---|3
|
2005-08-07 21:47:08 +00:00
|
|
|
| /
|
|
|
|
|
1 1* *2
|
|
|
|
|
| /
|
|
|
|
|
2* *1 2
|
|
|
|
|
| /
|
2005-07-17 15:45:35 +00:00
|
|
|
3|/
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
|
we will fill a 2 dim array of editvert*s to make filling easier
|
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
|
|
0 0---1---2---3---4
|
2005-08-07 21:47:08 +00:00
|
|
|
| / | / |/ | /
|
2005-07-17 15:45:35 +00:00
|
|
|
1 0---1----2---3
|
2005-08-07 21:47:08 +00:00
|
|
|
1 | / | / | /
|
|
|
|
|
2 0----1---2 2
|
|
|
|
|
| / | /
|
2005-07-17 15:45:35 +00:00
|
|
|
|/ |/
|
|
|
|
|
3 0---1
|
|
|
|
|
| /
|
|
|
|
|
|/
|
|
|
|
|
4 0
|
|
|
|
|
|
|
|
|
|
*/
|
2005-08-07 21:47:08 +00:00
|
|
|
|
2005-07-17 15:45:35 +00:00
|
|
|
innerverts = MEM_mallocN(sizeof(EditVert*)*(numcuts+2),"tri-tri subdiv inner verts outer array");
|
|
|
|
|
for(i=0;i<numcuts+2;i++){
|
|
|
|
|
innerverts[i] = MEM_mallocN(sizeof(EditVert*)*((numcuts+2)-i),"tri-tri subdiv inner verts inner array");
|
|
|
|
|
}
|
|
|
|
|
//top row is e3 backwards
|
|
|
|
|
for(i=0;i<numcuts+2;i++){
|
2005-08-07 21:47:08 +00:00
|
|
|
innerverts[0][i] = verts[2][(numcuts+1)-i];
|
2005-07-17 15:45:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i=1;i<=numcuts+1;i++){
|
|
|
|
|
//first vert is from e1, last is from e2
|
2005-08-07 21:47:08 +00:00
|
|
|
innerverts[i][0] = verts[0][i];
|
|
|
|
|
innerverts[i][(numcuts+1)-i] = verts[1][(numcuts+1)-i];
|
2005-07-17 15:45:35 +00:00
|
|
|
for(j=1;j<(numcuts+1)-i;j++){
|
|
|
|
|
co[0] = ((verts[0][i]->co[0] - verts[1][(numcuts+1)-i]->co[0]) * (j/(float)((numcuts+1)-i))) + verts[1][(numcuts+1)-i]->co[0];
|
|
|
|
|
co[1] = ((verts[0][i]->co[1] - verts[1][(numcuts+1)-i]->co[1]) * (j/(float)((numcuts+1)-i))) + verts[1][(numcuts+1)-i]->co[1];
|
2005-08-07 21:47:08 +00:00
|
|
|
co[2] = ((verts[0][i]->co[2] - verts[1][(numcuts+1)-i]->co[2]) * (j/(float)((numcuts+1)-i))) + verts[1][(numcuts+1)-i]->co[2];
|
2005-07-17 15:45:35 +00:00
|
|
|
|
|
|
|
|
temp.v1 = innerverts[i][0];
|
|
|
|
|
temp.v2 = innerverts[i][(numcuts+1)-i];
|
|
|
|
|
|
2005-08-05 15:08:43 +00:00
|
|
|
alter_co(co,&temp,rad,beauty,j/(float)((numcuts+1)-i));
|
2005-07-17 15:45:35 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
innerverts[i][((numcuts+1)-i)-j] = addvertlist(co);
|
2005-07-17 15:45:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Now fill the verts with happy little tris :)
|
|
|
|
|
for(i=0;i<=numcuts+1;i++){
|
|
|
|
|
for(j=0;j<(numcuts+1)-i;j++){
|
|
|
|
|
//We always do the first tri
|
2005-08-07 21:47:08 +00:00
|
|
|
hold = addfacelist(innerverts[i][j+1],innerverts[i][j],innerverts[i+1][j],NULL,NULL,NULL);
|
|
|
|
|
hold->e1->f2 |= EDGENEW;
|
2005-08-02 18:20:36 +00:00
|
|
|
hold->e2->f2 |= EDGENEW;
|
|
|
|
|
hold->e3->f2 |= EDGENEW;
|
|
|
|
|
if(i != 0){ hold->e1->f2 |= EDGEINNER; }
|
2005-08-07 21:47:08 +00:00
|
|
|
if(j != 0){ hold->e2->f2 |= EDGEINNER; }
|
|
|
|
|
if(j+1 != (numcuts+1)-i){hold->e3->f2 |= EDGEINNER;}
|
|
|
|
|
|
|
|
|
|
facecopy(efa,hold);
|
|
|
|
|
//if there are more to come, we do the 2nd
|
2005-07-17 15:45:35 +00:00
|
|
|
if(j+1 <= numcuts-i){
|
2005-08-07 21:47:08 +00:00
|
|
|
hold = addfacelist(innerverts[i+1][j],innerverts[i+1][j+1],innerverts[i][j+1],NULL,NULL,NULL);
|
2005-07-17 15:45:35 +00:00
|
|
|
facecopy(efa,hold);
|
2005-08-07 21:47:08 +00:00
|
|
|
hold->e1->f2 |= EDGENEW;
|
2005-08-02 18:20:36 +00:00
|
|
|
hold->e2->f2 |= EDGENEW;
|
|
|
|
|
hold->e3->f2 |= EDGENEW;
|
2005-07-17 15:45:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Clean up our dynamic multi-dim array
|
|
|
|
|
for(i=0;i<numcuts+2;i++){
|
|
|
|
|
MEM_freeN(innerverts[i]);
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
2005-07-17 15:45:35 +00:00
|
|
|
MEM_freeN(innerverts);
|
2005-07-13 15:20:40 +00:00
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
// This function takes an example edge, the current point to create and
|
|
|
|
|
// the total # of points to create, then creates the point and return the
|
|
|
|
|
// editvert pointer to it.
|
2005-07-17 15:45:35 +00:00
|
|
|
static EditVert *subdivideedgenum(EditEdge *edge,int curpoint,int totpoint,float rad,int beauty)
|
|
|
|
|
{
|
|
|
|
|
float co[3];
|
|
|
|
|
float percent;
|
|
|
|
|
EditVert *ev;
|
|
|
|
|
|
|
|
|
|
if (beauty & (B_PERCENTSUBD) && totpoint == 1){
|
|
|
|
|
percent=(float)(edge->f1)/32768.0f;
|
|
|
|
|
co[0] = (edge->v2->co[0]-edge->v1->co[0])*percent+edge->v1->co[0];
|
|
|
|
|
co[1] = (edge->v2->co[1]-edge->v1->co[1])*percent+edge->v1->co[1];
|
2005-08-07 21:47:08 +00:00
|
|
|
co[2] = (edge->v2->co[2]-edge->v1->co[2])*percent+edge->v1->co[2];
|
|
|
|
|
} else {
|
2005-07-17 15:45:35 +00:00
|
|
|
co[0] = (edge->v2->co[0]-edge->v1->co[0])*(curpoint/(float)(totpoint+1))+edge->v1->co[0];
|
|
|
|
|
co[1] = (edge->v2->co[1]-edge->v1->co[1])*(curpoint/(float)(totpoint+1))+edge->v1->co[1];
|
|
|
|
|
co[2] = (edge->v2->co[2]-edge->v1->co[2])*(curpoint/(float)(totpoint+1))+edge->v1->co[2];
|
|
|
|
|
}
|
|
|
|
|
|
2005-08-05 15:08:43 +00:00
|
|
|
alter_co(co,edge,rad,beauty,curpoint/(float)(totpoint+1));
|
2005-07-17 15:45:35 +00:00
|
|
|
ev = addvertlist(co);
|
|
|
|
|
ev->f = edge->v1->f;
|
|
|
|
|
|
|
|
|
|
return ev;
|
2005-07-13 15:20:40 +00:00
|
|
|
}
|
2005-05-13 10:20:10 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
void esubdivideflag(int flag, float rad, int beauty, int numcuts, int seltype)
|
|
|
|
|
{
|
2005-07-17 15:45:35 +00:00
|
|
|
EditMesh *em = G.editMesh;
|
|
|
|
|
EditFace *ef;
|
2005-07-19 15:37:18 +00:00
|
|
|
EditEdge *eed, *cedge, *sort[4];
|
2005-07-17 15:45:35 +00:00
|
|
|
EditVert **templist;
|
|
|
|
|
struct GHash *gh;
|
2005-07-19 15:37:18 +00:00
|
|
|
int i,j,edgecount,facetype,hold;
|
|
|
|
|
float length[4];
|
2005-07-17 15:45:35 +00:00
|
|
|
|
|
|
|
|
//Set faces f1 to 0 cause we need it later
|
|
|
|
|
|
|
|
|
|
for(ef=em->faces.first;ef;ef = ef->next){
|
|
|
|
|
ef->f1 = 0;
|
|
|
|
|
}
|
|
|
|
|
for(eed = em->edges.first;eed;eed = eed->next){
|
|
|
|
|
//Flush vertext flags upward to the edges
|
|
|
|
|
//if(eed->f & flag && eed->v1->f == eed->v2->f){
|
2005-08-07 21:47:08 +00:00
|
|
|
// eed->f |= eed->v1->f;
|
2005-07-17 15:45:35 +00:00
|
|
|
// }
|
|
|
|
|
eed->f2 = 0;
|
|
|
|
|
}
|
|
|
|
|
// We store an array of verts for each edge that is subdivided,
|
|
|
|
|
// we put this array as a value in a ghash which is keyed by the EditEdge*
|
|
|
|
|
|
2005-07-19 15:37:18 +00:00
|
|
|
// Now for beauty subdivide deselect edges based on length
|
|
|
|
|
if(beauty & B_BEAUTY){
|
2005-08-07 21:47:08 +00:00
|
|
|
for(ef = em->faces.first;ef;ef = ef->next){
|
|
|
|
|
if(!ef->v4){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if(ef->f & SELECT){
|
|
|
|
|
length[0] = VecLenf(ef->e1->v1->co,ef->e1->v2->co);
|
|
|
|
|
length[1] = VecLenf(ef->e2->v1->co,ef->e2->v2->co);
|
|
|
|
|
length[2] = VecLenf(ef->e3->v1->co,ef->e3->v2->co);
|
|
|
|
|
length[3] = VecLenf(ef->e4->v1->co,ef->e4->v2->co);
|
|
|
|
|
sort[0] = ef->e1;
|
|
|
|
|
sort[1] = ef->e2;
|
|
|
|
|
sort[2] = ef->e3;
|
|
|
|
|
sort[3] = ef->e4;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Beauty Short Edges
|
|
|
|
|
if(beauty & B_BEAUTY_SHORT){
|
|
|
|
|
for(j=0;j<2;j++){
|
|
|
|
|
hold = -1;
|
|
|
|
|
for(i=0;i<4;i++){
|
|
|
|
|
if(length[i] < 0){
|
|
|
|
|
continue;
|
|
|
|
|
} else if(hold == -1){
|
|
|
|
|
hold = i;
|
|
|
|
|
} else {
|
|
|
|
|
if(length[hold] < length[i]){
|
|
|
|
|
hold = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sort[hold]->f &= ~SELECT;
|
|
|
|
|
sort[hold]->f2 |= EDGENEW;
|
|
|
|
|
length[hold] = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Beauty Long Edges
|
|
|
|
|
else {
|
|
|
|
|
for(j=0;j<2;j++){
|
|
|
|
|
hold = -1;
|
|
|
|
|
for(i=0;i<4;i++){
|
|
|
|
|
if(length[i] < 0){
|
|
|
|
|
continue;
|
|
|
|
|
} else if(hold == -1){
|
|
|
|
|
hold = i;
|
|
|
|
|
} else {
|
|
|
|
|
if(length[hold] > length[i]){
|
|
|
|
|
hold = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sort[hold]->f &= ~SELECT;
|
|
|
|
|
sort[hold]->f2 |= EDGENEW;
|
|
|
|
|
length[hold] = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-07-19 15:37:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-07-17 15:45:35 +00:00
|
|
|
gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
// If we are knifing, We only need the selected edges that were cut, so deselect if it was not cut
|
2005-07-17 15:45:35 +00:00
|
|
|
if(beauty & B_KNIFE) {
|
2005-07-13 15:20:40 +00:00
|
|
|
for(eed= em->edges.first;eed;eed=eed->next){
|
|
|
|
|
if( eed->f1 == 0 ){
|
2005-07-17 15:45:35 +00:00
|
|
|
EM_select_edge(eed,0);
|
|
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-07-17 15:45:35 +00:00
|
|
|
// So for each edge, if it is selected, we allocate an array of size cuts+2
|
|
|
|
|
// so we can have a place for the v1, the new verts and v2
|
|
|
|
|
for(eed=em->edges.first;eed;eed = eed->next){
|
|
|
|
|
if(eed->f & flag){
|
|
|
|
|
templist = MEM_mallocN(sizeof(EditVert*)*(numcuts+2),"vertlist");
|
|
|
|
|
templist[0] = eed->v1;
|
|
|
|
|
for(i=0;i<numcuts;i++){
|
|
|
|
|
// This function creates the new vert and returns it back
|
|
|
|
|
// to the array
|
|
|
|
|
templist[i+1] = subdivideedgenum(eed,i+1,numcuts,rad,beauty);
|
|
|
|
|
//while we are here, we can copy edge info from the original edge
|
|
|
|
|
cedge = addedgelist(templist[i],templist[i+1],eed);
|
|
|
|
|
// Also set the edge f2 to EDGENEW so that we can use this info later
|
|
|
|
|
cedge->f2 = EDGENEW;
|
|
|
|
|
}
|
|
|
|
|
templist[i+1] = eed->v2;
|
|
|
|
|
//Do the last edge too
|
|
|
|
|
cedge = addedgelist(templist[i],templist[i+1],eed);
|
|
|
|
|
cedge->f2 = EDGENEW;
|
|
|
|
|
// Now that the edge is subdivided, we can put its verts in the ghash
|
2005-08-07 21:47:08 +00:00
|
|
|
BLI_ghash_insert(gh, eed, templist);
|
|
|
|
|
}
|
2005-07-17 15:45:35 +00:00
|
|
|
}
|
2005-07-19 15:37:18 +00:00
|
|
|
|
2005-08-05 15:08:43 +00:00
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
2005-07-17 15:45:35 +00:00
|
|
|
// Now for each face in the mesh we need to figure out How many edges were cut
|
|
|
|
|
// and which filling method to use for that face
|
2005-08-07 21:47:08 +00:00
|
|
|
for(ef = em->faces.first;ef;ef = ef->next){
|
2005-07-17 15:45:35 +00:00
|
|
|
edgecount = 0;
|
|
|
|
|
facetype = 3;
|
|
|
|
|
if(ef->e1->f & flag) {edgecount++;}
|
|
|
|
|
if(ef->e2->f & flag) {edgecount++;}
|
|
|
|
|
if(ef->e3->f & flag) {edgecount++;}
|
|
|
|
|
if(ef->v4){
|
|
|
|
|
facetype = 4;
|
|
|
|
|
if(ef->e4->f & flag){edgecount++;}
|
|
|
|
|
}
|
|
|
|
|
if(facetype == 4){
|
|
|
|
|
switch(edgecount){
|
|
|
|
|
case 0: break;
|
|
|
|
|
case 1: ef->f1 = SELECT;
|
2005-08-08 15:59:05 +00:00
|
|
|
fill_quad_single(ef, gh, numcuts, seltype);
|
2005-07-17 15:45:35 +00:00
|
|
|
break;
|
|
|
|
|
case 2: ef->f1 = SELECT;
|
|
|
|
|
// if there are 2, we check if edge 1 and 3 are either both on or off that way
|
|
|
|
|
// we can tell if the selected pair is Adjacent or Opposite of each other
|
|
|
|
|
if((ef->e1->f & flag && ef->e3->f & flag) ||
|
|
|
|
|
(ef->e2->f & flag && ef->e4->f & flag)){
|
2005-08-07 21:47:08 +00:00
|
|
|
fill_quad_double_op(ef, gh, numcuts);
|
2005-07-17 15:45:35 +00:00
|
|
|
}else{
|
|
|
|
|
//printf("adj\n");
|
2005-08-07 21:47:08 +00:00
|
|
|
fill_quad_double_adj(ef, gh, numcuts);
|
2005-07-17 15:45:35 +00:00
|
|
|
}
|
2005-08-07 21:47:08 +00:00
|
|
|
break;
|
2005-07-17 15:45:35 +00:00
|
|
|
case 3: ef->f1 = SELECT;
|
|
|
|
|
fill_quad_triple(ef, gh, numcuts);
|
2005-08-07 21:47:08 +00:00
|
|
|
break;
|
2005-07-17 15:45:35 +00:00
|
|
|
case 4: ef->f1 = SELECT;
|
|
|
|
|
fill_quad_quadruple(ef, gh, numcuts,rad,beauty);
|
2005-08-07 21:47:08 +00:00
|
|
|
break;
|
2005-07-17 15:45:35 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
switch(edgecount){
|
|
|
|
|
case 0: break;
|
|
|
|
|
case 1: ef->f1 = SELECT;
|
2005-08-08 15:59:05 +00:00
|
|
|
fill_tri_single(ef, gh, numcuts, seltype);
|
2005-07-17 15:45:35 +00:00
|
|
|
break;
|
|
|
|
|
case 2: ef->f1 = SELECT;
|
|
|
|
|
fill_tri_double(ef, gh, numcuts);
|
2005-08-07 21:47:08 +00:00
|
|
|
break;
|
2005-07-17 15:45:35 +00:00
|
|
|
case 3: ef->f1 = SELECT;
|
|
|
|
|
fill_tri_triple(ef, gh, numcuts,rad,beauty);
|
|
|
|
|
break;
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delete Old Faces
|
|
|
|
|
free_tagged_facelist(em->faces.first);
|
|
|
|
|
//Delete Old Edges
|
|
|
|
|
for(eed = em->edges.first;eed;eed = eed->next){
|
|
|
|
|
if(BLI_ghash_haskey(gh,eed)){
|
2005-07-17 15:45:35 +00:00
|
|
|
eed->f1 = SELECT;
|
2005-08-07 21:47:08 +00:00
|
|
|
} else {
|
2005-07-17 15:45:35 +00:00
|
|
|
eed->f1 = 0;
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
free_tagged_edgelist(em->edges.first);
|
|
|
|
|
|
2005-08-08 15:59:05 +00:00
|
|
|
if(seltype == SUBDIV_SELECT_ORIG && G.qual != LR_CTRLKEY){
|
2005-08-07 21:47:08 +00:00
|
|
|
for(eed = em->edges.first;eed;eed = eed->next){
|
|
|
|
|
if(eed->f2 & EDGENEW){
|
|
|
|
|
eed->f |= flag;
|
|
|
|
|
EM_select_edge(eed,1);
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
eed->f &= !flag;
|
|
|
|
|
EM_select_edge(eed,0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-08-08 15:59:05 +00:00
|
|
|
} else if ((seltype == SUBDIV_SELECT_INNER || seltype == SUBDIV_SELECT_INNER_SEL)|| G.qual == LR_CTRLKEY){
|
2005-08-07 21:47:08 +00:00
|
|
|
for(eed = em->edges.first;eed;eed = eed->next){
|
|
|
|
|
if(eed->f2 & EDGEINNER){
|
|
|
|
|
eed->f |= flag;
|
|
|
|
|
EM_select_edge(eed,1);
|
|
|
|
|
}else{
|
|
|
|
|
eed->f &= !flag;
|
|
|
|
|
EM_select_edge(eed,0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(G.scene->selectmode & SCE_SELECT_VERTEX){
|
|
|
|
|
for(eed = em->edges.first;eed;eed = eed->next){
|
|
|
|
|
if(eed->f & SELECT){
|
|
|
|
|
eed->v1->f |= SELECT;
|
|
|
|
|
eed->v2->f |= SELECT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Free the ghash and call MEM_freeN on all the value entries to return
|
|
|
|
|
// that memory
|
|
|
|
|
BLI_ghash_free(gh, NULL, (GHashValFreeFP)MEM_freeN);
|
2005-07-17 15:45:35 +00:00
|
|
|
|
2005-07-19 02:23:52 +00:00
|
|
|
EM_selectmode_flush();
|
|
|
|
|
for(ef=em->faces.first;ef;ef = ef->next){
|
|
|
|
|
if(ef->e4){
|
2005-08-07 21:47:08 +00:00
|
|
|
if( (ef->e1->f & SELECT && ef->e2->f & SELECT) &&
|
|
|
|
|
(ef->e3->f & SELECT && ef->e4->f & SELECT) ){
|
|
|
|
|
ef->f |= SELECT;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if( (ef->e1->f & SELECT && ef->e2->f & SELECT) && ef->e3->f & SELECT){
|
|
|
|
|
ef->f |= SELECT;
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-07-19 02:23:52 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
recalc_editnormals();
|
|
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
|
|
|
|
}
|
2005-05-13 10:20:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static int count_selected_edges(EditEdge *ed)
|
|
|
|
|
{
|
|
|
|
|
int totedge = 0;
|
|
|
|
|
while(ed) {
|
|
|
|
|
ed->vn= 0;
|
|
|
|
|
if( ed->f & SELECT ) totedge++;
|
|
|
|
|
ed= ed->next;
|
|
|
|
|
}
|
|
|
|
|
return totedge;
|
|
|
|
|
}
|
2005-05-13 10:20:10 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* hurms, as if this makes code readable! It's pointerpointer hiding... (ton) */
|
|
|
|
|
typedef EditFace *EVPtr;
|
|
|
|
|
typedef EVPtr EVPTuple[2];
|
2005-05-13 10:20:10 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/** builds EVPTuple array efaa of face tuples (in fact pointers to EditFaces)
|
2005-08-07 21:47:08 +00:00
|
|
|
sharing one edge.
|
2005-07-13 15:20:40 +00:00
|
|
|
arguments: selected edge list, face list.
|
2005-08-07 21:47:08 +00:00
|
|
|
Edges will also be tagged accordingly (see eed->f2) */
|
2005-05-13 10:20:10 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static int collect_quadedges(EVPTuple *efaa, EditEdge *eed, EditFace *efa)
|
|
|
|
|
{
|
|
|
|
|
EditEdge *e1, *e2, *e3;
|
|
|
|
|
EVPtr *evp;
|
2005-07-17 15:45:35 +00:00
|
|
|
int i = 0;
|
2005-05-13 10:20:10 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* run through edges, if selected, set pointer edge-> facearray */
|
|
|
|
|
while(eed) {
|
|
|
|
|
eed->f2= 0;
|
|
|
|
|
eed->f1= 0;
|
|
|
|
|
if( eed->f & SELECT ) {
|
|
|
|
|
eed->vn= (EditVert *) (&efaa[i]);
|
|
|
|
|
i++;
|
2005-05-13 10:20:10 +00:00
|
|
|
}
|
2005-08-07 21:23:55 +00:00
|
|
|
else eed->vn= NULL;
|
2005-07-13 15:20:40 +00:00
|
|
|
|
|
|
|
|
eed= eed->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* find edges pointing to 2 faces by procedure:
|
|
|
|
|
|
|
|
|
|
- run through faces and their edges, increase
|
|
|
|
|
face counter e->f1 for each face
|
|
|
|
|
*/
|
2005-05-13 10:20:10 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
while(efa) {
|
|
|
|
|
efa->f1= 0;
|
|
|
|
|
if(efa->v4==0) { /* if triangle */
|
|
|
|
|
if(efa->f & SELECT) {
|
|
|
|
|
|
|
|
|
|
e1= efa->e1;
|
|
|
|
|
e2= efa->e2;
|
|
|
|
|
e3= efa->e3;
|
2005-08-07 21:23:55 +00:00
|
|
|
if(e1->f2<3 && e1->vn) {
|
2005-07-13 15:20:40 +00:00
|
|
|
if(e1->f2<2) {
|
|
|
|
|
evp= (EVPtr *) e1->vn;
|
|
|
|
|
evp[(int)e1->f2]= efa;
|
|
|
|
|
}
|
|
|
|
|
e1->f2+= 1;
|
|
|
|
|
}
|
2005-08-07 21:23:55 +00:00
|
|
|
if(e2->f2<3 && e2->vn) {
|
2005-07-13 15:20:40 +00:00
|
|
|
if(e2->f2<2) {
|
|
|
|
|
evp= (EVPtr *) e2->vn;
|
|
|
|
|
evp[(int)e2->f2]= efa;
|
|
|
|
|
}
|
|
|
|
|
e2->f2+= 1;
|
|
|
|
|
}
|
2005-08-07 21:23:55 +00:00
|
|
|
if(e3->f2<3 && e3->vn) {
|
2005-07-13 15:20:40 +00:00
|
|
|
if(e3->f2<2) {
|
|
|
|
|
evp= (EVPtr *) e3->vn;
|
|
|
|
|
evp[(int)e3->f2]= efa;
|
|
|
|
|
}
|
|
|
|
|
e3->f2+= 1;
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
efa= efa->next;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
return i;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* returns vertices of two adjacent triangles forming a quad
|
|
|
|
|
- can be righthand or lefthand
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
4-----3
|
2005-08-07 21:47:08 +00:00
|
|
|
|\ |
|
2005-07-13 15:20:40 +00:00
|
|
|
| \ 2 | <- efa1
|
|
|
|
|
| \ |
|
|
|
|
|
efa-> | 1 \ |
|
2005-08-07 21:47:08 +00:00
|
|
|
| \|
|
2005-07-13 15:20:40 +00:00
|
|
|
1-----2
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
*/
|
|
|
|
|
#define VTEST(face, num, other) \
|
|
|
|
|
(face->v##num != other->v1 && face->v##num != other->v2 && face->v##num != other->v3)
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static void givequadverts(EditFace *efa, EditFace *efa1, EditVert **v1, EditVert **v2, EditVert **v3, EditVert **v4, float **uv, unsigned int *col)
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
{
|
2005-07-13 15:20:40 +00:00
|
|
|
if VTEST(efa, 1, efa1) {
|
|
|
|
|
//if(efa->v1!=efa1->v1 && efa->v1!=efa1->v2 && efa->v1!=efa1->v3) {
|
|
|
|
|
*v1= efa->v1;
|
|
|
|
|
*v2= efa->v2;
|
|
|
|
|
uv[0] = efa->tf.uv[0];
|
|
|
|
|
uv[1] = efa->tf.uv[1];
|
|
|
|
|
col[0] = efa->tf.col[0];
|
|
|
|
|
col[1] = efa->tf.col[1];
|
|
|
|
|
}
|
|
|
|
|
else if VTEST(efa, 2, efa1) {
|
|
|
|
|
//else if(efa->v2!=efa1->v1 && efa->v2!=efa1->v2 && efa->v2!=efa1->v3) {
|
|
|
|
|
*v1= efa->v2;
|
|
|
|
|
*v2= efa->v3;
|
|
|
|
|
uv[0] = efa->tf.uv[1];
|
|
|
|
|
uv[1] = efa->tf.uv[2];
|
|
|
|
|
col[0] = efa->tf.col[1];
|
|
|
|
|
col[1] = efa->tf.col[2];
|
|
|
|
|
}
|
|
|
|
|
else if VTEST(efa, 3, efa1) {
|
|
|
|
|
// else if(efa->v3!=efa1->v1 && efa->v3!=efa1->v2 && efa->v3!=efa1->v3) {
|
|
|
|
|
*v1= efa->v3;
|
|
|
|
|
*v2= efa->v1;
|
|
|
|
|
uv[0] = efa->tf.uv[2];
|
|
|
|
|
uv[1] = efa->tf.uv[0];
|
|
|
|
|
col[0] = efa->tf.col[2];
|
|
|
|
|
col[1] = efa->tf.col[0];
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
if VTEST(efa1, 1, efa) {
|
|
|
|
|
// if(efa1->v1!=efa->v1 && efa1->v1!=efa->v2 && efa1->v1!=efa->v3) {
|
|
|
|
|
*v3= efa1->v1;
|
|
|
|
|
uv[2] = efa1->tf.uv[0];
|
|
|
|
|
col[2] = efa1->tf.col[0];
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
*v4= efa1->v2;
|
|
|
|
|
uv[3] = efa1->tf.uv[1];
|
|
|
|
|
col[3] = efa1->tf.col[1];
|
|
|
|
|
/*
|
|
|
|
|
if(efa1->v2== *v2) {
|
|
|
|
|
*v4= efa1->v3;
|
|
|
|
|
uv[3] = efa1->tf.uv[2];
|
|
|
|
|
} else {
|
|
|
|
|
*v4= efa1->v2;
|
|
|
|
|
uv[3] = efa1->tf.uv[1];
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
else if VTEST(efa1, 2, efa) {
|
|
|
|
|
// else if(efa1->v2!=efa->v1 && efa1->v2!=efa->v2 && efa1->v2!=efa->v3) {
|
|
|
|
|
*v3= efa1->v2;
|
|
|
|
|
uv[2] = efa1->tf.uv[1];
|
|
|
|
|
col[2] = efa1->tf.col[1];
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
*v4= efa1->v3;
|
|
|
|
|
uv[3] = efa1->tf.uv[2];
|
|
|
|
|
col[3] = efa1->tf.col[2];
|
|
|
|
|
/*
|
|
|
|
|
if(efa1->v3== *v2) {
|
|
|
|
|
*v4= efa1->v1;
|
|
|
|
|
uv[3] = efa1->tf.uv[0];
|
|
|
|
|
} else {
|
|
|
|
|
*v4= efa1->v3;
|
|
|
|
|
uv[3] = efa1->tf.uv[2];
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
else if VTEST(efa1, 3, efa) {
|
|
|
|
|
// else if(efa1->v3!=efa->v1 && efa1->v3!=efa->v2 && efa1->v3!=efa->v3) {
|
|
|
|
|
*v3= efa1->v3;
|
|
|
|
|
uv[2] = efa1->tf.uv[2];
|
|
|
|
|
col[2] = efa1->tf.col[2];
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
*v4= efa1->v1;
|
|
|
|
|
uv[3] = efa1->tf.uv[0];
|
|
|
|
|
col[3] = efa1->tf.col[0];
|
|
|
|
|
/*
|
|
|
|
|
if(efa1->v1== *v2) {
|
|
|
|
|
*v4= efa1->v2;
|
|
|
|
|
uv[3] = efa1->tf.uv[3];
|
|
|
|
|
} else {
|
|
|
|
|
*v4= efa1->v1;
|
|
|
|
|
uv[3] = efa1->tf.uv[0];
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
*v3= *v4= NULL;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* Helper functions for edge/quad edit features*/
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static void untag_edges(EditFace *f)
|
|
|
|
|
{
|
|
|
|
|
f->e1->f2 = 0;
|
|
|
|
|
f->e2->f2 = 0;
|
|
|
|
|
if (f->e3) f->e3->f2 = 0;
|
|
|
|
|
if (f->e4) f->e4->f2 = 0;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/** remove and free list of tagged edges */
|
|
|
|
|
static void free_tagged_edgelist(EditEdge *eed)
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
{
|
2005-07-13 15:20:40 +00:00
|
|
|
EditEdge *nexted;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
while(eed) {
|
2005-07-13 15:20:40 +00:00
|
|
|
nexted= eed->next;
|
|
|
|
|
if(eed->f1) {
|
|
|
|
|
remedge(eed);
|
|
|
|
|
free_editedge(eed);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
eed= nexted;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/** remove and free list of tagged faces */
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static void free_tagged_facelist(EditFace *efa)
|
|
|
|
|
{
|
|
|
|
|
EditMesh *em = G.editMesh;
|
|
|
|
|
EditFace *nextvl;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
while(efa) {
|
2005-07-13 15:20:40 +00:00
|
|
|
nextvl= efa->next;
|
|
|
|
|
if(efa->f1) {
|
|
|
|
|
BLI_remlink(&em->faces, efa);
|
|
|
|
|
free_editface(efa);
|
|
|
|
|
}
|
|
|
|
|
efa= nextvl;
|
|
|
|
|
}
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-08-07 21:23:55 +00:00
|
|
|
/* note; the EM_selectmode_set() calls here illustrate how badly constructed it all is... from before the
|
|
|
|
|
edge/face flags, with very mixed results.... */
|
2005-07-13 15:20:40 +00:00
|
|
|
void beauty_fill(void)
|
|
|
|
|
{
|
2005-08-07 21:47:08 +00:00
|
|
|
EditMesh *em = G.editMesh;
|
|
|
|
|
EditVert *v1, *v2, *v3, *v4;
|
|
|
|
|
EditEdge *eed, *nexted;
|
|
|
|
|
EditEdge dia1, dia2;
|
|
|
|
|
EditFace *efa, *w;
|
|
|
|
|
// void **efaar, **efaa;
|
|
|
|
|
EVPTuple *efaar;
|
|
|
|
|
EVPtr *efaa;
|
|
|
|
|
float *uv[4];
|
|
|
|
|
unsigned int col[4];
|
|
|
|
|
float len1, len2, len3, len4, len5, len6, opp1, opp2, fac1, fac2;
|
|
|
|
|
int totedge, ok, notbeauty=8, onedone;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* - all selected edges with two faces
|
|
|
|
|
* - find the faces: store them in edges (using datablock)
|
|
|
|
|
* - per edge: - test convex
|
|
|
|
|
* - test edge: flip?
|
2005-08-07 21:47:08 +00:00
|
|
|
* - if true: remedge, addedge, all edges at the edge get new face pointers
|
2005-07-13 15:20:40 +00:00
|
|
|
*/
|
|
|
|
|
|
2005-08-07 21:23:55 +00:00
|
|
|
EM_selectmode_set(); // makes sure in selectmode 'face' the edges of selected faces are selected too
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
totedge = count_selected_edges(em->edges.first);
|
|
|
|
|
if(totedge==0) return;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
if(okee("Beautify fill")==0) return;
|
|
|
|
|
|
|
|
|
|
/* temp block with face pointers */
|
|
|
|
|
efaar= (EVPTuple *) MEM_callocN(totedge * sizeof(EVPTuple), "beautyfill");
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
while (notbeauty) {
|
|
|
|
|
notbeauty--;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
ok = collect_quadedges(efaar, em->edges.first, em->faces.first);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
/* there we go */
|
|
|
|
|
onedone= 0;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
eed= em->edges.first;
|
|
|
|
|
while(eed) {
|
|
|
|
|
nexted= eed->next;
|
2005-07-13 15:20:40 +00:00
|
|
|
|
|
|
|
|
/* f2 is set in collect_quadedges() */
|
2005-08-07 21:47:08 +00:00
|
|
|
if(eed->f2==2 && eed->h==0) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
efaa = (EVPtr *) eed->vn;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
/* none of the faces should be treated before, nor be part of fgon */
|
|
|
|
|
ok= 1;
|
|
|
|
|
efa= efaa[0];
|
|
|
|
|
if(efa->e1->f1 || efa->e2->f1 || efa->e3->f1) ok= 0;
|
2005-07-13 15:20:40 +00:00
|
|
|
if(efa->fgonf) ok= 0;
|
2005-08-07 21:47:08 +00:00
|
|
|
efa= efaa[1];
|
|
|
|
|
if(efa->e1->f1 || efa->e2->f1 || efa->e3->f1) ok= 0;
|
2005-07-13 15:20:40 +00:00
|
|
|
if(efa->fgonf) ok= 0;
|
|
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
if(ok) {
|
|
|
|
|
/* test convex */
|
|
|
|
|
givequadverts(efaa[0], efaa[1], &v1, &v2, &v3, &v4, uv, col);
|
2005-07-13 15:20:40 +00:00
|
|
|
if(v1 && v2 && v3 && v4) {
|
|
|
|
|
if( convex(v1->co, v2->co, v3->co, v4->co) ) {
|
|
|
|
|
|
|
|
|
|
/* test edges */
|
2005-07-14 13:12:29 +00:00
|
|
|
if( (v1) > (v3) ) {
|
2005-07-13 15:20:40 +00:00
|
|
|
dia1.v1= v3;
|
|
|
|
|
dia1.v2= v1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
dia1.v1= v1;
|
|
|
|
|
dia1.v2= v3;
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-14 13:12:29 +00:00
|
|
|
if( (v2) > (v4) ) {
|
2005-07-13 15:20:40 +00:00
|
|
|
dia2.v1= v4;
|
|
|
|
|
dia2.v2= v2;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
dia2.v1= v2;
|
|
|
|
|
dia2.v2= v4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* testing rule:
|
|
|
|
|
* the area divided by the total edge lengths
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
len1= VecLenf(v1->co, v2->co);
|
|
|
|
|
len2= VecLenf(v2->co, v3->co);
|
|
|
|
|
len3= VecLenf(v3->co, v4->co);
|
|
|
|
|
len4= VecLenf(v4->co, v1->co);
|
|
|
|
|
len5= VecLenf(v1->co, v3->co);
|
|
|
|
|
len6= VecLenf(v2->co, v4->co);
|
|
|
|
|
|
|
|
|
|
opp1= AreaT3Dfl(v1->co, v2->co, v3->co);
|
|
|
|
|
opp2= AreaT3Dfl(v1->co, v3->co, v4->co);
|
|
|
|
|
|
|
|
|
|
fac1= opp1/(len1+len2+len5) + opp2/(len3+len4+len5);
|
|
|
|
|
|
|
|
|
|
opp1= AreaT3Dfl(v2->co, v3->co, v4->co);
|
|
|
|
|
opp2= AreaT3Dfl(v2->co, v4->co, v1->co);
|
|
|
|
|
|
|
|
|
|
fac2= opp1/(len2+len3+len6) + opp2/(len4+len1+len6);
|
|
|
|
|
|
|
|
|
|
ok= 0;
|
|
|
|
|
if(fac1 > fac2) {
|
|
|
|
|
if(dia2.v1==eed->v1 && dia2.v2==eed->v2) {
|
|
|
|
|
eed->f1= 1;
|
|
|
|
|
efa= efaa[0];
|
|
|
|
|
efa->f1= 1;
|
|
|
|
|
efa= efaa[1];
|
|
|
|
|
efa->f1= 1;
|
|
|
|
|
|
|
|
|
|
w= addfacelist(v1, v2, v3, 0, efa, NULL);
|
2005-08-07 21:23:55 +00:00
|
|
|
w->f |= SELECT;
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
UVCOPY(w->tf.uv[0], uv[0]);
|
|
|
|
|
UVCOPY(w->tf.uv[1], uv[1]);
|
|
|
|
|
UVCOPY(w->tf.uv[2], uv[2]);
|
|
|
|
|
|
|
|
|
|
w->tf.col[0] = col[0]; w->tf.col[1] = col[1]; w->tf.col[2] = col[2];
|
|
|
|
|
w= addfacelist(v1, v3, v4, 0, efa, NULL);
|
2005-08-07 21:23:55 +00:00
|
|
|
w->f |= SELECT;
|
2005-07-13 15:20:40 +00:00
|
|
|
|
|
|
|
|
UVCOPY(w->tf.uv[0], uv[0]);
|
|
|
|
|
UVCOPY(w->tf.uv[1], uv[2]);
|
|
|
|
|
UVCOPY(w->tf.uv[2], uv[3]);
|
|
|
|
|
|
|
|
|
|
w->tf.col[0] = col[0]; w->tf.col[1] = col[2]; w->tf.col[2] = col[3];
|
|
|
|
|
|
|
|
|
|
onedone= 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(fac1 < fac2) {
|
|
|
|
|
if(dia1.v1==eed->v1 && dia1.v2==eed->v2) {
|
|
|
|
|
eed->f1= 1;
|
|
|
|
|
efa= efaa[0];
|
|
|
|
|
efa->f1= 1;
|
|
|
|
|
efa= efaa[1];
|
|
|
|
|
efa->f1= 1;
|
|
|
|
|
|
|
|
|
|
w= addfacelist(v2, v3, v4, 0, efa, NULL);
|
2005-08-07 21:23:55 +00:00
|
|
|
w->f |= SELECT;
|
2005-07-13 15:20:40 +00:00
|
|
|
|
|
|
|
|
UVCOPY(w->tf.uv[0], uv[1]);
|
|
|
|
|
UVCOPY(w->tf.uv[1], uv[3]);
|
|
|
|
|
UVCOPY(w->tf.uv[2], uv[4]);
|
|
|
|
|
|
|
|
|
|
w= addfacelist(v1, v2, v4, 0, efa, NULL);
|
2005-08-07 21:23:55 +00:00
|
|
|
w->f |= SELECT;
|
2005-07-13 15:20:40 +00:00
|
|
|
|
|
|
|
|
UVCOPY(w->tf.uv[0], uv[0]);
|
|
|
|
|
UVCOPY(w->tf.uv[1], uv[1]);
|
|
|
|
|
UVCOPY(w->tf.uv[2], uv[3]);
|
|
|
|
|
|
|
|
|
|
onedone= 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
|
|
|
|
eed= nexted;
|
|
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
free_tagged_edgelist(em->edges.first);
|
|
|
|
|
free_tagged_facelist(em->faces.first);
|
2005-07-13 15:20:40 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
if(onedone==0) break;
|
2005-07-13 15:20:40 +00:00
|
|
|
|
2005-08-07 21:23:55 +00:00
|
|
|
EM_selectmode_set(); // new edges/faces were added
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
MEM_freeN(efaar);
|
2005-07-13 15:20:40 +00:00
|
|
|
|
|
|
|
|
EM_select_flush();
|
|
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
2005-07-13 15:20:40 +00:00
|
|
|
BIF_undo_push("Beauty Fill");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ******************** FLIP EDGE ************************************* */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define FACE_MARKCLEAR(f) (f->f1 = 1)
|
|
|
|
|
|
|
|
|
|
void join_triangles(void)
|
|
|
|
|
{
|
|
|
|
|
EditMesh *em = G.editMesh;
|
|
|
|
|
EditVert *v1, *v2, *v3, *v4;
|
|
|
|
|
EditFace *efa, *w;
|
|
|
|
|
EVPTuple *efaar;
|
|
|
|
|
EVPtr *efaa;
|
|
|
|
|
EditEdge *eed, *nexted;
|
|
|
|
|
int totedge, ok;
|
|
|
|
|
float *uv[4];
|
|
|
|
|
unsigned int col[4];
|
|
|
|
|
|
|
|
|
|
EM_selectmode_flush(); // makes sure in selectmode 'face' the edges of selected faces are selected too
|
|
|
|
|
|
|
|
|
|
totedge = count_selected_edges(em->edges.first);
|
|
|
|
|
if(totedge==0) return;
|
|
|
|
|
|
|
|
|
|
efaar= (EVPTuple *) MEM_callocN(totedge * sizeof(EVPTuple), "jointris");
|
|
|
|
|
|
|
|
|
|
ok = collect_quadedges(efaar, em->edges.first, em->faces.first);
|
|
|
|
|
if (G.f & G_DEBUG) {
|
|
|
|
|
printf("Edges selected: %d\n", ok);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eed= em->edges.first;
|
|
|
|
|
while(eed) {
|
|
|
|
|
nexted= eed->next;
|
|
|
|
|
|
|
|
|
|
if(eed->f2==2) { /* points to 2 faces */
|
|
|
|
|
|
|
|
|
|
efaa= (EVPtr *) eed->vn;
|
|
|
|
|
|
|
|
|
|
/* don't do it if flagged */
|
|
|
|
|
|
|
|
|
|
ok= 1;
|
|
|
|
|
efa= efaa[0];
|
|
|
|
|
if(efa->e1->f1 || efa->e2->f1 || efa->e3->f1) ok= 0;
|
|
|
|
|
efa= efaa[1];
|
|
|
|
|
if(efa->e1->f1 || efa->e2->f1 || efa->e3->f1) ok= 0;
|
|
|
|
|
|
|
|
|
|
if(ok) {
|
|
|
|
|
/* test convex */
|
|
|
|
|
givequadverts(efaa[0], efaa[1], &v1, &v2, &v3, &v4, uv, col);
|
|
|
|
|
|
|
|
|
|
/*
|
2005-08-07 21:47:08 +00:00
|
|
|
4-----3 4-----3
|
|
|
|
|
|\ | | |
|
|
|
|
|
| \ 1 | | |
|
|
|
|
|
| \ | -> | |
|
|
|
|
|
| 0 \ | | |
|
|
|
|
|
| \| | |
|
|
|
|
|
1-----2 1-----2
|
2005-07-13 15:20:40 +00:00
|
|
|
*/
|
|
|
|
|
/* make new faces */
|
|
|
|
|
if(v1 && v2 && v3 && v4) {
|
|
|
|
|
if( convex(v1->co, v2->co, v3->co, v4->co) ) {
|
|
|
|
|
if(exist_face(v1, v2, v3, v4)==0) {
|
|
|
|
|
w = addfacelist(v1, v2, v3, v4, efaa[0], NULL); /* seam edge may get broken */
|
|
|
|
|
w->f= efaa[0]->f; /* copy selection flag */
|
|
|
|
|
untag_edges(w);
|
|
|
|
|
|
|
|
|
|
UVCOPY(w->tf.uv[0], uv[0]);
|
|
|
|
|
UVCOPY(w->tf.uv[1], uv[1]);
|
|
|
|
|
UVCOPY(w->tf.uv[2], uv[2]);
|
|
|
|
|
UVCOPY(w->tf.uv[3], uv[3]);
|
|
|
|
|
|
|
|
|
|
memcpy(w->tf.col, col, sizeof(w->tf.col));
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
/* tag as to-be-removed */
|
|
|
|
|
FACE_MARKCLEAR(efaa[0]);
|
|
|
|
|
FACE_MARKCLEAR(efaa[1]);
|
|
|
|
|
eed->f1 = 1;
|
|
|
|
|
} /* endif test convex */
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
eed= nexted;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
free_tagged_edgelist(em->edges.first);
|
|
|
|
|
free_tagged_facelist(em->faces.first);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
MEM_freeN(efaar);
|
|
|
|
|
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
|
|
|
|
BIF_undo_push("Convert Triangles to Quads");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* quick hack, basically a copy of beauty_fill */
|
|
|
|
|
void edge_flip(void)
|
|
|
|
|
{
|
|
|
|
|
EditMesh *em = G.editMesh;
|
|
|
|
|
EditVert *v1, *v2, *v3, *v4;
|
|
|
|
|
EditEdge *eed, *nexted;
|
|
|
|
|
EditFace *efa, *w;
|
|
|
|
|
//void **efaar, **efaa;
|
|
|
|
|
EVPTuple *efaar;
|
|
|
|
|
EVPtr *efaa;
|
|
|
|
|
|
|
|
|
|
float *uv[4];
|
|
|
|
|
unsigned int col[4];
|
|
|
|
|
|
|
|
|
|
int totedge, ok;
|
|
|
|
|
|
|
|
|
|
/* - all selected edges with two faces
|
|
|
|
|
* - find the faces: store them in edges (using datablock)
|
|
|
|
|
* - per edge: - test convex
|
|
|
|
|
* - test edge: flip?
|
|
|
|
|
- if true: remedge, addedge, all edges at the edge get new face pointers
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
EM_selectmode_flush(); // makes sure in selectmode 'face' the edges of selected faces are selected too
|
|
|
|
|
|
|
|
|
|
totedge = count_selected_edges(em->edges.first);
|
|
|
|
|
if(totedge==0) return;
|
|
|
|
|
|
|
|
|
|
/* temporary array for : edge -> face[1], face[2] */
|
|
|
|
|
efaar= (EVPTuple *) MEM_callocN(totedge * sizeof(EVPTuple), "edgeflip");
|
|
|
|
|
|
|
|
|
|
ok = collect_quadedges(efaar, em->edges.first, em->faces.first);
|
|
|
|
|
|
|
|
|
|
eed= em->edges.first;
|
|
|
|
|
while(eed) {
|
|
|
|
|
nexted= eed->next;
|
|
|
|
|
|
|
|
|
|
if(eed->f2==2) { /* points to 2 faces */
|
|
|
|
|
|
|
|
|
|
efaa= (EVPtr *) eed->vn;
|
|
|
|
|
|
|
|
|
|
/* don't do it if flagged */
|
|
|
|
|
|
|
|
|
|
ok= 1;
|
|
|
|
|
efa= efaa[0];
|
|
|
|
|
if(efa->e1->f1 || efa->e2->f1 || efa->e3->f1) ok= 0;
|
|
|
|
|
efa= efaa[1];
|
|
|
|
|
if(efa->e1->f1 || efa->e2->f1 || efa->e3->f1) ok= 0;
|
|
|
|
|
|
|
|
|
|
if(ok) {
|
|
|
|
|
/* test convex */
|
|
|
|
|
givequadverts(efaa[0], efaa[1], &v1, &v2, &v3, &v4, uv, col);
|
|
|
|
|
|
|
|
|
|
/*
|
2005-08-07 21:47:08 +00:00
|
|
|
4-----3 4-----3
|
|
|
|
|
|\ | | /|
|
|
|
|
|
| \ 1 | | 1 / |
|
|
|
|
|
| \ | -> | / |
|
|
|
|
|
| 0 \ | | / 0 |
|
|
|
|
|
| \| |/ |
|
|
|
|
|
1-----2 1-----2
|
2005-07-13 15:20:40 +00:00
|
|
|
*/
|
|
|
|
|
/* make new faces */
|
|
|
|
|
if (v1 && v2 && v3){
|
|
|
|
|
if( convex(v1->co, v2->co, v3->co, v4->co) ) {
|
|
|
|
|
if(exist_face(v1, v2, v3, v4)==0) {
|
|
|
|
|
w = addfacelist(v1, v2, v3, 0, efaa[1], NULL); /* outch this may break seams */
|
|
|
|
|
EM_select_face(w, 1);
|
|
|
|
|
untag_edges(w);
|
|
|
|
|
|
|
|
|
|
UVCOPY(w->tf.uv[0], uv[0]);
|
|
|
|
|
UVCOPY(w->tf.uv[1], uv[1]);
|
|
|
|
|
UVCOPY(w->tf.uv[2], uv[2]);
|
|
|
|
|
|
|
|
|
|
w->tf.col[0] = col[0]; w->tf.col[1] = col[1]; w->tf.col[2] = col[2];
|
|
|
|
|
|
|
|
|
|
w = addfacelist(v1, v3, v4, 0, efaa[1], NULL); /* outch this may break seams */
|
|
|
|
|
EM_select_face(w, 1);
|
|
|
|
|
untag_edges(w);
|
|
|
|
|
|
|
|
|
|
UVCOPY(w->tf.uv[0], uv[0]);
|
|
|
|
|
UVCOPY(w->tf.uv[1], uv[2]);
|
|
|
|
|
UVCOPY(w->tf.uv[2], uv[3]);
|
|
|
|
|
|
|
|
|
|
w->tf.col[0] = col[0]; w->tf.col[1] = col[2]; w->tf.col[2] = col[3];
|
|
|
|
|
|
|
|
|
|
/* erase old faces and edge */
|
|
|
|
|
}
|
|
|
|
|
/* tag as to-be-removed */
|
|
|
|
|
FACE_MARKCLEAR(efaa[1]);
|
|
|
|
|
FACE_MARKCLEAR(efaa[0]);
|
|
|
|
|
eed->f1 = 1;
|
|
|
|
|
|
|
|
|
|
} /* endif test convex */
|
|
|
|
|
}
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
eed= nexted;
|
|
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
|
|
|
|
|
/* clear tagged edges and faces: */
|
|
|
|
|
free_tagged_edgelist(em->edges.first);
|
|
|
|
|
free_tagged_facelist(em->faces.first);
|
|
|
|
|
|
|
|
|
|
MEM_freeN(efaar);
|
|
|
|
|
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
|
|
|
|
BIF_undo_push("Flip Triangle Edges");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void edge_rotate(EditEdge *eed,int dir)
|
|
|
|
|
{
|
|
|
|
|
EditMesh *em = G.editMesh;
|
|
|
|
|
EditFace *face[2], *efa, *newFace[2];
|
|
|
|
|
EditVert *faces[2][4],*v1,*v2,*v3,*v4,*vtemp;
|
|
|
|
|
EditEdge *srchedge = NULL;
|
|
|
|
|
short facecount=0, p1=0,p2=0,p3=0,p4=0,fac1=4,fac2=4,i,j,numhidden;
|
2005-08-07 21:47:08 +00:00
|
|
|
EditEdge **hiddenedges;
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* check to make sure that the edge is only part of 2 faces */
|
|
|
|
|
for(efa = em->faces.first;efa;efa = efa->next){
|
|
|
|
|
if((efa->e1 == eed || efa->e2 == eed) || (efa->e3 == eed || efa->e4 == eed)){
|
|
|
|
|
if(facecount == 2){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(facecount < 2)
|
|
|
|
|
face[facecount] = efa;
|
|
|
|
|
facecount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(facecount < 2){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* how many edges does each face have */
|
|
|
|
|
if(face[0]->e4 == NULL)
|
|
|
|
|
fac1=3;
|
|
|
|
|
else
|
|
|
|
|
fac1=4;
|
|
|
|
|
if(face[1]->e4 == NULL)
|
|
|
|
|
fac2=3;
|
|
|
|
|
else
|
|
|
|
|
fac2=4;
|
|
|
|
|
|
|
|
|
|
/*store the face info in a handy array */
|
|
|
|
|
faces[0][0] = face[0]->v1;
|
|
|
|
|
faces[0][1] = face[0]->v2;
|
|
|
|
|
faces[0][2] = face[0]->v3;
|
|
|
|
|
if(face[0]->e4 != NULL)
|
|
|
|
|
faces[0][3] = face[0]->v4;
|
|
|
|
|
else
|
|
|
|
|
faces[0][3] = NULL;
|
|
|
|
|
|
|
|
|
|
faces[1][0] = face[1]->v1;
|
|
|
|
|
faces[1][1] = face[1]->v2;
|
|
|
|
|
faces[1][2] = face[1]->v3;
|
|
|
|
|
if(face[1]->e4 != NULL)
|
|
|
|
|
faces[1][3] = face[1]->v4;
|
|
|
|
|
else
|
|
|
|
|
faces[1][3] = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* we don't want to rotate edges between faces that share more than one edge */
|
|
|
|
|
|
|
|
|
|
j=0;
|
|
|
|
|
if(face[0]->e1 == face[1]->e1 ||
|
|
|
|
|
face[0]->e1 == face[1]->e2 ||
|
|
|
|
|
face[0]->e1 == face[1]->e3 ||
|
|
|
|
|
((face[1]->e4) && face[0]->e1 == face[1]->e4) )
|
|
|
|
|
j++;
|
|
|
|
|
|
|
|
|
|
if(face[0]->e2 == face[1]->e1 ||
|
|
|
|
|
face[0]->e2 == face[1]->e2 ||
|
|
|
|
|
face[0]->e2 == face[1]->e3 ||
|
|
|
|
|
((face[1]->e4) && face[0]->e2 == face[1]->e4) )
|
|
|
|
|
j++;
|
|
|
|
|
|
|
|
|
|
if(face[0]->e3 == face[1]->e1 ||
|
|
|
|
|
face[0]->e3 == face[1]->e2 ||
|
|
|
|
|
face[0]->e3 == face[1]->e3 ||
|
|
|
|
|
((face[1]->e4) && face[0]->e3 == face[1]->e4) )
|
|
|
|
|
j++;
|
|
|
|
|
|
|
|
|
|
if(face[0]->e4){
|
|
|
|
|
if(face[0]->e4 == face[1]->e1 ||
|
|
|
|
|
face[0]->e4 == face[1]->e2 ||
|
|
|
|
|
face[0]->e4 == face[1]->e3 ||
|
|
|
|
|
((face[1]->e4) && face[0]->e4 == face[1]->e4) )
|
|
|
|
|
j++;
|
|
|
|
|
}
|
|
|
|
|
if(j > 1){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Coplaner Faces Only Please */
|
|
|
|
|
if(Inpf(face[0]->n,face[1]->n) <= 0.000001){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*get the edges verts */
|
|
|
|
|
v1 = eed->v1;
|
|
|
|
|
v2 = eed->v2;
|
|
|
|
|
v3 = eed->v1;
|
|
|
|
|
v4 = eed->v2;
|
|
|
|
|
|
|
|
|
|
/*figure out where the edges verts lie one the 2 faces */
|
|
|
|
|
for(i=0;i<4;i++){
|
|
|
|
|
if(v1 == faces[0][i])
|
|
|
|
|
p1 = i;
|
|
|
|
|
if(v2 == faces[0][i])
|
|
|
|
|
p2 = i;
|
|
|
|
|
if(v1 == faces[1][i])
|
|
|
|
|
p3 = i;
|
|
|
|
|
if(v2 == faces[1][i])
|
|
|
|
|
p4 = i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*make sure the verts are in the correct order */
|
|
|
|
|
if((p1+1)%fac1 == p2){
|
|
|
|
|
vtemp = v2;
|
|
|
|
|
v2 = v1;
|
|
|
|
|
v1 = vtemp;
|
|
|
|
|
|
|
|
|
|
i = p1;
|
|
|
|
|
p1 = p2;
|
|
|
|
|
p2 = i;
|
|
|
|
|
}
|
|
|
|
|
if((p3+1)%fac2 == p4){
|
|
|
|
|
vtemp = v4;
|
|
|
|
|
v4 = v3;
|
|
|
|
|
v3 = vtemp;
|
|
|
|
|
|
|
|
|
|
i = p3;
|
|
|
|
|
p3 = p4;
|
|
|
|
|
p4 = i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
/* Create an Array of the Edges who have h set prior to rotate */
|
|
|
|
|
numhidden = 0;
|
|
|
|
|
for(srchedge = em->edges.first;srchedge;srchedge = srchedge->next){
|
2005-08-09 14:44:46 +00:00
|
|
|
if(srchedge->h && (srchedge->v1->f & SELECT || srchedge->v2->f & SELECT)){
|
2005-08-07 21:47:08 +00:00
|
|
|
numhidden++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-08-09 14:44:46 +00:00
|
|
|
hiddenedges = MEM_mallocN(sizeof(EditVert*)*numhidden+1,"Hidden Vert Scratch Array for Rotate Edges");
|
|
|
|
|
if(!hiddenedges){
|
|
|
|
|
error("Malloc Was not happy!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
numhidden = 0;
|
2005-08-07 21:47:08 +00:00
|
|
|
for(srchedge = em->edges.first;srchedge;srchedge = srchedge->next){
|
2005-08-09 14:44:46 +00:00
|
|
|
if(srchedge->h && (srchedge->v1->f & SELECT || srchedge->v2->f & SELECT)){
|
2005-08-07 21:47:08 +00:00
|
|
|
hiddenedges[numhidden] = srchedge;
|
|
|
|
|
numhidden++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* create the 2 new faces */
|
|
|
|
|
if(fac1 == 3 && fac2 == 3){
|
|
|
|
|
/*No need of reverse setup*/
|
|
|
|
|
newFace[0] = addfacelist(faces[0][(p1+1 )%3],faces[0][(p1+2 )%3],faces[1][(p3+1 )%3],NULL,NULL,NULL);
|
|
|
|
|
newFace[1] = addfacelist(faces[1][(p3+1 )%3],faces[1][(p3+2 )%3],faces[0][(p1+1 )%3],NULL,NULL,NULL);
|
|
|
|
|
|
|
|
|
|
newFace[0]->tf.col[0] = face[0]->tf.col[(p1+1 )%3];
|
|
|
|
|
newFace[0]->tf.col[1] = face[0]->tf.col[(p1+2 )%3];
|
|
|
|
|
newFace[0]->tf.col[2] = face[1]->tf.col[(p3+1 )%3];
|
|
|
|
|
newFace[1]->tf.col[0] = face[1]->tf.col[(p3+1 )%3];
|
|
|
|
|
newFace[1]->tf.col[1] = face[1]->tf.col[(p3+2 )%3];
|
|
|
|
|
newFace[1]->tf.col[2] = face[0]->tf.col[(p1+1 )%3];
|
|
|
|
|
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[0],face[0]->tf.uv[(p1+1 )%3]);
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[1],face[0]->tf.uv[(p1+2 )%3]);
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[2],face[1]->tf.uv[(p3+1 )%3]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[0],face[1]->tf.uv[(p3+1 )%3]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[1],face[1]->tf.uv[(p3+2 )%3]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[2],face[0]->tf.uv[(p1+1 )%3]);
|
|
|
|
|
}
|
|
|
|
|
else if(fac1 == 4 && fac2 == 3){
|
|
|
|
|
if(dir == 1){
|
|
|
|
|
newFace[0] = addfacelist(faces[0][(p1+1 )%4],faces[0][(p1+2 )%4],faces[0][(p1+3 )%4],faces[1][(p3+1 )%3],NULL,NULL);
|
|
|
|
|
newFace[1] = addfacelist(faces[1][(p3+1 )%3],faces[1][(p3+2 )%3],faces[0][(p1+1 )%4],NULL,NULL,NULL);
|
|
|
|
|
|
|
|
|
|
newFace[0]->tf.col[0] = face[0]->tf.col[(p1+1 )%4];
|
|
|
|
|
newFace[0]->tf.col[1] = face[0]->tf.col[(p1+2 )%4];
|
|
|
|
|
newFace[0]->tf.col[2] = face[0]->tf.col[(p1+3 )%4];
|
|
|
|
|
newFace[0]->tf.col[3] = face[1]->tf.col[(p3+1 )%3];
|
|
|
|
|
newFace[1]->tf.col[0] = face[1]->tf.col[(p3+1 )%3];
|
|
|
|
|
newFace[1]->tf.col[1] = face[1]->tf.col[(p3+2 )%3];
|
|
|
|
|
newFace[1]->tf.col[2] = face[0]->tf.col[(p1+1 )%4];
|
|
|
|
|
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[0],face[0]->tf.uv[(p1+1 )%4]);
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[1],face[0]->tf.uv[(p1+2 )%4]);
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[2],face[0]->tf.uv[(p1+3 )%4]);
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[3],face[1]->tf.uv[(p3+1 )%3]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[0],face[1]->tf.uv[(p3+1 )%3]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[1],face[1]->tf.uv[(p3+2 )%3]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[2],face[0]->tf.uv[(p1+1 )%4]);
|
|
|
|
|
} else if (dir == 2){
|
|
|
|
|
newFace[0] = addfacelist(faces[0][(p1+2 )%4],faces[1][(p3+1)%3],faces[0][(p1)%4],faces[0][(p1+1 )%4],NULL,NULL);
|
|
|
|
|
newFace[1] = addfacelist(faces[0][(p1+2 )%4],faces[1][(p3)%3],faces[1][(p3+1 )%3],NULL,NULL,NULL);
|
|
|
|
|
|
|
|
|
|
newFace[0]->tf.col[0] = face[0]->tf.col[(p1+2)%4];
|
|
|
|
|
newFace[0]->tf.col[1] = face[1]->tf.col[(p3+1)%3];
|
|
|
|
|
newFace[0]->tf.col[2] = face[0]->tf.col[(p1 )%4];
|
|
|
|
|
newFace[0]->tf.col[3] = face[0]->tf.col[(p1+1)%4];
|
|
|
|
|
newFace[1]->tf.col[0] = face[0]->tf.col[(p1+2)%4];
|
|
|
|
|
newFace[1]->tf.col[1] = face[1]->tf.col[(p3 )%3];
|
|
|
|
|
newFace[1]->tf.col[2] = face[1]->tf.col[(p3+1)%3];
|
|
|
|
|
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[0],face[0]->tf.uv[(p1+2)%4]);
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[1],face[1]->tf.uv[(p3+1)%3]);
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[2],face[0]->tf.uv[(p1 )%4]);
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[3],face[0]->tf.uv[(p1+1)%4]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[0],face[0]->tf.uv[(p1+2)%4]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[1],face[1]->tf.uv[(p3 )%3]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[2],face[1]->tf.uv[(p3+1)%3]);
|
|
|
|
|
|
|
|
|
|
faces[0][(p1+2)%fac1]->f |= SELECT;
|
|
|
|
|
faces[1][(p3+1)%fac2]->f |= SELECT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if(fac1 == 3 && fac2 == 4){
|
|
|
|
|
if(dir == 1){
|
|
|
|
|
newFace[0] = addfacelist(faces[0][(p1+1 )%3],faces[0][(p1+2 )%3],faces[1][(p3+1 )%4],NULL,NULL,NULL);
|
|
|
|
|
newFace[1] = addfacelist(faces[1][(p3+1 )%4],faces[1][(p3+2 )%4],faces[1][(p3+3 )%4],faces[0][(p1+1 )%3],NULL,NULL);
|
|
|
|
|
|
|
|
|
|
newFace[0]->tf.col[0] = face[0]->tf.col[(p1+1 )%3];
|
|
|
|
|
newFace[0]->tf.col[1] = face[0]->tf.col[(p1+2 )%3];
|
|
|
|
|
newFace[0]->tf.col[2] = face[1]->tf.col[(p3+1 )%4];
|
|
|
|
|
newFace[1]->tf.col[0] = face[1]->tf.col[(p3+1 )%4];
|
|
|
|
|
newFace[1]->tf.col[1] = face[1]->tf.col[(p3+2 )%4];
|
|
|
|
|
newFace[1]->tf.col[2] = face[1]->tf.col[(p3+3 )%4];
|
|
|
|
|
newFace[1]->tf.col[3] = face[0]->tf.col[(p1+1 )%3];
|
|
|
|
|
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[0],face[0]->tf.uv[(p1+1 )%3]);
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[1],face[0]->tf.uv[(p1+2 )%3]);
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[2],face[1]->tf.uv[(p3+1 )%4]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[0],face[1]->tf.uv[(p3+1 )%4]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[1],face[1]->tf.uv[(p3+2 )%4]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[2],face[1]->tf.uv[(p3+3 )%4]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[3],face[0]->tf.uv[(p1+1 )%3]);
|
|
|
|
|
} else if (dir == 2){
|
|
|
|
|
newFace[0] = addfacelist(faces[0][(p1)%3],faces[0][(p1+1 )%3],faces[1][(p3+2 )%4],NULL,NULL,NULL);
|
|
|
|
|
newFace[1] = addfacelist(faces[1][(p3+1 )%4],faces[1][(p3+2 )%4],faces[0][(p1+1 )%3],faces[0][(p1+2 )%3],NULL,NULL);
|
|
|
|
|
|
|
|
|
|
newFace[0]->tf.col[0] = face[0]->tf.col[(p1 )%3];
|
|
|
|
|
newFace[0]->tf.col[1] = face[0]->tf.col[(p1+1 )%3];
|
|
|
|
|
newFace[0]->tf.col[2] = face[1]->tf.col[(p3+2 )%4];
|
|
|
|
|
newFace[1]->tf.col[0] = face[1]->tf.col[(p3+1 )%4];
|
|
|
|
|
newFace[1]->tf.col[1] = face[1]->tf.col[(p3+2 )%4];
|
|
|
|
|
newFace[1]->tf.col[2] = face[0]->tf.col[(p1+1 )%3];
|
|
|
|
|
newFace[1]->tf.col[3] = face[0]->tf.col[(p1+2 )%3];
|
|
|
|
|
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[0],face[0]->tf.uv[(p1 )%3]);
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[1],face[0]->tf.uv[(p1+1 )%3]);
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[2],face[1]->tf.uv[(p3+2 )%4]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[0],face[1]->tf.uv[(p3+1 )%4]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[1],face[1]->tf.uv[(p3+2 )%4]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[2],face[0]->tf.uv[(p1+1 )%3]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[3],face[0]->tf.uv[(p1+2 )%3]);
|
|
|
|
|
|
|
|
|
|
faces[0][(p1+1)%fac1]->f |= SELECT;
|
|
|
|
|
faces[1][(p3+2)%fac2]->f |= SELECT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if(fac1 == 4 && fac2 == 4){
|
|
|
|
|
if(dir == 1){
|
2005-08-07 21:47:08 +00:00
|
|
|
newFace[0] = addfacelist(faces[0][(p1+1 )%4],faces[0][(p1+2 )%4],faces[0][(p1+3 )%4],faces[1][(p3+1 )%4],NULL,NULL);
|
|
|
|
|
newFace[1] = addfacelist(faces[1][(p3+1 )%4],faces[1][(p3+2 )%4],faces[1][(p3+3 )%4],faces[0][(p1+1 )%4],NULL,NULL);
|
2005-07-13 15:20:40 +00:00
|
|
|
|
|
|
|
|
newFace[0]->tf.col[0] = face[0]->tf.col[(p1+1 )%4];
|
|
|
|
|
newFace[0]->tf.col[1] = face[0]->tf.col[(p1+2 )%4];
|
|
|
|
|
newFace[0]->tf.col[2] = face[0]->tf.col[(p1+3 )%4];
|
|
|
|
|
newFace[0]->tf.col[3] = face[1]->tf.col[(p3+1 )%4];
|
|
|
|
|
newFace[1]->tf.col[0] = face[1]->tf.col[(p3+1 )%4];
|
|
|
|
|
newFace[1]->tf.col[1] = face[1]->tf.col[(p3+2 )%4];
|
|
|
|
|
newFace[1]->tf.col[2] = face[1]->tf.col[(p3+3 )%4];
|
|
|
|
|
newFace[1]->tf.col[3] = face[0]->tf.col[(p1+1 )%4];
|
|
|
|
|
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[0],face[0]->tf.uv[(p1+1 )%4]);
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[1],face[0]->tf.uv[(p1+2 )%4]);
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[2],face[0]->tf.uv[(p1+3 )%4]);
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[3],face[1]->tf.uv[(p3+1 )%4]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[0],face[1]->tf.uv[(p3+1 )%4]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[1],face[1]->tf.uv[(p3+2 )%4]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[2],face[1]->tf.uv[(p3+3 )%4]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[3],face[0]->tf.uv[(p1+1 )%4]);
|
|
|
|
|
} else if (dir == 2){
|
|
|
|
|
newFace[0] = addfacelist(faces[0][(p1+2 )%4],faces[0][(p1+3 )%4],faces[1][(p3+1 )%4],faces[1][(p3+2 )%4],NULL,NULL);
|
|
|
|
|
newFace[1] = addfacelist(faces[1][(p3+2 )%4],faces[1][(p3+3 )%4],faces[0][(p1+1 )%4],faces[0][(p1+2 )%4],NULL,NULL);
|
|
|
|
|
|
|
|
|
|
newFace[0]->tf.col[0] = face[0]->tf.col[(p1+2 )%4];
|
|
|
|
|
newFace[0]->tf.col[1] = face[0]->tf.col[(p1+3 )%4];
|
|
|
|
|
newFace[0]->tf.col[2] = face[1]->tf.col[(p3+1 )%4];
|
|
|
|
|
newFace[0]->tf.col[3] = face[1]->tf.col[(p3+2 )%4];
|
|
|
|
|
newFace[1]->tf.col[0] = face[1]->tf.col[(p3+2 )%4];
|
|
|
|
|
newFace[1]->tf.col[1] = face[1]->tf.col[(p3+3 )%4];
|
|
|
|
|
newFace[1]->tf.col[2] = face[0]->tf.col[(p1+1 )%4];
|
|
|
|
|
newFace[1]->tf.col[3] = face[0]->tf.col[(p1+2 )%4];
|
|
|
|
|
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[0],face[0]->tf.uv[(p1+2 )%4]);
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[1],face[0]->tf.uv[(p1+3 )%4]);
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[2],face[1]->tf.uv[(p3+1 )%4]);
|
|
|
|
|
UVCOPY(newFace[0]->tf.uv[3],face[1]->tf.uv[(p3+2 )%4]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[0],face[1]->tf.uv[(p3+2 )%4]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[1],face[1]->tf.uv[(p3+3 )%4]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[2],face[0]->tf.uv[(p1+1 )%4]);
|
|
|
|
|
UVCOPY(newFace[1]->tf.uv[3],face[0]->tf.uv[(p1+2 )%4]);
|
|
|
|
|
|
|
|
|
|
faces[0][(p1+2)%fac1]->f |= SELECT;
|
|
|
|
|
faces[1][(p3+2)%fac2]->f |= SELECT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
/*This should never happen*/
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(dir == 1){
|
|
|
|
|
faces[0][(p1+1)%fac1]->f |= SELECT;
|
|
|
|
|
faces[1][(p3+1)%fac2]->f |= SELECT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*Copy old edge's flags to new center edge*/
|
|
|
|
|
for(srchedge=em->edges.first;srchedge;srchedge=srchedge->next){
|
|
|
|
|
if(srchedge->v1->f & SELECT &&srchedge->v2->f & SELECT ){
|
|
|
|
|
srchedge->f = eed->f;
|
|
|
|
|
srchedge->h = eed->h;
|
|
|
|
|
srchedge->dir = eed->dir;
|
|
|
|
|
srchedge->seam = eed->seam;
|
|
|
|
|
srchedge->crease = eed->crease;
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* copy flags and material */
|
|
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
newFace[0]->mat_nr = face[0]->mat_nr;
|
|
|
|
|
newFace[0]->tf.flag = face[0]->tf.flag;
|
2005-07-13 15:20:40 +00:00
|
|
|
newFace[0]->tf.transp = face[0]->tf.transp;
|
2005-08-07 21:47:08 +00:00
|
|
|
newFace[0]->tf.mode = face[0]->tf.mode;
|
|
|
|
|
newFace[0]->tf.tile = face[0]->tf.tile;
|
2005-07-13 15:20:40 +00:00
|
|
|
newFace[0]->tf.unwrap = face[0]->tf.unwrap;
|
|
|
|
|
newFace[0]->tf.tpage = face[0]->tf.tpage;
|
2005-08-07 21:47:08 +00:00
|
|
|
newFace[0]->flag = face[0]->flag;
|
2005-07-13 15:20:40 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
newFace[1]->mat_nr = face[1]->mat_nr;
|
|
|
|
|
newFace[1]->tf.flag = face[1]->tf.flag;
|
2005-07-13 15:20:40 +00:00
|
|
|
newFace[1]->tf.transp = face[1]->tf.transp;
|
2005-08-07 21:47:08 +00:00
|
|
|
newFace[1]->tf.mode = face[1]->tf.mode;
|
|
|
|
|
newFace[1]->tf.tile = face[1]->tf.tile;
|
2005-07-13 15:20:40 +00:00
|
|
|
newFace[1]->tf.unwrap = face[1]->tf.unwrap;
|
|
|
|
|
newFace[1]->tf.tpage = face[1]->tf.tpage;
|
2005-08-07 21:47:08 +00:00
|
|
|
newFace[1]->flag = face[1]->flag;
|
2005-07-13 15:20:40 +00:00
|
|
|
|
|
|
|
|
/* Resetting Hidden Flag */
|
|
|
|
|
for(numhidden--;numhidden>=0;numhidden--){
|
2005-08-07 21:47:08 +00:00
|
|
|
hiddenedges[numhidden]->h = 1;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* check for orhphan edges */
|
|
|
|
|
for(srchedge=em->edges.first;srchedge;srchedge = srchedge->next){
|
|
|
|
|
srchedge->f1 = -1;
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/*for(efa = em->faces.first;efa;efa = efa->next){
|
|
|
|
|
if(efa->h == 0){
|
2005-08-07 21:47:08 +00:00
|
|
|
efa->e1->f1 = 1;
|
|
|
|
|
efa->e2->f1 = 1;
|
|
|
|
|
efa->e3->f1 = 1;
|
|
|
|
|
if(efa->e4){
|
|
|
|
|
efa->e4->f1 = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
if(efa->h == 1){
|
2005-08-07 21:47:08 +00:00
|
|
|
if(efa->e1->f1 == -1){
|
|
|
|
|
efa->e1->f1 = 0;
|
|
|
|
|
}
|
|
|
|
|
if(efa->e2->f1 == -1){
|
|
|
|
|
efa->e2->f1 = 0;
|
|
|
|
|
}
|
|
|
|
|
if(efa->e1->f1 == -1){
|
|
|
|
|
efa->e1->f1 = 0;
|
|
|
|
|
}
|
|
|
|
|
if(efa->e4){
|
|
|
|
|
efa->e4->f1 = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
}
|
|
|
|
|
A Little Cleanup */
|
|
|
|
|
MEM_freeN(hiddenedges);
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* get rid of the old edge and faces*/
|
|
|
|
|
remedge(eed);
|
|
|
|
|
free_editedge(eed);
|
|
|
|
|
BLI_remlink(&em->faces, face[0]);
|
|
|
|
|
free_editface(face[0]);
|
|
|
|
|
BLI_remlink(&em->faces, face[1]);
|
|
|
|
|
free_editface(face[1]);
|
|
|
|
|
return;
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* only accepts 1 selected edge, or 2 selected faces */
|
|
|
|
|
void edge_rotate_selected(int dir)
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
{
|
2005-07-13 15:20:40 +00:00
|
|
|
EditEdge *eed;
|
|
|
|
|
EditFace *efa;
|
|
|
|
|
short edgeCount = 0;
|
|
|
|
|
|
|
|
|
|
/*clear new flag for new edges, count selected edges */
|
|
|
|
|
for(eed= G.editMesh->edges.first; eed; eed= eed->next){
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
eed->f1= 0;
|
2005-07-13 15:20:40 +00:00
|
|
|
eed->f2 &= ~2;
|
|
|
|
|
if(eed->f & SELECT) edgeCount++;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
if(edgeCount>1) {
|
|
|
|
|
/* more selected edges, check faces */
|
|
|
|
|
for(efa= G.editMesh->faces.first; efa; efa= efa->next) {
|
2004-10-13 19:39:26 +00:00
|
|
|
if(efa->f & SELECT) {
|
2005-07-13 15:20:40 +00:00
|
|
|
efa->e1->f1++;
|
|
|
|
|
efa->e2->f1++;
|
|
|
|
|
efa->e3->f1++;
|
|
|
|
|
if(efa->e4) efa->e4->f1++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
edgeCount= 0;
|
|
|
|
|
for(eed= G.editMesh->edges.first; eed; eed= eed->next) {
|
|
|
|
|
if(eed->f1==2) edgeCount++;
|
|
|
|
|
}
|
|
|
|
|
if(edgeCount==1) {
|
|
|
|
|
for(eed= G.editMesh->edges.first; eed; eed= eed->next) {
|
|
|
|
|
if(eed->f1==2) {
|
|
|
|
|
edge_rotate(eed,dir);
|
|
|
|
|
break;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
else error("Select one edge or two adjacent faces");
|
|
|
|
|
}
|
|
|
|
|
else if(edgeCount==1) {
|
|
|
|
|
for(eed= G.editMesh->edges.first; eed; eed= eed->next) {
|
|
|
|
|
if(eed->f & SELECT) {
|
|
|
|
|
EM_select_edge(eed, 0);
|
|
|
|
|
edge_rotate(eed,dir);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
else error("Select one edge or two adjacent faces");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* flush selected vertices (again) to edges/faces */
|
|
|
|
|
EM_select_flush();
|
|
|
|
|
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
BIF_undo_push("Rotate Edge");
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/******************* BEVEL CODE STARTS HERE ********************/
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static void bevel_displace_vec(float *midvec, float *v1, float *v2, float *v3, float d, float no[3])
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
{
|
2005-07-13 15:20:40 +00:00
|
|
|
float a[3], c[3], n_a[3], n_c[3], mid[3], ac, ac2, fac;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
VecSubf(a, v1, v2);
|
|
|
|
|
VecSubf(c, v3, v2);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
Crossf(n_a, a, no);
|
|
|
|
|
Normalise(n_a);
|
|
|
|
|
Crossf(n_c, no, c);
|
|
|
|
|
Normalise(n_c);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
Normalise(a);
|
|
|
|
|
Normalise(c);
|
|
|
|
|
ac = Inpf(a, c);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
if (ac == 1 || ac == -1) {
|
|
|
|
|
midvec[0] = midvec[1] = midvec[2] = 0;
|
|
|
|
|
return;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
ac2 = ac * ac;
|
|
|
|
|
fac = (float)sqrt((ac2 + 2*ac + 1)/(1 - ac2) + 1);
|
|
|
|
|
VecAddf(mid, n_c, n_a);
|
|
|
|
|
Normalise(mid);
|
|
|
|
|
VecMulf(mid, d * fac);
|
|
|
|
|
VecAddf(mid, mid, v2);
|
|
|
|
|
VecCopyf(midvec, mid);
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* Finds the new point using the sinus law to extrapolate a triangle
|
|
|
|
|
Lots of sqrts which would not be good for a real time algo
|
|
|
|
|
Using the mid point of the extrapolation of both sides
|
|
|
|
|
Useless for coplanar quads, but that doesn't happen too often */
|
|
|
|
|
static void fix_bevel_wrap(float *midvec, float *v1, float *v2, float *v3, float *v4, float d, float no[3])
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
{
|
2005-07-13 15:20:40 +00:00
|
|
|
float a[3], b[3], c[3], l_a, l_b, l_c, s_a, s_b, s_c, Pos1[3], Pos2[3], Dir[3];
|
2005-05-13 14:10:34 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
VecSubf(a, v3, v2);
|
|
|
|
|
l_a = Normalise(a);
|
|
|
|
|
VecSubf(b, v4, v3);
|
|
|
|
|
Normalise(b);
|
|
|
|
|
VecSubf(c, v1, v2);
|
|
|
|
|
Normalise(c);
|
2005-05-13 14:10:34 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
s_b = Inpf(a, c);
|
|
|
|
|
s_b = (float)sqrt(1 - (s_b * s_b));
|
|
|
|
|
s_a = Inpf(b, c);
|
|
|
|
|
s_a = (float)sqrt(1 - (s_a * s_a));
|
|
|
|
|
VecMulf(a, -1);
|
|
|
|
|
s_c = Inpf(a, b);
|
|
|
|
|
s_c = (float)sqrt(1 - (s_c * s_c));
|
2005-05-13 14:10:34 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
l_b = s_b * l_a / s_a;
|
|
|
|
|
l_c = s_c * l_a / s_a;
|
2005-05-13 14:10:34 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
VecMulf(b, l_b);
|
|
|
|
|
VecMulf(c, l_c);
|
2005-05-13 14:10:34 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
VecAddf(Pos1, v2, c);
|
|
|
|
|
VecAddf(Pos2, v3, b);
|
2005-05-13 14:10:34 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
VecAddf(Dir, Pos1, Pos2);
|
|
|
|
|
VecMulf(Dir, 0.5);
|
2005-05-13 14:10:34 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
bevel_displace_vec(midvec, v3, Dir, v2, d, no);
|
2005-05-13 14:10:34 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static char detect_wrap(float *o_v1, float *o_v2, float *v1, float *v2, float *no)
|
|
|
|
|
{
|
|
|
|
|
float o_a[3], a[3], o_c[3], c[3];
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
VecSubf(o_a, o_v1, o_v2);
|
|
|
|
|
VecSubf(a, v1, v2);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
Crossf(o_c, o_a, no);
|
|
|
|
|
Crossf(c, a, no);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
if (Inpf(c, o_c) <= 0)
|
|
|
|
|
return 1;
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
// Detects and fix a quad wrapping after the resize
|
|
|
|
|
// Arguments are the orginal verts followed by the final verts and then the bevel size and the normal
|
|
|
|
|
static void fix_bevel_quad_wrap(float *o_v1, float *o_v2, float *o_v3, float *o_v4, float *v1, float *v2, float *v3, float *v4, float d, float *no)
|
|
|
|
|
{
|
|
|
|
|
float vec[3];
|
|
|
|
|
char wrap[4];
|
|
|
|
|
|
|
|
|
|
// Quads can wrap partially. Watch out
|
|
|
|
|
wrap[0] = detect_wrap(o_v1, o_v2, v1, v2, no); // Edge 1-2
|
|
|
|
|
wrap[1] = detect_wrap(o_v2, o_v3, v2, v3, no); // Edge 2-3
|
|
|
|
|
wrap[2] = detect_wrap(o_v3, o_v4, v3, v4, no); // Edge 3-4
|
|
|
|
|
wrap[3] = detect_wrap(o_v4, o_v1, v4, v1, no); // Edge 4-1
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
// Edge 1 inverted
|
|
|
|
|
if (wrap[0] == 1 && wrap[1] == 0 && wrap[2] == 0 && wrap[3] == 0) {
|
|
|
|
|
fix_bevel_wrap(vec, o_v2, o_v3, o_v4, o_v1, d, no);
|
|
|
|
|
VECCOPY(v1, vec);
|
|
|
|
|
VECCOPY(v2, vec);
|
|
|
|
|
}
|
|
|
|
|
// Edge 2 inverted
|
|
|
|
|
else if (wrap[0] == 0 && wrap[1] == 1 && wrap[2] == 0 && wrap[3] == 0) {
|
|
|
|
|
fix_bevel_wrap(vec, o_v3, o_v4, o_v1, o_v2, d, no);
|
|
|
|
|
VECCOPY(v2, vec);
|
|
|
|
|
VECCOPY(v3, vec);
|
|
|
|
|
}
|
|
|
|
|
// Edge 3 inverted
|
|
|
|
|
else if (wrap[0] == 0 && wrap[1] == 0 && wrap[2] == 1 && wrap[3] == 0) {
|
|
|
|
|
fix_bevel_wrap(vec, o_v4, o_v1, o_v2, o_v3, d, no);
|
|
|
|
|
VECCOPY(v3, vec);
|
|
|
|
|
VECCOPY(v4, vec);
|
|
|
|
|
}
|
|
|
|
|
// Edge 4 inverted
|
|
|
|
|
else if (wrap[0] == 0 && wrap[1] == 0 && wrap[2] == 0 && wrap[3] == 1) {
|
|
|
|
|
fix_bevel_wrap(vec, o_v1, o_v2, o_v3, o_v4, d, no);
|
|
|
|
|
VECCOPY(v4, vec);
|
|
|
|
|
VECCOPY(v1, vec);
|
|
|
|
|
}
|
|
|
|
|
// Edge 2 and 4 inverted
|
|
|
|
|
else if (wrap[0] == 0 && wrap[1] == 1 && wrap[2] == 0 && wrap[3] == 1) {
|
|
|
|
|
VecAddf(vec, v2, v3);
|
|
|
|
|
VecMulf(vec, 0.5);
|
|
|
|
|
VECCOPY(v2, vec);
|
|
|
|
|
VECCOPY(v3, vec);
|
|
|
|
|
VecAddf(vec, v1, v4);
|
|
|
|
|
VecMulf(vec, 0.5);
|
|
|
|
|
VECCOPY(v1, vec);
|
|
|
|
|
VECCOPY(v4, vec);
|
|
|
|
|
}
|
|
|
|
|
// Edge 1 and 3 inverted
|
|
|
|
|
else if (wrap[0] == 1 && wrap[1] == 0 && wrap[2] == 1 && wrap[3] == 0) {
|
|
|
|
|
VecAddf(vec, v1, v2);
|
|
|
|
|
VecMulf(vec, 0.5);
|
|
|
|
|
VECCOPY(v1, vec);
|
|
|
|
|
VECCOPY(v2, vec);
|
|
|
|
|
VecAddf(vec, v3, v4);
|
|
|
|
|
VecMulf(vec, 0.5);
|
|
|
|
|
VECCOPY(v3, vec);
|
|
|
|
|
VECCOPY(v4, vec);
|
|
|
|
|
}
|
|
|
|
|
// Totally inverted
|
|
|
|
|
else if (wrap[0] == 1 && wrap[1] == 1 && wrap[2] == 1 && wrap[3] == 1) {
|
|
|
|
|
VecAddf(vec, v1, v2);
|
|
|
|
|
VecAddf(vec, vec, v3);
|
|
|
|
|
VecAddf(vec, vec, v4);
|
|
|
|
|
VecMulf(vec, 0.25);
|
|
|
|
|
VECCOPY(v1, vec);
|
|
|
|
|
VECCOPY(v2, vec);
|
|
|
|
|
VECCOPY(v3, vec);
|
|
|
|
|
VECCOPY(v4, vec);
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
// Detects and fix a tri wrapping after the resize
|
|
|
|
|
// Arguments are the orginal verts followed by the final verts and the normal
|
|
|
|
|
// Triangles cannot wrap partially (not in this situation
|
|
|
|
|
static void fix_bevel_tri_wrap(float *o_v1, float *o_v2, float *o_v3, float *v1, float *v2, float *v3, float *no)
|
|
|
|
|
{
|
|
|
|
|
if (detect_wrap(o_v1, o_v2, v1, v2, no)) {
|
|
|
|
|
float vec[3];
|
|
|
|
|
VecAddf(vec, o_v1, o_v2);
|
|
|
|
|
VecAddf(vec, vec, o_v3);
|
|
|
|
|
VecMulf(vec, 1.0f/3.0f);
|
|
|
|
|
VECCOPY(v1, vec);
|
|
|
|
|
VECCOPY(v2, vec);
|
|
|
|
|
VECCOPY(v3, vec);
|
|
|
|
|
}
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static void bevel_shrink_faces(float d, int flag)
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
{
|
|
|
|
|
EditMesh *em = G.editMesh;
|
2005-07-13 15:20:40 +00:00
|
|
|
EditFace *efa;
|
|
|
|
|
float vec[3], no[3], v1[3], v2[3], v3[3], v4[3];
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* move edges of all faces with efa->f1 & flag closer towards their centres */
|
|
|
|
|
efa= em->faces.first;
|
|
|
|
|
while (efa) {
|
|
|
|
|
if (efa->f1 & flag) {
|
|
|
|
|
VECCOPY(v1, efa->v1->co);
|
|
|
|
|
VECCOPY(v2, efa->v2->co);
|
|
|
|
|
VECCOPY(v3, efa->v3->co);
|
|
|
|
|
VECCOPY(no, efa->n);
|
|
|
|
|
if (efa->v4 == NULL) {
|
|
|
|
|
bevel_displace_vec(vec, v1, v2, v3, d, no);
|
|
|
|
|
VECCOPY(efa->v2->co, vec);
|
|
|
|
|
bevel_displace_vec(vec, v2, v3, v1, d, no);
|
|
|
|
|
VECCOPY(efa->v3->co, vec);
|
|
|
|
|
bevel_displace_vec(vec, v3, v1, v2, d, no);
|
|
|
|
|
VECCOPY(efa->v1->co, vec);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
fix_bevel_tri_wrap(v1, v2, v3, efa->v1->co, efa->v2->co, efa->v3->co, no);
|
|
|
|
|
} else {
|
|
|
|
|
VECCOPY(v4, efa->v4->co);
|
|
|
|
|
bevel_displace_vec(vec, v1, v2, v3, d, no);
|
|
|
|
|
VECCOPY(efa->v2->co, vec);
|
|
|
|
|
bevel_displace_vec(vec, v2, v3, v4, d, no);
|
|
|
|
|
VECCOPY(efa->v3->co, vec);
|
|
|
|
|
bevel_displace_vec(vec, v3, v4, v1, d, no);
|
|
|
|
|
VECCOPY(efa->v4->co, vec);
|
|
|
|
|
bevel_displace_vec(vec, v4, v1, v2, d, no);
|
|
|
|
|
VECCOPY(efa->v1->co, vec);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
fix_bevel_quad_wrap(v1, v2, v3, v4, efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co, d, no);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
efa= efa->next;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static void bevel_shrink_draw(float d, int flag)
|
|
|
|
|
{
|
|
|
|
|
EditMesh *em = G.editMesh;
|
|
|
|
|
EditFace *efa;
|
|
|
|
|
float vec[3], no[3], v1[3], v2[3], v3[3], v4[3], fv1[3], fv2[3], fv3[3], fv4[3];
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* move edges of all faces with efa->f1 & flag closer towards their centres */
|
|
|
|
|
efa= em->faces.first;
|
|
|
|
|
while (efa) {
|
|
|
|
|
VECCOPY(v1, efa->v1->co);
|
|
|
|
|
VECCOPY(v2, efa->v2->co);
|
|
|
|
|
VECCOPY(v3, efa->v3->co);
|
|
|
|
|
VECCOPY(no, efa->n);
|
|
|
|
|
if (efa->v4 == NULL) {
|
|
|
|
|
bevel_displace_vec(vec, v1, v2, v3, d, no);
|
|
|
|
|
VECCOPY(fv2, vec);
|
|
|
|
|
bevel_displace_vec(vec, v2, v3, v1, d, no);
|
|
|
|
|
VECCOPY(fv3, vec);
|
|
|
|
|
bevel_displace_vec(vec, v3, v1, v2, d, no);
|
|
|
|
|
VECCOPY(fv1, vec);
|
2005-05-06 12:12:26 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
fix_bevel_tri_wrap(v1, v2, v3, fv1, fv2, fv3, no);
|
2005-05-06 12:12:26 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
glVertex3fv(fv1);
|
|
|
|
|
glVertex3fv(fv2);
|
|
|
|
|
glEnd();
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
glVertex3fv(fv2);
|
|
|
|
|
glVertex3fv(fv3);
|
|
|
|
|
glEnd();
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
glVertex3fv(fv1);
|
|
|
|
|
glVertex3fv(fv3);
|
|
|
|
|
glEnd();
|
|
|
|
|
} else {
|
|
|
|
|
VECCOPY(v4, efa->v4->co);
|
|
|
|
|
bevel_displace_vec(vec, v4, v1, v2, d, no);
|
|
|
|
|
VECCOPY(fv1, vec);
|
|
|
|
|
bevel_displace_vec(vec, v1, v2, v3, d, no);
|
|
|
|
|
VECCOPY(fv2, vec);
|
|
|
|
|
bevel_displace_vec(vec, v2, v3, v4, d, no);
|
|
|
|
|
VECCOPY(fv3, vec);
|
|
|
|
|
bevel_displace_vec(vec, v3, v4, v1, d, no);
|
|
|
|
|
VECCOPY(fv4, vec);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
fix_bevel_quad_wrap(v1, v2, v3, v4, fv1, fv2, fv3, fv4, d, no);
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
glVertex3fv(fv1);
|
|
|
|
|
glVertex3fv(fv2);
|
|
|
|
|
glEnd();
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
glVertex3fv(fv2);
|
|
|
|
|
glVertex3fv(fv3);
|
|
|
|
|
glEnd();
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
glVertex3fv(fv3);
|
|
|
|
|
glVertex3fv(fv4);
|
|
|
|
|
glEnd();
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
glVertex3fv(fv1);
|
|
|
|
|
glVertex3fv(fv4);
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
efa= efa->next;
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static void bevel_mesh(float bsize, int allfaces)
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
{
|
|
|
|
|
EditMesh *em = G.editMesh;
|
2005-07-13 15:20:40 +00:00
|
|
|
//#define BEV_DEBUG
|
|
|
|
|
/* Enables debug printfs and assigns material indices: */
|
2005-08-07 21:47:08 +00:00
|
|
|
/* 2 = edge quad */
|
|
|
|
|
/* 3 = fill polygon (vertex clusters) */
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
EditFace *efa, *example; //, *nextvl;
|
|
|
|
|
EditEdge *eed, *eed2;
|
|
|
|
|
EditVert *neweve[1024], *eve, *eve2, *eve3, *v1, *v2, *v3, *v4; //, *eve4;
|
|
|
|
|
//short found4, search;
|
|
|
|
|
//float f1, f2, f3, f4;
|
|
|
|
|
float cent[3], min[3], max[3];
|
|
|
|
|
int a, b, c;
|
|
|
|
|
float limit= 0.001f;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
waitcursor(1);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
removedoublesflag(1, limit);
|
2004-10-16 13:53:41 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* tag all original faces */
|
|
|
|
|
efa= em->faces.first;
|
|
|
|
|
while (efa) {
|
|
|
|
|
efa->f1= 0;
|
|
|
|
|
if (faceselectedAND(efa, 1)||allfaces) {
|
|
|
|
|
efa->f1= 1;
|
|
|
|
|
efa->v1->f |= 128;
|
|
|
|
|
efa->v2->f |= 128;
|
|
|
|
|
efa->v3->f |= 128;
|
|
|
|
|
if (efa->v4) efa->v4->f |= 128;
|
|
|
|
|
}
|
|
|
|
|
efa->v1->f &= ~64;
|
|
|
|
|
efa->v2->f &= ~64;
|
|
|
|
|
efa->v3->f &= ~64;
|
|
|
|
|
if (efa->v4) efa->v4->f &= ~64;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
efa= efa->next;
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
#ifdef BEV_DEBUG
|
|
|
|
|
fprintf(stderr,"bevel_mesh: split\n");
|
|
|
|
|
#endif
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
efa= em->faces.first;
|
|
|
|
|
while (efa) {
|
|
|
|
|
if (efa->f1 & 1) {
|
|
|
|
|
efa->f1-= 1;
|
|
|
|
|
v1= addvertlist(efa->v1->co);
|
|
|
|
|
v1->f= efa->v1->f & ~128;
|
|
|
|
|
efa->v1->vn= v1;
|
|
|
|
|
#ifdef __NLA
|
|
|
|
|
v1->totweight = efa->v1->totweight;
|
|
|
|
|
if (efa->v1->totweight){
|
|
|
|
|
v1->dw = MEM_mallocN (efa->v1->totweight * sizeof(MDeformWeight), "deformWeight");
|
|
|
|
|
memcpy (v1->dw, efa->v1->dw, efa->v1->totweight * sizeof(MDeformWeight));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
v1->dw=NULL;
|
|
|
|
|
#endif
|
|
|
|
|
v1= addvertlist(efa->v2->co);
|
|
|
|
|
v1->f= efa->v2->f & ~128;
|
|
|
|
|
efa->v2->vn= v1;
|
|
|
|
|
#ifdef __NLA
|
|
|
|
|
v1->totweight = efa->v2->totweight;
|
|
|
|
|
if (efa->v2->totweight){
|
|
|
|
|
v1->dw = MEM_mallocN (efa->v2->totweight * sizeof(MDeformWeight), "deformWeight");
|
|
|
|
|
memcpy (v1->dw, efa->v2->dw, efa->v2->totweight * sizeof(MDeformWeight));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
v1->dw=NULL;
|
|
|
|
|
#endif
|
|
|
|
|
v1= addvertlist(efa->v3->co);
|
|
|
|
|
v1->f= efa->v3->f & ~128;
|
|
|
|
|
efa->v3->vn= v1;
|
|
|
|
|
#ifdef __NLA
|
|
|
|
|
v1->totweight = efa->v3->totweight;
|
|
|
|
|
if (efa->v3->totweight){
|
|
|
|
|
v1->dw = MEM_mallocN (efa->v3->totweight * sizeof(MDeformWeight), "deformWeight");
|
|
|
|
|
memcpy (v1->dw, efa->v3->dw, efa->v3->totweight * sizeof(MDeformWeight));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
v1->dw=NULL;
|
|
|
|
|
#endif
|
|
|
|
|
if (efa->v4) {
|
|
|
|
|
v1= addvertlist(efa->v4->co);
|
|
|
|
|
v1->f= efa->v4->f & ~128;
|
|
|
|
|
efa->v4->vn= v1;
|
|
|
|
|
#ifdef __NLA
|
|
|
|
|
v1->totweight = efa->v4->totweight;
|
|
|
|
|
if (efa->v4->totweight){
|
|
|
|
|
v1->dw = MEM_mallocN (efa->v4->totweight * sizeof(MDeformWeight), "deformWeight");
|
|
|
|
|
memcpy (v1->dw, efa->v4->dw, efa->v4->totweight * sizeof(MDeformWeight));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
v1->dw=NULL;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* Needs better adaption of creases? */
|
|
|
|
|
addedgelist(efa->e1->v1->vn, efa->e1->v2->vn, efa->e1);
|
|
|
|
|
addedgelist(efa->e2->v1->vn,efa->e2->v2->vn, efa->e2);
|
|
|
|
|
addedgelist(efa->e3->v1->vn,efa->e3->v2->vn, efa->e3);
|
|
|
|
|
if (efa->e4) addedgelist(efa->e4->v1->vn,efa->e4->v2->vn, efa->e4);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
if(efa->v4) {
|
|
|
|
|
v1= efa->v1->vn;
|
|
|
|
|
v2= efa->v2->vn;
|
|
|
|
|
v3= efa->v3->vn;
|
|
|
|
|
v4= efa->v4->vn;
|
|
|
|
|
addfacelist(v1, v2, v3, v4, efa,NULL);
|
|
|
|
|
} else {
|
|
|
|
|
v1= efa->v1->vn;
|
|
|
|
|
v2= efa->v2->vn;
|
|
|
|
|
v3= efa->v3->vn;
|
|
|
|
|
addfacelist(v1, v2, v3, 0, efa,NULL);
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
efa= efa-> next;
|
|
|
|
|
} else {
|
|
|
|
|
efa= efa->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(efa= em->faces.first; efa; efa= efa->next) {
|
|
|
|
|
if( (efa->v1->f & 128) && (efa->v2->f & 128) && (efa->v3->f & 128) ) {
|
|
|
|
|
if(efa->v4==NULL || (efa->v4->f & 128)) efa->f |= 128;
|
|
|
|
|
}
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
delfaceflag(128); // works with face flag now
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* tag all faces for shrink*/
|
|
|
|
|
efa= em->faces.first;
|
|
|
|
|
while (efa) {
|
|
|
|
|
if (faceselectedAND(efa, 1)||allfaces) {
|
|
|
|
|
efa->f1= 2;
|
|
|
|
|
}
|
|
|
|
|
efa= efa->next;
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
#ifdef BEV_DEBUG
|
|
|
|
|
fprintf(stderr,"bevel_mesh: make edge quads\n");
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* find edges that are on each other and make quads between them */
|
|
|
|
|
|
|
|
|
|
eed= em->edges.first;
|
|
|
|
|
while(eed) {
|
|
|
|
|
eed->f2= eed->f1= 0;
|
|
|
|
|
if ( ((eed->v1->f & eed->v2->f) & 1) || allfaces) eed->f1 |= 4; /* original edges */
|
|
|
|
|
eed->vn= 0;
|
|
|
|
|
eed= eed->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eed= em->edges.first;
|
|
|
|
|
while (eed) {
|
|
|
|
|
if ( ((eed->f1 & 2)==0) && (eed->f1 & 4) ) {
|
|
|
|
|
eed2= em->edges.first;
|
|
|
|
|
while (eed2) {
|
|
|
|
|
if ( (eed2 != eed) && ((eed2->f1 & 2)==0) && (eed->f1 & 4) ) {
|
|
|
|
|
if (
|
|
|
|
|
(eed->v1 != eed2->v1) &&
|
|
|
|
|
(eed->v1 != eed2->v2) &&
|
|
|
|
|
(eed->v2 != eed2->v1) &&
|
|
|
|
|
(eed->v2 != eed2->v2) && (
|
|
|
|
|
( VecCompare(eed->v1->co, eed2->v1->co, limit) &&
|
|
|
|
|
VecCompare(eed->v2->co, eed2->v2->co, limit) ) ||
|
|
|
|
|
( VecCompare(eed->v1->co, eed2->v2->co, limit) &&
|
|
|
|
|
VecCompare(eed->v2->co, eed2->v1->co, limit) ) ) )
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
#ifdef BEV_DEBUG
|
|
|
|
|
fprintf(stderr, "bevel_mesh: edge quad\n");
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
eed->f1 |= 2; /* these edges are finished */
|
|
|
|
|
eed2->f1 |= 2;
|
|
|
|
|
|
|
|
|
|
example= NULL;
|
|
|
|
|
efa= em->faces.first; /* search example face (for mat_nr, ME_SMOOTH, ...) */
|
|
|
|
|
while (efa) {
|
|
|
|
|
if ( (efa->e1 == eed) ||
|
2005-08-07 21:47:08 +00:00
|
|
|
(efa->e2 == eed) ||
|
|
|
|
|
(efa->e3 == eed) ||
|
|
|
|
|
(efa->e4 && (efa->e4 == eed)) ) {
|
|
|
|
|
example= efa;
|
2005-07-13 15:20:40 +00:00
|
|
|
efa= NULL;
|
|
|
|
|
}
|
|
|
|
|
if (efa) efa= efa->next;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
neweve[0]= eed->v1; neweve[1]= eed->v2;
|
|
|
|
|
neweve[2]= eed2->v1; neweve[3]= eed2->v2;
|
|
|
|
|
|
|
|
|
|
if(exist_face(neweve[0], neweve[1], neweve[2], neweve[3])==0) {
|
|
|
|
|
efa= NULL;
|
|
|
|
|
|
|
|
|
|
if (VecCompare(eed->v1->co, eed2->v2->co, limit)) {
|
|
|
|
|
efa= addfacelist(neweve[0], neweve[1], neweve[2], neweve[3], example,NULL);
|
|
|
|
|
} else {
|
|
|
|
|
efa= addfacelist(neweve[0], neweve[2], neweve[3], neweve[1], example,NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(efa) {
|
|
|
|
|
float inp;
|
|
|
|
|
CalcNormFloat(efa->v1->co, efa->v2->co, efa->v3->co, efa->n);
|
|
|
|
|
inp= efa->n[0]*G.vd->viewmat[0][2] + efa->n[1]*G.vd->viewmat[1][2] + efa->n[2]*G.vd->viewmat[2][2];
|
|
|
|
|
if(inp < 0.0) flipface(efa);
|
|
|
|
|
#ifdef BEV_DEBUG
|
|
|
|
|
efa->mat_nr= 1;
|
|
|
|
|
#endif
|
|
|
|
|
} else fprintf(stderr,"bevel_mesh: error creating face\n");
|
|
|
|
|
}
|
|
|
|
|
eed2= NULL;
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
if (eed2) eed2= eed2->next;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
eed= eed->next;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
eed= em->edges.first;
|
|
|
|
|
while(eed) {
|
|
|
|
|
eed->f2= eed->f1= 0;
|
|
|
|
|
eed->f1= 0;
|
|
|
|
|
eed->v1->f1 &= ~1;
|
|
|
|
|
eed->v2->f1 &= ~1;
|
|
|
|
|
eed->vn= 0;
|
|
|
|
|
eed= eed->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef BEV_DEBUG
|
|
|
|
|
fprintf(stderr,"bevel_mesh: find clusters\n");
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Look for vertex clusters */
|
|
|
|
|
|
|
|
|
|
eve= em->verts.first;
|
|
|
|
|
while (eve) {
|
|
|
|
|
eve->f &= ~(64|128);
|
|
|
|
|
eve->vn= NULL;
|
|
|
|
|
eve= eve->next;
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* eve->f: 128: first vertex in a list (->vn) */
|
2005-08-07 21:47:08 +00:00
|
|
|
/* 64: vertex is in a list */
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
eve= em->verts.first;
|
|
|
|
|
while (eve) {
|
|
|
|
|
eve2= em->verts.first;
|
|
|
|
|
eve3= NULL;
|
|
|
|
|
while (eve2) {
|
|
|
|
|
if ((eve2 != eve) && ((eve2->f & (64|128))==0)) {
|
|
|
|
|
if (VecCompare(eve->co, eve2->co, limit)) {
|
|
|
|
|
if ((eve->f & (128|64)) == 0) {
|
|
|
|
|
/* fprintf(stderr,"Found vertex cluster:\n *\n *\n"); */
|
|
|
|
|
eve->f |= 128;
|
|
|
|
|
eve->vn= eve2;
|
|
|
|
|
eve3= eve2;
|
|
|
|
|
} else if ((eve->f & 64) == 0) {
|
|
|
|
|
/* fprintf(stderr," *\n"); */
|
|
|
|
|
if (eve3) eve3->vn= eve2;
|
|
|
|
|
eve2->f |= 64;
|
|
|
|
|
eve3= eve2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
eve2= eve2->next;
|
|
|
|
|
if (!eve2) {
|
|
|
|
|
if (eve3) eve3->vn= NULL;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
eve= eve->next;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
#ifdef BEV_DEBUG
|
|
|
|
|
fprintf(stderr,"bevel_mesh: shrink faces\n");
|
|
|
|
|
#endif
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
bevel_shrink_faces(bsize, 2);
|
|
|
|
|
|
|
|
|
|
#ifdef BEV_DEBUG
|
|
|
|
|
fprintf(stderr,"bevel_mesh: fill clusters\n");
|
|
|
|
|
#endif
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* Make former vertex clusters faces */
|
|
|
|
|
|
|
|
|
|
eve= em->verts.first;
|
|
|
|
|
while (eve) {
|
|
|
|
|
eve->f &= ~64;
|
|
|
|
|
eve= eve->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eve= em->verts.first;
|
|
|
|
|
while (eve) {
|
|
|
|
|
if (eve->f & 128) {
|
|
|
|
|
eve->f &= ~128;
|
|
|
|
|
a= 0;
|
|
|
|
|
neweve[a]= eve;
|
|
|
|
|
eve2= eve->vn;
|
|
|
|
|
while (eve2) {
|
|
|
|
|
a++;
|
|
|
|
|
neweve[a]= eve2;
|
|
|
|
|
eve2= eve2->vn;
|
|
|
|
|
}
|
|
|
|
|
a++;
|
|
|
|
|
efa= NULL;
|
|
|
|
|
if (a>=3) {
|
|
|
|
|
example= NULL;
|
|
|
|
|
efa= em->faces.first; /* search example face */
|
|
|
|
|
while (efa) {
|
|
|
|
|
if ( (efa->v1 == neweve[0]) ||
|
2005-08-07 21:47:08 +00:00
|
|
|
(efa->v2 == neweve[0]) ||
|
|
|
|
|
(efa->v3 == neweve[0]) ||
|
|
|
|
|
(efa->v4 && (efa->v4 == neweve[0])) ) {
|
|
|
|
|
example= efa;
|
2005-07-13 15:20:40 +00:00
|
|
|
efa= NULL;
|
|
|
|
|
}
|
|
|
|
|
if (efa) efa= efa->next;
|
|
|
|
|
}
|
|
|
|
|
#ifdef BEV_DEBUG
|
|
|
|
|
fprintf(stderr,"bevel_mesh: Making %d-gon\n", a);
|
|
|
|
|
#endif
|
|
|
|
|
if (a>4) {
|
|
|
|
|
cent[0]= cent[1]= cent[2]= 0.0;
|
|
|
|
|
INIT_MINMAX(min, max);
|
|
|
|
|
for (b=0; b<a; b++) {
|
|
|
|
|
VecAddf(cent, cent, neweve[b]->co);
|
|
|
|
|
DO_MINMAX(neweve[b]->co, min, max);
|
|
|
|
|
}
|
|
|
|
|
cent[0]= (min[0]+max[0])/2;
|
|
|
|
|
cent[1]= (min[1]+max[1])/2;
|
|
|
|
|
cent[2]= (min[2]+max[2])/2;
|
|
|
|
|
eve2= addvertlist(cent);
|
|
|
|
|
eve2->f |= 1;
|
|
|
|
|
eed= em->edges.first;
|
|
|
|
|
while (eed) {
|
|
|
|
|
c= 0;
|
|
|
|
|
for (b=0; b<a; b++)
|
|
|
|
|
if ((neweve[b]==eed->v1) || (neweve[b]==eed->v2)) c++;
|
|
|
|
|
if (c==2) {
|
|
|
|
|
if(exist_face(eed->v1, eed->v2, eve2, 0)==0) {
|
|
|
|
|
efa= addfacelist(eed->v1, eed->v2, eve2, 0, example,NULL);
|
|
|
|
|
#ifdef BEV_DEBUG
|
|
|
|
|
efa->mat_nr= 2;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
eed= eed->next;
|
|
|
|
|
}
|
|
|
|
|
} else if (a==4) {
|
|
|
|
|
if(exist_face(neweve[0], neweve[1], neweve[2], neweve[3])==0) {
|
|
|
|
|
/* the order of vertices can be anything, three cases to check */
|
|
|
|
|
if( convex(neweve[0]->co, neweve[1]->co, neweve[2]->co, neweve[3]->co) ) {
|
|
|
|
|
efa= addfacelist(neweve[0], neweve[1], neweve[2], neweve[3], NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
else if( convex(neweve[0]->co, neweve[2]->co, neweve[3]->co, neweve[1]->co) ) {
|
|
|
|
|
efa= addfacelist(neweve[0], neweve[2], neweve[3], neweve[1], NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
else if( convex(neweve[0]->co, neweve[2]->co, neweve[1]->co, neweve[3]->co) ) {
|
|
|
|
|
efa= addfacelist(neweve[0], neweve[2], neweve[1], neweve[3], NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (a==3) {
|
|
|
|
|
if(exist_face(neweve[0], neweve[1], neweve[2], 0)==0)
|
|
|
|
|
efa= addfacelist(neweve[0], neweve[1], neweve[2], 0, example, NULL);
|
|
|
|
|
}
|
|
|
|
|
if(efa) {
|
|
|
|
|
float inp;
|
|
|
|
|
CalcNormFloat(neweve[0]->co, neweve[1]->co, neweve[2]->co, efa->n);
|
|
|
|
|
inp= efa->n[0]*G.vd->viewmat[0][2] + efa->n[1]*G.vd->viewmat[1][2] + efa->n[2]*G.vd->viewmat[2][2];
|
|
|
|
|
if(inp < 0.0) flipface(efa);
|
|
|
|
|
#ifdef BEV_DEBUG
|
|
|
|
|
efa->mat_nr= 2;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
eve= eve->next;
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
eve= em->verts.first;
|
|
|
|
|
while (eve) {
|
|
|
|
|
eve->f1= 0;
|
|
|
|
|
eve->f &= ~(128|64);
|
|
|
|
|
eve->vn= NULL;
|
|
|
|
|
eve= eve->next;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
recalc_editnormals();
|
|
|
|
|
waitcursor(0);
|
|
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
removedoublesflag(1, limit);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* flush selected vertices to edges/faces */
|
|
|
|
|
EM_select_flush();
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
#undef BEV_DEBUG
|
|
|
|
|
}
|
2005-04-25 20:42:50 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static void bevel_mesh_recurs(float bsize, short recurs, int allfaces)
|
|
|
|
|
{
|
|
|
|
|
float d;
|
|
|
|
|
short nr;
|
|
|
|
|
|
|
|
|
|
d= bsize;
|
|
|
|
|
for (nr=0; nr<recurs; nr++) {
|
|
|
|
|
bevel_mesh(d, allfaces);
|
|
|
|
|
if (nr==0) d /= 3; else d /= 2;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
}
|
2005-02-16 15:02:58 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
void bevel_menu()
|
|
|
|
|
{
|
|
|
|
|
char Finished = 0, Canceled = 0, str[100], Recalc = 0;
|
|
|
|
|
short mval[2], oval[2], curval[2], event = 0, recurs = 1, nr;
|
|
|
|
|
float vec[3], d, drawd=0.0, centre[3], fac = 1;
|
|
|
|
|
|
|
|
|
|
getmouseco_areawin(mval);
|
|
|
|
|
oval[0] = mval[0]; oval[1] = mval[1];
|
|
|
|
|
|
|
|
|
|
// Silly hackish code to initialise the variable (warning if not done)
|
|
|
|
|
// while still drawing in the first iteration (and without using another variable)
|
|
|
|
|
curval[0] = mval[0] + 1; curval[1] = mval[1] + 1;
|
|
|
|
|
|
|
|
|
|
window_to_3d(centre, mval[0], mval[1]);
|
|
|
|
|
|
|
|
|
|
if(button(&recurs, 1, 4, "Recursion:")==0) return;
|
|
|
|
|
|
|
|
|
|
for (nr=0; nr<recurs-1; nr++) {
|
|
|
|
|
if (nr==0) fac += 1.0f/3.0f; else fac += 1.0f/(3 * nr * 2.0f);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
SetBlenderCursor(SYSCURSOR);
|
|
|
|
|
|
|
|
|
|
while (Finished == 0)
|
|
|
|
|
{
|
|
|
|
|
getmouseco_areawin(mval);
|
|
|
|
|
if (mval[0] != curval[0] || mval[1] != curval[1] || (Recalc == 1))
|
|
|
|
|
{
|
|
|
|
|
Recalc = 0;
|
|
|
|
|
curval[0] = mval[0];
|
|
|
|
|
curval[1] = mval[1];
|
|
|
|
|
|
|
|
|
|
window_to_3d(vec, mval[0]-oval[0], mval[1]-oval[1]);
|
|
|
|
|
d = Normalise(vec) / 10;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
drawd = d * fac;
|
|
|
|
|
if (G.qual & LR_CTRLKEY)
|
|
|
|
|
drawd = (float) floor(drawd * 10.0f)/10.0f;
|
|
|
|
|
if (G.qual & LR_SHIFTKEY)
|
|
|
|
|
drawd /= 10;
|
|
|
|
|
|
|
|
|
|
/*------------- Preview lines--------------- */
|
|
|
|
|
|
|
|
|
|
/* uses callback mechanism to draw it all in current area */
|
|
|
|
|
scrarea_do_windraw(curarea);
|
2005-02-16 15:02:58 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* set window matrix to perspective, default an area returns with buttons transform */
|
|
|
|
|
persp(PERSP_VIEW);
|
|
|
|
|
/* make a copy, for safety */
|
|
|
|
|
glPushMatrix();
|
|
|
|
|
/* multiply with the object transformation */
|
|
|
|
|
mymultmatrix(G.obedit->obmat);
|
2005-02-16 15:02:58 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
glColor3ub(255, 255, 0);
|
|
|
|
|
|
|
|
|
|
// PREVIEW CODE GOES HERE
|
|
|
|
|
bevel_shrink_draw(drawd, 2);
|
|
|
|
|
|
|
|
|
|
/* restore matrix transform */
|
|
|
|
|
glPopMatrix();
|
|
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
sprintf(str, "Bevel Size: %.4f LMB to confirm, RMB to cancel, SPACE to input directly.", drawd);
|
2005-07-13 15:20:40 +00:00
|
|
|
headerprint(str);
|
|
|
|
|
|
|
|
|
|
/* this also verifies other area/windows for clean swap */
|
|
|
|
|
screen_swapbuffers();
|
|
|
|
|
|
|
|
|
|
persp(PERSP_WIN);
|
|
|
|
|
|
|
|
|
|
glDrawBuffer(GL_FRONT);
|
|
|
|
|
|
|
|
|
|
BIF_ThemeColor(TH_WIRE);
|
|
|
|
|
|
|
|
|
|
setlinestyle(3);
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
|
|
|
|
glVertex2sv(mval);
|
|
|
|
|
glVertex2sv(oval);
|
|
|
|
|
glEnd();
|
|
|
|
|
setlinestyle(0);
|
|
|
|
|
|
|
|
|
|
persp(PERSP_VIEW);
|
|
|
|
|
glFlush(); // flush display for frontbuffer
|
|
|
|
|
glDrawBuffer(GL_BACK);
|
2005-02-16 15:02:58 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
while(qtest()) {
|
|
|
|
|
unsigned short val=0;
|
|
|
|
|
event= extern_qread(&val); // extern_qread stores important events for the mainloop to handle
|
2005-02-16 15:02:58 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* val==0 on key-release event */
|
|
|
|
|
if(val && (event==ESCKEY || event==RIGHTMOUSE || event==LEFTMOUSE || event==RETKEY || event==ESCKEY)){
|
|
|
|
|
if (event==RIGHTMOUSE || event==ESCKEY)
|
|
|
|
|
Canceled = 1;
|
|
|
|
|
Finished = 1;
|
|
|
|
|
}
|
|
|
|
|
else if (val && event==SPACEKEY) {
|
|
|
|
|
if (fbutton(&d, 0.000, 10.000, 10, 0, "Width:")!=0) {
|
|
|
|
|
drawd = d * fac;
|
|
|
|
|
Finished = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (val) {
|
|
|
|
|
/* On any other keyboard event, recalc */
|
|
|
|
|
Recalc = 1;
|
|
|
|
|
}
|
2005-02-16 15:02:58 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
}
|
2005-02-16 15:02:58 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
if (Canceled==0) {
|
|
|
|
|
SetBlenderCursor(BC_WAITCURSOR);
|
|
|
|
|
bevel_mesh_recurs(drawd/fac, recurs, 1);
|
|
|
|
|
righthandfaces(1);
|
|
|
|
|
SetBlenderCursor(SYSCURSOR);
|
|
|
|
|
BIF_undo_push("Bevel");
|
2005-02-17 14:09:05 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
}
|
2005-02-14 20:14:10 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* *********** END BEVEL *********/
|
|
|
|
|
|
|
|
|
|
typedef struct SlideVert {
|
2005-08-07 21:47:08 +00:00
|
|
|
EditEdge *up,*down;
|
|
|
|
|
EditVert origvert;
|
2005-07-13 15:20:40 +00:00
|
|
|
} SlideVert;
|
|
|
|
|
|
2005-08-10 03:51:34 +00:00
|
|
|
void EdgeLoopDelete(void) {
|
2005-08-07 21:47:08 +00:00
|
|
|
EdgeSlide(1, 1);
|
|
|
|
|
select_more();
|
|
|
|
|
removedoublesflag(1,0.001);
|
2005-08-07 20:46:26 +00:00
|
|
|
EM_select_flush();
|
2005-08-07 21:47:08 +00:00
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
2005-08-07 20:46:26 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-23 14:39:59 +00:00
|
|
|
int EdgeSlide(short immediate, float imperc)
|
2005-07-17 15:45:35 +00:00
|
|
|
{
|
2005-08-07 21:47:08 +00:00
|
|
|
EditMesh *em = G.editMesh;
|
|
|
|
|
EditFace *efa;
|
|
|
|
|
EditEdge *eed,*first=NULL,*last=NULL, *temp = NULL;
|
|
|
|
|
EditVert *ev, *nearest;
|
|
|
|
|
LinkNode *edgelist = NULL, *vertlist=NULL, *look;
|
|
|
|
|
GHash *vertgh;
|
|
|
|
|
SlideVert *tempsv;
|
2005-08-15 04:10:02 +00:00
|
|
|
float perc = 0, percp = 0,vertdist, projectMat[4][4];
|
2005-08-07 21:47:08 +00:00
|
|
|
int i = 0,j, numsel, numadded=0, timesthrough = 0, vertsel=0, prop=1, cancel = 0;
|
|
|
|
|
short event, draw=1;
|
|
|
|
|
short mval[2], mvalo[2];
|
|
|
|
|
char str[128];
|
|
|
|
|
|
2005-08-15 04:10:02 +00:00
|
|
|
view3d_get_object_project_mat(curarea, G.obedit, projectMat);
|
2005-08-07 21:47:08 +00:00
|
|
|
|
|
|
|
|
mvalo[0] = -1; mvalo[1] = -1;
|
|
|
|
|
numsel =0;
|
|
|
|
|
|
|
|
|
|
// Get number of selected edges and clear some flags
|
|
|
|
|
for(eed=em->edges.first;eed;eed=eed->next){
|
|
|
|
|
eed->f1 = 0;
|
|
|
|
|
eed->f2 = 0;
|
|
|
|
|
if(eed->f & SELECT) numsel++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(ev=em->verts.first;ev;ev=ev->next){
|
|
|
|
|
ev->f1 = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Make sure each edge only has 2 faces
|
|
|
|
|
// make sure loop doesn't cross face
|
|
|
|
|
for(efa=em->faces.first;efa;efa=efa->next){
|
|
|
|
|
int ct = 0;
|
|
|
|
|
if(efa->e1->f & SELECT){
|
|
|
|
|
ct++;
|
|
|
|
|
efa->e1->f1++;
|
|
|
|
|
if(efa->e1->f1 > 2){
|
2005-08-07 23:59:34 +00:00
|
|
|
error("3+ face edge");
|
2005-08-07 21:47:08 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(efa->e2->f & SELECT){
|
|
|
|
|
ct++;
|
|
|
|
|
efa->e2->f1++;
|
|
|
|
|
if(efa->e2->f1 > 2){
|
2005-08-07 23:59:34 +00:00
|
|
|
error("3+ face edge");
|
2005-08-07 21:47:08 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(efa->e3->f & SELECT){
|
|
|
|
|
ct++;
|
|
|
|
|
efa->e3->f1++;
|
|
|
|
|
if(efa->e3->f1 > 2){
|
2005-08-07 23:59:34 +00:00
|
|
|
error("3+ face edge");
|
2005-08-07 21:47:08 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(efa->e4 && efa->e4->f & SELECT){
|
|
|
|
|
ct++;
|
|
|
|
|
efa->e4->f1++;
|
|
|
|
|
if(efa->e4->f1 > 2){
|
2005-08-07 23:59:34 +00:00
|
|
|
error("3+ face edge");
|
2005-08-07 21:47:08 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Make sure loop is not 2 edges of same face
|
|
|
|
|
if(ct > 1){
|
2005-08-07 23:59:34 +00:00
|
|
|
error("loop crosses itself");
|
2005-08-07 21:47:08 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Get # of selected verts
|
|
|
|
|
for(ev=em->verts.first;ev;ev=ev->next){
|
|
|
|
|
if(ev->f & SELECT) vertsel++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test for multiple segments
|
|
|
|
|
if(vertsel > numsel+1){
|
2005-08-07 23:59:34 +00:00
|
|
|
error("Was not a single edge loop");
|
2005-08-07 21:47:08 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get the edgeloop in order - mark f1 with SELECT once added
|
|
|
|
|
for(eed=em->edges.first;eed;eed=eed->next){
|
|
|
|
|
if((eed->f & SELECT) && !(eed->f1 & SELECT)){
|
|
|
|
|
// If this is the first edge added, just put it in
|
|
|
|
|
if(!edgelist){
|
|
|
|
|
BLI_linklist_prepend(&edgelist,eed);
|
|
|
|
|
numadded++;
|
|
|
|
|
first = eed;
|
|
|
|
|
last = eed;
|
|
|
|
|
eed->f1 = SELECT;
|
|
|
|
|
} else {
|
2005-08-10 03:51:34 +00:00
|
|
|
if(editedge_getSharedVert(eed, last)) {
|
2005-08-07 21:47:08 +00:00
|
|
|
BLI_linklist_append(&edgelist,eed);
|
|
|
|
|
eed->f1 = SELECT;
|
|
|
|
|
numadded++;
|
|
|
|
|
last = eed;
|
2005-08-10 03:51:34 +00:00
|
|
|
} else if(editedge_getSharedVert(eed, first)) {
|
2005-08-07 21:47:08 +00:00
|
|
|
BLI_linklist_prepend(&edgelist,eed);
|
|
|
|
|
eed->f1 = SELECT;
|
|
|
|
|
numadded++;
|
|
|
|
|
first = eed;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(eed->next == NULL && numadded != numsel){
|
|
|
|
|
eed=em->edges.first;
|
|
|
|
|
timesthrough++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// It looks like there was an unexpected case - Hopefully should not happen
|
|
|
|
|
if(timesthrough >= numsel*2){
|
|
|
|
|
BLI_linklist_free(edgelist,NULL);
|
2005-08-07 23:59:34 +00:00
|
|
|
error("could not order loop");
|
2005-08-07 21:47:08 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Put the verts in order in a linklist
|
|
|
|
|
look = edgelist;
|
|
|
|
|
while(look){
|
|
|
|
|
eed = look->link;
|
|
|
|
|
if(!vertlist){
|
|
|
|
|
if(look->next){
|
|
|
|
|
temp = look->next->link;
|
|
|
|
|
|
|
|
|
|
//This is the first entry takes care of extra vert
|
|
|
|
|
if(eed->v1 != temp->v1 && eed->v1 != temp->v2){
|
|
|
|
|
BLI_linklist_append(&vertlist,eed->v1);
|
|
|
|
|
eed->v1->f1 = 1;
|
|
|
|
|
} else {
|
|
|
|
|
BLI_linklist_append(&vertlist,eed->v2);
|
|
|
|
|
eed->v2->f1 = 1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//This is the case that we only have 1 edge
|
|
|
|
|
BLI_linklist_append(&vertlist,eed->v1);
|
|
|
|
|
eed->v1->f1 = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// for all the entries
|
|
|
|
|
if(eed->v1->f1 != 1){
|
|
|
|
|
BLI_linklist_append(&vertlist,eed->v1);
|
|
|
|
|
eed->v1->f1 = 1;
|
|
|
|
|
} else if(eed->v2->f1 != 1){
|
|
|
|
|
BLI_linklist_append(&vertlist,eed->v2);
|
|
|
|
|
eed->v2->f1 = 1;
|
|
|
|
|
}
|
|
|
|
|
look = look->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// populate the SlideVerts
|
|
|
|
|
|
|
|
|
|
vertgh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
|
|
|
|
|
look = vertlist;
|
2005-07-13 15:20:40 +00:00
|
|
|
while(look){
|
2005-08-07 21:47:08 +00:00
|
|
|
i=0;
|
|
|
|
|
j=0;
|
|
|
|
|
ev = look->link;
|
|
|
|
|
tempsv = (struct SlideVert*)MEM_mallocN(sizeof(struct SlideVert),"SlideVert");
|
|
|
|
|
tempsv->up = NULL;
|
|
|
|
|
tempsv->down = NULL;
|
|
|
|
|
tempsv->origvert.co[0] = ev->co[0];
|
|
|
|
|
tempsv->origvert.co[1] = ev->co[1];
|
|
|
|
|
tempsv->origvert.co[2] = ev->co[2];
|
|
|
|
|
tempsv->origvert.no[0] = ev->no[0];
|
|
|
|
|
tempsv->origvert.no[1] = ev->no[1];
|
|
|
|
|
tempsv->origvert.no[2] = ev->no[2];
|
|
|
|
|
// i is total edges that vert is on
|
|
|
|
|
// j is total selected edges that vert is on
|
|
|
|
|
|
|
|
|
|
for(eed=em->edges.first;eed;eed=eed->next){
|
|
|
|
|
if(eed->v1 == ev || eed->v2 == ev){
|
|
|
|
|
i++;
|
|
|
|
|
if(eed->f & SELECT){
|
|
|
|
|
j++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// If the vert is in the middle of an edge loop, it touches 2 selected edges and 2 unselected edges
|
|
|
|
|
if(i == 4 && j == 2){
|
|
|
|
|
for(eed=em->edges.first;eed;eed=eed->next){
|
2005-08-10 03:51:34 +00:00
|
|
|
if(editedge_containsVert(eed, ev)){
|
2005-08-07 21:47:08 +00:00
|
|
|
if(!(eed->f & SELECT)){
|
|
|
|
|
if(!tempsv->up){
|
|
|
|
|
tempsv->up = eed;
|
|
|
|
|
} else if (!(tempsv->down)){
|
|
|
|
|
tempsv->down = eed;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// If it is on the end of the loop, it touches 1 selected and as least 2 more unselected
|
|
|
|
|
if(i >= 3 && j == 1){
|
|
|
|
|
for(eed=em->edges.first;eed;eed=eed->next){
|
2005-08-10 03:51:34 +00:00
|
|
|
if(editedge_containsVert(eed, ev) && eed->f & SELECT){
|
2005-08-07 21:47:08 +00:00
|
|
|
for(efa = em->faces.first;efa;efa=efa->next){
|
2005-08-10 03:51:34 +00:00
|
|
|
if(editface_containsEdge(efa, eed)){
|
|
|
|
|
if(editedge_containsVert(efa->e1, ev) && efa->e1 != eed){
|
2005-08-07 21:47:08 +00:00
|
|
|
if(!tempsv->up){
|
|
|
|
|
tempsv->up = efa->e1;
|
|
|
|
|
} else if (!(tempsv->down)){
|
|
|
|
|
tempsv->down = efa->e1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-08-10 03:51:34 +00:00
|
|
|
if(editedge_containsVert(efa->e2, ev) && efa->e2 != eed){
|
2005-08-07 21:47:08 +00:00
|
|
|
if(!tempsv->up){
|
|
|
|
|
tempsv->up = efa->e2;
|
|
|
|
|
} else if (!(tempsv->down)){
|
|
|
|
|
tempsv->down = efa->e2;
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-08-10 03:51:34 +00:00
|
|
|
if(editedge_containsVert(efa->e3, ev) && efa->e3 != eed){
|
2005-08-07 21:47:08 +00:00
|
|
|
if(!tempsv->up){
|
|
|
|
|
tempsv->up = efa->e3;
|
|
|
|
|
} else if (!(tempsv->down)){
|
|
|
|
|
tempsv->down = efa->e3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(efa->e4){
|
2005-08-10 03:51:34 +00:00
|
|
|
if(editedge_containsVert(efa->e4, ev) && efa->e4 != eed){
|
2005-08-07 21:47:08 +00:00
|
|
|
if(!tempsv->up){
|
|
|
|
|
tempsv->up = efa->e4;
|
|
|
|
|
} else if (!(tempsv->down)){
|
|
|
|
|
tempsv->down = efa->e4;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(i > 4 && j == 2){
|
|
|
|
|
BLI_ghash_free(vertgh, NULL, (GHashValFreeFP)MEM_freeN);
|
|
|
|
|
BLI_linklist_free(vertlist,NULL);
|
|
|
|
|
BLI_linklist_free(edgelist,NULL);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
BLI_ghash_insert(vertgh,ev,tempsv);
|
|
|
|
|
|
|
|
|
|
look = look->next;
|
|
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
|
2005-08-07 21:47:08 +00:00
|
|
|
// make sure the UPs nad DOWNs are 'faceloops'
|
|
|
|
|
// Also find the nearest slidevert to the cursor
|
|
|
|
|
getmouseco_areawin(mval);
|
|
|
|
|
look = vertlist;
|
|
|
|
|
nearest = NULL;
|
|
|
|
|
vertdist = -1;
|
|
|
|
|
while(look){
|
|
|
|
|
if(look->next != NULL){
|
2005-08-10 03:51:34 +00:00
|
|
|
SlideVert *sv;
|
|
|
|
|
|
2005-08-07 23:59:34 +00:00
|
|
|
tempsv = BLI_ghash_lookup(vertgh,(EditVert*)look->link);
|
|
|
|
|
sv = BLI_ghash_lookup(vertgh,(EditVert*)look->next->link);
|
|
|
|
|
|
|
|
|
|
if(!tempsv->up || !tempsv->down){
|
|
|
|
|
error("Missing rails");
|
|
|
|
|
BLI_ghash_free(vertgh, NULL, (GHashValFreeFP)MEM_freeN);
|
|
|
|
|
BLI_linklist_free(vertlist,NULL);
|
|
|
|
|
BLI_linklist_free(edgelist,NULL);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2005-08-10 03:51:34 +00:00
|
|
|
|
|
|
|
|
if(sv) {
|
|
|
|
|
float tempdist, co[2];
|
|
|
|
|
|
2005-08-15 04:10:02 +00:00
|
|
|
if(!sharesFace(tempsv->up,sv->up)){
|
|
|
|
|
EditEdge *swap;
|
|
|
|
|
swap = sv->up;
|
|
|
|
|
sv->up = sv->down;
|
|
|
|
|
sv->down = swap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
view3d_project_float(curarea, tempsv->origvert.co, co, projectMat);
|
2005-08-10 03:51:34 +00:00
|
|
|
|
|
|
|
|
tempdist = sqrt(pow(co[0] - mval[0],2)+pow(co[1] - mval[1],2));
|
|
|
|
|
|
|
|
|
|
if(vertdist < 0){
|
|
|
|
|
vertdist = tempdist;
|
|
|
|
|
nearest = (EditVert*)look->link;
|
|
|
|
|
} else if ( tempdist < vertdist ){
|
|
|
|
|
vertdist = tempdist;
|
|
|
|
|
nearest = (EditVert*)look->link;
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-08-07 23:59:34 +00:00
|
|
|
}
|
2005-08-07 21:47:08 +00:00
|
|
|
look = look->next;
|
|
|
|
|
}
|
|
|
|
|
// we should have enough info now to slide
|
|
|
|
|
//persp(PERSP_WIN);
|
|
|
|
|
//glDrawBuffer(GL_FRONT);
|
|
|
|
|
percp = -1;
|
|
|
|
|
while(draw){
|
|
|
|
|
/* For the % calculation */
|
|
|
|
|
short mval[2];
|
|
|
|
|
float labda, rc[2], len;
|
2005-08-15 04:10:02 +00:00
|
|
|
float v2[2], v3[2];
|
2005-08-10 03:51:34 +00:00
|
|
|
EditVert *centerVert, *upVert, *downVert;
|
2005-08-07 21:47:08 +00:00
|
|
|
|
|
|
|
|
getmouseco_areawin(mval);
|
2005-08-07 21:23:55 +00:00
|
|
|
|
2005-08-10 03:51:34 +00:00
|
|
|
if (!immediate && (mval[0] == mvalo[0] && mval[1] == mvalo[1])) {
|
2005-08-07 21:47:08 +00:00
|
|
|
PIL_sleep_ms(10);
|
|
|
|
|
} else {
|
2005-08-07 23:59:34 +00:00
|
|
|
mvalo[0] = mval[0];
|
2005-07-31 20:18:38 +00:00
|
|
|
mvalo[1] = mval[1];
|
2005-08-07 21:47:08 +00:00
|
|
|
//Adjust Edgeloop
|
|
|
|
|
if(immediate){
|
|
|
|
|
perc = imperc;
|
|
|
|
|
}
|
|
|
|
|
percp = perc;
|
2005-08-10 03:51:34 +00:00
|
|
|
if(prop){
|
|
|
|
|
look = vertlist;
|
|
|
|
|
while(look){
|
|
|
|
|
EditVert *tempev;
|
|
|
|
|
ev = look->link;
|
|
|
|
|
tempsv = BLI_ghash_lookup(vertgh,ev);
|
|
|
|
|
|
|
|
|
|
tempev = editedge_getOtherVert((perc>=0)?tempsv->up:tempsv->down, ev);
|
|
|
|
|
VecLerpf(ev->co, tempsv->origvert.co, tempev->co, fabs(perc));
|
|
|
|
|
|
|
|
|
|
look = look->next;
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-08-10 03:51:34 +00:00
|
|
|
else {
|
|
|
|
|
//Non prop code
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tempsv = BLI_ghash_lookup(vertgh,nearest);
|
2005-08-07 21:47:08 +00:00
|
|
|
|
2005-08-10 03:51:34 +00:00
|
|
|
centerVert = editedge_getSharedVert(tempsv->up, tempsv->down);
|
|
|
|
|
upVert = editedge_getOtherVert(tempsv->up, centerVert);
|
|
|
|
|
downVert = editedge_getOtherVert(tempsv->down, centerVert);
|
2005-08-07 21:47:08 +00:00
|
|
|
// Highlight the Control Edges
|
|
|
|
|
|
|
|
|
|
scrarea_do_windraw(curarea);
|
|
|
|
|
persp(PERSP_VIEW);
|
|
|
|
|
glPushMatrix();
|
2005-08-10 03:51:34 +00:00
|
|
|
mymultmatrix(G.obedit->obmat);
|
2005-08-07 21:47:08 +00:00
|
|
|
|
|
|
|
|
glColor3ub(0, 255, 0);
|
2005-08-10 03:51:34 +00:00
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
glVertex3fv(upVert->co);
|
|
|
|
|
glVertex3fv(downVert->co);
|
2005-08-07 21:47:08 +00:00
|
|
|
glEnd();
|
|
|
|
|
glPopMatrix();
|
2005-08-15 04:10:02 +00:00
|
|
|
|
|
|
|
|
view3d_project_float(curarea, upVert->co, v2, projectMat);
|
|
|
|
|
view3d_project_float(curarea, downVert->co, v3, projectMat);
|
|
|
|
|
|
2005-08-10 03:51:34 +00:00
|
|
|
/* Determine the % on which the loop should be cut */
|
2005-08-07 21:47:08 +00:00
|
|
|
|
2005-08-15 04:10:02 +00:00
|
|
|
rc[0]= v3[0]-v2[0];
|
|
|
|
|
rc[1]= v3[1]-v2[1];
|
|
|
|
|
len= rc[0]*rc[0]+ rc[1]*rc[1];
|
|
|
|
|
if (len==0) {len = 0.0001;}
|
|
|
|
|
labda= ( rc[0]*(mval[0]-v2[0]) + rc[1]*(mval[1]-v2[1]) )/len;
|
2005-08-07 21:47:08 +00:00
|
|
|
|
2005-08-15 04:10:02 +00:00
|
|
|
if(labda<=0.0) labda=0.0;
|
|
|
|
|
else if(labda>=1.0)labda=1.0;
|
2005-08-07 21:47:08 +00:00
|
|
|
|
2005-08-15 04:10:02 +00:00
|
|
|
perc=((1-labda)*2)-1;
|
2005-08-07 21:47:08 +00:00
|
|
|
|
|
|
|
|
if(G.qual == 0){
|
|
|
|
|
perc *= 100;
|
|
|
|
|
perc = floor(perc);
|
|
|
|
|
perc /= 100;
|
|
|
|
|
} else if (G.qual == LR_CTRLKEY){
|
|
|
|
|
perc *= 10;
|
|
|
|
|
perc = floor(perc);
|
|
|
|
|
perc /= 10;
|
|
|
|
|
}
|
|
|
|
|
sprintf(str, "Percentage %f", perc);
|
2005-07-30 16:37:04 +00:00
|
|
|
headerprint(str);
|
2005-08-07 21:47:08 +00:00
|
|
|
screen_swapbuffers();
|
|
|
|
|
}
|
2005-08-07 23:59:34 +00:00
|
|
|
if(!immediate){
|
2005-08-07 21:47:08 +00:00
|
|
|
while(qtest()) {
|
|
|
|
|
unsigned short val=0;
|
|
|
|
|
event= extern_qread(&val); // extern_qread stores important events for the mainloop to handle
|
|
|
|
|
|
|
|
|
|
/* val==0 on key-release event */
|
2005-08-10 03:51:34 +00:00
|
|
|
if (val) {
|
|
|
|
|
if(ELEM(event, ESCKEY, RIGHTMOUSE)) {
|
|
|
|
|
perc = 0; // Set back to begining %
|
|
|
|
|
immediate = 1; //Run through eval code 1 more time
|
|
|
|
|
cancel = 1; // Return -1
|
|
|
|
|
} else if(ELEM3(event, PADENTER, LEFTMOUSE, RETKEY)) {
|
|
|
|
|
draw = 0; // End looping now
|
|
|
|
|
} else if(event==MIDDLEMOUSE) {
|
|
|
|
|
perc = 0;
|
|
|
|
|
immediate = 1;
|
|
|
|
|
} else if(ELEM(event, RIGHTARROWKEY, WHEELUPMOUSE)) { // Scroll through Control Edges
|
|
|
|
|
look = vertlist;
|
|
|
|
|
while(look){
|
|
|
|
|
if(nearest == (EditVert*)look->link){
|
|
|
|
|
if(look->next == NULL){
|
|
|
|
|
nearest = (EditVert*)vertlist->link;
|
|
|
|
|
} else {
|
|
|
|
|
nearest = (EditVert*)look->next->link;
|
|
|
|
|
}
|
2005-08-07 21:47:08 +00:00
|
|
|
mvalo[0] = -1;
|
2005-08-10 03:51:34 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
look = look->next;
|
|
|
|
|
}
|
|
|
|
|
} else if(ELEM(event, LEFTARROWKEY, WHEELDOWNMOUSE)) { // Scroll through Control Edges
|
|
|
|
|
look = vertlist;
|
|
|
|
|
while(look){
|
|
|
|
|
if(look->next){
|
|
|
|
|
if(look->next->link == nearest){
|
|
|
|
|
nearest = (EditVert*)look->link;
|
|
|
|
|
mvalo[0] = -1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if((EditVert*)vertlist->link == nearest){
|
|
|
|
|
nearest = look->link;
|
|
|
|
|
mvalo[0] = -1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
look = look->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2005-08-07 23:59:34 +00:00
|
|
|
draw = 0;
|
|
|
|
|
}
|
2005-08-07 21:47:08 +00:00
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
|
|
|
|
}
|
|
|
|
|
force_draw(0);
|
|
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
|
|
|
|
scrarea_queue_winredraw(curarea);
|
|
|
|
|
|
|
|
|
|
//BLI_ghash_free(edgesgh, freeGHash, NULL);
|
|
|
|
|
BLI_ghash_free(vertgh, NULL, (GHashValFreeFP)MEM_freeN);
|
|
|
|
|
BLI_linklist_free(vertlist,NULL);
|
|
|
|
|
BLI_linklist_free(edgelist,NULL);
|
|
|
|
|
|
|
|
|
|
if(cancel == 1){
|
2005-08-07 23:59:34 +00:00
|
|
|
return -1;
|
2005-08-07 21:47:08 +00:00
|
|
|
}
|
2005-08-07 23:59:34 +00:00
|
|
|
return 1;
|
2005-07-13 15:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------- OLD SUBDIVIDE -----------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/* ******************** SUBDIVIDE ********************************** */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void merge_weights(EditVert * vt, EditVert *vs )
|
|
|
|
|
{
|
|
|
|
|
MDeformWeight *newdw;
|
|
|
|
|
int i,j,done;
|
|
|
|
|
for (j=0; j<vs->totweight; j++){
|
|
|
|
|
done=0;
|
|
|
|
|
/* Is vertex memeber of group */
|
|
|
|
|
/* If so: Change its weight */
|
|
|
|
|
for (i=0; i<vt->totweight; i++){
|
|
|
|
|
if (vt->dw[i].def_nr == vs->dw[j].def_nr)
|
|
|
|
|
{ /* taking the maximum makes it independant from order of occurance */
|
|
|
|
|
if (vt->dw[i].weight < vs->dw[j].weight) vt->dw[i].weight = vs->dw[j].weight;
|
|
|
|
|
done=1;
|
|
|
|
|
break;
|
2004-11-10 11:14:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
/* If not: Add the group and set its weight */
|
|
|
|
|
if (!done){
|
|
|
|
|
newdw = MEM_callocN (sizeof(MDeformWeight)*(vt->totweight+1), "deformWeight");
|
|
|
|
|
if (vt->dw){
|
|
|
|
|
memcpy (newdw, vt->dw, sizeof(MDeformWeight)*vt->totweight);
|
|
|
|
|
MEM_freeN (vt->dw);
|
2004-11-10 11:14:11 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
vt->dw=newdw;
|
|
|
|
|
vt->dw[vt->totweight].weight=vs->dw[j].weight;
|
|
|
|
|
vt->dw[vt->totweight].def_nr=vs->dw[j].def_nr;
|
|
|
|
|
vt->totweight++;
|
2004-11-10 11:14:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
}
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
|
|
|
|
|
static void set_weights(EditVert * vt, EditVert *vs1,EditVert *vs2,EditVert *vs3,EditVert *vs4 )
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
vt is a new generated vertex with empty deform group information
|
|
|
|
|
vs1..v4 are egde neighbours holding group information
|
|
|
|
|
so let the information ooze into the new one
|
|
|
|
|
*/
|
|
|
|
|
if (vs1) merge_weights(vt,vs1);
|
|
|
|
|
if (vs2) merge_weights(vt,vs2);
|
|
|
|
|
if (vs3) merge_weights(vt,vs3);
|
|
|
|
|
if (vs4) merge_weights(vt,vs4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static unsigned int cpack_fact(unsigned int col1, unsigned int col2, float fact)
|
|
|
|
|
{
|
|
|
|
|
char *cp1, *cp2, *cp;
|
|
|
|
|
unsigned int col=0;
|
|
|
|
|
float facti;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
facti=1-fact; /*result is (1-fact) * col1 and fact * col2 */
|
|
|
|
|
|
|
|
|
|
cp1= (char *)&col1;
|
|
|
|
|
cp2= (char *)&col2;
|
|
|
|
|
cp= (char *)&col;
|
EditMesh refactory + undo recode
The changelog is very long... it's on the web too:
http://www.blender3d.org/cms/Mesh_editing_rewrite.425.0.html
EditMesh refactor notes (user)
**** New selection modes
When entering Edit Mode for a Mesh, you now have the choice for three selection modes. These are shown as icons in the 3D header (hotkey is being searched for!).
- Vertex Select
Select vertices as usual, fully compatible with how previous version work
- Edge Select
Vertices are not drawn anymore, and selections happen by default on the edges. It is a true edge select, meaning that you can select three out of four edges in a face, without automatic having the 4th edge selected.
- Face Select
Instead of vertices, now selection 'points' are drawn in the face centers. Selected faces also get a colored outline, like for edges. This also is true face select, for each face individual regardless selection status of its vertices or edges.
While holding SHIFT, and press a selection mode, you can also combine the above choices. Now selection becomes mixed, and will behave as expected.
For example; in Edge+Face select mode, selecting the 4 edges of a face will select the face too.
The selection modes and optional drawing modes (like transparant faces, normals, or solid drawing) all work together. All of Blender's mesh editing tools now react to the correct selection mode as well.
Most noticeable it's in:
**** Extrude
Extruding in Edge or Face Select mode allows much more precise control over what's extruded and what should be excluded. Try for example a checker pattern selection, and extrude it.
New is the fixed translation when faces are extruded. This always follows the (averaged) face normal(s) of the old face(s), enabling much easier working in 3D views . A single 'G' (Grab) or 'R' (Rotate) or 'S' (Scale) will change transform modus as usual.
**** Other things to note
- Hiding edges/faces will also behave different based on Select Mode.
- while editing, normals of faces are updated always now
- Border select (BKEY) has 2 different rules for edges; when one edge is fully inside of the border, it will only select edges that are fully inside. Otherwise it selects each edge intersecting with the border.
- in face mode, adding vertices, edges or a circle is invisible...
- "Add monkey" now works as a normal primitive (rotated and on 3d cursor)
- Mesh undo was fully recoded, hopefully solving issues now with Vertex Keys and Groups
- Going in and out of editmode was fully recoded. Especially on larger models you'll notice substantial speed gain.
**** Todo
Add 'FaceSelect mode' functionality in EditMode, including zbuffered selection, display and editing of UV texture.
EditMesh refactor notes (coder)
**** Usage of flags in general
The "->f" flags are reserved for the editmesh.c and editmesh_lib.c core functions. Actually only selection status is there now.
The "->f1" and "->f2" flags are free to use. They're available in vertex/edge/face structs. Since they're free, check carefully when calling other functions that use these flags... for example extrude() or subdivide() use them.
**** Selection flags
EditVert: eve->f & SELECT
EditEdge: eed->f & SELECT
EditFace: efa->f & SELECT
- Selection is only possible when not-hidden!
- Selection flags are always up-to-date, BUT:
if selection mode >= SELECT_EDGE vertex selection flags can be incorrect
if selection mode == SELECT_FACE vertex/edge selection flags can be incorrect
This because of shared vertices or edges.
- use for selecting vertices:
eve->f &= SELECT
- use for selecting edges always:
void EM_select_edge(eed, 1) // 1 = select, 0 = deselect
- use for selecting faces always:
void EM_select_face(efa, 1) // 1 = select, 0 = deselect
- To set the 'f' flags in all of the data:
void EM_set_flag_all(int flag);
void EM_clear_flag_all(int flag);
- the old faceselectedOR() and faceselectedAND() are still there, but only
to be used for evaluating its vertices
**** Code hints for handling selection
If the selectmode is 'face'; vertex or edge selections need to be flushed upward. Same is true for 'edge' selection mode. This means that you'll have to keep track of all selections while coding... selecting the four vertices in a face doesn't automatically select the face anymore.
However, by using the above calls, at least selections flush downward (to vertex level). You then can call:
void EM_selectmode_flush(void);
Which flushes selections back upward, based on the selectmode setting. This function does the following:
- if selectmode 'vertex': select edges/faces based on its selected vertices
- if selectmode 'edge': select faces based its selected edges
This works fine in nice controlled situations.
However, only changing the vertex selections then still doesn't select a face in face mode! If you really can't avoid only working with vertex selections, you can use this call:
void EM_select_flush(void);
Now selection is flushed upward regardless current selectmode. That can be destructive for special cases however, like checkerboard selected faces. So use this only when you know everything else was deselected (or deselect it). Example: adding primitives.
**** Hide flags
EditVert: eve->h
EditEdge: eed->h
EditFace: efa->h
- all hide flags are always up-to-date
- hidden vertices/edges/faces are always deselected. so when you operate on selection only, there's no need to check for hide flag.
**** Unified undo for editmode
New file: editmode_undo.h
A pretty nice function pointer handler style undo. Just code three functions, and your undo will fly! The c file has a good reference.
Also note that the old undo system has been replaced. It currently uses minimal dependencies on Meshes themselves (no abuse of going in/out editmode), and is restricted nicely to editmode functions.
**** Going in/out editmode
As speedup now all vertices/faces/edges are allocated in three big chunks. In vertices/faces/edges now tags are set to denote such data cannot be freed.
ALso the hashtable (lookup) for edges uses no mallocs at all anymore, but is part of the EditEdge itself.
2004-09-23 20:52:51 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
cp[0]= (char)(facti*cp1[0]+fact*cp2[0]);
|
|
|
|
|
cp[1]= (char)(facti*cp1[1]+fact*cp2[1]);
|
|
|
|
|
cp[2]= (char)(facti*cp1[2]+fact*cp2[2]);
|
|
|
|
|
cp[3]= (char)(facti*cp1[3]+fact*cp2[3]);
|
|
|
|
|
|
|
|
|
|
return col;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static void uv_half(float *uv, float *uv1, float *uv2)
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
{
|
2005-07-13 15:20:40 +00:00
|
|
|
uv[0]= (uv1[0]+uv2[0])/2.0f;
|
|
|
|
|
uv[1]= (uv1[1]+uv2[1])/2.0f;
|
|
|
|
|
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static void uv_fact(float *uv, float *uv1, float *uv2, float fact)
|
|
|
|
|
{
|
|
|
|
|
float facti = 1.0f - fact;
|
|
|
|
|
uv[0] = facti * uv1[0] + fact * uv2[0];
|
|
|
|
|
uv[1] = facti * uv1[1] + fact * uv2[1];
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static void uv_quart(float *uv, float *uv1)
|
|
|
|
|
{
|
|
|
|
|
uv[0]= (uv1[0]+uv1[2]+uv1[4]+uv1[6])/4.0f;
|
|
|
|
|
uv[1]= (uv1[1]+uv1[3]+uv1[5]+uv1[7])/4.0f;
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static void face_pin_vertex(EditFace *efa, EditVert *vertex)
|
|
|
|
|
{
|
|
|
|
|
if(efa->v1 == vertex) efa->tf.unwrap |= TF_PIN1;
|
|
|
|
|
else if(efa->v2 == vertex) efa->tf.unwrap |= TF_PIN2;
|
|
|
|
|
else if(efa->v3 == vertex) efa->tf.unwrap |= TF_PIN3;
|
|
|
|
|
else if(efa->v4 && vertex && efa->v4 == vertex) efa->tf.unwrap |= TF_PIN4;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static int vert_offset(EditFace *efa, EditVert *eve)
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
{
|
2005-07-13 15:20:40 +00:00
|
|
|
if (efa->v1 == eve)
|
|
|
|
|
return 0;
|
|
|
|
|
if (efa->v2 == eve)
|
|
|
|
|
return 1;
|
|
|
|
|
if (efa->v3 == eve)
|
|
|
|
|
return 2;
|
|
|
|
|
if (efa->v4)
|
|
|
|
|
if (efa->v4 == eve)
|
|
|
|
|
return 3;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static void set_wuv(int tot, EditFace *efa, int v1, int v2, int v3, int v4, EditFace *efapin)
|
|
|
|
|
{
|
|
|
|
|
/* this weird function only to be used for subdivide, the 'w' in the name has no meaning! */
|
|
|
|
|
float *uv, uvo[4][2];
|
|
|
|
|
unsigned int *col, colo[4], col1, col2;
|
|
|
|
|
int a, v;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* recover pinning */
|
|
|
|
|
if(efapin){
|
|
|
|
|
efa->tf.unwrap= 0;
|
|
|
|
|
if(efapin->tf.unwrap & TF_PIN1) face_pin_vertex(efa, efapin->v1);
|
|
|
|
|
if(efapin->tf.unwrap & TF_PIN2) face_pin_vertex(efa, efapin->v2);
|
|
|
|
|
if(efapin->tf.unwrap & TF_PIN3) face_pin_vertex(efa, efapin->v3);
|
|
|
|
|
if(efapin->tf.unwrap & TF_PIN4) face_pin_vertex(efa, efapin->v4);
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
memcpy(uvo, efa->tf.uv, sizeof(uvo));
|
|
|
|
|
uv= efa->tf.uv[0];
|
|
|
|
|
memcpy(colo, efa->tf.col, sizeof(colo));
|
|
|
|
|
col= efa->tf.col;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/*
|
|
|
|
|
Quads and Triangles reuse the same cases numbers, so we migh as well do both in the
|
|
|
|
|
same loop. Especially now that the offsets are calculated and not hardcoded, it's
|
|
|
|
|
much easier to reduce the code size (and make it less buggy).
|
|
|
|
|
*/
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* ******************************************** */
|
2005-08-07 21:47:08 +00:00
|
|
|
/* */
|
2005-07-13 15:20:40 +00:00
|
|
|
/* Numbers corespond to verts (corner points), */
|
2005-08-07 21:47:08 +00:00
|
|
|
/* edge->vn's (center edges), the Center */
|
|
|
|
|
/* And the quincunx points of a face */
|
|
|
|
|
/* */
|
2005-07-13 15:20:40 +00:00
|
|
|
/* ******************************************** */
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* ******************************************** */
|
2005-08-07 21:47:08 +00:00
|
|
|
/* as shown here for quads: */
|
|
|
|
|
/* */
|
|
|
|
|
/* 2 ------- 5 -------- 1 */
|
|
|
|
|
/* | \ / | \ / | */
|
|
|
|
|
/* | 10 | 13 | */
|
|
|
|
|
/* | / \ | / \ | */
|
|
|
|
|
/* 6 ------- 9 -------- 8 */
|
|
|
|
|
/* | \ / | \ / | */
|
|
|
|
|
/* | 11 | 12 | */
|
|
|
|
|
/* | / \ | / \ | */
|
|
|
|
|
/* 3 ------- 7 -------- 4 */
|
|
|
|
|
/* */
|
2005-07-13 15:20:40 +00:00
|
|
|
/* ******************************************** */
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* ******************************************** */
|
2005-08-07 21:47:08 +00:00
|
|
|
/* and for triangles: */
|
|
|
|
|
/* 1 */
|
|
|
|
|
/* / \ */
|
|
|
|
|
/* / \ */
|
|
|
|
|
/* 5 7 */
|
|
|
|
|
/* / \ */
|
|
|
|
|
/* / \ */
|
|
|
|
|
/* 2 --------- 6 -------- 3 */
|
|
|
|
|
/* */
|
2005-07-13 15:20:40 +00:00
|
|
|
/* ******************************************** */
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* ******************************************** */
|
2005-08-07 21:47:08 +00:00
|
|
|
/* */
|
2005-07-13 15:20:40 +00:00
|
|
|
/* My talents in ascii arts are minimal so the */
|
|
|
|
|
/* drawings don't show all possible subdivision */
|
2005-08-07 21:47:08 +00:00
|
|
|
/* just draw them on paper if you need to. */
|
|
|
|
|
/* */
|
2005-07-13 15:20:40 +00:00
|
|
|
/* ******************************************** */
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
for(a=0; a<tot; a++, uv+=2, col++) {
|
|
|
|
|
/* edges that are subdivided, if any */
|
|
|
|
|
EditEdge *e1 = NULL, *e2 = NULL;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
if(a==0) v= v1;
|
|
|
|
|
else if(a==1) v= v2;
|
|
|
|
|
else if(a==2) v= v3;
|
|
|
|
|
else v= v4;
|
|
|
|
|
|
|
|
|
|
if(a==3 && v4==0) break;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
switch (v) {
|
|
|
|
|
/* Face corners, direct copy of the UVs and VCol */
|
|
|
|
|
case 1:
|
|
|
|
|
case 2:
|
|
|
|
|
case 3:
|
|
|
|
|
case 4:
|
|
|
|
|
uv[0]= uvo[v-1][0];
|
|
|
|
|
uv[1]= uvo[v-1][1];
|
|
|
|
|
*col= colo[v-1];
|
|
|
|
|
break;
|
|
|
|
|
/* Face sides (cutting an edge) */
|
|
|
|
|
/*
|
|
|
|
|
set the edge pointer accordingly, it's used latter to do the
|
|
|
|
|
actual calculations of the new UV and VCol
|
|
|
|
|
*/
|
|
|
|
|
case 5:
|
|
|
|
|
e1 = efapin->e1;
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
e1 = efapin->e2;
|
|
|
|
|
break;
|
|
|
|
|
case 7:
|
|
|
|
|
e1 = efapin->e3;
|
|
|
|
|
break;
|
|
|
|
|
case 8:
|
|
|
|
|
e1 = efapin->e4;
|
|
|
|
|
break;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* The following applies to Quads only */
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* Quad middle, just used when subdividing a quad as a whole */
|
|
|
|
|
/* (not knife nor loop cut) */
|
|
|
|
|
/* UVs and VCol is just the average of the four corners */
|
|
|
|
|
case 9:
|
|
|
|
|
uv_quart(uv, uvo[0]);
|
|
|
|
|
col1= cpack_fact(colo[1], colo[0], 0.5f);
|
|
|
|
|
col2= cpack_fact(colo[2], colo[3], 0.5f);
|
|
|
|
|
*col= cpack_fact(col1, col2, 0.5f);
|
|
|
|
|
break;
|
|
|
|
|
/* Quad corner cuts */
|
|
|
|
|
/* only when two adjacent edges are subdivided (and no others) */
|
|
|
|
|
/* Set both edge pointers accordingly, used later for calculations */
|
|
|
|
|
case 10: // case test==3 in subdivideflag()
|
|
|
|
|
e1 = efapin->e1;
|
|
|
|
|
e2 = efapin->e2;
|
|
|
|
|
break;
|
|
|
|
|
case 11: // case of test==6
|
|
|
|
|
e1 = efapin->e2;
|
|
|
|
|
e2 = efapin->e3;
|
|
|
|
|
break;
|
|
|
|
|
case 12: // case of test==12
|
|
|
|
|
e1 = efapin->e3;
|
|
|
|
|
e2 = efapin->e4;
|
|
|
|
|
break;
|
|
|
|
|
case 13: // case of test==9
|
|
|
|
|
e1 = efapin->e4;
|
|
|
|
|
e2 = efapin->e1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
/* if splitting at least an edge */
|
|
|
|
|
if (e1) {
|
|
|
|
|
float percent;
|
|
|
|
|
int off1, off2;
|
|
|
|
|
/* if splitting two edges */
|
|
|
|
|
if (e2) {
|
|
|
|
|
float uv1[2], uv2[2];
|
|
|
|
|
/*
|
|
|
|
|
UV and VCol is obtained by using the middle ground of the weighted
|
|
|
|
|
average for both edges (weighted with Percent cut flag).
|
|
|
|
|
In a nutshell, the average of the cuts on both edges.
|
|
|
|
|
*/
|
|
|
|
|
/* first cut */
|
|
|
|
|
off1 = vert_offset(efapin, e1->v1);
|
|
|
|
|
off2 = vert_offset(efapin, e1->v2);
|
|
|
|
|
percent = e1->f1 / 32768.0f;
|
|
|
|
|
uv_fact(uv1, uvo[off1], uvo[off2], percent);
|
|
|
|
|
col1= cpack_fact(colo[off1], colo[off2], percent);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* second cut */
|
|
|
|
|
off1 = vert_offset(efapin, e2->v1);
|
|
|
|
|
off2 = vert_offset(efapin, e2->v2);
|
|
|
|
|
percent = e2->f1 / 32768.0f;
|
|
|
|
|
uv_fact(uv2, uvo[off1], uvo[off2], percent);
|
|
|
|
|
col2= cpack_fact(colo[off1], colo[off1], percent);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* average the two */
|
|
|
|
|
uv_half(uv, uv1, uv2);
|
|
|
|
|
*col= cpack_fact(col1, col2, 0.5f);
|
|
|
|
|
}
|
|
|
|
|
/* or only one */
|
|
|
|
|
else {
|
|
|
|
|
/*
|
|
|
|
|
UV and VCol is obtained by using the weighted average
|
|
|
|
|
of both vertice (weighted with Percent cut flag).
|
|
|
|
|
*/
|
|
|
|
|
off1 = vert_offset(efapin, e1->v1);
|
|
|
|
|
off2 = vert_offset(efapin, e1->v2);
|
|
|
|
|
percent = e1->f1 / 32768.0f;
|
|
|
|
|
uv_fact(uv, uvo[off1], uvo[off2], percent);
|
|
|
|
|
*col= cpack_fact(colo[off1], colo[off2], percent);
|
|
|
|
|
}
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static EditVert *vert_from_number(EditFace *efa, int nr)
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
{
|
2005-07-13 15:20:40 +00:00
|
|
|
switch(nr) {
|
|
|
|
|
case 0:
|
|
|
|
|
return 0;
|
|
|
|
|
case 1:
|
|
|
|
|
return efa->v1;
|
|
|
|
|
case 2:
|
|
|
|
|
return efa->v2;
|
|
|
|
|
case 3:
|
|
|
|
|
return efa->v3;
|
|
|
|
|
case 4:
|
|
|
|
|
return efa->v4;
|
|
|
|
|
case 5:
|
|
|
|
|
return efa->e1->vn;
|
|
|
|
|
case 6:
|
|
|
|
|
return efa->e2->vn;
|
|
|
|
|
case 7:
|
|
|
|
|
return efa->e3->vn;
|
|
|
|
|
case 8:
|
|
|
|
|
return efa->e4->vn;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
|
|
|
|
|
return NULL;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static void addface_subdiv(EditFace *efa, int val1, int val2, int val3, int val4, EditVert *eve, EditFace *efapin)
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
{
|
2005-07-13 15:20:40 +00:00
|
|
|
EditFace *w;
|
|
|
|
|
EditVert *v1, *v2, *v3, *v4;
|
|
|
|
|
|
|
|
|
|
if(val1>=9) v1= eve;
|
|
|
|
|
else v1= vert_from_number(efa, val1);
|
|
|
|
|
|
|
|
|
|
if(val2>=9) v2= eve;
|
|
|
|
|
else v2= vert_from_number(efa, val2);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
if(val3>=9) v3= eve;
|
|
|
|
|
else v3= vert_from_number(efa, val3);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
if(val4>=9) v4= eve;
|
|
|
|
|
else v4= vert_from_number(efa, val4);
|
|
|
|
|
|
|
|
|
|
w= addfacelist(v1, v2, v3, v4, efa, NULL);
|
|
|
|
|
if(w) {
|
|
|
|
|
if(efa->v4) set_wuv(4, w, val1, val2, val3, val4, efapin);
|
|
|
|
|
else set_wuv(3, w, val1, val2, val3, val4, efapin);
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static float smoothperc= 0.0;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static void smooth_subdiv_vec(float *v1, float *v2, float *n1, float *n2, float *vec)
|
|
|
|
|
{
|
|
|
|
|
float len, fac, nor[3], nor1[3], nor2[3];
|
|
|
|
|
|
|
|
|
|
VecSubf(nor, v1, v2);
|
|
|
|
|
len= 0.5f*Normalise(nor);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
VECCOPY(nor1, n1);
|
|
|
|
|
VECCOPY(nor2, n2);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* cosine angle */
|
|
|
|
|
fac= nor[0]*nor1[0] + nor[1]*nor1[1] + nor[2]*nor1[2] ;
|
|
|
|
|
|
|
|
|
|
vec[0]= fac*nor1[0];
|
|
|
|
|
vec[1]= fac*nor1[1];
|
|
|
|
|
vec[2]= fac*nor1[2];
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* cosine angle */
|
|
|
|
|
fac= -nor[0]*nor2[0] - nor[1]*nor2[1] - nor[2]*nor2[2] ;
|
|
|
|
|
|
|
|
|
|
vec[0]+= fac*nor2[0];
|
|
|
|
|
vec[1]+= fac*nor2[1];
|
|
|
|
|
vec[2]+= fac*nor2[2];
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
vec[0]*= smoothperc*len;
|
|
|
|
|
vec[1]*= smoothperc*len;
|
|
|
|
|
vec[2]*= smoothperc*len;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
static void smooth_subdiv_quad(EditFace *efa, float *vec)
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
{
|
2005-07-13 15:20:40 +00:00
|
|
|
|
|
|
|
|
float nor1[3], nor2[3];
|
|
|
|
|
float vec1[3], vec2[3];
|
|
|
|
|
float cent[3];
|
|
|
|
|
|
|
|
|
|
/* vlr->e1->vn is new vertex inbetween v1 / v2 */
|
|
|
|
|
|
|
|
|
|
VecMidf(nor1, efa->v1->no, efa->v2->no);
|
|
|
|
|
Normalise(nor1);
|
|
|
|
|
VecMidf(nor2, efa->v3->no, efa->v4->no);
|
|
|
|
|
Normalise(nor2);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
smooth_subdiv_vec( efa->e1->vn->co, efa->e3->vn->co, nor1, nor2, vec1);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
VecMidf(nor1, efa->v2->no, efa->v3->no);
|
|
|
|
|
Normalise(nor1);
|
|
|
|
|
VecMidf(nor2, efa->v4->no, efa->v1->no);
|
|
|
|
|
Normalise(nor2);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
smooth_subdiv_vec( efa->e2->vn->co, efa->e4->vn->co, nor1, nor2, vec2);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
VecAddf(vec1, vec1, vec2);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
CalcCent4f(cent, efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co);
|
|
|
|
|
VecAddf(vec, cent, vec1);
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
void subdivideflag(int flag, float rad, int beauty)
|
|
|
|
|
{
|
|
|
|
|
EditMesh *em = G.editMesh;
|
|
|
|
|
/* subdivide all with (vertflag & flag) */
|
|
|
|
|
/* if rad>0.0 it's a 'sphere' subdivide */
|
|
|
|
|
/* if rad<0.0 it's a fractal subdivide */
|
|
|
|
|
extern float doublimit;
|
|
|
|
|
EditVert *eve;
|
|
|
|
|
EditEdge *eed, *e1, *e2, *e3, *e4, *nexted;
|
|
|
|
|
EditFace *efa, efapin;
|
|
|
|
|
float fac, vec[3], vec1[3], len1, len2, len3, percent;
|
|
|
|
|
short test;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
if(beauty & B_SMOOTH) {
|
|
|
|
|
short perc= 100;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
if(button(&perc, 10, 500, "Percentage:")==0) return;
|
|
|
|
|
|
|
|
|
|
smoothperc= 0.292f*perc/100.0f;
|
|
|
|
|
}
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* edgeflags */
|
|
|
|
|
if((beauty & B_KNIFE)==0) { // knife option sets own flags
|
|
|
|
|
eed= em->edges.first;
|
|
|
|
|
while(eed) {
|
|
|
|
|
if( (eed->v1->f & flag) && (eed->v2->f & flag) ) eed->f2= flag;
|
|
|
|
|
else eed->f2= 0;
|
|
|
|
|
eed= eed->next;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* if beauty: test for area and clear edge flags of 'ugly' edges */
|
|
|
|
|
if(beauty & B_BEAUTY) {
|
|
|
|
|
efa= em->faces.first;
|
|
|
|
|
while(efa) {
|
|
|
|
|
if( faceselectedAND(efa, flag) ) {
|
|
|
|
|
if(efa->v4) {
|
|
|
|
|
|
|
|
|
|
/* area */
|
|
|
|
|
len1= AreaQ3Dfl(efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co);
|
|
|
|
|
if(len1 <= doublimit) {
|
|
|
|
|
efa->e1->f2 = 0;
|
|
|
|
|
efa->e2->f2 = 0;
|
|
|
|
|
efa->e3->f2 = 0;
|
|
|
|
|
efa->e4->f2 = 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
len1= VecLenf(efa->v1->co, efa->v2->co) + VecLenf(efa->v3->co, efa->v4->co);
|
|
|
|
|
len2= VecLenf(efa->v2->co, efa->v3->co) + VecLenf(efa->v1->co, efa->v4->co);
|
|
|
|
|
|
|
|
|
|
if(len1 < len2) {
|
|
|
|
|
efa->e1->f2 = 0;
|
|
|
|
|
efa->e3->f2 = 0;
|
|
|
|
|
}
|
|
|
|
|
else if(len1 > len2) {
|
|
|
|
|
efa->e2->f2 = 0;
|
|
|
|
|
efa->e4->f2 = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* area */
|
|
|
|
|
len1= AreaT3Dfl(efa->v1->co, efa->v2->co, efa->v3->co);
|
|
|
|
|
if(len1 <= doublimit) {
|
|
|
|
|
efa->e1->f2 = 0;
|
|
|
|
|
efa->e2->f2 = 0;
|
|
|
|
|
efa->e3->f2 = 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
len1= VecLenf(efa->v1->co, efa->v2->co) ;
|
|
|
|
|
len2= VecLenf(efa->v2->co, efa->v3->co) ;
|
|
|
|
|
len3= VecLenf(efa->v3->co, efa->v1->co) ;
|
|
|
|
|
|
|
|
|
|
if(len1<len2 && len1<len3) {
|
|
|
|
|
efa->e1->f2 = 0;
|
|
|
|
|
}
|
|
|
|
|
else if(len2<len3 && len2<len1) {
|
|
|
|
|
efa->e2->f2 = 0;
|
|
|
|
|
}
|
|
|
|
|
else if(len3<len2 && len3<len1) {
|
|
|
|
|
efa->e3->f2 = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
efa= efa->next;
|
2004-09-26 18:33:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* make new normal and put in edge, clear flag! needed for face creation part below */
|
|
|
|
|
eed= em->edges.first;
|
|
|
|
|
while(eed) {
|
|
|
|
|
if(eed->f2 & flag) {
|
|
|
|
|
/* for now */
|
|
|
|
|
eed->h &= ~EM_FGON;
|
|
|
|
|
|
|
|
|
|
/* Subdivide percentage is stored in 1/32768ths in eed->f1 */
|
|
|
|
|
if (beauty & B_PERCENTSUBD) percent=(float)(eed->f1)/32768.0f;
|
|
|
|
|
else {
|
|
|
|
|
eed->f1 = 32768 / 2;
|
|
|
|
|
percent=0.5f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vec[0]= (1-percent)*eed->v1->co[0] + percent*eed->v2->co[0];
|
|
|
|
|
vec[1]= (1-percent)*eed->v1->co[1] + percent*eed->v2->co[1];
|
|
|
|
|
vec[2]= (1-percent)*eed->v1->co[2] + percent*eed->v2->co[2];
|
|
|
|
|
|
|
|
|
|
if(rad > 0.0) { /* subdivide sphere */
|
|
|
|
|
Normalise(vec);
|
|
|
|
|
vec[0]*= rad;
|
|
|
|
|
vec[1]*= rad;
|
|
|
|
|
vec[2]*= rad;
|
|
|
|
|
}
|
|
|
|
|
else if(rad< 0.0) { /* fractal subdivide */
|
|
|
|
|
fac= rad* VecLenf(eed->v1->co, eed->v2->co);
|
|
|
|
|
vec1[0]= fac*(float)(0.5-BLI_drand());
|
|
|
|
|
vec1[1]= fac*(float)(0.5-BLI_drand());
|
|
|
|
|
vec1[2]= fac*(float)(0.5-BLI_drand());
|
|
|
|
|
VecAddf(vec, vec, vec1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(beauty & B_SMOOTH) {
|
|
|
|
|
smooth_subdiv_vec(eed->v1->co, eed->v2->co, eed->v1->no, eed->v2->no, vec1);
|
|
|
|
|
VecAddf(vec, vec, vec1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eed->vn= addvertlist(vec);
|
|
|
|
|
eed->vn->f= eed->v1->f;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
else eed->vn= 0;
|
|
|
|
|
|
|
|
|
|
eed->f2= 0; /* needed! */
|
|
|
|
|
|
|
|
|
|
eed= eed->next;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* test all faces for subdivide edges, there are 8 or 16 cases (ugh)! */
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
efa= em->faces.last;
|
|
|
|
|
while(efa) {
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
efapin= *efa; /* make a copy of efa to recover uv pinning later */
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
if( faceselectedOR(efa, flag) ) {
|
|
|
|
|
/* for now */
|
|
|
|
|
efa->fgonf= 0;
|
|
|
|
|
|
|
|
|
|
e1= efa->e1;
|
|
|
|
|
e2= efa->e2;
|
|
|
|
|
e3= efa->e3;
|
|
|
|
|
e4= efa->e4;
|
|
|
|
|
|
|
|
|
|
test= 0;
|
|
|
|
|
if(e1 && e1->vn) {
|
|
|
|
|
test+= 1;
|
|
|
|
|
e1->f2= 1;
|
|
|
|
|
/* add edges here, to copy correct edge data */
|
|
|
|
|
eed= addedgelist(e1->v1, e1->vn, e1);
|
|
|
|
|
eed= addedgelist(e1->vn, e1->v2, e1);
|
|
|
|
|
set_weights(e1->vn, e1->v1,e1->v2,NULL,NULL);
|
|
|
|
|
}
|
|
|
|
|
if(e2 && e2->vn) {
|
|
|
|
|
test+= 2;
|
|
|
|
|
e2->f2= 1;
|
|
|
|
|
/* add edges here, to copy correct edge data */
|
|
|
|
|
eed= addedgelist(e2->v1, e2->vn, e2);
|
|
|
|
|
eed= addedgelist(e2->vn, e2->v2, e2);
|
|
|
|
|
set_weights(e2->vn, e2->v1,e2->v2,NULL,NULL);
|
|
|
|
|
}
|
|
|
|
|
if(e3 && e3->vn) {
|
|
|
|
|
test+= 4;
|
|
|
|
|
e3->f2= 1;
|
|
|
|
|
/* add edges here, to copy correct edge data */
|
|
|
|
|
eed= addedgelist(e3->v1, e3->vn, e3);
|
|
|
|
|
eed= addedgelist(e3->vn, e3->v2, e3);
|
|
|
|
|
set_weights(e3->vn, e3->v1,e3->v2,NULL,NULL);
|
|
|
|
|
}
|
|
|
|
|
if(e4 && e4->vn) {
|
|
|
|
|
test+= 8;
|
|
|
|
|
e4->f2= 1;
|
|
|
|
|
/* add edges here, to copy correct edge data */
|
|
|
|
|
eed= addedgelist(e4->v1, e4->vn, e4);
|
|
|
|
|
eed= addedgelist(e4->vn, e4->v2, e4);
|
|
|
|
|
set_weights(e4->vn, e4->v1,e4->v2,NULL,NULL);
|
|
|
|
|
}
|
|
|
|
|
if(test) {
|
|
|
|
|
if(efa->v4==0) { /* All the permutations of 3 edges*/
|
|
|
|
|
if((test & 3)==3) addface_subdiv(efa, 2, 2+4, 1+4, 0, 0, &efapin);
|
|
|
|
|
if((test & 6)==6) addface_subdiv(efa, 3, 3+4, 2+4, 0, 0, &efapin);
|
|
|
|
|
if((test & 5)==5) addface_subdiv(efa, 1, 1+4, 3+4, 0, 0, &efapin);
|
|
|
|
|
|
|
|
|
|
if(test==7) { /* four new faces, old face renews */
|
|
|
|
|
efa->v1= e1->vn;
|
|
|
|
|
efa->v2= e2->vn;
|
|
|
|
|
efa->v3= e3->vn;
|
|
|
|
|
set_wuv(3, efa, 1+4, 2+4, 3+4, 0, &efapin);
|
|
|
|
|
}
|
|
|
|
|
else if(test==3) {
|
|
|
|
|
addface_subdiv(efa, 1+4, 2+4, 3, 0, 0, &efapin);
|
|
|
|
|
efa->v2= e1->vn;
|
|
|
|
|
set_wuv(3, efa, 1, 1+4, 3, 0, &efapin);
|
|
|
|
|
}
|
|
|
|
|
else if(test==6) {
|
|
|
|
|
addface_subdiv(efa, 2+4, 3+4, 1, 0, 0, &efapin);
|
|
|
|
|
efa->v3= e2->vn;
|
|
|
|
|
set_wuv(3, efa, 1, 2, 2+4, 0, &efapin);
|
|
|
|
|
}
|
|
|
|
|
else if(test==5) {
|
|
|
|
|
addface_subdiv(efa, 3+4, 1+4, 2, 0, 0, &efapin);
|
|
|
|
|
efa->v1= e3->vn;
|
|
|
|
|
set_wuv(3, efa, 3+4, 2, 3, 0, &efapin);
|
|
|
|
|
}
|
|
|
|
|
else if(test==1) {
|
|
|
|
|
addface_subdiv(efa, 1+4, 2, 3, 0, 0, &efapin);
|
|
|
|
|
efa->v2= e1->vn;
|
|
|
|
|
set_wuv(3, efa, 1, 1+4, 3, 0, &efapin);
|
|
|
|
|
}
|
|
|
|
|
else if(test==2) {
|
|
|
|
|
addface_subdiv(efa, 2+4, 3, 1, 0, 0, &efapin);
|
|
|
|
|
efa->v3= e2->vn;
|
|
|
|
|
set_wuv(3, efa, 1, 2, 2+4, 0, &efapin);
|
|
|
|
|
}
|
|
|
|
|
else if(test==4) {
|
|
|
|
|
addface_subdiv(efa, 3+4, 1, 2, 0, 0, &efapin);
|
|
|
|
|
efa->v1= e3->vn;
|
|
|
|
|
set_wuv(3, efa, 3+4, 2, 3, 0, &efapin);
|
|
|
|
|
}
|
|
|
|
|
efa->e1= addedgelist(efa->v1, efa->v2, NULL);
|
|
|
|
|
efa->e2= addedgelist(efa->v2, efa->v3, NULL);
|
|
|
|
|
efa->e3= addedgelist(efa->v3, efa->v1, NULL);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
}
|
|
|
|
|
else { /* All the permutations of 4 faces */
|
|
|
|
|
if(test==15) {
|
|
|
|
|
/* add a new point in center */
|
|
|
|
|
CalcCent4f(vec, efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
if(beauty & B_SMOOTH) {
|
|
|
|
|
smooth_subdiv_quad(efa, vec); /* adds */
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
eve= addvertlist(vec);
|
|
|
|
|
set_weights(eve, efa->v1,efa->v2,efa->v3,efa->v4);
|
|
|
|
|
eve->f |= flag;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
addface_subdiv(efa, 2, 2+4, 9, 1+4, eve, &efapin);
|
|
|
|
|
addface_subdiv(efa, 3, 3+4, 9, 2+4, eve, &efapin);
|
|
|
|
|
addface_subdiv(efa, 4, 4+4, 9, 3+4, eve, &efapin);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
efa->v2= e1->vn;
|
|
|
|
|
efa->v3= eve;
|
|
|
|
|
efa->v4= e4->vn;
|
|
|
|
|
set_wuv(4, efa, 1, 1+4, 9, 4+4, &efapin);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
else {
|
|
|
|
|
if(((test & 3)==3)&&(test!=3)) addface_subdiv(efa, 1+4, 2, 2+4, 0, 0, &efapin);
|
|
|
|
|
if(((test & 6)==6)&&(test!=6)) addface_subdiv(efa, 2+4, 3, 3+4, 0, 0, &efapin);
|
|
|
|
|
if(((test & 12)==12)&&(test!=12)) addface_subdiv(efa, 3+4, 4, 4+4, 0, 0, &efapin);
|
|
|
|
|
if(((test & 9)==9)&&(test!=9)) addface_subdiv(efa, 4+4, 1, 1+4, 0, 0, &efapin);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
if(test==1) { /* Edge 1 has new vert */
|
|
|
|
|
addface_subdiv(efa, 1+4, 2, 3, 0, 0, &efapin);
|
|
|
|
|
addface_subdiv(efa, 1+4, 3, 4, 0, 0, &efapin);
|
|
|
|
|
efa->v2= e1->vn;
|
|
|
|
|
efa->v3= efa->v4;
|
|
|
|
|
efa->v4= 0;
|
|
|
|
|
set_wuv(4, efa, 1, 1+4, 4, 0, &efapin);
|
|
|
|
|
}
|
|
|
|
|
else if(test==2) { /* Edge 2 has new vert */
|
|
|
|
|
addface_subdiv(efa, 2+4, 3, 4, 0, 0, &efapin);
|
|
|
|
|
addface_subdiv(efa, 2+4, 4, 1, 0, 0, &efapin);
|
|
|
|
|
efa->v3= e2->vn;
|
|
|
|
|
efa->v4= 0;
|
|
|
|
|
set_wuv(4, efa, 1, 2, 2+4, 0, &efapin);
|
|
|
|
|
}
|
|
|
|
|
else if(test==4) { /* Edge 3 has new vert */
|
|
|
|
|
addface_subdiv(efa, 3+4, 4, 1, 0, 0, &efapin);
|
|
|
|
|
addface_subdiv(efa, 3+4, 1, 2, 0, 0, &efapin);
|
|
|
|
|
efa->v1= efa->v2;
|
|
|
|
|
efa->v2= efa->v3;
|
|
|
|
|
efa->v3= e3->vn;
|
|
|
|
|
efa->v4= 0;
|
|
|
|
|
set_wuv(4, efa, 2, 3, 3+4, 0, &efapin);
|
|
|
|
|
}
|
|
|
|
|
else if(test==8) { /* Edge 4 has new vert */
|
|
|
|
|
addface_subdiv(efa, 4+4, 1, 2, 0, 0, &efapin);
|
|
|
|
|
addface_subdiv(efa, 4+4, 2, 3, 0, 0, &efapin);
|
|
|
|
|
efa->v1= efa->v3;
|
|
|
|
|
efa->v2= efa->v4;
|
|
|
|
|
efa->v3= e4->vn;
|
|
|
|
|
efa->v4= 0;
|
|
|
|
|
set_wuv(4, efa, 3, 4, 4+4, 0, &efapin);
|
|
|
|
|
}
|
|
|
|
|
else if(test==3) { /*edge 1&2 */
|
|
|
|
|
/* make new vert in center of new edge */
|
|
|
|
|
vec[0]=(e1->vn->co[0]+e2->vn->co[0])/2;
|
|
|
|
|
vec[1]=(e1->vn->co[1]+e2->vn->co[1])/2;
|
|
|
|
|
vec[2]=(e1->vn->co[2]+e2->vn->co[2])/2;
|
|
|
|
|
eve= addvertlist(vec);
|
|
|
|
|
set_weights(eve, e1->vn,e2->vn,NULL,NULL);
|
|
|
|
|
eve->f |= flag;
|
|
|
|
|
/* Add new faces */
|
|
|
|
|
addface_subdiv(efa, 4, 10, 2+4, 3, eve, &efapin);
|
|
|
|
|
addface_subdiv(efa, 4, 1, 1+4, 10, eve, &efapin);
|
|
|
|
|
/* orig face becomes small corner */
|
|
|
|
|
efa->v1=e1->vn;
|
|
|
|
|
//efa->v2=efa->v2;
|
|
|
|
|
efa->v3=e2->vn;
|
|
|
|
|
efa->v4=eve;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
set_wuv(4, efa, 1+4, 2, 2+4, 10, &efapin);
|
|
|
|
|
}
|
|
|
|
|
else if(test==6) { /* 2&3 */
|
|
|
|
|
/* make new vert in center of new edge */
|
|
|
|
|
vec[0]=(e2->vn->co[0]+e3->vn->co[0])/2;
|
|
|
|
|
vec[1]=(e2->vn->co[1]+e3->vn->co[1])/2;
|
|
|
|
|
vec[2]=(e2->vn->co[2]+e3->vn->co[2])/2;
|
|
|
|
|
eve= addvertlist(vec);
|
|
|
|
|
set_weights(eve, e2->vn,e3->vn,NULL,NULL);
|
|
|
|
|
eve->f |= flag;
|
|
|
|
|
/*New faces*/
|
|
|
|
|
addface_subdiv(efa, 1, 11, 3+4, 4, eve, &efapin);
|
|
|
|
|
addface_subdiv(efa, 1, 2, 2+4, 11, eve, &efapin);
|
|
|
|
|
/* orig face becomes small corner */
|
|
|
|
|
efa->v1=e2->vn;
|
|
|
|
|
efa->v2=efa->v3;
|
|
|
|
|
efa->v3=e3->vn;
|
|
|
|
|
efa->v4=eve;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
set_wuv(4, efa, 2+4, 3, 3+4, 11, &efapin);
|
|
|
|
|
}
|
|
|
|
|
else if(test==12) { /* 3&4 */
|
|
|
|
|
/* make new vert in center of new edge */
|
|
|
|
|
vec[0]=(e3->vn->co[0]+e4->vn->co[0])/2;
|
|
|
|
|
vec[1]=(e3->vn->co[1]+e4->vn->co[1])/2;
|
|
|
|
|
vec[2]=(e3->vn->co[2]+e4->vn->co[2])/2;
|
|
|
|
|
eve= addvertlist(vec);
|
|
|
|
|
set_weights(eve, e3->vn,e4->vn,NULL,NULL);
|
|
|
|
|
eve->f |= flag;
|
|
|
|
|
/*New Faces*/
|
|
|
|
|
addface_subdiv(efa, 2, 12, 4+4, 1, eve, &efapin);
|
|
|
|
|
addface_subdiv(efa, 2, 3, 3+4, 12, eve, &efapin);
|
|
|
|
|
/* orig face becomes small corner */
|
|
|
|
|
efa->v1=e3->vn;
|
|
|
|
|
efa->v2=efa->v4;
|
|
|
|
|
efa->v3=e4->vn;
|
|
|
|
|
efa->v4=eve;
|
|
|
|
|
|
|
|
|
|
set_wuv(4, efa, 3+4, 4, 4+4, 12, &efapin);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
else if(test==9) { /* 4&1 */
|
|
|
|
|
/* make new vert in center of new edge */
|
|
|
|
|
vec[0]=(e1->vn->co[0]+e4->vn->co[0])/2;
|
|
|
|
|
vec[1]=(e1->vn->co[1]+e4->vn->co[1])/2;
|
|
|
|
|
vec[2]=(e1->vn->co[2]+e4->vn->co[2])/2;
|
|
|
|
|
eve= addvertlist(vec);
|
|
|
|
|
set_weights(eve, e1->vn,e4->vn,NULL,NULL);
|
|
|
|
|
eve->f |= flag;
|
|
|
|
|
/*New Faces*/
|
|
|
|
|
addface_subdiv(efa, 3, 13, 1+4, 2, eve, &efapin);
|
|
|
|
|
addface_subdiv(efa, 3, 4, 4+4,13, eve, &efapin);
|
|
|
|
|
/* orig face becomes small corner */
|
|
|
|
|
efa->v2=efa->v1;
|
|
|
|
|
efa->v1=e4->vn;
|
|
|
|
|
efa->v3=e1->vn;
|
|
|
|
|
efa->v4=eve;
|
|
|
|
|
|
|
|
|
|
set_wuv(4, efa, 4+4, 1, 1+4, 13, &efapin);
|
2004-11-05 13:34:23 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
else if(test==5) { /* 1&3 */
|
|
|
|
|
addface_subdiv(efa, 1+4, 2, 3, 3+4, 0, &efapin);
|
|
|
|
|
efa->v2= e1->vn;
|
|
|
|
|
efa->v3= e3->vn;
|
|
|
|
|
set_wuv(4, efa, 1, 1+4, 3+4, 4, &efapin);
|
2004-11-05 13:34:23 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
else if(test==10) { /* 2&4 */
|
|
|
|
|
addface_subdiv(efa, 2+4, 3, 4, 4+4, 0, &efapin);
|
|
|
|
|
efa->v3= e2->vn;
|
|
|
|
|
efa->v4= e4->vn;
|
|
|
|
|
set_wuv(4, efa, 1, 2, 2+4, 4+4, &efapin);
|
|
|
|
|
}/* Unfortunately, there is no way to avoid tris on 1 or 3 edges*/
|
|
|
|
|
else if(test==7) { /*1,2&3 */
|
|
|
|
|
addface_subdiv(efa, 1+4, 2+4, 3+4, 0, 0, &efapin);
|
|
|
|
|
efa->v2= e1->vn;
|
|
|
|
|
efa->v3= e3->vn;
|
|
|
|
|
set_wuv(4, efa, 1, 1+4, 3+4, 4, &efapin);
|
2004-11-05 13:34:23 +00:00
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
|
|
|
|
|
else if(test==14) { /* 2,3&4 */
|
|
|
|
|
addface_subdiv(efa, 2+4, 3+4, 4+4, 0, 0, &efapin);
|
|
|
|
|
efa->v3= e2->vn;
|
|
|
|
|
efa->v4= e4->vn;
|
|
|
|
|
set_wuv(4, efa, 1, 2, 2+4, 4+4, &efapin);
|
|
|
|
|
}
|
|
|
|
|
else if(test==13) {/* 1,3&4 */
|
|
|
|
|
addface_subdiv(efa, 3+4, 4+4, 1+4, 0, 0, &efapin);
|
|
|
|
|
efa->v4= e3->vn;
|
|
|
|
|
efa->v1= e1->vn;
|
|
|
|
|
set_wuv(4, efa, 1+4, 2, 3, 3+4, &efapin);
|
|
|
|
|
}
|
|
|
|
|
else if(test==11) { /* 1,2,&4 */
|
|
|
|
|
addface_subdiv(efa, 4+4, 1+4, 2+4, 0, 0, &efapin);
|
|
|
|
|
efa->v1= e4->vn;
|
|
|
|
|
efa->v2= e2->vn;
|
|
|
|
|
set_wuv(4, efa, 4+4, 2+4, 3, 4, &efapin);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
efa->e1= addedgelist(efa->v1, efa->v2, NULL);
|
|
|
|
|
efa->e2= addedgelist(efa->v2, efa->v3, NULL);
|
|
|
|
|
if(efa->v4) efa->e3= addedgelist(efa->v3, efa->v4, NULL);
|
|
|
|
|
else efa->e3= addedgelist(efa->v3, efa->v1, NULL);
|
|
|
|
|
if(efa->v4) efa->e4= addedgelist(efa->v4, efa->v1, NULL);
|
|
|
|
|
else efa->e4= NULL;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-07-13 15:20:40 +00:00
|
|
|
efa= efa->prev;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* remove all old edges, if needed make new ones */
|
|
|
|
|
eed= em->edges.first;
|
|
|
|
|
while(eed) {
|
|
|
|
|
nexted= eed->next;
|
|
|
|
|
if( eed->vn ) {
|
|
|
|
|
eed->vn->f |= 16;
|
|
|
|
|
if(eed->f2==0) { /* not used in face */
|
|
|
|
|
addedgelist(eed->v1, eed->vn, eed);
|
|
|
|
|
addedgelist(eed->vn, eed->v2, eed);
|
|
|
|
|
}
|
|
|
|
|
remedge(eed);
|
|
|
|
|
free_editedge(eed);
|
|
|
|
|
}
|
|
|
|
|
eed= nexted;
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-13 15:20:40 +00:00
|
|
|
/* since this is all on vertex level, flush vertex selection */
|
|
|
|
|
EM_select_flush();
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
recalc_editnormals();
|
2005-07-13 15:20:40 +00:00
|
|
|
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
2005-08-07 21:47:08 +00:00
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
Part one of editmesh.c refactoring. The huge file has been split in
logical parts, and include files altered to denote internal and external
functions.
include/editmesh.h: internal calls for editmesh_xxx.c files
include/BIF_editmesh.h: external calls for these files
src/editmesh.c: basic alloc/lists and in/out editmode, undo, separate
src/editmesh_lib.c: basic utility calls for all editmesh_xxx.c (no UI)
src/editmesh_add.c: add prim, add duplicate, add vertex/edge/face (UI)
src/editmesh_mods.c: selecting, transforming (UI)
src/editmesh_loop.c: loop tools like knife, loop select, loop subdiv (UI)
src/editmesh_tools.c: other tools (extrude, spin, etc) (UI)
And a new file:
src/meshtools.c: tools for Mesh outside of editmode (normals, draw flags)
2004-09-19 11:47:49 +00:00
|
|
|
}
|