Blender V2.61 - r43446

scene.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2011, Blender Foundation.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 #ifndef __SCENE_H__
00020 #define __SCENE_H__
00021 
00022 #include "image.h"
00023 
00024 #include "device_memory.h"
00025 
00026 #include "kernel_types.h"
00027 
00028 #include "util_param.h"
00029 #include "util_string.h"
00030 #include "util_thread.h"
00031 #include "util_types.h"
00032 #include "util_vector.h"
00033 
00034 CCL_NAMESPACE_BEGIN
00035 
00036 class Background;
00037 class Camera;
00038 class Device;
00039 class Film;
00040 class Filter;
00041 class Integrator;
00042 class Light;
00043 class LightManager;
00044 class Mesh;
00045 class MeshManager;
00046 class Object;
00047 class ObjectManager;
00048 class Shader;
00049 class ShaderManager;
00050 class Progress;
00051 
00052 /* Scene Device Data */
00053 
00054 class DeviceScene {
00055 public:
00056     /* BVH */
00057     device_vector<float4> bvh_nodes;
00058     device_vector<uint> object_node;
00059     device_vector<float4> tri_woop;
00060     device_vector<uint> prim_visibility;
00061     device_vector<uint> prim_index;
00062     device_vector<uint> prim_object;
00063 
00064     /* mesh */
00065     device_vector<float4> tri_normal;
00066     device_vector<float4> tri_vnormal;
00067     device_vector<float4> tri_vindex;
00068     device_vector<float4> tri_verts;
00069 
00070     /* objects */
00071     device_vector<float4> objects;
00072 
00073     /* attributes */
00074     device_vector<uint4> attributes_map;
00075     device_vector<float> attributes_float;
00076     device_vector<float4> attributes_float3;
00077 
00078     /* lights */
00079     device_vector<float4> light_distribution;
00080     device_vector<float4> light_data;
00081 
00082     /* shaders */
00083     device_vector<uint4> svm_nodes;
00084     device_vector<uint> shader_flag;
00085 
00086     /* filter */
00087     device_vector<float> filter_table;
00088 
00089     /* integrator */
00090     device_vector<uint> sobol_directions;
00091 
00092     /* images */
00093     device_vector<uchar4> tex_image[TEX_IMAGE_MAX];
00094 
00095     KernelData data;
00096 };
00097 
00098 /* Scene Parameters */
00099 
00100 class SceneParams {
00101 public:
00102     enum { OSL, SVM } shadingsystem;
00103     enum BVHType { BVH_DYNAMIC, BVH_STATIC } bvh_type;
00104     bool use_bvh_cache;
00105     bool use_bvh_spatial_split;
00106     bool use_qbvh;
00107 
00108     SceneParams()
00109     {
00110         shadingsystem = SVM;
00111         bvh_type = BVH_DYNAMIC;
00112         use_bvh_cache = false;
00113         use_bvh_spatial_split = false;
00114 #ifdef __QBVH__
00115         use_qbvh = true;
00116 #else
00117         use_qbvh = false;
00118 #endif
00119     }
00120 
00121     bool modified(const SceneParams& params)
00122     { return !(shadingsystem == params.shadingsystem
00123         && bvh_type == params.bvh_type
00124         && use_bvh_cache == params.use_bvh_cache
00125         && use_bvh_spatial_split == params.use_bvh_spatial_split
00126         && use_qbvh == params.use_qbvh); }
00127 };
00128 
00129 /* Scene */
00130 
00131 class Scene {
00132 public:
00133     /* data */
00134     Camera *camera;
00135     Filter *filter;
00136     Film *film;
00137     Background *background;
00138     Integrator *integrator;
00139 
00140     /* data lists */
00141     vector<Object*> objects;
00142     vector<Mesh*> meshes;
00143     vector<Shader*> shaders;
00144     vector<Light*> lights;
00145 
00146     /* data managers */
00147     ImageManager *image_manager;
00148     LightManager *light_manager;
00149     ShaderManager *shader_manager;
00150     MeshManager *mesh_manager;
00151     ObjectManager *object_manager;
00152 
00153     /* default shaders */
00154     int default_surface;
00155     int default_light;
00156     int default_background;
00157 
00158     /* device */
00159     Device *device;
00160     DeviceScene dscene;
00161 
00162     /* parameters */
00163     SceneParams params;
00164 
00165     /* mutex must be locked manually by callers */
00166     thread_mutex mutex;
00167 
00168     Scene(const SceneParams& params);
00169     ~Scene();
00170 
00171     void device_update(Device *device, Progress& progress);
00172 
00173     bool need_update();
00174     bool need_reset();
00175 };
00176 
00177 CCL_NAMESPACE_END
00178 
00179 #endif /*  __SCENE_H__ */
00180