Cleanup: use override/final for derived classes.

This will help detecting missing API changes. Those keywords were added
on classes which did not already use them. Also added missing
`accepts_object_type()` on NURBS reader.
This commit is contained in:
Kévin Dietrich 2021-09-25 09:30:12 +02:00
parent 43394e41a8
commit 505422220d
7 changed files with 51 additions and 27 deletions

View File

@ -23,18 +23,18 @@
namespace blender::io::alembic {
class AbcCameraReader : public AbcObjectReader {
class AbcCameraReader final : public AbcObjectReader {
Alembic::AbcGeom::ICameraSchema m_schema;
public:
AbcCameraReader(const Alembic::Abc::IObject &object, ImportSettings &settings);
bool valid() const;
bool valid() const override;
bool accepts_object_type(const Alembic::AbcCoreAbstract::ObjectHeader &alembic_header,
const Object *const ob,
const char **err_str) const;
const char **err_str) const override;
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel) override;
};
} // namespace blender::io::alembic

View File

@ -31,24 +31,24 @@ struct Curve;
namespace blender::io::alembic {
class AbcCurveReader : public AbcObjectReader {
class AbcCurveReader final : public AbcObjectReader {
Alembic::AbcGeom::ICurvesSchema m_curves_schema;
public:
AbcCurveReader(const Alembic::Abc::IObject &object, ImportSettings &settings);
bool valid() const;
bool valid() const override;
bool accepts_object_type(const Alembic::AbcCoreAbstract::ObjectHeader &alembic_header,
const Object *const ob,
const char **err_str) const;
const char **err_str) const override;
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel) override;
struct Mesh *read_mesh(struct Mesh *existing_mesh,
const Alembic::Abc::ISampleSelector &sample_sel,
const int read_flag,
const char *velocity_name,
const float velocity_scale,
const char **err_str);
const char **err_str) override;
void read_curve_sample(Curve *cu,
const Alembic::AbcGeom::ICurvesSchema &schema,

View File

@ -26,7 +26,7 @@ struct Mesh;
namespace blender::io::alembic {
class AbcMeshReader : public AbcObjectReader {
class AbcMeshReader final : public AbcObjectReader {
Alembic::AbcGeom::IPolyMeshSchema m_schema;
CDStreamConfig m_mesh_data;
@ -60,7 +60,7 @@ class AbcMeshReader : public AbcObjectReader {
std::map<std::string, int> &r_mat_map);
};
class AbcSubDReader : public AbcObjectReader {
class AbcSubDReader final : public AbcObjectReader {
Alembic::AbcGeom::ISubDSchema m_schema;
CDStreamConfig m_mesh_data;
@ -68,17 +68,17 @@ class AbcSubDReader : public AbcObjectReader {
public:
AbcSubDReader(const Alembic::Abc::IObject &object, ImportSettings &settings);
bool valid() const;
bool valid() const override;
bool accepts_object_type(const Alembic::AbcCoreAbstract::ObjectHeader &alembic_header,
const Object *const ob,
const char **err_str) const;
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
const char **err_str) const override;
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel) override;
struct Mesh *read_mesh(struct Mesh *existing_mesh,
const Alembic::Abc::ISampleSelector &sample_sel,
const int read_flag,
const char *velocity_name,
const float velocity_scale,
const char **err_str);
const char **err_str) override;
};
void read_mverts(MVert *mverts,

View File

@ -71,6 +71,26 @@ bool AbcNurbsReader::valid() const
return true;
}
bool AbcNurbsReader::accepts_object_type(
const Alembic::AbcCoreAbstract::v12::ObjectHeader &alembic_header,
const Object *const ob,
const char **err_str) const
{
if (!Alembic::AbcGeom::INuPatch::matches(alembic_header)) {
*err_str =
"Object type mismatch, Alembic object path pointed to NURBS when importing, but not any "
"more.";
return false;
}
if (ob->type != OB_CURVE) {
*err_str = "Object type mismatch, Alembic object path points to NURBS.";
return false;
}
return true;
}
static bool set_knots(const FloatArraySamplePtr &knots, float *&nu_knots)
{
if (!knots || knots->size() < 2) {

View File

@ -23,15 +23,19 @@
namespace blender::io::alembic {
class AbcNurbsReader : public AbcObjectReader {
class AbcNurbsReader final : public AbcObjectReader {
std::vector<std::pair<Alembic::AbcGeom::INuPatchSchema, Alembic::Abc::IObject>> m_schemas;
public:
AbcNurbsReader(const Alembic::Abc::IObject &object, ImportSettings &settings);
bool valid() const;
bool valid() const override;
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
bool accepts_object_type(const Alembic::AbcCoreAbstract::ObjectHeader &alembic_header,
const Object *const ob,
const char **err_str) const override;
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel) override;
private:
void getNurbsPatches(const Alembic::Abc::IObject &obj);

View File

@ -27,26 +27,26 @@
namespace blender::io::alembic {
class AbcPointsReader : public AbcObjectReader {
class AbcPointsReader final : public AbcObjectReader {
Alembic::AbcGeom::IPointsSchema m_schema;
Alembic::AbcGeom::IPointsSchema::Sample m_sample;
public:
AbcPointsReader(const Alembic::Abc::IObject &object, ImportSettings &settings);
bool valid() const;
bool valid() const override;
bool accepts_object_type(const Alembic::AbcCoreAbstract::ObjectHeader &alembic_header,
const Object *const ob,
const char **err_str) const;
const char **err_str) const override;
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel) override;
struct Mesh *read_mesh(struct Mesh *existing_mesh,
const Alembic::Abc::ISampleSelector &sample_sel,
int read_flag,
const char *velocity_name,
const float velocity_scale,
const char **err_str);
const char **err_str) override;
};
void read_points_sample(const Alembic::AbcGeom::IPointsSchema &schema,

View File

@ -25,18 +25,18 @@
namespace blender::io::alembic {
class AbcEmptyReader : public AbcObjectReader {
class AbcEmptyReader final : public AbcObjectReader {
Alembic::AbcGeom::IXformSchema m_schema;
public:
AbcEmptyReader(const Alembic::Abc::IObject &object, ImportSettings &settings);
bool valid() const;
bool valid() const override;
bool accepts_object_type(const Alembic::AbcCoreAbstract::ObjectHeader &alembic_header,
const Object *const ob,
const char **err_str) const;
const char **err_str) const override;
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel) override;
};
} // namespace blender::io::alembic