Freestyle integration into Blender

October 26, 2009

Weekly update October 13-25

Filed under: Update — The dev team @ 7:46 AM

In the last 2 weeks, we fixed a few showstopper bugs found during the last minute of full Freestyle integration into Blender 2.5. Now the Freestyle branch should compile and run without a hitch.

In the meantime, the dev team was working on SVGWriter as a pilot investigation of the new RNA API in Blender 2.5. This made us aware of an API design issue in the branch concerning the notion of context. In Blender 2.5, a context refers to a target object to which a certain operation is applied. For example, rendering is an operation, and a scene and associated objects/data used in the scene comprise the context of the rendering operation. The problem is that as of this writing, Freestyle does not have a mechanism that allows style modules to access the context.

Contexts do not matter if you have only one scene in a .blend file, since all data is basically associated with the scene, and it is obvious which scene is the target of the rendering operation. When we have multiple scenes, however, we need a way to know which scene is the target. Try to open a new Blender window (Ctrl Alt w) and add a new scene (by pressing the “+” button next to the current scene name on top of a Blender window). Now you have 2 scenes being manipulated in 2 separate windows at the same time. You can start rendering with respect to each scene by hitting the render button in the corresponding window. Clearly, it does matter to know which scene should be rendered.

Note that the context issue is new in Blender 2.5. Before that, Blender was able to manipulate only one scene, since Blender did not have multiple main windows. That is why there was the notion of the current (active) scene, which can be retrieved by Blender.Scene.GetCurrent() in Python. In 2.5, this API function is no longer available.

As a temporary workaround, SVGWriter always refers to bpy.data.scenes[0] to get the first scene in the list of available scenes in a .blend file. This means that even if you have multiple scenes, the rest of the scenes never get rendered.

It is likely that the Freestyle Python API needs to be revised in the manner that style definitions are placed either in a method or in a function (instead of the module body) and a context is passed as an argument of the method/function. We are going to work on this in the next weeks.

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: