[Bf-committers] Knife tool and perspective mode -- incorrect results

Matthew H. Plough mplough at Princeton.EDU
Sat Nov 6 21:44:07 CET 2004


Hi everyone --

Last night I was playing around with 
http//www.princeton.edu/~mplough/tmp/optical.blend .  I was trying to 
use the knife tool to cut the pieces of the model in order to make one 
of those boxes where the back leg is drawn in front of the front one.  
Since this must be done only from the camera angle, I switched to the 
camera view and tried to cut.  However, the cut occurs quite far from my 
desired location.  Further investigation reveals that the knife tool 
produces incorrect results in any perspective mode. 

I present an overview of the current functionality of the seg_intersect 
function in blender/source/blender/src/editmesh_loop.c .  This function 
calculates the location of an intersection (if any) between a curve 
drawn by the user and an edit edge.

When KnifeSubdivide calls seg_intersect, it provides the curve and the 
current edge.

seg_intersect then copies the coordinates of the edge's two end 
vertices, and projects them onto the screen.  Then a huge mess happens, 
which accomplishes several things.  The function checks if an 
intersection occurs. 

If one does occur:
The function finds where along the edge (*IN SCREEN COORDINATES*) the 
intersection occurs, and returns this as a percentage.  Thus, if the cut 
happens halfway between e->v1->co and e->v2->co , the function returns a 
representation of 50%.

This is not valid in perspective mode.  In 
http://www.princeton.edu/~mplough/tmp/problem.png, the cursor is placed 
at the midpoint of an edge.  On screen, the edge is 831.5 pixels long.  
The screen distance from the cursor to the left edge is 320.7 pixels; 
the distance to the right edge is 509.7 pixels. 

509.7 is 61% of 831.5.

When I performed a cut at the cursor, the cut occurred as shown.  
Debugging output showed that isect (in seg_intersect) was a 
representation of 61%, so the cut occurred 61% of the way *in scene 
coordinates* from the right vertex the left vertex.  This is obviously 
incorrect. 

I am currently working on fixing seg_intersect to make this work properly.

Matt


More information about the Bf-committers mailing list