| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright 2011, Blender Foundation. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							|  |  |  |  * of the License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							|  |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "background.h"
 | 
					
						
							|  |  |  | #include "film.h"
 | 
					
						
							| 
									
										
										
										
											2011-08-28 13:55:59 +00:00
										 |  |  | #include "../render/filter.h"
 | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | #include "graph.h"
 | 
					
						
							|  |  |  | #include "integrator.h"
 | 
					
						
							|  |  |  | #include "light.h"
 | 
					
						
							|  |  |  | #include "mesh.h"
 | 
					
						
							|  |  |  | #include "nodes.h"
 | 
					
						
							|  |  |  | #include "object.h"
 | 
					
						
							|  |  |  | #include "scene.h"
 | 
					
						
							|  |  |  | #include "shader.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "device.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "blender_sync.h"
 | 
					
						
							|  |  |  | #include "blender_util.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "util_debug.h"
 | 
					
						
							|  |  |  | #include "util_foreach.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CCL_NAMESPACE_BEGIN | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Constructor */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | BlenderSync::BlenderSync(BL::BlendData b_data_, BL::Scene b_scene_, Scene *scene_, bool preview_) | 
					
						
							|  |  |  | : b_data(b_data_), b_scene(b_scene_), | 
					
						
							|  |  |  |   shader_map(&scene_->shaders), | 
					
						
							|  |  |  |   object_map(&scene_->objects), | 
					
						
							|  |  |  |   mesh_map(&scene_->meshes), | 
					
						
							|  |  |  |   light_map(&scene_->lights), | 
					
						
							|  |  |  |   world_map(NULL), | 
					
						
							| 
									
										
										
										
											2011-12-01 16:33:21 +00:00
										 |  |  |   world_recalc(false), | 
					
						
							| 
									
										
										
										
											2012-02-28 16:44:45 +00:00
										 |  |  |   experimental(false) | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	scene = scene_; | 
					
						
							|  |  |  | 	preview = preview_; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | BlenderSync::~BlenderSync() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Sync */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool BlenderSync::sync_recalc() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-08-11 16:48:13 +00:00
										 |  |  | 	/* sync recalc flags from blender to cycles. actual update is done separate,
 | 
					
						
							|  |  |  | 	   so we can do it later on if doing it immediate is not suitable */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 	BL::BlendData::materials_iterator b_mat; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-21 10:32:15 +00:00
										 |  |  | 	for(b_data.materials.begin(b_mat); b_mat != b_data.materials.end(); ++b_mat) | 
					
						
							| 
									
										
										
										
											2012-01-02 19:44:07 +00:00
										 |  |  | 		if(b_mat->is_updated() || (b_mat->node_tree() && b_mat->node_tree().is_updated())) | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 			shader_map.set_recalc(*b_mat); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	BL::BlendData::lamps_iterator b_lamp; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-21 10:32:15 +00:00
										 |  |  | 	for(b_data.lamps.begin(b_lamp); b_lamp != b_data.lamps.end(); ++b_lamp) | 
					
						
							| 
									
										
										
										
											2012-01-02 19:44:07 +00:00
										 |  |  | 		if(b_lamp->is_updated() || (b_lamp->node_tree() && b_lamp->node_tree().is_updated())) | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 			shader_map.set_recalc(*b_lamp); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	BL::BlendData::objects_iterator b_ob; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-21 10:32:15 +00:00
										 |  |  | 	for(b_data.objects.begin(b_ob); b_ob != b_data.objects.end(); ++b_ob) { | 
					
						
							| 
									
										
										
										
											2011-11-03 10:18:58 +00:00
										 |  |  | 		if(b_ob->is_updated()) { | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 			object_map.set_recalc(*b_ob); | 
					
						
							|  |  |  | 			light_map.set_recalc(*b_ob); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2011-09-27 20:37:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 		if(object_is_mesh(*b_ob)) { | 
					
						
							| 
									
										
										
										
											2011-11-03 10:18:58 +00:00
										 |  |  | 			if(b_ob->is_updated_data() || b_ob->data().is_updated()) { | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 				BL::ID key = object_is_modified(*b_ob)? *b_ob: b_ob->data(); | 
					
						
							|  |  |  | 				mesh_map.set_recalc(key); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2011-09-27 20:37:24 +00:00
										 |  |  | 		else if(object_is_light(*b_ob)) { | 
					
						
							| 
									
										
										
										
											2011-11-03 10:18:58 +00:00
										 |  |  | 			if(b_ob->is_updated_data() || b_ob->data().is_updated()) | 
					
						
							| 
									
										
										
										
											2011-09-27 20:37:24 +00:00
										 |  |  | 				light_map.set_recalc(*b_ob); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	BL::BlendData::meshes_iterator b_mesh; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-21 10:32:15 +00:00
										 |  |  | 	for(b_data.meshes.begin(b_mesh); b_mesh != b_data.meshes.end(); ++b_mesh) | 
					
						
							| 
									
										
										
										
											2011-11-03 10:18:58 +00:00
										 |  |  | 		if(b_mesh->is_updated()) | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 			mesh_map.set_recalc(*b_mesh); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	BL::BlendData::worlds_iterator b_world; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-21 10:32:15 +00:00
										 |  |  | 	for(b_data.worlds.begin(b_world); b_world != b_data.worlds.end(); ++b_world) | 
					
						
							| 
									
										
										
										
											2012-01-02 19:44:07 +00:00
										 |  |  | 		if(world_map == b_world->ptr.data && | 
					
						
							|  |  |  | 			(b_world->is_updated() || (b_world->node_tree() && b_world->node_tree().is_updated()))) | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 			world_recalc = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	bool recalc = | 
					
						
							|  |  |  | 		shader_map.has_recalc() || | 
					
						
							|  |  |  | 		object_map.has_recalc() || | 
					
						
							|  |  |  | 		light_map.has_recalc() || | 
					
						
							|  |  |  | 		mesh_map.has_recalc() || | 
					
						
							| 
									
										
										
										
											2011-11-03 10:18:58 +00:00
										 |  |  | 		BlendDataObjects_is_updated_get(&b_data.ptr) || | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 		world_recalc; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return recalc; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-07 20:51:33 +00:00
										 |  |  | void BlenderSync::sync_data(BL::SpaceView3D b_v3d, const char *layer) | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-02-28 16:44:45 +00:00
										 |  |  | 	sync_render_layers(b_v3d, layer); | 
					
						
							|  |  |  | 	sync_integrator(); | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 	sync_film(); | 
					
						
							|  |  |  | 	sync_shaders(); | 
					
						
							|  |  |  | 	sync_objects(b_v3d); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Integrator */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-28 16:44:45 +00:00
										 |  |  | void BlenderSync::sync_integrator() | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-01 16:33:21 +00:00
										 |  |  | 	experimental = (RNA_enum_get(&cscene, "feature_set") != 0); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 	Integrator *integrator = scene->integrator; | 
					
						
							|  |  |  | 	Integrator previntegrator = *integrator; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-01 15:53:36 +00:00
										 |  |  | 	integrator->min_bounce = get_int(cscene, "min_bounces"); | 
					
						
							|  |  |  | 	integrator->max_bounce = get_int(cscene, "max_bounces"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	integrator->max_diffuse_bounce = get_int(cscene, "diffuse_bounces"); | 
					
						
							|  |  |  | 	integrator->max_glossy_bounce = get_int(cscene, "glossy_bounces"); | 
					
						
							|  |  |  | 	integrator->max_transmission_bounce = get_int(cscene, "transmission_bounces"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	integrator->transparent_max_bounce = get_int(cscene, "transparent_max_bounces"); | 
					
						
							|  |  |  | 	integrator->transparent_min_bounce = get_int(cscene, "transparent_min_bounces"); | 
					
						
							| 
									
										
										
										
											2011-10-16 17:54:43 +00:00
										 |  |  | 	integrator->transparent_shadows = get_boolean(cscene, "use_transparent_shadows"); | 
					
						
							| 
									
										
										
										
											2011-09-01 15:53:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 	integrator->no_caustics = get_boolean(cscene, "no_caustics"); | 
					
						
							| 
									
										
										
										
											2011-10-29 14:27:24 +00:00
										 |  |  | 	integrator->seed = get_int(cscene, "seed"); | 
					
						
							| 
									
										
										
										
											2012-02-07 20:51:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-28 16:44:45 +00:00
										 |  |  | 	integrator->layer_flag = render_layer.layer; | 
					
						
							| 
									
										
										
										
											2011-10-29 14:27:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-05 15:17:45 +00:00
										 |  |  | 	integrator->sample_clamp = get_float(cscene, "sample_clamp"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 	if(integrator->modified(previntegrator)) | 
					
						
							|  |  |  | 		integrator->tag_update(scene); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Film */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void BlenderSync::sync_film() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Film *film = scene->film; | 
					
						
							|  |  |  | 	Film prevfilm = *film; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-01 15:53:36 +00:00
										 |  |  | 	film->exposure = get_float(cscene, "film_exposure"); | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if(film->modified(prevfilm)) | 
					
						
							|  |  |  | 		film->tag_update(scene); | 
					
						
							| 
									
										
										
										
											2011-08-28 13:55:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	Filter *filter = scene->filter; | 
					
						
							|  |  |  | 	Filter prevfilter = *filter; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	filter->filter_type = (FilterType)RNA_enum_get(&cscene, "filter_type"); | 
					
						
							|  |  |  | 	filter->filter_width = (filter->filter_type == FILTER_BOX)? 1.0f: get_float(cscene, "filter_width"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if(filter->modified(prevfilter)) | 
					
						
							|  |  |  | 		filter->tag_update(scene); | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-12 13:13:56 +00:00
										 |  |  | /* Render Layer */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-28 16:44:45 +00:00
										 |  |  | void BlenderSync::sync_render_layers(BL::SpaceView3D b_v3d, const char *layer) | 
					
						
							| 
									
										
										
										
											2011-09-12 13:13:56 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-28 09:07:35 +00:00
										 |  |  | 	string layername; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* 3d view */ | 
					
						
							| 
									
										
										
										
											2011-09-12 13:13:56 +00:00
										 |  |  | 	if(b_v3d) { | 
					
						
							| 
									
										
										
										
											2012-03-28 09:07:35 +00:00
										 |  |  | 		PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if(RNA_boolean_get(&cscene, "preview_active_layer")) { | 
					
						
							|  |  |  | 			BL::RenderLayers layers(b_scene.render().ptr); | 
					
						
							|  |  |  | 			layername = layers.active().name(); | 
					
						
							|  |  |  | 			layer = layername.c_str(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			render_layer.scene_layer = get_layer(b_v3d.layers()); | 
					
						
							|  |  |  | 			render_layer.layer = render_layer.scene_layer; | 
					
						
							|  |  |  | 			render_layer.holdout_layer = 0; | 
					
						
							|  |  |  | 			render_layer.material_override = PointerRNA_NULL; | 
					
						
							|  |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2011-09-12 13:13:56 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-12-21 20:51:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-28 09:07:35 +00:00
										 |  |  | 	/* render layer */ | 
					
						
							|  |  |  | 	BL::RenderSettings r = b_scene.render(); | 
					
						
							|  |  |  | 	BL::RenderSettings::layers_iterator b_rlay; | 
					
						
							|  |  |  | 	bool first_layer = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for(r.layers.begin(b_rlay); b_rlay != r.layers.end(); ++b_rlay) { | 
					
						
							|  |  |  | 		if((!layer && first_layer) || (layer && b_rlay->name() == layer)) { | 
					
						
							|  |  |  | 			render_layer.name = b_rlay->name(); | 
					
						
							|  |  |  | 			render_layer.scene_layer = get_layer(b_scene.layers()); | 
					
						
							|  |  |  | 			render_layer.layer = get_layer(b_rlay->layers()); | 
					
						
							|  |  |  | 			render_layer.holdout_layer = get_layer(b_rlay->layers_zmask()); | 
					
						
							|  |  |  | 			render_layer.layer |= render_layer.holdout_layer; | 
					
						
							|  |  |  | 			render_layer.material_override = b_rlay->material_override(); | 
					
						
							| 
									
										
										
										
											2011-09-12 13:13:56 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-03-28 09:07:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		first_layer = false; | 
					
						
							| 
									
										
										
										
											2011-09-12 13:13:56 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | /* Scene Parameters */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-04 15:46:15 +00:00
										 |  |  | SceneParams BlenderSync::get_scene_params(BL::Scene b_scene, bool background) | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	SceneParams params; | 
					
						
							|  |  |  | 	PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); | 
					
						
							|  |  |  | 	int shadingsystem = RNA_enum_get(&cscene, "shading_system"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if(shadingsystem == 0) | 
					
						
							|  |  |  | 		params.shadingsystem = SceneParams::SVM; | 
					
						
							|  |  |  | 	else if(shadingsystem == 1) | 
					
						
							|  |  |  | 		params.shadingsystem = SceneParams::OSL; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2011-11-04 15:46:15 +00:00
										 |  |  | 	if(background) | 
					
						
							|  |  |  | 		params.bvh_type = SceneParams::BVH_STATIC; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		params.bvh_type = (SceneParams::BVHType)RNA_enum_get(&cscene, "debug_bvh_type"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 	params.use_bvh_spatial_split = RNA_boolean_get(&cscene, "debug_use_spatial_splits"); | 
					
						
							| 
									
										
										
										
											2012-01-16 13:13:37 +00:00
										 |  |  | 	params.use_bvh_cache = (background)? RNA_boolean_get(&cscene, "use_cache"): false; | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return params; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Session Parameters */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-29 16:54:13 +00:00
										 |  |  | bool BlenderSync::get_session_pause(BL::Scene b_scene, bool background) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); | 
					
						
							|  |  |  | 	return (background)? false: get_boolean(cscene, "preview_pause"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-09 16:58:01 +00:00
										 |  |  | SessionParams BlenderSync::get_session_params(BL::UserPreferences b_userpref, BL::Scene b_scene, bool background) | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	SessionParams params; | 
					
						
							|  |  |  | 	PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-01 16:33:21 +00:00
										 |  |  | 	/* feature set */ | 
					
						
							| 
									
										
										
										
											2011-12-12 22:51:35 +00:00
										 |  |  | 	params.experimental = (RNA_enum_get(&cscene, "feature_set") != 0); | 
					
						
							| 
									
										
										
										
											2011-12-01 16:33:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 	/* device type */ | 
					
						
							| 
									
										
										
										
											2012-01-09 16:58:01 +00:00
										 |  |  | 	vector<DeviceInfo>& devices = Device::available_devices(); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* device default CPU */ | 
					
						
							|  |  |  | 	params.device = devices[0]; | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-01 19:43:57 +00:00
										 |  |  | 	if(RNA_enum_get(&cscene, "device") != 0) { | 
					
						
							| 
									
										
										
										
											2012-01-09 16:58:01 +00:00
										 |  |  | 		/* find GPU device with given id */ | 
					
						
							|  |  |  | 		PointerRNA systemptr = b_userpref.system().ptr; | 
					
						
							|  |  |  | 		PropertyRNA *deviceprop = RNA_struct_find_property(&systemptr, "compute_device"); | 
					
						
							|  |  |  | 		int device_id = b_userpref.system().compute_device(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		const char *id; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if(RNA_property_enum_identifier(NULL, &systemptr, deviceprop, device_id, &id)) { | 
					
						
							|  |  |  | 			foreach(DeviceInfo& info, devices) | 
					
						
							|  |  |  | 				if(info.id == id) | 
					
						
							|  |  |  | 					params.device = info; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2011-09-01 19:43:57 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-01-04 18:06:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-28 13:55:59 +00:00
										 |  |  | 	/* Background */ | 
					
						
							|  |  |  | 	params.background = background; | 
					
						
							|  |  |  | 			 | 
					
						
							| 
									
										
										
										
											2011-09-16 13:14:02 +00:00
										 |  |  | 	/* samples */ | 
					
						
							| 
									
										
										
										
											2011-08-28 13:55:59 +00:00
										 |  |  | 	if(background) { | 
					
						
							| 
									
										
										
										
											2011-09-16 13:14:02 +00:00
										 |  |  | 		params.samples = get_int(cscene, "samples"); | 
					
						
							| 
									
										
										
										
											2011-08-28 13:55:59 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2011-09-16 13:14:02 +00:00
										 |  |  | 		params.samples = get_int(cscene, "preview_samples"); | 
					
						
							|  |  |  | 		if(params.samples == 0) | 
					
						
							|  |  |  | 			params.samples = INT_MAX; | 
					
						
							| 
									
										
										
										
											2011-08-28 13:55:59 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* other parameters */ | 
					
						
							| 
									
										
										
										
											2011-08-24 10:44:04 +00:00
										 |  |  | 	params.threads = b_scene.render().threads(); | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 	params.tile_size = get_int(cscene, "debug_tile_size"); | 
					
						
							|  |  |  | 	params.min_size = get_int(cscene, "debug_min_size"); | 
					
						
							|  |  |  | 	params.cancel_timeout = get_float(cscene, "debug_cancel_timeout"); | 
					
						
							|  |  |  | 	params.reset_timeout = get_float(cscene, "debug_reset_timeout"); | 
					
						
							|  |  |  | 	params.text_timeout = get_float(cscene, "debug_text_timeout"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if(background) { | 
					
						
							|  |  |  | 		params.progressive = true; | 
					
						
							|  |  |  | 		params.min_size = INT_MAX; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		params.progressive = true; | 
					
						
							| 
									
										
										
										
											2012-01-09 16:58:01 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	/* todo: multi device only works with single tiles now */ | 
					
						
							|  |  |  | 	if(params.device.type == DEVICE_MULTI) | 
					
						
							|  |  |  | 		params.tile_size = INT_MAX; | 
					
						
							| 
									
										
										
										
											2011-04-27 11:58:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return params; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CCL_NAMESPACE_END | 
					
						
							|  |  |  | 
 |