Commit Graph

87 Commits

Author SHA1 Message Date
Campbell Barton
778542fd8f Cleanup: comments (long lines) in python 2019-04-29 20:01:10 +10:00
Campbell Barton
e12c08e8d1 ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.

For details on usage and instructions for migrating branches
without conflicts, see:

https://wiki.blender.org/wiki/Tools/ClangFormat
2019-04-17 06:21:24 +02:00
Campbell Barton
25ec4b437f Cleanup: style, use braces for the Python API 2019-03-30 07:14:28 +11:00
Brecht Van Lommel
6618a19fa9 Fix T62946: missing warning when Python driver expression execution is disabled. 2019-03-26 04:11:34 +01:00
Campbell Barton
de13d0a80c doxygen: add newline after \file
While \file doesn't need an argument, it can't have another doxy
command after it.
2019-02-18 08:22:12 +11:00
Campbell Barton
eef4077f18 Cleanup: remove redundant doxygen \file argument
Move \ingroup onto same line to be more compact and
make it clear the file is in the group.
2019-02-06 15:45:22 +11:00
Campbell Barton
afcbf7cf13 Cleanup: use G_FLAG_*/G_FILE_* for G.f/fileflags
Was confusing eg: G_AUTOPACK belonged to G.fileflags, G_PICKSEL to G.f.
2019-02-02 13:49:13 +11:00
Campbell Barton
65ec7ec524 Cleanup: remove redundant, invalid info from headers
BF-admins agree to remove header information that isn't useful,
to reduce noise.

- BEGIN/END license blocks

  Developers should add non license comments as separate comment blocks.
  No need for separator text.

- Contributors

  This is often invalid, outdated or misleading
  especially when splitting files.

  It's more useful to git-blame to find out who has developed the code.

See P901 for script to perform these edits.
2019-02-02 01:36:28 +11:00
Campbell Barton
1e4aab36c2 Cleanup: remove redundant BKE/BLI/BIF headers 2019-01-26 21:20:25 +11:00
Alexander Gavrilov
8c87e681a5 Fix driver expression bytecode validation crash if parsing fails.
Another NULL pointer access: nothing to validate if it already failed.
2018-09-16 10:46:28 +03:00
Alexander Gavrilov
9901679ce8 Fix a crash when a driver expression evaluates to NaN.
The debug logging statement was accessing a NULL pointer.
Also happens in 2.79.
2018-09-16 09:06:57 +03:00
Campbell Barton
0f449541d2 Merge branch 'master' into blender2.8 2018-08-01 09:01:29 +10:00
Campbell Barton
6a39d72558 Cleanup: declare vars or make static 2018-08-01 08:57:31 +10:00
Campbell Barton
4ac048f4e4 Merge branch 'master' into blender2.8 2018-07-06 19:34:41 +02:00
Campbell Barton
b94222b090 PyDrivers: update bytecode check for Python3.6 2018-07-06 19:31:00 +02:00
Campbell Barton
de4c81c153 Fix merge error in bpy_driver.c 2018-06-18 15:09:55 +02:00
Campbell Barton
05dc109553 Merge branch 'master' into blender2.8 2018-06-17 20:37:10 +02:00
Campbell Barton
2ceff8bd63 Python: Allow untrusted py-drivers to run limited expressions
Limit to a restricted set of built-ins, as well as the math module.
Also restrict of op-codes, disallowing imports and attribute access.

This allows most math expressions to run
without any performance cost once the initial check is done.

See: D1862 for details.
2018-06-17 20:01:05 +02:00
Brecht Van Lommel
3816502b7c Drivers: ensure Python expressions are cached with copy-on-write.
Store the compiled expressions on the original driver.

Ref T55442.
2018-06-11 21:34:21 +02:00
Campbell Barton
7719c11006 Cleanup: strip trailing space in Python module 2018-06-04 08:54:40 +02:00
Campbell Barton
a96c9def6f PyAPI: minor optimization for dictionary creation
Pass size when its known.
2016-07-31 17:22:04 +10:00
Campbell Barton
01d5d2853b Py-Driver: re-use self PyObject when its unchanged. 2016-07-31 11:46:36 +10:00
Campbell Barton
55f481d052 Py-Driver: use intern strings
Avoids managing strings inline
2016-07-31 11:46:36 +10: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
f5e020a7a6 PyAPI: fix memory leaks in dictionary assignment
Thanks to Kévin Dietrich for spotting driver leak,
checked other uses of PyDict_SetItem and found more.
2016-07-14 17:30:52 +10:00
Brecht Van Lommel
21fddf7d1c C99/C++11: replace deprecated finite() by isfinite(). 2016-05-17 21:39:16 +02:00
Campbell Barton
fc5a37b94e Recent pydriver update missed setting 'curval'
Using PyObject's for drivers (82b0a9e36) still needs to set the 'current value'
for debug info to display in the UI.

Resolves T48251
2016-04-25 15:27:51 +10: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
a21c6b5f59 Correct comments 2016-02-25 10:37:22 +11:00
Campbell Barton
24d2e46296 Add missing newlines for debug prints 2015-11-16 15:19:30 +11:00
Campbell Barton
7d040d2a08 Cleanup: use BLI_listbase_*** prefix for count,sort,sort_r 2014-11-16 13:57:58 +01:00
Campbell Barton
5e3509e2d2 Remove redundant NULL check 2014-05-07 14:14:27 +10:00
Campbell Barton
4dd7d4110a replace macro PYC_INTERPRETER_ACTIVE for PyC_IsInterpreterActive() function call,
(indirectly referenced Python define of ~30 lines, most were optimized out but still caused some code bloat).
2013-09-18 23:21:24 +00:00
Campbell Barton
fa51f02be3 minor changes to the script auto-execution based on Brecht's suggestions. 2013-06-12 00:10:56 +00:00
Campbell Barton
412c043474 Python script auto-execution changes:
- script execution is off by default

- if a blend file attempts to execute a script
  this shows a message in the header with the action
  that was suppressed (script/driver/game-autostart) and 2 buttons to either reload the file trusted, or to ignore the message.

- the file selector will always default to use the trust setting in the user preferences,
  but reloading an open file will keep using the current setting (whatever was set before or set on the command-line).

- added SCons setting WITH_BF_PYTHON_SECURITY, this sets the default state for the user prefereces not to trust blend files on load.
  ... this option was in CMake before, but always off, now its enabled by default for SCons and CMake, and forced on in CMake for now.
2013-06-10 00:42:16 +00:00
Campbell Barton
16b82845ee code cleanup: add 'const' to headers to quiet msvc warnings, also remove (char *) casts that aren't needed now we're on Python3.3 2013-03-17 18:30:31 +00:00
Campbell Barton
1bf5832dfb code cleanup: warnings and use stdbool for bpy* funcs. 2013-01-07 05:26:12 +00:00
Campbell Barton
da9394f596 code cleanup: define sizes of vectors for function args and use C style comments 2012-10-15 09:11:17 +00:00
Campbell Barton
af3e348430 code cleanup: use TRUE/FALSE rather then 1/0 for better readability, also replace do prefix with do_ for bool vars. 2012-05-19 13:28:19 +00:00
Campbell Barton
4f19c1a995 spelling cleanup 2012-03-18 07:38:51 +00:00
Campbell Barton
e17fd46c71 formatting edits only to use more consisted style 2011-12-26 12:26:11 +00:00
Campbell Barton
cad9cb563d fix own error [#29631] frame is lost from driver namespace after reload 2011-12-16 03:06:56 +00:00
Campbell Barton
6f7ae034fd fix for noise module in driver namespace (was infact mathutils). 2011-12-07 00:36:57 +00:00
Campbell Barton
f95d7c9e66 patch [#29421] Python Noise Module Updates
from Andrew Hale (trumanblending)

Tracker description
*******************

The current python noise module included with Blender has yet to be updated to the new Py API. This patch does so, with the following major points:

- The noise module has now been moved to a submodule of mathutils, it can be accessed by mathutils.noise. It was moved from it's own module as it will now return mathutils types and also have greater visibility to the user.
- All functions which return vectors will now return mathutils.Vector types to be consistent with the rest of the API. Previously (x, y, z) tuples were returned.
- A different implementation of random_unit_vector is now used, this allows 2D, 3D and 4D vectors to be returned. Previously only 3D was possible.
- Some function names have been changed to remove ambiguities and make naming consistent within the module. noise.vector is now noise.noise_vector and noise.vl_vector is now noise.variable_lacunarity
- Doc strings have been updated to be compatible with auto docs.
- Code style and internal naming has been changed to match the conventions in other mathutils code.

Thanks,
Andrew
2011-11-29 10:28:52 +00:00
Campbell Barton
db44a92a11 pydrivers: 'frame' is now in the driver namespace,
- no need to link to scenes when using a frame from the pydriver, this made linking rigs for eg, quite messy.
- advantage that we get subframe values (where scenes from was fixed to a whole number).
2011-11-17 07:08:09 +00:00
Campbell Barton
e5647ea196 py operators - don't use the screen as an operators ID anymore, screen's don't store operator instances and operator functions have access to the context if they need the current screen.
also add some more py api file descriptions.
2011-11-05 08:40:07 +00:00
Campbell Barton
2b939904ab documentation - brief descriptions for bpy api files. 2011-11-05 08:21:12 +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
276e5f7095 formatting edits & remove debug print. 2011-10-13 01:29:08 +00:00
Campbell Barton
9d13224e1a fix [#28807] Drivers breaking by undo 2011-10-05 07:28:59 +00:00