diff options
author | Siddhartha Jejurkar <f20180617@goa.bits-pilani.ac.in> | 2021-12-17 16:01:32 +0300 |
---|---|---|
committer | Siddhartha Jejurkar <f20180617@goa.bits-pilani.ac.in> | 2021-12-17 16:01:32 +0300 |
commit | dbc41b30f88b96f7d8c6e995b17f5930eb55cc77 (patch) | |
tree | c6c495328443ea3621e5df2ef483b0e0dd504496 /intern/cycles/scene/alembic.cpp | |
parent | 99a2af76d10e05a18987be5d554ada197b1ca086 (diff) | |
parent | 7c9e4099854a4fc8eab4db97173c1aacd25f9e08 (diff) |
Merge branch 'master' into soc-2021-uv-edge-select-supportsoc-2021-uv-edge-select-support
Diffstat (limited to 'intern/cycles/scene/alembic.cpp')
-rw-r--r-- | intern/cycles/scene/alembic.cpp | 87 |
1 files changed, 86 insertions, 1 deletions
diff --git a/intern/cycles/scene/alembic.cpp b/intern/cycles/scene/alembic.cpp index 39b5f467736..71fa1863b8b 100644 --- a/intern/cycles/scene/alembic.cpp +++ b/intern/cycles/scene/alembic.cpp @@ -21,6 +21,7 @@ #include "scene/curves.h" #include "scene/mesh.h" #include "scene/object.h" +#include "scene/pointcloud.h" #include "scene/scene.h" #include "scene/shader.h" @@ -99,6 +100,9 @@ void CachedData::clear() triangles.clear(); uv_loops.clear(); vertices.clear(); + points.clear(); + radiuses.clear(); + points_shader.clear(); for (CachedAttribute &attr : attributes) { attr.data.clear(); @@ -146,6 +150,9 @@ bool CachedData::is_constant() const CHECK_IF_CONSTANT(triangles) CHECK_IF_CONSTANT(uv_loops) CHECK_IF_CONSTANT(vertices) + CHECK_IF_CONSTANT(points) + CHECK_IF_CONSTANT(radiuses) + CHECK_IF_CONSTANT(points_shader) for (const CachedAttribute &attr : attributes) { if (!attr.data.is_constant()) { @@ -185,6 +192,9 @@ void CachedData::invalidate_last_loaded_time(bool attributes_only) triangles.invalidate_last_loaded_time(); uv_loops.invalidate_last_loaded_time(); vertices.invalidate_last_loaded_time(); + points.invalidate_last_loaded_time(); + radiuses.invalidate_last_loaded_time(); + points_shader.invalidate_last_loaded_time(); } void CachedData::set_time_sampling(TimeSampling time_sampling) @@ -206,6 +216,9 @@ void CachedData::set_time_sampling(TimeSampling time_sampling) triangles.set_time_sampling(time_sampling); uv_loops.set_time_sampling(time_sampling); vertices.set_time_sampling(time_sampling); + points.set_time_sampling(time_sampling); + radiuses.set_time_sampling(time_sampling); + points_shader.set_time_sampling(time_sampling); for (CachedAttribute &attr : attributes) { attr.data.set_time_sampling(time_sampling); @@ -233,6 +246,9 @@ size_t CachedData::memory_used() const mem_used += triangles.memory_used(); mem_used += uv_loops.memory_used(); mem_used += vertices.memory_used(); + mem_used += points.memory_used(); + mem_used += radiuses.memory_used(); + mem_used += points_shader.memory_used(); for (const CachedAttribute &attr : attributes) { mem_used += attr.data.memory_used(); @@ -901,6 +917,9 @@ void AlembicProcedural::generate(Scene *scene, Progress &progress) else if (object->schema_type == AlembicObject::CURVES) { read_curves(object, frame_time); } + else if (object->schema_type == AlembicObject::POINTS) { + read_points(object, frame_time); + } else if (object->schema_type == AlembicObject::SUBD) { read_subd(object, frame_time); } @@ -970,6 +989,9 @@ void AlembicProcedural::load_objects(Progress &progress) if (abc_object->schema_type == AlembicObject::CURVES) { geometry = scene_->create_node<Hair>(); } + else if (abc_object->schema_type == AlembicObject::POINTS) { + geometry = scene_->create_node<PointCloud>(); + } else if (abc_object->schema_type == AlembicObject::POLY_MESH || abc_object->schema_type == AlembicObject::SUBD) { geometry = scene_->create_node<Mesh>(); @@ -1202,6 +1224,45 @@ void AlembicProcedural::read_curves(AlembicObject *abc_object, Abc::chrono_t fra hair->tag_update(scene_, rebuild); } +void AlembicProcedural::read_points(AlembicObject *abc_object, Abc::chrono_t frame_time) +{ + CachedData &cached_data = abc_object->get_cached_data(); + + /* update sockets */ + + Object *object = abc_object->get_object(); + cached_data.transforms.copy_to_socket(frame_time, object, object->get_tfm_socket()); + + if (object->is_modified()) { + object->tag_update(scene_); + } + + /* Only update sockets for the original Geometry. */ + if (abc_object->instance_of) { + return; + } + + PointCloud *point_cloud = static_cast<PointCloud *>(object->get_geometry()); + + /* Make sure shader ids are also updated. */ + if (point_cloud->used_shaders_is_modified()) { + point_cloud->tag_shader_modified(); + } + + cached_data.points.copy_to_socket(frame_time, point_cloud, point_cloud->get_points_socket()); + cached_data.radiuses.copy_to_socket(frame_time, point_cloud, point_cloud->get_radius_socket()); + cached_data.points_shader.copy_to_socket( + frame_time, point_cloud, point_cloud->get_shader_socket()); + + /* update attributes */ + + update_attributes(point_cloud->attributes, cached_data, frame_time); + + const bool rebuild = (point_cloud->points_is_modified() || point_cloud->radius_is_modified() || + point_cloud->shader_is_modified()); + point_cloud->tag_update(scene_, rebuild); +} + void AlembicProcedural::walk_hierarchy( IObject parent, const ObjectHeader &header, @@ -1314,7 +1375,23 @@ void AlembicProcedural::walk_hierarchy( // ignore the face set, it will be read along with the data } else if (IPoints::matches(header)) { - // unsupported for now + IPoints points(parent, header.getName()); + + unordered_map<std::string, AlembicObject *>::const_iterator iter; + iter = object_map.find(points.getFullName()); + + if (iter != object_map.end()) { + AlembicObject *abc_object = iter->second; + abc_object->iobject = points; + abc_object->schema_type = AlembicObject::POINTS; + + if (matrix_samples_data.samples) { + abc_object->xform_samples = *matrix_samples_data.samples; + abc_object->xform_time_sampling = matrix_samples_data.time_sampling; + } + } + + next_object = points; } else if (INuPatch::matches(header)) { // unsupported for now @@ -1391,6 +1468,14 @@ void AlembicProcedural::build_caches(Progress &progress) object->load_data_in_cache(object->get_cached_data(), this, schema, progress); } } + else if (object->schema_type == AlembicObject::POINTS) { + if (!object->has_data_loaded() || default_radius_is_modified() || + object->radius_scale_is_modified()) { + IPoints points(object->iobject, Alembic::Abc::kWrapExisting); + IPointsSchema schema = points.getSchema(); + object->load_data_in_cache(object->get_cached_data(), this, schema, progress); + } + } else if (object->schema_type == AlembicObject::SUBD) { if (!object->has_data_loaded()) { ISubD subd_mesh(object->iobject, Alembic::Abc::kWrapExisting); |