diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-01-30 16:18:29 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-01-30 17:08:57 +0300 |
commit | 74c7707e8c763a60c2936e95c2f0ad13dfd33f43 (patch) | |
tree | 08dddce249a8821e54728355f32fea976d324ac1 /intern/cycles/blender/blender_object.cpp | |
parent | 0e4e1993e619caad3dfbecc20ab9fb20cdf6cd06 (diff) |
Cycles: Pass Blender's C++ RNA structures by reference
This way we avoid passing structures which could be up to
few hundred bytes by value to the utility functions.
Ideally we'll also have to add `const` qualifier in majority
of the calls, but C++ RNA does not allow us to do that because
it does not know if some function modifies contents or not.
Diffstat (limited to 'intern/cycles/blender/blender_object.cpp')
-rw-r--r-- | intern/cycles/blender/blender_object.cpp | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index 11593807a00..1c5180a1ddc 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -36,7 +36,7 @@ CCL_NAMESPACE_BEGIN /* Utilities */ -bool BlenderSync::BKE_object_is_modified(BL::Object b_ob) +bool BlenderSync::BKE_object_is_modified(BL::Object& b_ob) { /* test if we can instance or if the object is modified */ if(b_ob.type() == BL::Object::type_META) { @@ -58,7 +58,7 @@ bool BlenderSync::BKE_object_is_modified(BL::Object b_ob) return false; } -bool BlenderSync::object_is_mesh(BL::Object b_ob) +bool BlenderSync::object_is_mesh(BL::Object& b_ob) { BL::ID b_ob_data = b_ob.data(); @@ -66,14 +66,14 @@ bool BlenderSync::object_is_mesh(BL::Object b_ob) b_ob_data.is_a(&RNA_Curve) || b_ob_data.is_a(&RNA_MetaBall))); } -bool BlenderSync::object_is_light(BL::Object b_ob) +bool BlenderSync::object_is_light(BL::Object& b_ob) { BL::ID b_ob_data = b_ob.data(); return (b_ob_data && b_ob_data.is_a(&RNA_Lamp)); } -static uint object_ray_visibility(BL::Object b_ob) +static uint object_ray_visibility(BL::Object& b_ob) { PointerRNA cvisibility = RNA_pointer_get(&b_ob.ptr, "cycles_visibility"); uint flag = 0; @@ -90,7 +90,11 @@ static uint object_ray_visibility(BL::Object b_ob) /* Light */ -void BlenderSync::sync_light(BL::Object b_parent, int persistent_id[OBJECT_PERSISTENT_ID_SIZE], BL::Object b_ob, Transform& tfm, bool *use_portal) +void BlenderSync::sync_light(BL::Object& b_parent, + int persistent_id[OBJECT_PERSISTENT_ID_SIZE], + BL::Object& b_ob, + Transform& tfm, + bool *use_portal) { /* test if we need to sync */ Light *light; @@ -239,7 +243,7 @@ void BlenderSync::sync_background_light(bool use_portal) * to reduce number of objects which are wrongly considered visible. */ static bool object_boundbox_clip(Scene *scene, - BL::Object b_ob, + BL::Object& b_ob, Transform& tfm, float margin) { @@ -275,9 +279,9 @@ static bool object_boundbox_clip(Scene *scene, return true; } -Object *BlenderSync::sync_object(BL::Object b_parent, +Object *BlenderSync::sync_object(BL::Object& b_parent, int persistent_id[OBJECT_PERSISTENT_ID_SIZE], - BL::DupliObject b_dupli_ob, + BL::DupliObject& b_dupli_ob, Transform& tfm, uint layer_flag, float motion_time, @@ -439,7 +443,8 @@ Object *BlenderSync::sync_object(BL::Object b_parent, return object; } -static bool object_render_hide_original(BL::Object::type_enum ob_type, BL::Object::dupli_type_enum dupli_type) +static bool object_render_hide_original(BL::Object::type_enum ob_type, + BL::Object::dupli_type_enum dupli_type) { /* metaball exception, they duplicate self */ if(ob_type == BL::Object::type_META) @@ -450,7 +455,10 @@ static bool object_render_hide_original(BL::Object::type_enum ob_type, BL::Objec dupli_type == BL::Object::dupli_type_FRAMES); } -static bool object_render_hide(BL::Object b_ob, bool top_level, bool parent_hide, bool& hide_triangles) +static bool object_render_hide(BL::Object& b_ob, + bool top_level, + bool parent_hide, + bool& hide_triangles) { /* check if we should render or hide particle emitter */ BL::Object::particle_systems_iterator b_psys; @@ -507,7 +515,7 @@ static bool object_render_hide(BL::Object b_ob, bool top_level, bool parent_hide } } -static bool object_render_hide_duplis(BL::Object b_ob) +static bool object_render_hide_duplis(BL::Object& b_ob) { BL::Object parent = b_ob.parent(); @@ -516,7 +524,7 @@ static bool object_render_hide_duplis(BL::Object b_ob) /* Object Loop */ -void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, float motion_time) +void BlenderSync::sync_objects(BL::SpaceView3D& b_v3d, float motion_time) { /* layer data */ uint scene_layer = render_layer.scene_layer; @@ -631,9 +639,10 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, float motion_time) if(!object_render_hide(b_ob, true, true, hide_tris)) { /* object itself */ Transform tfm = get_transform(b_ob.matrix_world()); + BL::DupliObject b_empty_dupli_ob(PointerRNA_NULL); sync_object(b_ob, NULL, - PointerRNA_NULL, + b_empty_dupli_ob, tfm, ob_layer, motion_time, @@ -668,9 +677,9 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, float motion_time) mesh_motion_synced.clear(); } -void BlenderSync::sync_motion(BL::RenderSettings b_render, - BL::SpaceView3D b_v3d, - BL::Object b_override, +void BlenderSync::sync_motion(BL::RenderSettings& b_render, + BL::SpaceView3D& b_v3d, + BL::Object& b_override, int width, int height, void **python_thread_state) { |