Commit Graph

73 Commits

Author SHA1 Message Date
Alexander Gavrilov 1cb884be35 Make auto handle placement aware of cyclic extrapolation.
Cyclic extrapolation is implemented as an f-curve modifier, so this
technically violates abstraction separation and is something of a hack.
However without such behavior achieving smooth looping with cyclic
extrapolation is extremely cumbersome.

The new behavior is applied when the first modifier is Cyclic
extrapolation in Repeat or Repeat with Offset mode without
using influence, repeat count or range restrictions.

This change in behavior means that curve handles have to be updated
when the modifier is added, removed or its options change. Due to the
way code is structured, it seems it requires a helper link to the
containing curve from the modifier object.

Reviewers: aligorith

Differential Revision: https://developer.blender.org/D2783
2017-10-17 19:39:10 +03:00
Bastien Montagne eeb9e5316a Make whole ID copying code use const source pointer.
Noisy change, but safe, and better do it sooner than later if we are to
rework copying code. Also, previous commit shows this *is* useful to
catch some mistakes.
2017-06-14 22:38:11 +02:00
Campbell Barton 4e845e0670 Py-Driver: add 'self' option
Drivers can use this to refer to the data which the driver is applied to,
useful for objects, bones, to avoid having to create a variable pointing to its self.
2016-07-30 16:46:13 +10:00
Campbell Barton c6cc599311 Fix T48234: Glitch w/ action constraints sharing an action
FCurve evaluation depended on FCurve.curval, which isn't threadsafe.
Now only use this value for debug display,
and pass the value instead of storing in the FCurve for all but debug-display.
2016-06-04 00:57:44 +10:00
Joshua Leung 69ee6c9866 Drivers Editing: Added "Copy/Paste" buttons beside "Add Variable" for copying all variables from one driver to another
This was a feature request from a few years back (IIRC from ZanQdo?) to make it
easier to reuse one set of driver variables across several different drivers.

Dev Notes:
* Finally it's done! All that trouble for two little buttons.
* Grr... cmake... grrr!
2016-04-15 20:05:09 +12:00
Campbell Barton 82b0a9e369 PyDriver support for all RNA property types
Support for driver variables that don't resolve to numbers, eg:
objects, bones, curves... etc.

Without this, Python expressions to access this data needed to use an absolute path from `bpy.data`,
however this is inconvenient, breaks easily (based on naming) and wouldn't set the dependencies correctly.
2016-04-05 07:38:57 +10:00
Campbell Barton 7e65b02fb6 Cleanup: use prefix for return args 2016-03-24 18:05:10 +11:00
Joshua Leung 17d0c10096 Driver Keyframing: Some tweaks to make inserting keyframes on Driver F-Curves easier
Now, when trying to insert a keyframe on a driven property (using IKEY, or with
autokeying enabled), the keyframes will get created on the Driver's F-Curve
(instead of creating a new FCurve that goes into the active action, but will never
do anything). Furthermore, the x-value of the new keyframe will be the current
result of the driver expression.

Why/Motivations:
This way, it becomes easier to create corrective drivers, as you can position all
the targets the driver depends on, then adjust the driver value until it does what
you need, and then you keyframe that value to bake it into the Driver F-Curve
(in effect, "training" the computer how to behave in that case).

Usage Notes:
* In practice, that particular workflow is still quite clunky to achieve, due to some
  quirks of how the driver system and the UI widgets interact. Specifically, you'll
  need to disable/mute the driver before trying to edit the setting (to prevent the
  driver from immediately resetting the value - before even autokey fires!). However,
  if you're using the Graph Editor to preview/monitor/manage the keying process, you'll
  then want to re-enable the driver before changing the targets, so that you can see
  how much of a change you'll want to be applying!

* The warning about editing driver values may need to be disabled or selectively
  knocked out. I had it disabled while testing this functionality, but it's actually
  harmless in its current state (if just a bit annoying).
2016-03-24 19:34:52 +13:00
Joshua Leung c4956faf99 Drivers UI: Added name validation/linting for Driver Variables
When attempting to change a driver variable name to an "invalid" name,
an indicator will now be shown beside the offending variable name.
Clicking on this icon will show a popup which provides more information
about why the variable name cannot be used.

Reasons that it knows about are:
1) Starts with number
2) Has a dot
3) Has a space
4) Starts with or contains a special character
5) Starts with an underscore (Python does allow this, but it's bad practice,
   and makes checking security of drivers harder)
6) Is a reserved Python keyword
2016-03-24 15:15:04 +13:00
Campbell Barton 268524c025 Cleanup: use const for typeinfo 2015-03-30 21:18:49 +11:00
Joshua Leung fc0a576c30 Keyframes on NLA-Strip F-Curves are detected by RNA buttons too 2015-03-29 01:39:52 +13:00
Joshua Leung 2625dc5348 Bugfix T41525: Button keyframe indicators don't work correctly when editing NLA Strips
When the active action is a NLA strip, the keyframe indicator colors for buttons
and the 3D view indicator (i.e. the current frame indicator changes color) didn't
work correctly. This was because they were still checking for keyframes in
"global" time space, whereas they needed to be applying NLA corrections to
"look inside" the remapped action.
2014-11-16 20:24:38 +13:00
Bastien Montagne 8cb1b35bee Fix T40350: Some texture prop did not have visual feedback they were driven.
This is only a (hacky) partial fix, actually, since `RNA_property_animated()` will still
not work in those cases... Better that than nothing, though.

Thanks to Campbell for review.
2014-10-06 17:08:24 +02:00
Joshua Leung 76dd3db304 Move binary-search threshold used for FCurves to BKE_fcurve.h header
Since this is now pretty much the de-facto "minimum distance between keyframes",
we might as well expose this in this header so that other places which need similar
thresholds can perform similar checks (needed for my next commit)
2014-04-16 03:23:51 +12:00
Campbell Barton 1f58bfb8be Code cleanup: de-duplicate cotangent weight function & add arg sizes 2014-03-30 11:08:33 +11:00
Campbell Barton d900f5be55 Code cleanup: use bools where possible 2014-02-03 19:35:44 +11:00
Campbell Barton 70f2389f5a Code cleanup: be less vague checking invalid index values 2014-02-01 02:01:00 +11:00
Sergey Sharybin fe00175c35 Fix crash happening in Cycles fcurve modifier
Summary:
Crash was happening because of fcurve modifier stack
used modifier's DNA to store temporary data.

Now made it so storage for such a thing is being
allocated locally per object update so multiple objects
which shares the same animation wouldn't run into
threading conflict anymore.

This storage might be a part of EvaluationContext,
but that'd mean passing this context all over in
object_where_is which will clutter API for now without
actual benefit for this.

Optimization notes: storage is only being allocated
if there're Cycles modifier in the stack, so there're
no extra allocations happening in all other cases.

To make code a bit less cluttered with this storage
passing all over the place added extra callbacks to
the FModifier storage which runs evaluation with the
given storage.

Reviewers: brecht, campbellbarton, aligorith

CC: plasmasolutions

Differential Revision: https://developer.blender.org/D147
2014-01-01 22:32:48 +06:00
Campbell Barton ba01e5e3eb fix [#36919] Cannot delete keyframe of animated simulation parameter if simulation has been disabled 2013-10-02 16:37:47 +00:00
Campbell Barton f1f7648d4c fix for error setting vector handles to free when both vector handles were selected but not the mid-point.
only one of the handles would be changed to the HD_FREE.

effected curves and fcurves.
2013-10-01 08:18:43 +00:00
Campbell Barton 66f6ace938 fix for action editor view-selected behaving strangely.
- when an fcurve had no selected keyframes, a default fallback value was used which caused view-selected to include frame 1, even when no selected frames were there.

- the vertical axis was always reset, ideally we would center vertically too but the way this operator currently works we only know about the frame range,
  now don't change the vertical scroll when viewing selected since it would always jump to the top of the screen (view-all still acts this way).
2013-07-18 02:59:28 +00:00
Campbell Barton 09c41019a8 use const pointers for file loading and booleans for animation system return values passed as pointers. 2013-03-17 19:13:04 +00:00
Campbell Barton b77eccf801 patch [#33985] Added FModifierEnvelope control_point add remove to API
from Peter Staples (batfinger)
2013-01-31 08:19:11 +00:00
Joshua Leung 654f6c4c4f Bugfix [#32331] Graph editor zoom to selected includes coordinate origin if more
than one curve is displayed

The range calculation used to use a fixed 0-1 range whenever it couldn't find
any values for a particular F-Curve. However, this was then taken by the
aggregation calculation to be used as just another value, leading to problems if
only vertices of a very high-value curve are selected to be included.

Modified the range calculation to ensure that suitable vertices were found
before trying to take the range values returned.
2012-08-18 04:39:15 +00:00
Campbell Barton 0107385f7f code cleanup: ensure macros require ';' endings 2012-08-08 21:20:10 +00:00
Joshua Leung 240babf074 Graph Editor - View All/Selected now includes handles for calculating extents of
F-Curves

It is possible to get the old behaviour (handles excluded) by bringing up the
Operator Properties (F6) while in the Graph Editor (this doesn't work elsewhere
due to the context requirements of this stuff).
2012-05-24 13:52:25 +00:00
Campbell Barton 9892736206 code cleanup: header cleanup and remove some duplicate defines. 2012-05-12 20:39:39 +00:00
Campbell Barton ea13ec1699 Spelling Cleanup 2012-03-01 12:20:18 +00:00
Campbell Barton 2b7ca2304a unify include guard defines, __$FILENAME__
without the underscores these clogged up the namespace for autocompleation which was annoying.
2012-02-17 18:59:41 +00:00
Campbell Barton 4a04f72069 remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
Campbell Barton 5bbd0decfd fix [#28765] keyframe handles do not move with curves in graph editor when hidden, resulting in bad curves.
hide handles wasn't properly respected by transform function testhandles_fcurve().
2011-09-29 05:03:21 +00:00
Joerg Mueller bd6ca0570e 3D Audio GSoC:
Implemented basic audio animation.

* AnimatableProperty: Propper cache writing and spline interpolation for reading (the solution for stair steps in audio animation)
* Animatable properties so far are: volume, pitch, panning
* Users note: Changing the pitch of a sound results in wrong seeking, due to the resulting playback length difference.
* Users note: Panning only works for mono sources, values are in the range [-2..2], this basically controls the angle of the sound, 0 is front, -1 left, 1 right and 2 and -2 are back. Typical stereo panning only supports [-1..1].
* Disabled animation of audio related ffmpeg output parameters.
* Scene Audio Panel: 3D Listener settings also for Renderer, new Volume property (animatable!), Update/Bake buttons for animation problems, moved sampling rate and channel count here
2011-07-28 13:58:59 +00:00
Joshua Leung e3842d1ca4 Bugfix [#26505] zoom in selected keys on graph editor
Not really a "bug", but it was on my todo anyways. Based on patch
[#26508] by Campbell, with a few modifications including extending
this to the Action/DopeSheet editor too.
2011-03-17 10:02:37 +00:00
Nathan Letwory 22638e22ea doxygen: blenkernel under core as module. 2011-02-18 13:05:18 +00:00
Campbell Barton 263830f000 Enabled GCC -Wwrite-strings warning for CMake and replaced many 'char's for 'const char's,.
Only one functional change where Transform orientations passed "" to BIF_createTransformOrientation() which could then have the value written into.
2010-12-03 17:05:21 +00:00
Campbell Barton b45c3363fd fix for some pedantic warnings. 2010-12-03 01:52:28 +00:00
Joshua Leung f713761039 Keyframing Operators: Improved Error Messages
* Keyframing operators now use the reports system for displaying all its error messages. 
- The benefit of this is that users no longer need to check the console for error messages if keyframing fails.
- Unfortunately, reports are not currently viewable in any space/view in Blender, so...

* Added a temporary operator (UI_OT_reports_to_textblock), which can be accessed in the UI from the button which appears in place of the icon when more than one report exists. This dumps the current list of reports to a textblock "Recent Reports", from which they can be viewed. 

This isn't really nice, but at least we now have a way to view these again, which makes debugging some things a pain.

* Bugfix #24606 - when trying to add keyframes to F-Curves with F-Modifiers already which alter the curve significantly enough that the keyframes will have no effect, there are now warnings which aim to alleviate any confusion.
2010-11-17 12:02:36 +00:00
Nathan Letwory 82209cdc86 Reorganisation of COLLADA import code. Classes have been split into their own files.
No functional changes.

Where necessary extern "C" {} blocks have been added.
2010-10-05 00:05:14 +00:00
Campbell Barton adae794233 py/rna remove functions now all work in a similar way.
- some remove() functions took an int argument rather then the item to remove.
- disallow None argument.
- raise an error if the item isnt in the collection.
2010-08-24 06:40:28 +00:00
Campbell Barton 75410037fd - correct some spelling errors.
- remove FreeCamera struct (wasnt used)
- remove world color alpha values (not used anywhre).
2010-07-20 10:41:08 +00:00
Campbell Barton ee0a217be3 python function to remove drivers.
eg:
 bpy.context.object.driver_remove("location")

ANIM_remove_driver now accepts -1 as an index for removing all drivers from one path.
2010-04-11 09:13:37 +00:00
Joshua Leung 618b459e8b F-Modifier Goodies (as requested by @ndy):
* Copy/Paste operators for F-Modifiers
Available in Graph and NLA Editors. Use the Copy/Paste buttons beside the 'Add Modifier' buttons.

Copy copies all the modifiers of the ACTIVE F-Curve or Strip depending on the editor.
Paste pastes modifiers from the buffer to all the selected F-Curves or Strips, adding the new modifiers to the ends of each list.

* 'Stepped Interpolation' F-Modifier
This modifier holds each interpolated value from the F-Curve for several frames without changing the timing. 

This allows to preview motions 'on-twos' for example without altering the timing, or having to go through setting heaps of keyframes. In this case, Andy wanted to use this for CG <-> StopMo.
2010-03-18 13:04:46 +00:00
Campbell Barton 081c1205a3 correct fsf address 2010-02-12 13:34:04 +00:00
Brecht Van Lommel ec7df03c86 Warning fixes, one actual bug found in sequencer sound wave drawing. Also
changed some malloc to MEM_mallocN while trying to track down a memory leak.
2010-02-08 13:55:31 +00:00
Matt Ebb de56a63849 Fix [#20773] NODE ANIMATION: Animating node values broken
Now the compositing node tree will update on frame change if any of the 
nodes are animated.

This doesn't work for playback (i.e. alt a), that's better off waiting until we 
have some kind of frame caching system.
2010-01-27 05:42:17 +00:00
Joshua Leung a9861e3381 Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.

* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).

* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.

* Fix for Driver F-Curve colouring bug 
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.


Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever). 
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
Joshua Leung 5a3ac3ceeb Assorted F-Curve/Keyframe API stuff (for use with some Sequencer editing):
* Added function for F-Curves to find the F-Curves in a given list which affect some named data, such as bones, nodes, or sequence strips.

* Added a BezTriple offsetting callback to be used with the F-Curve+Keyframe loopers in use for many of the keyframe editing tools.
2009-12-22 10:14:13 +00:00
Campbell Barton 567ee32f14 - fcurve modifiers.new()/remove()/active
- renamed .add() to .new() for rna collection functions since they dont add an existing item.
- remove 'name' as an argument from the new driver target function, better to keep the api minimal and let scripters use the data api for editing values after.
- added some api functions to keep rna api from becoming a mess.
2009-11-16 11:11:16 +00:00
Campbell Barton c9d2186561 - sequencer speed effect back using fcurves, still needs manual reloading to refresh.
- added a function id_data_find_fcurve() to get the fcurve without RNA vars. Aligorith: this could be made to use a path rather then a property name.
2009-11-14 14:58:19 +00:00
Arystanbek Dyussenov 6c4388e3b0 - fixed enum syntax in BKE_fcurve.h and ED_keyframing.h to make g++ happy
- exporting addEditBone from armature module for COLLADA importer
2009-10-27 16:13:50 +00:00