2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* 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
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* 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) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <math.h>
|
2003-10-07 18:24:02 +00:00
|
|
|
#include <string.h>
|
2002-11-25 12:02:15 +00:00
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifndef WIN32
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#else
|
|
|
|
|
#include <io.h>
|
|
|
|
|
#endif
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BMF_Api.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
#include "BLI_arithb.h"
|
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
|
|
|
#include "BLI_dynstr.h"
|
2007-06-14 14:36:27 +00:00
|
|
|
#include "BLI_rand.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
#include "DNA_curve_types.h"
|
|
|
|
|
#include "DNA_ipo_types.h"
|
|
|
|
|
#include "DNA_key_types.h"
|
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
#include "DNA_screen_types.h"
|
2006-11-07 11:24:11 +00:00
|
|
|
#include "DNA_space_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_view3d_types.h"
|
2004-08-31 13:43:18 +00:00
|
|
|
#include "DNA_userdef_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
#include "BKE_utildefines.h"
|
|
|
|
|
#include "BKE_library.h"
|
|
|
|
|
#include "BKE_ipo.h"
|
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"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_curve.h"
|
|
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_object.h"
|
|
|
|
|
#include "BKE_main.h"
|
2005-07-15 17:55:19 +00:00
|
|
|
#include "BKE_key.h"
|
2002-10-12 11:37:38 +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
|
|
|
#include "BIF_editmode_undo.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BIF_gl.h"
|
|
|
|
|
#include "BIF_graphics.h"
|
|
|
|
|
#include "BIF_screen.h"
|
|
|
|
|
#include "BIF_toolbox.h"
|
|
|
|
|
#include "BIF_space.h"
|
|
|
|
|
#include "BIF_editkey.h"
|
|
|
|
|
#include "BIF_mywindow.h"
|
|
|
|
|
#include "BIF_interface.h"
|
2005-03-28 00:56:00 +00:00
|
|
|
#include "BIF_transform.h"
|
2006-11-06 01:08:26 +00:00
|
|
|
#include "BIF_retopo.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
#include "BSE_view.h" /* For persp... */
|
|
|
|
|
#include "BSE_edit.h"
|
|
|
|
|
|
|
|
|
|
#include "BDR_drawobject.h"
|
|
|
|
|
#include "BDR_editcurve.h"
|
|
|
|
|
#include "BDR_editobject.h"
|
|
|
|
|
|
|
|
|
|
#include "mydevice.h"
|
|
|
|
|
#include "blendef.h"
|
|
|
|
|
|
|
|
|
|
#include "BDR_editcurve.h"
|
|
|
|
|
/* still need to eradicate a few :( */
|
|
|
|
|
#define callocstructN(x,y,name) (x*)MEM_callocN((y)* sizeof(x),name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ListBase editNurb;
|
|
|
|
|
BPoint *lastselbp;
|
2008-05-25 23:05:13 +00:00
|
|
|
int actnu; /* for selected */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/* void freeNurblist(ListBase *lb); already declared in the kernel */
|
|
|
|
|
|
|
|
|
|
float nurbcircle[8][2]= {
|
|
|
|
|
{0.0, -1.0}, {-1.0, -1.0}, {-1.0, 0.0}, {-1.0, 1.0},
|
|
|
|
|
{0.0, 1.0}, { 1.0, 1.0}, { 1.0, 0.0}, { 1.0, -1.0}
|
|
|
|
|
};
|
|
|
|
|
|
2008-05-25 23:05:13 +00:00
|
|
|
|
|
|
|
|
/* this replaces the active flag used in uv/face mode */
|
|
|
|
|
void set_actNurb(Nurb *nu)
|
|
|
|
|
{
|
|
|
|
|
if (nu==NULL) {
|
|
|
|
|
actnu = -1;
|
|
|
|
|
} else {
|
|
|
|
|
actnu = BLI_findindex(&editNurb, nu);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Nurb * get_actNurb( void )
|
|
|
|
|
{
|
|
|
|
|
return BLI_findlink(&editNurb, actnu);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-06-14 14:36:27 +00:00
|
|
|
/* ******************* SELECTION FUNCTIONS ********************* */
|
|
|
|
|
|
|
|
|
|
/* returns 1 in case (de)selection was successful */
|
|
|
|
|
static short select_beztriple(BezTriple *bezt, short selstatus, short flag, short hidden)
|
|
|
|
|
{
|
|
|
|
|
if(bezt) {
|
|
|
|
|
if((bezt->hide==0) || (hidden==1)) {
|
|
|
|
|
if(selstatus==1) { /* selects */
|
|
|
|
|
bezt->f1 |= flag;
|
|
|
|
|
bezt->f2 |= flag;
|
|
|
|
|
bezt->f3 |= flag;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else { /* deselects */
|
|
|
|
|
bezt->f1 &= ~flag;
|
|
|
|
|
bezt->f2 &= ~flag;
|
|
|
|
|
bezt->f3 &= ~flag;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* returns 1 in case (de)selection was successful */
|
|
|
|
|
static short select_bpoint(BPoint *bp, short selstatus, short flag, short hidden)
|
|
|
|
|
{
|
|
|
|
|
if(bp) {
|
|
|
|
|
if((bp->hide==0) || (hidden==1)) {
|
|
|
|
|
if(selstatus==1) {
|
|
|
|
|
bp->f1 |= flag;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bp->f1 &= ~flag;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static short swap_selection_beztriple(BezTriple *bezt)
|
|
|
|
|
{
|
2007-12-01 23:25:00 +00:00
|
|
|
if(bezt->f2 & SELECT)
|
2007-06-14 14:36:27 +00:00
|
|
|
return select_beztriple(bezt, DESELECT, 1, VISIBLE);
|
|
|
|
|
else
|
|
|
|
|
return select_beztriple(bezt, SELECT, 1, VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static short swap_selection_bpoint(BPoint *bp)
|
|
|
|
|
{
|
2007-12-01 23:25:00 +00:00
|
|
|
if(bp->f1 & SELECT)
|
2007-06-14 14:36:27 +00:00
|
|
|
return select_bpoint(bp, DESELECT, 1, VISIBLE);
|
|
|
|
|
else
|
|
|
|
|
return select_bpoint(bp, SELECT, 1, VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
short isNurbsel(Nurb *nu)
|
|
|
|
|
{
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
if((nu->type & 7)==CU_BEZIER) {
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
while(a--) {
|
2007-12-01 23:25:00 +00:00
|
|
|
if( (bezt->f1 & SELECT) || (bezt->f2 & SELECT) || (bezt->f3 & SELECT) ) return 1;
|
2002-10-12 11:37:38 +00:00
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
while(a--) {
|
2007-12-01 23:25:00 +00:00
|
|
|
if( (bp->f1 & SELECT) ) return 1;
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int isNurbsel_count(Nurb *nu)
|
|
|
|
|
{
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
int a, sel=0;
|
|
|
|
|
|
|
|
|
|
if((nu->type & 7)==CU_BEZIER) {
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
while(a--) {
|
2007-12-11 14:19:05 +00:00
|
|
|
if (BEZSELECTED_HIDDENHANDLES(bezt)) sel++;
|
2002-10-12 11:37:38 +00:00
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
while(a--) {
|
2007-12-01 23:25:00 +00:00
|
|
|
if( (bp->f1 & SELECT) ) sel++;
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return sel;
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-14 14:36:27 +00:00
|
|
|
/* ******************* PRINTS ********************* */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
void printknots()
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
int a, num;
|
|
|
|
|
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if(isNurbsel(nu) && (nu->type & 7)==CU_NURBS) {
|
|
|
|
|
if(nu->knotsu) {
|
|
|
|
|
num= KNOTSU(nu);
|
|
|
|
|
for(a=0;a<num;a++) printf("knotu %d: %f\n", a, nu->knotsu[a]);
|
|
|
|
|
}
|
|
|
|
|
if(nu->knotsv) {
|
|
|
|
|
num= KNOTSV(nu);
|
|
|
|
|
for(a=0;a<num;a++) printf("knotv %d: %f\n", a, nu->knotsv[a]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 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
|
|
|
static void printweightsNurb__doPrint(void *userData, Nurb *nurb, BPoint *bp, BezTriple *bezt, int beztindex, int x, int y)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
char str[30];
|
|
|
|
|
|
2008-09-20 13:21:10 +00:00
|
|
|
if (bp && (bp->f1 & SELECT)) {
|
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
|
|
|
sprintf(str,"%2.2f", bp->vec[3]);
|
2002-10-12 11:37:38 +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
|
|
|
cpack(0x737373);
|
|
|
|
|
glRasterPos2i(x-1, y-1);
|
|
|
|
|
BMF_DrawString(G.font, str);
|
2002-10-12 11:37:38 +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
|
|
|
glRasterPos2i(x+1, y+1);
|
|
|
|
|
BMF_DrawString(G.font, str);
|
2002-10-12 11:37:38 +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
|
|
|
cpack(0xFFFFFF);
|
|
|
|
|
glRasterPos2i(x, y);
|
|
|
|
|
BMF_DrawString(G.font, str);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
static void printweightsNurb(void)
|
|
|
|
|
{
|
|
|
|
|
if(G.obedit==0) return;
|
2002-10-12 11:37:38 +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
|
|
|
persp(PERSP_WIN);
|
2002-10-12 11:37:38 +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
|
|
|
glDrawBuffer(GL_FRONT);
|
|
|
|
|
nurbs_foreachScreenVert(printweightsNurb__doPrint, NULL);
|
|
|
|
|
glDrawBuffer(GL_BACK);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-10-16 09:39:19 +00:00
|
|
|
persp(PERSP_VIEW);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
/* ********************* LOAD and MAKE *************** */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
void load_editNurb()
|
|
|
|
|
{
|
2003-04-28 14:43:20 +00:00
|
|
|
/* load editNurb in object */
|
2002-10-12 11:37:38 +00:00
|
|
|
Curve *cu= 0;
|
|
|
|
|
Nurb *nu, *newnu;
|
2005-07-15 17:55:19 +00:00
|
|
|
KeyBlock *actkey;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
if(G.obedit==0) return;
|
|
|
|
|
|
|
|
|
|
if ELEM(G.obedit->type, OB_CURVE, OB_SURF) {
|
|
|
|
|
|
|
|
|
|
G.totvert= count_curveverts(&editNurb);
|
|
|
|
|
|
|
|
|
|
cu= G.obedit->data;
|
|
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
/* are there keys? */
|
2005-09-26 15:34:21 +00:00
|
|
|
actkey = ob_get_keyblock(G.obedit);
|
2005-07-15 17:55:19 +00:00
|
|
|
if(actkey) {
|
|
|
|
|
/* active key: the vertices */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-07-15 17:55:19 +00:00
|
|
|
if(G.totvert) {
|
|
|
|
|
if(actkey->data) MEM_freeN(actkey->data);
|
|
|
|
|
|
|
|
|
|
actkey->data= MEM_callocN(cu->key->elemsize*G.totvert, "actkey->data");
|
|
|
|
|
actkey->totelem= G.totvert;
|
|
|
|
|
|
|
|
|
|
curve_to_key(cu, actkey, &editNurb);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(cu->key && actkey!=cu->key->refkey) {
|
2005-07-15 18:15:56 +00:00
|
|
|
;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
freeNurblist(&(cu->nurb));
|
|
|
|
|
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
newnu= duplicateNurb(nu);
|
|
|
|
|
BLI_addtail(&(cu->nurb), newnu);
|
|
|
|
|
|
|
|
|
|
if((nu->type & 7)==CU_NURBS) {
|
2008-05-26 09:50:46 +00:00
|
|
|
clamp_nurb_order_u(nu);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-25 23:05:13 +00:00
|
|
|
set_actNurb(NULL);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void make_editNurb()
|
|
|
|
|
{
|
2003-04-28 14:43:20 +00:00
|
|
|
/* make copy of baseNurb in editNurb */
|
2002-10-12 11:37:38 +00:00
|
|
|
Curve *cu=0;
|
|
|
|
|
Nurb *nu, *newnu;
|
2005-07-15 17:55:19 +00:00
|
|
|
KeyBlock *actkey;
|
2002-10-12 11:37:38 +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(G.obedit==NULL) return;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-04-07 11:35:11 +00:00
|
|
|
lastselbp= NULL; /* global for select row */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
if ELEM(G.obedit->type, OB_CURVE, OB_SURF) {
|
|
|
|
|
freeNurblist(&editNurb);
|
|
|
|
|
|
|
|
|
|
cu= G.obedit->data;
|
|
|
|
|
nu= cu->nurb.first;
|
|
|
|
|
|
|
|
|
|
while(nu) {
|
|
|
|
|
newnu= duplicateNurb(nu);
|
2004-10-31 21:11:03 +00:00
|
|
|
test2DNurb(newnu); // after join, or any other creation of curve
|
2002-10-12 11:37:38 +00:00
|
|
|
BLI_addtail(&editNurb, newnu);
|
|
|
|
|
nu= nu->next;
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-26 15:34:21 +00:00
|
|
|
actkey = ob_get_keyblock(G.obedit);
|
2005-07-15 17:55:19 +00:00
|
|
|
if(actkey) {
|
|
|
|
|
strcpy(G.editModeTitleExtra, "(Key) ");
|
|
|
|
|
key_to_curve(actkey, cu, &editNurb);
|
2002-10-12 11:37:38 +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
|
|
|
else G.obedit= NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
countall();
|
2008-05-25 23:05:13 +00:00
|
|
|
set_actNurb(NULL);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void remake_editNurb()
|
|
|
|
|
{
|
|
|
|
|
|
2004-06-05 05:55:15 +00:00
|
|
|
if(okee("Reload original data")==0) return;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
make_editNurb();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
allqueue(REDRAWBUTSEDIT, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void separate_nurb()
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu, *nu1;
|
|
|
|
|
Object *oldob;
|
|
|
|
|
Base *base, *oldbase;
|
|
|
|
|
Curve *cu;
|
|
|
|
|
ListBase editnurbo;
|
|
|
|
|
|
2007-03-14 09:08:41 +00:00
|
|
|
if( G.vd==0 || (G.vd->lay & G.obedit->lay)==0 ) return;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
if(okee("Separate")==0) return;
|
|
|
|
|
|
|
|
|
|
waitcursor(1);
|
|
|
|
|
|
|
|
|
|
cu= G.obedit->data;
|
|
|
|
|
if(cu->key) {
|
2004-06-05 05:55:15 +00:00
|
|
|
error("Can't separate a curve with vertex keys");
|
2002-10-12 11:37:38 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
/* we are going to trick everything as follows:
|
|
|
|
|
* 1. duplicate base: this is the new one, remember old pointer
|
|
|
|
|
* 2. set aside all NOT selected curves/nurbs
|
|
|
|
|
* 3. load_ebaseNurb(): this will be the new base
|
|
|
|
|
* 4. freelist and restore old nurbs
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
/* only edit-base selected */
|
2002-10-12 11:37:38 +00:00
|
|
|
base= FIRSTBASE;
|
|
|
|
|
while(base) {
|
|
|
|
|
if(base->lay & G.vd->lay) {
|
|
|
|
|
if(base->object==G.obedit) base->flag |= 1;
|
|
|
|
|
else base->flag &= ~1;
|
|
|
|
|
}
|
|
|
|
|
base= base->next;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
/* set aside: everything that is not selected */
|
2002-10-12 11:37:38 +00:00
|
|
|
editnurbo.first= editnurbo.last= 0;
|
|
|
|
|
nu= editNurb.first;
|
|
|
|
|
while(nu) {
|
|
|
|
|
nu1= nu->next;
|
|
|
|
|
if(isNurbsel(nu)==0) {
|
|
|
|
|
BLI_remlink(&editNurb, nu);
|
|
|
|
|
BLI_addtail(&editnurbo, nu);
|
|
|
|
|
}
|
|
|
|
|
nu= nu1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
oldob= G.obedit;
|
|
|
|
|
oldbase= BASACT;
|
|
|
|
|
|
2006-01-02 10:40:13 +00:00
|
|
|
adduplicate(1, 0); /* no transform and zero so do get a linked dupli */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
G.obedit= BASACT->object; /* basact is set in adduplicate() */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
G.obedit->data= copy_curve(cu);
|
2003-04-28 14:43:20 +00:00
|
|
|
/* because new curve is a copy: reduce user count */
|
2002-10-12 11:37:38 +00:00
|
|
|
cu->id.us--;
|
|
|
|
|
|
|
|
|
|
load_editNurb();
|
|
|
|
|
|
|
|
|
|
BASACT->flag &= ~SELECT;
|
|
|
|
|
|
|
|
|
|
if(editNurb.first) freeNurblist(&editNurb);
|
|
|
|
|
|
|
|
|
|
editNurb= editnurbo;
|
|
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
G.obedit= 0; /* displists behave different in edit mode */
|
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, OBACT, OB_RECALC_DATA); /* this is the separated one */
|
2008-03-31 03:40:47 +00:00
|
|
|
DAG_object_flush_update(G.scene, oldob, OB_RECALC_DATA); /* this is the original one */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
G.obedit= oldob;
|
|
|
|
|
BASACT= oldbase;
|
|
|
|
|
BASACT->flag |= SELECT;
|
|
|
|
|
|
|
|
|
|
waitcursor(0);
|
|
|
|
|
|
|
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
2004-04-07 11:35:11 +00:00
|
|
|
allqueue(REDRAWBUTSEDIT, 0);
|
2008-05-25 23:05:13 +00:00
|
|
|
set_actNurb(NULL);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ******************* FLAGS ********************* */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
short isNurbselUV(Nurb *nu, int *u, int *v, int flag)
|
|
|
|
|
{
|
2003-04-28 14:43:20 +00:00
|
|
|
/* return u!=-1: 1 row in u-direction selected. U has value between 0-pntsv
|
|
|
|
|
* return v!=-1: 1 collumn in v-direction selected. V has value between 0-pntsu
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
int a, b, sel;
|
|
|
|
|
|
|
|
|
|
*u= *v= -1;
|
|
|
|
|
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
for(b=0; b<nu->pntsv; b++) {
|
|
|
|
|
sel= 0;
|
|
|
|
|
for(a=0; a<nu->pntsu; a++, bp++) {
|
|
|
|
|
if(bp->f1 & flag) sel++;
|
|
|
|
|
}
|
|
|
|
|
if(sel==nu->pntsu) {
|
|
|
|
|
if(*u== -1) *u= b;
|
|
|
|
|
else return 0;
|
|
|
|
|
}
|
2003-04-28 14:43:20 +00:00
|
|
|
else if(sel>1) return 0; /* because sel==1 is still ok */
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(a=0; a<nu->pntsu; a++) {
|
|
|
|
|
sel= 0;
|
|
|
|
|
bp= nu->bp+a;
|
|
|
|
|
for(b=0; b<nu->pntsv; b++, bp+=nu->pntsu) {
|
|
|
|
|
if(bp->f1 & flag) sel++;
|
|
|
|
|
}
|
|
|
|
|
if(sel==nu->pntsv) {
|
|
|
|
|
if(*v== -1) *v= a;
|
|
|
|
|
else return 0;
|
|
|
|
|
}
|
|
|
|
|
else if(sel>1) return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(*u==-1 && *v>-1) return 1;
|
|
|
|
|
if(*v==-1 && *u>-1) return 1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setflagsNurb(short flag)
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
int a;
|
|
|
|
|
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if( (nu->type & 7)==CU_BEZIER) {
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
while(a--) {
|
|
|
|
|
bezt->f1= bezt->f2= bezt->f3= flag;
|
|
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
while(a--) {
|
|
|
|
|
bp->f1= flag;
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void rotateflagNurb(short flag, float *cent, float rotmat[][3])
|
|
|
|
|
{
|
2003-04-28 14:43:20 +00:00
|
|
|
/* all verts with (flag & 'flag') rotate */
|
2002-10-12 11:37:38 +00:00
|
|
|
Nurb *nu;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
int a;
|
|
|
|
|
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if((nu->type & 7)==CU_NURBS) {
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
|
|
|
|
|
while(a--) {
|
|
|
|
|
if(bp->f1 & flag) {
|
|
|
|
|
bp->vec[0]-=cent[0];
|
|
|
|
|
bp->vec[1]-=cent[1];
|
|
|
|
|
bp->vec[2]-=cent[2];
|
|
|
|
|
Mat3MulVecfl(rotmat, bp->vec);
|
|
|
|
|
bp->vec[0]+=cent[0];
|
|
|
|
|
bp->vec[1]+=cent[1];
|
|
|
|
|
bp->vec[2]+=cent[2];
|
|
|
|
|
}
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void translateflagNurb(short flag, float *vec)
|
|
|
|
|
{
|
2003-04-28 14:43:20 +00:00
|
|
|
/* all verts with ('flag' & flag) translate */
|
2002-10-12 11:37:38 +00:00
|
|
|
Nurb *nu;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
int a;
|
|
|
|
|
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if( (nu->type & 7)==CU_BEZIER) {
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
while(a--) {
|
|
|
|
|
if(bezt->f1 & flag) VecAddf(bezt->vec[0], bezt->vec[0], vec);
|
|
|
|
|
if(bezt->f2 & flag) VecAddf(bezt->vec[1], bezt->vec[1], vec);
|
|
|
|
|
if(bezt->f3 & flag) VecAddf(bezt->vec[2], bezt->vec[2], vec);
|
|
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
while(a--) {
|
|
|
|
|
if(bp->f1 & flag) VecAddf(bp->vec, bp->vec, vec);
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test2DNurb(nu);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
void weightflagNurb(short flag, float w, int mode) /* mode==0: replace, mode==1: multiply */
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
int a;
|
|
|
|
|
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if((nu->type & 7)==CU_NURBS) {
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
while(a--) {
|
|
|
|
|
if(bp->f1 & flag) {
|
|
|
|
|
if(mode==1) bp->vec[3]*= w;
|
|
|
|
|
else bp->vec[3]= w;
|
|
|
|
|
}
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void deleteflagNurb(short flag)
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu, *next;
|
|
|
|
|
BPoint *bp, *bpn, *newbp;
|
|
|
|
|
int a, b, newu, newv, sel;
|
|
|
|
|
|
|
|
|
|
if(G.obedit && G.obedit->type==OB_SURF);
|
|
|
|
|
else return;
|
|
|
|
|
|
2004-04-07 11:35:11 +00:00
|
|
|
lastselbp= NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
nu= editNurb.first;
|
|
|
|
|
while(nu) {
|
|
|
|
|
next= nu->next;
|
|
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
/* is entire nurb selected */
|
2002-10-12 11:37:38 +00:00
|
|
|
bp= nu->bp;
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
while(a) {
|
|
|
|
|
a--;
|
|
|
|
|
if(bp->f1 & flag);
|
|
|
|
|
else break;
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
if(a==0) {
|
|
|
|
|
BLI_remlink(&editNurb, nu);
|
2008-05-25 23:05:13 +00:00
|
|
|
freeNurb(nu); nu=NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2003-04-28 14:43:20 +00:00
|
|
|
/* is nurb in U direction selected */
|
2002-10-12 11:37:38 +00:00
|
|
|
newv= nu->pntsv;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
for(b=0; b<nu->pntsv; b++) {
|
|
|
|
|
sel= 0;
|
|
|
|
|
for(a=0; a<nu->pntsu; a++, bp++) {
|
|
|
|
|
if(bp->f1 & flag) sel++;
|
|
|
|
|
}
|
|
|
|
|
if(sel==nu->pntsu) {
|
|
|
|
|
newv--;
|
|
|
|
|
}
|
|
|
|
|
else if(sel>=1) {
|
|
|
|
|
/* don't delete */
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(newv!=nu->pntsv && b==nu->pntsv) {
|
2003-04-28 14:43:20 +00:00
|
|
|
/* delete */
|
2002-10-12 11:37:38 +00:00
|
|
|
bp= nu->bp;
|
|
|
|
|
bpn = newbp =
|
|
|
|
|
(BPoint*) MEM_mallocN(newv * nu->pntsu * sizeof(BPoint), "deleteNurb");
|
|
|
|
|
for(b=0; b<nu->pntsv; b++) {
|
|
|
|
|
if((bp->f1 & flag)==0) {
|
|
|
|
|
memcpy(bpn, bp, nu->pntsu*sizeof(BPoint));
|
|
|
|
|
bpn+= nu->pntsu;
|
|
|
|
|
}
|
|
|
|
|
bp+= nu->pntsu;
|
|
|
|
|
}
|
|
|
|
|
nu->pntsv= newv;
|
|
|
|
|
MEM_freeN(nu->bp);
|
|
|
|
|
nu->bp= newbp;
|
2008-05-26 09:50:46 +00:00
|
|
|
clamp_nurb_order_v(nu);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
makeknots(nu, 2, nu->flagv>>1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2003-04-28 14:43:20 +00:00
|
|
|
/* is the nurb in V direction selected */
|
2002-10-12 11:37:38 +00:00
|
|
|
newu= nu->pntsu;
|
|
|
|
|
for(a=0; a<nu->pntsu; a++) {
|
|
|
|
|
bp= nu->bp+a;
|
|
|
|
|
sel= 0;
|
|
|
|
|
for(b=0; b<nu->pntsv; b++, bp+=nu->pntsu) {
|
|
|
|
|
if(bp->f1 & flag) sel++;
|
|
|
|
|
}
|
|
|
|
|
if(sel==nu->pntsv) {
|
|
|
|
|
newu--;
|
|
|
|
|
}
|
|
|
|
|
else if(sel>=1) {
|
|
|
|
|
/* don't delete */
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(newu!=nu->pntsu && a==nu->pntsu) {
|
2003-04-28 14:43:20 +00:00
|
|
|
/* delete */
|
2002-10-12 11:37:38 +00:00
|
|
|
bp= nu->bp;
|
|
|
|
|
bpn = newbp =
|
|
|
|
|
(BPoint*) MEM_mallocN(newu * nu->pntsv * sizeof(BPoint), "deleteNurb");
|
|
|
|
|
for(b=0; b<nu->pntsv; b++) {
|
|
|
|
|
for(a=0; a<nu->pntsu; a++, bp++) {
|
|
|
|
|
if((bp->f1 & flag)==0) {
|
|
|
|
|
*bpn= *bp;
|
|
|
|
|
bpn++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MEM_freeN(nu->bp);
|
|
|
|
|
nu->bp= newbp;
|
2003-04-28 14:43:20 +00:00
|
|
|
if(newu==1 && nu->pntsv>1) { /* make a U spline */
|
2002-10-12 11:37:38 +00:00
|
|
|
nu->pntsu= nu->pntsv;
|
|
|
|
|
nu->pntsv= 1;
|
|
|
|
|
SWAP(short, nu->orderu, nu->orderv);
|
2008-05-26 09:50:46 +00:00
|
|
|
clamp_nurb_order_u(nu);
|
2002-10-12 11:37:38 +00:00
|
|
|
if(nu->knotsv) MEM_freeN(nu->knotsv);
|
2008-05-26 09:50:46 +00:00
|
|
|
nu->knotsv= NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
nu->pntsu= newu;
|
2008-05-26 09:50:46 +00:00
|
|
|
clamp_nurb_order_u(nu);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
makeknots(nu, 1, nu->flagu>>1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
nu= next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
short extrudeflagNurb(int flag)
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BPoint *bp, *bpn, *newbp;
|
|
|
|
|
int ok= 0, a, u, v, len;
|
|
|
|
|
|
|
|
|
|
if(G.obedit && G.obedit->type==OB_SURF);
|
|
|
|
|
else return 0;
|
|
|
|
|
|
|
|
|
|
nu= editNurb.first;
|
|
|
|
|
while(nu) {
|
|
|
|
|
|
|
|
|
|
if(nu->pntsv==1) {
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
while(a) {
|
|
|
|
|
if(bp->f1 & flag);
|
|
|
|
|
else break;
|
|
|
|
|
bp++;
|
|
|
|
|
a--;
|
|
|
|
|
}
|
|
|
|
|
if(a==0) {
|
|
|
|
|
ok= 1;
|
|
|
|
|
newbp =
|
|
|
|
|
(BPoint*)MEM_mallocN(2 * nu->pntsu * sizeof(BPoint), "extrudeNurb1");
|
|
|
|
|
memcpy(newbp, nu->bp, nu->pntsu*sizeof(BPoint) );
|
|
|
|
|
bp= newbp+ nu->pntsu;
|
|
|
|
|
memcpy(bp, nu->bp, nu->pntsu*sizeof(BPoint) );
|
|
|
|
|
MEM_freeN(nu->bp);
|
|
|
|
|
nu->bp= newbp;
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
while(a--) {
|
2007-06-14 14:36:27 +00:00
|
|
|
select_bpoint(bp, SELECT, flag, HIDDEN);
|
|
|
|
|
select_bpoint(newbp, DESELECT, flag, HIDDEN);
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
|
|
|
|
newbp++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nu->pntsv= 2;
|
|
|
|
|
nu->orderv= 2;
|
|
|
|
|
makeknots(nu, 2, nu->flagv>>1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2003-04-28 14:43:20 +00:00
|
|
|
/* which row or collumn is selected */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
if( isNurbselUV(nu, &u, &v, flag) ) {
|
|
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
/* deselect all */
|
2002-10-12 11:37:38 +00:00
|
|
|
bp= nu->bp;
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
while(a--) {
|
2007-06-14 14:36:27 +00:00
|
|
|
select_bpoint(bp, DESELECT, flag, HIDDEN);
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
if(u==0 || u== nu->pntsv-1) { /* row in u-direction selected */
|
2002-10-12 11:37:38 +00:00
|
|
|
ok= 1;
|
|
|
|
|
newbp =
|
|
|
|
|
(BPoint*) MEM_mallocN(nu->pntsu*(nu->pntsv + 1)
|
|
|
|
|
* sizeof(BPoint), "extrudeNurb1");
|
|
|
|
|
if(u==0) {
|
|
|
|
|
len= nu->pntsv*nu->pntsu;
|
|
|
|
|
memcpy(newbp+nu->pntsu, nu->bp, len*sizeof(BPoint) );
|
|
|
|
|
memcpy(newbp, nu->bp, nu->pntsu*sizeof(BPoint) );
|
|
|
|
|
bp= newbp;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
len= nu->pntsv*nu->pntsu;
|
|
|
|
|
memcpy(newbp, nu->bp, len*sizeof(BPoint) );
|
|
|
|
|
memcpy(newbp+len, nu->bp+len-nu->pntsu, nu->pntsu*sizeof(BPoint) );
|
|
|
|
|
bp= newbp+len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
while(a--) {
|
2007-06-14 14:36:27 +00:00
|
|
|
select_bpoint(bp, SELECT, flag, HIDDEN);
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MEM_freeN(nu->bp);
|
|
|
|
|
nu->bp= newbp;
|
|
|
|
|
nu->pntsv++;
|
|
|
|
|
makeknots(nu, 2, nu->flagv>>1);
|
|
|
|
|
}
|
2003-04-28 14:43:20 +00:00
|
|
|
else if(v==0 || v== nu->pntsu-1) { /* collumn in v-direction selected */
|
2002-10-12 11:37:38 +00:00
|
|
|
ok= 1;
|
|
|
|
|
bpn = newbp =
|
|
|
|
|
(BPoint*) MEM_mallocN((nu->pntsu + 1) * nu->pntsv * sizeof(BPoint), "extrudeNurb1");
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
|
|
|
|
|
for(a=0; a<nu->pntsv; a++) {
|
|
|
|
|
if(v==0) {
|
|
|
|
|
*bpn= *bp;
|
|
|
|
|
bpn->f1 |= flag;
|
|
|
|
|
bpn++;
|
|
|
|
|
}
|
|
|
|
|
memcpy(bpn, bp, nu->pntsu*sizeof(BPoint));
|
|
|
|
|
bp+= nu->pntsu;
|
|
|
|
|
bpn+= nu->pntsu;
|
|
|
|
|
if(v== nu->pntsu-1) {
|
|
|
|
|
*bpn= *(bp-1);
|
|
|
|
|
bpn->f1 |= flag;
|
|
|
|
|
bpn++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MEM_freeN(nu->bp);
|
|
|
|
|
nu->bp= newbp;
|
|
|
|
|
nu->pntsu++;
|
|
|
|
|
makeknots(nu, 1, nu->flagu>>1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
nu= nu->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void adduplicateflagNurb(short flag)
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu, *newnu;
|
|
|
|
|
BezTriple *bezt, *bezt1;
|
|
|
|
|
BPoint *bp, *bp1;
|
|
|
|
|
int a, b, starta, enda, newu, newv;
|
|
|
|
|
char *usel;
|
|
|
|
|
|
|
|
|
|
nu= editNurb.last;
|
|
|
|
|
while(nu) {
|
|
|
|
|
if( (nu->type & 7)==CU_BEZIER) {
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
for(a=0; a<nu->pntsu; a++) {
|
|
|
|
|
enda= -1;
|
|
|
|
|
starta= a;
|
|
|
|
|
while( (bezt->f1 & flag) || (bezt->f2 & flag) || (bezt->f3 & flag) ) {
|
2007-06-14 14:36:27 +00:00
|
|
|
select_beztriple(bezt, DESELECT, flag, HIDDEN);
|
2002-10-12 11:37:38 +00:00
|
|
|
enda=a;
|
|
|
|
|
if(a>=nu->pntsu-1) break;
|
|
|
|
|
a++;
|
|
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
if(enda>=starta) {
|
|
|
|
|
newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN");
|
|
|
|
|
memcpy(newnu, nu, sizeof(Nurb));
|
|
|
|
|
BLI_addtail(&editNurb, newnu);
|
2008-05-25 23:05:13 +00:00
|
|
|
set_actNurb(newnu);
|
2002-10-12 11:37:38 +00:00
|
|
|
newnu->pntsu= enda-starta+1;
|
|
|
|
|
newnu->bezt=
|
|
|
|
|
(BezTriple*)MEM_mallocN((enda - starta + 1) * sizeof(BezTriple), "adduplicateN");
|
|
|
|
|
memcpy(newnu->bezt, nu->bezt+starta, newnu->pntsu*sizeof(BezTriple));
|
|
|
|
|
|
|
|
|
|
b= newnu->pntsu;
|
|
|
|
|
bezt1= newnu->bezt;
|
|
|
|
|
while(b--) {
|
2007-06-14 14:36:27 +00:00
|
|
|
select_beztriple(bezt1, SELECT, flag, HIDDEN);
|
2002-10-12 11:37:38 +00:00
|
|
|
bezt1++;
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-26 12:50:00 +00:00
|
|
|
if(nu->flagu & CU_CYCLIC) {
|
|
|
|
|
if(starta!=0 || enda!=nu->pntsu-1) {
|
|
|
|
|
newnu->flagu &= ~CU_CYCLIC;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-04-28 14:43:20 +00:00
|
|
|
else if(nu->pntsv==1) { /* because UV Nurb has a different method for dupli */
|
2002-10-12 11:37:38 +00:00
|
|
|
bp= nu->bp;
|
|
|
|
|
for(a=0; a<nu->pntsu; a++) {
|
|
|
|
|
enda= -1;
|
|
|
|
|
starta= a;
|
|
|
|
|
while(bp->f1 & flag) {
|
2007-06-14 14:36:27 +00:00
|
|
|
select_bpoint(bp, DESELECT, flag, HIDDEN);
|
2002-10-12 11:37:38 +00:00
|
|
|
enda= a;
|
|
|
|
|
if(a>=nu->pntsu-1) break;
|
|
|
|
|
a++;
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
if(enda>=starta) {
|
|
|
|
|
newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN3");
|
|
|
|
|
memcpy(newnu, nu, sizeof(Nurb));
|
2008-05-25 23:05:13 +00:00
|
|
|
set_actNurb(newnu);
|
2002-10-12 11:37:38 +00:00
|
|
|
BLI_addtail(&editNurb, newnu);
|
|
|
|
|
newnu->pntsu= enda-starta+1;
|
|
|
|
|
newnu->bp = (BPoint*)MEM_mallocN((enda-starta+1) * sizeof(BPoint), "adduplicateN4");
|
|
|
|
|
memcpy(newnu->bp, nu->bp+starta, newnu->pntsu*sizeof(BPoint));
|
|
|
|
|
|
|
|
|
|
b= newnu->pntsu;
|
|
|
|
|
bp1= newnu->bp;
|
|
|
|
|
while(b--) {
|
2007-06-14 14:36:27 +00:00
|
|
|
select_bpoint(bp1, SELECT, flag, HIDDEN);
|
2002-10-12 11:37:38 +00:00
|
|
|
bp1++;
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-26 12:50:00 +00:00
|
|
|
if(nu->flagu & CU_CYCLIC) {
|
|
|
|
|
if(starta!=0 || enda!=nu->pntsu-1) {
|
|
|
|
|
newnu->flagu &= ~CU_CYCLIC;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* knots */
|
2008-05-26 09:50:46 +00:00
|
|
|
newnu->knotsu= NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
makeknots(newnu, 1, newnu->flagu>>1);
|
|
|
|
|
}
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2003-04-28 14:43:20 +00:00
|
|
|
/* a rectangular area in nurb has to be selected */
|
2002-10-12 11:37:38 +00:00
|
|
|
if(isNurbsel(nu)) {
|
|
|
|
|
usel= MEM_callocN(nu->pntsu, "adduplicateN4");
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
for(a=0; a<nu->pntsv; a++) {
|
|
|
|
|
for(b=0; b<nu->pntsu; b++, bp++) {
|
|
|
|
|
if(bp->f1 & flag) usel[b]++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
newu= 0;
|
|
|
|
|
newv= 0;
|
|
|
|
|
for(a=0; a<nu->pntsu; a++) {
|
|
|
|
|
if(usel[a]) {
|
|
|
|
|
if(newv==0 || usel[a]==newv) {
|
|
|
|
|
newv= usel[a];
|
|
|
|
|
newu++;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
newv= 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(newu==0 || newv==0) {
|
|
|
|
|
printf("Can't duplicate Nurb\n");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
|
|
if(newu==1) SWAP(short, newu, newv);
|
|
|
|
|
|
|
|
|
|
newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN5");
|
|
|
|
|
memcpy(newnu, nu, sizeof(Nurb));
|
|
|
|
|
BLI_addtail(&editNurb, newnu);
|
2008-05-25 23:05:13 +00:00
|
|
|
set_actNurb(newnu);
|
2002-10-12 11:37:38 +00:00
|
|
|
newnu->pntsu= newu;
|
|
|
|
|
newnu->pntsv= newv;
|
|
|
|
|
newnu->bp =
|
|
|
|
|
(BPoint*)MEM_mallocN(newu * newv * sizeof(BPoint), "adduplicateN6");
|
2008-05-26 09:50:46 +00:00
|
|
|
clamp_nurb_order_u(newnu);
|
|
|
|
|
clamp_nurb_order_v(newnu);
|
|
|
|
|
|
|
|
|
|
newnu->knotsu= newnu->knotsv= NULL;
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
bp= newnu->bp;
|
|
|
|
|
bp1= nu->bp;
|
|
|
|
|
for(a=0; a<nu->pntsv; a++) {
|
|
|
|
|
for(b=0; b<nu->pntsu; b++, bp1++) {
|
|
|
|
|
if(bp1->f1 & flag) {
|
|
|
|
|
memcpy(bp, bp1, sizeof(BPoint));
|
2007-06-14 14:36:27 +00:00
|
|
|
select_bpoint(bp1, DESELECT, flag, HIDDEN);
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-05-26 09:50:46 +00:00
|
|
|
if (check_valid_nurb_u(newnu)) {
|
|
|
|
|
if(nu->pntsu==newnu->pntsu && nu->knotsu) {
|
|
|
|
|
newnu->knotsu= MEM_dupallocN( nu->knotsu );
|
|
|
|
|
} else {
|
|
|
|
|
makeknots(newnu, 1, newnu->flagu>>1);
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2008-05-26 09:50:46 +00:00
|
|
|
if (check_valid_nurb_v(newnu)) {
|
|
|
|
|
if(nu->pntsv==newnu->pntsv && nu->knotsv) {
|
|
|
|
|
newnu->knotsv= MEM_dupallocN( nu->knotsv );
|
|
|
|
|
} else {
|
|
|
|
|
makeknots(newnu, 2, newnu->flagv>>1);
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MEM_freeN(usel);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nu= nu->prev;
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-25 23:05:13 +00:00
|
|
|
/* actnu changed */
|
2002-10-12 11:37:38 +00:00
|
|
|
allqueue(REDRAWBUTSEDIT, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void switchdirectionNurb2(void)
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
|
2007-03-14 09:08:41 +00:00
|
|
|
if(G.vd==0 || !(G.obedit->lay & G.vd->lay))
|
|
|
|
|
return;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if( isNurbsel(nu) ) switchdirectionNurb(nu);
|
|
|
|
|
}
|
|
|
|
|
|
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-14 19:03:11 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
allqueue(REDRAWVIEW3D, 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("Switch direction");
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void switchdirection_knots(float *base, int tot)
|
|
|
|
|
{
|
|
|
|
|
float *fp1, *fp2, *tempf;
|
|
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
if(base==NULL || tot==0) return;
|
|
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
/* reverse knots */
|
2002-10-12 11:37:38 +00:00
|
|
|
a= tot;
|
|
|
|
|
fp1= base;
|
|
|
|
|
fp2= fp1+(a-1);
|
|
|
|
|
a/= 2;
|
|
|
|
|
while(fp1!=fp2 && a>0) {
|
|
|
|
|
SWAP(float, *fp1, *fp2);
|
|
|
|
|
a--;
|
|
|
|
|
fp1++;
|
|
|
|
|
fp2--;
|
|
|
|
|
}
|
2003-04-28 14:43:20 +00:00
|
|
|
/* and make in increasing order again */
|
2002-10-12 11:37:38 +00:00
|
|
|
a= tot;
|
|
|
|
|
fp1= base;
|
|
|
|
|
fp2=tempf= MEM_mallocN(sizeof(float)*a, "switchdirect");
|
|
|
|
|
while(a--) {
|
|
|
|
|
fp2[0]= fabs(fp1[1]-fp1[0]);
|
|
|
|
|
fp1++;
|
|
|
|
|
fp2++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
a= tot-1;
|
|
|
|
|
fp1= base;
|
|
|
|
|
fp2= tempf;
|
|
|
|
|
fp1[0]= 0.0;
|
|
|
|
|
fp1++;
|
|
|
|
|
while(a--) {
|
|
|
|
|
fp1[0]= fp1[-1]+fp2[0];
|
|
|
|
|
fp1++;
|
|
|
|
|
fp2++;
|
|
|
|
|
}
|
|
|
|
|
MEM_freeN(tempf);
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-08 00:06:48 +00:00
|
|
|
void setweightNurb(void)
|
|
|
|
|
{
|
|
|
|
|
static float weight= 1.0f;
|
|
|
|
|
extern ListBase editNurb;
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
if(fbutton(&weight, 0.0f, 1.0f, 10, 10, "Set Weight")) {
|
|
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
|
|
|
|
if(nu->bezt) {
|
|
|
|
|
for(bezt=nu->bezt, a=0; a<nu->pntsu; a++, bezt++) {
|
|
|
|
|
if(bezt->f2 & SELECT)
|
|
|
|
|
bezt->weight= weight;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(nu->bp) {
|
|
|
|
|
for(bp=nu->bp, a=0; a<nu->pntsu*nu->pntsv; a++, bp++) {
|
|
|
|
|
if(bp->f1 & SELECT)
|
|
|
|
|
bp->weight= weight;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BIF_undo_push("Set Curve Weight");
|
|
|
|
|
DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setradiusNurb( void )
|
|
|
|
|
{
|
|
|
|
|
static float radius= 1.0f;
|
|
|
|
|
extern ListBase editNurb;
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
if(fbutton(&radius, 0.0001f, 10.0f, 10, 10, "Set Radius")) {
|
|
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
|
|
|
|
if(nu->bezt) {
|
|
|
|
|
for(bezt=nu->bezt, a=0; a<nu->pntsu; a++, bezt++) {
|
|
|
|
|
if(bezt->f2 & SELECT)
|
|
|
|
|
bezt->radius= radius;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(nu->bp) {
|
|
|
|
|
for(bp=nu->bp, a=0; a<nu->pntsu*nu->pntsv; a++, bp++) {
|
|
|
|
|
if(bp->f1 & SELECT)
|
|
|
|
|
bp->radius= radius;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BIF_undo_push("Set Curve Radius");
|
|
|
|
|
DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
allqueue(REDRAWBUTSALL, 0);
|
|
|
|
|
allqueue(REDRAWINFO, 1); /* 1, because header->win==0! */
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-12 14:46:32 +00:00
|
|
|
void smoothNurb( void )
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
extern ListBase editNurb;
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BezTriple *bezt, *beztOrig;
|
|
|
|
|
BPoint *bp, *bpOrig;
|
|
|
|
|
int a, i, change = 0;
|
|
|
|
|
|
|
|
|
|
/* floats for smoothing */
|
|
|
|
|
float val, newval, offset;
|
|
|
|
|
|
|
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
|
|
|
|
if(nu->bezt) {
|
|
|
|
|
change = 0;
|
|
|
|
|
beztOrig = MEM_dupallocN( nu->bezt );
|
|
|
|
|
for(bezt=nu->bezt+1, a=1; a<nu->pntsu-1; a++, bezt++) {
|
|
|
|
|
if(bezt->f2 & SELECT) {
|
|
|
|
|
for(i=0; i<3; i++) {
|
|
|
|
|
val = bezt->vec[1][i];
|
|
|
|
|
newval = ((beztOrig+(a-1))->vec[1][i] * 0.5) + ((beztOrig+(a+1))->vec[1][i] * 0.5);
|
|
|
|
|
offset = (val*((1.0/6.0)*5)) + (newval*(1.0/6.0)) - val;
|
|
|
|
|
/* offset handles */
|
|
|
|
|
bezt->vec[1][i] += offset;
|
|
|
|
|
bezt->vec[0][i] += offset;
|
|
|
|
|
bezt->vec[2][i] += offset;
|
|
|
|
|
}
|
|
|
|
|
change = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MEM_freeN(beztOrig);
|
|
|
|
|
if (change)
|
|
|
|
|
calchandlesNurb(nu);
|
|
|
|
|
} else if (nu->bp) {
|
|
|
|
|
bpOrig = MEM_dupallocN( nu->bp );
|
|
|
|
|
/* Same as above, keep these the same! */
|
|
|
|
|
for(bp=nu->bp+1, a=1; a<nu->pntsu-1; a++, bp++) {
|
|
|
|
|
if(bp->f1 & SELECT) {
|
|
|
|
|
for(i=0; i<3; i++) {
|
|
|
|
|
val = bp->vec[i];
|
|
|
|
|
newval = ((bpOrig+(a-1))->vec[i] * 0.5) + ((bpOrig+(a+1))->vec[i] * 0.5);
|
|
|
|
|
offset = (val*((1.0/6.0)*5)) + (newval*(1.0/6.0)) - val;
|
|
|
|
|
|
|
|
|
|
bp->vec[i] += offset;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MEM_freeN(bpOrig);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BIF_undo_push("Smooth Curve");
|
|
|
|
|
DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
allqueue(REDRAWBUTSALL, 0);
|
|
|
|
|
allqueue(REDRAWINFO, 1); /* 1, because header->win==0! */
|
|
|
|
|
}
|
2007-11-08 00:06:48 +00:00
|
|
|
|
|
|
|
|
/* TODO, make smoothing distance based */
|
|
|
|
|
void smoothradiusNurb( void )
|
|
|
|
|
{
|
|
|
|
|
extern ListBase editNurb;
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
/* use for smoothing */
|
|
|
|
|
int last_sel;
|
|
|
|
|
int start_sel, end_sel; /* selection indicies, inclusive */
|
|
|
|
|
float start_rad, end_rad, fac, range;
|
|
|
|
|
|
|
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
|
|
|
|
if(nu->bezt) {
|
|
|
|
|
|
|
|
|
|
for (last_sel=0; last_sel < nu->pntsu; last_sel++) {
|
|
|
|
|
/* loop over selection segments of a curve, smooth each */
|
|
|
|
|
|
|
|
|
|
/* Start BezTriple code, this is duplicated below for points, make sure these functions stay in sync */
|
|
|
|
|
start_sel = end_sel = -1;
|
|
|
|
|
for(bezt=nu->bezt+last_sel, a=last_sel; a<nu->pntsu; a++, bezt++) {
|
|
|
|
|
if(bezt->f2 & SELECT) {
|
|
|
|
|
start_sel = a;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* incase there are no other selected verts */
|
|
|
|
|
end_sel = start_sel;
|
|
|
|
|
for(bezt=nu->bezt+(start_sel+1), a=start_sel+1; a<nu->pntsu; a++, bezt++) {
|
|
|
|
|
if((bezt->f2 & SELECT)==0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
end_sel = a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (start_sel == -1) {
|
|
|
|
|
last_sel = nu->pntsu; /* next... */
|
|
|
|
|
} else {
|
|
|
|
|
last_sel = end_sel; /* before we modify it */
|
|
|
|
|
|
|
|
|
|
/* now blend between start and end sel */
|
|
|
|
|
start_rad = end_rad = -1.0;
|
|
|
|
|
|
|
|
|
|
if (start_sel == end_sel) {
|
|
|
|
|
/* simple, only 1 point selected */
|
|
|
|
|
if (start_sel>0) start_rad = (nu->bezt+start_sel-1)->radius;
|
|
|
|
|
if (end_sel!=-1 && end_sel < nu->pntsu) end_rad = (nu->bezt+start_sel+1)->radius;
|
|
|
|
|
|
|
|
|
|
if (start_rad >= 0.0 && end_rad >= 0.0) (nu->bezt+start_sel)->radius = (start_rad + end_rad)/2;
|
|
|
|
|
else if (start_rad >= 0.0) (nu->bezt+start_sel)->radius = start_rad;
|
|
|
|
|
else if (end_rad >= 0.0) (nu->bezt+start_sel)->radius = end_rad;
|
|
|
|
|
} else {
|
|
|
|
|
/* if endpoints selected, then use them */
|
|
|
|
|
if (start_sel==0) {
|
|
|
|
|
start_rad = (nu->bezt+start_sel)->radius;
|
|
|
|
|
start_sel++; /* we dont want to edit the selected endpoint */
|
|
|
|
|
} else {
|
|
|
|
|
start_rad = (nu->bezt+start_sel-1)->radius;
|
|
|
|
|
}
|
|
|
|
|
if (end_sel==nu->pntsu-1) {
|
|
|
|
|
end_rad = (nu->bezt+end_sel)->radius;
|
|
|
|
|
end_sel--; /* we dont want to edit the selected endpoint */
|
|
|
|
|
} else {
|
|
|
|
|
end_rad = (nu->bezt+end_sel+1)->radius;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-08 13:02:59 +00:00
|
|
|
/* Now Blend between the points */
|
2007-11-08 00:06:48 +00:00
|
|
|
range = (float)(end_sel - start_sel) + 2.0f;
|
|
|
|
|
for(bezt=nu->bezt+start_sel, a=start_sel; a<=end_sel; a++, bezt++) {
|
|
|
|
|
fac = (float)(1+a-start_sel) / range;
|
|
|
|
|
bezt->radius = start_rad*(1.0-fac) + end_rad*fac;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (nu->bp) {
|
|
|
|
|
/* Same as above, keep these the same! */
|
|
|
|
|
for (last_sel=0; last_sel < nu->pntsu; last_sel++) {
|
|
|
|
|
/* loop over selection segments of a curve, smooth each */
|
|
|
|
|
|
|
|
|
|
/* Start BezTriple code, this is duplicated below for points, make sure these functions stay in sync */
|
|
|
|
|
start_sel = end_sel = -1;
|
|
|
|
|
for(bp=nu->bp+last_sel, a=last_sel; a<nu->pntsu; a++, bp++) {
|
|
|
|
|
if(bp->f1 & SELECT) {
|
|
|
|
|
start_sel = a;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* incase there are no other selected verts */
|
|
|
|
|
end_sel = start_sel;
|
|
|
|
|
for(bp=nu->bp+(start_sel+1), a=start_sel+1; a<nu->pntsu; a++, bp++) {
|
|
|
|
|
if((bp->f1 & SELECT)==0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
end_sel = a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (start_sel == -1) {
|
|
|
|
|
last_sel = nu->pntsu; /* next... */
|
|
|
|
|
} else {
|
|
|
|
|
last_sel = end_sel; /* before we modify it */
|
|
|
|
|
|
|
|
|
|
/* now blend between start and end sel */
|
|
|
|
|
start_rad = end_rad = -1.0;
|
|
|
|
|
|
|
|
|
|
if (start_sel == end_sel) {
|
|
|
|
|
/* simple, only 1 point selected */
|
|
|
|
|
if (start_sel>0) start_rad = (nu->bp+start_sel-1)->radius;
|
|
|
|
|
if (end_sel!=-1 && end_sel < nu->pntsu) end_rad = (nu->bp+start_sel+1)->radius;
|
|
|
|
|
|
|
|
|
|
if (start_rad >= 0.0 && end_rad >= 0.0) (nu->bp+start_sel)->radius = (start_rad + end_rad)/2;
|
|
|
|
|
else if (start_rad >= 0.0) (nu->bp+start_sel)->radius = start_rad;
|
|
|
|
|
else if (end_rad >= 0.0) (nu->bp+start_sel)->radius = end_rad;
|
|
|
|
|
} else {
|
|
|
|
|
/* if endpoints selected, then use them */
|
|
|
|
|
if (start_sel==0) {
|
|
|
|
|
start_rad = (nu->bp+start_sel)->radius;
|
|
|
|
|
start_sel++; /* we dont want to edit the selected endpoint */
|
|
|
|
|
} else {
|
|
|
|
|
start_rad = (nu->bp+start_sel-1)->radius;
|
|
|
|
|
}
|
|
|
|
|
if (end_sel==nu->pntsu-1) {
|
|
|
|
|
end_rad = (nu->bp+end_sel)->radius;
|
|
|
|
|
end_sel--; /* we dont want to edit the selected endpoint */
|
|
|
|
|
} else {
|
|
|
|
|
end_rad = (nu->bp+end_sel+1)->radius;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-08 13:02:59 +00:00
|
|
|
/* Now Blend between the points */
|
2007-11-08 00:06:48 +00:00
|
|
|
range = (float)(end_sel - start_sel) + 2.0f;
|
|
|
|
|
for(bp=nu->bp+start_sel, a=start_sel; a<=end_sel; a++, bp++) {
|
|
|
|
|
fac = (float)(1+a-start_sel) / range;
|
|
|
|
|
bp->radius = start_rad*(1.0-fac) + end_rad*fac;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BIF_undo_push("Smooth Curve Radius");
|
|
|
|
|
DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
allqueue(REDRAWBUTSALL, 0);
|
|
|
|
|
allqueue(REDRAWINFO, 1); /* 1, because header->win==0! */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* **************** EDIT ************************ */
|
|
|
|
|
|
2007-06-14 14:36:27 +00:00
|
|
|
/* next == 1 -> select next */
|
|
|
|
|
/* next == -1 -> select previous */
|
|
|
|
|
/* cont == 1 -> select continuously */
|
|
|
|
|
/* selstatus, inverts behaviour */
|
|
|
|
|
static void select_adjacent_cp(short next, short cont, short selstatus)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
BPoint *bp;
|
2007-06-14 14:36:27 +00:00
|
|
|
int a;
|
|
|
|
|
short lastsel= 0, sel=0;
|
|
|
|
|
|
|
|
|
|
if(next==0) return;
|
|
|
|
|
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2007-06-14 14:36:27 +00:00
|
|
|
lastsel=0;
|
|
|
|
|
if((nu->type & 7)==CU_BEZIER) {
|
|
|
|
|
a= nu->pntsu;
|
2002-10-12 11:37:38 +00:00
|
|
|
bezt= nu->bezt;
|
2007-06-14 14:36:27 +00:00
|
|
|
if(next < 0) bezt= (nu->bezt + (a-1));
|
|
|
|
|
while(a--) {
|
|
|
|
|
if(a-abs(next) < 0) break;
|
|
|
|
|
sel= 0;
|
2007-12-01 23:25:00 +00:00
|
|
|
if((lastsel==0) && (bezt->hide==0) && ((bezt->f2 & SELECT) || (selstatus==0))) {
|
2007-06-14 14:36:27 +00:00
|
|
|
bezt+=next;
|
2007-12-01 23:25:00 +00:00
|
|
|
if(!(bezt->f2 & SELECT) || (selstatus==0)) {
|
2007-06-14 14:36:27 +00:00
|
|
|
sel= select_beztriple(bezt, selstatus, 1, VISIBLE);
|
|
|
|
|
if((sel==1) && (cont==0)) lastsel= 1;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2007-06-14 14:36:27 +00:00
|
|
|
else {
|
|
|
|
|
bezt+=next;
|
|
|
|
|
lastsel= 0;
|
|
|
|
|
}
|
|
|
|
|
/* move around in zigzag way so that we go through each */
|
|
|
|
|
bezt-=(next-next/abs(next));
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2007-06-14 14:36:27 +00:00
|
|
|
a= nu->pntsu*nu->pntsv;
|
2002-10-12 11:37:38 +00:00
|
|
|
bp= nu->bp;
|
2007-06-14 14:36:27 +00:00
|
|
|
if(next < 0) bp= (nu->bp + (a-1));
|
|
|
|
|
while(a--) {
|
|
|
|
|
if(a-abs(next) < 0) break;
|
|
|
|
|
sel=0;
|
2007-12-11 14:19:05 +00:00
|
|
|
if((lastsel==0) && (bp->hide==0) && ((bp->f1 & SELECT) || (selstatus==0))) {
|
2007-06-14 14:36:27 +00:00
|
|
|
bp+=next;
|
2007-12-11 14:19:05 +00:00
|
|
|
if(!(bp->f1 & SELECT) || (selstatus==0)) {
|
2007-06-14 14:36:27 +00:00
|
|
|
sel= select_bpoint(bp, selstatus, 1, VISIBLE);
|
|
|
|
|
if((sel==1) && (cont==0)) lastsel= 1;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2007-06-14 14:36:27 +00:00
|
|
|
else {
|
|
|
|
|
bp+=next;
|
|
|
|
|
lastsel= 0;
|
|
|
|
|
}
|
|
|
|
|
/* move around in zigzag way so that we go through each */
|
|
|
|
|
bp-=(next-next/abs(next));
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-06-14 14:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static short nurb_has_selected_cps()
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
int a;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2007-06-14 14:36:27 +00:00
|
|
|
if((nu->type & 7)==CU_BEZIER) {
|
|
|
|
|
a= nu->pntsu;
|
2002-10-12 11:37:38 +00:00
|
|
|
bezt= nu->bezt;
|
2007-06-14 14:36:27 +00:00
|
|
|
while(a--) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if(bezt->hide==0) {
|
2007-12-01 23:25:00 +00:00
|
|
|
if((bezt->f1 & SELECT)
|
|
|
|
|
|| (bezt->f2 & SELECT)
|
|
|
|
|
|| (bezt->f3 & SELECT)) return 1;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2007-06-14 14:36:27 +00:00
|
|
|
a= nu->pntsu*nu->pntsv;
|
2002-10-12 11:37:38 +00:00
|
|
|
bp= nu->bp;
|
2007-06-14 14:36:27 +00:00
|
|
|
while(a--) {
|
2007-12-01 23:25:00 +00:00
|
|
|
if((bp->hide==0) && (bp->f1 & SELECT)) return 1;
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-06-14 14:36:27 +00:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void deselectall_nurb()
|
|
|
|
|
{
|
|
|
|
|
if(!G.vd || !(G.obedit->lay & G.vd->lay))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(nurb_has_selected_cps()) { /* deselect all */
|
|
|
|
|
selectend_nurb(FIRST, 0, DESELECT); /* set first control points as unselected */
|
|
|
|
|
select_adjacent_cp(1, 1, DESELECT); /* cascade selection */
|
|
|
|
|
}
|
|
|
|
|
else { /* select all */
|
|
|
|
|
selectend_nurb(FIRST, 0, SELECT); /* set first control points as selected */
|
|
|
|
|
select_adjacent_cp(1, 1, SELECT); /* cascade selection */
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
2007-05-01 14:37:59 +00:00
|
|
|
BIF_undo_push("Deselect all");
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void hideNurb(int swap)
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
int a, sel;
|
|
|
|
|
|
|
|
|
|
if(G.obedit==0) 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
|
|
|
BIF_undo_push("Hide");
|
2004-08-31 13:43:18 +00:00
|
|
|
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if((nu->type & 7)==CU_BEZIER) {
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
sel= 0;
|
|
|
|
|
while(a--) {
|
2007-12-01 23:25:00 +00:00
|
|
|
if(BEZSELECTED_HIDDENHANDLES(bezt)) {
|
2007-06-14 14:36:27 +00:00
|
|
|
select_beztriple(bezt, DESELECT, 1, HIDDEN);
|
2002-10-12 11:37:38 +00:00
|
|
|
bezt->hide= 1;
|
|
|
|
|
}
|
2007-05-01 14:37:59 +00:00
|
|
|
if(bezt->hide) sel++;
|
2002-10-12 11:37:38 +00:00
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
if(sel==nu->pntsu) nu->hide= 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
sel= 0;
|
|
|
|
|
while(a--) {
|
2007-12-11 14:19:05 +00:00
|
|
|
if(swap==0 && (bp->f1 & SELECT)) {
|
2007-06-14 14:36:27 +00:00
|
|
|
select_bpoint(bp, DESELECT, 1, HIDDEN);
|
2002-10-12 11:37:38 +00:00
|
|
|
bp->hide= 1;
|
|
|
|
|
}
|
2007-12-11 14:19:05 +00:00
|
|
|
else if(swap && (bp->f1 & SELECT)==0) {
|
2007-06-14 14:36:27 +00:00
|
|
|
select_bpoint(bp, DESELECT, 1, HIDDEN);
|
2002-10-12 11:37:38 +00:00
|
|
|
bp->hide= 1;
|
|
|
|
|
}
|
2007-05-01 14:37:59 +00:00
|
|
|
if(bp->hide) sel++;
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
if(sel==nu->pntsu*nu->pntsv) nu->hide= 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
2002-10-12 11:37:38 +00:00
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
2004-04-07 11:35:11 +00:00
|
|
|
allqueue(REDRAWBUTSEDIT, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void revealNurb()
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
if(G.obedit==0) return;
|
|
|
|
|
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
nu->hide= 0;
|
|
|
|
|
if((nu->type & 7)==CU_BEZIER) {
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
while(a--) {
|
|
|
|
|
if(bezt->hide) {
|
2007-06-14 14:36:27 +00:00
|
|
|
select_beztriple(bezt, SELECT, 1, HIDDEN);
|
2002-10-12 11:37:38 +00:00
|
|
|
bezt->hide= 0;
|
|
|
|
|
}
|
|
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
while(a--) {
|
|
|
|
|
if(bp->hide) {
|
2007-06-14 14:36:27 +00:00
|
|
|
select_bpoint(bp, SELECT, 1, HIDDEN);
|
2002-10-12 11:37:38 +00:00
|
|
|
bp->hide= 0;
|
|
|
|
|
}
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
2002-10-12 11:37:38 +00:00
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 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("Reveal");
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void selectswapNurb()
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
if(G.obedit==0) return;
|
|
|
|
|
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if((nu->type & 7)==CU_BEZIER) {
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
while(a--) {
|
|
|
|
|
if(bezt->hide==0) {
|
2007-12-01 23:25:00 +00:00
|
|
|
bezt->f2 ^= SELECT; /* always do the center point */
|
|
|
|
|
if ((G.f & G_HIDDENHANDLES)==0) {
|
|
|
|
|
bezt->f1 ^= SELECT;
|
|
|
|
|
bezt->f3 ^= SELECT;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
while(a--) {
|
2007-06-14 14:36:27 +00:00
|
|
|
swap_selection_bpoint(bp);
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 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("Select swap");
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Divide the line segments associated with the currently selected
|
|
|
|
|
* curve nodes (Bezier or NURB). If there are no valid segment
|
|
|
|
|
* selections within the current selection, nothing happens.
|
|
|
|
|
*
|
|
|
|
|
* @deffunc subdividenurb subdivideNurb(void)
|
|
|
|
|
* @return Nothing
|
|
|
|
|
* @param None
|
|
|
|
|
*/
|
|
|
|
|
void subdivideNurb()
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BezTriple *prevbezt, *bezt, *beztnew, *beztn;
|
|
|
|
|
BPoint *bp, *prevbp, *bpnew, *bpn;
|
2004-07-23 14:31:22 +00:00
|
|
|
float vec[15];
|
|
|
|
|
int a, b, sel, amount, *usel, *vsel;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
// printf("*** subdivideNurb: entering subdivide\n");
|
|
|
|
|
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2004-07-23 14:31:22 +00:00
|
|
|
amount= 0;
|
2002-10-12 11:37:38 +00:00
|
|
|
if((nu->type & 7)==CU_BEZIER) {
|
|
|
|
|
/*
|
|
|
|
|
Insert a point into a 2D Bezier curve.
|
|
|
|
|
Endpoints are preserved. Otherwise, all selected and inserted points are
|
|
|
|
|
newly created. Old points are discarded.
|
|
|
|
|
*/
|
2003-04-28 14:43:20 +00:00
|
|
|
/* count */
|
2008-05-26 12:50:00 +00:00
|
|
|
if(nu->flagu & CU_CYCLIC) {
|
2002-10-12 11:37:38 +00:00
|
|
|
a= nu->pntsu;
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
prevbezt= bezt+(a-1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
a= nu->pntsu-1;
|
|
|
|
|
prevbezt= nu->bezt;
|
|
|
|
|
bezt= prevbezt+1;
|
|
|
|
|
}
|
|
|
|
|
while(a--) {
|
2007-12-01 23:25:00 +00:00
|
|
|
if( BEZSELECTED_HIDDENHANDLES(prevbezt) && BEZSELECTED_HIDDENHANDLES(bezt) ) amount++;
|
2002-10-12 11:37:38 +00:00
|
|
|
prevbezt= bezt;
|
|
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-23 14:31:22 +00:00
|
|
|
if(amount) {
|
2003-04-28 14:43:20 +00:00
|
|
|
/* insert */
|
2002-10-12 11:37:38 +00:00
|
|
|
beztnew =
|
2004-07-23 14:31:22 +00:00
|
|
|
(BezTriple*)MEM_mallocN((amount + nu->pntsu) * sizeof(BezTriple), "subdivNurb");
|
2002-10-12 11:37:38 +00:00
|
|
|
beztn= beztnew;
|
2008-05-26 12:50:00 +00:00
|
|
|
if(nu->flagu & CU_CYCLIC) {
|
2002-10-12 11:37:38 +00:00
|
|
|
a= nu->pntsu;
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
prevbezt= bezt+(a-1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
a= nu->pntsu-1;
|
|
|
|
|
prevbezt= nu->bezt;
|
|
|
|
|
bezt= prevbezt+1;
|
|
|
|
|
}
|
|
|
|
|
while(a--) {
|
|
|
|
|
memcpy(beztn, prevbezt, sizeof(BezTriple));
|
|
|
|
|
beztn++;
|
|
|
|
|
|
2007-12-01 23:25:00 +00:00
|
|
|
if( BEZSELECTED_HIDDENHANDLES(prevbezt) && BEZSELECTED_HIDDENHANDLES(bezt) ) {
|
2002-10-12 11:37:38 +00:00
|
|
|
memcpy(beztn, bezt, sizeof(BezTriple));
|
2004-07-23 14:31:22 +00:00
|
|
|
|
|
|
|
|
/* midpoint subdividing */
|
|
|
|
|
VecMidf(vec, prevbezt->vec[1], prevbezt->vec[2]);
|
|
|
|
|
VecMidf(vec+3, prevbezt->vec[2], bezt->vec[0]);
|
|
|
|
|
VecMidf(vec+6, bezt->vec[0], bezt->vec[1]);
|
|
|
|
|
|
|
|
|
|
VecMidf(vec+9, vec, vec+3);
|
|
|
|
|
VecMidf(vec+12, vec+3, vec+6);
|
|
|
|
|
|
|
|
|
|
/* change handle of prev beztn */
|
|
|
|
|
VECCOPY((beztn-1)->vec[2], vec);
|
|
|
|
|
/* new point */
|
|
|
|
|
VECCOPY(beztn->vec[0], vec+9);
|
|
|
|
|
VecMidf(beztn->vec[1], vec+9, vec+12);
|
|
|
|
|
VECCOPY(beztn->vec[2], vec+12);
|
|
|
|
|
/* handle of next bezt */
|
2008-05-26 12:50:00 +00:00
|
|
|
if(a==0 && (nu->flagu & CU_CYCLIC)) {VECCOPY(beztnew->vec[0], vec+6);}
|
2004-07-23 14:31:22 +00:00
|
|
|
else {VECCOPY(bezt->vec[0], vec+6);}
|
|
|
|
|
|
2006-08-13 07:37:51 +00:00
|
|
|
beztn->radius = (prevbezt->radius + bezt->radius)/2.0f;
|
|
|
|
|
beztn->weight = (prevbezt->weight + bezt->weight)/2.0f;
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
beztn++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prevbezt= bezt;
|
|
|
|
|
bezt++;
|
|
|
|
|
}
|
2003-04-28 14:43:20 +00:00
|
|
|
/* last point */
|
2008-05-26 12:50:00 +00:00
|
|
|
if((nu->flagu & CU_CYCLIC)==0) memcpy(beztn, prevbezt, sizeof(BezTriple));
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
MEM_freeN(nu->bezt);
|
|
|
|
|
nu->bezt= beztnew;
|
2004-07-23 14:31:22 +00:00
|
|
|
nu->pntsu+= amount;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
calchandlesNurb(nu);
|
|
|
|
|
}
|
|
|
|
|
} /* End of 'if((nu->type & 7)==CU_BEZIER)' */
|
|
|
|
|
else if (nu->pntsv==1) {
|
|
|
|
|
/*
|
|
|
|
|
All flat lines (ie. co-planar), except flat Nurbs. Flat NURB curves
|
|
|
|
|
are handled together with the regular NURB plane division, as it
|
|
|
|
|
should be. I split it off just now, let's see if it is
|
|
|
|
|
stable... nzc 30-5-'00
|
|
|
|
|
*/
|
2003-04-28 14:43:20 +00:00
|
|
|
/* count */
|
2008-05-26 12:50:00 +00:00
|
|
|
if(nu->flagu & CU_CYCLIC) {
|
2008-09-23 06:26:48 +00:00
|
|
|
a= nu->pntsu;
|
2002-10-12 11:37:38 +00:00
|
|
|
bp= nu->bp;
|
|
|
|
|
prevbp= bp+(a-1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
a= nu->pntsu-1;
|
|
|
|
|
prevbp= nu->bp;
|
|
|
|
|
bp= prevbp+1;
|
|
|
|
|
}
|
|
|
|
|
while(a--) {
|
2007-12-11 14:19:05 +00:00
|
|
|
if( (bp->f1 & SELECT) && (prevbp->f1 & SELECT) ) amount++;
|
2002-10-12 11:37:38 +00:00
|
|
|
prevbp= bp;
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-23 14:31:22 +00:00
|
|
|
if(amount) {
|
2003-04-28 14:43:20 +00:00
|
|
|
/* insert */
|
2002-10-12 11:37:38 +00:00
|
|
|
bpnew =
|
2004-07-23 14:31:22 +00:00
|
|
|
(BPoint*)MEM_mallocN((amount + nu->pntsu) * sizeof(BPoint), "subdivNurb2");
|
2002-10-12 11:37:38 +00:00
|
|
|
bpn= bpnew;
|
|
|
|
|
|
2008-05-26 12:50:00 +00:00
|
|
|
if(nu->flagu & CU_CYCLIC) {
|
2002-10-12 11:37:38 +00:00
|
|
|
a= nu->pntsu;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
prevbp= bp+(a-1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
a= nu->pntsu-1;
|
|
|
|
|
prevbp= nu->bp;
|
|
|
|
|
bp= prevbp+1;
|
|
|
|
|
}
|
|
|
|
|
while(a--) {
|
|
|
|
|
memcpy(bpn, prevbp, sizeof(BPoint));
|
|
|
|
|
bpn++;
|
|
|
|
|
|
2007-12-11 14:19:05 +00:00
|
|
|
if( (bp->f1 & SELECT) && (prevbp->f1 & SELECT) ) {
|
2002-10-12 11:37:38 +00:00
|
|
|
// printf("*** subdivideNurb: insert 'linear' point\n");
|
|
|
|
|
memcpy(bpn, bp, sizeof(BPoint));
|
|
|
|
|
bpn->vec[0]= (prevbp->vec[0]+bp->vec[0])/2.0;
|
|
|
|
|
bpn->vec[1]= (prevbp->vec[1]+bp->vec[1])/2.0;
|
|
|
|
|
bpn->vec[2]= (prevbp->vec[2]+bp->vec[2])/2.0;
|
|
|
|
|
bpn->vec[3]= (prevbp->vec[3]+bp->vec[3])/2.0;
|
|
|
|
|
bpn++;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
prevbp= bp;
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
2008-05-26 12:50:00 +00:00
|
|
|
if((nu->flagu & CU_CYCLIC)==0) memcpy(bpn, prevbp, sizeof(BPoint)); /* last point */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
MEM_freeN(nu->bp);
|
|
|
|
|
nu->bp= bpnew;
|
2004-07-23 14:31:22 +00:00
|
|
|
nu->pntsu+= amount;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
if(nu->type & 4) {
|
|
|
|
|
makeknots(nu, 1, nu->flagu>>1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} /* End of 'else if(nu->pntsv==1)' */
|
|
|
|
|
else if((nu->type & 7)==CU_NURBS) {
|
|
|
|
|
/* This is a very strange test ... */
|
|
|
|
|
/**
|
|
|
|
|
Subdivide NURB surfaces - nzc 30-5-'00 -
|
|
|
|
|
|
|
|
|
|
Subdivision of a NURB curve can be effected by adding a
|
|
|
|
|
control point (insertion of a knot), or by raising the
|
|
|
|
|
degree of the functions used to build the NURB. The
|
|
|
|
|
expression
|
|
|
|
|
|
|
|
|
|
degree = #knots - #controlpoints + 1 (J Walter piece)
|
|
|
|
|
degree = #knots - #controlpoints (Blender
|
|
|
|
|
implementation)
|
|
|
|
|
( this is confusing.... what is true? Another concern
|
|
|
|
|
is that the JW piece allows the curve to become
|
|
|
|
|
explicitly 1st order derivative discontinuous, while
|
|
|
|
|
this is not what we want here... )
|
|
|
|
|
|
|
|
|
|
is an invariant for a single NURB curve. Raising the degree
|
|
|
|
|
of the NURB is done elsewhere; the degree is assumed
|
|
|
|
|
constant during this opration. Degree is a property shared
|
|
|
|
|
by all controlpoints in a curve (even though it is stored
|
|
|
|
|
per control point - this can be misleading).
|
|
|
|
|
Adding a knot is done by searching for the place in the
|
|
|
|
|
knot vector where a certain knot value must be inserted, or
|
|
|
|
|
by picking an appropriate knot value between two existing
|
|
|
|
|
ones. The number of controlpoints that is influenced by the
|
|
|
|
|
insertion depends on the order of the curve. A certain
|
|
|
|
|
minimum number of knots is needed to form high-order
|
|
|
|
|
curves, as can be seen from the equation above. In Blender,
|
|
|
|
|
currently NURBs may be up to 6th order, so we modify at
|
|
|
|
|
most 6 points. One point is added. For an n-degree curve,
|
|
|
|
|
n points are discarded, and n+1 points inserted
|
|
|
|
|
(so effectively, n points are modified). (that holds for
|
|
|
|
|
the JW piece, but it seems not for our NURBs)
|
|
|
|
|
In practice, the knot spacing is copied, but the tail
|
|
|
|
|
(the points following the insertion point) need to be
|
|
|
|
|
offset to keep the knot series ascending. The knot series
|
|
|
|
|
is always a series of monotonically ascending integers in
|
|
|
|
|
Blender. When not enough control points are available to
|
|
|
|
|
fit the order, duplicates of the endpoints are added as
|
|
|
|
|
needed.
|
|
|
|
|
*/
|
2003-04-28 14:43:20 +00:00
|
|
|
/* selection-arrays */
|
2002-10-12 11:37:38 +00:00
|
|
|
usel= MEM_callocN(sizeof(int)*nu->pntsu, "subivideNurb3");
|
|
|
|
|
vsel= MEM_callocN(sizeof(int)*nu->pntsv, "subivideNurb3");
|
|
|
|
|
sel= 0;
|
|
|
|
|
|
|
|
|
|
/* Count the number of selected points. */
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
for(a=0; a<nu->pntsv; a++) {
|
|
|
|
|
for(b=0; b<nu->pntsu; b++) {
|
2007-12-11 14:19:05 +00:00
|
|
|
if(bp->f1 & SELECT) {
|
2002-10-12 11:37:38 +00:00
|
|
|
usel[b]++;
|
|
|
|
|
vsel[a]++;
|
|
|
|
|
sel++;
|
|
|
|
|
}
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-04-28 14:43:20 +00:00
|
|
|
if( sel == (nu->pntsu*nu->pntsv) ) { /* subdivide entire nurb */
|
2002-10-12 11:37:38 +00:00
|
|
|
/* Global subdivision is a special case of partial
|
|
|
|
|
subdivision. Strange it is considered separately... */
|
|
|
|
|
bpn=bpnew= MEM_mallocN( (2*nu->pntsu-1)*(2*nu->pntsv-1)*sizeof(BPoint), "subdivideNurb4");
|
|
|
|
|
bp= nu->bp;
|
2003-04-28 14:43:20 +00:00
|
|
|
/* first subdivide rows */
|
2002-10-12 11:37:38 +00:00
|
|
|
for(a=0; a<nu->pntsv; a++) {
|
|
|
|
|
for(b=0; b<nu->pntsu; b++) {
|
|
|
|
|
*bpn= *bp;
|
|
|
|
|
bpn++;
|
|
|
|
|
bp++;
|
|
|
|
|
if(b<nu->pntsu-1) {
|
|
|
|
|
*bpn= *bp;
|
|
|
|
|
prevbp= bp-1;
|
|
|
|
|
bpn->vec[0]= (prevbp->vec[0]+bp->vec[0])/2.0;
|
|
|
|
|
bpn->vec[1]= (prevbp->vec[1]+bp->vec[1])/2.0;
|
|
|
|
|
bpn->vec[2]= (prevbp->vec[2]+bp->vec[2])/2.0;
|
|
|
|
|
bpn->vec[3]= (prevbp->vec[3]+bp->vec[3])/2.0;
|
|
|
|
|
bpn++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bpn+= (2*nu->pntsu-1);
|
|
|
|
|
}
|
2003-04-28 14:43:20 +00:00
|
|
|
/* now insert new */
|
2002-10-12 11:37:38 +00:00
|
|
|
bpn= bpnew+(2*nu->pntsu-1);
|
|
|
|
|
bp= bpnew+(4*nu->pntsu-2);
|
|
|
|
|
prevbp= bpnew;
|
|
|
|
|
for(a=1; a<nu->pntsv; a++) {
|
|
|
|
|
|
|
|
|
|
for(b=0; b<2*nu->pntsu-1; b++) {
|
|
|
|
|
*bpn= *bp;
|
|
|
|
|
bpn->vec[0]= (prevbp->vec[0]+bp->vec[0])/2.0;
|
|
|
|
|
bpn->vec[1]= (prevbp->vec[1]+bp->vec[1])/2.0;
|
|
|
|
|
bpn->vec[2]= (prevbp->vec[2]+bp->vec[2])/2.0;
|
|
|
|
|
bpn->vec[3]= (prevbp->vec[3]+bp->vec[3])/2.0;
|
|
|
|
|
bpn++;
|
|
|
|
|
bp++;
|
|
|
|
|
prevbp++;
|
|
|
|
|
}
|
|
|
|
|
bp+= (2*nu->pntsu-1);
|
|
|
|
|
bpn+= (2*nu->pntsu-1);
|
|
|
|
|
prevbp+= (2*nu->pntsu-1);
|
|
|
|
|
}
|
|
|
|
|
MEM_freeN(nu->bp);
|
|
|
|
|
nu->bp= bpnew;
|
|
|
|
|
nu->pntsu= 2*nu->pntsu-1;
|
|
|
|
|
nu->pntsv= 2*nu->pntsv-1;
|
|
|
|
|
makeknots(nu, 1, nu->flagu>>1);
|
|
|
|
|
makeknots(nu, 2, nu->flagv>>1);
|
|
|
|
|
} /* End of 'if(sel== nu->pntsu*nu->pntsv)' (subdivide entire NURB) */
|
|
|
|
|
else {
|
2003-04-28 14:43:20 +00:00
|
|
|
/* subdivide in v direction? */
|
2002-10-12 11:37:38 +00:00
|
|
|
sel= 0;
|
|
|
|
|
for(a=0; a<nu->pntsv-1; a++) {
|
|
|
|
|
if(vsel[a]==nu->pntsu && vsel[a+1]==nu->pntsu) sel++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(sel) { /* V ! */
|
|
|
|
|
bpn=bpnew= MEM_mallocN( (sel+nu->pntsv)*nu->pntsu*sizeof(BPoint), "subdivideNurb4");
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
for(a=0; a<nu->pntsv; a++) {
|
|
|
|
|
for(b=0; b<nu->pntsu; b++) {
|
|
|
|
|
*bpn= *bp;
|
|
|
|
|
bpn++;
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
if( (a<nu->pntsv-1) && vsel[a]==nu->pntsu && vsel[a+1]==nu->pntsu ) {
|
|
|
|
|
prevbp= bp- nu->pntsu;
|
|
|
|
|
for(b=0; b<nu->pntsu; b++) {
|
|
|
|
|
/*
|
|
|
|
|
This simple bisection must be replaces by a
|
|
|
|
|
subtle resampling of a number of points. Our
|
|
|
|
|
task is made slightly easier because each
|
|
|
|
|
point in our curve is a separate data
|
|
|
|
|
node. (is it?)
|
|
|
|
|
*/
|
|
|
|
|
*bpn= *prevbp;
|
|
|
|
|
bpn->vec[0]= (prevbp->vec[0]+bp->vec[0])/2.0;
|
|
|
|
|
bpn->vec[1]= (prevbp->vec[1]+bp->vec[1])/2.0;
|
|
|
|
|
bpn->vec[2]= (prevbp->vec[2]+bp->vec[2])/2.0;
|
|
|
|
|
bpn->vec[3]= (prevbp->vec[3]+bp->vec[3])/2.0;
|
|
|
|
|
bpn++;
|
|
|
|
|
prevbp++;
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
bp-= nu->pntsu;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MEM_freeN(nu->bp);
|
|
|
|
|
nu->bp= bpnew;
|
|
|
|
|
nu->pntsv+= sel;
|
|
|
|
|
makeknots(nu, 2, nu->flagv>>1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2003-04-28 14:43:20 +00:00
|
|
|
/* or in u direction? */
|
2002-10-12 11:37:38 +00:00
|
|
|
sel= 0;
|
|
|
|
|
for(a=0; a<nu->pntsu-1; a++) {
|
|
|
|
|
if(usel[a]==nu->pntsv && usel[a+1]==nu->pntsv) sel++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(sel) { /* U ! */
|
|
|
|
|
/* Inserting U points is sort of 'default' Flat curves only get */
|
|
|
|
|
/* U points inserted in them. */
|
|
|
|
|
bpn=bpnew= MEM_mallocN( (sel+nu->pntsu)*nu->pntsv*sizeof(BPoint), "subdivideNurb4");
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
for(a=0; a<nu->pntsv; a++) {
|
|
|
|
|
for(b=0; b<nu->pntsu; b++) {
|
|
|
|
|
*bpn= *bp;
|
|
|
|
|
bpn++;
|
|
|
|
|
bp++;
|
|
|
|
|
if( (b<nu->pntsu-1) && usel[b]==nu->pntsv && usel[b+1]==nu->pntsv ) {
|
|
|
|
|
/*
|
|
|
|
|
One thing that bugs me here is that the
|
|
|
|
|
orders of things are not the same as in
|
|
|
|
|
the JW piece. Also, this implies that we
|
|
|
|
|
handle at most 3rd order curves? I miss
|
|
|
|
|
some symmetry here...
|
|
|
|
|
*/
|
|
|
|
|
prevbp= bp- 1;
|
|
|
|
|
*bpn= *prevbp;
|
|
|
|
|
bpn->vec[0]= (prevbp->vec[0]+bp->vec[0])/2.0;
|
|
|
|
|
bpn->vec[1]= (prevbp->vec[1]+bp->vec[1])/2.0;
|
|
|
|
|
bpn->vec[2]= (prevbp->vec[2]+bp->vec[2])/2.0;
|
|
|
|
|
bpn->vec[3]= (prevbp->vec[3]+bp->vec[3])/2.0;
|
|
|
|
|
bpn++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MEM_freeN(nu->bp);
|
|
|
|
|
nu->bp= bpnew;
|
|
|
|
|
nu->pntsu+= sel;
|
|
|
|
|
makeknots(nu, 1, nu->flagu>>1); /* shift knots
|
|
|
|
|
forward */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MEM_freeN(usel);
|
|
|
|
|
MEM_freeN(vsel);
|
2003-04-28 14:43:20 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
} /* End of 'if((nu->type & 7)==CU_NURBS)' */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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-14 19:03:11 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
2004-04-07 11:35:11 +00:00
|
|
|
allqueue(REDRAWBUTSEDIT, 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("Subdivide");
|
|
|
|
|
|
2002-10-12 11:37:38 +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
|
|
|
static void findnearestNurbvert__doClosest(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, int x, int y)
|
2002-10-12 11:37:38 +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
|
|
|
struct { BPoint *bp; BezTriple *bezt; Nurb *nurb; short dist, hpoint, select, mval[2]; } *data = userData;
|
2002-10-12 11:37:38 +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
|
|
|
short flag;
|
|
|
|
|
short temp;
|
2002-10-12 11:37:38 +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
|
|
|
if (bp) {
|
|
|
|
|
flag = bp->f1;
|
|
|
|
|
} else {
|
|
|
|
|
if (beztindex==0) {
|
|
|
|
|
flag = bezt->f1;
|
|
|
|
|
} else if (beztindex==1) {
|
|
|
|
|
flag = bezt->f2;
|
|
|
|
|
} else {
|
|
|
|
|
flag = bezt->f3;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-10-12 11:37:38 +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
|
|
|
temp = abs(data->mval[0]-x) + abs(data->mval[1]-y);
|
|
|
|
|
if ((flag&1)==data->select) temp += 5;
|
|
|
|
|
if (bezt && beztindex==1) temp += 3; /* middle points get a small disadvantage */
|
2002-10-12 11:37:38 +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
|
|
|
if (temp<data->dist) {
|
|
|
|
|
data->dist = temp;
|
2002-10-12 11:37:38 +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
|
|
|
data->bp = bp;
|
|
|
|
|
data->bezt = bezt;
|
|
|
|
|
data->nurb = nu;
|
|
|
|
|
data->hpoint = bezt?beztindex:0;
|
2002-10-12 11:37:38 +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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static short findnearestNurbvert(short sel, Nurb **nurb, BezTriple **bezt, BPoint **bp)
|
|
|
|
|
{
|
|
|
|
|
/* sel==1: selected gets a disadvantage */
|
|
|
|
|
/* in nurb and bezt or bp the nearest is written */
|
|
|
|
|
/* return 0 1 2: handlepunt */
|
|
|
|
|
struct { BPoint *bp; BezTriple *bezt; Nurb *nurb; short dist, hpoint, select, mval[2]; } data = {0};
|
|
|
|
|
|
|
|
|
|
data.dist = 100;
|
|
|
|
|
data.hpoint = 0;
|
|
|
|
|
data.select = sel;
|
|
|
|
|
getmouseco_areawin(data.mval);
|
|
|
|
|
|
|
|
|
|
nurbs_foreachScreenVert(findnearestNurbvert__doClosest, &data);
|
|
|
|
|
|
|
|
|
|
*nurb = data.nurb;
|
|
|
|
|
*bezt = data.bezt;
|
|
|
|
|
*bp = data.bp;
|
2002-10-12 11:37:38 +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
|
|
|
return data.hpoint;
|
2002-10-12 11:37:38 +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
|
|
|
static void findselectedNurbvert(Nurb **nu, BezTriple **bezt, BPoint **bp)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2003-04-28 14:43:20 +00:00
|
|
|
/* in nu and (bezt or bp) selected are written if there's 1 sel. */
|
|
|
|
|
/* if more points selected in 1 spline: return only nu, bezt and bp are 0 */
|
2002-10-12 11:37:38 +00:00
|
|
|
Nurb *nu1;
|
|
|
|
|
BezTriple *bezt1;
|
|
|
|
|
BPoint *bp1;
|
|
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
*nu= 0;
|
|
|
|
|
*bezt= 0;
|
|
|
|
|
*bp= 0;
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu1= editNurb.first; nu1; nu1= nu1->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if((nu1->type & 7)==CU_BEZIER) {
|
|
|
|
|
bezt1= nu1->bezt;
|
|
|
|
|
a= nu1->pntsu;
|
|
|
|
|
while(a--) {
|
2007-12-01 23:25:00 +00:00
|
|
|
if( (bezt1->f1 & SELECT) || (bezt1->f2 & SELECT) || (bezt1->f3 & SELECT) ) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if(*nu!=0 && *nu!= nu1) {
|
|
|
|
|
*nu= 0;
|
|
|
|
|
*bp= 0;
|
|
|
|
|
*bezt= 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if(*bezt || *bp) {
|
|
|
|
|
*bp= 0;
|
|
|
|
|
*bezt= 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
*bezt= bezt1;
|
|
|
|
|
*nu= nu1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bezt1++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bp1= nu1->bp;
|
|
|
|
|
a= nu1->pntsu*nu1->pntsv;
|
|
|
|
|
while(a--) {
|
|
|
|
|
if( bp1->f1 & 1 ) {
|
|
|
|
|
if(*nu!=0 && *nu!= nu1) {
|
|
|
|
|
*bp= 0;
|
|
|
|
|
*bezt= 0;
|
|
|
|
|
*nu= 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if(*bezt || *bp) {
|
|
|
|
|
*bp= 0;
|
|
|
|
|
*bezt= 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
*bp= bp1;
|
|
|
|
|
*nu= nu1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bp1++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-13 19:15:02 +00:00
|
|
|
int convertspline(short type, Nurb *nu)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
int a, c, nr;
|
|
|
|
|
|
2005-06-13 19:15:02 +00:00
|
|
|
if((nu->type & 7)==0) { /* Poly */
|
|
|
|
|
if(type==CU_BEZIER) { /* to Bezier with vecthandles */
|
|
|
|
|
nr= nu->pntsu;
|
|
|
|
|
bezt =
|
|
|
|
|
(BezTriple*)MEM_callocN(nr * sizeof(BezTriple), "setsplinetype2");
|
|
|
|
|
nu->bezt= bezt;
|
|
|
|
|
a= nr;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
while(a--) {
|
|
|
|
|
VECCOPY(bezt->vec[1], bp->vec);
|
|
|
|
|
bezt->f1=bezt->f2=bezt->f3= bp->f1;
|
|
|
|
|
bezt->h1= bezt->h2= HD_VECT;
|
2006-08-13 07:37:51 +00:00
|
|
|
bezt->weight= bp->weight;
|
|
|
|
|
bezt->radius= bp->radius;
|
2005-06-13 19:15:02 +00:00
|
|
|
bp++;
|
|
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
MEM_freeN(nu->bp);
|
|
|
|
|
nu->bp= 0;
|
|
|
|
|
nu->pntsu= nr;
|
|
|
|
|
nu->type &= ~7;
|
|
|
|
|
nu->type |= 1;
|
|
|
|
|
calchandlesNurb(nu);
|
|
|
|
|
}
|
2008-09-23 06:26:48 +00:00
|
|
|
else if(type==CU_NURBS) {
|
2005-06-13 19:15:02 +00:00
|
|
|
nu->type &= ~7;
|
|
|
|
|
nu->type+= 4;
|
|
|
|
|
nu->orderu= 4;
|
2008-05-26 12:50:00 +00:00
|
|
|
nu->flagu &= CU_CYCLIC; /* disable all flags except for cyclic */
|
2005-06-13 19:15:02 +00:00
|
|
|
nu->flagu += 4;
|
|
|
|
|
makeknots(nu, 1, nu->flagu>>1);
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
while(a--) {
|
|
|
|
|
bp->vec[3]= 1.0;
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2005-06-13 19:15:02 +00:00
|
|
|
else if((nu->type & 7)==CU_BEZIER) { /* Bezier */
|
|
|
|
|
if(type==0 || type==4) { /* to Poly or Nurb */
|
|
|
|
|
nr= 3*nu->pntsu;
|
|
|
|
|
nu->bp = MEM_callocN(nr * sizeof(BPoint), "setsplinetype");
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
while(a--) {
|
|
|
|
|
if(type==0 && bezt->h1==HD_VECT && bezt->h2==HD_VECT) {
|
|
|
|
|
/* vector handle becomes 1 poly vertice */
|
|
|
|
|
VECCOPY(bp->vec, bezt->vec[1]);
|
|
|
|
|
bp->vec[3]= 1.0;
|
|
|
|
|
bp->f1= bezt->f2;
|
|
|
|
|
nr-= 2;
|
2006-08-13 07:37:51 +00:00
|
|
|
bp->radius= bezt->radius;
|
|
|
|
|
bp->weight= bezt->weight;
|
2005-06-13 19:15:02 +00:00
|
|
|
bp++;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2005-06-13 19:15:02 +00:00
|
|
|
else {
|
|
|
|
|
for(c=0;c<3;c++) {
|
|
|
|
|
VECCOPY(bp->vec, bezt->vec[c]);
|
2002-10-12 11:37:38 +00:00
|
|
|
bp->vec[3]= 1.0;
|
2005-06-13 19:15:02 +00:00
|
|
|
if(c==0) bp->f1= bezt->f1;
|
|
|
|
|
else if(c==1) bp->f1= bezt->f2;
|
|
|
|
|
else bp->f1= bezt->f3;
|
2006-08-13 07:37:51 +00:00
|
|
|
bp->radius= bezt->radius;
|
|
|
|
|
bp->weight= bezt->weight;
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-06-13 19:15:02 +00:00
|
|
|
bezt++;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2005-06-13 19:15:02 +00:00
|
|
|
MEM_freeN(nu->bezt);
|
|
|
|
|
nu->bezt= 0;
|
|
|
|
|
nu->pntsu= nr;
|
|
|
|
|
nu->pntsv= 1;
|
|
|
|
|
nu->orderu= 4;
|
|
|
|
|
nu->orderv= 1;
|
|
|
|
|
nu->type &= ~7;
|
|
|
|
|
nu->type+= type;
|
2008-05-26 12:50:00 +00:00
|
|
|
if(nu->flagu & CU_CYCLIC) c= nu->orderu-1;
|
2005-06-13 19:15:02 +00:00
|
|
|
else c= 0;
|
|
|
|
|
if(type== 4) {
|
2008-05-26 12:50:00 +00:00
|
|
|
nu->flagu &= CU_CYCLIC; /* disable all flags except for cyclic */
|
2005-06-13 19:15:02 +00:00
|
|
|
nu->flagu += 4;
|
|
|
|
|
makeknots(nu, 1, nu->flagu>>1);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2005-06-13 19:15:02 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if( (nu->type & 7)==CU_NURBS) {
|
|
|
|
|
if(type==0) { /* to Poly */
|
|
|
|
|
nu->type &= ~7;
|
2006-02-08 12:52:57 +00:00
|
|
|
if(nu->knotsu) MEM_freeN(nu->knotsu); /* python created nurbs have a knotsu of zero */
|
2008-05-26 09:50:46 +00:00
|
|
|
nu->knotsu= NULL;
|
2005-06-13 19:15:02 +00:00
|
|
|
if(nu->knotsv) MEM_freeN(nu->knotsv);
|
2008-05-26 09:50:46 +00:00
|
|
|
nu->knotsv= NULL;
|
2005-06-13 19:15:02 +00:00
|
|
|
}
|
|
|
|
|
else if(type==CU_BEZIER) { /* to Bezier */
|
|
|
|
|
nr= nu->pntsu/3;
|
2004-10-18 09:43:38 +00:00
|
|
|
|
2005-06-13 19:15:02 +00:00
|
|
|
if(nr<2)
|
|
|
|
|
return 1; /* conversion impossible */
|
|
|
|
|
else {
|
|
|
|
|
bezt = MEM_callocN(nr * sizeof(BezTriple), "setsplinetype2");
|
|
|
|
|
nu->bezt= bezt;
|
|
|
|
|
a= nr;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
while(a--) {
|
|
|
|
|
VECCOPY(bezt->vec[0], bp->vec);
|
|
|
|
|
bezt->f1= bp->f1;
|
|
|
|
|
bp++;
|
|
|
|
|
VECCOPY(bezt->vec[1], bp->vec);
|
|
|
|
|
bezt->f2= bp->f1;
|
|
|
|
|
bp++;
|
|
|
|
|
VECCOPY(bezt->vec[2], bp->vec);
|
|
|
|
|
bezt->f3= bp->f1;
|
2006-08-13 07:37:51 +00:00
|
|
|
bezt->radius= bp->radius;
|
|
|
|
|
bezt->weight= bp->weight;
|
2005-06-13 19:15:02 +00:00
|
|
|
bp++;
|
|
|
|
|
bezt++;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2005-06-13 19:15:02 +00:00
|
|
|
MEM_freeN(nu->bp);
|
|
|
|
|
nu->bp= 0;
|
|
|
|
|
MEM_freeN(nu->knotsu);
|
2008-05-26 09:50:46 +00:00
|
|
|
nu->knotsu= NULL;
|
2005-06-13 19:15:02 +00:00
|
|
|
nu->pntsu= nr;
|
|
|
|
|
nu->type &= ~7;
|
|
|
|
|
nu->type+= 1;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-06-13 19:15:02 +00:00
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setsplinetype(short type)
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
|
|
|
|
|
if(type==CU_CARDINAL || type==CU_BSPLINE) {
|
|
|
|
|
error("Not implemented yet");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2005-06-13 19:15:02 +00:00
|
|
|
if(isNurbsel(nu)) {
|
|
|
|
|
if (convertspline(type, nu))
|
|
|
|
|
error("no conversion possible");
|
|
|
|
|
}
|
2002-10-12 11:37:38 +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("Set spline type");
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ******************** SKINNING LOFTING!!! ******************** */
|
|
|
|
|
|
|
|
|
|
void rotate_direction_nurb(Nurb *nu)
|
|
|
|
|
{
|
|
|
|
|
BPoint *bp1, *bp2, *temp;
|
|
|
|
|
int u, v;
|
|
|
|
|
|
|
|
|
|
SWAP(short, nu->pntsu, nu->pntsv);
|
|
|
|
|
SWAP(short, nu->orderu, nu->orderv);
|
|
|
|
|
SWAP(short, nu->resolu, nu->resolv);
|
|
|
|
|
SWAP(short, nu->flagu, nu->flagv);
|
|
|
|
|
|
|
|
|
|
SWAP(float *, nu->knotsu, nu->knotsv);
|
|
|
|
|
switchdirection_knots(nu->knotsv, KNOTSV(nu) );
|
|
|
|
|
|
|
|
|
|
temp= MEM_dupallocN(nu->bp);
|
|
|
|
|
bp1= nu->bp;
|
|
|
|
|
for(v=0; v<nu->pntsv; v++) {
|
|
|
|
|
for(u=0; u<nu->pntsu; u++, bp1++) {
|
|
|
|
|
bp2= temp + (nu->pntsu-u-1)*(nu->pntsv) + v;
|
|
|
|
|
*bp1= *bp2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MEM_freeN(temp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int is_u_selected(Nurb *nu, int u)
|
|
|
|
|
{
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
int v;
|
|
|
|
|
|
|
|
|
|
/* what about resolu == 2? */
|
|
|
|
|
bp= nu->bp+u;
|
|
|
|
|
for(v=0; v<nu->pntsv-1; v++, bp+=nu->pntsu) {
|
2007-12-11 14:19:05 +00:00
|
|
|
if(v) if(bp->f1 & SELECT) return 1;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ******************************** */
|
|
|
|
|
|
|
|
|
|
typedef struct NurbSort {
|
|
|
|
|
struct NurbSort *next, *prev;
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
float vec[3];
|
|
|
|
|
} NurbSort;
|
|
|
|
|
|
|
|
|
|
static ListBase nsortbase= {0, 0};
|
|
|
|
|
/* static NurbSort *nusmain; */ /* this var seems to go unused... at least in this file */
|
|
|
|
|
|
|
|
|
|
void make_selection_list_nurb()
|
|
|
|
|
{
|
|
|
|
|
ListBase nbase= {0, 0};
|
|
|
|
|
NurbSort *nus, *nustest, *headdo, *taildo;
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
float dist, headdist, taildist;
|
|
|
|
|
int a;
|
|
|
|
|
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if( isNurbsel(nu) ) {
|
|
|
|
|
|
|
|
|
|
nus = (NurbSort*)MEM_callocN(sizeof(NurbSort), "sort");
|
|
|
|
|
BLI_addhead(&nbase, nus);
|
|
|
|
|
nus->nu= nu;
|
|
|
|
|
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
while(a--) {
|
|
|
|
|
VecAddf(nus->vec, nus->vec, bp->vec);
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
VecMulf(nus->vec, 1.0/(float)nu->pntsu);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* just add the first one */
|
|
|
|
|
nus= nbase.first;
|
|
|
|
|
BLI_remlink(&nbase, nus);
|
|
|
|
|
BLI_addtail( &nsortbase, nus);
|
|
|
|
|
|
|
|
|
|
/* now add, either at head or tail, the closest one */
|
|
|
|
|
while(nbase.first) {
|
|
|
|
|
|
|
|
|
|
headdist= taildist= 1.0e30;
|
|
|
|
|
headdo= taildo= 0;
|
|
|
|
|
|
|
|
|
|
nustest= nbase.first;
|
|
|
|
|
while(nustest) {
|
|
|
|
|
dist= VecLenf(nustest->vec, ((NurbSort *)nsortbase.first)->vec);
|
|
|
|
|
|
|
|
|
|
if(dist<headdist) {
|
|
|
|
|
headdist= dist;
|
|
|
|
|
headdo= nustest;
|
|
|
|
|
}
|
|
|
|
|
dist= VecLenf(nustest->vec, ((NurbSort *)nsortbase.last)->vec);
|
|
|
|
|
|
|
|
|
|
if(dist<taildist) {
|
|
|
|
|
taildist= dist;
|
|
|
|
|
taildo= nustest;
|
|
|
|
|
}
|
|
|
|
|
nustest= nustest->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(headdist<taildist) {
|
|
|
|
|
BLI_remlink(&nbase, headdo);
|
|
|
|
|
BLI_addhead(&nsortbase, headdo);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_remlink(&nbase, taildo);
|
|
|
|
|
BLI_addtail(&nsortbase, taildo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void merge_2_nurb(Nurb *nu1, Nurb *nu2)
|
|
|
|
|
{
|
|
|
|
|
BPoint *bp, *bp1, *bp2, *temp;
|
|
|
|
|
float len1, len2;
|
|
|
|
|
int origu, u, v;
|
|
|
|
|
|
|
|
|
|
/* first nurbs will be changed to make u = resolu-1 selected */
|
|
|
|
|
/* 2nd nurbs will be changed to make u = 0 selected */
|
|
|
|
|
|
|
|
|
|
/* first nurbs: u = resolu-1 selected */
|
|
|
|
|
|
|
|
|
|
if( is_u_selected(nu1, nu1->pntsu-1) );
|
|
|
|
|
else {
|
|
|
|
|
rotate_direction_nurb(nu1);
|
|
|
|
|
if( is_u_selected(nu1, nu1->pntsu-1) );
|
|
|
|
|
else {
|
|
|
|
|
rotate_direction_nurb(nu1);
|
|
|
|
|
if( is_u_selected(nu1, nu1->pntsu-1) );
|
|
|
|
|
else {
|
|
|
|
|
rotate_direction_nurb(nu1);
|
|
|
|
|
if( is_u_selected(nu1, nu1->pntsu-1) );
|
|
|
|
|
else {
|
|
|
|
|
/* rotate again, now its OK! */
|
|
|
|
|
if(nu1->pntsv!=1) rotate_direction_nurb(nu1);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 2nd nurbs: u = 0 selected */
|
|
|
|
|
if( is_u_selected(nu2, 0) );
|
|
|
|
|
else {
|
|
|
|
|
rotate_direction_nurb(nu2);
|
|
|
|
|
if( is_u_selected(nu2, 0) );
|
|
|
|
|
else {
|
|
|
|
|
rotate_direction_nurb(nu2);
|
|
|
|
|
if( is_u_selected(nu2, 0) );
|
|
|
|
|
else {
|
|
|
|
|
rotate_direction_nurb(nu2);
|
|
|
|
|
if( is_u_selected(nu2, 0) );
|
|
|
|
|
else {
|
|
|
|
|
/* rotate again, now its OK! */
|
|
|
|
|
if(nu1->pntsu==1) rotate_direction_nurb(nu1);
|
|
|
|
|
if(nu2->pntsv!=1) rotate_direction_nurb(nu2);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( nu1->pntsv != nu2->pntsv ) {
|
2004-06-05 05:55:15 +00:00
|
|
|
error("Resolution doesn't match");
|
2002-10-12 11:37:38 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ok, now nu1 has the rightmost collumn and nu2 the leftmost collumn selected */
|
|
|
|
|
/* maybe we need a 'v' flip of nu2? */
|
|
|
|
|
|
|
|
|
|
bp1= nu1->bp+nu1->pntsu-1;
|
|
|
|
|
bp2= nu2->bp;
|
|
|
|
|
len1= 0.0;
|
|
|
|
|
|
|
|
|
|
for(v=0; v<nu1->pntsv; v++, bp1+=nu1->pntsu, bp2+=nu2->pntsu) {
|
|
|
|
|
len1+= VecLenf(bp1->vec, bp2->vec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bp1= nu1->bp + nu1->pntsu-1;
|
|
|
|
|
bp2= nu2->bp + nu2->pntsu*(nu2->pntsv-1);
|
|
|
|
|
len2= 0.0;
|
|
|
|
|
|
|
|
|
|
for(v=0; v<nu1->pntsv; v++, bp1+=nu1->pntsu, bp2-=nu2->pntsu) {
|
|
|
|
|
len2+= VecLenf(bp1->vec, bp2->vec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* merge */
|
|
|
|
|
origu= nu1->pntsu;
|
|
|
|
|
nu1->pntsu+= nu2->pntsu;
|
|
|
|
|
if(nu1->orderu<3) nu1->orderu++;
|
|
|
|
|
if(nu1->orderv<3) nu1->orderv++;
|
|
|
|
|
temp= nu1->bp;
|
|
|
|
|
nu1->bp= MEM_mallocN(nu1->pntsu*nu1->pntsv*sizeof(BPoint), "mergeBP");
|
|
|
|
|
|
|
|
|
|
bp= nu1->bp;
|
|
|
|
|
bp1= temp;
|
|
|
|
|
|
|
|
|
|
for(v=0; v<nu1->pntsv; v++) {
|
|
|
|
|
|
|
|
|
|
/* switch direction? */
|
|
|
|
|
if(len1<len2) bp2= nu2->bp + v*nu2->pntsu;
|
|
|
|
|
else bp2= nu2->bp + (nu1->pntsv-v-1)*nu2->pntsu;
|
|
|
|
|
|
|
|
|
|
for(u=0; u<nu1->pntsu; u++, bp++) {
|
|
|
|
|
if(u<origu) {
|
|
|
|
|
*bp= *bp1; bp1++;
|
2007-06-14 14:36:27 +00:00
|
|
|
select_bpoint(bp, SELECT, 1, HIDDEN);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
*bp= *bp2; bp2++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-07 11:35:11 +00:00
|
|
|
if((nu1->type & 7)==4) {
|
|
|
|
|
/* merge knots */
|
|
|
|
|
makeknots(nu1, 1, nu1->flagu>>1);
|
|
|
|
|
|
|
|
|
|
/* make knots, for merged curved for example */
|
|
|
|
|
makeknots(nu1, 2, nu1->flagv>>1);
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
MEM_freeN(temp);
|
|
|
|
|
BLI_remlink(&editNurb, nu2);
|
|
|
|
|
freeNurb(nu2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void merge_nurb()
|
|
|
|
|
{
|
|
|
|
|
NurbSort *nus1, *nus2;
|
|
|
|
|
int ok= 1;
|
|
|
|
|
|
|
|
|
|
make_selection_list_nurb();
|
|
|
|
|
|
|
|
|
|
if(nsortbase.first == nsortbase.last) {
|
|
|
|
|
BLI_freelistN(&nsortbase);
|
2004-06-05 05:55:15 +00:00
|
|
|
error("Too few selections to merge");
|
2002-10-12 11:37:38 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nus1= nsortbase.first;
|
|
|
|
|
nus2= nus1->next;
|
|
|
|
|
|
|
|
|
|
/* resolution match, to avoid uv rotations */
|
|
|
|
|
if(nus1->nu->pntsv==1) {
|
|
|
|
|
if(nus1->nu->pntsu==nus2->nu->pntsu || nus1->nu->pntsu==nus2->nu->pntsv);
|
|
|
|
|
else ok= 0;
|
|
|
|
|
}
|
|
|
|
|
else if(nus2->nu->pntsv==1) {
|
|
|
|
|
if(nus2->nu->pntsu==nus1->nu->pntsu || nus2->nu->pntsu==nus1->nu->pntsv);
|
|
|
|
|
else ok= 0;
|
|
|
|
|
}
|
|
|
|
|
else if( nus1->nu->pntsu==nus2->nu->pntsu || nus1->nu->pntsv==nus2->nu->pntsv);
|
|
|
|
|
else if( nus1->nu->pntsu==nus2->nu->pntsv || nus1->nu->pntsv==nus2->nu->pntsu);
|
|
|
|
|
else {
|
|
|
|
|
ok= 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ok==0) {
|
2004-06-05 05:55:15 +00:00
|
|
|
error("Resolution doesn't match");
|
2002-10-12 11:37:38 +00:00
|
|
|
BLI_freelistN(&nsortbase);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while(nus2) {
|
|
|
|
|
merge_2_nurb(nus1->nu, nus2->nu);
|
|
|
|
|
nus2= nus2->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLI_freelistN(&nsortbase);
|
|
|
|
|
|
2004-04-07 11:35:11 +00:00
|
|
|
countall();
|
2008-05-25 23:05:13 +00:00
|
|
|
set_actNurb(NULL);
|
2004-09-14 19:03:11 +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
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
2004-09-14 19:03:11 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
2004-04-07 11:35:11 +00:00
|
|
|
allqueue(REDRAWBUTSEDIT, 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("Merge");
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void addsegment_nurb()
|
|
|
|
|
{
|
2003-04-28 14:43:20 +00:00
|
|
|
/* joins 2 curves */
|
2002-10-12 11:37:38 +00:00
|
|
|
Nurb *nu, *nu1=0, *nu2=0;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
float *fp, offset;
|
|
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
/* first decide if this is a surface merge! */
|
|
|
|
|
if(G.obedit->type==OB_SURF) nu= editNurb.first;
|
2004-04-07 11:35:11 +00:00
|
|
|
else nu= NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
while(nu) {
|
|
|
|
|
if( isNurbsel(nu) ) {
|
|
|
|
|
|
|
|
|
|
if(nu->pntsu>1 && nu->pntsv>1) break;
|
|
|
|
|
if(isNurbsel_count(nu)>1) break;
|
|
|
|
|
if(isNurbsel_count(nu)==1) {
|
|
|
|
|
/* only 1 selected, not first or last, a little complex, but intuitive */
|
|
|
|
|
if(nu->pntsv==1) {
|
2007-12-11 14:19:05 +00:00
|
|
|
if( (nu->bp->f1 & SELECT) || ((nu->bp+nu->pntsu-1)->f1 & SELECT));
|
2002-10-12 11:37:38 +00:00
|
|
|
else break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
nu= nu->next;
|
|
|
|
|
}
|
|
|
|
|
if(nu) {
|
|
|
|
|
merge_nurb();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
/* find both nurbs and points, nu1 will be put behind nu2 */
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2008-05-26 12:50:00 +00:00
|
|
|
if((nu->flagu & CU_CYCLIC)==0) { /* not cyclic */
|
2002-10-12 11:37:38 +00:00
|
|
|
if( (nu->type & 7)==CU_BEZIER ) {
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
if(nu1==0) {
|
2007-12-01 23:25:00 +00:00
|
|
|
if( BEZSELECTED_HIDDENHANDLES(bezt) ) nu1= nu;
|
2002-10-12 11:37:38 +00:00
|
|
|
else {
|
|
|
|
|
bezt= bezt+(nu->pntsu-1);
|
2007-12-01 23:25:00 +00:00
|
|
|
if( BEZSELECTED_HIDDENHANDLES(bezt) ) {
|
2002-10-12 11:37:38 +00:00
|
|
|
nu1= nu;
|
|
|
|
|
switchdirectionNurb(nu);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(nu2==0) {
|
2007-12-01 23:25:00 +00:00
|
|
|
if( BEZSELECTED_HIDDENHANDLES(bezt) ) {
|
2002-10-12 11:37:38 +00:00
|
|
|
nu2= nu;
|
|
|
|
|
switchdirectionNurb(nu);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bezt= bezt+(nu->pntsu-1);
|
2007-12-01 23:25:00 +00:00
|
|
|
if( BEZSELECTED_HIDDENHANDLES(bezt) ) {
|
2002-10-12 11:37:38 +00:00
|
|
|
nu2= nu;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else break;
|
|
|
|
|
}
|
|
|
|
|
else if(nu->pntsv==1) {
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
if(nu1==0) {
|
2007-12-11 14:19:05 +00:00
|
|
|
if( bp->f1 & SELECT) nu1= nu;
|
2002-10-12 11:37:38 +00:00
|
|
|
else {
|
|
|
|
|
bp= bp+(nu->pntsu-1);
|
2007-12-11 14:19:05 +00:00
|
|
|
if( bp->f1 & SELECT ) {
|
2002-10-12 11:37:38 +00:00
|
|
|
nu1= nu;
|
|
|
|
|
switchdirectionNurb(nu);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(nu2==0) {
|
2007-12-11 14:19:05 +00:00
|
|
|
if( bp->f1 & SELECT ) {
|
2002-10-12 11:37:38 +00:00
|
|
|
nu2= nu;
|
|
|
|
|
switchdirectionNurb(nu);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bp= bp+(nu->pntsu-1);
|
2007-12-11 14:19:05 +00:00
|
|
|
if( bp->f1 & SELECT ) {
|
2002-10-12 11:37:38 +00:00
|
|
|
nu2= nu;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if((nu1 && nu2) && (nu1!=nu2)) {
|
|
|
|
|
if( nu1->type==nu2->type) {
|
|
|
|
|
if((nu1->type & 7)==CU_BEZIER) {
|
|
|
|
|
bezt =
|
|
|
|
|
(BezTriple*)MEM_mallocN((nu1->pntsu+nu2->pntsu) * sizeof(BezTriple), "addsegmentN");
|
|
|
|
|
memcpy(bezt, nu2->bezt, nu2->pntsu*sizeof(BezTriple));
|
|
|
|
|
memcpy(bezt+nu2->pntsu, nu1->bezt, nu1->pntsu*sizeof(BezTriple));
|
|
|
|
|
MEM_freeN(nu1->bezt);
|
|
|
|
|
nu1->bezt= bezt;
|
|
|
|
|
nu1->pntsu+= nu2->pntsu;
|
|
|
|
|
BLI_remlink(&editNurb, nu2);
|
2008-05-25 23:05:13 +00:00
|
|
|
freeNurb(nu2); nu2= NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
calchandlesNurb(nu1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bp =
|
|
|
|
|
(BPoint*)MEM_mallocN((nu1->pntsu+nu2->pntsu) * sizeof(BPoint), "addsegmentN2");
|
|
|
|
|
memcpy(bp, nu2->bp, nu2->pntsu*sizeof(BPoint) );
|
|
|
|
|
memcpy(bp+nu2->pntsu, nu1->bp, nu1->pntsu*sizeof(BPoint));
|
|
|
|
|
MEM_freeN(nu1->bp);
|
|
|
|
|
nu1->bp= bp;
|
|
|
|
|
|
|
|
|
|
a= nu1->pntsu+nu1->orderu;
|
|
|
|
|
|
|
|
|
|
nu1->pntsu+= nu2->pntsu;
|
|
|
|
|
BLI_remlink(&editNurb, nu2);
|
|
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
/* now join the knots */
|
2002-10-12 11:37:38 +00:00
|
|
|
if((nu1->type & 7)==4) {
|
2003-12-08 16:46:36 +00:00
|
|
|
if(nu1->knotsu==NULL) {
|
|
|
|
|
makeknots(nu1, 1, nu1->flagu>>1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
fp= MEM_mallocN(sizeof(float)*KNOTSU(nu1), "addsegment3");
|
|
|
|
|
memcpy(fp, nu1->knotsu, sizeof(float)*a);
|
|
|
|
|
MEM_freeN(nu1->knotsu);
|
|
|
|
|
nu1->knotsu= fp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
offset= nu1->knotsu[a-1] +1.0;
|
|
|
|
|
fp= nu1->knotsu+a;
|
|
|
|
|
for(a=0; a<nu2->pntsu; a++, fp++) {
|
|
|
|
|
if(nu2->knotsu)
|
|
|
|
|
*fp= offset+nu2->knotsu[a+1];
|
|
|
|
|
else
|
|
|
|
|
*fp = offset;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
2008-05-25 23:05:13 +00:00
|
|
|
freeNurb(nu2); nu2= NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
2004-04-07 11:35:11 +00:00
|
|
|
|
2008-05-25 23:05:13 +00:00
|
|
|
set_actNurb(NULL); /* for selected */
|
2004-04-07 11:35:11 +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
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
2004-09-14 19:03:11 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
2004-04-07 11:35:11 +00:00
|
|
|
allqueue(REDRAWBUTSEDIT, 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("Add segment");
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
else error("Can't make segment");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void mouse_nurb()
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BezTriple *bezt=0;
|
|
|
|
|
BPoint *bp=0;
|
|
|
|
|
short hand;
|
|
|
|
|
|
|
|
|
|
hand= findnearestNurbvert(1, &nu, &bezt, &bp);
|
|
|
|
|
|
|
|
|
|
if(bezt || bp) {
|
|
|
|
|
if((G.qual & LR_SHIFTKEY)==0) {
|
|
|
|
|
|
|
|
|
|
setflagsNurb(0);
|
|
|
|
|
|
|
|
|
|
if(bezt) {
|
|
|
|
|
|
2007-06-14 14:36:27 +00:00
|
|
|
if(hand==1) select_beztriple(bezt, SELECT, 1, HIDDEN);
|
2007-12-11 14:19:05 +00:00
|
|
|
else if(hand==0) bezt->f1|= SELECT;
|
|
|
|
|
else bezt->f3|= SELECT;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
lastselbp= bp;
|
2007-06-14 14:36:27 +00:00
|
|
|
select_bpoint(bp, SELECT, 1, HIDDEN);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if(bezt) {
|
|
|
|
|
if(hand==1) {
|
2007-12-01 23:25:00 +00:00
|
|
|
if(bezt->f2 & SELECT) select_beztriple(bezt, DESELECT, 1, HIDDEN);
|
2007-06-14 14:36:27 +00:00
|
|
|
else select_beztriple(bezt, SELECT, 1, HIDDEN);
|
2007-12-01 23:25:00 +00:00
|
|
|
} else if(hand==0) {
|
|
|
|
|
bezt->f1 ^= SELECT;
|
|
|
|
|
} else {
|
|
|
|
|
bezt->f3 ^= SELECT;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2007-12-01 23:25:00 +00:00
|
|
|
if(bp->f1 & SELECT) select_bpoint(bp, DESELECT, 1, HIDDEN);
|
2002-10-12 11:37:38 +00:00
|
|
|
else {
|
2007-06-14 14:36:27 +00:00
|
|
|
select_bpoint(bp, SELECT, 1, HIDDEN);
|
2002-10-12 11:37:38 +00:00
|
|
|
lastselbp= bp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
countall();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rightmouse_transform();
|
|
|
|
|
|
2008-05-25 23:05:13 +00:00
|
|
|
if(nu!=get_actNurb()) {
|
|
|
|
|
set_actNurb(nu);
|
2002-10-12 11:37:38 +00:00
|
|
|
allqueue(REDRAWBUTSEDIT, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
* Two usability tweaks in adding objects, with user prefs
This changes the default behaviour in adding new objects, which has been
discussed for a long time, in person, on the funboard, and in the tracker,
and was agreed to be implemented during the 2.5 release cycle, so here it is.
They have been made default, with preferences to bring back old behaviour since
although people like myself still prefer the new default anyway, it will benefit
new users the most.
The preferences are in the 'Edit Methods' section, changing back to old behaviour
is as simple as a click of a button.
- Switch to edit mode preference
By default, now adding a new object doesn't automatically switch to edit mode.
Not only can this be annoying (most of the time when setting up scenes and models
I don't want to edit it straight away anyway), but it's a major hurdle in the learning
curve that new users have had to deal with at a very early stage.
Blender's different modes are an important part of understanding how the software works
and should have clear behaviour. The problem is that when a user selects something from
the add menu, he's not telling Blender to change modes, he wants to add an object.
But Blender then goes ahead and changes modes underneath him anyway, something that was
never explicitly asked for, something that's unrelated to the mental task at hand, and
fundamentally important to the operation of the software.
We observed plenty of people struggling with this during the training sessions that
we ran during Project Orange, and there's also no shortage of "why can't I select
other objects" questions on the forums.
- Aligned to View preference
Now by default, adding a new object doesn't rotate it so it's aligned facing the view,
but rather, it's remains unrotated in world space. This is something that's more of
a convenience issue (allowing people like me to stop the 'Add->Tab->Alt R dance),
but also makes things easier for new users, especially when doing things like rigging.
For a lot of tools in Blender, like curve deform, path cycling, constraints, it's necessary
for your objects' local axes to be aligned. This requirement isn't that obvious, and I've
had to debug rigs a few times from the animator in our studio, who has everything set up
correctly, but he just happened to be in a different vie at the time he added the object,
so they're misaligned and causing problems. Having all objects get created aligned to
worldspace, by default, makes a lot of these problems go away. It's much more understandable
when rotations are caused by something you've done explicitly, rather than as a side effect
of the software.
For convenience as well, most of the time, when I'm working in context and I decide I need a new object,
particularly working on production scenes that involve more than just one model, an Alt R
is almost always required after adding, since I don't want to have to disrupt the current
view of the scene by switching to top view, just to add an object. It's a bit arbitrary,
the view from which you want to look at your objects isn't usually the way you want them to
be looking at you.
2007-10-31 21:55:06 +00:00
|
|
|
/* from what I can gather, the mode==0 magic number spins and bridges the nurbs based on the
|
|
|
|
|
* orientation of the global 3d view (yuck yuck!) mode==1 does the same, but doesn't bridge up
|
|
|
|
|
* up the new geometry, mode==2 now does the same as 0, but aligned to world axes, not the view.
|
|
|
|
|
*/
|
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
|
|
|
static void spin_nurb(float *dvec, short mode)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
float *curs, si,phi,n[3],q[4],cmat[3][3],tmat[3][3],imat[3][3];
|
|
|
|
|
float cent[3],bmat[3][3], rotmat[3][3], scalemat1[3][3], scalemat2[3][3];
|
|
|
|
|
float persmat[3][3], persinv[3][3];
|
|
|
|
|
short a,ok;
|
2007-03-14 09:08:41 +00:00
|
|
|
|
|
|
|
|
if(G.vd==0 || G.obedit==0 || G.obedit->type!=OB_SURF) return;
|
2002-10-12 11:37:38 +00:00
|
|
|
if( (G.vd->lay & G.obedit->lay)==0 ) return;
|
|
|
|
|
|
* Two usability tweaks in adding objects, with user prefs
This changes the default behaviour in adding new objects, which has been
discussed for a long time, in person, on the funboard, and in the tracker,
and was agreed to be implemented during the 2.5 release cycle, so here it is.
They have been made default, with preferences to bring back old behaviour since
although people like myself still prefer the new default anyway, it will benefit
new users the most.
The preferences are in the 'Edit Methods' section, changing back to old behaviour
is as simple as a click of a button.
- Switch to edit mode preference
By default, now adding a new object doesn't automatically switch to edit mode.
Not only can this be annoying (most of the time when setting up scenes and models
I don't want to edit it straight away anyway), but it's a major hurdle in the learning
curve that new users have had to deal with at a very early stage.
Blender's different modes are an important part of understanding how the software works
and should have clear behaviour. The problem is that when a user selects something from
the add menu, he's not telling Blender to change modes, he wants to add an object.
But Blender then goes ahead and changes modes underneath him anyway, something that was
never explicitly asked for, something that's unrelated to the mental task at hand, and
fundamentally important to the operation of the software.
We observed plenty of people struggling with this during the training sessions that
we ran during Project Orange, and there's also no shortage of "why can't I select
other objects" questions on the forums.
- Aligned to View preference
Now by default, adding a new object doesn't rotate it so it's aligned facing the view,
but rather, it's remains unrotated in world space. This is something that's more of
a convenience issue (allowing people like me to stop the 'Add->Tab->Alt R dance),
but also makes things easier for new users, especially when doing things like rigging.
For a lot of tools in Blender, like curve deform, path cycling, constraints, it's necessary
for your objects' local axes to be aligned. This requirement isn't that obvious, and I've
had to debug rigs a few times from the animator in our studio, who has everything set up
correctly, but he just happened to be in a different vie at the time he added the object,
so they're misaligned and causing problems. Having all objects get created aligned to
worldspace, by default, makes a lot of these problems go away. It's much more understandable
when rotations are caused by something you've done explicitly, rather than as a side effect
of the software.
For convenience as well, most of the time, when I'm working in context and I decide I need a new object,
particularly working on production scenes that involve more than just one model, an Alt R
is almost always required after adding, since I don't want to have to disrupt the current
view of the scene by switching to top view, just to add an object. It's a bit arbitrary,
the view from which you want to look at your objects isn't usually the way you want them to
be looking at you.
2007-10-31 21:55:06 +00:00
|
|
|
if (mode != 2) Mat3CpyMat4(persmat, G.vd->viewmat);
|
|
|
|
|
else Mat3One(persmat);
|
2002-10-12 11:37:38 +00:00
|
|
|
Mat3Inv(persinv, persmat);
|
|
|
|
|
|
2007-04-04 13:18:41 +00:00
|
|
|
/* imat and center and size */
|
2002-10-12 11:37:38 +00:00
|
|
|
Mat3CpyMat4(bmat, G.obedit->obmat);
|
|
|
|
|
Mat3Inv(imat, bmat);
|
|
|
|
|
|
|
|
|
|
curs= give_cursor();
|
|
|
|
|
VECCOPY(cent, curs);
|
|
|
|
|
VecSubf(cent, cent, G.obedit->obmat[3]);
|
|
|
|
|
Mat3MulVecfl(imat,cent);
|
|
|
|
|
|
* Two usability tweaks in adding objects, with user prefs
This changes the default behaviour in adding new objects, which has been
discussed for a long time, in person, on the funboard, and in the tracker,
and was agreed to be implemented during the 2.5 release cycle, so here it is.
They have been made default, with preferences to bring back old behaviour since
although people like myself still prefer the new default anyway, it will benefit
new users the most.
The preferences are in the 'Edit Methods' section, changing back to old behaviour
is as simple as a click of a button.
- Switch to edit mode preference
By default, now adding a new object doesn't automatically switch to edit mode.
Not only can this be annoying (most of the time when setting up scenes and models
I don't want to edit it straight away anyway), but it's a major hurdle in the learning
curve that new users have had to deal with at a very early stage.
Blender's different modes are an important part of understanding how the software works
and should have clear behaviour. The problem is that when a user selects something from
the add menu, he's not telling Blender to change modes, he wants to add an object.
But Blender then goes ahead and changes modes underneath him anyway, something that was
never explicitly asked for, something that's unrelated to the mental task at hand, and
fundamentally important to the operation of the software.
We observed plenty of people struggling with this during the training sessions that
we ran during Project Orange, and there's also no shortage of "why can't I select
other objects" questions on the forums.
- Aligned to View preference
Now by default, adding a new object doesn't rotate it so it's aligned facing the view,
but rather, it's remains unrotated in world space. This is something that's more of
a convenience issue (allowing people like me to stop the 'Add->Tab->Alt R dance),
but also makes things easier for new users, especially when doing things like rigging.
For a lot of tools in Blender, like curve deform, path cycling, constraints, it's necessary
for your objects' local axes to be aligned. This requirement isn't that obvious, and I've
had to debug rigs a few times from the animator in our studio, who has everything set up
correctly, but he just happened to be in a different vie at the time he added the object,
so they're misaligned and causing problems. Having all objects get created aligned to
worldspace, by default, makes a lot of these problems go away. It's much more understandable
when rotations are caused by something you've done explicitly, rather than as a side effect
of the software.
For convenience as well, most of the time, when I'm working in context and I decide I need a new object,
particularly working on production scenes that involve more than just one model, an Alt R
is almost always required after adding, since I don't want to have to disrupt the current
view of the scene by switching to top view, just to add an object. It's a bit arbitrary,
the view from which you want to look at your objects isn't usually the way you want them to
be looking at you.
2007-10-31 21:55:06 +00:00
|
|
|
if(dvec || mode==2) {
|
2002-10-12 11:37:38 +00:00
|
|
|
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];
|
2007-04-04 13:18:41 +00:00
|
|
|
Normalize(n);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
phi= M_PI/8.0;
|
|
|
|
|
q[0]= cos(phi);
|
|
|
|
|
si= sin(phi);
|
|
|
|
|
q[1]= n[0]*si;
|
|
|
|
|
q[2]= n[1]*si;
|
|
|
|
|
q[3]= n[2]*si;
|
|
|
|
|
QuatToMat3(q, cmat);
|
|
|
|
|
Mat3MulMat3(tmat, cmat, bmat);
|
|
|
|
|
Mat3MulMat3(rotmat, imat, tmat);
|
|
|
|
|
|
|
|
|
|
Mat3One(scalemat1);
|
|
|
|
|
scalemat1[0][0]= sqrt(2.0);
|
|
|
|
|
scalemat1[1][1]= sqrt(2.0);
|
|
|
|
|
|
|
|
|
|
Mat3MulMat3(tmat,persmat,bmat);
|
|
|
|
|
Mat3MulMat3(cmat,scalemat1,tmat);
|
|
|
|
|
Mat3MulMat3(tmat,persinv,cmat);
|
|
|
|
|
Mat3MulMat3(scalemat1,imat,tmat);
|
|
|
|
|
|
|
|
|
|
Mat3One(scalemat2);
|
|
|
|
|
scalemat2[0][0]/= sqrt(2.0);
|
|
|
|
|
scalemat2[1][1]/= sqrt(2.0);
|
|
|
|
|
|
|
|
|
|
Mat3MulMat3(tmat,persmat,bmat);
|
|
|
|
|
Mat3MulMat3(cmat,scalemat2,tmat);
|
|
|
|
|
Mat3MulMat3(tmat,persinv,cmat);
|
|
|
|
|
Mat3MulMat3(scalemat2,imat,tmat);
|
|
|
|
|
|
|
|
|
|
ok= 1;
|
|
|
|
|
|
|
|
|
|
for(a=0;a<7;a++) {
|
* Two usability tweaks in adding objects, with user prefs
This changes the default behaviour in adding new objects, which has been
discussed for a long time, in person, on the funboard, and in the tracker,
and was agreed to be implemented during the 2.5 release cycle, so here it is.
They have been made default, with preferences to bring back old behaviour since
although people like myself still prefer the new default anyway, it will benefit
new users the most.
The preferences are in the 'Edit Methods' section, changing back to old behaviour
is as simple as a click of a button.
- Switch to edit mode preference
By default, now adding a new object doesn't automatically switch to edit mode.
Not only can this be annoying (most of the time when setting up scenes and models
I don't want to edit it straight away anyway), but it's a major hurdle in the learning
curve that new users have had to deal with at a very early stage.
Blender's different modes are an important part of understanding how the software works
and should have clear behaviour. The problem is that when a user selects something from
the add menu, he's not telling Blender to change modes, he wants to add an object.
But Blender then goes ahead and changes modes underneath him anyway, something that was
never explicitly asked for, something that's unrelated to the mental task at hand, and
fundamentally important to the operation of the software.
We observed plenty of people struggling with this during the training sessions that
we ran during Project Orange, and there's also no shortage of "why can't I select
other objects" questions on the forums.
- Aligned to View preference
Now by default, adding a new object doesn't rotate it so it's aligned facing the view,
but rather, it's remains unrotated in world space. This is something that's more of
a convenience issue (allowing people like me to stop the 'Add->Tab->Alt R dance),
but also makes things easier for new users, especially when doing things like rigging.
For a lot of tools in Blender, like curve deform, path cycling, constraints, it's necessary
for your objects' local axes to be aligned. This requirement isn't that obvious, and I've
had to debug rigs a few times from the animator in our studio, who has everything set up
correctly, but he just happened to be in a different vie at the time he added the object,
so they're misaligned and causing problems. Having all objects get created aligned to
worldspace, by default, makes a lot of these problems go away. It's much more understandable
when rotations are caused by something you've done explicitly, rather than as a side effect
of the software.
For convenience as well, most of the time, when I'm working in context and I decide I need a new object,
particularly working on production scenes that involve more than just one model, an Alt R
is almost always required after adding, since I don't want to have to disrupt the current
view of the scene by switching to top view, just to add an object. It's a bit arbitrary,
the view from which you want to look at your objects isn't usually the way you want them to
be looking at you.
2007-10-31 21:55:06 +00:00
|
|
|
if(mode==0 || mode==2) ok= extrudeflagNurb(1);
|
2002-10-12 11:37:38 +00:00
|
|
|
else adduplicateflagNurb(1);
|
|
|
|
|
if(ok==0) {
|
|
|
|
|
error("Can't spin");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
rotateflagNurb(1,cent,rotmat);
|
|
|
|
|
|
* Two usability tweaks in adding objects, with user prefs
This changes the default behaviour in adding new objects, which has been
discussed for a long time, in person, on the funboard, and in the tracker,
and was agreed to be implemented during the 2.5 release cycle, so here it is.
They have been made default, with preferences to bring back old behaviour since
although people like myself still prefer the new default anyway, it will benefit
new users the most.
The preferences are in the 'Edit Methods' section, changing back to old behaviour
is as simple as a click of a button.
- Switch to edit mode preference
By default, now adding a new object doesn't automatically switch to edit mode.
Not only can this be annoying (most of the time when setting up scenes and models
I don't want to edit it straight away anyway), but it's a major hurdle in the learning
curve that new users have had to deal with at a very early stage.
Blender's different modes are an important part of understanding how the software works
and should have clear behaviour. The problem is that when a user selects something from
the add menu, he's not telling Blender to change modes, he wants to add an object.
But Blender then goes ahead and changes modes underneath him anyway, something that was
never explicitly asked for, something that's unrelated to the mental task at hand, and
fundamentally important to the operation of the software.
We observed plenty of people struggling with this during the training sessions that
we ran during Project Orange, and there's also no shortage of "why can't I select
other objects" questions on the forums.
- Aligned to View preference
Now by default, adding a new object doesn't rotate it so it's aligned facing the view,
but rather, it's remains unrotated in world space. This is something that's more of
a convenience issue (allowing people like me to stop the 'Add->Tab->Alt R dance),
but also makes things easier for new users, especially when doing things like rigging.
For a lot of tools in Blender, like curve deform, path cycling, constraints, it's necessary
for your objects' local axes to be aligned. This requirement isn't that obvious, and I've
had to debug rigs a few times from the animator in our studio, who has everything set up
correctly, but he just happened to be in a different vie at the time he added the object,
so they're misaligned and causing problems. Having all objects get created aligned to
worldspace, by default, makes a lot of these problems go away. It's much more understandable
when rotations are caused by something you've done explicitly, rather than as a side effect
of the software.
For convenience as well, most of the time, when I'm working in context and I decide I need a new object,
particularly working on production scenes that involve more than just one model, an Alt R
is almost always required after adding, since I don't want to have to disrupt the current
view of the scene by switching to top view, just to add an object. It's a bit arbitrary,
the view from which you want to look at your objects isn't usually the way you want them to
be looking at you.
2007-10-31 21:55:06 +00:00
|
|
|
if(mode==0 || mode==2) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if( (a & 1)==0 ) {
|
|
|
|
|
rotateflagNurb(1,cent,scalemat1);
|
|
|
|
|
weightflagNurb(1, 0.25*sqrt(2.0), 1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
rotateflagNurb(1,cent,scalemat2);
|
|
|
|
|
weightflagNurb(1, 4.0/sqrt(2.0), 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(dvec) {
|
|
|
|
|
Mat3MulVecfl(bmat,dvec);
|
|
|
|
|
translateflagNurb(1,dvec);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ok) {
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if(isNurbsel(nu)) {
|
|
|
|
|
nu->orderv= 4;
|
2008-05-26 12:50:00 +00:00
|
|
|
nu->flagv |= CU_CYCLIC;
|
2002-10-12 11:37:38 +00:00
|
|
|
makeknots(nu, 2, nu->flagv>>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
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* external one, for undo */
|
|
|
|
|
void spinNurb(float *dvec, short mode)
|
|
|
|
|
{
|
|
|
|
|
spin_nurb(dvec, mode);
|
|
|
|
|
BIF_undo_push("Spin");
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void addvert_Nurb(int mode)
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BezTriple *bezt, *newbezt = NULL;
|
|
|
|
|
BPoint *bp, *newbp = NULL;
|
|
|
|
|
float *curs, mat[3][3],imat[3][3], temp[3];
|
|
|
|
|
|
2007-03-14 09:08:41 +00:00
|
|
|
if(G.obedit==0 || G.vd == 0) return;
|
2002-10-12 11:37:38 +00:00
|
|
|
if( (G.vd->lay & G.obedit->lay)==0 ) return;
|
|
|
|
|
|
|
|
|
|
Mat3CpyMat4(mat, G.obedit->obmat);
|
|
|
|
|
Mat3Inv(imat,mat);
|
|
|
|
|
|
|
|
|
|
findselectedNurbvert(&nu, &bezt, &bp);
|
|
|
|
|
if(bezt==0 && bp==0) return;
|
|
|
|
|
|
|
|
|
|
if((nu->type & 7)==CU_BEZIER) {
|
2003-04-28 14:43:20 +00:00
|
|
|
/* which bezpoint? */
|
|
|
|
|
if(bezt== nu->bezt) { /* first */
|
2008-09-20 13:21:10 +00:00
|
|
|
BEZ_DESEL(bezt);
|
2002-10-12 11:37:38 +00:00
|
|
|
newbezt =
|
|
|
|
|
(BezTriple*)MEM_callocN((nu->pntsu+1) * sizeof(BezTriple), "addvert_Nurb");
|
|
|
|
|
memcpy(newbezt+1, bezt, nu->pntsu*sizeof(BezTriple));
|
|
|
|
|
*newbezt= *bezt;
|
2008-09-20 13:21:10 +00:00
|
|
|
BEZ_SEL(newbezt);
|
2005-11-08 17:57:04 +00:00
|
|
|
if(newbezt->h1 >= 0) newbezt->h2= newbezt->h1;
|
2005-11-08 17:47:57 +00:00
|
|
|
else newbezt->h2= newbezt->h1= HD_ALIGN; /* does this ever happen? */
|
2002-10-12 11:37:38 +00:00
|
|
|
VECCOPY(temp, bezt->vec[1]);
|
|
|
|
|
MEM_freeN(nu->bezt);
|
|
|
|
|
nu->bezt= newbezt;
|
|
|
|
|
bezt= newbezt+1;
|
|
|
|
|
}
|
2003-04-28 14:43:20 +00:00
|
|
|
else if(bezt== (nu->bezt+nu->pntsu-1)) { /* last */
|
2008-09-20 13:21:10 +00:00
|
|
|
BEZ_DESEL(bezt);
|
2002-10-12 11:37:38 +00:00
|
|
|
newbezt =
|
|
|
|
|
(BezTriple*)MEM_callocN((nu->pntsu+1) * sizeof(BezTriple), "addvert_Nurb");
|
|
|
|
|
memcpy(newbezt, nu->bezt, nu->pntsu*sizeof(BezTriple));
|
|
|
|
|
*(newbezt+nu->pntsu)= *bezt;
|
|
|
|
|
VECCOPY(temp, bezt->vec[1]);
|
|
|
|
|
MEM_freeN(nu->bezt);
|
|
|
|
|
nu->bezt= newbezt;
|
|
|
|
|
newbezt+= nu->pntsu;
|
2008-09-20 13:21:10 +00:00
|
|
|
BEZ_SEL(newbezt);
|
2005-11-08 17:57:04 +00:00
|
|
|
if(newbezt->h1 >= 0) newbezt->h2= newbezt->h1;
|
2005-11-08 17:47:57 +00:00
|
|
|
else newbezt->h2= newbezt->h1= HD_ALIGN; /* does this ever happen? */
|
2002-10-12 11:37:38 +00:00
|
|
|
bezt= nu->bezt+nu->pntsu-1;
|
|
|
|
|
}
|
|
|
|
|
else bezt= 0;
|
|
|
|
|
|
|
|
|
|
if(bezt) {
|
|
|
|
|
nu->pntsu++;
|
|
|
|
|
|
|
|
|
|
if(mode=='e') {
|
|
|
|
|
VECCOPY(newbezt->vec[0], bezt->vec[0]);
|
|
|
|
|
VECCOPY(newbezt->vec[1], bezt->vec[1]);
|
|
|
|
|
VECCOPY(newbezt->vec[2], bezt->vec[2]);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
curs= give_cursor();
|
|
|
|
|
|
|
|
|
|
VECCOPY(newbezt->vec[1], curs);
|
|
|
|
|
VecSubf(newbezt->vec[1],newbezt->vec[1],G.obedit->obmat[3]);
|
|
|
|
|
Mat3MulVecfl(imat,newbezt->vec[1]);
|
|
|
|
|
VecSubf(temp, newbezt->vec[1],temp);
|
|
|
|
|
VecAddf(newbezt->vec[0], bezt->vec[0],temp);
|
|
|
|
|
VecAddf(newbezt->vec[2], bezt->vec[2],temp);
|
|
|
|
|
calchandlesNurb(nu);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(nu->pntsv==1) {
|
2003-04-28 14:43:20 +00:00
|
|
|
/* which b-point? */
|
|
|
|
|
if(bp== nu->bp) { /* first */
|
2002-10-12 11:37:38 +00:00
|
|
|
bp->f1= 0;
|
|
|
|
|
newbp =
|
|
|
|
|
(BPoint*)MEM_callocN((nu->pntsu+1) * sizeof(BPoint), "addvert_Nurb3");
|
|
|
|
|
memcpy(newbp+1, bp, nu->pntsu*sizeof(BPoint));
|
|
|
|
|
*newbp= *bp;
|
|
|
|
|
newbp->f1= 1;
|
|
|
|
|
MEM_freeN(nu->bp);
|
|
|
|
|
nu->bp= newbp;
|
2007-10-02 11:19:01 +00:00
|
|
|
bp= newbp + 1;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2003-04-28 14:43:20 +00:00
|
|
|
else if(bp== (nu->bp+nu->pntsu-1)) { /* last */
|
2002-10-12 11:37:38 +00:00
|
|
|
bp->f1= 0;
|
|
|
|
|
newbp =
|
|
|
|
|
(BPoint*)MEM_callocN((nu->pntsu+1) * sizeof(BPoint), "addvert_Nurb4");
|
|
|
|
|
memcpy(newbp, nu->bp, nu->pntsu*sizeof(BPoint));
|
|
|
|
|
*(newbp+nu->pntsu)= *bp;
|
|
|
|
|
MEM_freeN(nu->bp);
|
|
|
|
|
nu->bp= newbp;
|
|
|
|
|
newbp+= nu->pntsu;
|
|
|
|
|
newbp->f1= 1;
|
2007-10-02 11:19:01 +00:00
|
|
|
bp= newbp - 1;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
else bp= 0;
|
|
|
|
|
|
|
|
|
|
if(bp) {
|
|
|
|
|
nu->pntsu++;
|
2007-10-02 11:19:01 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
makeknots(nu, 1, nu->flagu>>1);
|
2007-10-02 11:19:01 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if(mode=='e') {
|
|
|
|
|
VECCOPY(newbp->vec, bp->vec);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
curs= give_cursor();
|
|
|
|
|
|
|
|
|
|
VECCOPY(newbp->vec, curs);
|
|
|
|
|
VecSubf(newbp->vec, newbp->vec, G.obedit->obmat[3]);
|
|
|
|
|
Mat3MulVecfl(imat,newbp->vec);
|
|
|
|
|
newbp->vec[3]= 1.0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-02 20:33:11 +00:00
|
|
|
retopo_do_all();
|
2006-11-06 01:08:26 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
test2DNurb(nu);
|
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);
|
2002-10-12 11:37:38 +00:00
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
2004-04-07 11:35:11 +00:00
|
|
|
allqueue(REDRAWBUTSEDIT, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-05-08 12:00:28 +00:00
|
|
|
if(mode=='e') {
|
|
|
|
|
BIF_TransformSetUndo("Extrude");
|
2005-05-10 04:21:11 +00:00
|
|
|
initTransform(TFM_TRANSLATION, CTX_NO_PET);
|
|
|
|
|
Transform();
|
2005-05-08 12:00:28 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
else while(get_mbut()&R_MOUSE) BIF_wait_for_statechange();
|
2004-08-31 13:43:18 +00:00
|
|
|
|
|
|
|
|
if(mode!='e') {
|
|
|
|
|
/* dependencies with other objects, should become event */
|
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("Add vertex");
|
|
|
|
|
|
2004-08-31 13:43:18 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void extrude_nurb()
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
int ok= 0;
|
|
|
|
|
|
|
|
|
|
if(G.obedit && G.obedit->type==OB_SURF) {
|
|
|
|
|
|
|
|
|
|
/* first test: curve? */
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if(nu->pntsv==1 && isNurbsel_count(nu)==1 ) break;
|
|
|
|
|
}
|
|
|
|
|
if(nu) {
|
|
|
|
|
addvert_Nurb('e');
|
2007-12-11 14:19:05 +00:00
|
|
|
} else {
|
2002-10-12 11:37:38 +00:00
|
|
|
ok= extrudeflagNurb(1); /* '1'= flag */
|
|
|
|
|
|
|
|
|
|
if(ok) {
|
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);
|
2002-10-12 11:37:38 +00:00
|
|
|
countall();
|
2005-05-08 12:00:28 +00:00
|
|
|
BIF_TransformSetUndo("Extrude");
|
2005-05-10 04:21:11 +00:00
|
|
|
initTransform(TFM_TRANSLATION, CTX_NO_PET);
|
|
|
|
|
Transform();
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void makecyclicNurb()
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
float *fp;
|
|
|
|
|
int a, b, cyclmode=0;
|
|
|
|
|
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if( nu->pntsu>1 || nu->pntsv>1) {
|
|
|
|
|
if( (nu->type & 7)==0 ) {
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
while(a--) {
|
2007-12-11 14:19:05 +00:00
|
|
|
if( bp->f1 & SELECT ) {
|
2008-05-26 12:50:00 +00:00
|
|
|
if(nu->flagu & CU_CYCLIC) nu->flagu &= ~CU_CYCLIC;
|
|
|
|
|
else nu->flagu |= CU_CYCLIC;
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if( (nu->type & 7)==CU_BEZIER ) {
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
while(a--) {
|
2007-12-01 23:25:00 +00:00
|
|
|
if( BEZSELECTED_HIDDENHANDLES(bezt) ) {
|
2008-05-26 12:50:00 +00:00
|
|
|
if(nu->flagu & CU_CYCLIC) nu->flagu &= ~CU_CYCLIC;
|
|
|
|
|
else nu->flagu |= CU_CYCLIC;
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
calchandlesNurb(nu);
|
|
|
|
|
}
|
|
|
|
|
else if(nu->pntsv==1 && (nu->type & 7)==CU_NURBS) {
|
2008-05-26 09:50:46 +00:00
|
|
|
if (nu->knotsu) { /* if check_valid_nurb_u fails the knotsu can be NULL */
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
while(a--) {
|
|
|
|
|
if( bp->f1 & SELECT ) {
|
2008-05-26 12:50:00 +00:00
|
|
|
if(nu->flagu & CU_CYCLIC) nu->flagu &= ~CU_CYCLIC;
|
2008-05-26 09:50:46 +00:00
|
|
|
else {
|
2008-05-26 12:50:00 +00:00
|
|
|
nu->flagu |= CU_CYCLIC;
|
2008-05-26 09:50:46 +00:00
|
|
|
nu->flagu &= ~2; /* endpoint flag, fixme */
|
|
|
|
|
fp= MEM_mallocN(sizeof(float)*KNOTSU(nu), "makecyclicN");
|
|
|
|
|
b= (nu->orderu+nu->pntsu);
|
|
|
|
|
memcpy(fp, nu->knotsu, sizeof(float)*b);
|
|
|
|
|
MEM_freeN(nu->knotsu);
|
|
|
|
|
nu->knotsu= fp;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-05-26 09:50:46 +00:00
|
|
|
makeknots(nu, 1, 0); /* 1==u 0==uniform */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-05-26 09:50:46 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2008-05-26 09:50:46 +00:00
|
|
|
bp++;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(nu->type==CU_NURBS) {
|
|
|
|
|
if(cyclmode==0) {
|
|
|
|
|
cyclmode= pupmenu("Toggle %t|cyclic U%x1|cyclic V%x2");
|
|
|
|
|
if(cyclmode < 1) return;
|
|
|
|
|
}
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
while(a--) {
|
|
|
|
|
|
2007-12-11 14:19:05 +00:00
|
|
|
if( bp->f1 & SELECT) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if(cyclmode==1 && nu->pntsu>1) {
|
2008-05-26 12:50:00 +00:00
|
|
|
if(nu->flagu & CU_CYCLIC) nu->flagu &= ~CU_CYCLIC;
|
2002-10-12 11:37:38 +00:00
|
|
|
else {
|
2008-05-26 12:50:00 +00:00
|
|
|
nu->flagu |= CU_CYCLIC;
|
2008-05-26 09:50:46 +00:00
|
|
|
if (check_valid_nurb_u(nu)) {
|
|
|
|
|
fp= MEM_mallocN(sizeof(float)*KNOTSU(nu), "makecyclicN");
|
|
|
|
|
b= (nu->orderu+nu->pntsu);
|
|
|
|
|
if (nu->knotsu) { /* null if check_valid_nurb_u failed before but is valid now */
|
|
|
|
|
memcpy(fp, nu->knotsu, sizeof(float)*b);
|
|
|
|
|
MEM_freeN(nu->knotsu);
|
|
|
|
|
}
|
|
|
|
|
nu->knotsu= fp;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-05-26 09:50:46 +00:00
|
|
|
makeknots(nu, 1, 0); /* 1==u 0==uniform */
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(cyclmode==2 && nu->pntsv>1) {
|
|
|
|
|
if(nu->flagv & 1) nu->flagv--;
|
|
|
|
|
else {
|
|
|
|
|
nu->flagv++;
|
2008-05-26 09:50:46 +00:00
|
|
|
if (check_valid_nurb_v(nu)) {
|
|
|
|
|
fp= MEM_mallocN(sizeof(float)*KNOTSV(nu), "makecyclicN");
|
|
|
|
|
b= (nu->orderv+nu->pntsv);
|
|
|
|
|
if (nu->knotsv) { /* null if check_valid_nurb_v failed before but is valid now */
|
|
|
|
|
memcpy(fp, nu->knotsv, sizeof(float)*b);
|
|
|
|
|
MEM_freeN(nu->knotsv);
|
|
|
|
|
}
|
|
|
|
|
nu->knotsv= fp;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-05-26 09:50:46 +00:00
|
|
|
makeknots(nu, 2, 0); /* 2==v 0==uniform */
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
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("Cyclic");
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void selectconnected_nurb()
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
findnearestNurbvert(1, &nu, &bezt, &bp);
|
|
|
|
|
if(bezt) {
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
while(a--) {
|
2007-06-14 14:36:27 +00:00
|
|
|
if(G.qual & LR_SHIFTKEY) select_beztriple(bezt, DESELECT, 1, VISIBLE);
|
|
|
|
|
else select_beztriple(bezt, SELECT, 1, VISIBLE);
|
2002-10-12 11:37:38 +00:00
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(bp) {
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
while(a--) {
|
2007-06-14 14:36:27 +00:00
|
|
|
if(G.qual & LR_SHIFTKEY) select_bpoint(bp, DESELECT, 1, VISIBLE);
|
|
|
|
|
else select_bpoint(bp, SELECT, 1, VISIBLE);
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 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("Select connected");
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void selectrow_nurb()
|
|
|
|
|
{
|
|
|
|
|
static BPoint *last=0;
|
|
|
|
|
static int direction=0;
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
int u = 0, v = 0, a, b, ok=0;
|
|
|
|
|
|
|
|
|
|
if(editNurb.first==0) return;
|
2004-04-07 11:35:11 +00:00
|
|
|
if(G.obedit==NULL || G.obedit->type!=OB_SURF) return;
|
|
|
|
|
if(lastselbp==NULL) return;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
/* find the correct nurb and toggle with u of v */
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
bp= nu->bp;
|
|
|
|
|
for(v=0; v<nu->pntsv; v++) {
|
|
|
|
|
for(u=0; u<nu->pntsu; u++, bp++) {
|
|
|
|
|
if(bp==lastselbp) {
|
2007-12-11 14:19:05 +00:00
|
|
|
if(bp->f1 & SELECT) {
|
2002-10-12 11:37:38 +00:00
|
|
|
ok= 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(ok) break;
|
|
|
|
|
}
|
|
|
|
|
if(ok) {
|
|
|
|
|
if(last==lastselbp) {
|
|
|
|
|
direction= 1-direction;
|
|
|
|
|
setflagsNurb(0);
|
|
|
|
|
}
|
|
|
|
|
last= lastselbp;
|
|
|
|
|
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
for(a=0; a<nu->pntsv; a++) {
|
|
|
|
|
for(b=0; b<nu->pntsu; b++, bp++) {
|
|
|
|
|
if(direction) {
|
2007-06-14 14:36:27 +00:00
|
|
|
if(a==v) select_bpoint(bp, SELECT, 1, VISIBLE);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2007-06-14 14:36:27 +00:00
|
|
|
if(b==u) select_bpoint(bp, SELECT, 1, VISIBLE);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
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
|
|
|
BIF_undo_push("Select Row");
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2007-06-14 14:36:27 +00:00
|
|
|
/* (de)selects first or last of visible part of each Nurb depending on selFirst */
|
|
|
|
|
/* selFirst: defines the end of which to select */
|
|
|
|
|
/* doswap: defines if selection state of each first/last control point is swapped */
|
|
|
|
|
/* selstatus: selection status in case doswap is false */
|
|
|
|
|
void selectend_nurb(short selfirst, short doswap, short selstatus)
|
2006-11-06 18:20:56 +00:00
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
int a;
|
2007-06-14 14:36:27 +00:00
|
|
|
short sel;
|
2006-11-06 18:20:56 +00:00
|
|
|
|
|
|
|
|
if(G.obedit==0) return;
|
|
|
|
|
|
|
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2007-06-14 14:36:27 +00:00
|
|
|
sel= 0;
|
2006-11-06 18:20:56 +00:00
|
|
|
if((nu->type & 7)==CU_BEZIER) {
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
|
|
|
|
|
/* which point? */
|
2007-06-14 14:36:27 +00:00
|
|
|
if(selfirst==0) { /* select last */
|
2006-11-06 18:20:56 +00:00
|
|
|
bezt= (nu->bezt + (a-1));
|
2007-06-14 14:36:27 +00:00
|
|
|
}
|
|
|
|
|
else { /* select first */
|
2006-11-06 18:20:56 +00:00
|
|
|
bezt= nu->bezt;
|
2007-06-14 14:36:27 +00:00
|
|
|
}
|
2006-11-06 18:20:56 +00:00
|
|
|
|
2007-06-14 14:36:27 +00:00
|
|
|
while(a--) {
|
|
|
|
|
if(doswap) sel= swap_selection_beztriple(bezt);
|
|
|
|
|
else sel= select_beztriple(bezt, selstatus, 1, VISIBLE);
|
|
|
|
|
|
|
|
|
|
if(sel==1) break;
|
2006-11-06 18:20:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
|
|
|
|
|
/* which point? */
|
2007-06-14 14:36:27 +00:00
|
|
|
if(selfirst==0) { /* select last */
|
2006-11-06 18:20:56 +00:00
|
|
|
bp= (nu->bp + (a-1));
|
2007-06-14 14:36:27 +00:00
|
|
|
}
|
|
|
|
|
else{ /* select first */
|
2006-11-06 18:20:56 +00:00
|
|
|
bp= nu->bp;
|
2007-06-14 14:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while(a--) {
|
|
|
|
|
if (bp->hide == 0) {
|
|
|
|
|
if(doswap) sel= swap_selection_bpoint(bp);
|
|
|
|
|
else sel= select_bpoint(bp, selstatus, 1, VISIBLE);
|
|
|
|
|
|
|
|
|
|
if(sel==1) break;
|
|
|
|
|
}
|
2006-11-06 18:20:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
BIF_undo_push("Select/Deselect End");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void select_next_nurb()
|
|
|
|
|
{
|
|
|
|
|
if(G.obedit==0) return;
|
|
|
|
|
|
2007-06-14 14:36:27 +00:00
|
|
|
select_adjacent_cp(1, 0, SELECT);
|
2006-11-06 18:20:56 +00:00
|
|
|
|
|
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
BIF_undo_push("Select Next");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void select_prev_nurb()
|
|
|
|
|
{
|
2007-06-14 14:36:27 +00:00
|
|
|
if(G.obedit==0) return;
|
|
|
|
|
|
|
|
|
|
select_adjacent_cp(-1, 0, SELECT);
|
|
|
|
|
|
|
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
BIF_undo_push("Select Previous");
|
|
|
|
|
}
|
2006-11-06 18:20:56 +00:00
|
|
|
|
2007-06-14 14:36:27 +00:00
|
|
|
void select_more_nurb()
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BPoint *bp, *tempbp;
|
|
|
|
|
int a;
|
|
|
|
|
short sel= 0;
|
|
|
|
|
short *selbpoints;
|
|
|
|
|
|
2006-11-06 18:20:56 +00:00
|
|
|
if(G.obedit==0) return;
|
|
|
|
|
|
2007-06-14 14:36:27 +00:00
|
|
|
/* note that NURBS surface is a special case because we mimic */
|
|
|
|
|
/* the behaviour of "select more" of mesh tools. */
|
|
|
|
|
/* The algorithm is designed to work in planar cases so it */
|
|
|
|
|
/* may not be optimal always (example: end of NURBS sphere) */
|
|
|
|
|
if(G.obedit->type==OB_SURF) {
|
|
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
selbpoints= MEM_callocN(sizeof(short)*a-nu->pntsu, "selectlist");
|
|
|
|
|
while(a > 0) {
|
2007-12-11 14:19:05 +00:00
|
|
|
if((selbpoints[a]!=1) && (bp->hide==0) && (bp->f1 & SELECT)) {
|
2007-06-14 14:36:27 +00:00
|
|
|
/* upper control point */
|
|
|
|
|
if(a%nu->pntsu != 0) {
|
|
|
|
|
tempbp= bp-1;
|
2007-12-11 14:19:05 +00:00
|
|
|
if(!(tempbp->f1 & SELECT)) select_bpoint(tempbp, SELECT, 1, VISIBLE);
|
2007-06-14 14:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* left control point. select only if it is not selected already */
|
|
|
|
|
if(a-nu->pntsu > 0) {
|
|
|
|
|
sel= 0;
|
|
|
|
|
tempbp= bp+nu->pntsu;
|
2007-12-11 14:19:05 +00:00
|
|
|
if(!(tempbp->f1 & SELECT)) sel= select_bpoint(tempbp, SELECT, 1, VISIBLE);
|
2007-06-14 14:36:27 +00:00
|
|
|
/* make sure selected bpoint is discarded */
|
|
|
|
|
if(sel == 1) selbpoints[a-nu->pntsu]= 1;
|
2006-11-06 18:20:56 +00:00
|
|
|
}
|
|
|
|
|
|
2007-06-14 14:36:27 +00:00
|
|
|
/* right control point */
|
|
|
|
|
if(a+nu->pntsu < nu->pntsu*nu->pntsv) {
|
|
|
|
|
tempbp= bp-nu->pntsu;
|
2007-12-11 14:19:05 +00:00
|
|
|
if(!(tempbp->f1 & SELECT)) select_bpoint(tempbp, SELECT, 1, VISIBLE);
|
2006-11-06 18:20:56 +00:00
|
|
|
}
|
2007-06-14 14:36:27 +00:00
|
|
|
|
|
|
|
|
/* lower control point. skip next bp in case selection was made */
|
|
|
|
|
if(a%nu->pntsu != 1) {
|
|
|
|
|
sel= 0;
|
|
|
|
|
tempbp= bp+1;
|
|
|
|
|
if(!(tempbp->f1 & 1)) sel= select_bpoint(tempbp, SELECT, 1, VISIBLE);
|
|
|
|
|
if(sel) {
|
|
|
|
|
bp++;
|
|
|
|
|
a--;
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-11-06 18:20:56 +00:00
|
|
|
}
|
2007-06-14 14:36:27 +00:00
|
|
|
|
|
|
|
|
bp++;
|
|
|
|
|
a--;
|
2006-11-06 18:20:56 +00:00
|
|
|
}
|
|
|
|
|
|
2007-06-14 14:36:27 +00:00
|
|
|
MEM_freeN(selbpoints);
|
2006-11-06 18:20:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-06-14 14:36:27 +00:00
|
|
|
else {
|
|
|
|
|
select_adjacent_cp(1, 0, SELECT);
|
|
|
|
|
select_adjacent_cp(-1, 0, SELECT);
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-06 18:20:56 +00:00
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
2007-06-14 14:36:27 +00:00
|
|
|
BIF_undo_push("Select More");
|
2006-11-06 18:20:56 +00:00
|
|
|
}
|
|
|
|
|
|
2007-06-14 14:36:27 +00:00
|
|
|
/* basic method: deselect if control point doesn't have all neighbours selected */
|
|
|
|
|
void select_less_nurb()
|
2006-11-06 18:20:56 +00:00
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BPoint *bp;
|
2007-06-14 14:36:27 +00:00
|
|
|
BezTriple *bezt;
|
|
|
|
|
int a;
|
|
|
|
|
short sel= 0, lastsel= 0;
|
|
|
|
|
short *selbpoints;
|
2006-11-06 18:20:56 +00:00
|
|
|
|
|
|
|
|
if(G.obedit==0) return;
|
|
|
|
|
|
2007-06-14 14:36:27 +00:00
|
|
|
if(G.obedit->type==OB_SURF) {
|
|
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
selbpoints= MEM_callocN(sizeof(short)*a, "selectlist");
|
|
|
|
|
while(a--) {
|
2007-12-11 14:19:05 +00:00
|
|
|
if((bp->hide==0) && (bp->f1 & SELECT)) {
|
2007-06-14 14:36:27 +00:00
|
|
|
sel= 0;
|
|
|
|
|
|
|
|
|
|
/* check if neighbours have been selected */
|
|
|
|
|
/* edges of surface are an exception */
|
|
|
|
|
if((a+1)%nu->pntsu==0) sel++;
|
|
|
|
|
else {
|
|
|
|
|
bp--;
|
2007-12-11 14:19:05 +00:00
|
|
|
if((selbpoints[a+1]==1) || ((bp->hide==0) && (bp->f1 & SELECT))) sel++;
|
2007-06-14 14:36:27 +00:00
|
|
|
bp++;
|
2006-11-06 18:20:56 +00:00
|
|
|
}
|
|
|
|
|
|
2007-06-14 14:36:27 +00:00
|
|
|
if((a+1)%nu->pntsu==1) sel++;
|
|
|
|
|
else {
|
|
|
|
|
bp++;
|
2007-12-11 14:19:05 +00:00
|
|
|
if((bp->hide==0) && (bp->f1 & SELECT)) sel++;
|
2007-06-14 14:36:27 +00:00
|
|
|
bp--;
|
2006-11-06 18:20:56 +00:00
|
|
|
}
|
|
|
|
|
|
2007-06-14 14:36:27 +00:00
|
|
|
if(a+1 > nu->pntsu*nu->pntsv-nu->pntsu) sel++;
|
|
|
|
|
else {
|
|
|
|
|
bp-=nu->pntsu;
|
2007-12-11 14:19:05 +00:00
|
|
|
if((selbpoints[a+nu->pntsu]==1) || ((bp->hide==0) && (bp->f1 & SELECT))) sel++;
|
2007-06-14 14:36:27 +00:00
|
|
|
bp+=nu->pntsu;
|
2006-11-06 18:20:56 +00:00
|
|
|
}
|
2007-06-14 14:36:27 +00:00
|
|
|
|
|
|
|
|
if(a < nu->pntsu) sel++;
|
2006-11-06 18:20:56 +00:00
|
|
|
else {
|
2007-06-14 14:36:27 +00:00
|
|
|
bp+=nu->pntsu;
|
2007-12-11 14:19:05 +00:00
|
|
|
if((bp->hide==0) && (bp->f1 & SELECT)) sel++;
|
2007-06-14 14:36:27 +00:00
|
|
|
bp-=nu->pntsu;
|
2006-11-06 18:20:56 +00:00
|
|
|
}
|
2007-06-14 14:36:27 +00:00
|
|
|
|
|
|
|
|
if(sel!=4) {
|
|
|
|
|
select_bpoint(bp, DESELECT, 1, VISIBLE);
|
|
|
|
|
selbpoints[a]= 1;
|
|
|
|
|
}
|
2006-11-06 18:20:56 +00:00
|
|
|
}
|
2007-06-14 14:36:27 +00:00
|
|
|
else lastsel= 0;
|
|
|
|
|
|
|
|
|
|
bp++;
|
2006-11-06 18:20:56 +00:00
|
|
|
}
|
|
|
|
|
|
2007-06-14 14:36:27 +00:00
|
|
|
MEM_freeN(selbpoints);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
|
|
|
|
lastsel=0;
|
|
|
|
|
/* check what type of curve/nurb it is */
|
|
|
|
|
if((nu->type & 7)==CU_BEZIER) {
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
while(a--) {
|
2007-12-01 23:25:00 +00:00
|
|
|
if((bezt->hide==0) && (bezt->f2 & SELECT)) {
|
2007-06-14 14:36:27 +00:00
|
|
|
if(lastsel==1) sel= 1;
|
|
|
|
|
else sel= 0;
|
|
|
|
|
|
|
|
|
|
/* check if neighbours have been selected */
|
|
|
|
|
/* first and last are exceptions */
|
|
|
|
|
if(a==nu->pntsu-1) sel++;
|
|
|
|
|
else {
|
|
|
|
|
bezt--;
|
2007-12-01 23:25:00 +00:00
|
|
|
if((bezt->hide==0) && (bezt->f2 & SELECT)) sel++;
|
2007-06-14 14:36:27 +00:00
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(a==0) sel++;
|
|
|
|
|
else {
|
|
|
|
|
bezt++;
|
2007-12-01 23:25:00 +00:00
|
|
|
if((bezt->hide==0) && (bezt->f2 & SELECT)) sel++;
|
2007-06-14 14:36:27 +00:00
|
|
|
bezt--;
|
|
|
|
|
}
|
2007-12-01 23:25:00 +00:00
|
|
|
|
2007-06-14 14:36:27 +00:00
|
|
|
if(sel!=2) {
|
|
|
|
|
select_beztriple(bezt, DESELECT, 1, VISIBLE);
|
2007-12-01 23:25:00 +00:00
|
|
|
lastsel= 1;
|
|
|
|
|
}
|
|
|
|
|
else lastsel= 0;
|
2007-06-14 14:36:27 +00:00
|
|
|
}
|
|
|
|
|
else lastsel= 0;
|
|
|
|
|
|
|
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
while(a--) {
|
2007-12-11 14:19:05 +00:00
|
|
|
if((lastsel==0) && (bp->hide==0) && (bp->f1 & SELECT)) {
|
2007-06-14 14:36:27 +00:00
|
|
|
if(lastsel!=0) sel= 1;
|
|
|
|
|
else sel= 0;
|
|
|
|
|
|
|
|
|
|
/* first and last are exceptions */
|
|
|
|
|
if(a==nu->pntsu*nu->pntsv-1) sel++;
|
|
|
|
|
else {
|
|
|
|
|
bp--;
|
2007-12-11 14:19:05 +00:00
|
|
|
if((bp->hide==0) && (bp->f1 & SELECT)) sel++;
|
2007-06-14 14:36:27 +00:00
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(a==0) sel++;
|
|
|
|
|
else {
|
|
|
|
|
bp++;
|
2007-12-11 14:19:05 +00:00
|
|
|
if((bp->hide==0) && (bp->f1 & SELECT)) sel++;
|
2007-06-14 14:36:27 +00:00
|
|
|
bp--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(sel!=2) {
|
|
|
|
|
select_bpoint(bp, DESELECT, 1, VISIBLE);
|
|
|
|
|
lastsel= 1;
|
|
|
|
|
}
|
|
|
|
|
else lastsel= 0;
|
|
|
|
|
}
|
|
|
|
|
else lastsel= 0;
|
|
|
|
|
|
|
|
|
|
bp++;
|
2006-11-06 18:20:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
2007-06-14 14:36:27 +00:00
|
|
|
BIF_undo_push("Select Less");
|
2006-11-06 18:20:56 +00:00
|
|
|
}
|
|
|
|
|
|
2007-06-14 14:36:27 +00:00
|
|
|
/* this function could be moved elsewhere as it can be reused in other parts of the source needing randomized list */
|
|
|
|
|
/* returns list containing -1 in indices that have been left out of the list. otherwise index contains reference */
|
|
|
|
|
/* to next index. basically *list contains a linked list */
|
|
|
|
|
static void generate_pickable_list(int *list, int size, int pickamount)
|
|
|
|
|
{
|
|
|
|
|
int i, j, removable;
|
|
|
|
|
|
|
|
|
|
BLI_srand( BLI_rand() ); /* random seed */
|
|
|
|
|
|
|
|
|
|
/* generate list in form 0->1, 1->2, 2->3, ... i-2->i-1, i->0 */
|
|
|
|
|
for(i=0; i<size; i++) {
|
|
|
|
|
if(i == size-1) list[i]= 0;
|
|
|
|
|
else list[i]= i+1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i=0; i<size-pickamount; i++) {
|
|
|
|
|
removable= floor(BLI_frand()*(size-1)+0.5); /* with rounding. frand returns [0,1] */
|
|
|
|
|
|
|
|
|
|
/* seek proper item as the one randomly selected might not be appropriate */
|
|
|
|
|
for(j=0; j<size; j++, removable++) {
|
|
|
|
|
if(list[removable] != -1) break;
|
|
|
|
|
if(removable == size-1) removable= -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* pick unwanted item out of the list */
|
|
|
|
|
list[list[removable]]= -1; /* mark former last as invalid */
|
|
|
|
|
|
|
|
|
|
if(list[removable] == size-1) list[removable]= 0;
|
|
|
|
|
else list[removable]= list[removable]+1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void select_random_nurb()
|
2006-11-06 18:20:56 +00:00
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BezTriple *bezt;
|
2007-06-14 14:36:27 +00:00
|
|
|
BPoint *bp;
|
|
|
|
|
static short randfac= 50;
|
|
|
|
|
int amounttoselect, amountofcps, a, i, k= 0;
|
|
|
|
|
int *itemstobeselected;
|
|
|
|
|
|
|
|
|
|
if(!G.obedit) return;
|
2006-11-06 18:20:56 +00:00
|
|
|
|
2007-06-14 14:36:27 +00:00
|
|
|
if(!button(&randfac,0, 100,"Percentage:")) return;
|
2006-11-06 18:20:56 +00:00
|
|
|
|
2007-06-14 14:36:27 +00:00
|
|
|
if(randfac == 0) return;
|
|
|
|
|
|
|
|
|
|
amountofcps= count_curveverts_without_handles(&editNurb);
|
|
|
|
|
itemstobeselected= MEM_callocN(sizeof(int) * amountofcps, "selectitems");
|
|
|
|
|
amounttoselect= floor(randfac * amountofcps / 100 + 0.5);
|
|
|
|
|
generate_pickable_list(itemstobeselected, amountofcps, amounttoselect);
|
|
|
|
|
|
|
|
|
|
/* select elements */
|
|
|
|
|
for(i=1, nu= editNurb.first; nu; nu= nu->next) {
|
|
|
|
|
if((nu->type & 7)==CU_BEZIER) {
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
while(a--) {
|
|
|
|
|
if(itemstobeselected[k] != -1) select_beztriple(bezt, SELECT, 1, VISIBLE);
|
|
|
|
|
k++;
|
|
|
|
|
bezt++;
|
2006-11-06 18:20:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2007-06-14 14:36:27 +00:00
|
|
|
bp= nu->bp;
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
while(a--) {
|
|
|
|
|
if(itemstobeselected[k] != -1) select_bpoint(bp, SELECT, 1, VISIBLE);
|
|
|
|
|
k++;
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-11-06 18:20:56 +00:00
|
|
|
}
|
2007-06-14 14:36:27 +00:00
|
|
|
|
|
|
|
|
MEM_freeN(itemstobeselected);
|
|
|
|
|
|
|
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
BIF_undo_push("Select Random");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void select_every_nth_nurb()
|
|
|
|
|
{
|
|
|
|
|
static short nfac= 2;
|
|
|
|
|
|
|
|
|
|
if(!G.obedit) return;
|
|
|
|
|
|
|
|
|
|
if(!button(&nfac, 2, 25,"N:")) return;
|
|
|
|
|
|
|
|
|
|
select_adjacent_cp(nfac, 1, SELECT);
|
|
|
|
|
select_adjacent_cp(-nfac, 1, SELECT);
|
2006-11-06 18:20:56 +00:00
|
|
|
|
|
|
|
|
countall();
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
2007-06-14 14:36:27 +00:00
|
|
|
BIF_undo_push("Select Every Nth");
|
2006-11-06 18:20:56 +00:00
|
|
|
}
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
void adduplicate_nurb()
|
|
|
|
|
{
|
|
|
|
|
|
2007-03-14 09:08:41 +00:00
|
|
|
if(G.vd==0 || (G.vd->lay & G.obedit->lay)==0 ) return;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
adduplicateflagNurb(1);
|
|
|
|
|
|
|
|
|
|
countall();
|
2005-05-08 12:00:28 +00:00
|
|
|
BIF_TransformSetUndo("Add Duplicate");
|
2005-05-10 04:21:11 +00:00
|
|
|
initTransform(TFM_TRANSLATION, CTX_NO_PET);
|
|
|
|
|
Transform();
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void delNurb()
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu, *next, *nu1;
|
|
|
|
|
BezTriple *bezt, *bezt1, *bezt2;
|
|
|
|
|
BPoint *bp, *bp1, *bp2;
|
|
|
|
|
int a;
|
|
|
|
|
short event, cut = 0;
|
|
|
|
|
|
|
|
|
|
if(G.obedit==0 ) return;
|
2007-03-14 09:08:41 +00:00
|
|
|
if(G.vd==0 || (G.vd->lay & G.obedit->lay)==0 ) return;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-06-05 05:55:15 +00:00
|
|
|
if(G.obedit->type==OB_SURF) event= pupmenu("Erase %t|Selected%x0|All%x2");
|
|
|
|
|
else event= pupmenu("Erase %t|Selected%x0|Segment%x1|All%x2");
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
if(event== -1) return;
|
|
|
|
|
|
|
|
|
|
if(G.obedit->type==OB_SURF) {
|
|
|
|
|
if(event==0) deleteflagNurb(1);
|
|
|
|
|
else freeNurblist(&editNurb);
|
|
|
|
|
|
|
|
|
|
countall();
|
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);
|
2002-10-12 11:37:38 +00:00
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
2004-04-07 11:35:11 +00:00
|
|
|
allqueue(REDRAWBUTSEDIT, 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("Delete");
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(event==0) {
|
2003-04-28 14:43:20 +00:00
|
|
|
/* first loop, can we remove entire pieces? */
|
2002-10-12 11:37:38 +00:00
|
|
|
nu= editNurb.first;
|
|
|
|
|
while(nu) {
|
|
|
|
|
next= nu->next;
|
|
|
|
|
if( (nu->type & 7)==CU_BEZIER ) {
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
if(a) {
|
|
|
|
|
while(a) {
|
2007-12-01 23:25:00 +00:00
|
|
|
if( BEZSELECTED_HIDDENHANDLES(bezt) );
|
2002-10-12 11:37:38 +00:00
|
|
|
else break;
|
|
|
|
|
a--;
|
|
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
if(a==0) {
|
|
|
|
|
BLI_remlink(&editNurb, nu);
|
2008-05-25 23:05:13 +00:00
|
|
|
freeNurb(nu); nu= NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
if(a) {
|
|
|
|
|
while(a) {
|
2007-12-11 14:19:05 +00:00
|
|
|
if(bp->f1 & SELECT);
|
2002-10-12 11:37:38 +00:00
|
|
|
else break;
|
|
|
|
|
a--;
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
if(a==0) {
|
|
|
|
|
BLI_remlink(&editNurb, nu);
|
2008-05-25 23:05:13 +00:00
|
|
|
freeNurb(nu); nu= NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-05-17 22:37:34 +00:00
|
|
|
|
2008-05-26 09:50:46 +00:00
|
|
|
/* Never allow the order to exceed the number of points
|
|
|
|
|
- note, this is ok but changes unselected nurbs, disable for now */
|
|
|
|
|
/*
|
|
|
|
|
if ((nu!= NULL) && ((nu->type & 7)==CU_NURBS)) {
|
|
|
|
|
clamp_nurb_order_u(nu);
|
2008-05-17 22:37:34 +00:00
|
|
|
}
|
2008-05-26 09:50:46 +00:00
|
|
|
*/
|
2002-10-12 11:37:38 +00:00
|
|
|
nu= next;
|
|
|
|
|
}
|
2003-04-28 14:43:20 +00:00
|
|
|
/* 2nd loop, delete small pieces: just for curves */
|
2002-10-12 11:37:38 +00:00
|
|
|
nu= editNurb.first;
|
|
|
|
|
while(nu) {
|
|
|
|
|
next= nu->next;
|
|
|
|
|
event= 0;
|
|
|
|
|
if( (nu->type & 7)==CU_BEZIER ) {
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
for(a=0;a<nu->pntsu;a++) {
|
2007-12-01 23:25:00 +00:00
|
|
|
if( BEZSELECTED_HIDDENHANDLES(bezt) ) {
|
2008-05-17 22:37:34 +00:00
|
|
|
memmove(bezt, bezt+1, (nu->pntsu-a-1)*sizeof(BezTriple));
|
2002-10-12 11:37:38 +00:00
|
|
|
nu->pntsu--;
|
|
|
|
|
a--;
|
|
|
|
|
event= 1;
|
|
|
|
|
}
|
|
|
|
|
else bezt++;
|
|
|
|
|
}
|
|
|
|
|
if(event) {
|
|
|
|
|
bezt1 =
|
|
|
|
|
(BezTriple*)MEM_mallocN((nu->pntsu) * sizeof(BezTriple), "delNurb");
|
|
|
|
|
memcpy(bezt1, nu->bezt, (nu->pntsu)*sizeof(BezTriple) );
|
|
|
|
|
MEM_freeN(nu->bezt);
|
|
|
|
|
nu->bezt= bezt1;
|
|
|
|
|
calchandlesNurb(nu);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(nu->pntsv==1) {
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
|
|
|
|
|
for(a=0;a<nu->pntsu;a++) {
|
2007-12-11 14:19:05 +00:00
|
|
|
if( bp->f1 & SELECT ) {
|
2008-05-17 22:37:34 +00:00
|
|
|
memmove(bp, bp+1, (nu->pntsu-a-1)*sizeof(BPoint));
|
2002-10-12 11:37:38 +00:00
|
|
|
nu->pntsu--;
|
|
|
|
|
a--;
|
|
|
|
|
event= 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(event) {
|
|
|
|
|
bp1 = (BPoint*)MEM_mallocN(nu->pntsu * sizeof(BPoint), "delNurb2");
|
|
|
|
|
memcpy(bp1, nu->bp, (nu->pntsu)*sizeof(BPoint) );
|
|
|
|
|
MEM_freeN(nu->bp);
|
|
|
|
|
nu->bp= bp1;
|
2008-05-17 22:37:34 +00:00
|
|
|
|
2008-05-26 09:50:46 +00:00
|
|
|
/* Never allow the order to exceed the number of points\
|
|
|
|
|
- note, this is ok but changes unselected nurbs, disable for now */
|
|
|
|
|
/*
|
|
|
|
|
if ((nu->type & 7)==CU_NURBS) {
|
|
|
|
|
clamp_nurb_order_u(nu);
|
|
|
|
|
}*/
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
makeknots(nu, 1, nu->flagu>>1);
|
|
|
|
|
}
|
|
|
|
|
nu= next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(event==1) { /* erase segment */
|
2003-04-28 14:43:20 +00:00
|
|
|
/* find the 2 selected points */
|
2002-10-12 11:37:38 +00:00
|
|
|
bezt1= bezt2= 0;
|
|
|
|
|
bp1= bp2= 0;
|
|
|
|
|
nu= editNurb.first;
|
|
|
|
|
nu1= 0;
|
|
|
|
|
while(nu) {
|
|
|
|
|
next= nu->next;
|
|
|
|
|
if( (nu->type & 7)==CU_BEZIER ) {
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
for(a=0; a<nu->pntsu-1; a++) {
|
2007-12-01 23:25:00 +00:00
|
|
|
if( BEZSELECTED_HIDDENHANDLES(bezt) ) {
|
2002-10-12 11:37:38 +00:00
|
|
|
bezt1= bezt;
|
|
|
|
|
bezt2= bezt+1;
|
2007-12-01 23:25:00 +00:00
|
|
|
if( (bezt2->f1 & SELECT) || (bezt2->f2 & SELECT) || (bezt2->f3 & SELECT) ) ;
|
2003-04-28 14:43:20 +00:00
|
|
|
else { /* maybe do not make cyclic */
|
2008-05-26 12:50:00 +00:00
|
|
|
if(a==0 && (nu->flagu & CU_CYCLIC) ) {
|
2002-10-12 11:37:38 +00:00
|
|
|
bezt2= bezt+(nu->pntsu-1);
|
2007-12-01 23:25:00 +00:00
|
|
|
if( (bezt2->f1 & SELECT) || (bezt2->f2 & SELECT) || (bezt2->f3 & SELECT) ) {
|
2008-05-26 12:50:00 +00:00
|
|
|
nu->flagu &= ~CU_CYCLIC;
|
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);
|
2002-10-12 11:37:38 +00:00
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
2004-04-07 11:35:11 +00:00
|
|
|
allqueue(REDRAWBUTSEDIT, 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("Delete");
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
cut= a;
|
|
|
|
|
nu1= nu;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(nu->pntsv==1) {
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
for(a=0; a<nu->pntsu-1; a++) {
|
2007-12-11 14:19:05 +00:00
|
|
|
if( bp->f1 & SELECT ) {
|
2002-10-12 11:37:38 +00:00
|
|
|
bp1= bp;
|
|
|
|
|
bp2= bp+1;
|
|
|
|
|
if( bp2->f1 & 1 ) ;
|
2003-04-28 14:43:20 +00:00
|
|
|
else { /* maybe do not make cyclic */
|
2008-05-26 12:50:00 +00:00
|
|
|
if(a==0 && (nu->flagu & CU_CYCLIC) ) {
|
2002-10-12 11:37:38 +00:00
|
|
|
bp2= bp+(nu->pntsu-1);
|
2008-05-26 12:50:00 +00:00
|
|
|
if( bp2->f1 & SELECT ) {
|
|
|
|
|
nu->flagu &= ~CU_CYCLIC;
|
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);
|
2002-10-12 11:37:38 +00:00
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
2004-04-07 11:35:11 +00:00
|
|
|
allqueue(REDRAWBUTSEDIT, 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("Delete");
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
cut= a;
|
|
|
|
|
nu1= nu;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(nu1) break;
|
|
|
|
|
|
|
|
|
|
nu= nu->next;
|
|
|
|
|
}
|
|
|
|
|
if(nu1) {
|
|
|
|
|
if(bezt1) {
|
2003-04-28 14:43:20 +00:00
|
|
|
if(nu1->pntsu==2) { /* remove completely */
|
2002-10-12 11:37:38 +00:00
|
|
|
BLI_remlink(&editNurb, nu);
|
2008-05-25 23:05:13 +00:00
|
|
|
freeNurb(nu); nu = NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2008-05-26 12:50:00 +00:00
|
|
|
else if(nu1->flagu & CU_CYCLIC) { /* cyclic */
|
2002-10-12 11:37:38 +00:00
|
|
|
bezt =
|
|
|
|
|
(BezTriple*)MEM_mallocN((cut+1) * sizeof(BezTriple), "delNurb1");
|
|
|
|
|
memcpy(bezt, nu1->bezt,(cut+1)*sizeof(BezTriple));
|
|
|
|
|
a= nu1->pntsu-cut-1;
|
|
|
|
|
memcpy(nu1->bezt, bezt2, a*sizeof(BezTriple));
|
|
|
|
|
memcpy(nu1->bezt+a, bezt, (cut+1)*sizeof(BezTriple));
|
2008-05-26 12:50:00 +00:00
|
|
|
nu1->flagu &= ~CU_CYCLIC;
|
2002-10-12 11:37:38 +00:00
|
|
|
MEM_freeN(bezt);
|
|
|
|
|
calchandlesNurb(nu);
|
|
|
|
|
}
|
2003-04-28 14:43:20 +00:00
|
|
|
else { /* add new curve */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
/* seems to be an error here... but where? (a can become zero) */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
nu =
|
|
|
|
|
(Nurb*)MEM_mallocN(sizeof(Nurb), "delNurb2");
|
|
|
|
|
memcpy(nu, nu1, sizeof(Nurb));
|
|
|
|
|
BLI_addtail(&editNurb, nu);
|
|
|
|
|
nu->bezt =
|
|
|
|
|
(BezTriple*)MEM_mallocN((cut+1) * sizeof(BezTriple), "delNurb3");
|
|
|
|
|
memcpy(nu->bezt, nu1->bezt,(cut+1)*sizeof(BezTriple));
|
|
|
|
|
a= nu1->pntsu-cut-1;
|
|
|
|
|
|
|
|
|
|
bezt =
|
|
|
|
|
(BezTriple*)MEM_mallocN(a * sizeof(BezTriple), "delNurb4");
|
|
|
|
|
memcpy(bezt, nu1->bezt+cut+1,a*sizeof(BezTriple));
|
|
|
|
|
MEM_freeN(nu1->bezt);
|
|
|
|
|
nu1->bezt= bezt;
|
|
|
|
|
nu1->pntsu= a;
|
|
|
|
|
nu->pntsu= cut+1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
calchandlesNurb(nu);
|
|
|
|
|
calchandlesNurb(nu1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(bp1) {
|
2003-04-28 14:43:20 +00:00
|
|
|
if(nu1->pntsu==2) { /* remove completely */
|
2002-10-12 11:37:38 +00:00
|
|
|
BLI_remlink(&editNurb, nu);
|
2008-05-25 23:05:13 +00:00
|
|
|
freeNurb(nu); nu= NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2008-05-26 12:50:00 +00:00
|
|
|
else if(nu1->flagu & CU_CYCLIC) { /* cyclic */
|
2002-10-12 11:37:38 +00:00
|
|
|
bp =
|
|
|
|
|
(BPoint*)MEM_mallocN((cut+1) * sizeof(BPoint), "delNurb5");
|
|
|
|
|
memcpy(bp, nu1->bp,(cut+1)*sizeof(BPoint));
|
|
|
|
|
a= nu1->pntsu-cut-1;
|
|
|
|
|
memcpy(nu1->bp, bp2, a*sizeof(BPoint));
|
|
|
|
|
memcpy(nu1->bp+a, bp, (cut+1)*sizeof(BPoint));
|
2008-05-26 12:50:00 +00:00
|
|
|
nu1->flagu &= ~CU_CYCLIC;
|
2002-10-12 11:37:38 +00:00
|
|
|
MEM_freeN(bp);
|
|
|
|
|
}
|
2003-04-28 14:43:20 +00:00
|
|
|
else { /* add new curve */
|
2002-10-12 11:37:38 +00:00
|
|
|
nu = (Nurb*)MEM_mallocN(sizeof(Nurb), "delNurb6");
|
|
|
|
|
memcpy(nu, nu1, sizeof(Nurb));
|
|
|
|
|
BLI_addtail(&editNurb, nu);
|
|
|
|
|
nu->bp =
|
|
|
|
|
(BPoint*)MEM_mallocN((cut+1) * sizeof(BPoint), "delNurb7");
|
|
|
|
|
memcpy(nu->bp, nu1->bp,(cut+1)*sizeof(BPoint));
|
|
|
|
|
a= nu1->pntsu-cut-1;
|
|
|
|
|
bp =
|
|
|
|
|
(BPoint*)MEM_mallocN(a * sizeof(BPoint), "delNurb8");
|
|
|
|
|
memcpy(bp, nu1->bp+cut+1,a*sizeof(BPoint));
|
|
|
|
|
MEM_freeN(nu1->bp);
|
|
|
|
|
nu1->bp= bp;
|
|
|
|
|
nu1->pntsu= a;
|
|
|
|
|
nu->pntsu= cut+1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(event==2) {
|
|
|
|
|
freeNurblist(&editNurb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
countall();
|
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-14 19:03:11 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
2004-04-07 11:35:11 +00:00
|
|
|
allqueue(REDRAWBUTSEDIT, 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("Delete");
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2005-09-28 11:55:43 +00:00
|
|
|
void nurb_set_smooth(short event)
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
|
|
|
|
|
if(G.obedit==0) return;
|
|
|
|
|
|
|
|
|
|
if(G.obedit->type != OB_CURVE) return;
|
|
|
|
|
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2005-09-28 11:55:43 +00:00
|
|
|
if(isNurbsel(nu)) {
|
|
|
|
|
if(event==1) nu->flag |= CU_SMOOTH;
|
|
|
|
|
else if(event==0) nu->flag &= ~CU_SMOOTH;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
|
|
|
|
|
if(event==1) BIF_undo_push("Set Smooth");
|
|
|
|
|
else if(event==0) BIF_undo_push("Set Solid");
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-01-03 02:35:45 +00:00
|
|
|
int join_curve(int type)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
Base *base, *nextb;
|
|
|
|
|
Object *ob;
|
|
|
|
|
Curve *cu;
|
|
|
|
|
Nurb *nu, *newnu;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
ListBase tempbase;
|
|
|
|
|
float imat[4][4], cmat[4][4];
|
|
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
ob= OBACT;
|
2007-04-22 22:08:19 +00:00
|
|
|
if (object_data_is_libdata(ob)) {
|
|
|
|
|
error_libdata();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-14 09:08:41 +00:00
|
|
|
if(!G.vd || ob->type!=type) return 0;
|
2006-01-03 02:35:45 +00:00
|
|
|
if(ob->lay & G.vd->lay); else return 0;
|
2002-10-12 11:37:38 +00:00
|
|
|
tempbase.first= tempbase.last= 0;
|
|
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
/* trasnform all selected curves inverse in obact */
|
2002-10-12 11:37:38 +00:00
|
|
|
Mat4Invert(imat, ob->obmat);
|
|
|
|
|
|
|
|
|
|
base= FIRSTBASE;
|
|
|
|
|
while(base) {
|
|
|
|
|
nextb= base->next;
|
2007-04-22 22:08:19 +00:00
|
|
|
if TESTBASE(base) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if(base->object->type==type) {
|
|
|
|
|
if(base->object != ob) {
|
|
|
|
|
|
|
|
|
|
cu= base->object->data;
|
|
|
|
|
|
|
|
|
|
if(cu->nurb.first) {
|
2003-04-28 14:43:20 +00:00
|
|
|
/* watch it: switch order here really goes wrong */
|
2002-10-12 11:37:38 +00:00
|
|
|
Mat4MulMat4(cmat, base->object->obmat, imat);
|
|
|
|
|
|
|
|
|
|
nu= cu->nurb.first;
|
|
|
|
|
while(nu) {
|
|
|
|
|
newnu= duplicateNurb(nu);
|
|
|
|
|
BLI_addtail(&tempbase, newnu);
|
|
|
|
|
|
|
|
|
|
if( (bezt= newnu->bezt) ) {
|
|
|
|
|
a= newnu->pntsu;
|
|
|
|
|
while(a--) {
|
|
|
|
|
Mat4MulVecfl(cmat, bezt->vec[0]);
|
|
|
|
|
Mat4MulVecfl(cmat, bezt->vec[1]);
|
|
|
|
|
Mat4MulVecfl(cmat, bezt->vec[2]);
|
|
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if( (bp= newnu->bp) ) {
|
|
|
|
|
a= newnu->pntsu*nu->pntsv;
|
|
|
|
|
while(a--) {
|
|
|
|
|
Mat4MulVecfl(cmat, bp->vec);
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
nu= nu->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free_and_unlink_base(base);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
base= nextb;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cu= ob->data;
|
|
|
|
|
addlisttolist(&cu->nurb, &tempbase);
|
|
|
|
|
|
2005-10-11 19:54:15 +00:00
|
|
|
DAG_scene_sort(G.scene); // because we removed object(s), call before editmode!
|
|
|
|
|
|
2006-09-28 01:55:44 +00:00
|
|
|
enter_editmode(EM_WAITCURSOR);
|
|
|
|
|
exit_editmode(EM_FREEDATA|EM_WAITCURSOR);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
2004-04-07 11:35:11 +00:00
|
|
|
allqueue(REDRAWBUTSEDIT, 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("Join");
|
2006-01-03 02:35:45 +00:00
|
|
|
return 1;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Nurb *addNurbprim(int type, int stype, int newname)
|
|
|
|
|
/* type: &8= 2D; 0=poly,1 bez, 4 nurb
|
2003-04-28 14:43:20 +00:00
|
|
|
* stype: 0: 2/4 points curve
|
|
|
|
|
* 1: 8 points circle
|
2002-10-12 11:37:38 +00:00
|
|
|
* 2: 4x4 patch Nurb
|
|
|
|
|
* 3: tube 4:sphere 5:donut
|
2003-04-28 14:43:20 +00:00
|
|
|
* 6: 5 points, 5th order straight line (for anim path)
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
{
|
|
|
|
|
static int xzproj= 0;
|
|
|
|
|
Nurb *nu = NULL;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
float *curs, cent[3],vec[3],imat[3][3],mat[3][3];
|
2007-03-14 09:08:41 +00:00
|
|
|
float fac,cmat[3][3], grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
int a, b;
|
2007-03-14 09:08:41 +00:00
|
|
|
|
|
|
|
|
if (G.vd) grid = G.vd->grid;
|
|
|
|
|
else grid = 1.0;
|
|
|
|
|
|
2007-04-04 13:18:41 +00:00
|
|
|
/* imat and center and size */
|
2002-10-12 11:37:38 +00:00
|
|
|
if(G.obedit) {
|
|
|
|
|
|
|
|
|
|
Mat3CpyMat4(mat, G.obedit->obmat);
|
|
|
|
|
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];
|
2007-03-14 09:08:41 +00:00
|
|
|
|
|
|
|
|
if (G.vd) {
|
* Two usability tweaks in adding objects, with user prefs
This changes the default behaviour in adding new objects, which has been
discussed for a long time, in person, on the funboard, and in the tracker,
and was agreed to be implemented during the 2.5 release cycle, so here it is.
They have been made default, with preferences to bring back old behaviour since
although people like myself still prefer the new default anyway, it will benefit
new users the most.
The preferences are in the 'Edit Methods' section, changing back to old behaviour
is as simple as a click of a button.
- Switch to edit mode preference
By default, now adding a new object doesn't automatically switch to edit mode.
Not only can this be annoying (most of the time when setting up scenes and models
I don't want to edit it straight away anyway), but it's a major hurdle in the learning
curve that new users have had to deal with at a very early stage.
Blender's different modes are an important part of understanding how the software works
and should have clear behaviour. The problem is that when a user selects something from
the add menu, he's not telling Blender to change modes, he wants to add an object.
But Blender then goes ahead and changes modes underneath him anyway, something that was
never explicitly asked for, something that's unrelated to the mental task at hand, and
fundamentally important to the operation of the software.
We observed plenty of people struggling with this during the training sessions that
we ran during Project Orange, and there's also no shortage of "why can't I select
other objects" questions on the forums.
- Aligned to View preference
Now by default, adding a new object doesn't rotate it so it's aligned facing the view,
but rather, it's remains unrotated in world space. This is something that's more of
a convenience issue (allowing people like me to stop the 'Add->Tab->Alt R dance),
but also makes things easier for new users, especially when doing things like rigging.
For a lot of tools in Blender, like curve deform, path cycling, constraints, it's necessary
for your objects' local axes to be aligned. This requirement isn't that obvious, and I've
had to debug rigs a few times from the animator in our studio, who has everything set up
correctly, but he just happened to be in a different vie at the time he added the object,
so they're misaligned and causing problems. Having all objects get created aligned to
worldspace, by default, makes a lot of these problems go away. It's much more understandable
when rotations are caused by something you've done explicitly, rather than as a side effect
of the software.
For convenience as well, most of the time, when I'm working in context and I decide I need a new object,
particularly working on production scenes that involve more than just one model, an Alt R
is almost always required after adding, since I don't want to have to disrupt the current
view of the scene by switching to top view, just to add an object. It's a bit arbitrary,
the view from which you want to look at your objects isn't usually the way you want them to
be looking at you.
2007-10-31 21:55:06 +00:00
|
|
|
if ( !(newname) || U.flag & USER_ADD_VIEWALIGNED) Mat3CpyMat4(imat, G.vd->viewmat);
|
|
|
|
|
else Mat3One(imat);
|
2007-03-14 09:08:41 +00:00
|
|
|
Mat3MulVecfl(imat, cent);
|
|
|
|
|
Mat3MulMat3(cmat, imat, mat);
|
|
|
|
|
Mat3Inv(imat, cmat);
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
setflagsNurb(0);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Mat3One(imat);
|
|
|
|
|
cent[0]= cent[1]= cent[2]= 0.0;
|
|
|
|
|
}
|
2008-09-29 23:46:01 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if ELEM5(stype, 0, 1, 2, 4, 6) {
|
|
|
|
|
nu = (Nurb*)MEM_callocN(sizeof(Nurb), "addNurbprim");
|
|
|
|
|
nu->type= type;
|
2008-09-26 19:00:49 +00:00
|
|
|
nu->resolu= 4;
|
|
|
|
|
nu->resolv= 4;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch(stype) {
|
|
|
|
|
case 0: /* curve */
|
2008-09-29 23:46:01 +00:00
|
|
|
nu->resolu= 12; /* set as 4 above */
|
2002-10-12 11:37:38 +00:00
|
|
|
if(newname) {
|
|
|
|
|
rename_id((ID *)G.obedit, "Curve");
|
|
|
|
|
rename_id((ID *)G.obedit->data, "Curve");
|
|
|
|
|
}
|
|
|
|
|
if((type & 7)==CU_BEZIER) {
|
|
|
|
|
nu->pntsu= 2;
|
|
|
|
|
nu->bezt =
|
|
|
|
|
(BezTriple*)MEM_callocN(2 * sizeof(BezTriple), "addNurbprim1");
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
bezt->h1= bezt->h2= HD_ALIGN;
|
2007-12-01 23:25:00 +00:00
|
|
|
bezt->f1= bezt->f2= bezt->f3= SELECT;
|
2006-08-13 07:37:51 +00:00
|
|
|
bezt->radius = 1.0;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
for(a=0;a<3;a++) {
|
|
|
|
|
VECCOPY(bezt->vec[a], cent);
|
|
|
|
|
}
|
2007-03-14 09:08:41 +00:00
|
|
|
bezt->vec[1][0]+= -grid;
|
|
|
|
|
bezt->vec[0][0]+= -1.5*grid;
|
|
|
|
|
bezt->vec[0][1]+= -0.5*grid;
|
|
|
|
|
bezt->vec[2][0]+= -0.5*grid;
|
|
|
|
|
bezt->vec[2][1]+= 0.5*grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
for(a=0;a<3;a++) Mat3MulVecfl(imat, bezt->vec[a]);
|
|
|
|
|
|
|
|
|
|
bezt++;
|
|
|
|
|
bezt->h1= bezt->h2= HD_ALIGN;
|
2007-12-01 23:25:00 +00:00
|
|
|
bezt->f1= bezt->f2= bezt->f3= SELECT;
|
2006-08-13 07:37:51 +00:00
|
|
|
bezt->radius = bezt->weight = 1.0;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
for(a=0;a<3;a++) {
|
|
|
|
|
VECCOPY(bezt->vec[a], cent);
|
|
|
|
|
}
|
2007-03-14 09:08:41 +00:00
|
|
|
bezt->vec[1][0]+= grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
for(a=0;a<3;a++) Mat3MulVecfl(imat, bezt->vec[a]);
|
|
|
|
|
|
|
|
|
|
calchandlesNurb(nu);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2007-03-14 09:08:41 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
nu->pntsu= 4;
|
|
|
|
|
nu->pntsv= 1;
|
|
|
|
|
nu->orderu= 4;
|
|
|
|
|
nu->bp= callocstructN(BPoint, 4, "addNurbprim3");
|
|
|
|
|
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
for(a=0;a<4;a++, bp++) {
|
|
|
|
|
VECCOPY(bp->vec, cent);
|
|
|
|
|
bp->vec[3]= 1.0;
|
2007-12-11 14:19:05 +00:00
|
|
|
bp->f1= SELECT;
|
2006-08-13 07:37:51 +00:00
|
|
|
bp->radius = bp->weight = 1.0;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bp= nu->bp;
|
2007-03-14 09:08:41 +00:00
|
|
|
bp->vec[0]+= -1.5*grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
2007-03-14 09:08:41 +00:00
|
|
|
bp->vec[0]+= -grid;
|
|
|
|
|
bp->vec[1]+= grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
2007-03-14 09:08:41 +00:00
|
|
|
bp->vec[0]+= grid;
|
|
|
|
|
bp->vec[1]+= grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
2007-03-14 09:08:41 +00:00
|
|
|
bp->vec[0]+= 1.5*grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
for(a=0;a<4;a++, bp++) Mat3MulVecfl(imat,bp->vec);
|
|
|
|
|
|
|
|
|
|
if((type & 7)==4) {
|
2003-04-28 14:43:20 +00:00
|
|
|
nu->knotsu= 0; /* makeknots allocates */
|
2002-10-12 11:37:38 +00:00
|
|
|
makeknots(nu, 1, nu->flagu>>1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
2006-08-13 07:37:51 +00:00
|
|
|
case 6: /* 5 point path */
|
2002-10-12 11:37:38 +00:00
|
|
|
nu->pntsu= 5;
|
|
|
|
|
nu->pntsv= 1;
|
|
|
|
|
nu->orderu= 5;
|
|
|
|
|
nu->flagu= 2; /* endpoint */
|
2008-09-26 19:00:49 +00:00
|
|
|
nu->resolu= 8;
|
2002-10-12 11:37:38 +00:00
|
|
|
nu->bp= callocstructN(BPoint, 5, "addNurbprim3");
|
|
|
|
|
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
for(a=0;a<5;a++, bp++) {
|
|
|
|
|
VECCOPY(bp->vec, cent);
|
|
|
|
|
bp->vec[3]= 1.0;
|
2007-12-11 14:19:05 +00:00
|
|
|
bp->f1= SELECT;
|
2006-08-13 07:37:51 +00:00
|
|
|
bp->radius = bp->weight = 1.0;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bp= nu->bp;
|
2007-03-14 09:08:41 +00:00
|
|
|
bp->vec[0]+= -2.0*grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
2007-03-14 09:08:41 +00:00
|
|
|
bp->vec[0]+= -grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++; bp++;
|
2007-03-14 09:08:41 +00:00
|
|
|
bp->vec[0]+= grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
2007-03-14 09:08:41 +00:00
|
|
|
bp->vec[0]+= 2.0*grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
for(a=0;a<5;a++, bp++) Mat3MulVecfl(imat,bp->vec);
|
|
|
|
|
|
|
|
|
|
if((type & 7)==4) {
|
2003-04-28 14:43:20 +00:00
|
|
|
nu->knotsu= 0; /* makeknots allocates */
|
2002-10-12 11:37:38 +00:00
|
|
|
makeknots(nu, 1, nu->flagu>>1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
2003-04-28 14:43:20 +00:00
|
|
|
case 1: /* circle */
|
2008-09-29 23:46:01 +00:00
|
|
|
nu->resolu= 12; /* set as 4 above */
|
2002-10-12 11:37:38 +00:00
|
|
|
if(newname) {
|
|
|
|
|
rename_id((ID *)G.obedit, "CurveCircle");
|
|
|
|
|
rename_id((ID *)G.obedit->data, "CurveCircle");
|
|
|
|
|
}
|
|
|
|
|
if((type & 7)==CU_BEZIER) {
|
|
|
|
|
nu->pntsu= 4;
|
|
|
|
|
nu->bezt= callocstructN(BezTriple, 4, "addNurbprim1");
|
2008-05-26 12:50:00 +00:00
|
|
|
nu->flagu= CU_CYCLIC;
|
2002-10-12 11:37:38 +00:00
|
|
|
bezt= nu->bezt;
|
|
|
|
|
|
|
|
|
|
for(a=0;a<3;a++) {
|
|
|
|
|
VECCOPY(bezt->vec[a], cent);
|
|
|
|
|
}
|
|
|
|
|
bezt->h1= bezt->h2= HD_AUTO;
|
2007-12-01 23:25:00 +00:00
|
|
|
bezt->f1= bezt->f2= bezt->f3= SELECT;
|
2007-03-14 09:08:41 +00:00
|
|
|
bezt->vec[1][0]+= -grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
for(a=0;a<3;a++) Mat3MulVecfl(imat,bezt->vec[a]);
|
2006-08-13 07:37:51 +00:00
|
|
|
bezt->radius = bezt->weight = 1.0;
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
bezt++;
|
|
|
|
|
for(a=0;a<3;a++) {
|
|
|
|
|
VECCOPY(bezt->vec[a], cent);
|
|
|
|
|
}
|
|
|
|
|
bezt->h1= bezt->h2= HD_AUTO;
|
2007-12-01 23:25:00 +00:00
|
|
|
bezt->f1= bezt->f2= bezt->f3= SELECT;
|
2007-03-14 09:08:41 +00:00
|
|
|
bezt->vec[1][1]+= grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
for(a=0;a<3;a++) Mat3MulVecfl(imat,bezt->vec[a]);
|
2006-08-13 07:37:51 +00:00
|
|
|
bezt->radius = bezt->weight = 1.0;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
bezt++;
|
|
|
|
|
for(a=0;a<3;a++) {
|
|
|
|
|
VECCOPY(bezt->vec[a], cent);
|
|
|
|
|
}
|
|
|
|
|
bezt->h1= bezt->h2= HD_AUTO;
|
2007-12-01 23:25:00 +00:00
|
|
|
bezt->f1= bezt->f2= bezt->f3= SELECT;
|
2007-03-14 09:08:41 +00:00
|
|
|
bezt->vec[1][0]+= grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
for(a=0;a<3;a++) Mat3MulVecfl(imat,bezt->vec[a]);
|
2006-08-13 07:37:51 +00:00
|
|
|
bezt->radius = bezt->weight = 1.0;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
bezt++;
|
|
|
|
|
for(a=0;a<3;a++) {
|
|
|
|
|
VECCOPY(bezt->vec[a], cent);
|
|
|
|
|
}
|
|
|
|
|
bezt->h1= bezt->h2= HD_AUTO;
|
2007-12-01 23:25:00 +00:00
|
|
|
bezt->f1= bezt->f2= bezt->f3= SELECT;
|
2007-03-14 09:08:41 +00:00
|
|
|
bezt->vec[1][1]+= -grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
for(a=0;a<3;a++) Mat3MulVecfl(imat,bezt->vec[a]);
|
2006-08-13 07:37:51 +00:00
|
|
|
bezt->radius = bezt->weight = 1.0;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
calchandlesNurb(nu);
|
|
|
|
|
}
|
|
|
|
|
else if( (type & 7)==CU_NURBS ) { /* nurb */
|
|
|
|
|
nu->pntsu= 8;
|
|
|
|
|
nu->pntsv= 1;
|
|
|
|
|
nu->orderu= 4;
|
|
|
|
|
nu->bp= callocstructN(BPoint, 8, "addNurbprim6");
|
2008-05-26 12:50:00 +00:00
|
|
|
nu->flagu= CU_CYCLIC;
|
2002-10-12 11:37:38 +00:00
|
|
|
bp= nu->bp;
|
|
|
|
|
|
|
|
|
|
for(a=0; a<8; a++) {
|
2007-12-11 14:19:05 +00:00
|
|
|
bp->f1= SELECT;
|
2002-10-12 11:37:38 +00:00
|
|
|
VECCOPY(bp->vec, cent);
|
|
|
|
|
|
|
|
|
|
if(xzproj==0) {
|
2007-03-14 09:08:41 +00:00
|
|
|
bp->vec[0]+= nurbcircle[a][0]*grid;
|
|
|
|
|
bp->vec[1]+= nurbcircle[a][1]*grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2007-03-14 09:08:41 +00:00
|
|
|
bp->vec[0]+= 0.25*nurbcircle[a][0]*grid-.75*grid;
|
|
|
|
|
bp->vec[2]+= 0.25*nurbcircle[a][1]*grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
if(a & 1) bp->vec[3]= 0.25*sqrt(2.0);
|
|
|
|
|
else bp->vec[3]= 1.0;
|
|
|
|
|
Mat3MulVecfl(imat,bp->vec);
|
2006-08-13 07:37:51 +00:00
|
|
|
bp->radius = bp->weight = 1.0;
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
makeknots(nu, 1, nu->flagu>>1);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2: /* 4x4 patch */
|
|
|
|
|
if( (type & 7)==CU_NURBS ) { /* nurb */
|
|
|
|
|
if(newname) {
|
|
|
|
|
rename_id((ID *)G.obedit, "Surf");
|
|
|
|
|
rename_id((ID *)G.obedit->data, "Surf");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nu->pntsu= 4;
|
|
|
|
|
nu->pntsv= 4;
|
|
|
|
|
nu->orderu= 4;
|
|
|
|
|
nu->orderv= 4;
|
2004-07-08 20:38:27 +00:00
|
|
|
nu->flag= CU_SMOOTH;
|
2002-10-12 11:37:38 +00:00
|
|
|
nu->bp= callocstructN(BPoint, 4*4, "addNurbprim6");
|
|
|
|
|
nu->flagu= 0;
|
|
|
|
|
nu->flagv= 0;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
|
|
|
|
|
for(a=0; a<4; a++) {
|
|
|
|
|
for(b=0; b<4; b++) {
|
|
|
|
|
VECCOPY(bp->vec, cent);
|
2007-12-11 14:19:05 +00:00
|
|
|
bp->f1= SELECT;
|
2002-10-12 11:37:38 +00:00
|
|
|
fac= (float)a -1.5;
|
2007-03-14 09:08:41 +00:00
|
|
|
bp->vec[0]+= fac*grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
fac= (float)b -1.5;
|
2007-03-14 09:08:41 +00:00
|
|
|
bp->vec[1]+= fac*grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
if(a==1 || a==2) if(b==1 || b==2) {
|
2007-03-14 09:08:41 +00:00
|
|
|
bp->vec[2]+= grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
Mat3MulVecfl(imat,bp->vec);
|
|
|
|
|
bp->vec[3]= 1.0;
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
makeknots(nu, 1, nu->flagu>>1);
|
|
|
|
|
makeknots(nu, 2, nu->flagv>>1);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 3: /* tube */
|
|
|
|
|
if( (type & 7)==CU_NURBS ) {
|
|
|
|
|
if(newname) {
|
|
|
|
|
rename_id((ID *)G.obedit, "SurfTube");
|
|
|
|
|
rename_id((ID *)G.obedit->data, "SurfTube");
|
|
|
|
|
}
|
|
|
|
|
|
* Two usability tweaks in adding objects, with user prefs
This changes the default behaviour in adding new objects, which has been
discussed for a long time, in person, on the funboard, and in the tracker,
and was agreed to be implemented during the 2.5 release cycle, so here it is.
They have been made default, with preferences to bring back old behaviour since
although people like myself still prefer the new default anyway, it will benefit
new users the most.
The preferences are in the 'Edit Methods' section, changing back to old behaviour
is as simple as a click of a button.
- Switch to edit mode preference
By default, now adding a new object doesn't automatically switch to edit mode.
Not only can this be annoying (most of the time when setting up scenes and models
I don't want to edit it straight away anyway), but it's a major hurdle in the learning
curve that new users have had to deal with at a very early stage.
Blender's different modes are an important part of understanding how the software works
and should have clear behaviour. The problem is that when a user selects something from
the add menu, he's not telling Blender to change modes, he wants to add an object.
But Blender then goes ahead and changes modes underneath him anyway, something that was
never explicitly asked for, something that's unrelated to the mental task at hand, and
fundamentally important to the operation of the software.
We observed plenty of people struggling with this during the training sessions that
we ran during Project Orange, and there's also no shortage of "why can't I select
other objects" questions on the forums.
- Aligned to View preference
Now by default, adding a new object doesn't rotate it so it's aligned facing the view,
but rather, it's remains unrotated in world space. This is something that's more of
a convenience issue (allowing people like me to stop the 'Add->Tab->Alt R dance),
but also makes things easier for new users, especially when doing things like rigging.
For a lot of tools in Blender, like curve deform, path cycling, constraints, it's necessary
for your objects' local axes to be aligned. This requirement isn't that obvious, and I've
had to debug rigs a few times from the animator in our studio, who has everything set up
correctly, but he just happened to be in a different vie at the time he added the object,
so they're misaligned and causing problems. Having all objects get created aligned to
worldspace, by default, makes a lot of these problems go away. It's much more understandable
when rotations are caused by something you've done explicitly, rather than as a side effect
of the software.
For convenience as well, most of the time, when I'm working in context and I decide I need a new object,
particularly working on production scenes that involve more than just one model, an Alt R
is almost always required after adding, since I don't want to have to disrupt the current
view of the scene by switching to top view, just to add an object. It's a bit arbitrary,
the view from which you want to look at your objects isn't usually the way you want them to
be looking at you.
2007-10-31 21:55:06 +00:00
|
|
|
nu= addNurbprim(4, 1, newname); /* circle */
|
2008-09-26 19:00:49 +00:00
|
|
|
nu->resolu= 4;
|
2004-07-08 20:38:27 +00:00
|
|
|
nu->flag= CU_SMOOTH;
|
2003-04-28 14:43:20 +00:00
|
|
|
BLI_addtail(&editNurb, nu); /* temporal for extrude and translate */
|
2002-10-12 11:37:38 +00:00
|
|
|
vec[0]=vec[1]= 0.0;
|
2007-03-14 09:08:41 +00:00
|
|
|
vec[2]= -grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
Mat3MulVecfl(imat, vec);
|
|
|
|
|
translateflagNurb(1, vec);
|
|
|
|
|
extrudeflagNurb(1);
|
|
|
|
|
vec[0]= -2*vec[0];
|
|
|
|
|
vec[1]= -2*vec[1];
|
|
|
|
|
vec[2]= -2*vec[2];
|
|
|
|
|
translateflagNurb(1, vec);
|
|
|
|
|
|
|
|
|
|
BLI_remlink(&editNurb, nu);
|
|
|
|
|
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
while(a-- >0) {
|
2007-12-11 14:19:05 +00:00
|
|
|
bp->f1 |= SELECT;
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 4: /* sphere */
|
|
|
|
|
if( (type & 7)==CU_NURBS ) {
|
|
|
|
|
if(newname) {
|
|
|
|
|
rename_id((ID *)G.obedit, "SurfSphere");
|
|
|
|
|
rename_id((ID *)G.obedit->data, "SurfSphere");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nu->pntsu= 5;
|
|
|
|
|
nu->pntsv= 1;
|
|
|
|
|
nu->orderu= 3;
|
2008-09-26 19:00:49 +00:00
|
|
|
nu->resolu= 4;
|
|
|
|
|
nu->resolv= 4;
|
2004-07-08 20:38:27 +00:00
|
|
|
nu->flag= CU_SMOOTH;
|
2002-10-12 11:37:38 +00:00
|
|
|
nu->bp= callocstructN(BPoint, 5, "addNurbprim6");
|
|
|
|
|
nu->flagu= 0;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
|
|
|
|
|
for(a=0; a<5; a++) {
|
2007-12-11 14:19:05 +00:00
|
|
|
bp->f1= SELECT;
|
2002-10-12 11:37:38 +00:00
|
|
|
VECCOPY(bp->vec, cent);
|
2007-03-14 09:08:41 +00:00
|
|
|
bp->vec[0]+= nurbcircle[a][0]*grid;
|
|
|
|
|
bp->vec[2]+= nurbcircle[a][1]*grid;
|
2002-10-12 11:37:38 +00:00
|
|
|
if(a & 1) bp->vec[3]= 0.5*sqrt(2.0);
|
|
|
|
|
else bp->vec[3]= 1.0;
|
|
|
|
|
Mat3MulVecfl(imat,bp->vec);
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
nu->flagu= 4;
|
|
|
|
|
makeknots(nu, 1, nu->flagu>>1);
|
|
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
BLI_addtail(&editNurb, nu); /* temporal for spin */
|
2008-05-01 18:16:21 +00:00
|
|
|
if(newname && (U.flag & USER_ADD_VIEWALIGNED) == 0)
|
|
|
|
|
spin_nurb(0, 2);
|
|
|
|
|
else
|
|
|
|
|
spin_nurb(0, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
makeknots(nu, 2, nu->flagv>>1);
|
|
|
|
|
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
while(a-- >0) {
|
2007-12-11 14:19:05 +00:00
|
|
|
bp->f1 |= SELECT;
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
BLI_remlink(&editNurb, nu);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 5: /* donut */
|
|
|
|
|
if( (type & 7)==CU_NURBS ) {
|
|
|
|
|
if(newname) {
|
|
|
|
|
rename_id((ID *)G.obedit, "SurfDonut");
|
|
|
|
|
rename_id((ID *)G.obedit->data, "SurfDonut");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xzproj= 1;
|
* Two usability tweaks in adding objects, with user prefs
This changes the default behaviour in adding new objects, which has been
discussed for a long time, in person, on the funboard, and in the tracker,
and was agreed to be implemented during the 2.5 release cycle, so here it is.
They have been made default, with preferences to bring back old behaviour since
although people like myself still prefer the new default anyway, it will benefit
new users the most.
The preferences are in the 'Edit Methods' section, changing back to old behaviour
is as simple as a click of a button.
- Switch to edit mode preference
By default, now adding a new object doesn't automatically switch to edit mode.
Not only can this be annoying (most of the time when setting up scenes and models
I don't want to edit it straight away anyway), but it's a major hurdle in the learning
curve that new users have had to deal with at a very early stage.
Blender's different modes are an important part of understanding how the software works
and should have clear behaviour. The problem is that when a user selects something from
the add menu, he's not telling Blender to change modes, he wants to add an object.
But Blender then goes ahead and changes modes underneath him anyway, something that was
never explicitly asked for, something that's unrelated to the mental task at hand, and
fundamentally important to the operation of the software.
We observed plenty of people struggling with this during the training sessions that
we ran during Project Orange, and there's also no shortage of "why can't I select
other objects" questions on the forums.
- Aligned to View preference
Now by default, adding a new object doesn't rotate it so it's aligned facing the view,
but rather, it's remains unrotated in world space. This is something that's more of
a convenience issue (allowing people like me to stop the 'Add->Tab->Alt R dance),
but also makes things easier for new users, especially when doing things like rigging.
For a lot of tools in Blender, like curve deform, path cycling, constraints, it's necessary
for your objects' local axes to be aligned. This requirement isn't that obvious, and I've
had to debug rigs a few times from the animator in our studio, who has everything set up
correctly, but he just happened to be in a different vie at the time he added the object,
so they're misaligned and causing problems. Having all objects get created aligned to
worldspace, by default, makes a lot of these problems go away. It's much more understandable
when rotations are caused by something you've done explicitly, rather than as a side effect
of the software.
For convenience as well, most of the time, when I'm working in context and I decide I need a new object,
particularly working on production scenes that involve more than just one model, an Alt R
is almost always required after adding, since I don't want to have to disrupt the current
view of the scene by switching to top view, just to add an object. It's a bit arbitrary,
the view from which you want to look at your objects isn't usually the way you want them to
be looking at you.
2007-10-31 21:55:06 +00:00
|
|
|
nu= addNurbprim(4, 1, newname); /* circle */
|
2002-10-12 11:37:38 +00:00
|
|
|
xzproj= 0;
|
2008-09-26 19:00:49 +00:00
|
|
|
nu->resolu= 4;
|
|
|
|
|
nu->resolv= 4;
|
2004-07-08 20:38:27 +00:00
|
|
|
nu->flag= CU_SMOOTH;
|
2003-04-28 14:43:20 +00:00
|
|
|
BLI_addtail(&editNurb, nu); /* temporal for extrude and translate */
|
2008-05-01 18:16:21 +00:00
|
|
|
if(newname && (U.flag & USER_ADD_VIEWALIGNED) == 0)
|
|
|
|
|
spin_nurb(0, 2);
|
|
|
|
|
else
|
|
|
|
|
spin_nurb(0, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
BLI_remlink(&editNurb, nu);
|
|
|
|
|
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
while(a-- >0) {
|
2007-12-11 14:19:05 +00:00
|
|
|
bp->f1 |= SELECT;
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
/* always do: */
|
2004-07-08 20:38:27 +00:00
|
|
|
nu->flag= CU_SMOOTH;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
test2DNurb(nu);
|
|
|
|
|
|
|
|
|
|
return nu;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void default_curve_ipo(Curve *cu)
|
|
|
|
|
{
|
|
|
|
|
IpoCurve *icu;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
|
|
|
|
|
if(cu->ipo) return;
|
|
|
|
|
|
|
|
|
|
cu->ipo= add_ipo("CurveIpo", ID_CU);
|
|
|
|
|
|
|
|
|
|
icu= MEM_callocN(sizeof(IpoCurve), "ipocurve");
|
|
|
|
|
|
|
|
|
|
icu->blocktype= ID_CU;
|
|
|
|
|
icu->adrcode= CU_SPEED;
|
2005-07-11 12:31:15 +00:00
|
|
|
icu->flag= IPO_VISIBLE|IPO_SELECT|IPO_AUTO_HORIZ;
|
2002-10-12 11:37:38 +00:00
|
|
|
set_icu_vars(icu);
|
|
|
|
|
|
|
|
|
|
BLI_addtail( &(cu->ipo->curve), icu);
|
|
|
|
|
|
|
|
|
|
icu->bezt= bezt= MEM_callocN(2*sizeof(BezTriple), "defaultipo");
|
|
|
|
|
icu->totvert= 2;
|
|
|
|
|
|
|
|
|
|
bezt->hide= IPO_BEZ;
|
|
|
|
|
bezt->f1=bezt->f2= bezt->f3= SELECT;
|
|
|
|
|
bezt->h1= bezt->h2= HD_AUTO;
|
|
|
|
|
bezt++;
|
|
|
|
|
bezt->vec[1][0]= 100.0;
|
|
|
|
|
bezt->vec[1][1]= 1.0;
|
|
|
|
|
bezt->hide= IPO_BEZ;
|
|
|
|
|
bezt->f1=bezt->f2= bezt->f3= SELECT;
|
|
|
|
|
bezt->h1= bezt->h2= HD_AUTO;
|
|
|
|
|
|
|
|
|
|
calchandles_ipocurve(icu);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void add_primitiveCurve(int stype)
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
Curve *cu;
|
|
|
|
|
int type, newname= 0;
|
|
|
|
|
|
2007-03-14 09:08:41 +00:00
|
|
|
if(G.vd==0) return;
|
2002-10-12 11:37:38 +00:00
|
|
|
if(G.scene->id.lib) return;
|
|
|
|
|
|
|
|
|
|
/* this function also comes from an info window */
|
|
|
|
|
if ELEM(curarea->spacetype, SPACE_VIEW3D, SPACE_INFO); else return;
|
|
|
|
|
|
|
|
|
|
if(stype>=10 && stype<20) type= CU_2D+1;
|
|
|
|
|
else if(stype>=20 && stype<30) type= CU_2D+2;
|
|
|
|
|
else if(stype>=30 && stype<40) type= CU_2D+3;
|
|
|
|
|
else if(stype>=40 && stype<50) {
|
|
|
|
|
if(stype==46) type= 4;
|
|
|
|
|
else type= CU_2D+4;
|
|
|
|
|
}
|
|
|
|
|
else type= CU_2D;
|
|
|
|
|
|
|
|
|
|
check_editmode(OB_CURVE);
|
|
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
/* if no obedit: new object and enter editmode */
|
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(G.obedit==NULL) {
|
2003-10-12 00:42:09 +00:00
|
|
|
add_object_draw(OB_CURVE);
|
2002-10-12 11:37:38 +00:00
|
|
|
base_init_from_view3d(BASACT, G.vd);
|
|
|
|
|
G.obedit= BASACT->object;
|
|
|
|
|
|
|
|
|
|
where_is_object(G.obedit);
|
|
|
|
|
|
|
|
|
|
make_editNurb();
|
|
|
|
|
setcursor_space(SPACE_VIEW3D, CURSOR_EDIT);
|
|
|
|
|
newname= 1;
|
|
|
|
|
|
|
|
|
|
cu= G.obedit->data;
|
|
|
|
|
if(stype==46) {
|
|
|
|
|
cu->flag |= (CU_3D+CU_PATH);
|
|
|
|
|
|
|
|
|
|
default_curve_ipo(cu);
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-08-31 13:43:18 +00:00
|
|
|
else {
|
|
|
|
|
cu= G.obedit->data;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
if(cu->flag & CU_3D) type &= ~CU_2D;
|
|
|
|
|
|
|
|
|
|
stype= (stype % 10);
|
|
|
|
|
|
|
|
|
|
nu= addNurbprim(type, stype, newname); /* 2D */
|
|
|
|
|
|
|
|
|
|
BLI_addtail(&editNurb, nu);
|
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-14 19:03:11 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
countall();
|
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 a new object was created, it stores it in Curve, for reload original data and undo */
|
* Two usability tweaks in adding objects, with user prefs
This changes the default behaviour in adding new objects, which has been
discussed for a long time, in person, on the funboard, and in the tracker,
and was agreed to be implemented during the 2.5 release cycle, so here it is.
They have been made default, with preferences to bring back old behaviour since
although people like myself still prefer the new default anyway, it will benefit
new users the most.
The preferences are in the 'Edit Methods' section, changing back to old behaviour
is as simple as a click of a button.
- Switch to edit mode preference
By default, now adding a new object doesn't automatically switch to edit mode.
Not only can this be annoying (most of the time when setting up scenes and models
I don't want to edit it straight away anyway), but it's a major hurdle in the learning
curve that new users have had to deal with at a very early stage.
Blender's different modes are an important part of understanding how the software works
and should have clear behaviour. The problem is that when a user selects something from
the add menu, he's not telling Blender to change modes, he wants to add an object.
But Blender then goes ahead and changes modes underneath him anyway, something that was
never explicitly asked for, something that's unrelated to the mental task at hand, and
fundamentally important to the operation of the software.
We observed plenty of people struggling with this during the training sessions that
we ran during Project Orange, and there's also no shortage of "why can't I select
other objects" questions on the forums.
- Aligned to View preference
Now by default, adding a new object doesn't rotate it so it's aligned facing the view,
but rather, it's remains unrotated in world space. This is something that's more of
a convenience issue (allowing people like me to stop the 'Add->Tab->Alt R dance),
but also makes things easier for new users, especially when doing things like rigging.
For a lot of tools in Blender, like curve deform, path cycling, constraints, it's necessary
for your objects' local axes to be aligned. This requirement isn't that obvious, and I've
had to debug rigs a few times from the animator in our studio, who has everything set up
correctly, but he just happened to be in a different vie at the time he added the object,
so they're misaligned and causing problems. Having all objects get created aligned to
worldspace, by default, makes a lot of these problems go away. It's much more understandable
when rotations are caused by something you've done explicitly, rather than as a side effect
of the software.
For convenience as well, most of the time, when I'm working in context and I decide I need a new object,
particularly working on production scenes that involve more than just one model, an Alt R
is almost always required after adding, since I don't want to have to disrupt the current
view of the scene by switching to top view, just to add an object. It's a bit arbitrary,
the view from which you want to look at your objects isn't usually the way you want them to
be looking at you.
2007-10-31 21:55:06 +00:00
|
|
|
if ( !(newname) || U.flag & USER_ADD_EDITMODE) {
|
|
|
|
|
if(newname) load_editNurb();
|
|
|
|
|
} else {
|
|
|
|
|
exit_editmode(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
allqueue(REDRAWALL, 0);
|
|
|
|
|
|
|
|
|
|
BIF_undo_push("Add Curve");
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void add_primitiveNurb(int type)
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
int newname= 0;
|
|
|
|
|
|
|
|
|
|
if(G.scene->id.lib) return;
|
|
|
|
|
if ELEM(curarea->spacetype, SPACE_VIEW3D, SPACE_INFO); else return;
|
|
|
|
|
|
|
|
|
|
check_editmode(OB_SURF);
|
|
|
|
|
|
2003-04-28 14:43:20 +00:00
|
|
|
/* if no obedit: new object and enter editmode */
|
2002-10-12 11:37:38 +00:00
|
|
|
if(G.obedit==0) {
|
2003-10-12 00:42:09 +00:00
|
|
|
add_object_draw(OB_SURF);
|
2002-10-12 11:37:38 +00:00
|
|
|
base_init_from_view3d(BASACT, G.vd);
|
|
|
|
|
G.obedit= BASACT->object;
|
|
|
|
|
|
|
|
|
|
where_is_object(G.obedit);
|
|
|
|
|
|
|
|
|
|
make_editNurb();
|
|
|
|
|
setcursor_space(SPACE_VIEW3D, CURSOR_EDIT);
|
|
|
|
|
newname= 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nu= addNurbprim(4, type, newname);
|
|
|
|
|
BLI_addtail(&editNurb,nu);
|
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);
|
2003-05-13 14:22:28 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
countall();
|
* Two usability tweaks in adding objects, with user prefs
This changes the default behaviour in adding new objects, which has been
discussed for a long time, in person, on the funboard, and in the tracker,
and was agreed to be implemented during the 2.5 release cycle, so here it is.
They have been made default, with preferences to bring back old behaviour since
although people like myself still prefer the new default anyway, it will benefit
new users the most.
The preferences are in the 'Edit Methods' section, changing back to old behaviour
is as simple as a click of a button.
- Switch to edit mode preference
By default, now adding a new object doesn't automatically switch to edit mode.
Not only can this be annoying (most of the time when setting up scenes and models
I don't want to edit it straight away anyway), but it's a major hurdle in the learning
curve that new users have had to deal with at a very early stage.
Blender's different modes are an important part of understanding how the software works
and should have clear behaviour. The problem is that when a user selects something from
the add menu, he's not telling Blender to change modes, he wants to add an object.
But Blender then goes ahead and changes modes underneath him anyway, something that was
never explicitly asked for, something that's unrelated to the mental task at hand, and
fundamentally important to the operation of the software.
We observed plenty of people struggling with this during the training sessions that
we ran during Project Orange, and there's also no shortage of "why can't I select
other objects" questions on the forums.
- Aligned to View preference
Now by default, adding a new object doesn't rotate it so it's aligned facing the view,
but rather, it's remains unrotated in world space. This is something that's more of
a convenience issue (allowing people like me to stop the 'Add->Tab->Alt R dance),
but also makes things easier for new users, especially when doing things like rigging.
For a lot of tools in Blender, like curve deform, path cycling, constraints, it's necessary
for your objects' local axes to be aligned. This requirement isn't that obvious, and I've
had to debug rigs a few times from the animator in our studio, who has everything set up
correctly, but he just happened to be in a different vie at the time he added the object,
so they're misaligned and causing problems. Having all objects get created aligned to
worldspace, by default, makes a lot of these problems go away. It's much more understandable
when rotations are caused by something you've done explicitly, rather than as a side effect
of the software.
For convenience as well, most of the time, when I'm working in context and I decide I need a new object,
particularly working on production scenes that involve more than just one model, an Alt R
is almost always required after adding, since I don't want to have to disrupt the current
view of the scene by switching to top view, just to add an object. It's a bit arbitrary,
the view from which you want to look at your objects isn't usually the way you want them to
be looking at you.
2007-10-31 21:55:06 +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 a new object was created, it stores it in Curve, for reload original data and undo */
|
* Two usability tweaks in adding objects, with user prefs
This changes the default behaviour in adding new objects, which has been
discussed for a long time, in person, on the funboard, and in the tracker,
and was agreed to be implemented during the 2.5 release cycle, so here it is.
They have been made default, with preferences to bring back old behaviour since
although people like myself still prefer the new default anyway, it will benefit
new users the most.
The preferences are in the 'Edit Methods' section, changing back to old behaviour
is as simple as a click of a button.
- Switch to edit mode preference
By default, now adding a new object doesn't automatically switch to edit mode.
Not only can this be annoying (most of the time when setting up scenes and models
I don't want to edit it straight away anyway), but it's a major hurdle in the learning
curve that new users have had to deal with at a very early stage.
Blender's different modes are an important part of understanding how the software works
and should have clear behaviour. The problem is that when a user selects something from
the add menu, he's not telling Blender to change modes, he wants to add an object.
But Blender then goes ahead and changes modes underneath him anyway, something that was
never explicitly asked for, something that's unrelated to the mental task at hand, and
fundamentally important to the operation of the software.
We observed plenty of people struggling with this during the training sessions that
we ran during Project Orange, and there's also no shortage of "why can't I select
other objects" questions on the forums.
- Aligned to View preference
Now by default, adding a new object doesn't rotate it so it's aligned facing the view,
but rather, it's remains unrotated in world space. This is something that's more of
a convenience issue (allowing people like me to stop the 'Add->Tab->Alt R dance),
but also makes things easier for new users, especially when doing things like rigging.
For a lot of tools in Blender, like curve deform, path cycling, constraints, it's necessary
for your objects' local axes to be aligned. This requirement isn't that obvious, and I've
had to debug rigs a few times from the animator in our studio, who has everything set up
correctly, but he just happened to be in a different vie at the time he added the object,
so they're misaligned and causing problems. Having all objects get created aligned to
worldspace, by default, makes a lot of these problems go away. It's much more understandable
when rotations are caused by something you've done explicitly, rather than as a side effect
of the software.
For convenience as well, most of the time, when I'm working in context and I decide I need a new object,
particularly working on production scenes that involve more than just one model, an Alt R
is almost always required after adding, since I don't want to have to disrupt the current
view of the scene by switching to top view, just to add an object. It's a bit arbitrary,
the view from which you want to look at your objects isn't usually the way you want them to
be looking at you.
2007-10-31 21:55:06 +00:00
|
|
|
if ( !(newname) || U.flag & USER_ADD_EDITMODE) {
|
|
|
|
|
if(newname) load_editNurb();
|
|
|
|
|
} else {
|
|
|
|
|
exit_editmode(2);
|
|
|
|
|
}
|
|
|
|
|
allqueue(REDRAWALL, 0);
|
|
|
|
|
|
|
|
|
|
BIF_undo_push("Add Surface");
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void clear_tilt()
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
if(okee("Clear tilt")==0) return;
|
|
|
|
|
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if( nu->bezt ) {
|
|
|
|
|
bezt= nu->bezt;
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
while(a--) {
|
2007-12-01 23:25:00 +00:00
|
|
|
if(BEZSELECTED_HIDDENHANDLES(bezt)) bezt->alfa= 0.0;
|
2002-10-12 11:37:38 +00:00
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(nu->bp) {
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
a= nu->pntsu*nu->pntsv;
|
|
|
|
|
while(a--) {
|
2007-12-11 14:19:05 +00:00
|
|
|
if(bp->f1 & SELECT) bp->alfa= 0.0;
|
2002-10-12 11:37:38 +00:00
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-08-14 06:08:41 +00:00
|
|
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
2002-10-12 11:37:38 +00:00
|
|
|
allqueue(REDRAWVIEW3D, 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("Clear tilt");
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int bezt_compare (const void *e1, const void *e2)
|
|
|
|
|
{
|
|
|
|
|
BezTriple *b1 = *((BezTriple**)e1);
|
|
|
|
|
BezTriple *b2 = *((BezTriple**)e2);
|
|
|
|
|
|
|
|
|
|
/* Check numerical values */
|
|
|
|
|
float val = b1->vec[1][0] - b2->vec[1][0];
|
|
|
|
|
|
|
|
|
|
if (val<0)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
if (val>0)
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
/* Check selected flags : Ensures that selected keys will be listed first */
|
|
|
|
|
|
2007-12-01 23:25:00 +00:00
|
|
|
if ((b1->f2 & SELECT) && !(b2->f2 & SELECT))
|
2002-10-12 11:37:38 +00:00
|
|
|
return -1;
|
2007-12-01 23:25:00 +00:00
|
|
|
if (!(b1->f2 & SELECT) && (b2->f2 & SELECT))
|
2002-10-12 11:37:38 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2004-08-31 13:43:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/* **************** undo for curves ************** */
|
|
|
|
|
|
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
|
|
|
static void undoCurve_to_editCurve(void *lbv)
|
2004-08-31 13:43:18 +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
|
|
|
ListBase *lb= lbv;
|
2004-08-31 13:43:18 +00:00
|
|
|
Nurb *nu, *newnu;
|
2004-09-29 11:32:08 +00:00
|
|
|
|
2004-08-31 13:43:18 +00:00
|
|
|
freeNurblist(&editNurb);
|
|
|
|
|
|
|
|
|
|
/* copy */
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= lb->first; nu; nu= nu->next) {
|
2004-08-31 13:43:18 +00:00
|
|
|
newnu= duplicateNurb(nu);
|
|
|
|
|
BLI_addtail(&editNurb, newnu);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
static void *editCurve_to_undoCurve(void)
|
2004-08-31 13:43:18 +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
|
|
|
ListBase *lb;
|
2004-08-31 13:43:18 +00:00
|
|
|
Nurb *nu, *newnu;
|
|
|
|
|
|
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
|
|
|
lb= MEM_callocN(sizeof(ListBase), "listbase undo");
|
|
|
|
|
|
|
|
|
|
/* copy */
|
2006-11-06 18:20:56 +00:00
|
|
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
2004-08-31 13:43:18 +00:00
|
|
|
newnu= duplicateNurb(nu);
|
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
|
|
|
BLI_addtail(lb, newnu);
|
2004-08-31 13:43:18 +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
|
|
|
return lb;
|
2004-08-31 13:43:18 +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
|
|
|
static void free_undoCurve(void *lbv)
|
2004-08-31 13:43:18 +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
|
|
|
ListBase *lb= lbv;
|
2004-08-31 13:43:18 +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
|
|
|
freeNurblist(lb);
|
|
|
|
|
MEM_freeN(lb);
|
2004-08-31 13:43:18 +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
|
|
|
/* and this is all the undo system needs to know */
|
|
|
|
|
void undo_push_curve(char *name)
|
2004-08-31 13:43:18 +00:00
|
|
|
{
|
2008-02-21 16:57:58 +00:00
|
|
|
undo_editmode_push(name, free_undoCurve, undoCurve_to_editCurve, editCurve_to_undoCurve, NULL);
|
2004-08-31 13:43:18 +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
|
|
|
|
2004-08-31 13:43:18 +00:00
|
|
|
/***/
|