Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r--intern/cycles/blender/blender_camera.cpp141
-rw-r--r--intern/cycles/blender/blender_curves.cpp71
-rw-r--r--intern/cycles/blender/blender_geometry.cpp11
-rw-r--r--intern/cycles/blender/blender_light.cpp106
-rw-r--r--intern/cycles/blender/blender_mesh.cpp155
-rw-r--r--intern/cycles/blender/blender_object.cpp108
-rw-r--r--intern/cycles/blender/blender_object_cull.cpp6
-rw-r--r--intern/cycles/blender/blender_particles.cpp14
-rw-r--r--intern/cycles/blender/blender_session.cpp33
-rw-r--r--intern/cycles/blender/blender_shader.cpp424
-rw-r--r--intern/cycles/blender/blender_sync.cpp190
-rw-r--r--intern/cycles/blender/blender_sync.h8
-rw-r--r--intern/cycles/blender/blender_volume.cpp14
13 files changed, 656 insertions, 625 deletions
diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp
index e1ab3b3fbc1..c1da9f1983f 100644
--- a/intern/cycles/blender/blender_camera.cpp
+++ b/intern/cycles/blender/blender_camera.cpp
@@ -388,18 +388,19 @@ static void blender_camera_sync(Camera *cam,
const char *viewname,
PointerRNA *cscene)
{
- /* copy camera to compare later */
- Camera prevcam = *cam;
float aspectratio, sensor_size;
/* viewplane */
- blender_camera_viewplane(bcam, width, height, &cam->viewplane, &aspectratio, &sensor_size);
+ BoundBox2D viewplane;
+ blender_camera_viewplane(bcam, width, height, &viewplane, &aspectratio, &sensor_size);
- cam->width = bcam->full_width;
- cam->height = bcam->full_height;
+ cam->set_viewplane_left(viewplane.left);
+ cam->set_viewplane_right(viewplane.right);
+ cam->set_viewplane_top(viewplane.top);
+ cam->set_viewplane_bottom(viewplane.bottom);
- cam->full_width = width;
- cam->full_height = height;
+ cam->set_full_width(width);
+ cam->set_full_height(height);
/* panorama sensor */
if (bcam->type == CAMERA_PANORAMA && bcam->panorama_type == PANORAMA_FISHEYE_EQUISOLID) {
@@ -422,85 +423,91 @@ static void blender_camera_sync(Camera *cam,
}
if (horizontal_fit) {
- cam->sensorwidth = sensor_size;
- cam->sensorheight = sensor_size * fit_yratio / fit_xratio;
+ cam->set_sensorwidth(sensor_size);
+ cam->set_sensorheight(sensor_size * fit_yratio / fit_xratio);
}
else {
- cam->sensorwidth = sensor_size * fit_xratio / fit_yratio;
- cam->sensorheight = sensor_size;
+ cam->set_sensorwidth(sensor_size * fit_xratio / fit_yratio);
+ cam->set_sensorheight(sensor_size);
}
}
/* clipping distances */
- cam->nearclip = bcam->nearclip;
- cam->farclip = bcam->farclip;
+ cam->set_nearclip(bcam->nearclip);
+ cam->set_farclip(bcam->farclip);
/* type */
- cam->type = bcam->type;
+ cam->set_camera_type(bcam->type);
/* panorama */
- cam->panorama_type = bcam->panorama_type;
- cam->fisheye_fov = bcam->fisheye_fov;
- cam->fisheye_lens = bcam->fisheye_lens;
- cam->latitude_min = bcam->latitude_min;
- cam->latitude_max = bcam->latitude_max;
+ cam->set_panorama_type(bcam->panorama_type);
+ cam->set_fisheye_fov(bcam->fisheye_fov);
+ cam->set_fisheye_lens(bcam->fisheye_lens);
+ cam->set_latitude_min(bcam->latitude_min);
+ cam->set_latitude_max(bcam->latitude_max);
- cam->longitude_min = bcam->longitude_min;
- cam->longitude_max = bcam->longitude_max;
+ cam->set_longitude_min(bcam->longitude_min);
+ cam->set_longitude_max(bcam->longitude_max);
/* panorama stereo */
- cam->interocular_distance = bcam->interocular_distance;
- cam->convergence_distance = bcam->convergence_distance;
- cam->use_spherical_stereo = bcam->use_spherical_stereo;
+ cam->set_interocular_distance(bcam->interocular_distance);
+ cam->set_convergence_distance(bcam->convergence_distance);
+ cam->set_use_spherical_stereo(bcam->use_spherical_stereo);
- if (cam->use_spherical_stereo) {
+ if (cam->get_use_spherical_stereo()) {
if (strcmp(viewname, "left") == 0)
- cam->stereo_eye = Camera::STEREO_LEFT;
+ cam->set_stereo_eye(Camera::STEREO_LEFT);
else if (strcmp(viewname, "right") == 0)
- cam->stereo_eye = Camera::STEREO_RIGHT;
+ cam->set_stereo_eye(Camera::STEREO_RIGHT);
else
- cam->stereo_eye = Camera::STEREO_NONE;
+ cam->set_stereo_eye(Camera::STEREO_NONE);
}
- cam->use_pole_merge = bcam->use_pole_merge;
- cam->pole_merge_angle_from = bcam->pole_merge_angle_from;
- cam->pole_merge_angle_to = bcam->pole_merge_angle_to;
+ cam->set_use_pole_merge(bcam->use_pole_merge);
+ cam->set_pole_merge_angle_from(bcam->pole_merge_angle_from);
+ cam->set_pole_merge_angle_to(bcam->pole_merge_angle_to);
/* anamorphic lens bokeh */
- cam->aperture_ratio = bcam->aperture_ratio;
+ cam->set_aperture_ratio(bcam->aperture_ratio);
/* perspective */
- cam->fov = 2.0f * atanf((0.5f * sensor_size) / bcam->lens / aspectratio);
- cam->focaldistance = bcam->focaldistance;
- cam->aperturesize = bcam->aperturesize;
- cam->blades = bcam->apertureblades;
- cam->bladesrotation = bcam->aperturerotation;
+ cam->set_fov(2.0f * atanf((0.5f * sensor_size) / bcam->lens / aspectratio));
+ cam->set_focaldistance(bcam->focaldistance);
+ cam->set_aperturesize(bcam->aperturesize);
+ cam->set_blades(bcam->apertureblades);
+ cam->set_bladesrotation(bcam->aperturerotation);
/* transform */
- cam->matrix = blender_camera_matrix(bcam->matrix, bcam->type, bcam->panorama_type);
- cam->motion.clear();
- cam->motion.resize(bcam->motion_steps, cam->matrix);
- cam->use_perspective_motion = false;
- cam->shuttertime = bcam->shuttertime;
- cam->fov_pre = cam->fov;
- cam->fov_post = cam->fov;
- cam->motion_position = bcam->motion_position;
+ cam->set_matrix(blender_camera_matrix(bcam->matrix, bcam->type, bcam->panorama_type));
- cam->rolling_shutter_type = bcam->rolling_shutter_type;
- cam->rolling_shutter_duration = bcam->rolling_shutter_duration;
+ array<Transform> motion;
+ motion.resize(bcam->motion_steps, cam->get_matrix());
+ cam->set_motion(motion);
+ cam->set_use_perspective_motion(false);
- cam->shutter_curve = bcam->shutter_curve;
+ cam->set_shuttertime(bcam->shuttertime);
+ cam->set_fov_pre(cam->get_fov());
+ cam->set_fov_post(cam->get_fov());
+ cam->set_motion_position(bcam->motion_position);
+
+ cam->set_rolling_shutter_type(bcam->rolling_shutter_type);
+ cam->set_rolling_shutter_duration(bcam->rolling_shutter_duration);
+
+ cam->set_shutter_curve(bcam->shutter_curve);
/* border */
- cam->border = bcam->border;
- cam->viewport_camera_border = bcam->viewport_camera_border;
+ cam->set_border_left(bcam->border.left);
+ cam->set_border_right(bcam->border.right);
+ cam->set_border_top(bcam->border.top);
+ cam->set_border_bottom(bcam->border.bottom);
- bcam->offscreen_dicing_scale = RNA_float_get(cscene, "offscreen_dicing_scale");
- cam->offscreen_dicing_scale = bcam->offscreen_dicing_scale;
+ cam->set_viewport_camera_border_left(bcam->viewport_camera_border.left);
+ cam->set_viewport_camera_border_right(bcam->viewport_camera_border.right);
+ cam->set_viewport_camera_border_top(bcam->viewport_camera_border.top);
+ cam->set_viewport_camera_border_bottom(bcam->viewport_camera_border.bottom);
- /* set update flag */
- if (cam->modified(prevcam))
- cam->tag_update();
+ bcam->offscreen_dicing_scale = RNA_float_get(cscene, "offscreen_dicing_scale");
+ cam->set_offscreen_dicing_scale(bcam->offscreen_dicing_scale);
}
/* Sync Render Camera */
@@ -582,22 +589,24 @@ void BlenderSync::sync_camera_motion(
Camera *cam = scene->camera;
BL::Array<float, 16> b_ob_matrix;
- b_engine.camera_model_matrix(b_ob, cam->use_spherical_stereo, b_ob_matrix);
+ b_engine.camera_model_matrix(b_ob, cam->get_use_spherical_stereo(), b_ob_matrix);
Transform tfm = get_transform(b_ob_matrix);
- tfm = blender_camera_matrix(tfm, cam->type, cam->panorama_type);
+ tfm = blender_camera_matrix(tfm, cam->get_camera_type(), cam->get_panorama_type());
if (motion_time == 0.0f) {
/* When motion blur is not centered in frame, cam->matrix gets reset. */
- cam->matrix = tfm;
+ cam->set_matrix(tfm);
}
/* Set transform in motion array. */
int motion_step = cam->motion_step(motion_time);
if (motion_step >= 0) {
- cam->motion[motion_step] = tfm;
+ array<Transform> motion = cam->get_motion();
+ motion[motion_step] = tfm;
+ cam->set_motion(motion);
}
- if (cam->type == CAMERA_PERSPECTIVE) {
+ if (cam->get_camera_type() == CAMERA_PERSPECTIVE) {
BlenderCamera bcam;
float aspectratio, sensor_size;
blender_camera_init(&bcam, b_render);
@@ -610,18 +619,18 @@ void BlenderSync::sync_camera_motion(
blender_camera_viewplane(&bcam, width, height, NULL, &aspectratio, &sensor_size);
/* TODO(sergey): De-duplicate calculation with camera sync. */
float fov = 2.0f * atanf((0.5f * sensor_size) / bcam.lens / aspectratio);
- if (fov != cam->fov) {
+ if (fov != cam->get_fov()) {
VLOG(1) << "Camera " << b_ob.name() << " FOV change detected.";
if (motion_time == 0.0f) {
- cam->fov = fov;
+ cam->set_fov(fov);
}
else if (motion_time == -1.0f) {
- cam->fov_pre = fov;
- cam->use_perspective_motion = true;
+ cam->set_fov_pre(fov);
+ cam->set_use_perspective_motion(true);
}
else if (motion_time == 1.0f) {
- cam->fov_post = fov;
- cam->use_perspective_motion = true;
+ cam->set_fov_post(fov);
+ cam->set_use_perspective_motion(true);
}
}
}
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index 6288c370567..1af592fc8ab 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -77,7 +77,7 @@ static bool ObtainCacheParticleData(
if ((b_part.render_type() == BL::ParticleSettings::render_type_PATH) &&
(b_part.type() == BL::ParticleSettings::type_HAIR)) {
- int shader = clamp(b_part.material() - 1, 0, hair->used_shaders.size() - 1);
+ int shader = clamp(b_part.material() - 1, 0, hair->get_used_shaders().size() - 1);
int display_step = background ? b_part.render_step() : b_part.display_step();
int totparts = b_psys.particles.length();
int totchild = background ? b_psys.child_particles.length() :
@@ -307,7 +307,7 @@ static void ExportCurveSegments(Scene *scene, Hair *hair, ParticleCurveData *CDa
VLOG(1) << "Exporting curve segments for mesh " << hair->name;
}
- hair->reserve_curves(hair->num_curves() + num_curves, hair->curve_keys.size() + num_keys);
+ hair->reserve_curves(hair->num_curves() + num_curves, hair->get_curve_keys().size() + num_keys);
num_keys = 0;
num_curves = 0;
@@ -350,7 +350,7 @@ static void ExportCurveSegments(Scene *scene, Hair *hair, ParticleCurveData *CDa
}
/* check allocation */
- if ((hair->curve_keys.size() != num_keys) || (hair->num_curves() != num_curves)) {
+ if ((hair->get_curve_keys().size() != num_keys) || (hair->num_curves() != num_curves)) {
VLOG(1) << "Allocation failed, clearing data";
hair->clear();
}
@@ -402,7 +402,7 @@ static void export_hair_motion_validate_attribute(Hair *hair,
bool have_motion)
{
Attribute *attr_mP = hair->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
- const int num_keys = hair->curve_keys.size();
+ const int num_keys = hair->get_curve_keys().size();
if (num_motion_keys != num_keys || !have_motion) {
/* No motion or hair "topology" changed, remove attributes again. */
@@ -423,8 +423,8 @@ static void export_hair_motion_validate_attribute(Hair *hair,
float4 *mP = attr_mP->data_float4() + step * num_keys;
for (int key = 0; key < num_keys; key++) {
- mP[key] = float3_to_float4(hair->curve_keys[key]);
- mP[key].w = hair->curve_radius[key];
+ mP[key] = float3_to_float4(hair->get_curve_keys()[key]);
+ mP[key].w = hair->get_curve_radius()[key];
}
}
}
@@ -447,7 +447,7 @@ static void ExportCurveSegmentsMotion(Hair *hair, ParticleCurveData *CData, int
}
/* export motion vectors for curve keys */
- size_t numkeys = hair->curve_keys.size();
+ size_t numkeys = hair->get_curve_keys().size();
float4 *mP = attr_mP->data_float4() + motion_step * numkeys;
bool have_motion = false;
int i = 0;
@@ -458,24 +458,24 @@ static void ExportCurveSegmentsMotion(Hair *hair, ParticleCurveData *CData, int
curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys];
curve++) {
/* Curve lengths may not match! Curves can be clipped. */
- int curve_key_end = (num_curves + 1 < (int)hair->curve_first_key.size() ?
- hair->curve_first_key[num_curves + 1] :
- (int)hair->curve_keys.size());
- const int num_center_curve_keys = curve_key_end - hair->curve_first_key[num_curves];
+ int curve_key_end = (num_curves + 1 < (int)hair->get_curve_first_key().size() ?
+ hair->get_curve_first_key()[num_curves + 1] :
+ (int)hair->get_curve_keys().size());
+ const int num_center_curve_keys = curve_key_end - hair->get_curve_first_key()[num_curves];
const int is_num_keys_different = CData->curve_keynum[curve] - num_center_curve_keys;
if (!is_num_keys_different) {
for (int curvekey = CData->curve_firstkey[curve];
curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve];
curvekey++) {
- if (i < hair->curve_keys.size()) {
+ if (i < hair->get_curve_keys().size()) {
mP[i] = CurveSegmentMotionCV(CData, sys, curve, curvekey);
if (!have_motion) {
/* unlike mesh coordinates, these tend to be slightly different
* between frames due to particle transforms into/out of object
* space, so we use an epsilon to detect actual changes */
- float4 curve_key = float3_to_float4(hair->curve_keys[i]);
- curve_key.w = hair->curve_radius[i];
+ float4 curve_key = float3_to_float4(hair->get_curve_keys()[i]);
+ curve_key.w = hair->get_curve_radius()[i];
if (len_squared(mP[i] - curve_key) > 1e-5f * 1e-5f)
have_motion = true;
}
@@ -560,7 +560,7 @@ void BlenderSync::sync_particle_hair(
float3 *generated = attr_generated->data_float3();
for (size_t i = 0; i < hair->num_curves(); i++) {
- float3 co = hair->curve_keys[hair->get_curve(i).first_key];
+ float3 co = hair->get_curve_keys()[hair->get_curve(i).first_key];
generated[i] = co * size - loc;
}
}
@@ -742,7 +742,7 @@ static void export_hair_curves_motion(Hair *hair, BL::Hair b_hair, int motion_st
}
/* Export motion keys. */
- const int num_keys = hair->curve_keys.size();
+ const int num_keys = hair->get_curve_keys().size();
float4 *mP = attr_mP->data_float4() + motion_step * num_keys;
bool have_motion = false;
int num_motion_keys = 0;
@@ -769,8 +769,8 @@ static void export_hair_curves_motion(Hair *hair, BL::Hair b_hair, int motion_st
if (!have_motion) {
/* TODO: use epsilon for comparison? Was needed for particles due to
* transform, but ideally should not happen anymore. */
- float4 curve_key = float3_to_float4(hair->curve_keys[i]);
- curve_key.w = hair->curve_radius[i];
+ float4 curve_key = float3_to_float4(hair->get_curve_keys()[i]);
+ curve_key.w = hair->get_curve_radius()[i];
have_motion = !(mP[i] == curve_key);
}
}
@@ -820,39 +820,44 @@ void BlenderSync::sync_hair(Hair *hair, BL::Object &b_ob, bool motion, int motio
void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph,
BL::Object b_ob,
Hair *hair,
- const vector<Shader *> &used_shaders)
+ array<Node *> &used_shaders)
{
- /* Compares curve_keys rather than strands in order to handle quick hair
- * adjustments in dynamic BVH - other methods could probably do this better. */
- array<float3> oldcurve_keys;
- array<float> oldcurve_radius;
- oldcurve_keys.steal_data(hair->curve_keys);
- oldcurve_radius.steal_data(hair->curve_radius);
-
- hair->clear();
- hair->used_shaders = used_shaders;
+ Hair new_hair;
+ new_hair.set_used_shaders(used_shaders);
if (view_layer.use_hair) {
if (b_ob.type() == BL::Object::type_HAIR) {
/* Hair object. */
- sync_hair(hair, b_ob, false);
+ sync_hair(&new_hair, b_ob, false);
}
else {
/* Particle hair. */
- bool need_undeformed = hair->need_attribute(scene, ATTR_STD_GENERATED);
+ bool need_undeformed = new_hair.need_attribute(scene, ATTR_STD_GENERATED);
BL::Mesh b_mesh = object_to_mesh(
b_data, b_ob, b_depsgraph, need_undeformed, Mesh::SUBDIVISION_NONE);
if (b_mesh) {
- sync_particle_hair(hair, b_mesh, b_ob, false);
+ sync_particle_hair(&new_hair, b_mesh, b_ob, false);
free_object_to_mesh(b_data, b_ob, b_mesh);
}
}
}
+ /* update original sockets */
+
+ for (const SocketType &socket : new_hair.type->inputs) {
+ hair->set_value(socket, new_hair, socket);
+ }
+
+ foreach (Attribute &attr, new_hair.attributes.attributes) {
+ hair->attributes.attributes.push_back(std::move(attr));
+ }
+
/* tag update */
- const bool rebuild = ((oldcurve_keys != hair->curve_keys) ||
- (oldcurve_radius != hair->curve_radius));
+
+ /* Compares curve_keys rather than strands in order to handle quick hair
+ * adjustments in dynamic BVH - other methods could probably do this better. */
+ const bool rebuild = (hair->curve_keys_is_modified() || hair->curve_radius_is_modified());
hair->tag_update(scene, rebuild);
}
diff --git a/intern/cycles/blender/blender_geometry.cpp b/intern/cycles/blender/blender_geometry.cpp
index c7637fe8608..0c05f93d995 100644
--- a/intern/cycles/blender/blender_geometry.cpp
+++ b/intern/cycles/blender/blender_geometry.cpp
@@ -59,7 +59,7 @@ Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,
GeometryKey key(b_key_id.ptr.data, geom_type);
/* Find shader indices. */
- vector<Shader *> used_shaders;
+ array<Node *> used_shaders;
BL::Object::material_slots_iterator slot;
for (b_ob.material_slots.begin(slot); slot != b_ob.material_slots.end(); ++slot) {
@@ -76,7 +76,7 @@ Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,
if (material_override)
find_shader(material_override, used_shaders, default_shader);
else
- used_shaders.push_back(default_shader);
+ used_shaders.push_back_slow(default_shader);
}
/* Ensure we only sync instanced geometry once. */
@@ -114,7 +114,7 @@ Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,
}
/* Test if shaders changed, these can be object level so geometry
* does not get tagged for recalc. */
- else if (geom->used_shaders != used_shaders) {
+ else if (geom->get_used_shaders() != used_shaders) {
;
}
else {
@@ -122,7 +122,8 @@ Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,
* because the shader needs different geometry attributes. */
bool attribute_recalc = false;
- foreach (Shader *shader, geom->used_shaders) {
+ foreach (Node *node, geom->get_used_shaders()) {
+ Shader *shader = static_cast<Shader *>(node);
if (shader->need_update_geometry) {
attribute_recalc = true;
}
@@ -177,7 +178,7 @@ void BlenderSync::sync_geometry_motion(BL::Depsgraph &b_depsgraph,
TaskPool *task_pool)
{
/* Ensure we only sync instanced geometry once. */
- Geometry *geom = object->geometry;
+ Geometry *geom = object->get_geometry();
if (geometry_motion_synced.find(geom) != geometry_motion_synced.end())
return;
diff --git a/intern/cycles/blender/blender_light.cpp b/intern/cycles/blender/blender_light.cpp
index 117e9214e5a..6c9f61e6caa 100644
--- a/intern/cycles/blender/blender_light.cpp
+++ b/intern/cycles/blender/blender_light.cpp
@@ -42,7 +42,7 @@ void BlenderSync::sync_light(BL::Object &b_parent,
if (!light_map.add_or_update(scene, &light, b_ob, b_parent, key)) {
Shader *shader;
if (!shader_map.add_or_update(scene, &shader, b_light)) {
- if (light->is_portal)
+ if (light->get_is_portal())
*use_portal = true;
return;
}
@@ -52,16 +52,16 @@ void BlenderSync::sync_light(BL::Object &b_parent,
switch (b_light.type()) {
case BL::Light::type_POINT: {
BL::PointLight b_point_light(b_light);
- light->size = b_point_light.shadow_soft_size();
- light->type = LIGHT_POINT;
+ light->set_size(b_point_light.shadow_soft_size());
+ light->set_light_type(LIGHT_POINT);
break;
}
case BL::Light::type_SPOT: {
BL::SpotLight b_spot_light(b_light);
- light->size = b_spot_light.shadow_soft_size();
- light->type = LIGHT_SPOT;
- light->spot_angle = b_spot_light.spot_size();
- light->spot_smooth = b_spot_light.spot_blend();
+ light->set_size(b_spot_light.shadow_soft_size());
+ light->set_light_type(LIGHT_SPOT);
+ light->set_spot_angle(b_spot_light.spot_size());
+ light->set_spot_smooth(b_spot_light.spot_blend());
break;
}
/* Hemi were removed from 2.8 */
@@ -72,88 +72,88 @@ void BlenderSync::sync_light(BL::Object &b_parent,
// }
case BL::Light::type_SUN: {
BL::SunLight b_sun_light(b_light);
- light->angle = b_sun_light.angle();
- light->type = LIGHT_DISTANT;
+ light->set_angle(b_sun_light.angle());
+ light->set_light_type(LIGHT_DISTANT);
break;
}
case BL::Light::type_AREA: {
BL::AreaLight b_area_light(b_light);
- light->size = 1.0f;
- light->axisu = transform_get_column(&tfm, 0);
- light->axisv = transform_get_column(&tfm, 1);
- light->sizeu = b_area_light.size();
+ light->set_size(1.0f);
+ light->set_axisu(transform_get_column(&tfm, 0));
+ light->set_axisv(transform_get_column(&tfm, 1));
+ light->set_sizeu(b_area_light.size());
switch (b_area_light.shape()) {
case BL::AreaLight::shape_SQUARE:
- light->sizev = light->sizeu;
- light->round = false;
+ light->set_sizev(light->get_sizeu());
+ light->set_round(false);
break;
case BL::AreaLight::shape_RECTANGLE:
- light->sizev = b_area_light.size_y();
- light->round = false;
+ light->set_sizev(b_area_light.size_y());
+ light->set_round(false);
break;
case BL::AreaLight::shape_DISK:
- light->sizev = light->sizeu;
- light->round = true;
+ light->set_sizev(light->get_sizeu());
+ light->set_round(true);
break;
case BL::AreaLight::shape_ELLIPSE:
- light->sizev = b_area_light.size_y();
- light->round = true;
+ light->set_sizev(b_area_light.size_y());
+ light->set_round(true);
break;
}
- light->type = LIGHT_AREA;
+ light->set_light_type(LIGHT_AREA);
break;
}
}
/* strength */
- light->strength = get_float3(b_light.color());
- light->strength *= BL::PointLight(b_light).energy();
+ float3 strength = get_float3(b_light.color()) * BL::PointLight(b_light).energy();
+ light->set_strength(strength);
/* location and (inverted!) direction */
- light->co = transform_get_column(&tfm, 3);
- light->dir = -transform_get_column(&tfm, 2);
- light->tfm = tfm;
+ light->set_co(transform_get_column(&tfm, 3));
+ light->set_dir(-transform_get_column(&tfm, 2));
+ light->set_tfm(tfm);
/* shader */
- vector<Shader *> used_shaders;
+ array<Node *> used_shaders;
find_shader(b_light, used_shaders, scene->default_light);
- light->shader = used_shaders[0];
+ light->set_shader(static_cast<Shader *>(used_shaders[0]));
/* shadow */
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
PointerRNA clight = RNA_pointer_get(&b_light.ptr, "cycles");
- light->cast_shadow = get_boolean(clight, "cast_shadow");
- light->use_mis = get_boolean(clight, "use_multiple_importance_sampling");
+ light->set_cast_shadow(get_boolean(clight, "cast_shadow"));
+ light->set_use_mis(get_boolean(clight, "use_multiple_importance_sampling"));
int samples = get_int(clight, "samples");
if (get_boolean(cscene, "use_square_samples"))
- light->samples = samples * samples;
+ light->set_samples(samples * samples);
else
- light->samples = samples;
+ light->set_samples(samples);
- light->max_bounces = get_int(clight, "max_bounces");
+ light->set_max_bounces(get_int(clight, "max_bounces"));
if (b_ob != b_ob_instance) {
- light->random_id = random_id;
+ light->set_random_id(random_id);
}
else {
- light->random_id = hash_uint2(hash_string(b_ob.name().c_str()), 0);
+ light->set_random_id(hash_uint2(hash_string(b_ob.name().c_str()), 0));
}
- if (light->type == LIGHT_AREA)
- light->is_portal = get_boolean(clight, "is_portal");
+ if (light->get_light_type() == LIGHT_AREA)
+ light->set_is_portal(get_boolean(clight, "is_portal"));
else
- light->is_portal = false;
+ light->set_is_portal(false);
- if (light->is_portal)
+ if (light->get_is_portal())
*use_portal = true;
/* visibility */
uint visibility = object_ray_visibility(b_ob);
- light->use_diffuse = (visibility & PATH_RAY_DIFFUSE) != 0;
- light->use_glossy = (visibility & PATH_RAY_GLOSSY) != 0;
- light->use_transmission = (visibility & PATH_RAY_TRANSMIT) != 0;
- light->use_scatter = (visibility & PATH_RAY_VOLUME_SCATTER) != 0;
+ light->set_use_diffuse((visibility & PATH_RAY_DIFFUSE) != 0);
+ light->set_use_glossy((visibility & PATH_RAY_GLOSSY) != 0);
+ light->set_use_transmission((visibility & PATH_RAY_TRANSMIT) != 0);
+ light->set_use_scatter((visibility & PATH_RAY_VOLUME_SCATTER) != 0);
/* tag */
light->tag_update(scene);
@@ -178,25 +178,25 @@ void BlenderSync::sync_background_light(BL::SpaceView3D &b_v3d, bool use_portal)
if (light_map.add_or_update(scene, &light, b_world, b_world, key) || world_recalc ||
b_world.ptr.data != world_map) {
- light->type = LIGHT_BACKGROUND;
+ light->set_light_type(LIGHT_BACKGROUND);
if (sampling_method == SAMPLING_MANUAL) {
- light->map_resolution = get_int(cworld, "sample_map_resolution");
+ light->set_map_resolution(get_int(cworld, "sample_map_resolution"));
}
else {
- light->map_resolution = 0;
+ light->set_map_resolution(0);
}
- light->shader = scene->default_background;
- light->use_mis = sample_as_light;
- light->max_bounces = get_int(cworld, "max_bounces");
+ light->set_shader(scene->default_background);
+ light->set_use_mis(sample_as_light);
+ light->set_max_bounces(get_int(cworld, "max_bounces"));
/* force enable light again when world is resynced */
- light->is_enabled = true;
+ light->set_is_enabled(true);
int samples = get_int(cworld, "samples");
if (get_boolean(cscene, "use_square_samples"))
- light->samples = samples * samples;
+ light->set_samples(samples * samples);
else
- light->samples = samples;
+ light->set_samples(samples);
light->tag_update(scene);
light_map.set_recalc(b_world);
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index e40e1f5f001..ed1075c7e53 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -48,8 +48,8 @@ struct MikkUserData {
float *tangent_sign)
: mesh(mesh), texface(NULL), orco(NULL), tangent(tangent), tangent_sign(tangent_sign)
{
- const AttributeSet &attributes = (mesh->subd_faces.size()) ? mesh->subd_attributes :
- mesh->attributes;
+ const AttributeSet &attributes = (mesh->get_num_subd_faces()) ? mesh->subd_attributes :
+ mesh->attributes;
Attribute *attr_vN = attributes.find(ATTR_STD_VERTEX_NORMAL);
vertex_normal = attr_vN->data_float3();
@@ -85,8 +85,8 @@ struct MikkUserData {
static int mikk_get_num_faces(const SMikkTSpaceContext *context)
{
const MikkUserData *userdata = (const MikkUserData *)context->m_pUserData;
- if (userdata->mesh->subd_faces.size()) {
- return userdata->mesh->subd_faces.size();
+ if (userdata->mesh->get_num_subd_faces()) {
+ return userdata->mesh->get_num_subd_faces();
}
else {
return userdata->mesh->num_triangles();
@@ -96,9 +96,9 @@ static int mikk_get_num_faces(const SMikkTSpaceContext *context)
static int mikk_get_num_verts_of_face(const SMikkTSpaceContext *context, const int face_num)
{
const MikkUserData *userdata = (const MikkUserData *)context->m_pUserData;
- if (userdata->mesh->subd_faces.size()) {
+ if (userdata->mesh->get_num_subd_faces()) {
const Mesh *mesh = userdata->mesh;
- return mesh->subd_faces[face_num].num_corners;
+ return mesh->get_subd_num_corners()[face_num];
}
else {
return 3;
@@ -107,19 +107,19 @@ static int mikk_get_num_verts_of_face(const SMikkTSpaceContext *context, const i
static int mikk_vertex_index(const Mesh *mesh, const int face_num, const int vert_num)
{
- if (mesh->subd_faces.size()) {
- const Mesh::SubdFace &face = mesh->subd_faces[face_num];
- return mesh->subd_face_corners[face.start_corner + vert_num];
+ if (mesh->get_num_subd_faces()) {
+ const Mesh::SubdFace &face = mesh->get_subd_face(face_num);
+ return mesh->get_subd_face_corners()[face.start_corner + vert_num];
}
else {
- return mesh->triangles[face_num * 3 + vert_num];
+ return mesh->get_triangles()[face_num * 3 + vert_num];
}
}
static int mikk_corner_index(const Mesh *mesh, const int face_num, const int vert_num)
{
- if (mesh->subd_faces.size()) {
- const Mesh::SubdFace &face = mesh->subd_faces[face_num];
+ if (mesh->get_num_subd_faces()) {
+ const Mesh::SubdFace &face = mesh->get_subd_face(face_num);
return face.start_corner + vert_num;
}
else {
@@ -135,7 +135,7 @@ static void mikk_get_position(const SMikkTSpaceContext *context,
const MikkUserData *userdata = (const MikkUserData *)context->m_pUserData;
const Mesh *mesh = userdata->mesh;
const int vertex_index = mikk_vertex_index(mesh, face_num, vert_num);
- const float3 vP = mesh->verts[vertex_index];
+ const float3 vP = mesh->get_verts()[vertex_index];
P[0] = vP.x;
P[1] = vP.y;
P[2] = vP.z;
@@ -178,8 +178,8 @@ static void mikk_get_normal(const SMikkTSpaceContext *context,
const MikkUserData *userdata = (const MikkUserData *)context->m_pUserData;
const Mesh *mesh = userdata->mesh;
float3 vN;
- if (mesh->subd_faces.size()) {
- const Mesh::SubdFace &face = mesh->subd_faces[face_num];
+ if (mesh->get_num_subd_faces()) {
+ const Mesh::SubdFace &face = mesh->get_subd_face(face_num);
if (face.smooth) {
const int vertex_index = mikk_vertex_index(mesh, face_num, vert_num);
vN = userdata->vertex_normal[vertex_index];
@@ -189,13 +189,13 @@ static void mikk_get_normal(const SMikkTSpaceContext *context,
}
}
else {
- if (mesh->smooth[face_num]) {
+ if (mesh->get_smooth()[face_num]) {
const int vertex_index = mikk_vertex_index(mesh, face_num, vert_num);
vN = userdata->vertex_normal[vertex_index];
}
else {
const Mesh::Triangle tri = mesh->get_triangle(face_num);
- vN = tri.compute_normal(&mesh->verts[0]);
+ vN = tri.compute_normal(&mesh->get_verts()[0]);
}
}
N[0] = vN.x;
@@ -222,7 +222,8 @@ static void mikk_compute_tangents(
const BL::Mesh &b_mesh, const char *layer_name, Mesh *mesh, bool need_sign, bool active_render)
{
/* Create tangent attributes. */
- AttributeSet &attributes = (mesh->subd_faces.size()) ? mesh->subd_attributes : mesh->attributes;
+ AttributeSet &attributes = (mesh->get_num_subd_faces()) ? mesh->subd_attributes :
+ mesh->attributes;
Attribute *attr;
ustring name;
if (layer_name != NULL) {
@@ -554,7 +555,7 @@ static void attr_create_pointiness(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh, b
for (int vert_index = 0; vert_index < num_verts; ++vert_index) {
sorted_vert_indeices[vert_index] = vert_index;
}
- VertexAverageComparator compare(mesh->verts);
+ VertexAverageComparator compare(mesh->get_verts());
sort(sorted_vert_indeices.begin(), sorted_vert_indeices.end(), compare);
/* This array stores index of the original vertex for the given vertex
* index.
@@ -562,12 +563,12 @@ static void attr_create_pointiness(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh, b
vector<int> vert_orig_index(num_verts);
for (int sorted_vert_index = 0; sorted_vert_index < num_verts; ++sorted_vert_index) {
const int vert_index = sorted_vert_indeices[sorted_vert_index];
- const float3 &vert_co = mesh->verts[vert_index];
+ const float3 &vert_co = mesh->get_verts()[vert_index];
bool found = false;
for (int other_sorted_vert_index = sorted_vert_index + 1; other_sorted_vert_index < num_verts;
++other_sorted_vert_index) {
const int other_vert_index = sorted_vert_indeices[other_sorted_vert_index];
- const float3 &other_vert_co = mesh->verts[other_vert_index];
+ const float3 &other_vert_co = mesh->get_verts()[other_vert_index];
/* We are too far away now, we wouldn't have duplicate. */
if ((other_vert_co.x + other_vert_co.y + other_vert_co.z) -
(vert_co.x + vert_co.y + vert_co.z) >
@@ -732,7 +733,7 @@ static void attr_create_random_per_island(Scene *scene,
static void create_mesh(Scene *scene,
Mesh *mesh,
BL::Mesh &b_mesh,
- const vector<Shader *> &used_shaders,
+ const array<Node *> &used_shaders,
bool subdivision = false,
bool subdivide_uvs = true)
{
@@ -743,7 +744,7 @@ static void create_mesh(Scene *scene,
int numcorners = 0;
int numngons = 0;
bool use_loop_normals = b_mesh.use_auto_smooth() &&
- (mesh->subdivision_type != Mesh::SUBDIVISION_CATMULL_CLARK);
+ (mesh->get_subdivision_type() != Mesh::SUBDIVISION_CATMULL_CLARK);
/* If no faces, create empty mesh. */
if (numfaces == 0) {
@@ -762,8 +763,11 @@ static void create_mesh(Scene *scene,
}
/* allocate memory */
+ if (subdivision) {
+ mesh->reserve_subd_faces(numfaces, numngons, numcorners);
+ }
+
mesh->reserve_mesh(numverts, numtris);
- mesh->reserve_subd_faces(numfaces, numngons, numcorners);
/* create vertex coordinates and normals */
BL::Mesh::vertices_iterator v;
@@ -875,7 +879,7 @@ static void create_subd_mesh(Scene *scene,
Mesh *mesh,
BL::Object &b_ob,
BL::Mesh &b_mesh,
- const vector<Shader *> &used_shaders,
+ const array<Node *> &used_shaders,
float dicing_rate,
int max_subdivisions)
{
@@ -894,31 +898,21 @@ static void create_subd_mesh(Scene *scene,
}
}
- mesh->subd_creases.resize(num_creases);
+ mesh->reserve_subd_creases(num_creases);
- Mesh::SubdEdgeCrease *crease = mesh->subd_creases.data();
for (b_mesh.edges.begin(e); e != b_mesh.edges.end(); ++e) {
if (e->crease() != 0.0f) {
- crease->v[0] = e->vertices()[0];
- crease->v[1] = e->vertices()[1];
- crease->crease = e->crease();
-
- crease++;
+ mesh->add_crease(e->vertices()[0], e->vertices()[1], e->crease());
}
}
/* set subd params */
- if (!mesh->subd_params) {
- mesh->subd_params = new SubdParams(mesh);
- }
- SubdParams &sdparams = *mesh->subd_params;
-
PointerRNA cobj = RNA_pointer_get(&b_ob.ptr, "cycles");
+ float subd_dicing_rate = max(0.1f, RNA_float_get(&cobj, "dicing_rate") * dicing_rate);
- sdparams.dicing_rate = max(0.1f, RNA_float_get(&cobj, "dicing_rate") * dicing_rate);
- sdparams.max_level = max_subdivisions;
-
- sdparams.objecttoworld = get_transform(b_ob.matrix_world());
+ mesh->set_subd_dicing_rate(subd_dicing_rate);
+ mesh->set_subd_max_level(max_subdivisions);
+ mesh->set_subd_objecttoworld(get_transform(b_ob.matrix_world()));
}
/* Sync */
@@ -955,14 +949,14 @@ static void sync_mesh_cached_velocities(BL::Object &b_ob, Scene *scene, Mesh *me
return;
}
- const size_t numverts = mesh->verts.size();
+ const size_t numverts = mesh->get_verts().size();
if (b_mesh_cache.vertex_velocities.length() != numverts) {
return;
}
/* Find or add attribute */
- float3 *P = &mesh->verts[0];
+ float3 *P = &mesh->get_verts()[0];
Attribute *attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
if (!attr_mP) {
@@ -996,11 +990,11 @@ static void sync_mesh_fluid_motion(BL::Object &b_ob, Scene *scene, Mesh *mesh)
return;
/* If the mesh has modifiers following the fluid domain we can't export motion. */
- if (b_fluid_domain.mesh_vertices.length() != mesh->verts.size())
+ if (b_fluid_domain.mesh_vertices.length() != mesh->get_verts().size())
return;
/* Find or add attribute */
- float3 *P = &mesh->verts[0];
+ float3 *P = &mesh->get_verts()[0];
Attribute *attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
if (!attr_mP) {
@@ -1011,7 +1005,7 @@ static void sync_mesh_fluid_motion(BL::Object &b_ob, Scene *scene, Mesh *mesh)
float motion_times[2] = {-1.0f, 1.0f};
for (int step = 0; step < 2; step++) {
float relative_time = motion_times[step] * scene->motion_shutter_time() * 0.5f;
- float3 *mP = attr_mP->data_float3() + step * mesh->verts.size();
+ float3 *mP = attr_mP->data_float3() + step * mesh->get_verts().size();
BL::FluidDomainSettings::mesh_vertices_iterator svi;
int i = 0;
@@ -1026,53 +1020,68 @@ static void sync_mesh_fluid_motion(BL::Object &b_ob, Scene *scene, Mesh *mesh)
void BlenderSync::sync_mesh(BL::Depsgraph b_depsgraph,
BL::Object b_ob,
Mesh *mesh,
- const vector<Shader *> &used_shaders)
+ array<Node *> &used_shaders)
{
- array<int> oldtriangles;
- array<Mesh::SubdFace> oldsubd_faces;
- array<int> oldsubd_face_corners;
- oldtriangles.steal_data(mesh->triangles);
- oldsubd_faces.steal_data(mesh->subd_faces);
- oldsubd_face_corners.steal_data(mesh->subd_face_corners);
-
- mesh->clear();
- mesh->used_shaders = used_shaders;
-
- mesh->subdivision_type = Mesh::SUBDIVISION_NONE;
+ Mesh new_mesh;
+ new_mesh.set_used_shaders(used_shaders);
if (view_layer.use_surfaces) {
/* Adaptive subdivision setup. Not for baking since that requires
* exact mapping to the Blender mesh. */
if (!scene->bake_manager->get_baking()) {
- mesh->subdivision_type = object_subdivision_type(b_ob, preview, experimental);
+ new_mesh.set_subdivision_type(object_subdivision_type(b_ob, preview, experimental));
}
/* For some reason, meshes do not need this... */
- bool need_undeformed = mesh->need_attribute(scene, ATTR_STD_GENERATED);
+ bool need_undeformed = new_mesh.need_attribute(scene, ATTR_STD_GENERATED);
BL::Mesh b_mesh = object_to_mesh(
- b_data, b_ob, b_depsgraph, need_undeformed, mesh->subdivision_type);
+ b_data, b_ob, b_depsgraph, need_undeformed, new_mesh.get_subdivision_type());
if (b_mesh) {
/* Sync mesh itself. */
- if (mesh->subdivision_type != Mesh::SUBDIVISION_NONE)
- create_subd_mesh(
- scene, mesh, b_ob, b_mesh, mesh->used_shaders, dicing_rate, max_subdivisions);
+ if (new_mesh.get_subdivision_type() != Mesh::SUBDIVISION_NONE)
+ create_subd_mesh(scene,
+ &new_mesh,
+ b_ob,
+ b_mesh,
+ new_mesh.get_used_shaders(),
+ dicing_rate,
+ max_subdivisions);
else
- create_mesh(scene, mesh, b_mesh, mesh->used_shaders, false);
+ create_mesh(scene, &new_mesh, b_mesh, new_mesh.get_used_shaders(), false);
free_object_to_mesh(b_data, b_ob, b_mesh);
}
}
/* cached velocities (e.g. from alembic archive) */
- sync_mesh_cached_velocities(b_ob, scene, mesh);
+ sync_mesh_cached_velocities(b_ob, scene, &new_mesh);
/* mesh fluid motion mantaflow */
- sync_mesh_fluid_motion(b_ob, scene, mesh);
+ sync_mesh_fluid_motion(b_ob, scene, &new_mesh);
+
+ /* update original sockets */
+
+ for (const SocketType &socket : new_mesh.type->inputs) {
+ mesh->set_value(socket, new_mesh, socket);
+ }
+
+ foreach (Attribute &attr, new_mesh.attributes.attributes) {
+ mesh->attributes.attributes.push_back(std::move(attr));
+ }
+
+ foreach (Attribute &attr, new_mesh.subd_attributes.attributes) {
+ mesh->subd_attributes.attributes.push_back(std::move(attr));
+ }
+
+ mesh->set_num_subd_faces(new_mesh.get_num_subd_faces());
/* tag update */
- bool rebuild = (oldtriangles != mesh->triangles) || (oldsubd_faces != mesh->subd_faces) ||
- (oldsubd_face_corners != mesh->subd_face_corners);
+ bool rebuild = (mesh->triangles_is_modified()) || (mesh->subd_num_corners_is_modified()) ||
+ (mesh->subd_shader_is_modified()) || (mesh->subd_smooth_is_modified()) ||
+ (mesh->subd_ptex_offset_is_modified()) ||
+ (mesh->subd_start_corner_is_modified()) ||
+ (mesh->subd_face_corners_is_modified());
mesh->tag_update(scene, rebuild);
}
@@ -1095,7 +1104,7 @@ void BlenderSync::sync_mesh_motion(BL::Depsgraph b_depsgraph,
}
/* Skip if no vertices were exported. */
- size_t numverts = mesh->verts.size();
+ size_t numverts = mesh->get_verts().size();
if (numverts == 0) {
return;
}
@@ -1140,7 +1149,7 @@ void BlenderSync::sync_mesh_motion(BL::Depsgraph b_depsgraph,
if (new_attribute) {
/* In case of new attribute, we verify if there really was any motion. */
if (b_mesh.vertices.length() != numverts ||
- memcmp(mP, &mesh->verts[0], sizeof(float3) * numverts) == 0) {
+ memcmp(mP, &mesh->get_verts()[0], sizeof(float3) * numverts) == 0) {
/* no motion, remove attributes again */
if (b_mesh.vertices.length() != numverts) {
VLOG(1) << "Topology differs, disabling motion blur for object " << b_ob.name();
@@ -1156,7 +1165,7 @@ void BlenderSync::sync_mesh_motion(BL::Depsgraph b_depsgraph,
VLOG(1) << "Filling deformation motion for object " << b_ob.name();
/* motion, fill up previous steps that we might have skipped because
* they had no motion, but we need them anyway now */
- float3 *P = &mesh->verts[0];
+ float3 *P = &mesh->get_verts()[0];
float3 *N = (attr_N) ? attr_N->data_float3() : NULL;
for (int step = 0; step < motion_step; step++) {
memcpy(attr_mP->data_float3() + step * numverts, P, sizeof(float3) * numverts);
@@ -1169,7 +1178,7 @@ void BlenderSync::sync_mesh_motion(BL::Depsgraph b_depsgraph,
if (b_mesh.vertices.length() != numverts) {
VLOG(1) << "Topology differs, discarding motion blur for object " << b_ob.name()
<< " at time " << motion_step;
- memcpy(mP, &mesh->verts[0], sizeof(float3) * numverts);
+ memcpy(mP, &mesh->get_verts()[0], sizeof(float3) * numverts);
if (mN != NULL) {
memcpy(mN, attr_N->data_float3(), sizeof(float3) * numverts);
}
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index 23faacc15da..609ca8f6f79 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -199,11 +199,13 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
/* Set transform at matching motion time step. */
int time_index = object->motion_step(motion_time);
if (time_index >= 0) {
- object->motion[time_index] = tfm;
+ array<Transform> motion = object->get_motion();
+ motion[time_index] = tfm;
+ object->set_motion(motion);
}
/* mesh deformation */
- if (object->geometry)
+ if (object->get_geometry())
sync_geometry_motion(b_depsgraph,
b_ob_instance,
object,
@@ -225,38 +227,29 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
/* b_ob is owned by the iterator and will go out of scope at the end of the block.
* b_ob_instance is the original object and will remain valid for deferred geometry
* sync. */
- object->geometry = sync_geometry(b_depsgraph,
- b_ob_instance,
- b_ob_instance,
- object_updated,
- use_particle_hair,
- object_geom_task_pool);
+ Geometry *geometry = sync_geometry(b_depsgraph,
+ b_ob_instance,
+ b_ob_instance,
+ object_updated,
+ use_particle_hair,
+ object_geom_task_pool);
+ object->set_geometry(geometry);
/* special case not tracked by object update flags */
/* holdout */
- if (use_holdout != object->use_holdout) {
- object->use_holdout = use_holdout;
+ object->set_use_holdout(use_holdout);
+ if (object->use_holdout_is_modified()) {
scene->object_manager->tag_update(scene);
- object_updated = true;
}
- if (visibility != object->visibility) {
- object->visibility = visibility;
- object_updated = true;
- }
+ object->set_visibility(visibility);
bool is_shadow_catcher = get_boolean(cobject, "is_shadow_catcher");
- if (is_shadow_catcher != object->is_shadow_catcher) {
- object->is_shadow_catcher = is_shadow_catcher;
- object_updated = true;
- }
+ object->set_is_shadow_catcher(is_shadow_catcher);
float shadow_terminator_offset = get_float(cobject, "shadow_terminator_offset");
- if (shadow_terminator_offset != object->shadow_terminator_offset) {
- object->shadow_terminator_offset = shadow_terminator_offset;
- object_updated = true;
- }
+ object->set_shadow_terminator_offset(shadow_terminator_offset);
/* sync the asset name for Cryptomatte */
BL::Object parent = b_ob.parent();
@@ -270,48 +263,49 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
else {
parent_name = b_ob.name();
}
- if (object->asset_name != parent_name) {
- object->asset_name = parent_name;
- object_updated = true;
- }
+ object->set_asset_name(parent_name);
/* object sync
* transform comparison should not be needed, but duplis don't work perfect
* in the depsgraph and may not signal changes, so this is a workaround */
- if (object_updated || (object->geometry && object->geometry->need_update) ||
- tfm != object->tfm) {
+ if (object->is_modified() || object_updated ||
+ (object->get_geometry() && object->get_geometry()->is_modified()) ||
+ tfm != object->get_tfm()) {
object->name = b_ob.name().c_str();
- object->pass_id = b_ob.pass_index();
- object->color = get_float3(b_ob.color());
- object->tfm = tfm;
- object->motion.clear();
+ object->set_pass_id(b_ob.pass_index());
+ object->set_color(get_float3(b_ob.color()));
+ object->set_tfm(tfm);
+ array<Transform> motion;
+ object->set_motion(motion);
/* motion blur */
Scene::MotionType need_motion = scene->need_motion();
- if (need_motion != Scene::MOTION_NONE && object->geometry) {
- Geometry *geom = object->geometry;
- geom->use_motion_blur = false;
- geom->motion_steps = 0;
+ if (need_motion != Scene::MOTION_NONE && object->get_geometry()) {
+ Geometry *geom = object->get_geometry();
+ geom->set_use_motion_blur(false);
+ geom->set_motion_steps(0);
uint motion_steps;
if (need_motion == Scene::MOTION_BLUR) {
motion_steps = object_motion_steps(b_parent, b_ob, Object::MAX_MOTION_STEPS);
- geom->motion_steps = motion_steps;
+ geom->set_motion_steps(motion_steps);
if (motion_steps && object_use_deform_motion(b_parent, b_ob)) {
- geom->use_motion_blur = true;
+ geom->set_use_motion_blur(true);
}
}
else {
motion_steps = 3;
- geom->motion_steps = motion_steps;
+ geom->set_motion_steps(motion_steps);
}
- object->motion.clear();
- object->motion.resize(motion_steps, transform_empty());
+ motion.resize(motion_steps, transform_empty());
if (motion_steps) {
- object->motion[motion_steps / 2] = tfm;
+ motion[motion_steps / 2] = tfm;
+
+ /* update motion socket before trying to access object->motion_time */
+ object->set_motion(motion);
for (size_t step = 0; step < motion_steps; step++) {
motion_times.insert(object->motion_time(step));
@@ -321,15 +315,15 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
/* dupli texture coordinates and random_id */
if (is_instance) {
- object->dupli_generated = 0.5f * get_float3(b_instance.orco()) -
- make_float3(0.5f, 0.5f, 0.5f);
- object->dupli_uv = get_float2(b_instance.uv());
- object->random_id = b_instance.random_id();
+ object->set_dupli_generated(0.5f * get_float3(b_instance.orco()) -
+ make_float3(0.5f, 0.5f, 0.5f));
+ object->set_dupli_uv(get_float2(b_instance.uv()));
+ object->set_random_id(b_instance.random_id());
}
else {
- object->dupli_generated = make_float3(0.0f, 0.0f, 0.0f);
- object->dupli_uv = make_float2(0.0f, 0.0f);
- object->random_id = hash_uint2(hash_string(object->name.c_str()), 0);
+ object->set_dupli_generated(make_float3(0.0f, 0.0f, 0.0f));
+ object->set_dupli_uv(make_float2(0.0f, 0.0f));
+ object->set_random_id(hash_uint2(hash_string(object->name.c_str()), 0));
}
object->tag_update(scene);
@@ -461,20 +455,18 @@ void BlenderSync::sync_motion(BL::RenderSettings &b_render,
if (b_override)
b_cam = b_override;
- Camera prevcam = *(scene->camera);
-
int frame_center = b_scene.frame_current();
float subframe_center = b_scene.frame_subframe();
float frame_center_delta = 0.0f;
if (scene->need_motion() != Scene::MOTION_PASS &&
- scene->camera->motion_position != Camera::MOTION_POSITION_CENTER) {
- float shuttertime = scene->camera->shuttertime;
- if (scene->camera->motion_position == Camera::MOTION_POSITION_END) {
+ scene->camera->get_motion_position() != Camera::MOTION_POSITION_CENTER) {
+ float shuttertime = scene->camera->get_shuttertime();
+ if (scene->camera->get_motion_position() == Camera::MOTION_POSITION_END) {
frame_center_delta = -shuttertime * 0.5f;
}
else {
- assert(scene->camera->motion_position == Camera::MOTION_POSITION_START);
+ assert(scene->camera->get_motion_position() == Camera::MOTION_POSITION_START);
frame_center_delta = shuttertime * 0.5f;
}
@@ -535,10 +527,6 @@ void BlenderSync::sync_motion(BL::RenderSettings &b_render,
python_thread_state_restore(python_thread_state);
b_engine.frame_set(frame_center, subframe_center);
python_thread_state_save(python_thread_state);
-
- /* tag camera for motion update */
- if (scene->camera->motion_modified(prevcam))
- scene->camera->tag_update();
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/blender/blender_object_cull.cpp b/intern/cycles/blender/blender_object_cull.cpp
index bebecb364eb..cb7827b3c4a 100644
--- a/intern/cycles/blender/blender_object_cull.cpp
+++ b/intern/cycles/blender/blender_object_cull.cpp
@@ -34,10 +34,10 @@ BlenderObjectCulling::BlenderObjectCulling(Scene *scene, BL::Scene &b_scene)
if (b_scene.render().use_simplify()) {
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
- use_scene_camera_cull_ = scene->camera->type != CAMERA_PANORAMA &&
+ use_scene_camera_cull_ = scene->camera->get_camera_type() != CAMERA_PANORAMA &&
!b_scene.render().use_multiview() &&
get_boolean(cscene, "use_camera_cull");
- use_scene_distance_cull_ = scene->camera->type != CAMERA_PANORAMA &&
+ use_scene_distance_cull_ = scene->camera->get_camera_type() != CAMERA_PANORAMA &&
!b_scene.render().use_multiview() &&
get_boolean(cscene, "use_distance_cull");
@@ -123,7 +123,7 @@ bool BlenderObjectCulling::test_camera(Scene *scene, float3 bb[8])
bool BlenderObjectCulling::test_distance(Scene *scene, float3 bb[8])
{
- float3 camera_position = transform_get_column(&scene->camera->matrix, 3);
+ float3 camera_position = transform_get_column(&scene->camera->get_matrix(), 3);
float3 bb_min = make_float3(FLT_MAX, FLT_MAX, FLT_MAX),
bb_max = make_float3(-FLT_MAX, -FLT_MAX, -FLT_MAX);
diff --git a/intern/cycles/blender/blender_particles.cpp b/intern/cycles/blender/blender_particles.cpp
index ee14217988b..6f9a0da9d67 100644
--- a/intern/cycles/blender/blender_particles.cpp
+++ b/intern/cycles/blender/blender_particles.cpp
@@ -36,10 +36,10 @@ bool BlenderSync::sync_dupli_particle(BL::Object &b_ob,
if (!b_psys)
return false;
- object->hide_on_missing_motion = true;
+ object->set_hide_on_missing_motion(true);
/* test if we need particle data */
- if (!object->geometry->need_attribute(scene, ATTR_STD_PARTICLE))
+ if (!object->get_geometry()->need_attribute(scene, ATTR_STD_PARTICLE))
return false;
/* don't handle child particles yet */
@@ -57,7 +57,8 @@ bool BlenderSync::sync_dupli_particle(BL::Object &b_ob,
scene, &psys, b_ob, b_instance.object(), key);
/* no update needed? */
- if (!need_update && !object->geometry->need_update && !scene->object_manager->need_update)
+ if (!need_update && !object->get_geometry()->is_modified() &&
+ !scene->object_manager->need_update)
return true;
/* first time used in this sync loop? clear and tag update */
@@ -81,10 +82,11 @@ bool BlenderSync::sync_dupli_particle(BL::Object &b_ob,
psys->particles.push_back_slow(pa);
- if (object->particle_index != psys->particles.size() - 1)
+ object->set_particle_system(psys);
+ object->set_particle_index(psys->particles.size() - 1);
+
+ if (object->particle_index_is_modified())
scene->object_manager->tag_update(scene);
- object->particle_system = psys;
- object->particle_index = psys->particles.size() - 1;
/* return that this object has particle data */
return true;
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index c2bdec0e53d..4b7d2265092 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -441,17 +441,17 @@ void BlenderSession::stamp_view_layer_metadata(Scene *scene, const string &view_
}
/* Write cryptomatte metadata. */
- if (scene->film->cryptomatte_passes & CRYPT_OBJECT) {
+ if (scene->film->get_cryptomatte_passes() & CRYPT_OBJECT) {
add_cryptomatte_layer(b_rr,
view_layer_name + ".CryptoObject",
scene->object_manager->get_cryptomatte_objects(scene));
}
- if (scene->film->cryptomatte_passes & CRYPT_MATERIAL) {
+ if (scene->film->get_cryptomatte_passes() & CRYPT_MATERIAL) {
add_cryptomatte_layer(b_rr,
view_layer_name + ".CryptoMaterial",
scene->shader_manager->get_cryptomatte_materials(scene));
}
- if (scene->film->cryptomatte_passes & CRYPT_ASSET) {
+ if (scene->film->get_cryptomatte_passes() & CRYPT_ASSET) {
add_cryptomatte_layer(b_rr,
view_layer_name + ".CryptoAsset",
scene->object_manager->get_cryptomatte_assets(scene));
@@ -502,9 +502,9 @@ void BlenderSession::render(BL::Depsgraph &b_depsgraph_)
/* Set buffer params, using film settings from sync_render_passes. */
buffer_params.passes = passes;
- buffer_params.denoising_data_pass = scene->film->denoising_data_pass;
- buffer_params.denoising_clean_pass = scene->film->denoising_clean_pass;
- buffer_params.denoising_prefiltered_pass = scene->film->denoising_prefiltered_pass;
+ buffer_params.denoising_data_pass = scene->film->get_denoising_data_pass();
+ buffer_params.denoising_clean_pass = scene->film->get_denoising_clean_pass();
+ buffer_params.denoising_prefiltered_pass = scene->film->get_denoising_prefiltered_pass();
BL::RenderResult::views_iterator b_view_iter;
@@ -541,8 +541,9 @@ void BlenderSession::render(BL::Depsgraph &b_depsgraph_)
/* Make sure all views have different noise patterns. - hardcoded value just to make it random
*/
if (view_index != 0) {
- scene->integrator->seed += hash_uint2(scene->integrator->seed,
- hash_uint2(view_index * 0xdeadbeef, 0));
+ int seed = scene->integrator->get_seed();
+ seed += hash_uint2(seed, hash_uint2(view_index * 0xdeadbeef, 0));
+ scene->integrator->set_seed(seed);
scene->integrator->tag_update(scene);
}
@@ -714,7 +715,7 @@ void BlenderSession::do_write_update_render_result(BL::RenderLayer &b_rlay,
if (!buffers->copy_from_device())
return;
- float exposure = scene->film->exposure;
+ float exposure = scene->film->get_exposure();
vector<float> pixels(rtile.w * rtile.h * 4);
@@ -831,10 +832,7 @@ void BlenderSession::synchronize(BL::Depsgraph &b_depsgraph_)
session->set_denoising(session_params.denoising);
/* Update film if denoising data was enabled or disabled. */
- if (scene->film->denoising_data_pass != buffer_params.denoising_data_pass) {
- scene->film->denoising_data_pass = buffer_params.denoising_data_pass;
- scene->film->tag_update(scene);
- }
+ scene->film->set_denoising_data_pass(buffer_params.denoising_data_pass);
/* reset if needed */
if (scene->need_reset()) {
@@ -893,7 +891,7 @@ bool BlenderSession::draw(int w, int h)
sync->sync_view(b_v3d, b_rv3d, width, height);
- if (scene->camera->need_update)
+ if (scene->camera->is_modified())
reset = true;
session->scene->mutex.unlock();
@@ -1108,8 +1106,11 @@ void BlenderSession::update_resumable_tile_manager(int num_samples)
VLOG(1) << "Samples range start is " << range_start_sample << ", "
<< "number of samples to render is " << range_num_samples;
- scene->integrator->start_sample = rounded_range_start_sample;
- scene->integrator->tag_update(scene);
+ scene->integrator->set_start_sample(rounded_range_start_sample);
+
+ if (scene->integrator->is_modified()) {
+ scene->integrator->tag_update(scene);
+ }
session->tile_manager.range_start_sample = rounded_range_start_sample;
session->tile_manager.range_num_samples = rounded_range_num_samples;
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index 03ed88ea9ec..dda8a2aa4f3 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -42,11 +42,11 @@ typedef map<string, ConvertNode *> ProxyMap;
/* Find */
-void BlenderSync::find_shader(BL::ID &id, vector<Shader *> &used_shaders, Shader *default_shader)
+void BlenderSync::find_shader(BL::ID &id, array<Node *> &used_shaders, Shader *default_shader)
{
Shader *shader = (id) ? shader_map.find(id) : default_shader;
- used_shaders.push_back(shader);
+ used_shaders.push_back_slow(shader);
shader->tag_used(scene);
}
@@ -194,19 +194,19 @@ static void set_default_value(ShaderInput *input,
}
}
-static void get_tex_mapping(TextureMapping *mapping, BL::TexMapping &b_mapping)
+static void get_tex_mapping(TextureNode *mapping, BL::TexMapping &b_mapping)
{
if (!b_mapping)
return;
- mapping->translation = get_float3(b_mapping.translation());
- mapping->rotation = get_float3(b_mapping.rotation());
- mapping->scale = get_float3(b_mapping.scale());
- mapping->type = (TextureMapping::Type)b_mapping.vector_type();
+ mapping->set_tex_mapping_translation(get_float3(b_mapping.translation()));
+ mapping->set_tex_mapping_rotation(get_float3(b_mapping.rotation()));
+ mapping->set_tex_mapping_scale(get_float3(b_mapping.scale()));
+ mapping->set_tex_mapping_type((TextureMapping::Type)b_mapping.vector_type());
- mapping->x_mapping = (TextureMapping::Mapping)b_mapping.mapping_x();
- mapping->y_mapping = (TextureMapping::Mapping)b_mapping.mapping_y();
- mapping->z_mapping = (TextureMapping::Mapping)b_mapping.mapping_z();
+ mapping->set_tex_mapping_x_mapping((TextureMapping::Mapping)b_mapping.mapping_x());
+ mapping->set_tex_mapping_y_mapping((TextureMapping::Mapping)b_mapping.mapping_y());
+ mapping->set_tex_mapping_z_mapping((TextureMapping::Mapping)b_mapping.mapping_z());
}
static ShaderNode *add_node(Scene *scene,
@@ -225,34 +225,48 @@ static ShaderNode *add_node(Scene *scene,
BL::ShaderNodeRGBCurve b_curve_node(b_node);
BL::CurveMapping mapping(b_curve_node.mapping());
RGBCurvesNode *curves = graph->create_node<RGBCurvesNode>();
- curvemapping_color_to_array(mapping, curves->curves, RAMP_TABLE_SIZE, true);
- curvemapping_minmax(mapping, true, &curves->min_x, &curves->max_x);
+ array<float3> curve_mapping_curves;
+ float min_x, max_x;
+ curvemapping_color_to_array(mapping, curve_mapping_curves, RAMP_TABLE_SIZE, true);
+ curvemapping_minmax(mapping, true, &min_x, &max_x);
+ curves->set_min_x(min_x);
+ curves->set_max_x(max_x);
+ curves->set_curves(curve_mapping_curves);
node = curves;
}
if (b_node.is_a(&RNA_ShaderNodeVectorCurve)) {
BL::ShaderNodeVectorCurve b_curve_node(b_node);
BL::CurveMapping mapping(b_curve_node.mapping());
VectorCurvesNode *curves = graph->create_node<VectorCurvesNode>();
- curvemapping_color_to_array(mapping, curves->curves, RAMP_TABLE_SIZE, false);
- curvemapping_minmax(mapping, false, &curves->min_x, &curves->max_x);
+ array<float3> curve_mapping_curves;
+ float min_x, max_x;
+ curvemapping_color_to_array(mapping, curve_mapping_curves, RAMP_TABLE_SIZE, false);
+ curvemapping_minmax(mapping, false, &min_x, &max_x);
+ curves->set_min_x(min_x);
+ curves->set_max_x(max_x);
+ curves->set_curves(curve_mapping_curves);
node = curves;
}
else if (b_node.is_a(&RNA_ShaderNodeValToRGB)) {
RGBRampNode *ramp = graph->create_node<RGBRampNode>();
BL::ShaderNodeValToRGB b_ramp_node(b_node);
BL::ColorRamp b_color_ramp(b_ramp_node.color_ramp());
- colorramp_to_array(b_color_ramp, ramp->ramp, ramp->ramp_alpha, RAMP_TABLE_SIZE);
- ramp->interpolate = b_color_ramp.interpolation() != BL::ColorRamp::interpolation_CONSTANT;
+ array<float3> ramp_values;
+ array<float> ramp_alpha;
+ colorramp_to_array(b_color_ramp, ramp_values, ramp_alpha, RAMP_TABLE_SIZE);
+ ramp->set_ramp(ramp_values);
+ ramp->set_ramp_alpha(ramp_alpha);
+ ramp->set_interpolate(b_color_ramp.interpolation() != BL::ColorRamp::interpolation_CONSTANT);
node = ramp;
}
else if (b_node.is_a(&RNA_ShaderNodeRGB)) {
ColorNode *color = graph->create_node<ColorNode>();
- color->value = get_node_output_rgba(b_node, "Color");
+ color->set_value(get_node_output_rgba(b_node, "Color"));
node = color;
}
else if (b_node.is_a(&RNA_ShaderNodeValue)) {
ValueNode *value = graph->create_node<ValueNode>();
- value->value = get_node_output_value(b_node, "Value");
+ value->set_value(get_node_output_value(b_node, "Value"));
node = value;
}
else if (b_node.is_a(&RNA_ShaderNodeCameraData)) {
@@ -270,8 +284,8 @@ static ShaderNode *add_node(Scene *scene,
else if (b_node.is_a(&RNA_ShaderNodeMixRGB)) {
BL::ShaderNodeMixRGB b_mix_node(b_node);
MixNode *mix = graph->create_node<MixNode>();
- mix->type = (NodeMix)b_mix_node.blend_type();
- mix->use_clamp = b_mix_node.use_clamp();
+ mix->set_mix_type((NodeMix)b_mix_node.blend_type());
+ mix->set_use_clamp(b_mix_node.use_clamp());
node = mix;
}
else if (b_node.is_a(&RNA_ShaderNodeSeparateRGB)) {
@@ -301,43 +315,45 @@ static ShaderNode *add_node(Scene *scene,
else if (b_node.is_a(&RNA_ShaderNodeMapRange)) {
BL::ShaderNodeMapRange b_map_range_node(b_node);
MapRangeNode *map_range_node = graph->create_node<MapRangeNode>();
- map_range_node->clamp = b_map_range_node.clamp();
- map_range_node->type = (NodeMapRangeType)b_map_range_node.interpolation_type();
+ map_range_node->set_clamp(b_map_range_node.clamp());
+ map_range_node->set_range_type((NodeMapRangeType)b_map_range_node.interpolation_type());
node = map_range_node;
}
else if (b_node.is_a(&RNA_ShaderNodeClamp)) {
BL::ShaderNodeClamp b_clamp_node(b_node);
ClampNode *clamp_node = graph->create_node<ClampNode>();
- clamp_node->type = (NodeClampType)b_clamp_node.clamp_type();
+ clamp_node->set_clamp_type((NodeClampType)b_clamp_node.clamp_type());
node = clamp_node;
}
else if (b_node.is_a(&RNA_ShaderNodeMath)) {
BL::ShaderNodeMath b_math_node(b_node);
MathNode *math_node = graph->create_node<MathNode>();
- math_node->type = (NodeMathType)b_math_node.operation();
- math_node->use_clamp = b_math_node.use_clamp();
+ math_node->set_math_type((NodeMathType)b_math_node.operation());
+ math_node->set_use_clamp(b_math_node.use_clamp());
node = math_node;
}
else if (b_node.is_a(&RNA_ShaderNodeVectorMath)) {
BL::ShaderNodeVectorMath b_vector_math_node(b_node);
VectorMathNode *vector_math_node = graph->create_node<VectorMathNode>();
- vector_math_node->type = (NodeVectorMathType)b_vector_math_node.operation();
+ vector_math_node->set_math_type((NodeVectorMathType)b_vector_math_node.operation());
node = vector_math_node;
}
else if (b_node.is_a(&RNA_ShaderNodeVectorRotate)) {
BL::ShaderNodeVectorRotate b_vector_rotate_node(b_node);
VectorRotateNode *vector_rotate_node = graph->create_node<VectorRotateNode>();
- vector_rotate_node->type = (NodeVectorRotateType)b_vector_rotate_node.rotation_type();
- vector_rotate_node->invert = b_vector_rotate_node.invert();
+ vector_rotate_node->set_rotate_type(
+ (NodeVectorRotateType)b_vector_rotate_node.rotation_type());
+ vector_rotate_node->set_invert(b_vector_rotate_node.invert());
node = vector_rotate_node;
}
else if (b_node.is_a(&RNA_ShaderNodeVectorTransform)) {
BL::ShaderNodeVectorTransform b_vector_transform_node(b_node);
VectorTransformNode *vtransform = graph->create_node<VectorTransformNode>();
- vtransform->type = (NodeVectorTransformType)b_vector_transform_node.vector_type();
- vtransform->convert_from = (NodeVectorTransformConvertSpace)
- b_vector_transform_node.convert_from();
- vtransform->convert_to = (NodeVectorTransformConvertSpace)b_vector_transform_node.convert_to();
+ vtransform->set_transform_type((NodeVectorTransformType)b_vector_transform_node.vector_type());
+ vtransform->set_convert_from(
+ (NodeVectorTransformConvertSpace)b_vector_transform_node.convert_from());
+ vtransform->set_convert_to(
+ (NodeVectorTransformConvertSpace)b_vector_transform_node.convert_to());
node = vtransform;
}
else if (b_node.is_a(&RNA_ShaderNodeNormal)) {
@@ -345,13 +361,13 @@ static ShaderNode *add_node(Scene *scene,
b_node.outputs.begin(out_it);
NormalNode *norm = graph->create_node<NormalNode>();
- norm->direction = get_node_output_vector(b_node, "Normal");
+ norm->set_direction(get_node_output_vector(b_node, "Normal"));
node = norm;
}
else if (b_node.is_a(&RNA_ShaderNodeMapping)) {
BL::ShaderNodeMapping b_mapping_node(b_node);
MappingNode *mapping = graph->create_node<MappingNode>();
- mapping->type = (NodeMappingType)b_mapping_node.vector_type();
+ mapping->set_mapping_type((NodeMappingType)b_mapping_node.vector_type());
node = mapping;
}
else if (b_node.is_a(&RNA_ShaderNodeFresnel)) {
@@ -369,7 +385,7 @@ static ShaderNode *add_node(Scene *scene,
else if (b_node.is_a(&RNA_ShaderNodeAttribute)) {
BL::ShaderNodeAttribute b_attr_node(b_node);
AttributeNode *attr = graph->create_node<AttributeNode>();
- attr->attribute = b_attr_node.attribute_name();
+ attr->set_attribute(ustring(b_attr_node.attribute_name()));
node = attr;
}
else if (b_node.is_a(&RNA_ShaderNodeBackground)) {
@@ -384,16 +400,16 @@ static ShaderNode *add_node(Scene *scene,
switch (b_aniso_node.distribution()) {
case BL::ShaderNodeBsdfAnisotropic::distribution_BECKMANN:
- aniso->distribution = CLOSURE_BSDF_MICROFACET_BECKMANN_ID;
+ aniso->set_distribution(CLOSURE_BSDF_MICROFACET_BECKMANN_ID);
break;
case BL::ShaderNodeBsdfAnisotropic::distribution_GGX:
- aniso->distribution = CLOSURE_BSDF_MICROFACET_GGX_ID;
+ aniso->set_distribution(CLOSURE_BSDF_MICROFACET_GGX_ID);
break;
case BL::ShaderNodeBsdfAnisotropic::distribution_MULTI_GGX:
- aniso->distribution = CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID;
+ aniso->set_distribution(CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID);
break;
case BL::ShaderNodeBsdfAnisotropic::distribution_ASHIKHMIN_SHIRLEY:
- aniso->distribution = CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID;
+ aniso->set_distribution(CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID);
break;
}
@@ -409,16 +425,16 @@ static ShaderNode *add_node(Scene *scene,
switch (b_subsurface_node.falloff()) {
case BL::ShaderNodeSubsurfaceScattering::falloff_CUBIC:
- subsurface->falloff = CLOSURE_BSSRDF_CUBIC_ID;
+ subsurface->set_falloff(CLOSURE_BSSRDF_CUBIC_ID);
break;
case BL::ShaderNodeSubsurfaceScattering::falloff_GAUSSIAN:
- subsurface->falloff = CLOSURE_BSSRDF_GAUSSIAN_ID;
+ subsurface->set_falloff(CLOSURE_BSSRDF_GAUSSIAN_ID);
break;
case BL::ShaderNodeSubsurfaceScattering::falloff_BURLEY:
- subsurface->falloff = CLOSURE_BSSRDF_BURLEY_ID;
+ subsurface->set_falloff(CLOSURE_BSSRDF_BURLEY_ID);
break;
case BL::ShaderNodeSubsurfaceScattering::falloff_RANDOM_WALK:
- subsurface->falloff = CLOSURE_BSSRDF_RANDOM_WALK_ID;
+ subsurface->set_falloff(CLOSURE_BSSRDF_RANDOM_WALK_ID);
break;
}
@@ -430,19 +446,19 @@ static ShaderNode *add_node(Scene *scene,
switch (b_glossy_node.distribution()) {
case BL::ShaderNodeBsdfGlossy::distribution_SHARP:
- glossy->distribution = CLOSURE_BSDF_REFLECTION_ID;
+ glossy->set_distribution(CLOSURE_BSDF_REFLECTION_ID);
break;
case BL::ShaderNodeBsdfGlossy::distribution_BECKMANN:
- glossy->distribution = CLOSURE_BSDF_MICROFACET_BECKMANN_ID;
+ glossy->set_distribution(CLOSURE_BSDF_MICROFACET_BECKMANN_ID);
break;
case BL::ShaderNodeBsdfGlossy::distribution_GGX:
- glossy->distribution = CLOSURE_BSDF_MICROFACET_GGX_ID;
+ glossy->set_distribution(CLOSURE_BSDF_MICROFACET_GGX_ID);
break;
case BL::ShaderNodeBsdfGlossy::distribution_ASHIKHMIN_SHIRLEY:
- glossy->distribution = CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID;
+ glossy->set_distribution(CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID);
break;
case BL::ShaderNodeBsdfGlossy::distribution_MULTI_GGX:
- glossy->distribution = CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID;
+ glossy->set_distribution(CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID);
break;
}
node = glossy;
@@ -452,16 +468,16 @@ static ShaderNode *add_node(Scene *scene,
GlassBsdfNode *glass = graph->create_node<GlassBsdfNode>();
switch (b_glass_node.distribution()) {
case BL::ShaderNodeBsdfGlass::distribution_SHARP:
- glass->distribution = CLOSURE_BSDF_SHARP_GLASS_ID;
+ glass->set_distribution(CLOSURE_BSDF_SHARP_GLASS_ID);
break;
case BL::ShaderNodeBsdfGlass::distribution_BECKMANN:
- glass->distribution = CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID;
+ glass->set_distribution(CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID);
break;
case BL::ShaderNodeBsdfGlass::distribution_GGX:
- glass->distribution = CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID;
+ glass->set_distribution(CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID);
break;
case BL::ShaderNodeBsdfGlass::distribution_MULTI_GGX:
- glass->distribution = CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID;
+ glass->set_distribution(CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID);
break;
}
node = glass;
@@ -471,13 +487,13 @@ static ShaderNode *add_node(Scene *scene,
RefractionBsdfNode *refraction = graph->create_node<RefractionBsdfNode>();
switch (b_refraction_node.distribution()) {
case BL::ShaderNodeBsdfRefraction::distribution_SHARP:
- refraction->distribution = CLOSURE_BSDF_REFRACTION_ID;
+ refraction->set_distribution(CLOSURE_BSDF_REFRACTION_ID);
break;
case BL::ShaderNodeBsdfRefraction::distribution_BECKMANN:
- refraction->distribution = CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID;
+ refraction->set_distribution(CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID);
break;
case BL::ShaderNodeBsdfRefraction::distribution_GGX:
- refraction->distribution = CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID;
+ refraction->set_distribution(CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID);
break;
}
node = refraction;
@@ -487,10 +503,10 @@ static ShaderNode *add_node(Scene *scene,
ToonBsdfNode *toon = graph->create_node<ToonBsdfNode>();
switch (b_toon_node.component()) {
case BL::ShaderNodeBsdfToon::component_DIFFUSE:
- toon->component = CLOSURE_BSDF_DIFFUSE_TOON_ID;
+ toon->set_component(CLOSURE_BSDF_DIFFUSE_TOON_ID);
break;
case BL::ShaderNodeBsdfToon::component_GLOSSY:
- toon->component = CLOSURE_BSDF_GLOSSY_TOON_ID;
+ toon->set_component(CLOSURE_BSDF_GLOSSY_TOON_ID);
break;
}
node = toon;
@@ -500,10 +516,10 @@ static ShaderNode *add_node(Scene *scene,
HairBsdfNode *hair = graph->create_node<HairBsdfNode>();
switch (b_hair_node.component()) {
case BL::ShaderNodeBsdfHair::component_Reflection:
- hair->component = CLOSURE_BSDF_HAIR_REFLECTION_ID;
+ hair->set_component(CLOSURE_BSDF_HAIR_REFLECTION_ID);
break;
case BL::ShaderNodeBsdfHair::component_Transmission:
- hair->component = CLOSURE_BSDF_HAIR_TRANSMISSION_ID;
+ hair->set_component(CLOSURE_BSDF_HAIR_TRANSMISSION_ID);
break;
}
node = hair;
@@ -511,11 +527,11 @@ static ShaderNode *add_node(Scene *scene,
else if (b_node.is_a(&RNA_ShaderNodeBsdfHairPrincipled)) {
BL::ShaderNodeBsdfHairPrincipled b_principled_hair_node(b_node);
PrincipledHairBsdfNode *principled_hair = graph->create_node<PrincipledHairBsdfNode>();
- principled_hair->parametrization = (NodePrincipledHairParametrization)get_enum(
- b_principled_hair_node.ptr,
- "parametrization",
- NODE_PRINCIPLED_HAIR_NUM,
- NODE_PRINCIPLED_HAIR_REFLECTANCE);
+ principled_hair->set_parametrization(
+ (NodePrincipledHairParametrization)get_enum(b_principled_hair_node.ptr,
+ "parametrization",
+ NODE_PRINCIPLED_HAIR_NUM,
+ NODE_PRINCIPLED_HAIR_REFLECTANCE));
node = principled_hair;
}
else if (b_node.is_a(&RNA_ShaderNodeBsdfPrincipled)) {
@@ -523,18 +539,18 @@ static ShaderNode *add_node(Scene *scene,
PrincipledBsdfNode *principled = graph->create_node<PrincipledBsdfNode>();
switch (b_principled_node.distribution()) {
case BL::ShaderNodeBsdfPrincipled::distribution_GGX:
- principled->distribution = CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID;
+ principled->set_distribution(CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID);
break;
case BL::ShaderNodeBsdfPrincipled::distribution_MULTI_GGX:
- principled->distribution = CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID;
+ principled->set_distribution(CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID);
break;
}
switch (b_principled_node.subsurface_method()) {
case BL::ShaderNodeBsdfPrincipled::subsurface_method_BURLEY:
- principled->subsurface_method = CLOSURE_BSSRDF_PRINCIPLED_ID;
+ principled->set_subsurface_method(CLOSURE_BSSRDF_PRINCIPLED_ID);
break;
case BL::ShaderNodeBsdfPrincipled::subsurface_method_RANDOM_WALK:
- principled->subsurface_method = CLOSURE_BSSRDF_PRINCIPLED_RANDOM_WALK_ID;
+ principled->set_subsurface_method(CLOSURE_BSSRDF_PRINCIPLED_RANDOM_WALK_ID);
break;
}
node = principled;
@@ -554,9 +570,9 @@ static ShaderNode *add_node(Scene *scene,
else if (b_node.is_a(&RNA_ShaderNodeAmbientOcclusion)) {
BL::ShaderNodeAmbientOcclusion b_ao_node(b_node);
AmbientOcclusionNode *ao = graph->create_node<AmbientOcclusionNode>();
- ao->samples = b_ao_node.samples();
- ao->inside = b_ao_node.inside();
- ao->only_local = b_ao_node.only_local();
+ ao->set_samples(b_ao_node.samples());
+ ao->set_inside(b_ao_node.inside());
+ ao->set_only_local(b_ao_node.only_local());
node = ao;
}
else if (b_node.is_a(&RNA_ShaderNodeVolumeScatter)) {
@@ -575,7 +591,7 @@ static ShaderNode *add_node(Scene *scene,
else if (b_node.is_a(&RNA_ShaderNodeWireframe)) {
BL::ShaderNodeWireframe b_wireframe_node(b_node);
WireframeNode *wire = graph->create_node<WireframeNode>();
- wire->use_pixel_size = b_wireframe_node.use_pixel_size();
+ wire->set_use_pixel_size(b_wireframe_node.use_pixel_size());
node = wire;
}
else if (b_node.is_a(&RNA_ShaderNodeWavelength)) {
@@ -605,13 +621,13 @@ static ShaderNode *add_node(Scene *scene,
else if (b_node.is_a(&RNA_ShaderNodeVertexColor)) {
BL::ShaderNodeVertexColor b_vertex_color_node(b_node);
VertexColorNode *vertex_color_node = graph->create_node<VertexColorNode>();
- vertex_color_node->layer_name = b_vertex_color_node.layer_name();
+ vertex_color_node->set_layer_name(ustring(b_vertex_color_node.layer_name()));
node = vertex_color_node;
}
else if (b_node.is_a(&RNA_ShaderNodeBump)) {
BL::ShaderNodeBump b_bump_node(b_node);
BumpNode *bump = graph->create_node<BumpNode>();
- bump->invert = b_bump_node.invert();
+ bump->set_invert(b_bump_node.invert());
node = bump;
}
else if (b_node.is_a(&RNA_ShaderNodeScript)) {
@@ -644,25 +660,26 @@ static ShaderNode *add_node(Scene *scene,
BL::ImageUser b_image_user(b_image_node.image_user());
ImageTextureNode *image = graph->create_node<ImageTextureNode>();
- image->interpolation = get_image_interpolation(b_image_node);
- image->extension = get_image_extension(b_image_node);
- image->projection = (NodeImageProjection)b_image_node.projection();
- image->projection_blend = b_image_node.projection_blend();
+ image->set_interpolation(get_image_interpolation(b_image_node));
+ image->set_extension(get_image_extension(b_image_node));
+ image->set_projection((NodeImageProjection)b_image_node.projection());
+ image->set_projection_blend(b_image_node.projection_blend());
BL::TexMapping b_texture_mapping(b_image_node.texture_mapping());
- get_tex_mapping(&image->tex_mapping, b_texture_mapping);
+ get_tex_mapping(image, b_texture_mapping);
if (b_image) {
PointerRNA colorspace_ptr = b_image.colorspace_settings().ptr;
- image->colorspace = get_enum_identifier(colorspace_ptr, "name");
+ image->set_colorspace(ustring(get_enum_identifier(colorspace_ptr, "name")));
- image->animated = b_image_node.image_user().use_auto_refresh();
- image->alpha_type = get_image_alpha_type(b_image);
+ image->set_animated(b_image_node.image_user().use_auto_refresh());
+ image->set_alpha_type(get_image_alpha_type(b_image));
- image->tiles.clear();
+ array<int> tiles;
BL::Image::tiles_iterator b_iter;
for (b_image.tiles.begin(b_iter); b_iter != b_image.tiles.end(); ++b_iter) {
- image->tiles.push_back(b_iter->number());
+ tiles.push_back_slow(b_iter->number());
}
+ image->set_tiles(tiles);
/* builtin images will use callback-based reading because
* they could only be loaded correct from blender side
@@ -684,8 +701,9 @@ static ShaderNode *add_node(Scene *scene,
new BlenderImageLoader(b_image, image_frame), image->image_params());
}
else {
- image->filename = image_user_file_path(
- b_image_user, b_image, b_scene.frame_current(), true);
+ ustring filename = ustring(
+ image_user_file_path(b_image_user, b_image, b_scene.frame_current(), true));
+ image->set_filename(filename);
}
}
node = image;
@@ -696,17 +714,17 @@ static ShaderNode *add_node(Scene *scene,
BL::ImageUser b_image_user(b_env_node.image_user());
EnvironmentTextureNode *env = graph->create_node<EnvironmentTextureNode>();
- env->interpolation = get_image_interpolation(b_env_node);
- env->projection = (NodeEnvironmentProjection)b_env_node.projection();
+ env->set_interpolation(get_image_interpolation(b_env_node));
+ env->set_projection((NodeEnvironmentProjection)b_env_node.projection());
BL::TexMapping b_texture_mapping(b_env_node.texture_mapping());
- get_tex_mapping(&env->tex_mapping, b_texture_mapping);
+ get_tex_mapping(env, b_texture_mapping);
if (b_image) {
PointerRNA colorspace_ptr = b_image.colorspace_settings().ptr;
- env->colorspace = get_enum_identifier(colorspace_ptr, "name");
+ env->set_colorspace(ustring(get_enum_identifier(colorspace_ptr, "name")));
- env->animated = b_env_node.image_user().use_auto_refresh();
- env->alpha_type = get_image_alpha_type(b_image);
+ env->set_animated(b_env_node.image_user().use_auto_refresh());
+ env->set_alpha_type(get_image_alpha_type(b_image));
bool is_builtin = b_image.packed_file() || b_image.source() == BL::Image::source_GENERATED ||
b_image.source() == BL::Image::source_MOVIE ||
@@ -719,8 +737,8 @@ static ShaderNode *add_node(Scene *scene,
env->image_params());
}
else {
- env->filename = image_user_file_path(
- b_image_user, b_image, b_scene.frame_current(), false);
+ env->set_filename(
+ ustring(image_user_file_path(b_image_user, b_image, b_scene.frame_current(), false)));
}
}
node = env;
@@ -728,103 +746,103 @@ static ShaderNode *add_node(Scene *scene,
else if (b_node.is_a(&RNA_ShaderNodeTexGradient)) {
BL::ShaderNodeTexGradient b_gradient_node(b_node);
GradientTextureNode *gradient = graph->create_node<GradientTextureNode>();
- gradient->type = (NodeGradientType)b_gradient_node.gradient_type();
+ gradient->set_gradient_type((NodeGradientType)b_gradient_node.gradient_type());
BL::TexMapping b_texture_mapping(b_gradient_node.texture_mapping());
- get_tex_mapping(&gradient->tex_mapping, b_texture_mapping);
+ get_tex_mapping(gradient, b_texture_mapping);
node = gradient;
}
else if (b_node.is_a(&RNA_ShaderNodeTexVoronoi)) {
BL::ShaderNodeTexVoronoi b_voronoi_node(b_node);
VoronoiTextureNode *voronoi = graph->create_node<VoronoiTextureNode>();
- voronoi->dimensions = b_voronoi_node.voronoi_dimensions();
- voronoi->feature = (NodeVoronoiFeature)b_voronoi_node.feature();
- voronoi->metric = (NodeVoronoiDistanceMetric)b_voronoi_node.distance();
+ voronoi->set_dimensions(b_voronoi_node.voronoi_dimensions());
+ voronoi->set_feature((NodeVoronoiFeature)b_voronoi_node.feature());
+ voronoi->set_metric((NodeVoronoiDistanceMetric)b_voronoi_node.distance());
BL::TexMapping b_texture_mapping(b_voronoi_node.texture_mapping());
- get_tex_mapping(&voronoi->tex_mapping, b_texture_mapping);
+ get_tex_mapping(voronoi, b_texture_mapping);
node = voronoi;
}
else if (b_node.is_a(&RNA_ShaderNodeTexMagic)) {
BL::ShaderNodeTexMagic b_magic_node(b_node);
MagicTextureNode *magic = graph->create_node<MagicTextureNode>();
- magic->depth = b_magic_node.turbulence_depth();
+ magic->set_depth(b_magic_node.turbulence_depth());
BL::TexMapping b_texture_mapping(b_magic_node.texture_mapping());
- get_tex_mapping(&magic->tex_mapping, b_texture_mapping);
+ get_tex_mapping(magic, b_texture_mapping);
node = magic;
}
else if (b_node.is_a(&RNA_ShaderNodeTexWave)) {
BL::ShaderNodeTexWave b_wave_node(b_node);
WaveTextureNode *wave = graph->create_node<WaveTextureNode>();
- wave->type = (NodeWaveType)b_wave_node.wave_type();
- wave->bands_direction = (NodeWaveBandsDirection)b_wave_node.bands_direction();
- wave->rings_direction = (NodeWaveRingsDirection)b_wave_node.rings_direction();
- wave->profile = (NodeWaveProfile)b_wave_node.wave_profile();
+ wave->set_wave_type((NodeWaveType)b_wave_node.wave_type());
+ wave->set_bands_direction((NodeWaveBandsDirection)b_wave_node.bands_direction());
+ wave->set_rings_direction((NodeWaveRingsDirection)b_wave_node.rings_direction());
+ wave->set_profile((NodeWaveProfile)b_wave_node.wave_profile());
BL::TexMapping b_texture_mapping(b_wave_node.texture_mapping());
- get_tex_mapping(&wave->tex_mapping, b_texture_mapping);
+ get_tex_mapping(wave, b_texture_mapping);
node = wave;
}
else if (b_node.is_a(&RNA_ShaderNodeTexChecker)) {
BL::ShaderNodeTexChecker b_checker_node(b_node);
CheckerTextureNode *checker = graph->create_node<CheckerTextureNode>();
BL::TexMapping b_texture_mapping(b_checker_node.texture_mapping());
- get_tex_mapping(&checker->tex_mapping, b_texture_mapping);
+ get_tex_mapping(checker, b_texture_mapping);
node = checker;
}
else if (b_node.is_a(&RNA_ShaderNodeTexBrick)) {
BL::ShaderNodeTexBrick b_brick_node(b_node);
BrickTextureNode *brick = graph->create_node<BrickTextureNode>();
- brick->offset = b_brick_node.offset();
- brick->offset_frequency = b_brick_node.offset_frequency();
- brick->squash = b_brick_node.squash();
- brick->squash_frequency = b_brick_node.squash_frequency();
+ brick->set_offset(b_brick_node.offset());
+ brick->set_offset_frequency(b_brick_node.offset_frequency());
+ brick->set_squash(b_brick_node.squash());
+ brick->set_squash_frequency(b_brick_node.squash_frequency());
BL::TexMapping b_texture_mapping(b_brick_node.texture_mapping());
- get_tex_mapping(&brick->tex_mapping, b_texture_mapping);
+ get_tex_mapping(brick, b_texture_mapping);
node = brick;
}
else if (b_node.is_a(&RNA_ShaderNodeTexNoise)) {
BL::ShaderNodeTexNoise b_noise_node(b_node);
NoiseTextureNode *noise = graph->create_node<NoiseTextureNode>();
- noise->dimensions = b_noise_node.noise_dimensions();
+ noise->set_dimensions(b_noise_node.noise_dimensions());
BL::TexMapping b_texture_mapping(b_noise_node.texture_mapping());
- get_tex_mapping(&noise->tex_mapping, b_texture_mapping);
+ get_tex_mapping(noise, b_texture_mapping);
node = noise;
}
else if (b_node.is_a(&RNA_ShaderNodeTexMusgrave)) {
BL::ShaderNodeTexMusgrave b_musgrave_node(b_node);
MusgraveTextureNode *musgrave_node = graph->create_node<MusgraveTextureNode>();
- musgrave_node->type = (NodeMusgraveType)b_musgrave_node.musgrave_type();
- musgrave_node->dimensions = b_musgrave_node.musgrave_dimensions();
+ musgrave_node->set_musgrave_type((NodeMusgraveType)b_musgrave_node.musgrave_type());
+ musgrave_node->set_dimensions(b_musgrave_node.musgrave_dimensions());
BL::TexMapping b_texture_mapping(b_musgrave_node.texture_mapping());
- get_tex_mapping(&musgrave_node->tex_mapping, b_texture_mapping);
+ get_tex_mapping(musgrave_node, b_texture_mapping);
node = musgrave_node;
}
else if (b_node.is_a(&RNA_ShaderNodeTexCoord)) {
BL::ShaderNodeTexCoord b_tex_coord_node(b_node);
TextureCoordinateNode *tex_coord = graph->create_node<TextureCoordinateNode>();
- tex_coord->from_dupli = b_tex_coord_node.from_instancer();
+ tex_coord->set_from_dupli(b_tex_coord_node.from_instancer());
if (b_tex_coord_node.object()) {
- tex_coord->use_transform = true;
- tex_coord->ob_tfm = get_transform(b_tex_coord_node.object().matrix_world());
+ tex_coord->set_use_transform(true);
+ tex_coord->set_ob_tfm(get_transform(b_tex_coord_node.object().matrix_world()));
}
node = tex_coord;
}
else if (b_node.is_a(&RNA_ShaderNodeTexSky)) {
BL::ShaderNodeTexSky b_sky_node(b_node);
SkyTextureNode *sky = graph->create_node<SkyTextureNode>();
- sky->type = (NodeSkyType)b_sky_node.sky_type();
- sky->sun_direction = normalize(get_float3(b_sky_node.sun_direction()));
- sky->turbidity = b_sky_node.turbidity();
- sky->ground_albedo = b_sky_node.ground_albedo();
- sky->sun_disc = b_sky_node.sun_disc();
- sky->sun_size = b_sky_node.sun_size();
- sky->sun_intensity = b_sky_node.sun_intensity();
- sky->sun_elevation = b_sky_node.sun_elevation();
- sky->sun_rotation = b_sky_node.sun_rotation();
- sky->altitude = 1000.0f * b_sky_node.altitude();
- sky->air_density = b_sky_node.air_density();
- sky->dust_density = b_sky_node.dust_density();
- sky->ozone_density = b_sky_node.ozone_density();
+ sky->set_sky_type((NodeSkyType)b_sky_node.sky_type());
+ sky->set_sun_direction(normalize(get_float3(b_sky_node.sun_direction())));
+ sky->set_turbidity(b_sky_node.turbidity());
+ sky->set_ground_albedo(b_sky_node.ground_albedo());
+ sky->set_sun_disc(b_sky_node.sun_disc());
+ sky->set_sun_size(b_sky_node.sun_size());
+ sky->set_sun_intensity(b_sky_node.sun_intensity());
+ sky->set_sun_elevation(b_sky_node.sun_elevation());
+ sky->set_sun_rotation(b_sky_node.sun_rotation());
+ sky->set_altitude(1000.0f * b_sky_node.altitude());
+ sky->set_air_density(b_sky_node.air_density());
+ sky->set_dust_density(b_sky_node.dust_density());
+ sky->set_ozone_density(b_sky_node.ozone_density());
BL::TexMapping b_texture_mapping(b_sky_node.texture_mapping());
- get_tex_mapping(&sky->tex_mapping, b_texture_mapping);
+ get_tex_mapping(sky, b_texture_mapping);
node = sky;
}
else if (b_node.is_a(&RNA_ShaderNodeTexIES)) {
@@ -832,13 +850,14 @@ static ShaderNode *add_node(Scene *scene,
IESLightNode *ies = graph->create_node<IESLightNode>();
switch (b_ies_node.mode()) {
case BL::ShaderNodeTexIES::mode_EXTERNAL:
- ies->filename = blender_absolute_path(b_data, b_ntree, b_ies_node.filepath());
+ ies->set_filename(ustring(blender_absolute_path(b_data, b_ntree, b_ies_node.filepath())));
break;
case BL::ShaderNodeTexIES::mode_INTERNAL:
- ies->ies = get_text_datablock_content(b_ies_node.ies().ptr);
- if (ies->ies.empty()) {
- ies->ies = "\n";
+ ustring ies_content = ustring(get_text_datablock_content(b_ies_node.ies().ptr));
+ if (ies_content.empty()) {
+ ies_content = "\n";
}
+ ies->set_ies(ies_content);
break;
}
node = ies;
@@ -846,36 +865,36 @@ static ShaderNode *add_node(Scene *scene,
else if (b_node.is_a(&RNA_ShaderNodeTexWhiteNoise)) {
BL::ShaderNodeTexWhiteNoise b_tex_white_noise_node(b_node);
WhiteNoiseTextureNode *white_noise_node = graph->create_node<WhiteNoiseTextureNode>();
- white_noise_node->dimensions = b_tex_white_noise_node.noise_dimensions();
+ white_noise_node->set_dimensions(b_tex_white_noise_node.noise_dimensions());
node = white_noise_node;
}
else if (b_node.is_a(&RNA_ShaderNodeNormalMap)) {
BL::ShaderNodeNormalMap b_normal_map_node(b_node);
NormalMapNode *nmap = graph->create_node<NormalMapNode>();
- nmap->space = (NodeNormalMapSpace)b_normal_map_node.space();
- nmap->attribute = b_normal_map_node.uv_map();
+ nmap->set_space((NodeNormalMapSpace)b_normal_map_node.space());
+ nmap->set_attribute(ustring(b_normal_map_node.uv_map()));
node = nmap;
}
else if (b_node.is_a(&RNA_ShaderNodeTangent)) {
BL::ShaderNodeTangent b_tangent_node(b_node);
TangentNode *tangent = graph->create_node<TangentNode>();
- tangent->direction_type = (NodeTangentDirectionType)b_tangent_node.direction_type();
- tangent->axis = (NodeTangentAxis)b_tangent_node.axis();
- tangent->attribute = b_tangent_node.uv_map();
+ tangent->set_direction_type((NodeTangentDirectionType)b_tangent_node.direction_type());
+ tangent->set_axis((NodeTangentAxis)b_tangent_node.axis());
+ tangent->set_attribute(ustring(b_tangent_node.uv_map()));
node = tangent;
}
else if (b_node.is_a(&RNA_ShaderNodeUVMap)) {
BL::ShaderNodeUVMap b_uvmap_node(b_node);
UVMapNode *uvm = graph->create_node<UVMapNode>();
- uvm->attribute = b_uvmap_node.uv_map();
- uvm->from_dupli = b_uvmap_node.from_instancer();
+ uvm->set_attribute(ustring(b_uvmap_node.uv_map()));
+ uvm->set_from_dupli(b_uvmap_node.from_instancer());
node = uvm;
}
else if (b_node.is_a(&RNA_ShaderNodeTexPointDensity)) {
BL::ShaderNodeTexPointDensity b_point_density_node(b_node);
PointDensityTextureNode *point_density = graph->create_node<PointDensityTextureNode>();
- point_density->space = (NodeTexVoxelSpace)b_point_density_node.space();
- point_density->interpolation = get_image_interpolation(b_point_density_node);
+ point_density->set_space((NodeTexVoxelSpace)b_point_density_node.space());
+ point_density->set_interpolation(get_image_interpolation(b_point_density_node));
point_density->handle = scene->image_manager->add_image(
new BlenderPointDensityLoader(b_depsgraph, b_point_density_node),
point_density->image_params());
@@ -892,33 +911,33 @@ static ShaderNode *add_node(Scene *scene,
if (b_ob) {
float3 loc, size;
point_density_texture_space(b_depsgraph, b_point_density_node, loc, size);
- point_density->tfm = transform_translate(-loc) * transform_scale(size) *
- transform_inverse(get_transform(b_ob.matrix_world()));
+ point_density->set_tfm(transform_translate(-loc) * transform_scale(size) *
+ transform_inverse(get_transform(b_ob.matrix_world())));
}
}
else if (b_node.is_a(&RNA_ShaderNodeBevel)) {
BL::ShaderNodeBevel b_bevel_node(b_node);
BevelNode *bevel = graph->create_node<BevelNode>();
- bevel->samples = b_bevel_node.samples();
+ bevel->set_samples(b_bevel_node.samples());
node = bevel;
}
else if (b_node.is_a(&RNA_ShaderNodeDisplacement)) {
BL::ShaderNodeDisplacement b_disp_node(b_node);
DisplacementNode *disp = graph->create_node<DisplacementNode>();
- disp->space = (NodeNormalMapSpace)b_disp_node.space();
+ disp->set_space((NodeNormalMapSpace)b_disp_node.space());
node = disp;
}
else if (b_node.is_a(&RNA_ShaderNodeVectorDisplacement)) {
BL::ShaderNodeVectorDisplacement b_disp_node(b_node);
VectorDisplacementNode *disp = graph->create_node<VectorDisplacementNode>();
- disp->space = (NodeNormalMapSpace)b_disp_node.space();
- disp->attribute = "";
+ disp->set_space((NodeNormalMapSpace)b_disp_node.space());
+ disp->set_attribute(ustring(""));
node = disp;
}
else if (b_node.is_a(&RNA_ShaderNodeOutputAOV)) {
BL::ShaderNodeOutputAOV b_aov_node(b_node);
OutputAOVNode *aov = graph->create_node<OutputAOVNode>();
- aov->name = b_aov_node.name();
+ aov->set_name(ustring(b_aov_node.name()));
node = aov;
}
@@ -1245,7 +1264,7 @@ void BlenderSync::sync_materials(BL::Depsgraph &b_depsgraph, bool update_all)
ShaderGraph *graph = new ShaderGraph();
shader->name = b_mat.name().c_str();
- shader->pass_id = b_mat.pass_index();
+ shader->set_pass_id(b_mat.pass_index());
/* create nodes */
if (b_mat.use_nodes() && b_mat.node_tree()) {
@@ -1255,7 +1274,7 @@ void BlenderSync::sync_materials(BL::Depsgraph &b_depsgraph, bool update_all)
}
else {
DiffuseBsdfNode *diffuse = graph->create_node<DiffuseBsdfNode>();
- diffuse->color = get_float3(b_mat.diffuse_color());
+ diffuse->set_color(get_float3(b_mat.diffuse_color()));
graph->add(diffuse);
ShaderNode *out = graph->output();
@@ -1264,13 +1283,13 @@ void BlenderSync::sync_materials(BL::Depsgraph &b_depsgraph, bool update_all)
/* settings */
PointerRNA cmat = RNA_pointer_get(&b_mat.ptr, "cycles");
- shader->use_mis = get_boolean(cmat, "sample_as_light");
- shader->use_transparent_shadow = get_boolean(cmat, "use_transparent_shadow");
- shader->heterogeneous_volume = !get_boolean(cmat, "homogeneous_volume");
- shader->volume_sampling_method = get_volume_sampling(cmat);
- shader->volume_interpolation_method = get_volume_interpolation(cmat);
- shader->volume_step_rate = get_float(cmat, "volume_step_rate");
- shader->displacement_method = get_displacement_method(cmat);
+ shader->set_use_mis(get_boolean(cmat, "sample_as_light"));
+ shader->set_use_transparent_shadow(get_boolean(cmat, "use_transparent_shadow"));
+ shader->set_heterogeneous_volume(!get_boolean(cmat, "homogeneous_volume"));
+ shader->set_volume_sampling_method(get_volume_sampling(cmat));
+ shader->set_volume_interpolation_method(get_volume_interpolation(cmat));
+ shader->set_volume_step_rate(get_float(cmat, "volume_step_rate"));
+ shader->set_displacement_method(get_displacement_method(cmat));
shader->set_graph(graph);
@@ -1311,7 +1330,6 @@ void BlenderSync::sync_materials(BL::Depsgraph &b_depsgraph, bool update_all)
void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d, bool update_all)
{
Background *background = scene->background;
- Background prevbackground = *background;
BL::World b_world = b_scene.world();
@@ -1331,14 +1349,14 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d,
/* volume */
PointerRNA cworld = RNA_pointer_get(&b_world.ptr, "cycles");
- shader->heterogeneous_volume = !get_boolean(cworld, "homogeneous_volume");
- shader->volume_sampling_method = get_volume_sampling(cworld);
- shader->volume_interpolation_method = get_volume_interpolation(cworld);
- shader->volume_step_rate = get_float(cworld, "volume_step_size");
+ shader->set_heterogeneous_volume(!get_boolean(cworld, "homogeneous_volume"));
+ shader->set_volume_sampling_method(get_volume_sampling(cworld));
+ shader->set_volume_interpolation_method(get_volume_interpolation(cworld));
+ shader->set_volume_step_rate(get_float(cworld, "volume_step_size"));
}
else if (new_viewport_parameters.use_scene_world && b_world) {
BackgroundNode *background = graph->create_node<BackgroundNode>();
- background->color = get_float3(b_world.color());
+ background->set_color(get_float3(b_world.color()));
graph->add(background);
ShaderNode *out = graph->output();
@@ -1360,29 +1378,32 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d,
graph->add(light_path);
MixNode *mix_scene_with_background = graph->create_node<MixNode>();
- mix_scene_with_background->color2 = world_color;
+ mix_scene_with_background->set_color2(world_color);
graph->add(mix_scene_with_background);
EnvironmentTextureNode *texture_environment = graph->create_node<EnvironmentTextureNode>();
- texture_environment->tex_mapping.type = TextureMapping::VECTOR;
- texture_environment->tex_mapping.rotation[2] = new_viewport_parameters.studiolight_rotate_z;
- texture_environment->filename = new_viewport_parameters.studiolight_path;
+ texture_environment->set_tex_mapping_type(TextureMapping::VECTOR);
+ float3 rotation_z = texture_environment->get_tex_mapping_rotation();
+ rotation_z[2] = new_viewport_parameters.studiolight_rotate_z;
+ texture_environment->set_tex_mapping_rotation(rotation_z);
+ texture_environment->set_filename(new_viewport_parameters.studiolight_path);
graph->add(texture_environment);
MixNode *mix_intensity = graph->create_node<MixNode>();
- mix_intensity->type = NODE_MIX_MUL;
- mix_intensity->fac = 1.0f;
- mix_intensity->color2 = make_float3(new_viewport_parameters.studiolight_intensity,
- new_viewport_parameters.studiolight_intensity,
- new_viewport_parameters.studiolight_intensity);
+ mix_intensity->set_mix_type(NODE_MIX_MUL);
+ mix_intensity->set_fac(1.0f);
+ mix_intensity->set_color2(make_float3(new_viewport_parameters.studiolight_intensity,
+ new_viewport_parameters.studiolight_intensity,
+ new_viewport_parameters.studiolight_intensity));
graph->add(mix_intensity);
TextureCoordinateNode *texture_coordinate = graph->create_node<TextureCoordinateNode>();
graph->add(texture_coordinate);
MixNode *mix_background_with_environment = graph->create_node<MixNode>();
- mix_background_with_environment->fac = new_viewport_parameters.studiolight_background_alpha;
- mix_background_with_environment->color1 = world_color;
+ mix_background_with_environment->set_fac(
+ new_viewport_parameters.studiolight_background_alpha);
+ mix_background_with_environment->set_color1(world_color);
graph->add(mix_background_with_environment);
ShaderNode *out = graph->output();
@@ -1404,9 +1425,9 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d,
/* AO */
BL::WorldLighting b_light = b_world.light_settings();
- background->use_ao = b_light.use_ambient_occlusion();
- background->ao_factor = b_light.ao_factor();
- background->ao_distance = b_light.distance();
+ background->set_use_ao(b_light.use_ambient_occlusion());
+ background->set_ao_factor(b_light.ao_factor());
+ background->set_ao_distance(b_light.distance());
/* visibility */
PointerRNA cvisibility = RNA_pointer_get(&b_world.ptr, "cycles_visibility");
@@ -1418,12 +1439,12 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d,
visibility |= get_boolean(cvisibility, "transmission") ? PATH_RAY_TRANSMIT : 0;
visibility |= get_boolean(cvisibility, "scatter") ? PATH_RAY_VOLUME_SCATTER : 0;
- background->visibility = visibility;
+ background->set_visibility(visibility);
}
else {
- background->use_ao = false;
- background->ao_factor = 0.0f;
- background->ao_distance = FLT_MAX;
+ background->set_use_ao(false);
+ background->set_ao_factor(0.0f);
+ background->set_ao_distance(FLT_MAX);
}
shader->set_graph(graph);
@@ -1432,22 +1453,23 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d,
}
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
- background->transparent = b_scene.render().film_transparent();
+ background->set_transparent(b_scene.render().film_transparent());
- if (background->transparent) {
- background->transparent_glass = get_boolean(cscene, "film_transparent_glass");
- background->transparent_roughness_threshold = get_float(cscene, "film_transparent_roughness");
+ if (background->get_transparent()) {
+ background->set_transparent_glass(get_boolean(cscene, "film_transparent_glass"));
+ background->set_transparent_roughness_threshold(
+ get_float(cscene, "film_transparent_roughness"));
}
else {
- background->transparent_glass = false;
- background->transparent_roughness_threshold = 0.0f;
+ background->set_transparent_glass(false);
+ background->set_transparent_roughness_threshold(0.0f);
}
- background->use_shader = view_layer.use_background_shader |
- viewport_parameters.custom_viewport_parameters();
- background->use_ao = background->use_ao && view_layer.use_background_ao;
+ background->set_use_shader(view_layer.use_background_shader |
+ viewport_parameters.custom_viewport_parameters());
+ background->set_use_ao(background->get_use_ao() && view_layer.use_background_ao);
- if (background->modified(prevbackground))
+ if (background->is_modified())
background->tag_update(scene);
}
@@ -1480,8 +1502,8 @@ void BlenderSync::sync_lights(BL::Depsgraph &b_depsgraph, bool update_all)
}
else {
EmissionNode *emission = graph->create_node<EmissionNode>();
- emission->color = make_float3(1.0f, 1.0f, 1.0f);
- emission->strength = 1.0f;
+ emission->set_color(make_float3(1.0f, 1.0f, 1.0f));
+ emission->set_strength(1.0f);
graph->add(emission);
ShaderNode *out = graph->output();
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index d2760d55f2d..931bbb509b1 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -118,9 +118,9 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d
if (dicing_prop_changed) {
for (const pair<const GeometryKey, Geometry *> &iter : geometry_map.key_to_scene_data()) {
Geometry *geom = iter.second;
- if (geom->type == Geometry::MESH) {
+ if (geom->is_mesh()) {
Mesh *mesh = static_cast<Mesh *>(geom);
- if (mesh->subdivision_type != Mesh::SUBDIVISION_NONE) {
+ if (mesh->get_subdivision_type() != Mesh::SUBDIVISION_NONE) {
PointerRNA id_ptr;
RNA_id_pointer_create((::ID *)iter.first.id, &id_ptr);
geometry_map.set_recalc(BL::ID(id_ptr));
@@ -238,7 +238,7 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render,
geometry_synced.clear(); /* use for objects and motion sync */
if (scene->need_motion() == Scene::MOTION_PASS || scene->need_motion() == Scene::MOTION_NONE ||
- scene->camera->motion_position == Camera::MOTION_POSITION_CENTER) {
+ scene->camera->get_motion_position() == Camera::MOTION_POSITION_CENTER) {
sync_objects(b_depsgraph, b_v3d);
}
sync_motion(b_render, b_depsgraph, b_v3d, b_override, width, height, python_thread_state);
@@ -264,68 +264,70 @@ void BlenderSync::sync_integrator()
experimental = (get_enum(cscene, "feature_set") != 0);
Integrator *integrator = scene->integrator;
- Integrator previntegrator = *integrator;
- integrator->min_bounce = get_int(cscene, "min_light_bounces");
- integrator->max_bounce = get_int(cscene, "max_bounces");
+ integrator->set_min_bounce(get_int(cscene, "min_light_bounces"));
+ integrator->set_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->max_volume_bounce = get_int(cscene, "volume_bounces");
+ integrator->set_max_diffuse_bounce(get_int(cscene, "diffuse_bounces"));
+ integrator->set_max_glossy_bounce(get_int(cscene, "glossy_bounces"));
+ integrator->set_max_transmission_bounce(get_int(cscene, "transmission_bounces"));
+ integrator->set_max_volume_bounce(get_int(cscene, "volume_bounces"));
- integrator->transparent_min_bounce = get_int(cscene, "min_transparent_bounces");
- integrator->transparent_max_bounce = get_int(cscene, "transparent_max_bounces");
+ integrator->set_transparent_min_bounce(get_int(cscene, "min_transparent_bounces"));
+ integrator->set_transparent_max_bounce(get_int(cscene, "transparent_max_bounces"));
- integrator->volume_max_steps = get_int(cscene, "volume_max_steps");
- integrator->volume_step_rate = (preview) ? get_float(cscene, "volume_preview_step_rate") :
- get_float(cscene, "volume_step_rate");
+ integrator->set_volume_max_steps(get_int(cscene, "volume_max_steps"));
+ float volume_step_rate = (preview) ? get_float(cscene, "volume_preview_step_rate") :
+ get_float(cscene, "volume_step_rate");
+ integrator->set_volume_step_rate(volume_step_rate);
- integrator->caustics_reflective = get_boolean(cscene, "caustics_reflective");
- integrator->caustics_refractive = get_boolean(cscene, "caustics_refractive");
- integrator->filter_glossy = get_float(cscene, "blur_glossy");
+ integrator->set_caustics_reflective(get_boolean(cscene, "caustics_reflective"));
+ integrator->set_caustics_refractive(get_boolean(cscene, "caustics_refractive"));
+ integrator->set_filter_glossy(get_float(cscene, "blur_glossy"));
- integrator->seed = get_int(cscene, "seed");
+ int seed = get_int(cscene, "seed");
if (get_boolean(cscene, "use_animated_seed")) {
- integrator->seed = hash_uint2(b_scene.frame_current(), get_int(cscene, "seed"));
+ seed = hash_uint2(b_scene.frame_current(), get_int(cscene, "seed"));
if (b_scene.frame_subframe() != 0.0f) {
/* TODO(sergey): Ideally should be some sort of hash_merge,
* but this is good enough for now.
*/
- integrator->seed += hash_uint2((int)(b_scene.frame_subframe() * (float)INT_MAX),
- get_int(cscene, "seed"));
+ seed += hash_uint2((int)(b_scene.frame_subframe() * (float)INT_MAX),
+ get_int(cscene, "seed"));
}
}
- integrator->sampling_pattern = (SamplingPattern)get_enum(
- cscene, "sampling_pattern", SAMPLING_NUM_PATTERNS, SAMPLING_PATTERN_SOBOL);
+ integrator->set_seed(seed);
- integrator->sample_clamp_direct = get_float(cscene, "sample_clamp_direct");
- integrator->sample_clamp_indirect = get_float(cscene, "sample_clamp_indirect");
+ integrator->set_sampling_pattern((SamplingPattern)get_enum(
+ cscene, "sampling_pattern", SAMPLING_NUM_PATTERNS, SAMPLING_PATTERN_SOBOL));
+
+ integrator->set_sample_clamp_direct(get_float(cscene, "sample_clamp_direct"));
+ integrator->set_sample_clamp_indirect(get_float(cscene, "sample_clamp_indirect"));
if (!preview) {
- if (integrator->motion_blur != r.use_motion_blur()) {
+ if (integrator->get_motion_blur() != r.use_motion_blur()) {
scene->object_manager->tag_update(scene);
- scene->camera->tag_update();
+ scene->camera->tag_modified();
}
- integrator->motion_blur = r.use_motion_blur();
+ integrator->set_motion_blur(r.use_motion_blur());
}
- integrator->method = (Integrator::Method)get_enum(
- cscene, "progressive", Integrator::NUM_METHODS, Integrator::PATH);
+ integrator->set_method((Integrator::Method)get_enum(
+ cscene, "progressive", Integrator::NUM_METHODS, Integrator::PATH));
- integrator->sample_all_lights_direct = get_boolean(cscene, "sample_all_lights_direct");
- integrator->sample_all_lights_indirect = get_boolean(cscene, "sample_all_lights_indirect");
- integrator->light_sampling_threshold = get_float(cscene, "light_sampling_threshold");
+ integrator->set_sample_all_lights_direct(get_boolean(cscene, "sample_all_lights_direct"));
+ integrator->set_sample_all_lights_indirect(get_boolean(cscene, "sample_all_lights_indirect"));
+ integrator->set_light_sampling_threshold(get_float(cscene, "light_sampling_threshold"));
if (RNA_boolean_get(&cscene, "use_adaptive_sampling")) {
- integrator->sampling_pattern = SAMPLING_PATTERN_PMJ;
- integrator->adaptive_min_samples = get_int(cscene, "adaptive_min_samples");
- integrator->adaptive_threshold = get_float(cscene, "adaptive_threshold");
+ integrator->set_sampling_pattern(SAMPLING_PATTERN_PMJ);
+ integrator->set_adaptive_min_samples(get_int(cscene, "adaptive_min_samples"));
+ integrator->set_adaptive_threshold(get_float(cscene, "adaptive_threshold"));
}
else {
- integrator->adaptive_min_samples = INT_MAX;
- integrator->adaptive_threshold = 0.0f;
+ integrator->set_adaptive_min_samples(INT_MAX);
+ integrator->set_adaptive_threshold(0.0f);
}
int diffuse_samples = get_int(cscene, "diffuse_samples");
@@ -337,39 +339,39 @@ void BlenderSync::sync_integrator()
int volume_samples = get_int(cscene, "volume_samples");
if (get_boolean(cscene, "use_square_samples")) {
- integrator->diffuse_samples = diffuse_samples * diffuse_samples;
- integrator->glossy_samples = glossy_samples * glossy_samples;
- integrator->transmission_samples = transmission_samples * transmission_samples;
- integrator->ao_samples = ao_samples * ao_samples;
- integrator->mesh_light_samples = mesh_light_samples * mesh_light_samples;
- integrator->subsurface_samples = subsurface_samples * subsurface_samples;
- integrator->volume_samples = volume_samples * volume_samples;
- integrator->adaptive_min_samples = min(
- integrator->adaptive_min_samples * integrator->adaptive_min_samples, INT_MAX);
+ integrator->set_diffuse_samples(diffuse_samples * diffuse_samples);
+ integrator->set_glossy_samples(glossy_samples * glossy_samples);
+ integrator->set_transmission_samples(transmission_samples * transmission_samples);
+ integrator->set_ao_samples(ao_samples * ao_samples);
+ integrator->set_mesh_light_samples(mesh_light_samples * mesh_light_samples);
+ integrator->set_subsurface_samples(subsurface_samples * subsurface_samples);
+ integrator->set_volume_samples(volume_samples * volume_samples);
+ integrator->set_adaptive_min_samples(min(
+ integrator->get_adaptive_min_samples() * integrator->get_adaptive_min_samples(), INT_MAX));
}
else {
- integrator->diffuse_samples = diffuse_samples;
- integrator->glossy_samples = glossy_samples;
- integrator->transmission_samples = transmission_samples;
- integrator->ao_samples = ao_samples;
- integrator->mesh_light_samples = mesh_light_samples;
- integrator->subsurface_samples = subsurface_samples;
- integrator->volume_samples = volume_samples;
+ integrator->set_diffuse_samples(diffuse_samples);
+ integrator->set_glossy_samples(glossy_samples);
+ integrator->set_transmission_samples(transmission_samples);
+ integrator->set_ao_samples(ao_samples);
+ integrator->set_mesh_light_samples(mesh_light_samples);
+ integrator->set_subsurface_samples(subsurface_samples);
+ integrator->set_volume_samples(volume_samples);
}
if (b_scene.render().use_simplify()) {
if (preview) {
- integrator->ao_bounces = get_int(cscene, "ao_bounces");
+ integrator->set_ao_bounces(get_int(cscene, "ao_bounces"));
}
else {
- integrator->ao_bounces = get_int(cscene, "ao_bounces_render");
+ integrator->set_ao_bounces(get_int(cscene, "ao_bounces_render"));
}
}
else {
- integrator->ao_bounces = 0;
+ integrator->set_ao_bounces(0);
}
- if (integrator->modified(previntegrator))
+ if (integrator->is_modified())
integrator->tag_update(scene);
}
@@ -380,46 +382,42 @@ void BlenderSync::sync_film(BL::SpaceView3D &b_v3d)
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
Film *film = scene->film;
- Film prevfilm = *film;
vector<Pass> prevpasses = scene->passes;
if (b_v3d) {
- film->display_pass = update_viewport_display_passes(b_v3d, scene->passes);
+ film->set_display_pass(update_viewport_display_passes(b_v3d, scene->passes));
}
- film->exposure = get_float(cscene, "film_exposure");
- film->filter_type = (FilterType)get_enum(
- cscene, "pixel_filter_type", FILTER_NUM_TYPES, FILTER_BLACKMAN_HARRIS);
- film->filter_width = (film->filter_type == FILTER_BOX) ? 1.0f :
- get_float(cscene, "filter_width");
+ film->set_exposure(get_float(cscene, "film_exposure"));
+ film->set_filter_type(
+ (FilterType)get_enum(cscene, "pixel_filter_type", FILTER_NUM_TYPES, FILTER_BLACKMAN_HARRIS));
+ float filter_width = (film->get_filter_type() == FILTER_BOX) ? 1.0f :
+ get_float(cscene, "filter_width");
+ film->set_filter_width(filter_width);
if (b_scene.world()) {
BL::WorldMistSettings b_mist = b_scene.world().mist_settings();
- film->mist_start = b_mist.start();
- film->mist_depth = b_mist.depth();
+ film->set_mist_start(b_mist.start());
+ film->set_mist_depth(b_mist.depth());
switch (b_mist.falloff()) {
case BL::WorldMistSettings::falloff_QUADRATIC:
- film->mist_falloff = 2.0f;
+ film->set_mist_falloff(2.0f);
break;
case BL::WorldMistSettings::falloff_LINEAR:
- film->mist_falloff = 1.0f;
+ film->set_mist_falloff(1.0f);
break;
case BL::WorldMistSettings::falloff_INVERSE_QUADRATIC:
- film->mist_falloff = 0.5f;
+ film->set_mist_falloff(0.5f);
break;
}
}
- if (film->modified(prevfilm)) {
- film->tag_update(scene);
- }
-
if (!Pass::equals(prevpasses, scene->passes)) {
film->tag_passes_update(scene, prevpasses, false);
- film->tag_update(scene);
+ film->tag_modified();
}
}
@@ -585,7 +583,7 @@ vector<Pass> BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay,
BL::RenderPass b_pass(*b_pass_iter);
PassType pass_type = get_pass_type(b_pass);
- if (pass_type == PASS_MOTION && scene->integrator->motion_blur)
+ if (pass_type == PASS_MOTION && scene->integrator->get_motion_blur())
continue;
if (pass_type != PASS_NONE)
Pass::add(pass_type, passes, b_pass.name().c_str());
@@ -593,12 +591,12 @@ vector<Pass> BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay,
PointerRNA crl = RNA_pointer_get(&b_view_layer.ptr, "cycles");
- scene->film->denoising_flags = 0;
+ int denoising_flags = 0;
if (denoising.use || denoising.store_passes) {
if (denoising.type == DENOISER_NLM) {
#define MAP_OPTION(name, flag) \
if (!get_boolean(crl, name)) { \
- scene->film->denoising_flags |= flag; \
+ denoising_flags |= flag; \
} \
((void)0)
MAP_OPTION("denoising_diffuse_direct", DENOISING_CLEAN_DIFFUSE_DIR);
@@ -611,6 +609,7 @@ vector<Pass> BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay,
}
b_engine.add_pass("Noisy Image", 4, "RGBA", b_view_layer.name().c_str());
}
+ scene->film->set_denoising_flags(denoising_flags);
if (denoising.store_passes) {
b_engine.add_pass("Denoising Normal", 3, "XYZ", b_view_layer.name().c_str());
@@ -622,7 +621,7 @@ vector<Pass> BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay,
b_engine.add_pass("Denoising Intensity", 1, "X", b_view_layer.name().c_str());
}
- if (scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES) {
+ if (scene->film->get_denoising_flags() & DENOISING_CLEAN_ALL_PASSES) {
b_engine.add_pass("Denoising Clean", 3, "RGB", b_view_layer.name().c_str());
}
}
@@ -665,16 +664,15 @@ vector<Pass> BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay,
/* Cryptomatte stores two ID/weight pairs per RGBA layer.
* User facing parameter is the number of pairs. */
int crypto_depth = divide_up(min(16, get_int(crl, "pass_crypto_depth")), 2);
- scene->film->cryptomatte_depth = crypto_depth;
- scene->film->cryptomatte_passes = CRYPT_NONE;
+ scene->film->set_cryptomatte_depth(crypto_depth);
+ CryptomatteType cryptomatte_passes = CRYPT_NONE;
if (get_boolean(crl, "use_pass_crypto_object")) {
for (int i = 0; i < crypto_depth; i++) {
string passname = cryptomatte_prefix + string_printf("Object%02d", i);
b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str());
Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str());
}
- scene->film->cryptomatte_passes = (CryptomatteType)(scene->film->cryptomatte_passes |
- CRYPT_OBJECT);
+ cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_OBJECT);
}
if (get_boolean(crl, "use_pass_crypto_material")) {
for (int i = 0; i < crypto_depth; i++) {
@@ -682,8 +680,7 @@ vector<Pass> BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay,
b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str());
Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str());
}
- scene->film->cryptomatte_passes = (CryptomatteType)(scene->film->cryptomatte_passes |
- CRYPT_MATERIAL);
+ cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_MATERIAL);
}
if (get_boolean(crl, "use_pass_crypto_asset")) {
for (int i = 0; i < crypto_depth; i++) {
@@ -691,13 +688,12 @@ vector<Pass> BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay,
b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str());
Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str());
}
- scene->film->cryptomatte_passes = (CryptomatteType)(scene->film->cryptomatte_passes |
- CRYPT_ASSET);
+ cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_ASSET);
}
- if (get_boolean(crl, "pass_crypto_accurate") && scene->film->cryptomatte_passes != CRYPT_NONE) {
- scene->film->cryptomatte_passes = (CryptomatteType)(scene->film->cryptomatte_passes |
- CRYPT_ACCURATE);
+ if (get_boolean(crl, "pass_crypto_accurate") && cryptomatte_passes != CRYPT_NONE) {
+ cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_ACCURATE);
}
+ scene->film->set_cryptomatte_passes(cryptomatte_passes);
if (adaptive_sampling) {
Pass::add(PASS_ADAPTIVE_AUX_BUFFER, passes);
@@ -721,14 +717,14 @@ vector<Pass> BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay,
}
RNA_END;
- scene->film->denoising_data_pass = denoising.use || denoising.store_passes;
- scene->film->denoising_clean_pass = (scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES);
- scene->film->denoising_prefiltered_pass = denoising.store_passes &&
- denoising.type == DENOISER_NLM;
+ scene->film->set_denoising_data_pass(denoising.use || denoising.store_passes);
+ scene->film->set_denoising_clean_pass(scene->film->get_denoising_flags() &
+ DENOISING_CLEAN_ALL_PASSES);
+ scene->film->set_denoising_prefiltered_pass(denoising.store_passes &&
+ denoising.type == DENOISER_NLM);
- scene->film->pass_alpha_threshold = b_view_layer.pass_alpha_threshold();
+ scene->film->set_pass_alpha_threshold(b_view_layer.pass_alpha_threshold());
scene->film->tag_passes_update(scene, passes);
- scene->film->tag_update(scene);
scene->integrator->tag_update(scene);
return passes;
diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h
index a17db128957..1dabab99658 100644
--- a/intern/cycles/blender/blender_sync.h
+++ b/intern/cycles/blender/blender_sync.h
@@ -150,20 +150,20 @@ class BlenderSync {
TaskPool *geom_task_pool);
/* Volume */
- void sync_volume(BL::Object &b_ob, Volume *volume, const vector<Shader *> &used_shaders);
+ void sync_volume(BL::Object &b_ob, Volume *volume, array<Node *> &used_shaders);
/* Mesh */
void sync_mesh(BL::Depsgraph b_depsgraph,
BL::Object b_ob,
Mesh *mesh,
- const vector<Shader *> &used_shaders);
+ array<Node *> &used_shaders);
void sync_mesh_motion(BL::Depsgraph b_depsgraph, BL::Object b_ob, Mesh *mesh, int motion_step);
/* Hair */
void sync_hair(BL::Depsgraph b_depsgraph,
BL::Object b_ob,
Hair *hair,
- const vector<Shader *> &used_shaders);
+ array<Node *> &used_shaders);
void sync_hair_motion(BL::Depsgraph b_depsgraph, BL::Object b_ob, Hair *hair, int motion_step);
void sync_hair(Hair *hair, BL::Object &b_ob, bool motion, int motion_step = 0);
void sync_particle_hair(
@@ -211,7 +211,7 @@ class BlenderSync {
void free_data_after_sync(BL::Depsgraph &b_depsgraph);
/* util */
- void find_shader(BL::ID &id, vector<Shader *> &used_shaders, Shader *default_shader);
+ void find_shader(BL::ID &id, array<Node *> &used_shaders, Shader *default_shader);
bool BKE_object_is_modified(BL::Object &b_ob);
bool object_is_geometry(BL::Object &b_ob);
bool object_is_light(BL::Object &b_ob);
diff --git a/intern/cycles/blender/blender_volume.cpp b/intern/cycles/blender/blender_volume.cpp
index e039d8a4895..e86512b6f91 100644
--- a/intern/cycles/blender/blender_volume.cpp
+++ b/intern/cycles/blender/blender_volume.cpp
@@ -202,7 +202,7 @@ static void sync_smoke_volume(Scene *scene, BL::Object &b_ob, Volume *volume, fl
continue;
}
- volume->clipping = b_domain.clipping();
+ volume->set_clipping(b_domain.clipping());
Attribute *attr = volume->attributes.add(std);
@@ -262,9 +262,9 @@ static void sync_volume_object(BL::BlendData &b_data,
BL::VolumeRender b_render(b_volume.render());
- volume->clipping = b_render.clipping();
- volume->step_size = b_render.step_size();
- volume->object_space = (b_render.space() == BL::VolumeRender::space_OBJECT);
+ volume->set_clipping(b_render.clipping());
+ volume->set_step_size(b_render.step_size());
+ volume->set_object_space((b_render.space() == BL::VolumeRender::space_OBJECT));
/* Find grid with matching name. */
BL::Volume::grids_iterator b_grid_iter;
@@ -320,14 +320,12 @@ static vector<int> get_voxel_image_slots(Mesh *mesh)
return slots;
}
-void BlenderSync::sync_volume(BL::Object &b_ob,
- Volume *volume,
- const vector<Shader *> &used_shaders)
+void BlenderSync::sync_volume(BL::Object &b_ob, Volume *volume, array<Node *> &used_shaders)
{
vector<int> old_voxel_slots = get_voxel_image_slots(volume);
volume->clear();
- volume->used_shaders = used_shaders;
+ volume->set_used_shaders(used_shaders);
if (view_layer.use_volumes) {
if (b_ob.type() == BL::Object::type_VOLUME) {