~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to release/scripts/templates/driver_functions.py

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# This script defines functions to be used directly in drivers expressions to
2
 
# extend the builtin set of python functions.
3
 
#
4
 
# This can be executed on manually or set to 'Register' to
5
 
# initialize thefunctions on file load.
6
 
 
7
 
 
8
 
# two sample functions
9
 
def invert(f):
10
 
    """ Simple function call:
11
 
 
12
 
            invert(val)
13
 
    """
14
 
    return 1.0 - f
15
 
 
16
 
 
17
 
uuid_store = {}
18
 
 
19
 
 
20
 
def slow_value(value, fac, uuid):
21
 
    """ Delay the value by a factor, use a unique string to allow
22
 
        use in multiple drivers without conflict:
23
 
 
24
 
            slow_value(val, 0.5, "my_value")
25
 
    """
26
 
    value_prev = uuid_store.get(uuid, value)
27
 
    uuid_store[uuid] = value_new = (value_prev * fac) + (value * (1.0 - fac))
28
 
    return value_new
29
 
 
30
 
 
31
 
import bpy
32
 
 
33
 
# Add variable defined in this script into the drivers namespace.
34
 
bpy.app.driver_namespace["invert"] = invert
35
 
bpy.app.driver_namespace["slow_value"] = slow_value