[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23019] trunk/blender/source/blender: Option to correct for 3D curve twist error.

Campbell Barton ideasman42 at gmail.com
Sun Sep 6 22:39:49 CEST 2009

Hi Martin, this was a method I had in mind for a while...
- twist are calculated from an orientation defined buy the 2
surrounding points, (twist wont change while rotating in editmode).
- twisting works the same way when switching curve direction
- twist depends entirely on curve shape so only parts of the curve
that move change.
- predictable - you can know if some part of the curve will be on the
outside - see the image, (except if it flips).

example and patch on trunk. only works for open curves.

is this what you mean be no.1?

The problem with flipping is that its not always 180d, twisting
gradually becomes greater and eventually flips. this is true for
2.49release also.
So this leaves me with some questions...
- how would you detect the difference between a gradual twist and a flip?
- if each segments rotation is calculated only knowing the previous
and next point, how would you know if the flip is gradual or not?
- if flipping is done based on the shape of the curve how can this be
animation safe?

On Sun, Sep 6, 2009 at 6:27 AM, Martin Poirier<theeth at yahoo.com> wrote:
> --- On Sun, 9/6/09, Campbell Barton <ideasman42 at gmail.com> wrote:
>> from talking to ZanQdo and Martin the
>> current method used to minimize
>> twist could be changed/improved
>> At the moment its not totally animation safe, since the
>> minimum twist
>> can change when the point positions move (hooks or shape
>> keys).
>> though is not likely to flicker, just rotate as the curve
>> moves which
>> is noticeable if you have a bevel shape rather then a
>> circle,
>> presumably if your using UV textures too.
> What it does is break the curve property of piecewise independence. So if you move a CV, it will affect the orientation of the curve for all points after that one (in the direction of the curve) and not just in 180 degrees rotations. That also breaks direction invariance, obviously.
> That's very nasty.
>> Martin suggests the existing Z-up method could check for
>> flipping and
>> correct for that but otherwise stay as it is.
>> I'll test some different methods and see if one can be used
>> or maybe
>> it can be an option per curve since they give such
>> different results.
> What I'm suggesting is one of two things: either (1) using the tangent and cotangent (first and second derivative) directly calculate the orientation, detecting zero crossings in the cotangent to avoid flips or (2) simply detecting flips in the current method (they happen invariably when the tangent become parallel to the reference up axis).
> In both cases, when a flip is detected, it should do a 180 rotation of the flipped orientation. This is the "classic" solution (taught in school classes), it works all the time and keeps piecewise independence.
> Variances caused by changes of direction are strictly 180 degrees and can be fixed by twisting the whole curve by a fixed amount (unlike the current solution). Orientations are still perpendicular before and after.
> The advantage of (1) is that the orientation of the curve is now dependent on its curvature and will result in more "natural" looking motion. It also means that rotating a curve in 3d in edit mode doesn't affect the orientation with regards to the curve itself. (2) on the other hand has the advantage of being closer to what we have right now (which is slightly more predictable than the cotangent method) and, if wanted, code could be written to add back twists when reading old files (meaning that this option would always be on, but old files that showed the bug would still show it BUT could be correct by changing the tilt).
> Martin
>      __________________________________________________________________
> Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now
> http://ca.toolbar.yahoo.com.
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers

- Campbell

More information about the Bf-committers mailing list