Revert "Alembic: Construct ISampleSelector once and pass along"
This reverts commit 099816587a0e064fb6a52c82a737ae8814cf21df. It had some unforseen side-effects that should be investigated first.
This commit is contained in:
parent
0a07cdbe80
commit
e353cf8705
@ -117,10 +117,11 @@ bool AbcCameraReader::valid() const
|
||||
return m_schema.valid();
|
||||
}
|
||||
|
||||
void AbcCameraReader::readObjectData(Main *bmain, const ISampleSelector &sample_sel)
|
||||
void AbcCameraReader::readObjectData(Main *bmain, float time)
|
||||
{
|
||||
Camera *bcam = static_cast<Camera *>(BKE_camera_add(bmain, m_data_name.c_str()));
|
||||
|
||||
ISampleSelector sample_sel(time);
|
||||
CameraSample cam_sample;
|
||||
m_schema.get(cam_sample, sample_sel);
|
||||
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
|
||||
bool valid() const;
|
||||
|
||||
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
|
||||
void readObjectData(Main *bmain, float time);
|
||||
};
|
||||
|
||||
#endif /* __ABC_CAMERA_H__ */
|
||||
|
@ -211,7 +211,7 @@ bool AbcCurveReader::valid() const
|
||||
return m_curves_schema.valid();
|
||||
}
|
||||
|
||||
void AbcCurveReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel)
|
||||
void AbcCurveReader::readObjectData(Main *bmain, float time)
|
||||
{
|
||||
Curve *cu = BKE_curve_add(bmain, m_data_name.c_str(), OB_CURVE);
|
||||
|
||||
@ -219,6 +219,8 @@ void AbcCurveReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSele
|
||||
cu->actvert = CU_ACT_NONE;
|
||||
cu->resolu = 1;
|
||||
|
||||
const ISampleSelector sample_sel(time);
|
||||
|
||||
ICompoundProperty user_props = m_curves_schema.getUserProperties();
|
||||
if (user_props) {
|
||||
const PropertyHeader *header = user_props.getPropertyHeader(ABC_CURVE_RESOLUTION_U_PROPNAME);
|
||||
@ -387,11 +389,9 @@ void read_curve_sample(Curve *cu, const ICurvesSchema &schema, const ISampleSele
|
||||
* object directly and create a new DerivedMesh from that. Also we might need to
|
||||
* create new or delete existing NURBS in the curve.
|
||||
*/
|
||||
DerivedMesh *AbcCurveReader::read_derivedmesh(DerivedMesh * /*dm*/,
|
||||
const ISampleSelector &sample_sel,
|
||||
int /*read_flag*/,
|
||||
const char ** /*err_str*/)
|
||||
DerivedMesh *AbcCurveReader::read_derivedmesh(DerivedMesh * /*dm*/, const float time, int /*read_flag*/, const char ** /*err_str*/)
|
||||
{
|
||||
ISampleSelector sample_sel(time);
|
||||
const ICurvesSchema::Sample sample = m_curves_schema.getValue(sample_sel);
|
||||
|
||||
const P3fArraySamplePtr &positions = sample.getPositions();
|
||||
|
@ -55,11 +55,8 @@ public:
|
||||
|
||||
bool valid() const;
|
||||
|
||||
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
|
||||
DerivedMesh *read_derivedmesh(DerivedMesh *dm,
|
||||
const Alembic::Abc::ISampleSelector &sample_sel,
|
||||
int read_flag,
|
||||
const char **err_str);
|
||||
void readObjectData(Main *bmain, float time);
|
||||
DerivedMesh *read_derivedmesh(DerivedMesh *, const float time, int read_flag, const char **err_str);
|
||||
};
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
@ -1021,15 +1021,17 @@ bool AbcMeshReader::valid() const
|
||||
return m_schema.valid();
|
||||
}
|
||||
|
||||
void AbcMeshReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel)
|
||||
void AbcMeshReader::readObjectData(Main *bmain, float time)
|
||||
{
|
||||
Mesh *mesh = BKE_mesh_add(bmain, m_data_name.c_str());
|
||||
|
||||
m_object = BKE_object_add_only_object(bmain, OB_MESH, m_object_name.c_str());
|
||||
m_object->data = mesh;
|
||||
|
||||
const ISampleSelector sample_sel(time);
|
||||
|
||||
DerivedMesh *dm = CDDM_from_mesh(mesh);
|
||||
DerivedMesh *ndm = this->read_derivedmesh(dm, sample_sel, MOD_MESHSEQ_READ_ALL, NULL);
|
||||
DerivedMesh *ndm = this->read_derivedmesh(dm, time, MOD_MESHSEQ_READ_ALL, NULL);
|
||||
|
||||
if (ndm != dm) {
|
||||
dm->release(dm);
|
||||
@ -1048,11 +1050,9 @@ void AbcMeshReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec
|
||||
}
|
||||
}
|
||||
|
||||
DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm,
|
||||
const ISampleSelector &sample_sel,
|
||||
int read_flag,
|
||||
const char **err_str)
|
||||
DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm, const float time, int read_flag, const char **err_str)
|
||||
{
|
||||
ISampleSelector sample_sel(time);
|
||||
const IPolyMeshSchema::Sample sample = m_schema.getValue(sample_sel);
|
||||
|
||||
const P3fArraySamplePtr &positions = sample.getPositions();
|
||||
@ -1092,7 +1092,7 @@ DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm,
|
||||
}
|
||||
|
||||
CDStreamConfig config = get_config(new_dm ? new_dm : dm);
|
||||
config.time = sample_sel.getRequestedTime();
|
||||
config.time = time;
|
||||
|
||||
bool do_normals = false;
|
||||
read_mesh_sample(&settings, m_schema, sample_sel, config, do_normals);
|
||||
@ -1239,7 +1239,7 @@ bool AbcSubDReader::valid() const
|
||||
return m_schema.valid();
|
||||
}
|
||||
|
||||
void AbcSubDReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel)
|
||||
void AbcSubDReader::readObjectData(Main *bmain, float time)
|
||||
{
|
||||
Mesh *mesh = BKE_mesh_add(bmain, m_data_name.c_str());
|
||||
|
||||
@ -1247,7 +1247,7 @@ void AbcSubDReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec
|
||||
m_object->data = mesh;
|
||||
|
||||
DerivedMesh *dm = CDDM_from_mesh(mesh);
|
||||
DerivedMesh *ndm = this->read_derivedmesh(dm, sample_sel, MOD_MESHSEQ_READ_ALL, NULL);
|
||||
DerivedMesh *ndm = this->read_derivedmesh(dm, time, MOD_MESHSEQ_READ_ALL, NULL);
|
||||
|
||||
if (ndm != dm) {
|
||||
dm->release(dm);
|
||||
@ -1255,6 +1255,7 @@ void AbcSubDReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec
|
||||
|
||||
DM_to_mesh(ndm, mesh, m_object, CD_MASK_MESH, true);
|
||||
|
||||
const ISampleSelector sample_sel(time);
|
||||
const ISubDSchema::Sample sample = m_schema.getValue(sample_sel);
|
||||
Int32ArraySamplePtr indices = sample.getCreaseIndices();
|
||||
Alembic::Abc::FloatArraySamplePtr sharpnesses = sample.getCreaseSharpnesses();
|
||||
@ -1285,11 +1286,9 @@ void AbcSubDReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec
|
||||
}
|
||||
}
|
||||
|
||||
DerivedMesh *AbcSubDReader::read_derivedmesh(DerivedMesh *dm,
|
||||
const ISampleSelector &sample_sel,
|
||||
int read_flag,
|
||||
const char **err_str)
|
||||
DerivedMesh *AbcSubDReader::read_derivedmesh(DerivedMesh *dm, const float time, int read_flag, const char **err_str)
|
||||
{
|
||||
ISampleSelector sample_sel(time);
|
||||
const ISubDSchema::Sample sample = m_schema.getValue(sample_sel);
|
||||
|
||||
const P3fArraySamplePtr &positions = sample.getPositions();
|
||||
@ -1329,7 +1328,7 @@ DerivedMesh *AbcSubDReader::read_derivedmesh(DerivedMesh *dm,
|
||||
|
||||
/* Only read point data when streaming meshes, unless we need to create new ones. */
|
||||
CDStreamConfig config = get_config(new_dm ? new_dm : dm);
|
||||
config.time = sample_sel.getRequestedTime();
|
||||
config.time = time;
|
||||
read_subd_sample(&settings, m_schema, sample_sel, config);
|
||||
|
||||
if (new_dm) {
|
||||
|
@ -100,12 +100,9 @@ public:
|
||||
|
||||
bool valid() const;
|
||||
|
||||
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
|
||||
void readObjectData(Main *bmain, float time);
|
||||
|
||||
DerivedMesh *read_derivedmesh(DerivedMesh *dm,
|
||||
const Alembic::Abc::ISampleSelector &sample_sel,
|
||||
int read_flag,
|
||||
const char **err_str);
|
||||
DerivedMesh *read_derivedmesh(DerivedMesh *dm, const float time, int read_flag, const char **err_str);
|
||||
|
||||
private:
|
||||
void readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_start,
|
||||
@ -124,11 +121,8 @@ public:
|
||||
|
||||
bool valid() const;
|
||||
|
||||
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
|
||||
DerivedMesh *read_derivedmesh(DerivedMesh *dm,
|
||||
const Alembic::Abc::ISampleSelector &sample_sel,
|
||||
int read_flag,
|
||||
const char **err_str);
|
||||
void readObjectData(Main *bmain, float time);
|
||||
DerivedMesh *read_derivedmesh(DerivedMesh *dm, const float time, int read_flag, const char **err_str);
|
||||
};
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
@ -239,7 +239,7 @@ static bool set_knots(const FloatArraySamplePtr &knots, float *&nu_knots)
|
||||
return true;
|
||||
}
|
||||
|
||||
void AbcNurbsReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel)
|
||||
void AbcNurbsReader::readObjectData(Main *bmain, float time)
|
||||
{
|
||||
Curve *cu = static_cast<Curve *>(BKE_curve_add(bmain, "abc_curve", OB_SURF));
|
||||
cu->actvert = CU_ACT_NONE;
|
||||
@ -253,6 +253,7 @@ void AbcNurbsReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSele
|
||||
nu->resolu = cu->resolu;
|
||||
nu->resolv = cu->resolv;
|
||||
|
||||
const ISampleSelector sample_sel(time);
|
||||
const INuPatchSchema &schema = it->first;
|
||||
const INuPatchSchema::Sample smp = schema.getValue(sample_sel);
|
||||
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
|
||||
bool valid() const;
|
||||
|
||||
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
|
||||
void readObjectData(Main *bmain, float time);
|
||||
|
||||
private:
|
||||
void getNurbsPatches(const Alembic::Abc::IObject &obj);
|
||||
|
@ -160,15 +160,6 @@ void AbcObjectReader::object(Object *ob)
|
||||
m_object = ob;
|
||||
}
|
||||
|
||||
DerivedMesh *AbcObjectReader::read_derivedmesh(DerivedMesh *dm,
|
||||
const Alembic::Abc::ISampleSelector &UNUSED(sample_sel),
|
||||
int UNUSED(read_flag),
|
||||
const char **UNUSED(err_str))
|
||||
{
|
||||
return dm;
|
||||
}
|
||||
|
||||
|
||||
static Imath::M44d blend_matrices(const Imath::M44d &m0, const Imath::M44d &m1, const float weight)
|
||||
{
|
||||
float mat0[4][4], mat1[4][4], ret[4][4];
|
||||
@ -224,6 +215,14 @@ Imath::M44d get_matrix(const IXformSchema &schema, const float time)
|
||||
return s0.getMatrix();
|
||||
}
|
||||
|
||||
DerivedMesh *AbcObjectReader::read_derivedmesh(DerivedMesh *dm,
|
||||
const float UNUSED(time),
|
||||
int UNUSED(read_flag),
|
||||
const char **UNUSED(err_str))
|
||||
{
|
||||
return dm;
|
||||
}
|
||||
|
||||
void AbcObjectReader::setupObjectTransform(const float time)
|
||||
{
|
||||
bool is_constant = false;
|
||||
|
@ -170,10 +170,10 @@ public:
|
||||
|
||||
virtual bool valid() const = 0;
|
||||
|
||||
virtual void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel) = 0;
|
||||
virtual void readObjectData(Main *bmain, float time) = 0;
|
||||
|
||||
virtual DerivedMesh *read_derivedmesh(DerivedMesh *dm,
|
||||
const Alembic::Abc::ISampleSelector &sample_sel,
|
||||
const float time,
|
||||
int read_flag,
|
||||
const char **err_str);
|
||||
|
||||
|
@ -151,12 +151,12 @@ bool AbcPointsReader::valid() const
|
||||
return m_schema.valid();
|
||||
}
|
||||
|
||||
void AbcPointsReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel)
|
||||
void AbcPointsReader::readObjectData(Main *bmain, float time)
|
||||
{
|
||||
Mesh *mesh = BKE_mesh_add(bmain, m_data_name.c_str());
|
||||
|
||||
DerivedMesh *dm = CDDM_from_mesh(mesh);
|
||||
DerivedMesh *ndm = this->read_derivedmesh(dm, sample_sel, 0, NULL);
|
||||
DerivedMesh *ndm = this->read_derivedmesh(dm, time, 0, NULL);
|
||||
|
||||
if (ndm != dm) {
|
||||
dm->release(dm);
|
||||
@ -178,7 +178,8 @@ void AbcPointsReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSel
|
||||
|
||||
void read_points_sample(const IPointsSchema &schema,
|
||||
const ISampleSelector &selector,
|
||||
CDStreamConfig &config)
|
||||
CDStreamConfig &config,
|
||||
float time)
|
||||
{
|
||||
Alembic::AbcGeom::IPointsSchema::Sample sample = schema.getValue(selector);
|
||||
|
||||
@ -188,7 +189,7 @@ void read_points_sample(const IPointsSchema &schema,
|
||||
N3fArraySamplePtr vnormals;
|
||||
|
||||
if (has_property(prop, "N")) {
|
||||
const Alembic::Util::uint32_t itime = static_cast<Alembic::Util::uint32_t>(selector.getRequestedTime());
|
||||
const Alembic::Util::uint32_t itime = static_cast<Alembic::Util::uint32_t>(time);
|
||||
const IN3fArrayProperty &normals_prop = IN3fArrayProperty(prop, "N", itime);
|
||||
|
||||
if (normals_prop) {
|
||||
@ -199,11 +200,9 @@ void read_points_sample(const IPointsSchema &schema,
|
||||
read_mverts(config.mvert, positions, vnormals);
|
||||
}
|
||||
|
||||
DerivedMesh *AbcPointsReader::read_derivedmesh(DerivedMesh *dm,
|
||||
const ISampleSelector &sample_sel,
|
||||
int /*read_flag*/,
|
||||
const char ** /*err_str*/)
|
||||
DerivedMesh *AbcPointsReader::read_derivedmesh(DerivedMesh *dm, const float time, int /*read_flag*/, const char ** /*err_str*/)
|
||||
{
|
||||
ISampleSelector sample_sel(time);
|
||||
const IPointsSchema::Sample sample = m_schema.getValue(sample_sel);
|
||||
|
||||
const P3fArraySamplePtr &positions = sample.getPositions();
|
||||
@ -215,7 +214,7 @@ DerivedMesh *AbcPointsReader::read_derivedmesh(DerivedMesh *dm,
|
||||
}
|
||||
|
||||
CDStreamConfig config = get_config(new_dm ? new_dm : dm);
|
||||
read_points_sample(m_schema, sample_sel, config);
|
||||
read_points_sample(m_schema, sample_sel, config, time);
|
||||
|
||||
return new_dm ? new_dm : dm;
|
||||
}
|
||||
|
@ -59,16 +59,14 @@ public:
|
||||
|
||||
bool valid() const;
|
||||
|
||||
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
|
||||
void readObjectData(Main *bmain, float time);
|
||||
|
||||
DerivedMesh *read_derivedmesh(DerivedMesh *dm,
|
||||
const Alembic::Abc::ISampleSelector &sample_sel,
|
||||
int read_flag,
|
||||
const char **err_str);
|
||||
DerivedMesh *read_derivedmesh(DerivedMesh *dm, const float time, int read_flag, const char **err_str);
|
||||
};
|
||||
|
||||
void read_points_sample(const Alembic::AbcGeom::IPointsSchema &schema,
|
||||
const Alembic::AbcGeom::ISampleSelector &selector,
|
||||
CDStreamConfig &config);
|
||||
CDStreamConfig &config,
|
||||
float time);
|
||||
|
||||
#endif /* __ABC_POINTS_H__ */
|
||||
|
@ -36,7 +36,6 @@ extern "C" {
|
||||
|
||||
using Alembic::AbcGeom::OObject;
|
||||
using Alembic::AbcGeom::OXform;
|
||||
using Alembic::Abc::ISampleSelector;
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -154,7 +153,7 @@ bool AbcEmptyReader::valid() const
|
||||
return m_schema.valid();
|
||||
}
|
||||
|
||||
void AbcEmptyReader::readObjectData(Main *bmain, const ISampleSelector &UNUSED(sample_sel))
|
||||
void AbcEmptyReader::readObjectData(Main *bmain, float /*time*/)
|
||||
{
|
||||
m_object = BKE_object_add_only_object(bmain, OB_EMPTY,
|
||||
m_object_name.c_str());
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
|
||||
bool valid() const;
|
||||
|
||||
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
|
||||
void readObjectData(Main *bmain, float time);
|
||||
};
|
||||
|
||||
#endif /* __ABC_TRANSFORM_H__ */
|
||||
|
@ -704,13 +704,12 @@ static void import_startjob(void *user_data, short *stop, short *do_update, floa
|
||||
chrono_t min_time = std::numeric_limits<chrono_t>::max();
|
||||
chrono_t max_time = std::numeric_limits<chrono_t>::min();
|
||||
|
||||
ISampleSelector sample_sel(0.0f);
|
||||
std::vector<AbcObjectReader *>::iterator iter;
|
||||
for (iter = data->readers.begin(); iter != data->readers.end(); ++iter) {
|
||||
AbcObjectReader *reader = *iter;
|
||||
|
||||
if (reader->valid()) {
|
||||
reader->readObjectData(data->bmain, sample_sel);
|
||||
reader->readObjectData(data->bmain, 0.0f);
|
||||
|
||||
min_time = std::min(min_time, reader->minTime());
|
||||
max_time = std::max(max_time, reader->maxTime());
|
||||
@ -923,7 +922,6 @@ DerivedMesh *ABC_read_mesh(CacheReader *reader,
|
||||
}
|
||||
|
||||
const ObjectHeader &header = iobject.getHeader();
|
||||
ISampleSelector sample_sel(time);
|
||||
|
||||
if (IPolyMesh::matches(header)) {
|
||||
if (ob->type != OB_MESH) {
|
||||
@ -931,7 +929,7 @@ DerivedMesh *ABC_read_mesh(CacheReader *reader,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return abc_reader->read_derivedmesh(dm, sample_sel, read_flag, err_str);
|
||||
return abc_reader->read_derivedmesh(dm, time, read_flag, err_str);
|
||||
}
|
||||
else if (ISubD::matches(header)) {
|
||||
if (ob->type != OB_MESH) {
|
||||
@ -939,7 +937,7 @@ DerivedMesh *ABC_read_mesh(CacheReader *reader,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return abc_reader->read_derivedmesh(dm, sample_sel, read_flag, err_str);
|
||||
return abc_reader->read_derivedmesh(dm, time, read_flag, err_str);
|
||||
}
|
||||
else if (IPoints::matches(header)) {
|
||||
if (ob->type != OB_MESH) {
|
||||
@ -947,7 +945,7 @@ DerivedMesh *ABC_read_mesh(CacheReader *reader,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return abc_reader->read_derivedmesh(dm, sample_sel, read_flag, err_str);
|
||||
return abc_reader->read_derivedmesh(dm, time, read_flag, err_str);
|
||||
}
|
||||
else if (ICurves::matches(header)) {
|
||||
if (ob->type != OB_CURVE) {
|
||||
@ -955,7 +953,7 @@ DerivedMesh *ABC_read_mesh(CacheReader *reader,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return abc_reader->read_derivedmesh(dm, sample_sel, read_flag, err_str);
|
||||
return abc_reader->read_derivedmesh(dm, time, read_flag, err_str);
|
||||
}
|
||||
|
||||
*err_str = "Unsupported object type: verify object path"; // or poke developer
|
||||
|
Loading…
Reference in New Issue
Block a user