/* * Copyright 2011-2013 Blender Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __SCENE_H__ #define __SCENE_H__ #include "image.h" #include "shader.h" #include "device_memory.h" #include "util_param.h" #include "util_string.h" #include "util_system.h" #include "util_texture.h" #include "util_thread.h" #include "util_types.h" #include "util_vector.h" CCL_NAMESPACE_BEGIN class AttributeRequestSet; class Background; class Camera; class Device; class DeviceInfo; class Film; class Integrator; class Light; class LightManager; class LookupTables; class Mesh; class MeshManager; class Object; class ObjectManager; class ParticleSystemManager; class ParticleSystem; class CurveSystemManager; class Shader; class ShaderManager; class Progress; class BakeManager; class BakeData; /* Scene Device Data */ class DeviceScene { public: /* BVH */ device_vector bvh_nodes; device_vector bvh_leaf_nodes; device_vector object_node; device_vector prim_tri_index; device_vector prim_tri_verts; device_vector prim_type; device_vector prim_visibility; device_vector prim_index; device_vector prim_object; /* mesh */ device_vector tri_shader; device_vector tri_vnormal; device_vector tri_vindex; device_vector curves; device_vector curve_keys; /* objects */ device_vector objects; device_vector objects_vector; /* attributes */ device_vector attributes_map; device_vector attributes_float; device_vector attributes_float3; device_vector attributes_uchar4; /* lights */ device_vector light_distribution; device_vector light_data; device_vector light_background_marginal_cdf; device_vector light_background_conditional_cdf; /* particles */ device_vector particles; /* shaders */ device_vector svm_nodes; device_vector shader_flag; device_vector object_flag; /* lookup tables */ device_vector lookup_table; /* integrator */ device_vector sobol_directions; /* cpu images */ device_vector tex_byte4_image[TEX_NUM_BYTE4_CPU]; device_vector tex_float4_image[TEX_NUM_FLOAT4_CPU]; device_vector tex_float_image[TEX_NUM_FLOAT_CPU]; device_vector tex_byte_image[TEX_NUM_BYTE_CPU]; device_vector tex_half4_image[TEX_NUM_HALF4_CPU]; device_vector tex_half_image[TEX_NUM_HALF_CPU]; /* opencl images */ device_vector tex_image_byte4_packed; device_vector tex_image_float4_packed; device_vector tex_image_packed_info; KernelData data; }; /* Scene Parameters */ class SceneParams { public: ShadingSystem shadingsystem; enum BVHType { BVH_DYNAMIC = 0, BVH_STATIC = 1, BVH_NUM_TYPES, } bvh_type; bool use_bvh_spatial_split; bool use_bvh_unaligned_nodes; bool use_qbvh; bool persistent_data; SceneParams() { shadingsystem = SHADINGSYSTEM_SVM; bvh_type = BVH_DYNAMIC; use_bvh_spatial_split = false; use_bvh_unaligned_nodes = true; use_qbvh = false; persistent_data = false; } bool modified(const SceneParams& params) { return !(shadingsystem == params.shadingsystem && bvh_type == params.bvh_type && use_bvh_spatial_split == params.use_bvh_spatial_split && use_bvh_unaligned_nodes == params.use_bvh_unaligned_nodes && use_qbvh == params.use_qbvh && persistent_data == params.persistent_data); } }; /* Scene */ class Scene { public: /* data */ Camera *camera; LookupTables *lookup_tables; Film *film; Background *background; Integrator *integrator; /* data lists */ vector objects; vector meshes; vector shaders; vector lights; vector particle_systems; /* data managers */ ImageManager *image_manager; LightManager *light_manager; ShaderManager *shader_manager; MeshManager *mesh_manager; ObjectManager *object_manager; ParticleSystemManager *particle_system_manager; CurveSystemManager *curve_system_manager; BakeManager *bake_manager; /* default shaders */ Shader *default_surface; Shader *default_light; Shader *default_background; Shader *default_empty; /* device */ Device *device; DeviceScene dscene; /* parameters */ SceneParams params; /* mutex must be locked manually by callers */ thread_mutex mutex; Scene(const SceneParams& params, const DeviceInfo& device_info); ~Scene(); void device_update(Device *device, Progress& progress); bool need_global_attribute(AttributeStandard std); void need_global_attributes(AttributeRequestSet& attributes); enum MotionType { MOTION_NONE = 0, MOTION_PASS, MOTION_BLUR }; MotionType need_motion(bool advanced_shading = true); float motion_shutter_time(); bool need_update(); bool need_reset(); void reset(); void device_free(); protected: /* Check if some heavy data worth logging was updated. * Mainly used to suppress extra annoying logging. */ bool need_data_update(); void free_memory(bool final); }; CCL_NAMESPACE_END #endif /* __SCENE_H__ */