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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __BLENDER_SYNC_H__
|
|
|
|
|
#define __BLENDER_SYNC_H__
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
#include "RNA_types.h"
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
#include "RNA_blender_cpp.h"
|
|
|
|
|
|
|
|
|
|
#include "blender_util.h"
|
|
|
|
|
|
|
|
|
|
#include "scene.h"
|
|
|
|
|
#include "session.h"
|
|
|
|
|
|
|
|
|
|
#include "util_map.h"
|
|
|
|
|
#include "util_set.h"
|
|
|
|
|
#include "util_transform.h"
|
|
|
|
|
#include "util_vector.h"
|
|
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
|
|
class Background;
|
|
|
|
|
class Camera;
|
|
|
|
|
class Film;
|
|
|
|
|
class Light;
|
|
|
|
|
class Mesh;
|
|
|
|
|
class Object;
|
|
|
|
|
class Scene;
|
|
|
|
|
class Shader;
|
|
|
|
|
class ShaderGraph;
|
|
|
|
|
class ShaderNode;
|
|
|
|
|
|
|
|
|
|
class BlenderSync {
|
|
|
|
|
public:
|
|
|
|
|
BlenderSync(BL::BlendData b_data, BL::Scene b_scene, Scene *scene_, bool preview_);
|
|
|
|
|
~BlenderSync();
|
|
|
|
|
|
|
|
|
|
/* sync */
|
|
|
|
|
bool sync_recalc();
|
2012-02-07 20:51:33 +00:00
|
|
|
void sync_data(BL::SpaceView3D b_v3d, const char *layer = 0);
|
2011-04-27 11:58:34 +00:00
|
|
|
void sync_camera(int width, int height);
|
|
|
|
|
void sync_view(BL::SpaceView3D b_v3d, BL::RegionView3D b_rv3d, int width, int height);
|
|
|
|
|
|
|
|
|
|
/* get parameters */
|
2011-11-04 15:46:15 +00:00
|
|
|
static SceneParams get_scene_params(BL::Scene b_scene, bool background);
|
2012-01-09 16:58:01 +00:00
|
|
|
static SessionParams get_session_params(BL::UserPreferences b_userpref, BL::Scene b_scene, bool background);
|
2011-08-29 16:54:13 +00:00
|
|
|
static bool get_session_pause(BL::Scene b_scene, bool background);
|
2011-12-20 12:25:37 +00:00
|
|
|
static BufferParams get_buffer_params(BL::Scene b_scene, BL::RegionView3D b_rv3d, int width, int height);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
/* sync */
|
|
|
|
|
void sync_lamps();
|
|
|
|
|
void sync_materials();
|
|
|
|
|
void sync_objects(BL::SpaceView3D b_v3d);
|
|
|
|
|
void sync_film();
|
2012-02-28 16:44:45 +00:00
|
|
|
void sync_integrator();
|
2011-04-27 11:58:34 +00:00
|
|
|
void sync_view();
|
|
|
|
|
void sync_world();
|
2012-02-28 16:44:45 +00:00
|
|
|
void sync_render_layers(BL::SpaceView3D b_v3d, const char *layer);
|
2011-04-27 11:58:34 +00:00
|
|
|
void sync_shaders();
|
|
|
|
|
|
|
|
|
|
void sync_nodes(Shader *shader, BL::ShaderNodeTree b_ntree);
|
2012-02-28 16:44:45 +00:00
|
|
|
Mesh *sync_mesh(BL::Object b_ob, bool holdout, bool object_updated);
|
2011-12-21 20:51:43 +00:00
|
|
|
void sync_object(BL::Object b_parent, int b_index, BL::Object b_object, Transform& tfm, uint layer_flag);
|
2011-05-31 10:41:01 +00:00
|
|
|
void sync_light(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm);
|
2012-01-20 17:49:17 +00:00
|
|
|
void sync_background_light();
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
|
/* util */
|
2011-12-09 00:24:48 +00:00
|
|
|
void find_shader(BL::ID id, vector<uint>& used_shaders, int default_shader);
|
2011-04-27 11:58:34 +00:00
|
|
|
bool object_is_modified(BL::Object b_ob);
|
|
|
|
|
bool object_is_mesh(BL::Object b_ob);
|
|
|
|
|
bool object_is_light(BL::Object b_ob);
|
|
|
|
|
|
|
|
|
|
/* variables */
|
|
|
|
|
BL::BlendData b_data;
|
|
|
|
|
BL::Scene b_scene;
|
|
|
|
|
|
|
|
|
|
id_map<void*, Shader> shader_map;
|
|
|
|
|
id_map<ObjectKey, Object> object_map;
|
|
|
|
|
id_map<void*, Mesh> mesh_map;
|
2011-05-31 10:41:01 +00:00
|
|
|
id_map<ObjectKey, Light> light_map;
|
2011-05-31 10:57:43 +00:00
|
|
|
set<Mesh*> mesh_synced;
|
2011-04-27 11:58:34 +00:00
|
|
|
void *world_map;
|
|
|
|
|
bool world_recalc;
|
|
|
|
|
|
|
|
|
|
Scene *scene;
|
|
|
|
|
bool preview;
|
2011-12-01 16:33:21 +00:00
|
|
|
bool experimental;
|
2011-09-12 13:13:56 +00:00
|
|
|
|
|
|
|
|
struct RenderLayerInfo {
|
|
|
|
|
RenderLayerInfo()
|
2012-03-12 01:34:38 +00:00
|
|
|
: scene_layer(0), layer(0), holdout_layer(0),
|
2011-09-12 13:13:56 +00:00
|
|
|
material_override(PointerRNA_NULL)
|
|
|
|
|
{}
|
|
|
|
|
|
2012-02-07 20:51:33 +00:00
|
|
|
string name;
|
2011-09-12 13:13:56 +00:00
|
|
|
uint scene_layer;
|
|
|
|
|
uint layer;
|
2012-02-28 16:44:45 +00:00
|
|
|
uint holdout_layer;
|
2011-09-12 13:13:56 +00:00
|
|
|
BL::Material material_override;
|
2012-02-28 16:44:45 +00:00
|
|
|
} render_layer;
|
2011-04-27 11:58:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|
|
|
|
|
#endif /* __BLENDER_SYNC_H__ */
|
|
|
|
|
|