Dev:Ref/Release Notes/2.61/Python
目次
Blender 2.61: Python
Changes up to revision 42577. Before editing or adding items, please read the guidelines for editing the changelogs.
Render Engine API
- update_progress() function to update progress bar progress from external render engines. - r41201
- .is_animation and .is_preview properties to detect if it's an animation or preview render that is being done. - r41463
- RenderEngine is now a persistent python object that exists and retains properties as long as a frame is being rendered. This is mostly useful now that more than one callback will be added. - r41465
- update() callback that should ideally be used to export the scene, leaving only the rendering to the render() callback. This is not required to be used at this point, but separating this will make things more thread safe later on. - r41465
- Viewport rendering: - r41473
- view_draw() callback will do OpenGL drawing instead of the viewport.
- view_update() callback is called after depsgraph updates.
- tag_redraw() and tag_update() functions.
Render Engine API documentation
Persistent Callbacks
Ability to make callbacks persistent when new .blend files are loaded. - r41485, r41487
Example:
import bpy
from bpy.app.handlers import persistent
@persistent
def my_func(scene):
pass
bpy.app.handlers.frame_change_pre.append(my_func)
Detecting Scene Updates
Functionality was added to detect when the scene changes, for example for external render engines that want to do interactive rendering.
- Adds two new python handlers: scene_update_pre() and scene_update_post() These run before and after Blender does a scene update on making modifications to the scene. - r41476
- Datablocks now have an is_updated property. This will be set to true in the above callbacks if the datablock was tagged to be updated. This works for the most common datablocks used for rendering: object, material, world, lamps, texture, mesh, curve. - r41476
- Datablock collections also have an is_updated property. If this is set, it means one datablock of this type was added, removed or modified. It's also useful as a quick check to avoid looping over all datablocks. - r41476
- RenderEngine.view_update() can also check these properties, for interactive viewport rendering. - r41476
- Fix missing update after making modifications in frame_change_pre.
Operator Presets
Operator presets now work in the 3D view, file selector and non-redo popups. - r41669, r41714
To enable for an operator:
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
Library Datablocks
Optional collection subscript to contain the datablock library or None. - r41946, r42368
bpy.data.objects["Mesh", "/subsurf_test.blend"]
bpy.data.scenes["Scene", None]
# also works with get()
bpy.data.armatures.get(("some_armature", "//some_lib.blend"), None)
# and with contains test
if ("Cube", "//lib.blend") in bpy.data.objects:
pass
Noise Module
Noise module updated to new python API. - r42248
- The noise module has now been moved to a submodule of mathutils, it can be accessed by mathutils.noise.
- All functions which return vectors will now return mathutils.Vector types.
- Different implementation of random_unit_vector is now used, to support 2D/3D/4D vectors instead of only 3D.
- Naming: noise.vector is now noise.noise_vector and noise.vl_vector is now noise.variable_lacunarity
- API documentation updated.
Other
- Edit Source option when right clicking on buttons is now available in the release. This will open the python source file that controls the user interface at the line where the button is created. - r41210
- List template: ability to add some controls for each list element - r41338
- event.unicode so scripts can get unicode text input - r41215
- Quaternion.to_axis_angle() added - r41460
- mathutils.geometry.distance_point_to_plane(pt, plane_co, plane_no) - r41767
- Include invalid type name in mathutils error messages. - r41774
- Expose 3D view camera zoom and offset, needed if you want to precisely reconstruct camera parameters. - r41625
- Rename SpaceFileBrowser.operator to active_operator. - r41625
- Added context member 'active_operator' - r41669
- Mesh.validate extended to remove invalid custom data layers - r41281
- Mesh.validate() improved to handle invalid vertex groups, NaN values, zero normals r42528, r42324
- ID property support for raw byte strings (non-null terminated) - r41861
- Functions for adding int/float/string properties on mesh faces r41876
- scene.render.layers.new()/remove() functions added - r41957
- bgpic.add() renamed to new(), remove() added - r41965
- mathutils.geometry.intersect_plane_plane added - r42000
- clear() method added for most collections that support new()/remove() - r42091