Added Action.fcurves.find(data_path, array_index=0)
authorSybren A. Stüvel <sybren@stuvel.eu>
Tue, 21 Jul 2015 14:01:26 +0000 (16:01 +0200)
committerSybren A. Stüvel <sybren@stuvel.eu>
Tue, 21 Jul 2015 14:01:26 +0000 (16:01 +0200)
commit89e5c756665c1e7e622ddbd5deece0dda4ce7724
tree4d9f772983c7a4aa7fe06859b51be0b147b08f35
parente7fc8d98f5eb28d26d9a2a6be816dc5e57a1d678
Added Action.fcurves.find(data_path, array_index=0)

Finding a specific F-Curve is often needed in Python, and usually
consists of a construct like:

```
 [fcurve
  for fcurve in ob.animation_data.action.fcurves
  if fcurve.data_path == "location"][1]
```

This can now be written as
`ob.animation_data.action.fcurves.find('location', 1)`

This new function `Action.fcurves.find()` is still O(N) in the number
of FCurves in the Action, but at least it allows us to remove
boiler-plate code. It is also faster than the Python equivalent, as
only the found F-Curve is converted to Python.

Reviewers: campbellbarton, aligorith

Reviewed By: aligorith

Differential Revision: https://developer.blender.org/D1427
source/blender/makesrna/intern/rna_action.c