[Bf-blender-cvs] [e301ed57519] cycles_procedural_api: alembic, compute the frame index from the schema
Kévin Dietrich
noreply at git.blender.org
Wed Sep 9 01:08:22 CEST 2020
Commit: e301ed57519a877bd96dd35ec3a46d770d67af65
Author: Kévin Dietrich
Date: Tue Sep 8 11:45:45 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rBe301ed57519a877bd96dd35ec3a46d770d67af65
alembic, compute the frame index from the schema
===================================================================
M intern/cycles/render/alembic.cpp
M intern/cycles/render/alembic.h
===================================================================
diff --git a/intern/cycles/render/alembic.cpp b/intern/cycles/render/alembic.cpp
index ee053d7709b..8db74da436e 100644
--- a/intern/cycles/render/alembic.cpp
+++ b/intern/cycles/render/alembic.cpp
@@ -148,11 +148,6 @@ bool AlembicObject::has_data_loaded() const
return data_loaded;
}
-int AlembicObject::frame_index(float frame, float frame_rate)
-{
- return static_cast<int>(frame - (static_cast<float>(min_time) * frame_rate));
-}
-
AlembicObject::DataCache &AlembicObject::get_frame_data(int index)
{
if (index < 0) {
@@ -170,17 +165,6 @@ void AlembicObject::load_all_data(IPolyMeshSchema &schema)
{
frame_data.clear();
- const auto &time_sampling = schema.getTimeSampling();
-
- if (!schema.isConstant()) {
- auto num_samples = schema.getNumSamples();
-
- if (num_samples > 0) {
- min_time = time_sampling->getSampleTime(0);
- max_time = time_sampling->getSampleTime(num_samples - 1);
- }
- }
-
// TODO : store other properties and have a better structure to store these arrays
for (size_t i = 0; i < schema.getNumSamples(); ++i) {
frame_data.emplace_back();
@@ -363,7 +347,8 @@ void AlembicProcedural::read_mesh(Scene *scene,
abc_object->load_all_data(schema);
}
- int frame_index = abc_object->frame_index(frame, frame_rate);
+ ISampleSelector sample_sel = ISampleSelector(frame_time);
+ int frame_index = sample_sel.getIndex(schema.getTimeSampling(), schema.getNumSamples());
auto &data = abc_object->get_frame_data(frame_index);
// TODO : arrays are emptied when passed to the sockets, so we need to reload the data
@@ -403,7 +388,7 @@ void AlembicProcedural::read_mesh(Scene *scene,
mesh->set_shader(shader);
}
- IPolyMeshSchema::Sample samp = schema.getValue(ISampleSelector(frame_time));
+ IPolyMeshSchema::Sample samp = schema.getValue(sample_sel);
IV2fGeomParam uvs = polymesh.getSchema().getUVsParam();
read_uvs(uvs, mesh, samp.getFaceCounts()->get(), samp.getFaceCounts()->size());
diff --git a/intern/cycles/render/alembic.h b/intern/cycles/render/alembic.h
index 0f55fe4348b..59d0204a7aa 100644
--- a/intern/cycles/render/alembic.h
+++ b/intern/cycles/render/alembic.h
@@ -46,8 +46,6 @@ class AlembicObject : public Node {
void set_object(Object *object);
Object *get_object();
- int frame_index(float frame, float frame_rate);
-
void load_all_data(IPolyMeshSchema &schema);
bool has_data_loaded() const;
@@ -68,8 +66,6 @@ class AlembicObject : public Node {
// runtime data
bool data_loaded = false;
- chrono_t min_time = 0.0;
- chrono_t max_time = 0.0;
vector<DataCache> frame_data;
};
More information about the Bf-blender-cvs
mailing list