Cycles: Fallback to bottom-top tile order when rendering from the command line
[blender-staging.git] / intern / cycles / blender / addon / engine.py
1 #
2 # Copyright 2011-2013 Blender Foundation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16
17 # <pep8 compliant>
18
19
20 def init():
21     import bpy
22     import _cycles
23     import os.path
24
25     path = os.path.dirname(__file__)
26     user_path = os.path.dirname(os.path.abspath(bpy.utils.user_resource('CONFIG', '')))
27
28     _cycles.init(path, user_path)
29
30
31 def create(engine, data, scene, region=None, v3d=None, rv3d=None, preview_osl=False, background=False):
32     import bpy
33     import _cycles
34
35     data = data.as_pointer()
36     userpref = bpy.context.user_preferences.as_pointer()
37     scene = scene.as_pointer()
38     if region:
39         region = region.as_pointer()
40     if v3d:
41         v3d = v3d.as_pointer()
42     if rv3d:
43         rv3d = rv3d.as_pointer()
44
45     engine.session = _cycles.create(engine.as_pointer(), userpref, data, scene, region, v3d, rv3d, preview_osl, background)
46
47
48 def free(engine):
49     if hasattr(engine, "session"):
50         if engine.session:
51             import _cycles
52             _cycles.free(engine.session)
53         del engine.session
54
55
56 def render(engine):
57     import _cycles
58     if hasattr(engine, "session"):
59         _cycles.render(engine.session)
60
61
62 def bake(engine, obj, pass_type, pixel_array, num_pixels, depth, result):
63     import _cycles
64     session = getattr(engine, "session", None)
65     if session is not None:
66         _cycles.bake(engine.session, obj.as_pointer(), pass_type, pixel_array.as_pointer(), num_pixels, depth, result.as_pointer())
67
68
69 def reset(engine, data, scene):
70     import _cycles
71     data = data.as_pointer()
72     scene = scene.as_pointer()
73     _cycles.reset(engine.session, data, scene)
74
75
76 def update(engine, data, scene):
77     import _cycles
78     _cycles.sync(engine.session)
79
80
81 def draw(engine, region, v3d, rv3d):
82     import _cycles
83     v3d = v3d.as_pointer()
84     rv3d = rv3d.as_pointer()
85
86     # draw render image
87     _cycles.draw(engine.session, v3d, rv3d)
88
89
90 def available_devices():
91     import _cycles
92     return _cycles.available_devices()
93
94
95 def with_osl():
96     import _cycles
97     return _cycles.with_osl
98
99
100 def with_network():
101     import _cycles
102     return _cycles.with_network
103
104
105 def system_info():
106     import _cycles
107     return _cycles.system_info()