Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorRobert Wenzlaff <rwenzlaff@soylent-green.com>2003-10-19 23:50:17 +0400
committerRobert Wenzlaff <rwenzlaff@soylent-green.com>2003-10-19 23:50:17 +0400
commitde64d218a08548d5b33f412374f360585356a41c (patch)
tree4066459135cd1ef6b7d681a52a793a37f3caa289 /source
parenta56d3d189a7c57d10398174d1cf5b08194daa2f3 (diff)
Adding Knife tool as to be released in 2.3
User Info: To use this tool, select a group of verts, it can be larger than the desired cut as explained below. Then hit Shift-K. The tool will prompt for cut type (Exact line or Edge centers), Select, then use LMB to draw a "cut-line". Holding down LMB causes a freehand draw, clicking LMB causes a polyline draw. MMB locks the axis. When done press enter to divide mesh on cut line. Subdivide routines have been modified to produce fewer triangles as part of this tool. Edge Centers preserves UV info, Exact Line does not (it will be there, just slightly distorted). Since the cut line exists in 2D space, and does not make a persistant selection that can be modified in another 3D view, the knife selection is the AND of the vertex selection and the knife line, ie; the edge will be subdivided only if both verts are selected, and the knife line crosses the edge. Select your verts first, but you don't have to be overly precise. If you want to cut a few faces on the front of a sphere, you can select the whole front of the sphere, then knife the faces you want. Coder Info: KnifeSubdivide is called with 1 of 3 modes. KNIFE_PROMPT, KNIFE_EXACT, KNIFE_MIDPOINTS. The hotkey calls KNIFE_PROMPT. When adding to a menu or button, explicitly call out the mode. Part of the tool provides get_mouse_trail() that returns a CutCurve struct that defines a knife line. There are modes defined, but currently they are not implimented. Another part of this tool defines new behaviour for subdivideflag(). Setting beauty param to B_KNIFE tells subdivideflag() that the edges are preselected ans to skip the vert check. Also setting B_PERCENTSUB tells subdivideflag() to divide the edge at a percentage of the distance from eed->v1 to eed->v2. This percentage is passed in the eed->f1 flag as a short (ie, setting eed->f1 to 16384 cuts the edge half-way).
Diffstat (limited to 'source')
-rw-r--r--source/blender/include/BIF_editmesh.h13
-rw-r--r--source/blender/src/editmesh.c16
-rw-r--r--source/blender/src/space.c2
3 files changed, 21 insertions, 10 deletions
diff --git a/source/blender/include/BIF_editmesh.h b/source/blender/include/BIF_editmesh.h
index 1a91d31750e..6cff0bdb692 100644
--- a/source/blender/include/BIF_editmesh.h
+++ b/source/blender/include/BIF_editmesh.h
@@ -54,8 +54,17 @@ typedef struct CutCurve {
short y;
} CutCurve;
-void KnifeSubdivide(void);
-CutCurve *get_mouse_trail(int * length);
+void KnifeSubdivide(char mode);
+#define KNIFE_PROMPT 0
+#define KNIFE_EXACT 1
+#define KNIFE_MIDPOINT 2
+
+CutCurve *get_mouse_trail(int * length, char mode);
+#define TRAIL_POLYLINE 1 /* For future use, They don't do anything yet */
+#define TRAIL_FREEHAND 2
+#define TRAIL_MIXED 3
+#define TRAIL_AUTO 4
+
short seg_intersect(struct EditEdge * e, CutCurve *c, int len);
/* End Knife Subdiv */
diff --git a/source/blender/src/editmesh.c b/source/blender/src/editmesh.c
index cee9b4dc5f7..e390bfe463b 100644
--- a/source/blender/src/editmesh.c
+++ b/source/blender/src/editmesh.c
@@ -6862,7 +6862,7 @@ It is up to the caller to free the block when done with it,
this doesn't belong here.....
*/
-CutCurve *get_mouse_trail(int *len){
+CutCurve *get_mouse_trail(int *len, char mode){
CutCurve *curve,*temp;
short event, val, ldown=0, restart=0, rubberband=0;
@@ -6880,6 +6880,8 @@ CutCurve *get_mouse_trail(int *len){
glDrawBuffer(GL_FRONT);
persp(PERSP_WIN);
+
+ headerprint("LMB to draw, Enter to finish, ESC to abort.");
event=extern_qread(&val);
while((event != RETKEY ) && (event != RIGHTMOUSE) ){
@@ -6980,17 +6982,17 @@ CutCurve *get_mouse_trail(int *len){
Currently mapped to KKey when in MeshEdit mode.
Usage:
- Hit K,
+ Hit Shift K, Select Centers or Exact
Hold LMB down to draw path, hit RETKEY.
ESC cancels as expected.
Contributed by Robert Wenzlaff (Det. Thorn).
*/
-void KnifeSubdivide(){
+void KnifeSubdivide(char mode){
int oldcursor, len=0;
- short isect=0, mode=0;
+ short isect=0;
CutCurve *curve;
EditEdge *eed;
@@ -7001,10 +7003,10 @@ void KnifeSubdivide(){
set_cursor(CURSOR_PENCIL);
calc_meshverts_ext(); /*Update screen coords for current window */
+
+ if (mode==KNIFE_PROMPT) mode=pupmenu("Cut Type %t|Exact Line%x1|Centers%x2|");
- curve=get_mouse_trail(&len);
-
- if (curve) mode=pupmenu("Cut Type %t|Intersect%x1|50%%x2|");
+ curve=get_mouse_trail(&len, TRAIL_MIXED);
if (curve && len && mode){
eed= G.eded.first;
diff --git a/source/blender/src/space.c b/source/blender/src/space.c
index 80ac9ae7cd5..7877a7c3423 100644
--- a/source/blender/src/space.c
+++ b/source/blender/src/space.c
@@ -1019,7 +1019,7 @@ void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
case KKEY:
if(G.obedit) {
if (G.qual & LR_SHIFTKEY ){
- if (G.obedit->type==OB_MESH) KnifeSubdivide();
+ if (G.obedit->type==OB_MESH) KnifeSubdivide(KNIFE_PROMPT);
}
else if(G.obedit->type==OB_SURF) printknots();
}