diff --git a/source/blender/editors/io/io_collada.cc b/source/blender/editors/io/io_collada.cc index 2a5eecf3dd9..a484bfc19c5 100644 --- a/source/blender/editors/io/io_collada.cc +++ b/source/blender/editors/io/io_collada.cc @@ -11,6 +11,7 @@ # include "BLT_translation.hh" # include "BLI_fileops.h" +# include "BLI_path_utils.hh" # include "BLI_string.h" # include "BKE_context.hh" diff --git a/source/blender/io/alembic/ABC_alembic.h b/source/blender/io/alembic/ABC_alembic.h index 6e25c29f707..f125cdcd853 100644 --- a/source/blender/io/alembic/ABC_alembic.h +++ b/source/blender/io/alembic/ABC_alembic.h @@ -22,7 +22,7 @@ struct Object; struct Scene; struct bContext; -int ABC_get_version(void); +int ABC_get_version(); struct AlembicExportParams { double frame_start; @@ -120,12 +120,12 @@ void ABC_get_transform(struct CacheReader *reader, double time, float scale); -typedef struct ABCReadParams { +struct ABCReadParams { double time; int read_flags; const char *velocity_name; float velocity_scale; -} ABCReadParams; +}; #ifdef __cplusplus namespace blender::bke { diff --git a/source/blender/io/alembic/exporter/abc_archive.h b/source/blender/io/alembic/exporter/abc_archive.h index 6004e905359..17dde986864 100644 --- a/source/blender/io/alembic/exporter/abc_archive.h +++ b/source/blender/io/alembic/exporter/abc_archive.h @@ -29,7 +29,7 @@ namespace blender::io::alembic { * metadata. */ class ABCArchive { public: - typedef std::set Frames; + using Frames = std::set; Alembic::Abc::OArchive *archive; diff --git a/source/blender/io/alembic/exporter/abc_hierarchy_iterator.h b/source/blender/io/alembic/exporter/abc_hierarchy_iterator.h index d4062fabf67..51d60229901 100644 --- a/source/blender/io/alembic/exporter/abc_hierarchy_iterator.h +++ b/source/blender/io/alembic/exporter/abc_hierarchy_iterator.h @@ -42,29 +42,26 @@ class ABCHierarchyIterator : public AbstractHierarchyIterator { ABCArchive *abc_archive, const AlembicExportParams ¶ms); - virtual void iterate_and_write() override; - virtual std::string make_valid_name(const std::string &name) const override; + void iterate_and_write() override; + std::string make_valid_name(const std::string &name) const override; Alembic::Abc::OObject get_alembic_object(const std::string &export_path) const; protected: - virtual bool mark_as_weak_export(const Object *object) const override; + bool mark_as_weak_export(const Object *object) const override; - virtual ExportGraph::key_type determine_graph_index_object( - const HierarchyContext *context) override; - virtual AbstractHierarchyIterator::ExportGraph::key_type determine_graph_index_dupli( + ExportGraph::key_type determine_graph_index_object(const HierarchyContext *context) override; + AbstractHierarchyIterator::ExportGraph::key_type determine_graph_index_dupli( const HierarchyContext *context, const DupliObject *dupli_object, const DupliParentFinder &dupli_parent_finder) override; - virtual AbstractHierarchyWriter *create_transform_writer( - const HierarchyContext *context) override; - virtual AbstractHierarchyWriter *create_data_writer(const HierarchyContext *context) override; - virtual AbstractHierarchyWriter *create_hair_writer(const HierarchyContext *context) override; - virtual AbstractHierarchyWriter *create_particle_writer( - const HierarchyContext *context) override; + AbstractHierarchyWriter *create_transform_writer(const HierarchyContext *context) override; + AbstractHierarchyWriter *create_data_writer(const HierarchyContext *context) override; + AbstractHierarchyWriter *create_hair_writer(const HierarchyContext *context) override; + AbstractHierarchyWriter *create_particle_writer(const HierarchyContext *context) override; - virtual void release_writer(AbstractHierarchyWriter *writer) override; + void release_writer(AbstractHierarchyWriter *writer) override; private: Alembic::Abc::OObject get_alembic_parent(const HierarchyContext *context) const; diff --git a/source/blender/io/alembic/exporter/abc_writer_abstract.h b/source/blender/io/alembic/exporter/abc_writer_abstract.h index 202f5c63ef9..0c30d5ae031 100644 --- a/source/blender/io/alembic/exporter/abc_writer_abstract.h +++ b/source/blender/io/alembic/exporter/abc_writer_abstract.h @@ -34,7 +34,7 @@ class ABCAbstractWriter : public AbstractHierarchyWriter { public: explicit ABCAbstractWriter(const ABCWriterConstructorArgs &args); - virtual void write(HierarchyContext &context) override; + void write(HierarchyContext &context) override; /* Returns true if the data to be written is actually supported. This would, for example, allow a * hypothetical camera writer accept a perspective camera but reject an orthogonal one. diff --git a/source/blender/io/alembic/exporter/abc_writer_camera.h b/source/blender/io/alembic/exporter/abc_writer_camera.h index 5a3f38cbf89..55d554210ce 100644 --- a/source/blender/io/alembic/exporter/abc_writer_camera.h +++ b/source/blender/io/alembic/exporter/abc_writer_camera.h @@ -25,12 +25,12 @@ class ABCCameraWriter : public ABCAbstractWriter { public: explicit ABCCameraWriter(const ABCWriterConstructorArgs &args); - virtual void create_alembic_objects(const HierarchyContext *context) override; - virtual Alembic::Abc::OObject get_alembic_object() const override; + void create_alembic_objects(const HierarchyContext *context) override; + Alembic::Abc::OObject get_alembic_object() const override; protected: - virtual bool is_supported(const HierarchyContext *context) const override; - virtual void do_write(HierarchyContext &context) override; + bool is_supported(const HierarchyContext *context) const override; + void do_write(HierarchyContext &context) override; Alembic::Abc::OCompoundProperty abc_prop_for_custom_props() override; }; diff --git a/source/blender/io/alembic/exporter/abc_writer_curves.h b/source/blender/io/alembic/exporter/abc_writer_curves.h index b0bc1bf9204..528fa1f0ecb 100644 --- a/source/blender/io/alembic/exporter/abc_writer_curves.h +++ b/source/blender/io/alembic/exporter/abc_writer_curves.h @@ -24,12 +24,12 @@ class ABCCurveWriter : public ABCAbstractWriter { public: explicit ABCCurveWriter(const ABCWriterConstructorArgs &args); - virtual void create_alembic_objects(const HierarchyContext *context) override; - virtual Alembic::Abc::OObject get_alembic_object() const override; + void create_alembic_objects(const HierarchyContext *context) override; + Alembic::Abc::OObject get_alembic_object() const override; Alembic::Abc::OCompoundProperty abc_prop_for_custom_props() override; protected: - virtual void do_write(HierarchyContext &context) override; + void do_write(HierarchyContext &context) override; }; class ABCCurveMeshWriter : public ABCGenericMeshWriter { @@ -37,7 +37,7 @@ class ABCCurveMeshWriter : public ABCGenericMeshWriter { ABCCurveMeshWriter(const ABCWriterConstructorArgs &args); protected: - virtual Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) override; + Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) override; }; } // namespace blender::io::alembic diff --git a/source/blender/io/alembic/exporter/abc_writer_hair.h b/source/blender/io/alembic/exporter/abc_writer_hair.h index 6c03fdc2799..5a69f4ae48b 100644 --- a/source/blender/io/alembic/exporter/abc_writer_hair.h +++ b/source/blender/io/alembic/exporter/abc_writer_hair.h @@ -23,12 +23,12 @@ class ABCHairWriter : public ABCAbstractWriter { public: explicit ABCHairWriter(const ABCWriterConstructorArgs &args); - virtual void create_alembic_objects(const HierarchyContext *context) override; - virtual Alembic::Abc::OObject get_alembic_object() const override; + void create_alembic_objects(const HierarchyContext *context) override; + Alembic::Abc::OObject get_alembic_object() const override; protected: - virtual void do_write(HierarchyContext &context) override; - virtual bool check_is_animated(const HierarchyContext &context) const override; + void do_write(HierarchyContext &context) override; + bool check_is_animated(const HierarchyContext &context) const override; Alembic::Abc::OCompoundProperty abc_prop_for_custom_props() override; private: diff --git a/source/blender/io/alembic/exporter/abc_writer_instance.h b/source/blender/io/alembic/exporter/abc_writer_instance.h index 9bd3a29e102..e2a0618b21a 100644 --- a/source/blender/io/alembic/exporter/abc_writer_instance.h +++ b/source/blender/io/alembic/exporter/abc_writer_instance.h @@ -20,12 +20,12 @@ class ABCInstanceWriter : public ABCAbstractWriter { public: explicit ABCInstanceWriter(const ABCWriterConstructorArgs &args); - virtual void create_alembic_objects(const HierarchyContext *context) override; - virtual Alembic::Abc::OObject get_alembic_object() const override; + void create_alembic_objects(const HierarchyContext *context) override; + Alembic::Abc::OObject get_alembic_object() const override; protected: - virtual bool is_supported(const HierarchyContext *context) const override; - virtual void do_write(HierarchyContext &context) override; + bool is_supported(const HierarchyContext *context) const override; + void do_write(HierarchyContext &context) override; void ensure_custom_properties_exporter(const HierarchyContext &context) override; Alembic::Abc::OCompoundProperty abc_prop_for_custom_props() override; }; diff --git a/source/blender/io/alembic/exporter/abc_writer_mball.h b/source/blender/io/alembic/exporter/abc_writer_mball.h index 257ac4b7b9a..9c8b289c763 100644 --- a/source/blender/io/alembic/exporter/abc_writer_mball.h +++ b/source/blender/io/alembic/exporter/abc_writer_mball.h @@ -16,11 +16,11 @@ class ABCMetaballWriter : public ABCGenericMeshWriter { explicit ABCMetaballWriter(const ABCWriterConstructorArgs &args); protected: - virtual Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) override; - virtual void free_export_mesh(Mesh *mesh) override; - virtual bool is_supported(const HierarchyContext *context) const override; - virtual bool check_is_animated(const HierarchyContext &context) const override; - virtual bool export_as_subdivision_surface(Object *ob_eval) const override; + Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) override; + void free_export_mesh(Mesh *mesh) override; + bool is_supported(const HierarchyContext *context) const override; + bool check_is_animated(const HierarchyContext &context) const override; + bool export_as_subdivision_surface(Object *ob_eval) const override; private: bool is_basis_ball(Scene *scene, Object *ob) const; diff --git a/source/blender/io/alembic/exporter/abc_writer_mesh.cc b/source/blender/io/alembic/exporter/abc_writer_mesh.cc index a72506ee917..9739b84a957 100644 --- a/source/blender/io/alembic/exporter/abc_writer_mesh.cc +++ b/source/blender/io/alembic/exporter/abc_writer_mesh.cc @@ -10,8 +10,6 @@ #include "abc_hierarchy_iterator.h" #include "intern/abc_axis_conversion.h" -#include "BLI_math_vector.h" - #include "BKE_attribute.hh" #include "BKE_lib_id.hh" #include "BKE_material.hh" diff --git a/source/blender/io/alembic/exporter/abc_writer_mesh.h b/source/blender/io/alembic/exporter/abc_writer_mesh.h index a25122cefb4..9b30bf21540 100644 --- a/source/blender/io/alembic/exporter/abc_writer_mesh.h +++ b/source/blender/io/alembic/exporter/abc_writer_mesh.h @@ -39,13 +39,13 @@ class ABCGenericMeshWriter : public ABCAbstractWriter { public: explicit ABCGenericMeshWriter(const ABCWriterConstructorArgs &args); - virtual void create_alembic_objects(const HierarchyContext *context) override; - virtual Alembic::Abc::OObject get_alembic_object() const override; + void create_alembic_objects(const HierarchyContext *context) override; + Alembic::Abc::OObject get_alembic_object() const override; Alembic::Abc::OCompoundProperty abc_prop_for_custom_props() override; protected: - virtual bool is_supported(const HierarchyContext *context) const override; - virtual void do_write(HierarchyContext &context) override; + bool is_supported(const HierarchyContext *context) const override; + void do_write(HierarchyContext &context) override; virtual Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) = 0; virtual void free_export_mesh(Mesh *mesh); @@ -70,7 +70,7 @@ class ABCMeshWriter : public ABCGenericMeshWriter { ABCMeshWriter(const ABCWriterConstructorArgs &args); protected: - virtual Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) override; + Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) override; }; } // namespace blender::io::alembic diff --git a/source/blender/io/alembic/exporter/abc_writer_nurbs.h b/source/blender/io/alembic/exporter/abc_writer_nurbs.h index b16bf2f8156..eb650824643 100644 --- a/source/blender/io/alembic/exporter/abc_writer_nurbs.h +++ b/source/blender/io/alembic/exporter/abc_writer_nurbs.h @@ -24,13 +24,13 @@ class ABCNurbsWriter : public ABCAbstractWriter { public: explicit ABCNurbsWriter(const ABCWriterConstructorArgs &args); - virtual void create_alembic_objects(const HierarchyContext *context) override; - virtual Alembic::Abc::OObject get_alembic_object() const override; + void create_alembic_objects(const HierarchyContext *context) override; + Alembic::Abc::OObject get_alembic_object() const override; protected: - virtual bool is_supported(const HierarchyContext *context) const override; - virtual void do_write(HierarchyContext &context) override; - virtual bool check_is_animated(const HierarchyContext &context) const override; + bool is_supported(const HierarchyContext *context) const override; + void do_write(HierarchyContext &context) override; + bool check_is_animated(const HierarchyContext &context) const override; Alembic::Abc::OCompoundProperty abc_prop_for_custom_props() override; }; @@ -39,7 +39,7 @@ class ABCNurbsMeshWriter : public ABCGenericMeshWriter { explicit ABCNurbsMeshWriter(const ABCWriterConstructorArgs &args); protected: - virtual Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) override; + Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) override; }; } // namespace blender::io::alembic diff --git a/source/blender/io/alembic/exporter/abc_writer_points.h b/source/blender/io/alembic/exporter/abc_writer_points.h index d1fb49a0d81..0de19e5c1c5 100644 --- a/source/blender/io/alembic/exporter/abc_writer_points.h +++ b/source/blender/io/alembic/exporter/abc_writer_points.h @@ -20,15 +20,15 @@ class ABCPointsWriter : public ABCAbstractWriter { public: explicit ABCPointsWriter(const ABCWriterConstructorArgs &args); - virtual void create_alembic_objects(const HierarchyContext *context) override; - virtual Alembic::Abc::OObject get_alembic_object() const override; + void create_alembic_objects(const HierarchyContext *context) override; + Alembic::Abc::OObject get_alembic_object() const override; Alembic::Abc::OCompoundProperty abc_prop_for_custom_props() override; - virtual bool is_supported(const HierarchyContext *context) const override; + bool is_supported(const HierarchyContext *context) const override; protected: - virtual bool check_is_animated(const HierarchyContext &context) const override; - virtual void do_write(HierarchyContext &context) override; + bool check_is_animated(const HierarchyContext &context) const override; + void do_write(HierarchyContext &context) override; }; } // namespace blender::io::alembic diff --git a/source/blender/io/alembic/exporter/abc_writer_transform.h b/source/blender/io/alembic/exporter/abc_writer_transform.h index 8d03299fc78..c7f81498a8c 100644 --- a/source/blender/io/alembic/exporter/abc_writer_transform.h +++ b/source/blender/io/alembic/exporter/abc_writer_transform.h @@ -20,12 +20,12 @@ class ABCTransformWriter : public ABCAbstractWriter { public: explicit ABCTransformWriter(const ABCWriterConstructorArgs &args); - virtual void create_alembic_objects(const HierarchyContext *context) override; + void create_alembic_objects(const HierarchyContext *context) override; protected: - virtual void do_write(HierarchyContext &context) override; - virtual bool check_is_animated(const HierarchyContext &context) const override; - virtual Alembic::Abc::OObject get_alembic_object() const override; + void do_write(HierarchyContext &context) override; + bool check_is_animated(const HierarchyContext &context) const override; + Alembic::Abc::OObject get_alembic_object() const override; const IDProperty *get_id_properties(const HierarchyContext &context) const override; Alembic::Abc::OCompoundProperty abc_prop_for_custom_props() override; }; diff --git a/source/blender/io/alembic/intern/abc_axis_conversion.h b/source/blender/io/alembic/intern/abc_axis_conversion.h index 02e8a752b52..cc8275a1d53 100644 --- a/source/blender/io/alembic/intern/abc_axis_conversion.h +++ b/source/blender/io/alembic/intern/abc_axis_conversion.h @@ -57,10 +57,10 @@ BLI_INLINE void copy_yup_from_zup(short yup[3], const short zup[3]) /* Names are given in (dst, src) order, just like * the parameters of copy_m44_axis_swap(). */ -typedef enum { +enum AbcAxisSwapMode { ABC_ZUP_FROM_YUP = 1, ABC_YUP_FROM_ZUP = 2, -} AbcAxisSwapMode; +}; /** * Create a rotation matrix for each axis from euler angles. @@ -78,10 +78,10 @@ void create_swapped_rotation_matrix(float rot_x_mat[3][3], */ void copy_m44_axis_swap(float dst_mat[4][4], float src_mat[4][4], AbcAxisSwapMode mode); -typedef enum { +enum AbcMatrixMode { ABC_MATRIX_WORLD = 1, ABC_MATRIX_LOCAL = 2, -} AbcMatrixMode; +}; /** * Recompute transform matrix of object in new coordinate system diff --git a/source/blender/io/alembic/intern/abc_customdata.h b/source/blender/io/alembic/intern/abc_customdata.h index 65b78c7f8cf..20a20026c24 100644 --- a/source/blender/io/alembic/intern/abc_customdata.h +++ b/source/blender/io/alembic/intern/abc_customdata.h @@ -36,30 +36,30 @@ struct UVSample { }; struct CDStreamConfig { - int *corner_verts; - int totloop; + int *corner_verts = nullptr; + int totloop = 0; - int *face_offsets; - int faces_num; + int *face_offsets = nullptr; + int faces_num = 0; - float3 *positions; - int totvert; + float3 *positions = nullptr; + int totvert = 0; - float2 *mloopuv; + float2 *mloopuv = nullptr; - CustomData *loopdata; + CustomData *loopdata = nullptr; - bool pack_uvs; + bool pack_uvs = false; /* TODO(kevin): might need a better way to handle adding and/or updating * custom data such that it updates the custom data holder and its pointers properly. */ - Mesh *mesh; - void *(*add_customdata_cb)(Mesh *mesh, const char *name, int data_type); + Mesh *mesh = nullptr; + void *(*add_customdata_cb)(Mesh *mesh, const char *name, int data_type) = nullptr; - Alembic::Abc::chrono_t time; - int timesample_index; + Alembic::Abc::chrono_t time = 0.0; + int timesample_index = 0; - const char **modifier_error_message; + const char **modifier_error_message = nullptr; /* Alembic needs Blender to keep references to C++ objects (the destructors finalize the writing * to ABC). The following fields are all used to keep these references. */ @@ -74,19 +74,7 @@ struct CDStreamConfig { /* Mapping from vertex color layer name to its Alembic color data. */ std::map abc_vertex_colors; - CDStreamConfig() - : corner_verts(NULL), - totloop(0), - face_offsets(NULL), - faces_num(0), - totvert(0), - pack_uvs(false), - mesh(NULL), - add_customdata_cb(NULL), - time(0.0), - modifier_error_message(NULL) - { - } + CDStreamConfig() = default; }; /* Get the UVs for the main UV property on a OSchema. @@ -115,11 +103,11 @@ void read_custom_data(const std::string &iobject_full_name, const CDStreamConfig &config, const Alembic::Abc::ISampleSelector &iss); -typedef enum { +enum AbcUvScope { ABC_UV_SCOPE_NONE, ABC_UV_SCOPE_LOOP, ABC_UV_SCOPE_VERTEX, -} AbcUvScope; +}; /** * UVs can be defined per-loop (one value per vertex per face), or per-vertex (one value per diff --git a/source/blender/io/alembic/intern/abc_reader_nurbs.cc b/source/blender/io/alembic/intern/abc_reader_nurbs.cc index 56a7e33116b..8a5d4586313 100644 --- a/source/blender/io/alembic/intern/abc_reader_nurbs.cc +++ b/source/blender/io/alembic/intern/abc_reader_nurbs.cc @@ -98,7 +98,7 @@ static bool set_knots(const FloatArraySamplePtr &knots, float *&nu_knots) void AbcNurbsReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel) { - Curve *cu = static_cast(BKE_curve_add(bmain, m_data_name.c_str(), OB_SURF)); + Curve *cu = BKE_curve_add(bmain, m_data_name.c_str(), OB_SURF); cu->actvert = CU_ACT_NONE; std::vector>::iterator it; diff --git a/source/blender/io/alembic/intern/abc_reader_object.cc b/source/blender/io/alembic/intern/abc_reader_object.cc index d437bd251e6..41f62b27d8e 100644 --- a/source/blender/io/alembic/intern/abc_reader_object.cc +++ b/source/blender/io/alembic/intern/abc_reader_object.cc @@ -24,7 +24,6 @@ #include "BLI_listbase.h" #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" -#include "BLI_math_vector.h" #include "BLI_string.h" using Alembic::AbcGeom::IObject; diff --git a/source/blender/io/alembic/intern/abc_reader_object.h b/source/blender/io/alembic/intern/abc_reader_object.h index ca87c7635f8..cfa7cda48de 100644 --- a/source/blender/io/alembic/intern/abc_reader_object.h +++ b/source/blender/io/alembic/intern/abc_reader_object.h @@ -30,48 +30,32 @@ using Alembic::AbcCoreAbstract::chrono_t; namespace blender::io::alembic { struct ImportSettings { - bool do_convert_mat; + bool do_convert_mat = false; float conversion_mat[4][4]; - int from_up; - int from_forward; - float scale; - bool is_sequence; - bool set_frame_range; + int from_up = 0; + int from_forward = 0; + float scale = 1.0f; + bool is_sequence = false; + bool set_frame_range = false; /* Min and max frame detected from file sequences. */ - int sequence_min_frame; - int sequence_max_frame; + int sequence_min_frame = 0; + int sequence_max_frame = 1; /* From MeshSeqCacheModifierData.read_flag */ - int read_flag; + int read_flag = 0; /* From CacheFile and MeshSeqCacheModifierData */ std::string velocity_name; - float velocity_scale; + float velocity_scale = 1.0f; - bool validate_meshes; - bool always_add_cache_reader; + bool validate_meshes = false; + bool always_add_cache_reader = false; - CacheFile *cache_file; + CacheFile *cache_file = nullptr; - ImportSettings() - : do_convert_mat(false), - from_up(0), - from_forward(0), - scale(1.0f), - is_sequence(false), - set_frame_range(false), - sequence_min_frame(0), - sequence_max_frame(1), - read_flag(0), - velocity_name(""), - velocity_scale(1.0f), - validate_meshes(false), - always_add_cache_reader(false), - cache_file(NULL) - { - } + ImportSettings() = default; }; template static bool has_animations(Schema &schema, ImportSettings *settings) @@ -105,14 +89,13 @@ class AbcObjectReader { public: AbcObjectReader *parent_reader; - public: explicit AbcObjectReader(const Alembic::Abc::IObject &object, ImportSettings &settings); virtual ~AbcObjectReader() = default; const Alembic::Abc::IObject &iobject() const; - typedef std::vector ptr_vector; + using ptr_vector = std::vector; /** * Returns the transform of this object. This can be the Alembic object diff --git a/source/blender/io/alembic/intern/abc_reader_points.cc b/source/blender/io/alembic/intern/abc_reader_points.cc index 10e6d399026..87aa3cfbd59 100644 --- a/source/blender/io/alembic/intern/abc_reader_points.cc +++ b/source/blender/io/alembic/intern/abc_reader_points.cc @@ -19,8 +19,6 @@ #include "BKE_object.hh" #include "BKE_pointcloud.hh" -#include "BLI_math_vector.h" - using namespace Alembic::AbcGeom; namespace blender::io::alembic { diff --git a/source/blender/io/alembic/intern/abc_util.h b/source/blender/io/alembic/intern/abc_util.h index 16bae242618..6e2844e15d6 100644 --- a/source/blender/io/alembic/intern/abc_util.h +++ b/source/blender/io/alembic/intern/abc_util.h @@ -18,7 +18,6 @@ #include #include -#include #include #include #include diff --git a/source/blender/io/alembic/intern/alembic_capi.cc b/source/blender/io/alembic/intern/alembic_capi.cc index 132ff1540a1..8551d3029bf 100644 --- a/source/blender/io/alembic/intern/alembic_capi.cc +++ b/source/blender/io/alembic/intern/alembic_capi.cc @@ -10,14 +10,16 @@ #include "IO_types.hh" #include +#include #include -#include "abc_axis_conversion.h" #include "abc_reader_archive.h" #include "abc_reader_camera.h" #include "abc_reader_curves.h" #include "abc_reader_mesh.h" -#include "abc_reader_nurbs.h" +#ifdef USE_NURBS +# include "abc_reader_nurbs.h" +#endif #include "abc_reader_points.h" #include "abc_reader_transform.h" #include "abc_util.h" @@ -839,12 +841,12 @@ void ABC_read_geometry(CacheReader *reader, } ISampleSelector sample_sel = sample_selector_for_time(params->time); - return abc_reader->read_geometry(geometry_set, - sample_sel, - params->read_flags, - params->velocity_name, - params->velocity_scale, - r_err_str); + abc_reader->read_geometry(geometry_set, + sample_sel, + params->read_flags, + params->velocity_name, + params->velocity_scale, + r_err_str); } bool ABC_mesh_topology_changed(CacheReader *reader, diff --git a/source/blender/io/alembic/tests/abc_export_test.cc b/source/blender/io/alembic/tests/abc_export_test.cc index f9b89498151..9f062b1ce57 100644 --- a/source/blender/io/alembic/tests/abc_export_test.cc +++ b/source/blender/io/alembic/tests/abc_export_test.cc @@ -6,12 +6,10 @@ /* Keep first since utildefines defines AT which conflicts with STL */ #include "exporter/abc_archive.h" -#include "intern/abc_util.h" #include "BKE_main.hh" #include "BLI_fileops.h" #include "BLI_string.h" -#include "BLI_utildefines.h" #include "DNA_scene_types.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/io/alembic/tests/abc_matrix_test.cc b/source/blender/io/alembic/tests/abc_matrix_test.cc index a9afe4d9ec2..6dcbf715f4b 100644 --- a/source/blender/io/alembic/tests/abc_matrix_test.cc +++ b/source/blender/io/alembic/tests/abc_matrix_test.cc @@ -9,7 +9,6 @@ #include "BLI_math_base.h" #include "BLI_math_matrix.h" -#include "BLI_utildefines.h" namespace blender::io::alembic { diff --git a/source/blender/io/collada/AnimationClipExporter.cpp b/source/blender/io/collada/AnimationClipExporter.cpp index ef6c3393f65..8dfea48bd0f 100644 --- a/source/blender/io/collada/AnimationClipExporter.cpp +++ b/source/blender/io/collada/AnimationClipExporter.cpp @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ #include "AnimationClipExporter.h" -#include "GeometryExporter.h" -#include "MaterialExporter.h" void AnimationClipExporter::exportAnimationClips(Scene *sce) { diff --git a/source/blender/io/collada/AnimationClipExporter.h b/source/blender/io/collada/AnimationClipExporter.h index 7166896cb84..85c16ff7065 100644 --- a/source/blender/io/collada/AnimationClipExporter.h +++ b/source/blender/io/collada/AnimationClipExporter.h @@ -4,9 +4,7 @@ #pragma once -#include -#include -#include +#include #include "COLLADASWLibraryAnimationClips.h" #include "DEG_depsgraph.hh" @@ -15,7 +13,7 @@ class AnimationClipExporter : COLLADASW::LibraryAnimationClips { private: Depsgraph *depsgraph; - Scene *scene; + Scene *scene = nullptr; COLLADASW::StreamWriter *sw; BCExportSettings &export_settings; std::vector> anim_meta; @@ -27,7 +25,6 @@ class AnimationClipExporter : COLLADASW::LibraryAnimationClips { std::vector> anim_meta) : COLLADASW::LibraryAnimationClips(sw), depsgraph(depsgraph), - scene(nullptr), sw(sw), export_settings(export_settings), anim_meta(anim_meta) diff --git a/source/blender/io/collada/AnimationExporter.cpp b/source/blender/io/collada/AnimationExporter.cpp index e939f7cc970..ba0d0c679a9 100644 --- a/source/blender/io/collada/AnimationExporter.cpp +++ b/source/blender/io/collada/AnimationExporter.cpp @@ -7,12 +7,13 @@ */ #include "AnimationExporter.h" -#include "AnimationClipExporter.h" #include "BCAnimationSampler.h" -#include "GeometryExporter.h" -#include "MaterialExporter.h" #include "collada_utils.h" +#include "BKE_material.hh" + +#include "BLI_string.h" + std::string EMPTY_STRING; std::string AnimationExporter::get_axis_name(std::string channel_type, int id) @@ -388,7 +389,6 @@ void AnimationExporter::export_collada_curve_animation( BCValues values; curve.get_frames(frames); curve.get_values(values); - std::string channel_target = curve.get_channel_target(); fprintf( stdout, "Export animation curve %s (%d control points)\n", id.c_str(), int(frames.size())); @@ -503,31 +503,31 @@ void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNa { switch (semantic) { case COLLADASW::InputSemantic::INPUT: - param.push_back("TIME"); + param.emplace_back("TIME"); break; case COLLADASW::InputSemantic::OUTPUT: if (is_rot) { - param.push_back("ANGLE"); + param.emplace_back("ANGLE"); } else { if (!axis.empty()) { param.push_back(axis); } else if (transform) { - param.push_back("TRANSFORM"); + param.emplace_back("TRANSFORM"); } else { /* assumes if axis isn't specified all axes are added */ - param.push_back("X"); - param.push_back("Y"); - param.push_back("Z"); + param.emplace_back("X"); + param.emplace_back("Y"); + param.emplace_back("Z"); } } break; case COLLADASW::InputSemantic::IN_TANGENT: case COLLADASW::InputSemantic::OUT_TANGENT: - param.push_back("X"); - param.push_back("Y"); + param.emplace_back("X"); + param.emplace_back("Y"); break; default: break; @@ -680,7 +680,7 @@ std::string AnimationExporter::collada_interpolation_source(const BCAnimationCur source.setAccessorStride(1); COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - param.push_back("INTERPOLATION"); + param.emplace_back("INTERPOLATION"); source.prepareToAppendValues(); @@ -723,7 +723,7 @@ std::string AnimationExporter::collada_linear_interpolation_source(int tot, source.setAccessorStride(1); COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - param.push_back("INTERPOLATION"); + param.emplace_back("INTERPOLATION"); source.prepareToAppendValues(); @@ -791,7 +791,6 @@ std::string AnimationExporter::get_collada_name(std::string channel_type) const std::string AnimationExporter::get_collada_sid(const BCAnimationCurve &curve, const std::string axis_name) { - std::string channel_target = curve.get_channel_target(); std::string channel_type = curve.get_channel_type(); std::string tm_name = get_collada_name(channel_type); diff --git a/source/blender/io/collada/AnimationExporter.h b/source/blender/io/collada/AnimationExporter.h index 7760bd819a1..d0ecc2a6d0a 100644 --- a/source/blender/io/collada/AnimationExporter.h +++ b/source/blender/io/collada/AnimationExporter.h @@ -4,73 +4,29 @@ #pragma once -#include -#include -#include +#include #include "BCAnimationCurve.h" #include "DNA_action_types.h" -#include "DNA_anim_types.h" #include "DNA_armature_types.h" -#include "DNA_camera_types.h" -#include "DNA_constraint_types.h" -#include "DNA_curve_types.h" -#include "DNA_light_types.h" -#include "DNA_material_types.h" #include "DNA_object_types.h" -#include "DNA_scene_types.h" -#include "BLI_listbase.h" -#include "BLI_string.h" -#include "BLI_utildefines.h" - -#include "BIK_api.h" -#include "BKE_action.hh" /* pose functions */ -#include "BKE_armature.hh" -#include "BKE_constraint.h" -#include "BKE_fcurve.hh" -#include "BKE_object.hh" -#include "BKE_scene.hh" -#include "ED_object.hh" - -#include "MEM_guardedalloc.h" - -#include "RNA_access.hh" - -#include "COLLADASWBaseInputElement.h" -#include "COLLADASWConstants.h" #include "COLLADASWInputList.h" -#include "COLLADASWInstanceGeometry.h" #include "COLLADASWLibraryAnimations.h" -#include "COLLADASWParamBase.h" -#include "COLLADASWParamTemplate.h" -#include "COLLADASWPrimitves.h" -#include "COLLADASWSampler.h" #include "COLLADASWSource.h" -#include "COLLADASWVertices.h" #include "BCAnimationSampler.h" -#include "EffectExporter.h" -#include "collada_internal.h" -#include "IK_solver.h" - -#include /* std::find */ -#include #include -typedef enum BC_animation_source_type { +enum BC_animation_source_type { BC_SOURCE_TYPE_VALUE, BC_SOURCE_TYPE_ANGLE, BC_SOURCE_TYPE_TIMEFRAME, -} BC_animation_source_type; +}; -typedef enum BC_global_rotation_type { - BC_NO_ROTATION, - BC_OBJECT_ROTATION, - BC_DATA_ROTATION -} BC_global_rotation_type; +enum BC_global_rotation_type { BC_NO_ROTATION, BC_OBJECT_ROTATION, BC_DATA_ROTATION }; class AnimationExporter : COLLADASW::LibraryAnimations { private: diff --git a/source/blender/io/collada/AnimationImporter.cpp b/source/blender/io/collada/AnimationImporter.cpp index 87fda6d48d2..e1c07ef80b8 100644 --- a/source/blender/io/collada/AnimationImporter.cpp +++ b/source/blender/io/collada/AnimationImporter.cpp @@ -8,8 +8,15 @@ #include -/* COLLADABU_ASSERT, may be able to remove later */ -#include "COLLADABUPlatform.h" +#include "COLLADAFWAnimation.h" +#include "COLLADAFWAnimationCurve.h" +#include "COLLADAFWAnimationList.h" +#include "COLLADAFWCamera.h" +#include "COLLADAFWEffect.h" +#include "COLLADAFWLight.h" +#include "COLLADAFWNode.h" +#include "COLLADAFWRotate.h" +#include "COLLADAFWUniqueId.h" #include "DNA_armature_types.h" @@ -20,23 +27,16 @@ #include "ANIM_animdata.hh" #include "ANIM_fcurve.hh" -#include "BLI_listbase.h" #include "BLI_math_matrix.h" #include "BLI_string.h" -#include "BLI_string_utils.hh" - -#include "BLT_translation.hh" #include "BKE_action.hh" #include "BKE_armature.hh" #include "BKE_fcurve.hh" #include "BKE_object.hh" -#include "MEM_guardedalloc.h" - #include "AnimationImporter.h" #include "ArmatureImporter.h" -#include "MaterialExporter.h" #include "collada_utils.h" #include diff --git a/source/blender/io/collada/AnimationImporter.h b/source/blender/io/collada/AnimationImporter.h index f0b3156a120..3cc758f4109 100644 --- a/source/blender/io/collada/AnimationImporter.h +++ b/source/blender/io/collada/AnimationImporter.h @@ -14,11 +14,6 @@ #include "COLLADAFWAnimation.h" #include "COLLADAFWAnimationCurve.h" #include "COLLADAFWAnimationList.h" -#include "COLLADAFWCamera.h" -#include "COLLADAFWEffect.h" -#include "COLLADAFWInstanceGeometry.h" -#include "COLLADAFWLight.h" -#include "COLLADAFWMaterial.h" #include "COLLADAFWNode.h" #include "COLLADAFWUniqueId.h" @@ -27,7 +22,6 @@ #include "DNA_anim_types.h" #include "DNA_camera_types.h" -#include "DNA_light_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" diff --git a/source/blender/io/collada/ArmatureExporter.cpp b/source/blender/io/collada/ArmatureExporter.cpp index b32b4f4f973..bd3aff68253 100644 --- a/source/blender/io/collada/ArmatureExporter.cpp +++ b/source/blender/io/collada/ArmatureExporter.cpp @@ -6,18 +6,9 @@ * \ingroup collada */ -#include "COLLADASWBaseInputElement.h" #include "COLLADASWInstanceController.h" -#include "COLLADASWPrimitves.h" -#include "COLLADASWSource.h" -#include "DNA_action_types.h" -#include "DNA_modifier_types.h" - -#include "BKE_action.hh" #include "BKE_armature.hh" -#include "BKE_global.hh" -#include "BKE_mesh.hh" #include "ED_armature.hh" @@ -25,9 +16,10 @@ #include "BLI_math_matrix.h" #include "ArmatureExporter.h" -#include "GeometryExporter.h" #include "SceneExporter.h" +#include "collada_utils.h" + void ArmatureExporter::add_bone_collections(Object *ob_arm, COLLADASW::Node &node) { bArmature *armature = (bArmature *)ob_arm->data; @@ -190,7 +182,7 @@ void ArmatureExporter::add_bone_node(Bone *bone, } } - std::string collection_names = ""; + std::string collection_names; LISTBASE_FOREACH (const BoneCollectionReference *, bcoll_ref, &bone->runtime.collections) { collection_names += std::string(bcoll_ref->bcoll->name) + "\n"; } diff --git a/source/blender/io/collada/ArmatureExporter.h b/source/blender/io/collada/ArmatureExporter.h index b533e74cac2..fb222f89dce 100644 --- a/source/blender/io/collada/ArmatureExporter.h +++ b/source/blender/io/collada/ArmatureExporter.h @@ -8,9 +8,7 @@ #pragma once -#include #include -// #include #include #include @@ -19,11 +17,7 @@ #include #include "DNA_armature_types.h" -#include "DNA_constraint_types.h" -#include "DNA_listBase.h" -#include "DNA_mesh_types.h" #include "DNA_object_types.h" -#include "DNA_scene_types.h" #include "InstanceWriter.h" #include "TransformWriter.h" @@ -85,7 +79,7 @@ class ArmatureExporter : public COLLADASW::LibraryControllers, SceneExporter *se, std::vector &child_objects); - inline bool can_export(Bone *bone) + bool can_export(Bone *bone) { return !(export_settings.get_deform_bones_only() && bone->flag & BONE_NO_DEFORM); } diff --git a/source/blender/io/collada/ArmatureImporter.cpp b/source/blender/io/collada/ArmatureImporter.cpp index a719f0421e3..e9e24535906 100644 --- a/source/blender/io/collada/ArmatureImporter.cpp +++ b/source/blender/io/collada/ArmatureImporter.cpp @@ -6,10 +6,8 @@ * \ingroup collada */ -/* COLLADABU_ASSERT, may be able to remove later */ -#include "COLLADABUPlatform.h" - #include +#include #include "COLLADAFWUniqueId.h" @@ -201,9 +199,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin, for (uint i = 0; i < children.getCount(); i++) { int cl = create_bone(skin, children[i], bone, children.getCount(), mat, arm, layer_labels); - if (cl > chain_length) { - chain_length = cl; - } + chain_length = std::max(cl, chain_length); } bone->length = len_v3v3(bone->head, bone->tail); diff --git a/source/blender/io/collada/ArmatureImporter.h b/source/blender/io/collada/ArmatureImporter.h index ae35c7ef7c5..f9bc21cb65e 100644 --- a/source/blender/io/collada/ArmatureImporter.h +++ b/source/blender/io/collada/ArmatureImporter.h @@ -133,7 +133,7 @@ class ArmatureImporter : private TransformReader { void create_armature_bones(Main *bmain, std::vector &arm_objs); /** TagsMap typedef for uid_tags_map. */ - typedef std::map TagsMap; + using TagsMap = std::map; TagsMap uid_tags_map; public: diff --git a/source/blender/io/collada/BCAnimationCurve.cpp b/source/blender/io/collada/BCAnimationCurve.cpp index 2974c8c4d00..e3b37f01af7 100644 --- a/source/blender/io/collada/BCAnimationCurve.cpp +++ b/source/blender/io/collada/BCAnimationCurve.cpp @@ -2,10 +2,26 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "DNA_anim_types.h" +#include "DNA_camera_types.h" +#include "DNA_light_types.h" +#include "DNA_material_types.h" + +#include "BLI_string.h" + +#include "BKE_material.hh" + +#include "RNA_access.hh" #include "RNA_path.hh" +#include "ANIM_fcurve.hh" + #include "BCAnimationCurve.h" +#include "collada_utils.h" + +#include + BCAnimationCurve::BCAnimationCurve() { this->curve_key.set_object_type(BC_ANIMATION_TYPE_OBJECT); @@ -351,12 +367,8 @@ float BCAnimationCurve::get_value(const float frame) void BCAnimationCurve::update_range(float val) { - if (val < min) { - min = val; - } - if (val > max) { - max = val; - } + min = std::min(val, min); + max = std::max(val, max); } void BCAnimationCurve::init_range(float val) diff --git a/source/blender/io/collada/BCAnimationCurve.h b/source/blender/io/collada/BCAnimationCurve.h index e4f7907ebdd..bbc12d23242 100644 --- a/source/blender/io/collada/BCAnimationCurve.h +++ b/source/blender/io/collada/BCAnimationCurve.h @@ -4,35 +4,33 @@ #pragma once +#include +#include +#include + #include "BCSampleData.h" -#include "collada_utils.h" -#include "MEM_guardedalloc.h" - -#include "BKE_armature.hh" #include "BKE_fcurve.hh" -#include "BKE_material.hh" + +#include "RNA_types.hh" #include "ED_anim_api.hh" -#include "ED_keyframes_edit.hh" -#include "ANIM_fcurve.hh" +using TangentPoint = float[2]; -typedef float(TangentPoint)[2]; +using BCFrameSet = std::set; +using BCFrames = std::vector; +using BCValues = std::vector; +using BCTimes = std::vector; +using BCValueMap = std::map; -typedef std::set BCFrameSet; -typedef std::vector BCFrames; -typedef std::vector BCValues; -typedef std::vector BCTimes; -typedef std::map BCValueMap; - -typedef enum BC_animation_type { +enum BC_animation_type { BC_ANIMATION_TYPE_OBJECT, BC_ANIMATION_TYPE_BONE, BC_ANIMATION_TYPE_CAMERA, BC_ANIMATION_TYPE_MATERIAL, BC_ANIMATION_TYPE_LIGHT, -} BC_animation_type; +}; class BCCurveKey { private: @@ -131,4 +129,4 @@ class BCAnimationCurve { int closest_index_below(float sample_frame) const; }; -typedef std::map BCAnimationCurveMap; +using BCAnimationCurveMap = std::map; diff --git a/source/blender/io/collada/BCAnimationSampler.cpp b/source/blender/io/collada/BCAnimationSampler.cpp index 8394f6a5905..916b1785ee5 100644 --- a/source/blender/io/collada/BCAnimationSampler.cpp +++ b/source/blender/io/collada/BCAnimationSampler.cpp @@ -2,7 +2,6 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include /* std::find */ #include #include @@ -14,16 +13,13 @@ #include "BKE_action.hh" #include "BKE_constraint.h" -#include "BKE_key.hh" -#include "BKE_lib_id.hh" -#include "BKE_main.hh" #include "BKE_material.hh" #include "BLI_listbase.h" +#include "BLI_string.h" #include "DNA_anim_types.h" #include "DNA_constraint_types.h" -#include "DNA_key_types.h" #include "DNA_scene_types.h" #include "ED_object.hh" diff --git a/source/blender/io/collada/BCAnimationSampler.h b/source/blender/io/collada/BCAnimationSampler.h index a18b4360c34..d50725074a9 100644 --- a/source/blender/io/collada/BCAnimationSampler.h +++ b/source/blender/io/collada/BCAnimationSampler.h @@ -11,14 +11,10 @@ #include "BKE_action.hh" #include "BKE_lib_id.hh" -#include "BLI_math_rotation.h" - -#include "DNA_action_types.h" - /* Collection of animation curves */ class BCAnimation { private: - Object *reference = NULL; + Object *reference = nullptr; bContext *mContext; public: @@ -52,7 +48,7 @@ class BCAnimation { } }; -typedef std::map BCAnimationObjectMap; +using BCAnimationObjectMap = std::map; class BCSampleFrame { @@ -90,7 +86,7 @@ class BCSampleFrame { bool has_sample_for(Object *ob, Bone *bone) const; }; -typedef std::map BCSampleFrameMap; +using BCSampleFrameMap = std::map; class BCSampleFrameContainer { @@ -122,7 +118,7 @@ class BCSampleFrameContainer { BCSampleFrameMap sample_frames; public: - ~BCSampleFrameContainer() {} + ~BCSampleFrameContainer() = default; BCSample &add(Object *ob, int frame_index); /** Return either the #BCSampleFrame or NULL if frame does not exist. */ diff --git a/source/blender/io/collada/BCMath.cpp b/source/blender/io/collada/BCMath.cpp index 201edb11a79..41bef6a93ac 100644 --- a/source/blender/io/collada/BCMath.cpp +++ b/source/blender/io/collada/BCMath.cpp @@ -2,8 +2,6 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BLI_utildefines.h" - #include "BCMath.h" #include "BlenderContext.h" diff --git a/source/blender/io/collada/BCSampleData.h b/source/blender/io/collada/BCSampleData.h index cc25307aa93..770d1ee7069 100644 --- a/source/blender/io/collada/BCSampleData.h +++ b/source/blender/io/collada/BCSampleData.h @@ -4,25 +4,15 @@ #pragma once -#include #include #include #include "BCMath.h" -#include "BCSampleData.h" -#include "ExportSettings.h" - -#include "BKE_object.hh" - -#include "BLI_math_rotation.h" #include "DNA_armature_types.h" -#include "DNA_camera_types.h" -#include "DNA_light_types.h" -#include "DNA_material_types.h" #include "DNA_object_types.h" -typedef std::map BCBoneMatrixMap; +using BCBoneMatrixMap = std::map; class BCSample { private: @@ -42,6 +32,6 @@ class BCSample { const BCMatrix *get_matrix(Bone *bone) const; /* returns NULL if bone is not animated */ }; -typedef std::map BCSampleMap; -typedef std::map BCFrameSampleMap; -typedef std::map BCMatrixSampleMap; +using BCSampleMap = std::map; +using BCFrameSampleMap = std::map; +using BCMatrixSampleMap = std::map; diff --git a/source/blender/io/collada/BlenderTypes.h b/source/blender/io/collada/BlenderTypes.h index c7eaab1098d..0b82f20298c 100644 --- a/source/blender/io/collada/BlenderTypes.h +++ b/source/blender/io/collada/BlenderTypes.h @@ -8,26 +8,26 @@ #pragma once -typedef float(Vector)[3]; -typedef float(Quat)[4]; -typedef float(Color)[4]; -typedef float(Matrix)[4][4]; -typedef double(DMatrix)[4][4]; +using Vector = float[3]; +using Quat = float[4]; +using Color = float[4]; +using Matrix = float[4][4]; +using DMatrix = double[4][4]; -typedef enum BC_global_forward_axis { +enum BC_global_forward_axis { BC_GLOBAL_FORWARD_X = 0, BC_GLOBAL_FORWARD_Y = 1, BC_GLOBAL_FORWARD_Z = 2, BC_GLOBAL_FORWARD_MINUS_X = 3, BC_GLOBAL_FORWARD_MINUS_Y = 4, BC_GLOBAL_FORWARD_MINUS_Z = 5 -} BC_global_forward_axis; +}; -typedef enum BC_global_up_axis { +enum BC_global_up_axis { BC_GLOBAL_UP_X = 0, BC_GLOBAL_UP_Y = 1, BC_GLOBAL_UP_Z = 2, BC_GLOBAL_UP_MINUS_X = 3, BC_GLOBAL_UP_MINUS_Y = 4, BC_GLOBAL_UP_MINUS_Z = 5 -} BC_global_up_axis; +}; diff --git a/source/blender/io/collada/ControllerExporter.cpp b/source/blender/io/collada/ControllerExporter.cpp index 196aefc71a8..ea13207df41 100644 --- a/source/blender/io/collada/ControllerExporter.cpp +++ b/source/blender/io/collada/ControllerExporter.cpp @@ -13,13 +13,11 @@ #include "DNA_action_types.h" #include "DNA_meshdata_types.h" -#include "DNA_modifier_types.h" #include "BKE_action.hh" #include "BKE_armature.hh" #include "BKE_deform.hh" -#include "BKE_global.hh" -#include "BKE_idprop.hh" +#include "BKE_key.hh" #include "BKE_lib_id.hh" #include "BKE_mesh.hh" @@ -28,10 +26,8 @@ #include "BLI_listbase.h" #include "BLI_math_matrix.h" -#include "ArmatureExporter.h" #include "ControllerExporter.h" #include "GeometryExporter.h" -#include "SceneExporter.h" #include "collada_utils.h" @@ -320,7 +316,7 @@ std::string ControllerExporter::add_morph_targets(Key *key, Object *ob) source.setAccessorStride(1); COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - param.push_back("IDREF"); + param.emplace_back("IDREF"); source.prepareToAppendValues(); @@ -348,7 +344,7 @@ std::string ControllerExporter::add_morph_weights(Key *key, Object *ob) source.setAccessorStride(1); COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - param.push_back("MORPH_WEIGHT"); + param.emplace_back("MORPH_WEIGHT"); source.prepareToAppendValues(); @@ -437,7 +433,7 @@ std::string ControllerExporter::add_joints_source(Object *ob_arm, source.setAccessorStride(1); COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - param.push_back("JOINT"); + param.emplace_back("JOINT"); source.prepareToAppendValues(); @@ -474,7 +470,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, source.setParameterTypeName(&COLLADASW::CSWC::CSW_VALUE_TYPE_FLOAT4x4); COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - param.push_back("TRANSFORM"); + param.emplace_back("TRANSFORM"); source.prepareToAppendValues(); @@ -578,7 +574,7 @@ std::string ControllerExporter::add_weights_source(Mesh *mesh, source.setAccessorStride(1); COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - param.push_back("WEIGHT"); + param.emplace_back("WEIGHT"); source.prepareToAppendValues(); diff --git a/source/blender/io/collada/ControllerExporter.h b/source/blender/io/collada/ControllerExporter.h index 5c579c4bf3f..34252cb726d 100644 --- a/source/blender/io/collada/ControllerExporter.h +++ b/source/blender/io/collada/ControllerExporter.h @@ -12,28 +12,21 @@ #include // #include -#include "COLLADASWExtraTechnique.h" -#include "COLLADASWInputList.h" #include "COLLADASWInstanceController.h" #include "COLLADASWLibraryControllers.h" -#include "COLLADASWNode.h" #include "COLLADASWStreamWriter.h" #include "DNA_armature_types.h" -#include "DNA_constraint_types.h" #include "DNA_key_types.h" #include "DNA_listBase.h" #include "DNA_mesh_types.h" #include "DNA_object_types.h" -#include "DNA_scene_types.h" #include "InstanceWriter.h" #include "TransformWriter.h" #include "ExportSettings.h" -#include "BKE_key.hh" - class SceneExporter; class ControllerExporter : public COLLADASW::LibraryControllers, diff --git a/source/blender/io/collada/DocumentExporter.cpp b/source/blender/io/collada/DocumentExporter.cpp index bb6ee8c389c..e0c6a39f7df 100644 --- a/source/blender/io/collada/DocumentExporter.cpp +++ b/source/blender/io/collada/DocumentExporter.cpp @@ -6,79 +6,26 @@ * \ingroup collada */ -#include /* std::find */ -#include #include #include -#include #include "COLLADASWAsset.h" -#include "COLLADASWBaseInputElement.h" -#include "COLLADASWBindMaterial.h" #include "COLLADASWCamera.h" -#include "COLLADASWColorOrTexture.h" -#include "COLLADASWConstants.h" -#include "COLLADASWEffectProfile.h" #include "COLLADASWException.h" -#include "COLLADASWImage.h" -#include "COLLADASWInputList.h" -#include "COLLADASWInstanceCamera.h" -#include "COLLADASWInstanceController.h" -#include "COLLADASWInstanceGeometry.h" -#include "COLLADASWInstanceLight.h" -#include "COLLADASWInstanceNode.h" -#include "COLLADASWLibraryAnimations.h" -#include "COLLADASWLibraryControllers.h" -#include "COLLADASWLibraryEffects.h" -#include "COLLADASWLibraryImages.h" -#include "COLLADASWLibraryMaterials.h" -#include "COLLADASWLibraryVisualScenes.h" -#include "COLLADASWNode.h" -#include "COLLADASWParamBase.h" -#include "COLLADASWParamTemplate.h" -#include "COLLADASWPrimitves.h" -#include "COLLADASWSampler.h" #include "COLLADASWScene.h" -#include "COLLADASWSource.h" -#include "COLLADASWSurfaceInitOption.h" -#include "COLLADASWTechnique.h" -#include "COLLADASWTexture.h" -#include "COLLADASWVertices.h" -#include "MEM_guardedalloc.h" - -#include "DNA_action_types.h" -#include "DNA_anim_types.h" -#include "DNA_armature_types.h" -#include "DNA_collection_types.h" -#include "DNA_curve_types.h" -#include "DNA_image_types.h" -#include "DNA_material_types.h" -#include "DNA_mesh_types.h" -#include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "DNA_userdef_types.h" #include "BLI_fileops.h" -#include "BLI_listbase.h" #include "BLI_path_utils.hh" #include "BLI_string.h" -#include "BLI_utildefines.h" -#include "BKE_action.hh" /* pose functions */ #include "BKE_animsys.h" #include "BKE_appdir.hh" -#include "BKE_armature.hh" #include "BKE_blender_version.h" #include "BKE_customdata.hh" #include "BKE_fcurve.hh" -#include "BKE_global.hh" -#include "BKE_image.hh" -#include "BKE_main.hh" -#include "BKE_material.hh" -#include "BKE_object.hh" -#include "BKE_scene.hh" #include "ED_keyframing.hh" #ifdef WITH_BUILDINFO @@ -94,8 +41,6 @@ extern "C" char build_hash[]; #include "collada_utils.h" /* can probably go after refactor is complete */ -#include "InstanceWriter.h" -#include "TransformWriter.h" #include "AnimationExporter.h" #include "ArmatureExporter.h" diff --git a/source/blender/io/collada/DocumentExporter.h b/source/blender/io/collada/DocumentExporter.h index 263ae2a1011..440be4135f0 100644 --- a/source/blender/io/collada/DocumentExporter.h +++ b/source/blender/io/collada/DocumentExporter.h @@ -9,11 +9,8 @@ #pragma once #include "BlenderContext.h" -#include "collada.h" #include "collada_utils.h" -#include "DNA_customdata_types.h" - class DocumentExporter { public: DocumentExporter(BlenderContext &blender_context, ExportSettings *export_settings); diff --git a/source/blender/io/collada/DocumentImporter.cpp b/source/blender/io/collada/DocumentImporter.cpp index 0928e92eb41..ef41ab7da97 100644 --- a/source/blender/io/collada/DocumentImporter.cpp +++ b/source/blender/io/collada/DocumentImporter.cpp @@ -10,37 +10,24 @@ * * name imported objects * * import object rotation as euler */ -#include /* sort() */ #include #include #include "COLLADAFWArrayPrimitiveType.h" #include "COLLADAFWCamera.h" -#include "COLLADAFWColorOrTexture.h" -#include "COLLADAFWIndexList.h" #include "COLLADAFWLibraryNodes.h" #include "COLLADAFWLight.h" -#include "COLLADAFWMeshPrimitiveWithFaceVertexCount.h" -#include "COLLADAFWPolygons.h" #include "COLLADAFWRoot.h" -#include "COLLADAFWSampler.h" -#include "COLLADAFWStableHeaders.h" -#include "COLLADAFWTypes.h" #include "COLLADAFWVisualScene.h" -#include "COLLADASaxFWLIExtraDataCallbackHandler.h" #include "COLLADASaxFWLLoader.h" -#include "MEM_guardedalloc.h" - #include "BLI_fileops.h" -#include "BLI_listbase.h" #include "BLI_math_matrix.h" -#include "BLI_string.h" -#include "BLI_utildefines.h" #include "BKE_camera.h" #include "BKE_collection.hh" +#include "BKE_constraint.h" #include "BKE_fcurve.hh" #include "BKE_global.hh" #include "BKE_image.hh" @@ -66,7 +53,6 @@ #include "DocumentImporter.h" #include "ErrorHandler.h" #include "ExtraHandler.h" -#include "TransformReader.h" #include "Materials.h" #include "collada_internal.h" diff --git a/source/blender/io/collada/DocumentImporter.h b/source/blender/io/collada/DocumentImporter.h index 144eb919db1..f587369baf6 100644 --- a/source/blender/io/collada/DocumentImporter.h +++ b/source/blender/io/collada/DocumentImporter.h @@ -8,26 +8,17 @@ #pragma once -#include "COLLADAFWColor.h" #include "COLLADAFWController.h" #include "COLLADAFWEffect.h" #include "COLLADAFWEffectCommon.h" #include "COLLADAFWIWriter.h" #include "COLLADAFWImage.h" -#include "COLLADAFWInstanceGeometry.h" #include "COLLADAFWMaterial.h" -#include "COLLADAFWMorphController.h" -#include "COLLADAFWSkinController.h" - -#include "BKE_constraint.h" -#include "BKE_object.hh" #include "AnimationImporter.h" #include "ArmatureImporter.h" -#include "ControllerExporter.h" #include "ImportSettings.h" #include "MeshImporter.h" -#include "TransformReader.h" struct bContext; @@ -43,7 +34,7 @@ class DocumentImporter : COLLADAFW::IWriter { DocumentImporter(bContext *C, const ImportSettings *import_settings); /** Destructor */ - ~DocumentImporter(); + ~DocumentImporter() override; /** Function called by blender UI */ bool import(); @@ -67,22 +58,22 @@ class DocumentImporter : COLLADAFW::IWriter { * continue to load. The writer should undo all operations that have been performed. * \param errorMessage: A message containing information about the error that occurred. */ - void cancel(const COLLADAFW::String &errorMessage); + void cancel(const COLLADAFW::String &errorMessage) override; /** This is the method called. The writer hast to prepare to receive data. */ - void start(); + void start() override; /** * This method is called after the last write* method. * No other methods will be called after this. */ - void finish(); + void finish() override; /** * When this method is called, the writer must write the global document asset. * \return The writer should return true, if writing succeeded, false otherwise. */ - bool writeGlobalAsset(const COLLADAFW::FileInfo *); + bool writeGlobalAsset(const COLLADAFW::FileInfo * /*asset*/) override; /** * If the imported file was made with Blender, return the Blender version used, * otherwise return an empty std::string @@ -93,85 +84,86 @@ class DocumentImporter : COLLADAFW::IWriter { * When this method is called, the writer must write the scene. * \return The writer should return true, if writing succeeded, false otherwise. */ - bool writeScene(const COLLADAFW::Scene *); + bool writeScene(const COLLADAFW::Scene * /*scene*/) override; /** * When this method is called, the writer must write the entire visual scene. * Return The writer should return true, if writing succeeded, false otherwise. */ - bool writeVisualScene(const COLLADAFW::VisualScene *); + bool writeVisualScene(const COLLADAFW::VisualScene * /*visualScene*/) override; /** * When this method is called, the writer must handle all nodes contained in the * library nodes. * \return The writer should return true, if writing succeeded, false otherwise. */ - bool writeLibraryNodes(const COLLADAFW::LibraryNodes *); + bool writeLibraryNodes(const COLLADAFW::LibraryNodes * /*libraryNodes*/) override; /** * This function is called only for animations that pass COLLADAFW::validate. */ - bool writeAnimation(const COLLADAFW::Animation *); + bool writeAnimation(const COLLADAFW::Animation * /*animation*/) override; /** * Called on post-process stage after writeVisualScenes. */ - bool writeAnimationList(const COLLADAFW::AnimationList *); + bool writeAnimationList(const COLLADAFW::AnimationList * /*animationList*/) override; #if WITH_OPENCOLLADA_ANIMATION_CLIP /* Please enable this when building with Collada 1.6.65 or newer (also in DocumentImporter.cpp) */ - bool writeAnimationClip(const COLLADAFW::AnimationClip *animationClip); + bool writeAnimationClip(const COLLADAFW::AnimationClip *animationClip) override; #endif /** * When this method is called, the writer must write the geometry. * \return The writer should return true, if writing succeeded, false otherwise. */ - bool writeGeometry(const COLLADAFW::Geometry *); + bool writeGeometry(const COLLADAFW::Geometry * /*geometry*/) override; /** * When this method is called, the writer must write the material. * \return The writer should return true, if writing succeeded, false otherwise. */ - bool writeMaterial(const COLLADAFW::Material *); + bool writeMaterial(const COLLADAFW::Material * /*material*/) override; /** * When this method is called, the writer must write the effect. * \return The writer should return true, if writing succeeded, false otherwise. */ - bool writeEffect(const COLLADAFW::Effect *); + bool writeEffect(const COLLADAFW::Effect * /*effect*/) override; /** * When this method is called, the writer must write the camera. * \return The writer should return true, if writing succeeded, false otherwise. */ - bool writeCamera(const COLLADAFW::Camera *); + bool writeCamera(const COLLADAFW::Camera * /*camera*/) override; /** * When this method is called, the writer must write the image. * \return The writer should return true, if writing succeeded, false otherwise. */ - bool writeImage(const COLLADAFW::Image *); + bool writeImage(const COLLADAFW::Image * /*image*/) override; /** * When this method is called, the writer must write the light. * \return The writer should return true, if writing succeeded, false otherwise. */ - bool writeLight(const COLLADAFW::Light *); + bool writeLight(const COLLADAFW::Light * /*light*/) override; /** * When this method is called, the writer must write the skin controller data. * \return The writer should return true, if writing succeeded, false otherwise. */ - bool writeSkinControllerData(const COLLADAFW::SkinControllerData *); + bool writeSkinControllerData( + const COLLADAFW::SkinControllerData * /*skinControllerData*/) override; /** This is called on post-process, before writeVisualScenes. */ - bool writeController(const COLLADAFW::Controller *); + bool writeController(const COLLADAFW::Controller * /*controller*/) override; - bool writeFormulas(const COLLADAFW::Formulas *); + bool writeFormulas(const COLLADAFW::Formulas * /*formulas*/) override; - bool writeKinematicsScene(const COLLADAFW::KinematicsScene *); + bool writeKinematicsScene(const COLLADAFW::KinematicsScene * /*kinematicsScene*/) override; /** Add element and data for UniqueId */ bool addExtraTags(const COLLADAFW::UniqueId &uid, ExtraTags *extra_tags); @@ -195,7 +187,7 @@ class DocumentImporter : COLLADAFW::IWriter { AnimationImporter anim_importer; /** TagsMap typedef for uid_tags_map. */ - typedef std::map TagsMap; + using TagsMap = std::map; /** Tags map of unique id as a string and ExtraTags instance. */ TagsMap uid_tags_map; diff --git a/source/blender/io/collada/EffectExporter.cpp b/source/blender/io/collada/EffectExporter.cpp index 5cbd35dc026..e88be52c4d5 100644 --- a/source/blender/io/collada/EffectExporter.cpp +++ b/source/blender/io/collada/EffectExporter.cpp @@ -7,25 +7,21 @@ */ #include -#include -#include "COLLADAFWColorOrTexture.h" #include "COLLADASWEffectProfile.h" -#include "DocumentExporter.h" #include "EffectExporter.h" #include "MaterialExporter.h" +#include "Materials.h" #include "collada_internal.h" #include "collada_utils.h" #include "DNA_mesh_types.h" -#include "DNA_world_types.h" #include "BKE_collection.hh" #include "BKE_customdata.hh" #include "BKE_material.hh" -#include "BKE_mesh.hh" static std::string getActiveUVLayerName(Object *ob) { diff --git a/source/blender/io/collada/EffectExporter.h b/source/blender/io/collada/EffectExporter.h index 988bd6734e0..0bb759fe798 100644 --- a/source/blender/io/collada/EffectExporter.h +++ b/source/blender/io/collada/EffectExporter.h @@ -9,7 +9,6 @@ #pragma once #include -#include #include "COLLADASWColorOrTexture.h" #include "COLLADASWLibraryEffects.h" diff --git a/source/blender/io/collada/ErrorHandler.h b/source/blender/io/collada/ErrorHandler.h index a8d1af4a8a7..46fb45cd7d4 100644 --- a/source/blender/io/collada/ErrorHandler.h +++ b/source/blender/io/collada/ErrorHandler.h @@ -8,11 +8,6 @@ #pragma once -#include /* sort() */ -#include -#include -#include - #include "COLLADASaxFWLIErrorHandler.h" /** \brief Handler class for parser errors @@ -23,7 +18,7 @@ class ErrorHandler : public COLLADASaxFWL::IErrorHandler { ErrorHandler(); /** handle any error thrown by the parser. */ - bool virtual handleError(const COLLADASaxFWL::IError *error); + bool handleError(const COLLADASaxFWL::IError *error) override; /** True if there was an error during parsing. */ bool hasError() { diff --git a/source/blender/io/collada/ExportSettings.h b/source/blender/io/collada/ExportSettings.h index 1135d11964a..6c66944b687 100644 --- a/source/blender/io/collada/ExportSettings.h +++ b/source/blender/io/collada/ExportSettings.h @@ -18,30 +18,30 @@ extern "C" { #endif -typedef enum BC_export_mesh_type { +enum BC_export_mesh_type { BC_MESH_TYPE_VIEW, BC_MESH_TYPE_RENDER, -} BC_export_mesh_type; +}; -typedef enum BC_export_transformation_type { +enum BC_export_transformation_type { BC_TRANSFORMATION_TYPE_MATRIX, BC_TRANSFORMATION_TYPE_DECOMPOSED, -} BC_export_transformation_type; +}; -typedef enum BC_export_animation_type { +enum BC_export_animation_type { BC_ANIMATION_EXPORT_SAMPLES, BC_ANIMATION_EXPORT_KEYS, -} BC_export_animation_type; +}; -typedef enum BC_ui_export_section { +enum BC_ui_export_section { BC_UI_SECTION_MAIN, BC_UI_SECTION_GEOMETRY, BC_UI_SECTION_ARMATURE, BC_UI_SECTION_ANIMATION, BC_UI_SECTION_COLLADA, -} BC_ui_export_section; +}; -typedef struct ExportSettings { +struct ExportSettings { bool apply_modifiers; BC_global_forward_axis global_forward; BC_global_up_axis global_up; @@ -78,7 +78,7 @@ typedef struct ExportSettings { char *filepath; LinkNode *export_set; -} ExportSettings; +}; #ifdef __cplusplus } diff --git a/source/blender/io/collada/ExtraHandler.cpp b/source/blender/io/collada/ExtraHandler.cpp index 8f755614bb7..48e7373ee45 100644 --- a/source/blender/io/collada/ExtraHandler.cpp +++ b/source/blender/io/collada/ExtraHandler.cpp @@ -6,8 +6,10 @@ * \ingroup collada */ -#include "BLI_string.h" #include +#include + +#include "BLI_string.h" #include "ExtraHandler.h" diff --git a/source/blender/io/collada/ExtraHandler.h b/source/blender/io/collada/ExtraHandler.h index 4bf158f724c..6cd91364098 100644 --- a/source/blender/io/collada/ExtraHandler.h +++ b/source/blender/io/collada/ExtraHandler.h @@ -8,13 +8,9 @@ #pragma once -#include /* sort() */ -#include #include #include -#include "COLLADASWInstanceController.h" -#include "COLLADASaxFWLFilePartLoader.h" #include "COLLADASaxFWLIExtraDataCallbackHandler.h" #include "AnimationImporter.h" @@ -29,20 +25,20 @@ class ExtraHandler : public COLLADASaxFWL::IExtraDataCallbackHandler { ExtraHandler(DocumentImporter *dimp, AnimationImporter *aimp); /** Handle the beginning of an element. */ - bool elementBegin(const char *elementName, const char **attributes); + bool elementBegin(const char *elementName, const char **attributes) override; /** Handle the end of an element. */ - bool elementEnd(const char *elementName); + bool elementEnd(const char *elementName) override; /** Receive the data in text format. */ - bool textData(const char *text, size_t textLength); + bool textData(const char *text, size_t textLength) override; /** Method to ask, if the current callback handler want to read the data of the given extra * element. */ bool parseElement(const char *profileName, const unsigned long &elementHash, const COLLADAFW::UniqueId &uniqueId, - COLLADAFW::Object *object); + COLLADAFW::Object *object) override; /** For backwards compatibility with older OpenCollada, new version added object parameter */ bool parseElement(const char *profileName, diff --git a/source/blender/io/collada/ExtraTags.cpp b/source/blender/io/collada/ExtraTags.cpp index 099fc640b10..aad60035834 100644 --- a/source/blender/io/collada/ExtraTags.cpp +++ b/source/blender/io/collada/ExtraTags.cpp @@ -6,11 +6,9 @@ * \ingroup collada */ -#include "BLI_string.h" #include #include -#include #include #include "ExtraTags.h" diff --git a/source/blender/io/collada/GeometryExporter.cpp b/source/blender/io/collada/GeometryExporter.cpp index f05a83da68d..6801b98e0d9 100644 --- a/source/blender/io/collada/GeometryExporter.cpp +++ b/source/blender/io/collada/GeometryExporter.cpp @@ -15,14 +15,15 @@ #include "GeometryExporter.h" +#include "DNA_key_types.h" #include "DNA_meshdata_types.h" #include "BLI_math_vector_types.hh" -#include "BLI_utildefines.h" +#include "BLI_string.h" #include "BKE_attribute.hh" #include "BKE_customdata.hh" -#include "BKE_global.hh" +#include "BKE_key.hh" #include "BKE_lib_id.hh" #include "BKE_material.hh" #include "BKE_mesh.hh" @@ -68,7 +69,7 @@ void GeometryExporter::operator()(Object *ob) exportedGeometry.insert(geom_id); - bool has_color = bool(CustomData_has_layer(&mesh->fdata_legacy, CD_MCOL)); + bool has_color = CustomData_has_layer(&mesh->fdata_legacy, CD_MCOL); create_normals(nor, norind, mesh); @@ -81,7 +82,7 @@ void GeometryExporter::operator()(Object *ob) /* writes for normal coords */ createNormalsSource(geom_id, mesh, nor); - bool has_uvs = bool(CustomData_has_layer(&mesh->corner_data, CD_PROP_FLOAT2)); + bool has_uvs = CustomData_has_layer(&mesh->corner_data, CD_PROP_FLOAT2); /* writes for uv coords if mesh has uv coords */ if (has_uvs) { @@ -152,7 +153,7 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *mesh, KeyBlock *kb) exportedGeometry.insert(geom_id); - bool has_color = bool(CustomData_has_layer(&mesh->fdata_legacy, CD_MCOL)); + bool has_color = CustomData_has_layer(&mesh->fdata_legacy, CD_MCOL); create_normals(nor, norind, mesh); @@ -165,7 +166,7 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *mesh, KeyBlock *kb) /* writes for normal coords */ createNormalsSource(geom_id, mesh, nor); - bool has_uvs = bool(CustomData_has_layer(&mesh->corner_data, CD_PROP_FLOAT2)); + bool has_uvs = CustomData_has_layer(&mesh->corner_data, CD_PROP_FLOAT2); /* writes for uv coords if mesh has uv coords */ if (has_uvs) { @@ -452,9 +453,9 @@ void GeometryExporter::createVertsSource(std::string geom_id, Mesh *mesh) source.setAccessorStride(3); COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - param.push_back("X"); - param.push_back("Y"); - param.push_back("Z"); + param.emplace_back("X"); + param.emplace_back("Y"); + param.emplace_back("Z"); /* main function, it creates , */ source.prepareToAppendValues(); @@ -504,10 +505,10 @@ void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *mesh) source.setAccessorStride(4); COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - param.push_back("R"); - param.push_back("G"); - param.push_back("B"); - param.push_back("A"); + param.emplace_back("R"); + param.emplace_back("G"); + param.emplace_back("B"); + param.emplace_back("A"); source.prepareToAppendValues(); @@ -562,8 +563,8 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *mesh) source.setAccessorCount(totuv); source.setAccessorStride(2); COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - param.push_back("S"); - param.push_back("T"); + param.emplace_back("S"); + param.emplace_back("T"); source.prepareToAppendValues(); @@ -594,9 +595,9 @@ void GeometryExporter::createNormalsSource(std::string geom_id, source.setAccessorCount(ulong(nor.size())); source.setAccessorStride(3); COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - param.push_back("X"); - param.push_back("Y"); - param.push_back("Z"); + param.emplace_back("X"); + param.emplace_back("Y"); + param.emplace_back("Z"); source.prepareToAppendValues(); diff --git a/source/blender/io/collada/GeometryExporter.h b/source/blender/io/collada/GeometryExporter.h index 78893d96444..58c21a33d4c 100644 --- a/source/blender/io/collada/GeometryExporter.h +++ b/source/blender/io/collada/GeometryExporter.h @@ -21,7 +21,6 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "BKE_key.hh" #include "BlenderContext.h" #include "ExportSettings.h" #include "collada_utils.h" diff --git a/source/blender/io/collada/ImageExporter.cpp b/source/blender/io/collada/ImageExporter.cpp index 276607686a4..30e0bcc313e 100644 --- a/source/blender/io/collada/ImageExporter.cpp +++ b/source/blender/io/collada/ImageExporter.cpp @@ -10,14 +10,10 @@ #include "COLLADASWImage.h" #include "DNA_image_types.h" -#include "DNA_texture_types.h" -#include "BKE_customdata.hh" -#include "BKE_global.hh" #include "BKE_image.hh" #include "BKE_image_format.hh" #include "BKE_main.hh" -#include "BKE_mesh.hh" #include "BLI_fileops.h" #include "BLI_path_utils.hh" @@ -26,7 +22,6 @@ #include "IMB_imbuf_types.hh" #include "ImageExporter.h" -#include "MaterialExporter.h" ImagesExporter::ImagesExporter(COLLADASW::StreamWriter *sw, BCExportSettings &export_settings, @@ -144,9 +139,6 @@ void ImagesExporter::exportImages(Scene *sce) for (iter = key_image_map.begin(); iter != key_image_map.end(); iter++) { Image *image = iter->second; - std::string uid(id_name(image)); - std::string key = translate_id(uid); - export_UV_Image(image, use_texture_copies); } diff --git a/source/blender/io/collada/ImageExporter.h b/source/blender/io/collada/ImageExporter.h index 44166f75904..fc369fe063b 100644 --- a/source/blender/io/collada/ImageExporter.h +++ b/source/blender/io/collada/ImageExporter.h @@ -8,15 +8,10 @@ #pragma once -#include -#include - #include "COLLADASWLibraryImages.h" #include "COLLADASWStreamWriter.h" #include "DNA_image_types.h" -#include "DNA_material_types.h" -#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "ExportSettings.h" diff --git a/source/blender/io/collada/ImportSettings.h b/source/blender/io/collada/ImportSettings.h index 35b79592de9..21f0eedec89 100644 --- a/source/blender/io/collada/ImportSettings.h +++ b/source/blender/io/collada/ImportSettings.h @@ -8,7 +8,7 @@ #pragma once -typedef struct ImportSettings { +struct ImportSettings { bool import_units; bool custom_normals; bool find_chains; @@ -17,4 +17,4 @@ typedef struct ImportSettings { int min_chain_length; char *filepath; bool keep_bind_info; -} ImportSettings; +}; diff --git a/source/blender/io/collada/MaterialExporter.h b/source/blender/io/collada/MaterialExporter.h index ee107345695..922dfe607ec 100644 --- a/source/blender/io/collada/MaterialExporter.h +++ b/source/blender/io/collada/MaterialExporter.h @@ -22,7 +22,6 @@ #include "ExportSettings.h" #include "GeometryExporter.h" -#include "Materials.h" #include "collada_internal.h" class MaterialsExporter : COLLADASW::LibraryMaterials { diff --git a/source/blender/io/collada/Materials.cpp b/source/blender/io/collada/Materials.cpp index f6959b9dfb9..227414782d9 100644 --- a/source/blender/io/collada/Materials.cpp +++ b/source/blender/io/collada/Materials.cpp @@ -4,9 +4,10 @@ #include "Materials.h" +#include "BLI_string.h" + #include "BKE_node.hh" #include "BKE_node_legacy_types.hh" - #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.hh" diff --git a/source/blender/io/collada/Materials.h b/source/blender/io/collada/Materials.h index 5667fdcbd03..e9ae62e5273 100644 --- a/source/blender/io/collada/Materials.h +++ b/source/blender/io/collada/Materials.h @@ -9,14 +9,13 @@ #include "BKE_context.hh" #include "BKE_node.hh" -#include "BLI_listbase.h" #include "DNA_material_types.h" #include "DNA_node_types.h" #include "COLLADAFWEffectCommon.h" #include "collada_utils.h" -typedef std::map NodeMap; +using NodeMap = std::map; class MaterialNode { diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp index f4d5e388b72..b6e62a6e0dd 100644 --- a/source/blender/io/collada/MeshImporter.cpp +++ b/source/blender/io/collada/MeshImporter.cpp @@ -6,21 +6,14 @@ * \ingroup collada */ -#include #include -/* COLLADABU_ASSERT, may be able to remove later */ -#include "COLLADABUPlatform.h" - #include "COLLADAFWMeshPrimitive.h" #include "COLLADAFWMeshVertexData.h" #include "COLLADAFWPolygons.h" -#include "MEM_guardedalloc.h" - #include "BKE_attribute.hh" #include "BKE_customdata.hh" -#include "BKE_displist.h" #include "BKE_global.hh" #include "BKE_lib_id.hh" #include "BKE_material.hh" @@ -30,9 +23,6 @@ #include "DNA_meshdata_types.h" -#include "BLI_listbase.h" -#include "BLI_string.h" - #include "ArmatureImporter.h" #include "MeshImporter.h" #include "collada_utils.h" diff --git a/source/blender/io/collada/MeshImporter.h b/source/blender/io/collada/MeshImporter.h index 0b2248bdadb..dbf45b01fba 100644 --- a/source/blender/io/collada/MeshImporter.h +++ b/source/blender/io/collada/MeshImporter.h @@ -86,7 +86,7 @@ class MeshImporter : public MeshImporterBase { int *material_indices; uint faces_num; }; - typedef std::map> MaterialIdPrimitiveArrayMap; + using MaterialIdPrimitiveArrayMap = std::map>; /* crazy name! */ std::map geom_uid_mat_mapping_map; /* < materials that have already been mapped to a geometry. @@ -190,9 +190,9 @@ class MeshImporter : public MeshImporterBase { Scene *sce, ViewLayer *view_layer); - virtual Object *get_object_by_geom_uid(const COLLADAFW::UniqueId &geom_uid); + Object *get_object_by_geom_uid(const COLLADAFW::UniqueId &geom_uid) override; - virtual Mesh *get_mesh_by_geom_uid(const COLLADAFW::UniqueId &geom_uid); + Mesh *get_mesh_by_geom_uid(const COLLADAFW::UniqueId &geom_uid) override; /** * @@ -234,5 +234,5 @@ class MeshImporter : public MeshImporterBase { /** Create a mesh storing a pointer in a map so it can be retrieved later by geometry UID. */ bool write_geometry(const COLLADAFW::Geometry *geom); - std::string *get_geometry_name(const std::string &mesh_name); + std::string *get_geometry_name(const std::string &mesh_name) override; }; diff --git a/source/blender/io/collada/SceneExporter.cpp b/source/blender/io/collada/SceneExporter.cpp index 1ba6de676b3..dba95f0cf10 100644 --- a/source/blender/io/collada/SceneExporter.cpp +++ b/source/blender/io/collada/SceneExporter.cpp @@ -6,13 +6,15 @@ * \ingroup collada */ -#include "BKE_collection.hh" -#include "BKE_lib_id.hh" -#include "BKE_object.hh" -#include "BLI_listbase.h" -#include "BLI_utildefines.h" +#include "COLLADASWInstanceCamera.h" +#include "COLLADASWInstanceGeometry.h" +#include "COLLADASWInstanceLight.h" + +#include "BLI_listbase.h" + +#include "BKE_collection.hh" +#include "BKE_constraint.h" -#include "BCSampleData.h" #include "SceneExporter.h" #include "collada_utils.h" diff --git a/source/blender/io/collada/SceneExporter.h b/source/blender/io/collada/SceneExporter.h index e4e6844f87d..eb11f93a834 100644 --- a/source/blender/io/collada/SceneExporter.h +++ b/source/blender/io/collada/SceneExporter.h @@ -8,61 +8,11 @@ #pragma once -#include -#include -#include +#include -#include "DNA_action_types.h" -#include "DNA_anim_types.h" -#include "DNA_armature_types.h" -#include "DNA_collection_types.h" -#include "DNA_constraint_types.h" -#include "DNA_curve_types.h" -#include "DNA_image_types.h" -#include "DNA_material_types.h" -#include "DNA_mesh_types.h" -#include "DNA_modifier_types.h" #include "DNA_object_types.h" -#include "DNA_scene_types.h" -#include "DNA_texture_types.h" -#include "DNA_userdef_types.h" -#include "BKE_constraint.h" -#include "BKE_fcurve.hh" -#include "BLI_fileops.h" -#include "BLI_path_utils.hh" -#include "ED_keyframing.hh" - -#include "COLLADASWAsset.h" -#include "COLLADASWBaseInputElement.h" -#include "COLLADASWBindMaterial.h" -#include "COLLADASWColorOrTexture.h" -#include "COLLADASWConstants.h" -#include "COLLADASWEffectProfile.h" -#include "COLLADASWImage.h" -#include "COLLADASWInputList.h" -#include "COLLADASWInstanceCamera.h" -#include "COLLADASWInstanceController.h" -#include "COLLADASWInstanceGeometry.h" -#include "COLLADASWInstanceLight.h" -#include "COLLADASWInstanceNode.h" -#include "COLLADASWLibraryAnimations.h" -#include "COLLADASWLibraryControllers.h" -#include "COLLADASWLibraryEffects.h" -#include "COLLADASWLibraryImages.h" -#include "COLLADASWLibraryMaterials.h" #include "COLLADASWLibraryVisualScenes.h" -#include "COLLADASWNode.h" -#include "COLLADASWParamBase.h" -#include "COLLADASWParamTemplate.h" -#include "COLLADASWPrimitves.h" -#include "COLLADASWSampler.h" -#include "COLLADASWScene.h" -#include "COLLADASWSource.h" -#include "COLLADASWSurfaceInitOption.h" -#include "COLLADASWTechnique.h" -#include "COLLADASWTexture.h" -#include "COLLADASWVertices.h" #include "ArmatureExporter.h" #include "ExportSettings.h" diff --git a/source/blender/io/collada/SkinInfo.cpp b/source/blender/io/collada/SkinInfo.cpp index 39fb5a7dcbc..d9e6bd9b530 100644 --- a/source/blender/io/collada/SkinInfo.cpp +++ b/source/blender/io/collada/SkinInfo.cpp @@ -8,14 +8,6 @@ #include -#if !defined(WIN32) -# include -#endif - -/* COLLADABU_ASSERT, may be able to remove later */ -#include "COLLADABUPlatform.h" - -#include "BLI_compiler_attrs.h" #include "BLI_listbase.h" #include "BLI_math_matrix.h" diff --git a/source/blender/io/collada/TransformReader.cpp b/source/blender/io/collada/TransformReader.cpp index d18a01e997c..d2a4c835cdf 100644 --- a/source/blender/io/collada/TransformReader.cpp +++ b/source/blender/io/collada/TransformReader.cpp @@ -6,14 +6,15 @@ * \ingroup collada */ -/* COLLADABU_ASSERT, may be able to remove later */ -#include "COLLADABUPlatform.h" +#include "COLLADAFWMatrix.h" +#include "COLLADAFWRotate.h" +#include "COLLADAFWScale.h" +#include "COLLADAFWTranslate.h" #include "TransformReader.h" #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" -#include "BLI_math_vector.h" TransformReader::TransformReader(UnitConverter *conv) : unit_converter(conv) { diff --git a/source/blender/io/collada/TransformReader.h b/source/blender/io/collada/TransformReader.h index c5678d53927..229b41ecdb2 100644 --- a/source/blender/io/collada/TransformReader.h +++ b/source/blender/io/collada/TransformReader.h @@ -8,12 +8,10 @@ #pragma once -#include "COLLADAFWMatrix.h" +#include + #include "COLLADAFWNode.h" -#include "COLLADAFWRotate.h" -#include "COLLADAFWScale.h" #include "COLLADAFWTransformation.h" -#include "COLLADAFWTranslate.h" #include "COLLADAFWUniqueId.h" #include "Math/COLLADABUMathVector3.h" diff --git a/source/blender/io/collada/TransformWriter.cpp b/source/blender/io/collada/TransformWriter.cpp index d2a95a3963d..888ce4ef937 100644 --- a/source/blender/io/collada/TransformWriter.cpp +++ b/source/blender/io/collada/TransformWriter.cpp @@ -7,12 +7,13 @@ */ #include "BLI_math_matrix.h" -#include "BLI_sys_types.h" #include "BKE_object.hh" #include "TransformWriter.h" +#include "collada_utils.h" + void TransformWriter::add_joint_transform(COLLADASW::Node &node, float mat[4][4], float parent_mat[4][4], diff --git a/source/blender/io/collada/TransformWriter.h b/source/blender/io/collada/TransformWriter.h index dccc6cf8d94..eb5843e28be 100644 --- a/source/blender/io/collada/TransformWriter.h +++ b/source/blender/io/collada/TransformWriter.h @@ -12,9 +12,7 @@ #include "DNA_object_types.h" -#include "collada.h" -#include "collada_internal.h" -#include "collada_utils.h" +#include "ExportSettings.h" class TransformWriter { protected: diff --git a/source/blender/io/collada/collada.cpp b/source/blender/io/collada/collada.cpp index 7dafa12f4de..cf8637ac211 100644 --- a/source/blender/io/collada/collada.cpp +++ b/source/blender/io/collada/collada.cpp @@ -6,22 +6,14 @@ * \ingroup collada */ -/* COLLADABU_ASSERT, may be able to remove later */ -#include "COLLADABUPlatform.h" - +#include "collada.h" #include "DocumentExporter.h" #include "DocumentImporter.h" #include "ExportSettings.h" #include "ImportSettings.h" -#include "collada.h" #include "BKE_context.hh" -#include "BKE_scene.hh" -#include "DEG_depsgraph.hh" -#include "DEG_depsgraph_query.hh" -/* make dummy file */ -#include "BLI_fileops.h" #include "BLI_linklist.h" extern "C" { diff --git a/source/blender/io/collada/collada.h b/source/blender/io/collada/collada.h index d11729beea6..7c13935a1b8 100644 --- a/source/blender/io/collada/collada.h +++ b/source/blender/io/collada/collada.h @@ -8,13 +8,11 @@ #pragma once -#include +#include #include "ExportSettings.h" #include "ImportSettings.h" -#include "BLI_linklist.h" -#include "BLI_path_utils.hh" #include "RNA_types.hh" #ifdef __cplusplus diff --git a/source/blender/io/collada/collada_internal.cpp b/source/blender/io/collada/collada_internal.cpp index 77c0559d8b0..dc8d6aa54a9 100644 --- a/source/blender/io/collada/collada_internal.cpp +++ b/source/blender/io/collada/collada_internal.cpp @@ -6,15 +6,17 @@ * \ingroup collada */ -/* COLLADABU_ASSERT, may be able to remove later */ -#include "COLLADABUPlatform.h" -#include "collada_utils.h" +#include "collada_internal.h" -#include "BLI_linklist.h" #include "BLI_math_matrix.h" +#include "BLI_math_rotation.h" #include "BKE_armature.hh" +#include "RNA_access.hh" + +#include + UnitConverter::UnitConverter() : up_axis(COLLADAFW::FileInfo::Z_UP) { axis_angle_to_mat4_single(x_up_mat4, 'Y', -M_PI_2); diff --git a/source/blender/io/collada/collada_internal.h b/source/blender/io/collada/collada_internal.h index 28a9a62510c..c6463dda82e 100644 --- a/source/blender/io/collada/collada_internal.h +++ b/source/blender/io/collada/collada_internal.h @@ -8,14 +8,11 @@ #pragma once -#include #include -#include #include "COLLADAFWFileInfo.h" #include "Math/COLLADABUMathMatrix4.h" -#include "BLI_linklist.h" #include "DNA_armature_types.h" #include "DNA_material_types.h" #include "DNA_object_types.h" @@ -45,9 +42,9 @@ class UnitConverter { void convertVector3(COLLADABU::Math::Vector3 &vec, float *v); - UnitConverter::UnitSystem isMetricSystem(void); + UnitConverter::UnitSystem isMetricSystem(); - float getLinearMeter(void); + float getLinearMeter(); /* TODO: need also for angle conversion, time conversion... */ diff --git a/source/blender/io/collada/collada_utils.cpp b/source/blender/io/collada/collada_utils.cpp index 42eb4629d65..a200cd91358 100644 --- a/source/blender/io/collada/collada_utils.cpp +++ b/source/blender/io/collada/collada_utils.cpp @@ -6,19 +6,12 @@ * \ingroup collada */ -/* COLLADABU_ASSERT, may be able to remove later */ -#include "COLLADABUPlatform.h" - -#include "COLLADAFWGeometry.h" -#include "COLLADAFWMeshPrimitive.h" #include "COLLADAFWMeshVertexData.h" #include "COLLADAFWNode.h" #include #include -#include "MEM_guardedalloc.h" - #include "DNA_armature_types.h" #include "DNA_constraint_types.h" #include "DNA_customdata_types.h" @@ -31,6 +24,7 @@ #include "BLI_linklist.h" #include "BLI_listbase.h" #include "BLI_math_matrix.h" +#include "BLI_string.h" #include "BKE_action.hh" #include "BKE_armature.hh" @@ -38,6 +32,7 @@ #include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_global.hh" +#include "BKE_idprop.hh" #include "BKE_key.hh" #include "BKE_layer.hh" #include "BKE_lib_id.hh" @@ -655,7 +650,7 @@ int BoneExtended::get_use_connect() void bc_set_IDPropertyMatrix(EditBone *ebone, const char *key, float mat[4][4]) { - IDProperty *idgroup = (IDProperty *)ebone->prop; + IDProperty *idgroup = ebone->prop; if (idgroup == nullptr) { idgroup = blender::bke::idprop::create_group("RNA_EditBone ID properties").release(); ebone->prop = idgroup; @@ -701,7 +696,7 @@ float bc_get_property(Bone *bone, std::string key, float def) result = float(IDP_Int(property)); break; case IDP_FLOAT: - result = float(IDP_Float(property)); + result = IDP_Float(property); break; case IDP_DOUBLE: result = float(IDP_Double(property)); diff --git a/source/blender/io/collada/collada_utils.h b/source/blender/io/collada/collada_utils.h index 10f76bb127e..47b4500d46d 100644 --- a/source/blender/io/collada/collada_utils.h +++ b/source/blender/io/collada/collada_utils.h @@ -8,12 +8,9 @@ #pragma once -#include "COLLADAFWColorOrTexture.h" #include "COLLADAFWFloatOrDoubleArray.h" -#include "COLLADAFWGeometry.h" -#include "COLLADAFWMeshPrimitive.h" #include "COLLADAFWTypes.h" -#include "COLLADASWEffectProfile.h" +#include "COLLADASWColorOrTexture.h" #include #include @@ -34,30 +31,24 @@ #include "RNA_access.hh" #include "BLI_linklist.h" -#include "BLI_string.h" -#include "BLI_utildefines.h" #include "BKE_context.hh" -#include "BKE_idprop.hh" #include "BKE_main.hh" #include "BKE_node.hh" #include "BKE_object.hh" #include "BKE_scene.hh" -#include "DEG_depsgraph_query.hh" - #include "BCSampleData.h" #include "BlenderContext.h" #include "ExportSettings.h" -#include "ImportSettings.h" #include "collada_internal.h" constexpr int LIMITTED_PRECISION = 6; -typedef std::map UidImageMap; -typedef std::map KeyImageMap; -typedef std::map> TexIndexTextureArrayMap; -typedef std::set BCObjectSet; +using UidImageMap = std::map; +using KeyImageMap = std::map; +using TexIndexTextureArrayMap = std::map>; +using BCObjectSet = std::set; namespace COLLADAFW { class Node; @@ -72,39 +63,39 @@ std::vector bc_getSceneActions(const bContext *C, Object *ob, bool al /* Action and Animdata helpers */ -/* Return Object's Action or NULL. */ +/* Return Object's Action or nullptr. */ inline bAction *bc_getSceneObjectAction(Object *ob) { - return (ob->adt && ob->adt->action) ? ob->adt->action : NULL; + return (ob->adt && ob->adt->action) ? ob->adt->action : nullptr; } -/* Return Light's AnimData or NULL. */ +/* Return Light's AnimData or nullptr. */ inline AnimData *bc_getSceneLightAnimData(Object *ob) { if (ob->type != OB_LAMP) { - return NULL; + return nullptr; } Light *lamp = (Light *)ob->data; return lamp->adt; } -/* Return Camera's AnimData or NULL. */ +/* Return Camera's AnimData or nullptr. */ inline AnimData *bc_getSceneCameraAnimData(Object *ob) { if (ob->type != OB_CAMERA) { - return NULL; + return nullptr; } const Camera *camera = (const Camera *)ob->data; return camera->adt; } -/* Return Material's AnimData or NULL. */ +/* Return Material's AnimData or nullptr. */ inline AnimData *bc_getSceneMaterialAnimData(Material *ma) { - if (ma == NULL) { - return NULL; + if (ma == nullptr) { + return nullptr; } return ma->adt; @@ -412,7 +403,7 @@ class BoneExtended { * std:string : an armature name * BoneExtended * : a map that contains extra data for bones */ -typedef std::map BoneExtensionMap; +using BoneExtensionMap = std::map; /* * A class to organize bone extension data for multiple Armatures. diff --git a/source/blender/io/common/IO_abstract_hierarchy_iterator.h b/source/blender/io/common/IO_abstract_hierarchy_iterator.h index 0f954314a1b..e3624358013 100644 --- a/source/blender/io/common/IO_abstract_hierarchy_iterator.h +++ b/source/blender/io/common/IO_abstract_hierarchy_iterator.h @@ -209,16 +209,16 @@ bool operator==(const ObjectIdentifier &obj_ident_a, const ObjectIdentifier &obj class AbstractHierarchyIterator { public: /* Mapping from export path to writer. */ - typedef std::map WriterMap; + using WriterMap = std::map; /* All the children of some object, as per the export hierarchy. */ - typedef std::set ExportChildren; + using ExportChildren = std::set; /* Mapping from an object and its duplicator to the object's export-children. */ - typedef std::map ExportGraph; + using ExportGraph = std::map; /* Mapping from ID to its export path. This is used for instancing; given an * instanced datablock, the export path of the original can be looked up. */ - typedef std::map ExportPathMap; + using ExportPathMap = std::map; /* IDs of all duplisource objects, used to identify instance prototypes. */ - typedef std::set DupliSources; + using DupliSources = std::set; protected: ExportGraph export_graph_; @@ -297,8 +297,8 @@ class AbstractHierarchyIterator { std::string get_object_name(const Object *object) const; std::string get_object_data_name(const Object *object) const; - typedef AbstractHierarchyWriter *(AbstractHierarchyIterator::*create_writer_func)( - const HierarchyContext *); + using create_writer_func = + AbstractHierarchyWriter *(AbstractHierarchyIterator::*)(const HierarchyContext *); /* Ensure that a writer exists; if it doesn't, call create_func(context). * * The create_func function should be one of the create_XXXX_writer(context) functions declared diff --git a/source/blender/io/common/intern/dupli_parent_finder.hh b/source/blender/io/common/intern/dupli_parent_finder.hh index a94b3949b69..059f923e58b 100644 --- a/source/blender/io/common/intern/dupli_parent_finder.hh +++ b/source/blender/io/common/intern/dupli_parent_finder.hh @@ -20,11 +20,11 @@ class DupliParentFinder final { std::set dupli_set_; /* To find the DupliObject given its Persistent ID. */ - typedef std::map PIDToDupliMap; + using PIDToDupliMap = std::map; PIDToDupliMap pid_to_dupli_; /* Mapping from instancer PID to duplis instanced by it. */ - typedef std::map> InstancerPIDToDuplisMap; + using InstancerPIDToDuplisMap = std::map>; InstancerPIDToDuplisMap instancer_pid_to_duplis_; public: diff --git a/source/blender/io/common/intern/subdiv_disabler.cc b/source/blender/io/common/intern/subdiv_disabler.cc index 3c7c59b5232..7589cae6001 100644 --- a/source/blender/io/common/intern/subdiv_disabler.cc +++ b/source/blender/io/common/intern/subdiv_disabler.cc @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ #include "IO_subdiv_disabler.hh" -#include - #include "BLI_listbase.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/io/grease_pencil/intern/grease_pencil_io.cc b/source/blender/io/grease_pencil/intern/grease_pencil_io.cc index 159558bf4d8..c6d67e5a9bd 100644 --- a/source/blender/io/grease_pencil/intern/grease_pencil_io.cc +++ b/source/blender/io/grease_pencil/intern/grease_pencil_io.cc @@ -2,6 +2,7 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "BLI_bounds.hh" #include "BLI_color.hh" #include "BLI_math_matrix.hh" #include "BLI_math_vector.h" diff --git a/source/blender/io/grease_pencil/intern/grease_pencil_io_export_pdf.cc b/source/blender/io/grease_pencil/intern/grease_pencil_io_export_pdf.cc index 7ba716f5749..0648fb4e7a2 100644 --- a/source/blender/io/grease_pencil/intern/grease_pencil_io_export_pdf.cc +++ b/source/blender/io/grease_pencil/intern/grease_pencil_io_export_pdf.cc @@ -2,20 +2,16 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BKE_attribute.hh" -#include "BKE_curves.hh" +#include "BLI_bounds.hh" + #include "BKE_grease_pencil.hh" -#include "BKE_material.hh" #include "BKE_scene.hh" #include "DEG_depsgraph_query.hh" #include "DNA_grease_pencil_types.h" -#include "DNA_material_types.h" #include "DNA_scene_types.h" -#include "ED_view3d.hh" - #include "grease_pencil_io.hh" #include "grease_pencil_io_intern.hh" diff --git a/source/blender/io/grease_pencil/intern/grease_pencil_io_export_svg.cc b/source/blender/io/grease_pencil/intern/grease_pencil_io_export_svg.cc index ce012740c2f..237e8b6fede 100644 --- a/source/blender/io/grease_pencil/intern/grease_pencil_io_export_svg.cc +++ b/source/blender/io/grease_pencil/intern/grease_pencil_io_export_svg.cc @@ -2,35 +2,22 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BKE_attribute.hh" -#include "BKE_curves.hh" -#include "BKE_material.hh" +#include "BLI_bounds.hh" #include "BLI_color.hh" -#include "BLI_math_matrix.hh" -#include "BLI_offset_indices.hh" #include "BLI_string.h" -#include "BLI_task.hh" #include "BLI_vector.hh" -#include "BLI_virtual_array.hh" #include "BKE_grease_pencil.hh" -#include "DNA_material_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DEG_depsgraph_query.hh" -#include "DNA_view3d_types.h" - -#include "GEO_resample_curves.hh" - -#include "ED_grease_pencil.hh" -#include "ED_view3d.hh" #include "grease_pencil_io_intern.hh" #include #include -#include #include #include diff --git a/source/blender/io/grease_pencil/intern/grease_pencil_io_import_svg.cc b/source/blender/io/grease_pencil/intern/grease_pencil_io_import_svg.cc index 9b9bdefb9a8..0f3649d1a68 100644 --- a/source/blender/io/grease_pencil/intern/grease_pencil_io_import_svg.cc +++ b/source/blender/io/grease_pencil/intern/grease_pencil_io_import_svg.cc @@ -24,8 +24,6 @@ #include "DNA_space_types.h" #include "DNA_windowmanager_types.h" -#include "GEO_resample_curves.hh" - #include "ED_grease_pencil.hh" #include "grease_pencil_io_intern.hh" diff --git a/source/blender/io/grease_pencil/intern/grease_pencil_io_intern.hh b/source/blender/io/grease_pencil/intern/grease_pencil_io_intern.hh index 38f2e3af94f..db91d9c690a 100644 --- a/source/blender/io/grease_pencil/intern/grease_pencil_io_intern.hh +++ b/source/blender/io/grease_pencil/intern/grease_pencil_io_intern.hh @@ -2,7 +2,7 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BLI_bounds.hh" +#include "BLI_bounds_types.hh" #include "BLI_color.hh" #include "BLI_function_ref.hh" #include "BLI_math_matrix_types.hh" diff --git a/source/blender/io/ply/exporter/ply_export.cc b/source/blender/io/ply/exporter/ply_export.cc index af07fe380c2..ee7fd12cd3d 100644 --- a/source/blender/io/ply/exporter/ply_export.cc +++ b/source/blender/io/ply/exporter/ply_export.cc @@ -84,13 +84,13 @@ void exporter_main(bContext *C, const PLYExportParams &export_params) return; } - write_header(*buffer.get(), *plyData.get(), export_params); + write_header(*buffer, *plyData, export_params); - write_vertices(*buffer.get(), *plyData.get()); + write_vertices(*buffer, *plyData); - write_faces(*buffer.get(), *plyData.get()); + write_faces(*buffer, *plyData); - write_edges(*buffer.get(), *plyData.get()); + write_edges(*buffer, *plyData); buffer->close_file(); } diff --git a/source/blender/io/ply/exporter/ply_file_buffer.hh b/source/blender/io/ply/exporter/ply_file_buffer.hh index 990a305039e..43535d25fd1 100644 --- a/source/blender/io/ply/exporter/ply_file_buffer.hh +++ b/source/blender/io/ply/exporter/ply_file_buffer.hh @@ -8,8 +8,6 @@ #pragma once -#include - #include "BLI_string_ref.hh" #include "BLI_utility_mixins.hh" #include "BLI_vector.hh" diff --git a/source/blender/io/ply/importer/ply_import.cc b/source/blender/io/ply/importer/ply_import.cc index 23a1b3589c2..8da29dcd6bf 100644 --- a/source/blender/io/ply/importer/ply_import.cc +++ b/source/blender/io/ply/importer/ply_import.cc @@ -18,7 +18,6 @@ #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" -#include "BLI_math_vector.h" #include "BLI_span.hh" #include "BLI_string.h" diff --git a/source/blender/io/ply/importer/ply_import_buffer.cc b/source/blender/io/ply/importer/ply_import_buffer.cc index 45ca35d9094..2a82e885753 100644 --- a/source/blender/io/ply/importer/ply_import_buffer.cc +++ b/source/blender/io/ply/importer/ply_import_buffer.cc @@ -6,6 +6,7 @@ #include "BLI_fileops.h" +#include #include #include #include @@ -69,9 +70,7 @@ bool PlyReadBuffer::read_bytes(void *dst, size_t size) } } int to_copy = int(size); - if (to_copy > buf_used_) { - to_copy = buf_used_; - } + to_copy = std::min(to_copy, buf_used_); memcpy(dst, buffer_.data() + pos_, to_copy); pos_ += to_copy; dst = (char *)dst + to_copy; diff --git a/source/blender/io/ply/importer/ply_import_buffer.hh b/source/blender/io/ply/importer/ply_import_buffer.hh index 24d4a6feb3b..e0f300ac32b 100644 --- a/source/blender/io/ply/importer/ply_import_buffer.hh +++ b/source/blender/io/ply/importer/ply_import_buffer.hh @@ -41,7 +41,6 @@ class PlyReadBuffer { private: bool refill_buffer(); - private: FILE *file_ = nullptr; Array buffer_; int pos_ = 0; diff --git a/source/blender/io/ply/importer/ply_import_data.cc b/source/blender/io/ply/importer/ply_import_data.cc index 2cfa704a44b..0387863a8e0 100644 --- a/source/blender/io/ply/importer/ply_import_data.cc +++ b/source/blender/io/ply/importer/ply_import_data.cc @@ -261,8 +261,9 @@ static const char *load_vertex_element(PlyReadBuffer &file, const PlyProperty &prop = element.properties[prop_idx]; bool is_standard = ELEM( prop.name, "x", "y", "z", "nx", "ny", "nz", "red", "green", "blue", "alpha", "s", "t"); - if (is_standard) + if (is_standard) { continue; + } custom_attr_indices.append(prop_idx); PlyCustomAttribute attr(prop.name, element.count); diff --git a/source/blender/io/ply/importer/ply_import_mesh.cc b/source/blender/io/ply/importer/ply_import_mesh.cc index 8c870a65346..8c25936bf08 100644 --- a/source/blender/io/ply/importer/ply_import_mesh.cc +++ b/source/blender/io/ply/importer/ply_import_mesh.cc @@ -9,7 +9,6 @@ #include "BKE_attribute.hh" #include "BKE_lib_id.hh" #include "BKE_mesh.hh" -#include "BKE_mesh_runtime.hh" #include "GEO_mesh_merge_by_distance.hh" diff --git a/source/blender/io/ply/tests/io_ply_exporter_test.cc b/source/blender/io/ply/tests/io_ply_exporter_test.cc index 0eddb0ec2dc..e734d79893a 100644 --- a/source/blender/io/ply/tests/io_ply_exporter_test.cc +++ b/source/blender/io/ply/tests/io_ply_exporter_test.cc @@ -113,7 +113,7 @@ static std::string read_temp_file_in_string(const std::string &file_path) static char read(std::ifstream &file) { char return_val; - file.read((char *)&return_val, sizeof(return_val)); + file.read(&return_val, sizeof(return_val)); return return_val; } @@ -146,7 +146,7 @@ TEST_F(PLYExportTest, WriteHeaderAscii) std::unique_ptr buffer = std::make_unique(_params.filepath); - write_header(*buffer.get(), *plyData.get(), _params); + write_header(*buffer, *plyData, _params); buffer->close_file(); @@ -184,7 +184,7 @@ TEST_F(PLYExportTest, WriteHeaderBinary) std::unique_ptr buffer = std::make_unique(_params.filepath); - write_header(*buffer.get(), *plyData.get(), _params); + write_header(*buffer, *plyData, _params); buffer->close_file(); @@ -222,7 +222,7 @@ TEST_F(PLYExportTest, WriteVerticesAscii) std::unique_ptr buffer = std::make_unique(_params.filepath); - write_vertices(*buffer.get(), *plyData.get()); + write_vertices(*buffer, *plyData); buffer->close_file(); @@ -254,7 +254,7 @@ TEST_F(PLYExportTest, WriteVerticesBinary) std::unique_ptr buffer = std::make_unique(_params.filepath); - write_vertices(*buffer.get(), *plyData.get()); + write_vertices(*buffer, *plyData); buffer->close_file(); @@ -290,7 +290,7 @@ TEST_F(PLYExportTest, WriteFacesAscii) std::unique_ptr buffer = std::make_unique(_params.filepath); - write_faces(*buffer.get(), *plyData.get()); + write_faces(*buffer, *plyData); buffer->close_file(); @@ -320,7 +320,7 @@ TEST_F(PLYExportTest, WriteFacesBinary) std::unique_ptr buffer = std::make_unique(_params.filepath); - write_faces(*buffer.get(), *plyData.get()); + write_faces(*buffer, *plyData); buffer->close_file(); @@ -356,7 +356,7 @@ TEST_F(PLYExportTest, WriteVertexNormalsAscii) std::unique_ptr buffer = std::make_unique(_params.filepath); - write_vertices(*buffer.get(), *plyData.get()); + write_vertices(*buffer, *plyData); buffer->close_file(); @@ -388,7 +388,7 @@ TEST_F(PLYExportTest, WriteVertexNormalsBinary) std::unique_ptr buffer = std::make_unique(_params.filepath); - write_vertices(*buffer.get(), *plyData.get()); + write_vertices(*buffer, *plyData); buffer->close_file(); diff --git a/source/blender/io/stl/tests/stl_exporter_tests.cc b/source/blender/io/stl/tests/stl_exporter_tests.cc index 2f322794ff6..c1bf8673c83 100644 --- a/source/blender/io/stl/tests/stl_exporter_tests.cc +++ b/source/blender/io/stl/tests/stl_exporter_tests.cc @@ -5,13 +5,10 @@ #include "tests/blendfile_loading_base_test.h" #include "BKE_appdir.hh" -#include "BKE_main.hh" #include "BLI_fileops.h" #include "BLI_string.h" -#include "BLO_readfile.hh" - #include "DEG_depsgraph.hh" #include "MEM_guardedalloc.h" diff --git a/source/blender/io/usd/hydra/curves.cc b/source/blender/io/usd/hydra/curves.cc index 62770c5989a..7539a2c3557 100644 --- a/source/blender/io/usd/hydra/curves.cc +++ b/source/blender/io/usd/hydra/curves.cc @@ -86,10 +86,10 @@ pxr::VtValue CurvesData::get_data(pxr::TfToken const &key) const if (key == pxr::HdTokens->points) { return pxr::VtValue(vertices_); } - else if (key == pxr::HdTokens->widths) { + if (key == pxr::HdTokens->widths) { return pxr::VtValue(widths_); } - else if (key == usdtokens::st) { + if (key == usdtokens::st) { return pxr::VtValue(uvs_); } return pxr::VtValue(); diff --git a/source/blender/io/usd/hydra/curves.hh b/source/blender/io/usd/hydra/curves.hh index bfac0316507..065692635fc 100644 --- a/source/blender/io/usd/hydra/curves.hh +++ b/source/blender/io/usd/hydra/curves.hh @@ -9,9 +9,6 @@ #include "BLI_set.hh" -#include "BKE_duplilist.hh" - -#include "DNA_curves_types.h" #include "DNA_particle_types.h" #include "material.hh" diff --git a/source/blender/io/usd/hydra/hydra_scene_delegate.cc b/source/blender/io/usd/hydra/hydra_scene_delegate.cc index d68e687e906..b080d3f2c68 100644 --- a/source/blender/io/usd/hydra/hydra_scene_delegate.cc +++ b/source/blender/io/usd/hydra/hydra_scene_delegate.cc @@ -6,10 +6,12 @@ #include -#include "DNA_scene_types.h" +#include "DNA_view3d_types.h" +#include "BKE_duplilist.hh" #include "BKE_particle.h" +#include "BLI_listbase.h" #include "BLI_set.hh" #include "BLI_string.h" @@ -287,7 +289,7 @@ ObjectData *HydraSceneDelegate::object_data(pxr::SdfPath const &id) const pxr::SdfPath p_id = (STRPREFIX(name.c_str(), "SM_") || STRPREFIX(name.c_str(), "VF_")) ? id.GetParentPath() : id; - auto obj_data = objects_.lookup_ptr(p_id); + const auto *obj_data = objects_.lookup_ptr(p_id); if (obj_data) { return obj_data->get(); } @@ -320,7 +322,7 @@ LightData *HydraSceneDelegate::light_data(pxr::SdfPath const &id) const MaterialData *HydraSceneDelegate::material_data(pxr::SdfPath const &id) const { - auto mat_data = materials_.lookup_ptr(id); + const auto *mat_data = materials_.lookup_ptr(id); if (!mat_data) { return nullptr; } diff --git a/source/blender/io/usd/hydra/hydra_scene_delegate.hh b/source/blender/io/usd/hydra/hydra_scene_delegate.hh index 2eb35fa2a14..744cdd4e2cf 100644 --- a/source/blender/io/usd/hydra/hydra_scene_delegate.hh +++ b/source/blender/io/usd/hydra/hydra_scene_delegate.hh @@ -7,8 +7,6 @@ #include #include -#include "BLI_map.hh" - #include "DEG_depsgraph.hh" #include "CLG_log.h" @@ -19,7 +17,6 @@ #include "mesh.hh" #include "object.hh" #include "volume.hh" -#include "volume_modifier.hh" #include "world.hh" struct Depsgraph; @@ -96,7 +93,7 @@ class HydraSceneDelegate : public pxr::HdSceneDelegate { pxr::SdfPath prim_id(const ID *id, const char *prefix) const; pxr::SdfPath object_prim_id(const Object *object) const; pxr::SdfPath material_prim_id(const Material *mat) const; - pxr::SdfPath hair_prim_id(Object *parent_obj, const ParticleSystem *mat) const; + pxr::SdfPath hair_prim_id(Object *parent_obj, const ParticleSystem *psys) const; pxr::SdfPath instancer_prim_id() const; pxr::SdfPath world_prim_id() const; diff --git a/source/blender/io/usd/hydra/id.cc b/source/blender/io/usd/hydra/id.cc index 2568313880f..6f3fc2848e7 100644 --- a/source/blender/io/usd/hydra/id.cc +++ b/source/blender/io/usd/hydra/id.cc @@ -4,8 +4,6 @@ #include "id.hh" -#include "BKE_lib_id.hh" - namespace blender::io::hydra { IdData::IdData(HydraSceneDelegate *scene_delegate, const ID *id, pxr::SdfPath const &prim_id) diff --git a/source/blender/io/usd/hydra/image.cc b/source/blender/io/usd/hydra/image.cc index 29bcd65f8db..d223595c493 100644 --- a/source/blender/io/usd/hydra/image.cc +++ b/source/blender/io/usd/hydra/image.cc @@ -11,16 +11,12 @@ #include "BLI_path_utils.hh" #include "BLI_string.h" -#include "BKE_appdir.hh" #include "BKE_image.hh" #include "BKE_image_format.hh" #include "BKE_image_save.hh" #include "BKE_main.hh" #include "BKE_packedFile.hh" -#include "IMB_imbuf.hh" -#include "IMB_imbuf_types.hh" - #include "hydra_scene_delegate.hh" namespace blender::io::hydra { diff --git a/source/blender/io/usd/hydra/instancer.cc b/source/blender/io/usd/hydra/instancer.cc index bcc18fe99b2..43bf30537d7 100644 --- a/source/blender/io/usd/hydra/instancer.cc +++ b/source/blender/io/usd/hydra/instancer.cc @@ -7,9 +7,10 @@ #include #include +#include "BKE_duplilist.hh" #include "BKE_particle.h" -#include "BLI_math_matrix.h" +#include "BLI_listbase.h" #include "BLI_string.h" #include "DEG_depsgraph_query.hh" @@ -101,7 +102,7 @@ ObjectData *InstancerData::object_data(pxr::SdfPath const &id) const pxr::SdfPathVector InstancerData::prototypes() const { pxr::SdfPathVector paths; - for (auto &m_inst : mesh_instances_.values()) { + for (const auto &m_inst : mesh_instances_.values()) { for (auto &p : m_inst.data->submesh_paths()) { paths.push_back(p); } @@ -111,10 +112,10 @@ pxr::SdfPathVector InstancerData::prototypes() const void InstancerData::available_materials(Set &paths) const { - for (auto &m_inst : mesh_instances_.values()) { + for (const auto &m_inst : mesh_instances_.values()) { m_inst.data->available_materials(paths); } - for (auto &l_inst : nonmesh_instances_.values()) { + for (const auto &l_inst : nonmesh_instances_.values()) { l_inst.data->available_materials(paths); } } @@ -299,8 +300,8 @@ void InstancerData::update_nonmesh_instance(NonmeshInstance &nm_inst) InstancerData::MeshInstance *InstancerData::mesh_instance(pxr::SdfPath const &id) const { - auto m_inst = mesh_instances_.lookup_ptr(id.GetPathElementCount() == 4 ? id.GetParentPath() : - id); + const auto *m_inst = mesh_instances_.lookup_ptr( + id.GetPathElementCount() == 4 ? id.GetParentPath() : id); if (!m_inst) { return nullptr; } @@ -309,8 +310,8 @@ InstancerData::MeshInstance *InstancerData::mesh_instance(pxr::SdfPath const &id InstancerData::NonmeshInstance *InstancerData::nonmesh_instance(pxr::SdfPath const &id) const { - auto nm_inst = nonmesh_instances_.lookup_ptr(id.GetPathElementCount() == 4 ? id.GetParentPath() : - id); + const auto *nm_inst = nonmesh_instances_.lookup_ptr( + id.GetPathElementCount() == 4 ? id.GetParentPath() : id); if (!nm_inst) { return nullptr; } diff --git a/source/blender/io/usd/hydra/instancer.hh b/source/blender/io/usd/hydra/instancer.hh index 22494549b37..8e633a59c03 100644 --- a/source/blender/io/usd/hydra/instancer.hh +++ b/source/blender/io/usd/hydra/instancer.hh @@ -9,6 +9,7 @@ #include "mesh.hh" +struct DupliObject; struct ParticleSystem; namespace blender::io::hydra { diff --git a/source/blender/io/usd/hydra/material.cc b/source/blender/io/usd/hydra/material.cc index e0829f96dee..f1db8c2e16a 100644 --- a/source/blender/io/usd/hydra/material.cc +++ b/source/blender/io/usd/hydra/material.cc @@ -19,19 +19,8 @@ # include #endif -#include "MEM_guardedalloc.h" - -#include "BKE_lib_id.hh" -#include "BKE_material.hh" - -#include "RNA_access.hh" -#include "RNA_prototypes.hh" -#include "RNA_types.hh" - #include "DEG_depsgraph_query.hh" -#include "bpy_rna.hh" - #include "hydra_scene_delegate.hh" #include "image.hh" @@ -39,7 +28,6 @@ #include "intern/usd_writer_material.hh" #ifdef WITH_MATERIALX -# include "shader/materialx/node_parser.h" # include "shader/materialx/material.h" #endif diff --git a/source/blender/io/usd/hydra/mesh.cc b/source/blender/io/usd/hydra/mesh.cc index 863c17b3cb2..41bf8146e75 100644 --- a/source/blender/io/usd/hydra/mesh.cc +++ b/source/blender/io/usd/hydra/mesh.cc @@ -14,7 +14,6 @@ #include "BKE_customdata.hh" #include "BKE_material.hh" #include "BKE_mesh.hh" -#include "BKE_mesh_runtime.hh" #include "hydra_scene_delegate.hh" #include "mesh.hh" @@ -120,7 +119,7 @@ pxr::SdfPath MeshData::material_id(pxr::SdfPath const &id) const void MeshData::available_materials(Set &paths) const { - for (auto &sm : submeshes_) { + for (const auto &sm : submeshes_) { if (sm.mat_data && !sm.mat_data->prim_id.IsEmpty()) { paths.add(sm.mat_data->prim_id); } diff --git a/source/blender/io/usd/hydra/mesh.hh b/source/blender/io/usd/hydra/mesh.hh index 7d189ec27bf..56066787a34 100644 --- a/source/blender/io/usd/hydra/mesh.hh +++ b/source/blender/io/usd/hydra/mesh.hh @@ -9,8 +9,6 @@ #include "BLI_set.hh" -#include "BKE_duplilist.hh" - #include "material.hh" #include "object.hh" diff --git a/source/blender/io/usd/hydra/object.cc b/source/blender/io/usd/hydra/object.cc index ea89e594f74..ffeddc90b09 100644 --- a/source/blender/io/usd/hydra/object.cc +++ b/source/blender/io/usd/hydra/object.cc @@ -2,6 +2,8 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "BKE_layer.hh" + #include "DEG_depsgraph_query.hh" #include "curves.hh" @@ -10,6 +12,7 @@ #include "mesh.hh" #include "object.hh" #include "volume.hh" +#include "volume_modifier.hh" namespace blender::io::hydra { diff --git a/source/blender/io/usd/hydra/object.hh b/source/blender/io/usd/hydra/object.hh index 04335fe825d..abaedc10223 100644 --- a/source/blender/io/usd/hydra/object.hh +++ b/source/blender/io/usd/hydra/object.hh @@ -12,7 +12,6 @@ #include "BLI_map.hh" #include "BLI_set.hh" -#include "BKE_layer.hh" #include "BKE_object.hh" #include "id.hh" @@ -25,7 +24,6 @@ class ObjectData : public IdData { pxr::GfMatrix4d transform; bool visible = true; - public: ObjectData(HydraSceneDelegate *scene_delegate, const Object *object, pxr::SdfPath const &prim_id); diff --git a/source/blender/io/usd/hydra/volume_modifier.cc b/source/blender/io/usd/hydra/volume_modifier.cc index e33b796fde9..305f46fbaf9 100644 --- a/source/blender/io/usd/hydra/volume_modifier.cc +++ b/source/blender/io/usd/hydra/volume_modifier.cc @@ -7,7 +7,6 @@ #include #include "DNA_scene_types.h" -#include "DNA_volume_types.h" #include "BLI_path_utils.hh" #include "BLI_string.h" diff --git a/source/blender/io/usd/hydra/world.cc b/source/blender/io/usd/hydra/world.cc index 3f73eca7d56..bd175671600 100644 --- a/source/blender/io/usd/hydra/world.cc +++ b/source/blender/io/usd/hydra/world.cc @@ -15,9 +15,9 @@ #include "DNA_node_types.h" #include "DNA_scene_types.h" +#include "DNA_world_types.h" #include "BLI_math_rotation.h" -#include "BLI_path_utils.hh" #include "BKE_node.hh" #include "BKE_node_legacy_types.hh" @@ -65,7 +65,7 @@ void WorldData::init() const Span input_sockets = output_node->input_sockets(); bNodeSocket *input_socket = nullptr; - for (auto socket : input_sockets) { + for (auto *socket : input_sockets) { if (STREQ(socket->name, "Surface")) { input_socket = socket; break; diff --git a/source/blender/io/usd/hydra/world.hh b/source/blender/io/usd/hydra/world.hh index 73efbf35b45..ebd2c1fc1c3 100644 --- a/source/blender/io/usd/hydra/world.hh +++ b/source/blender/io/usd/hydra/world.hh @@ -4,17 +4,12 @@ #pragma once -#include - #include #include #include #include #include -#include "DNA_view3d_types.h" -#include "DNA_world_types.h" - #include "light.hh" namespace blender::io::hydra { diff --git a/source/blender/io/usd/intern/usd_asset_utils.cc b/source/blender/io/usd/intern/usd_asset_utils.cc index 8bf78e05015..a7ab8889ca0 100644 --- a/source/blender/io/usd/intern/usd_asset_utils.cc +++ b/source/blender/io/usd/intern/usd_asset_utils.cc @@ -394,7 +394,7 @@ bool should_import_asset(const std::string &path) return true; } - if (is_udim_path(path) && parent_dir_exists_on_file_system(path.c_str())) { + if (is_udim_path(path) && parent_dir_exists_on_file_system(path)) { return false; } diff --git a/source/blender/io/usd/intern/usd_attribute_utils.cc b/source/blender/io/usd/intern/usd_attribute_utils.cc index 113c598ac89..822e993d0eb 100644 --- a/source/blender/io/usd/intern/usd_attribute_utils.cc +++ b/source/blender/io/usd/intern/usd_attribute_utils.cc @@ -5,7 +5,6 @@ #include "usd_attribute_utils.hh" #include "usd_hash_types.hh" -#include "BLI_generic_span.hh" #include "BLI_map.hh" #include "BLI_offset_indices.hh" #include "BLI_sys_types.h" diff --git a/source/blender/io/usd/intern/usd_capi_export.cc b/source/blender/io/usd/intern/usd_capi_export.cc index 89beba9b07e..17d55974e0f 100644 --- a/source/blender/io/usd/intern/usd_capi_export.cc +++ b/source/blender/io/usd/intern/usd_capi_export.cc @@ -432,10 +432,12 @@ pxr::UsdStageRefPtr export_to_stage(const USDExportParams ¶ms, pxr::VtValue upAxis = pxr::VtValue(pxr::UsdGeomTokens->z); if (params.convert_orientation) { - if (params.up_axis == IO_AXIS_X) + if (params.up_axis == IO_AXIS_X) { upAxis = pxr::VtValue(pxr::UsdGeomTokens->x); - else if (params.up_axis == IO_AXIS_Y) + } + else if (params.up_axis == IO_AXIS_Y) { upAxis = pxr::VtValue(pxr::UsdGeomTokens->y); + } } usd_stage->SetMetadata(pxr::UsdGeomTokens->upAxis, upAxis); diff --git a/source/blender/io/usd/intern/usd_capi_import.cc b/source/blender/io/usd/intern/usd_capi_import.cc index f50a3b71ce6..a778b0dc414 100644 --- a/source/blender/io/usd/intern/usd_capi_import.cc +++ b/source/blender/io/usd/intern/usd_capi_import.cc @@ -520,7 +520,7 @@ void USD_read_geometry(CacheReader *reader, return; } - return usd_reader->read_geometry(geometry_set, params, r_err_str); + usd_reader->read_geometry(geometry_set, params, r_err_str); } bool USD_mesh_topology_changed(CacheReader *reader, diff --git a/source/blender/io/usd/intern/usd_hierarchy_iterator.hh b/source/blender/io/usd/intern/usd_hierarchy_iterator.hh index ef297a4599c..5a043556e8a 100644 --- a/source/blender/io/usd/intern/usd_hierarchy_iterator.hh +++ b/source/blender/io/usd/intern/usd_hierarchy_iterator.hh @@ -41,21 +41,19 @@ class USDHierarchyIterator : public AbstractHierarchyIterator { void set_export_frame(float frame_nr); - virtual std::string make_valid_name(const std::string &name) const override; + std::string make_valid_name(const std::string &name) const override; void process_usd_skel() const; protected: - virtual bool mark_as_weak_export(const Object *object) const override; + bool mark_as_weak_export(const Object *object) const override; - virtual AbstractHierarchyWriter *create_transform_writer( - const HierarchyContext *context) override; - virtual AbstractHierarchyWriter *create_data_writer(const HierarchyContext *context) override; - virtual AbstractHierarchyWriter *create_hair_writer(const HierarchyContext *context) override; - virtual AbstractHierarchyWriter *create_particle_writer( - const HierarchyContext *context) override; + AbstractHierarchyWriter *create_transform_writer(const HierarchyContext *context) override; + AbstractHierarchyWriter *create_data_writer(const HierarchyContext *context) override; + AbstractHierarchyWriter *create_hair_writer(const HierarchyContext *context) override; + AbstractHierarchyWriter *create_particle_writer(const HierarchyContext *context) override; - virtual void release_writer(AbstractHierarchyWriter *writer) override; + void release_writer(AbstractHierarchyWriter *writer) override; virtual bool include_data_writers(const HierarchyContext *context) const override; virtual bool include_child_writers(const HierarchyContext *context) const override; diff --git a/source/blender/io/usd/intern/usd_hook.cc b/source/blender/io/usd/intern/usd_hook.cc index a97d358ad56..1e1f01af6f4 100644 --- a/source/blender/io/usd/intern/usd_hook.cc +++ b/source/blender/io/usd/intern/usd_hook.cc @@ -144,9 +144,7 @@ struct USDSceneImportContext { void release() { - if (prim_map_dict) { - delete prim_map_dict; - } + delete prim_map_dict; } pxr::UsdStageRefPtr get_stage() const @@ -165,7 +163,7 @@ struct USDSceneImportContext { } PYTHON_NS::list list = PYTHON_NS::extract((*prim_map_dict)[path]); - for (auto &ptr_rna : ids) { + for (const auto &ptr_rna : ids) { list.append(ptr_rna); } }); @@ -507,7 +505,7 @@ class MaterialImportPollInvoker : public USDHookInvoker { private: USDMaterialImportContext hook_context_; pxr::UsdShadeMaterial usd_material_; - bool result_; + bool result_ = false; public: MaterialImportPollInvoker(pxr::UsdStageRefPtr stage, @@ -516,8 +514,7 @@ class MaterialImportPollInvoker : public USDHookInvoker { ReportList *reports) : USDHookInvoker(reports), hook_context_(stage, import_params, reports), - usd_material_(usd_material), - result_(false) + usd_material_(usd_material) { } @@ -548,7 +545,7 @@ class OnMaterialImportInvoker : public USDHookInvoker { USDMaterialImportContext hook_context_; pxr::UsdShadeMaterial usd_material_; PointerRNA material_ptr_; - bool result_; + bool result_ = false; public: OnMaterialImportInvoker(pxr::UsdStageRefPtr stage, @@ -558,8 +555,7 @@ class OnMaterialImportInvoker : public USDHookInvoker { ReportList *reports) : USDHookInvoker(reports), hook_context_(stage, import_params, reports), - usd_material_(usd_material), - result_(false) + usd_material_(usd_material) { material_ptr_ = RNA_pointer_create_discrete(nullptr, &RNA_Material, material); } diff --git a/source/blender/io/usd/intern/usd_reader_material.cc b/source/blender/io/usd/intern/usd_reader_material.cc index 5963d8848aa..cd2667b2a82 100644 --- a/source/blender/io/usd/intern/usd_reader_material.cc +++ b/source/blender/io/usd/intern/usd_reader_material.cc @@ -7,7 +7,6 @@ #include "usd_reader_utils.hh" #include "usd_utils.hh" -#include "BKE_appdir.hh" #include "BKE_image.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" @@ -22,7 +21,6 @@ #include "BLI_math_vector.h" #include "BLI_path_utils.hh" #include "BLI_string.h" -#include "BLI_string_utils.hh" #include "BLI_vector.hh" #include "DNA_material_types.h" @@ -687,62 +685,61 @@ bool USDMaterialReader::set_node_input(const pxr::UsdShadeInput &usd_input, * and attempt to convert the connected USD shader to a Blender node. */ return follow_connection(usd_input, dest_node, dest_socket_name, ntree, column, r_ctx, extra); } - else { - /* Set the destination node socket value from the USD shader input value. */ - bNodeSocket *sock = blender::bke::node_find_socket(dest_node, SOCK_IN, dest_socket_name); - if (!sock) { - CLOG_ERROR(&LOG, "Couldn't get destination node socket %s", dest_socket_name); - return false; - } + /* Set the destination node socket value from the USD shader input value. */ - pxr::VtValue val; - if (!usd_input.Get(&val)) { - CLOG_ERROR(&LOG, - "Couldn't get value for usd shader input %s", - usd_input.GetPrim().GetPath().GetAsString().c_str()); - return false; - } + bNodeSocket *sock = blender::bke::node_find_socket(dest_node, SOCK_IN, dest_socket_name); + if (!sock) { + CLOG_ERROR(&LOG, "Couldn't get destination node socket %s", dest_socket_name); + return false; + } - switch (sock->type) { - case SOCK_FLOAT: - if (val.IsHolding()) { - ((bNodeSocketValueFloat *)sock->default_value)->value = val.UncheckedGet(); - return true; - } - else if (val.IsHolding()) { - pxr::GfVec3f v3f = val.UncheckedGet(); - float average = (v3f[0] + v3f[1] + v3f[2]) / 3.0f; - ((bNodeSocketValueFloat *)sock->default_value)->value = average; - return true; - } - break; - case SOCK_RGBA: - if (val.IsHolding()) { - pxr::GfVec3f v3f = val.UncheckedGet(); - copy_v3_v3(((bNodeSocketValueRGBA *)sock->default_value)->value, v3f.data()); - return true; - } - break; - case SOCK_VECTOR: - if (val.IsHolding()) { - pxr::GfVec3f v3f = val.UncheckedGet(); - copy_v3_v3(((bNodeSocketValueVector *)sock->default_value)->value, v3f.data()); - return true; - } - else if (val.IsHolding()) { - pxr::GfVec2f v2f = val.UncheckedGet(); - copy_v2_v2(((bNodeSocketValueVector *)sock->default_value)->value, v2f.data()); - return true; - } - break; - default: - CLOG_WARN(&LOG, - "Unexpected type %s for destination node socket %s", - sock->idname, - dest_socket_name); - break; - } + pxr::VtValue val; + if (!usd_input.Get(&val)) { + CLOG_ERROR(&LOG, + "Couldn't get value for usd shader input %s", + usd_input.GetPrim().GetPath().GetAsString().c_str()); + return false; + } + + switch (sock->type) { + case SOCK_FLOAT: + if (val.IsHolding()) { + ((bNodeSocketValueFloat *)sock->default_value)->value = val.UncheckedGet(); + return true; + } + else if (val.IsHolding()) { + pxr::GfVec3f v3f = val.UncheckedGet(); + float average = (v3f[0] + v3f[1] + v3f[2]) / 3.0f; + ((bNodeSocketValueFloat *)sock->default_value)->value = average; + return true; + } + break; + case SOCK_RGBA: + if (val.IsHolding()) { + pxr::GfVec3f v3f = val.UncheckedGet(); + copy_v3_v3(((bNodeSocketValueRGBA *)sock->default_value)->value, v3f.data()); + return true; + } + break; + case SOCK_VECTOR: + if (val.IsHolding()) { + pxr::GfVec3f v3f = val.UncheckedGet(); + copy_v3_v3(((bNodeSocketValueVector *)sock->default_value)->value, v3f.data()); + return true; + } + else if (val.IsHolding()) { + pxr::GfVec2f v2f = val.UncheckedGet(); + copy_v2_v2(((bNodeSocketValueVector *)sock->default_value)->value, v2f.data()); + return true; + } + break; + default: + CLOG_WARN(&LOG, + "Unexpected type %s for destination node socket %s", + sock->idname, + dest_socket_name); + break; } return false; diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc index 50807bbdc05..bfbc5a2b1d2 100644 --- a/source/blender/io/usd/intern/usd_reader_mesh.cc +++ b/source/blender/io/usd/intern/usd_reader_mesh.cc @@ -953,13 +953,12 @@ std::optional USDMeshReader::get_local_usd_xform(const float time) * is constant over time. */ return XformResult(pxr::GfMatrix4f(bind_xf), true); } - else { - BKE_reportf(reports(), - RPT_WARNING, - "%s: Couldn't compute geom bind transform for %s", - __func__, - prim_.GetPath().GetAsString().c_str()); - } + + BKE_reportf(reports(), + RPT_WARNING, + "%s: Couldn't compute geom bind transform for %s", + __func__, + prim_.GetPath().GetAsString().c_str()); } } diff --git a/source/blender/io/usd/intern/usd_reader_mesh.hh b/source/blender/io/usd/intern/usd_reader_mesh.hh index bc7ba12a63c..7367ed86999 100644 --- a/source/blender/io/usd/intern/usd_reader_mesh.hh +++ b/source/blender/io/usd/intern/usd_reader_mesh.hh @@ -31,23 +31,19 @@ class USDMeshReader : public USDGeomReader { pxr::TfToken normal_interpolation_; pxr::TfToken orientation_; - bool is_left_handed_; - bool is_time_varying_; + bool is_left_handed_ = false; + bool is_time_varying_ = false; /* This is to ensure we load all data once, because we reuse the read_mesh function * in the mesh seq modifier, and in initial load. Ideally, a better fix would be * implemented. Note this will break if faces or positions vary. */ - bool is_initial_load_; + bool is_initial_load_ = false; public: USDMeshReader(const pxr::UsdPrim &prim, const USDImportParams &import_params, const ImportSettings &settings) - : USDGeomReader(prim, import_params, settings), - mesh_prim_(prim), - is_left_handed_(false), - is_time_varying_(false), - is_initial_load_(false) + : USDGeomReader(prim, import_params, settings), mesh_prim_(prim) { } diff --git a/source/blender/io/usd/intern/usd_reader_nurbs.cc b/source/blender/io/usd/intern/usd_reader_nurbs.cc index b42863bffcc..9e9938a71cb 100644 --- a/source/blender/io/usd/intern/usd_reader_nurbs.cc +++ b/source/blender/io/usd/intern/usd_reader_nurbs.cc @@ -141,9 +141,9 @@ void USDNurbsReader::read_curve_sample(Curve *cu, const double motionSampleTime) BPoint *bp = nu->bp; for (int j = 0; j < nu->pntsu; j++, bp++, idx++) { - bp->vec[0] = float(usdPoints[idx][0]); - bp->vec[1] = float(usdPoints[idx][1]); - bp->vec[2] = float(usdPoints[idx][2]); + bp->vec[0] = usdPoints[idx][0]; + bp->vec[1] = usdPoints[idx][1]; + bp->vec[2] = usdPoints[idx][2]; bp->vec[3] = weight; bp->f1 = SELECT; bp->weight = weight; diff --git a/source/blender/io/usd/intern/usd_reader_shape.cc b/source/blender/io/usd/intern/usd_reader_shape.cc index 60ae7d6f1f2..120a610e332 100644 --- a/source/blender/io/usd/intern/usd_reader_shape.cc +++ b/source/blender/io/usd/intern/usd_reader_shape.cc @@ -2,7 +2,6 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BKE_attribute.hh" #include "BKE_geometry_set.hh" #include "BKE_lib_id.hh" #include "BKE_mesh.hh" diff --git a/source/blender/io/usd/intern/usd_reader_shape.hh b/source/blender/io/usd/intern/usd_reader_shape.hh index 4c5a7444048..3075f12489a 100644 --- a/source/blender/io/usd/intern/usd_reader_shape.hh +++ b/source/blender/io/usd/intern/usd_reader_shape.hh @@ -64,8 +64,7 @@ class USDShapeReader : public USDGeomReader { * This assumes mesh_from_prim() has been called. */ bool is_time_varying(); - virtual bool topology_changed(const Mesh * /*existing_mesh*/, - double /*motionSampleTime*/) override + bool topology_changed(const Mesh * /*existing_mesh*/, double /*motionSampleTime*/) override { return false; }; diff --git a/source/blender/io/usd/intern/usd_reader_xform.hh b/source/blender/io/usd/intern/usd_reader_xform.hh index edee6eb6687..582d9dd2a65 100644 --- a/source/blender/io/usd/intern/usd_reader_xform.hh +++ b/source/blender/io/usd/intern/usd_reader_xform.hh @@ -23,7 +23,7 @@ using XformResult = std::tuple; class USDXformReader : public USDPrimReader { private: - bool use_parent_xform_; + bool use_parent_xform_ = false; /* Indicates if the created object is the root of a * transform hierarchy. */ @@ -33,9 +33,7 @@ class USDXformReader : public USDPrimReader { USDXformReader(const pxr::UsdPrim &prim, const USDImportParams &import_params, const ImportSettings &settings) - : USDPrimReader(prim, import_params, settings), - use_parent_xform_(false), - is_root_xform_(is_root_xform_prim()) + : USDPrimReader(prim, import_params, settings), is_root_xform_(is_root_xform_prim()) { } diff --git a/source/blender/io/usd/intern/usd_skel_convert.cc b/source/blender/io/usd/intern/usd_skel_convert.cc index 11c977936a3..8e5cad48e68 100644 --- a/source/blender/io/usd/intern/usd_skel_convert.cc +++ b/source/blender/io/usd/intern/usd_skel_convert.cc @@ -44,6 +44,7 @@ #include "ANIM_animdata.hh" +#include #include #include @@ -1313,9 +1314,7 @@ void export_deform_verts(const Mesh *mesh, int max_totweight = 1; for (const int i : dverts.index_range()) { const MDeformVert &vert = dverts[i]; - if (vert.totweight > max_totweight) { - max_totweight = vert.totweight; - } + max_totweight = std::max(vert.totweight, max_totweight); } /* elem_size will specify the number of diff --git a/source/blender/io/usd/intern/usd_writer_abstract.hh b/source/blender/io/usd/intern/usd_writer_abstract.hh index b81aff90e39..37233899ee8 100644 --- a/source/blender/io/usd/intern/usd_writer_abstract.hh +++ b/source/blender/io/usd/intern/usd_writer_abstract.hh @@ -41,7 +41,7 @@ class USDAbstractWriter : public AbstractHierarchyWriter { public: USDAbstractWriter(const USDExporterContext &usd_export_context); - virtual void write(HierarchyContext &context) override; + void write(HierarchyContext &context) override; /** * Returns true if the data to be written is actually supported. This would, for example, allow a diff --git a/source/blender/io/usd/intern/usd_writer_armature.hh b/source/blender/io/usd/intern/usd_writer_armature.hh index a81ee28d0fc..07590dfd65c 100644 --- a/source/blender/io/usd/intern/usd_writer_armature.hh +++ b/source/blender/io/usd/intern/usd_writer_armature.hh @@ -16,9 +16,9 @@ class USDArmatureWriter : public USDAbstractWriter { USDArmatureWriter(const USDExporterContext &ctx); protected: - virtual void do_write(HierarchyContext &context) override; + void do_write(HierarchyContext &context) override; - virtual bool check_is_animated(const HierarchyContext &context) const override; + bool check_is_animated(const HierarchyContext &context) const override; private: Map deform_map_; diff --git a/source/blender/io/usd/intern/usd_writer_camera.hh b/source/blender/io/usd/intern/usd_writer_camera.hh index 2daa4d73b77..a09c2558f62 100644 --- a/source/blender/io/usd/intern/usd_writer_camera.hh +++ b/source/blender/io/usd/intern/usd_writer_camera.hh @@ -13,8 +13,8 @@ class USDCameraWriter : public USDAbstractWriter { USDCameraWriter(const USDExporterContext &ctx); protected: - virtual bool is_supported(const HierarchyContext *context) const override; - virtual void do_write(HierarchyContext &context) override; + bool is_supported(const HierarchyContext *context) const override; + void do_write(HierarchyContext &context) override; }; } // namespace blender::io::usd diff --git a/source/blender/io/usd/intern/usd_writer_curves.cc b/source/blender/io/usd/intern/usd_writer_curves.cc index 28ef4e9e280..48df273a1f2 100644 --- a/source/blender/io/usd/intern/usd_writer_curves.cc +++ b/source/blender/io/usd/intern/usd_writer_curves.cc @@ -649,7 +649,7 @@ void USDCurvesWriter::assign_materials(const HierarchyContext &context, } bool curve_material_bound = false; - for (short mat_num = 0; mat_num < context.object->totcol; mat_num++) { + for (int mat_num = 0; mat_num < context.object->totcol; mat_num++) { Material *material = BKE_object_material_get(context.object, mat_num + 1); if (material == nullptr) { continue; diff --git a/source/blender/io/usd/intern/usd_writer_curves.hh b/source/blender/io/usd/intern/usd_writer_curves.hh index f5a1aef615b..e2ee763dc7d 100644 --- a/source/blender/io/usd/intern/usd_writer_curves.hh +++ b/source/blender/io/usd/intern/usd_writer_curves.hh @@ -23,7 +23,7 @@ class USDCurvesWriter final : public USDAbstractWriter { ~USDCurvesWriter() final = default; protected: - virtual void do_write(HierarchyContext &context) override; + void do_write(HierarchyContext &context) override; void assign_materials(const HierarchyContext &context, const pxr::UsdGeomCurves &usd_curves); private: diff --git a/source/blender/io/usd/intern/usd_writer_hair.hh b/source/blender/io/usd/intern/usd_writer_hair.hh index 4799955b309..353d296d796 100644 --- a/source/blender/io/usd/intern/usd_writer_hair.hh +++ b/source/blender/io/usd/intern/usd_writer_hair.hh @@ -13,8 +13,8 @@ class USDHairWriter : public USDAbstractWriter { USDHairWriter(const USDExporterContext &ctx); protected: - virtual void do_write(HierarchyContext &context) override; - virtual bool check_is_animated(const HierarchyContext &context) const override; + void do_write(HierarchyContext &context) override; + bool check_is_animated(const HierarchyContext &context) const override; }; } // namespace blender::io::usd diff --git a/source/blender/io/usd/intern/usd_writer_light.hh b/source/blender/io/usd/intern/usd_writer_light.hh index f3583ed52fc..a9d54895a47 100644 --- a/source/blender/io/usd/intern/usd_writer_light.hh +++ b/source/blender/io/usd/intern/usd_writer_light.hh @@ -12,8 +12,8 @@ class USDLightWriter : public USDAbstractWriter { USDLightWriter(const USDExporterContext &ctx); protected: - virtual bool is_supported(const HierarchyContext *context) const override; - virtual void do_write(HierarchyContext &context) override; + bool is_supported(const HierarchyContext *context) const override; + void do_write(HierarchyContext &context) override; }; } // namespace blender::io::usd diff --git a/source/blender/io/usd/intern/usd_writer_material.cc b/source/blender/io/usd/intern/usd_writer_material.cc index 2ec80f0c004..53cbefdf921 100644 --- a/source/blender/io/usd/intern/usd_writer_material.cc +++ b/source/blender/io/usd/intern/usd_writer_material.cc @@ -7,7 +7,6 @@ #include "usd_exporter_context.hh" #include "usd_hook.hh" #include "usd_utils.hh" -#include "usd_writer_abstract.hh" #include "BKE_image.hh" #include "BKE_image_format.hh" @@ -23,7 +22,6 @@ #include "BLI_fileops.h" #include "BLI_listbase.h" #include "BLI_map.hh" -#include "BLI_memory_utils.hh" #include "BLI_path_utils.hh" #include "BLI_set.hh" #include "BLI_string.h" @@ -44,7 +42,6 @@ static CLG_LogRef LOG = {"io.usd"}; #ifdef WITH_MATERIALX # include "shader/materialx/material.h" -# include "shader/materialx/node_parser.h" # include # include # include @@ -1361,8 +1358,11 @@ pxr::TfToken token_for_input(const char *input_name) #ifdef WITH_MATERIALX /* A wrapper for the MaterialX code to re-use the standard Texture export code */ -static std::string materialx_export_image( - const USDExporterContext &usd_export_context, Main *, Scene *, Image *ima, ImageUser *) +static std::string materialx_export_image(const USDExporterContext &usd_export_context, + Main * /*main*/, + Scene * /*scene*/, + Image *ima, + ImageUser * /*iuser*/) { auto tex_path = get_tex_image_asset_filepath( ima, usd_export_context.stage, usd_export_context.export_params); @@ -1383,7 +1383,7 @@ static pxr::SdfPath reflow_materialx_paths(pxr::SdfPath input_path, /* First we see if the path is in the rename_pairs, * otherwise we check if it starts with any items in the list plus a path separator (/ or .) . * Checking for the path separators, removes false positives from other prefixed elements. */ - auto value_lookup_ptr = rename_pairs.lookup_ptr(input_path_string); + const auto *value_lookup_ptr = rename_pairs.lookup_ptr(input_path_string); if (value_lookup_ptr) { input_path = pxr::SdfPath(*value_lookup_ptr); } @@ -1415,13 +1415,11 @@ static void create_usd_materialx_material(const USDExporterContext &usd_export_c usd_path.GetElementString(), /* We want to re-use the same MaterialX document generation code as used by the renderer. * While the graph is traversed, we also want it to export the textures out. */ - (usd_export_context.export_image_fn) ? usd_export_context.export_image_fn : - std::bind(materialx_export_image, - usd_export_context, - std::placeholders::_1, - std::placeholders::_2, - std::placeholders::_3, - std::placeholders::_4), + (usd_export_context.export_image_fn) ? + usd_export_context.export_image_fn : + [usd_export_context](Main *main, Scene *scene, Image *ima, ImageUser *iuser) { + return materialx_export_image(usd_export_context, main, scene, ima, iuser); + }, /* Active UV map name to use for default texture coordinates. */ (usd_export_context.export_params.rename_uvmaps) ? "st" : active_uvmap_name, active_uvmap_name, diff --git a/source/blender/io/usd/intern/usd_writer_mesh.hh b/source/blender/io/usd/intern/usd_writer_mesh.hh index 0165f74c495..a750fe132e1 100644 --- a/source/blender/io/usd/intern/usd_writer_mesh.hh +++ b/source/blender/io/usd/intern/usd_writer_mesh.hh @@ -28,8 +28,8 @@ class USDGenericMeshWriter : public USDAbstractWriter { USDGenericMeshWriter(const USDExporterContext &ctx); protected: - virtual bool is_supported(const HierarchyContext *context) const override; - virtual void do_write(HierarchyContext &context) override; + bool is_supported(const HierarchyContext *context) const override; + void do_write(HierarchyContext &context) override; virtual Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) = 0; virtual void free_export_mesh(Mesh *mesh); @@ -64,9 +64,9 @@ class USDMeshWriter : public USDGenericMeshWriter { USDMeshWriter(const USDExporterContext &ctx); protected: - virtual void do_write(HierarchyContext &context) override; + void do_write(HierarchyContext &context) override; - virtual Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) override; + Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) override; /** * Determine whether we should write skinned mesh or blend shape data diff --git a/source/blender/io/usd/intern/usd_writer_metaball.hh b/source/blender/io/usd/intern/usd_writer_metaball.hh index 7b198bd3fdc..9eba8b0de1c 100644 --- a/source/blender/io/usd/intern/usd_writer_metaball.hh +++ b/source/blender/io/usd/intern/usd_writer_metaball.hh @@ -12,10 +12,10 @@ class USDMetaballWriter : public USDGenericMeshWriter { USDMetaballWriter(const USDExporterContext &ctx); protected: - virtual Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) override; - virtual void free_export_mesh(Mesh *mesh) override; - virtual bool is_supported(const HierarchyContext *context) const override; - virtual bool check_is_animated(const HierarchyContext &context) const override; + Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) override; + void free_export_mesh(Mesh *mesh) override; + bool is_supported(const HierarchyContext *context) const override; + bool check_is_animated(const HierarchyContext &context) const override; private: bool is_basis_ball(Scene *scene, Object *ob) const; diff --git a/source/blender/io/usd/intern/usd_writer_points.hh b/source/blender/io/usd/intern/usd_writer_points.hh index 24b19839e33..9e8ba108794 100644 --- a/source/blender/io/usd/intern/usd_writer_points.hh +++ b/source/blender/io/usd/intern/usd_writer_points.hh @@ -23,7 +23,7 @@ class USDPointsWriter final : public USDAbstractWriter { ~USDPointsWriter() final = default; protected: - virtual void do_write(HierarchyContext &context) override; + void do_write(HierarchyContext &context) override; private: void write_generic_data(const bke::AttributeIter &attr, diff --git a/source/blender/io/usd/intern/usd_writer_transform.cc b/source/blender/io/usd/intern/usd_writer_transform.cc index 90383d919d2..0e9deedef4c 100644 --- a/source/blender/io/usd/intern/usd_writer_transform.cc +++ b/source/blender/io/usd/intern/usd_writer_transform.cc @@ -137,7 +137,8 @@ bool USDTransformWriter::check_is_animated(const HierarchyContext &context) cons return BKE_object_moves_in_time(context.object, context.animation_check_include_parent); } -void USDTransformWriter::set_xform_ops(float xf_matrix[4][4], const pxr::UsdGeomXformable &xf) +void USDTransformWriter::set_xform_ops(float parent_relative_matrix[4][4], + const pxr::UsdGeomXformable &xf) { if (!xf) { return; @@ -175,7 +176,7 @@ void USDTransformWriter::set_xform_ops(float xf_matrix[4][4], const pxr::UsdGeom pxr::UsdTimeCode time_code = get_export_time_code(); if (xformOps_.size() == 1) { - pxr::GfMatrix4d mat_val(xf_matrix); + pxr::GfMatrix4d mat_val(parent_relative_matrix); usd_value_writer_.SetAttribute(xformOps_[0].GetAttr(), mat_val, time_code); } else if (xformOps_.size() == 3) { @@ -184,7 +185,7 @@ void USDTransformWriter::set_xform_ops(float xf_matrix[4][4], const pxr::UsdGeom float quat[4]; float scale[3]; - mat4_decompose(loc, quat, scale, xf_matrix); + mat4_decompose(loc, quat, scale, parent_relative_matrix); if (xfOpMode == USD_XFORM_OP_TRS) { float rot[3]; diff --git a/source/blender/io/usd/intern/usd_writer_volume.cc b/source/blender/io/usd/intern/usd_writer_volume.cc index bd3f2452832..8c856bb94ea 100644 --- a/source/blender/io/usd/intern/usd_writer_volume.cc +++ b/source/blender/io/usd/intern/usd_writer_volume.cc @@ -23,7 +23,6 @@ #include "BLI_fileops.h" #include "BLI_index_range.hh" #include "BLI_math_base.h" -#include "BLI_math_vector_types.hh" #include "BLI_path_utils.hh" #include "BLI_string.h" diff --git a/source/blender/io/usd/intern/usd_writer_volume.hh b/source/blender/io/usd/intern/usd_writer_volume.hh index 6480fda4390..1c66d6f00f6 100644 --- a/source/blender/io/usd/intern/usd_writer_volume.hh +++ b/source/blender/io/usd/intern/usd_writer_volume.hh @@ -18,8 +18,8 @@ class USDVolumeWriter : public USDAbstractWriter { USDVolumeWriter(const USDExporterContext &ctx); protected: - virtual bool check_is_animated(const HierarchyContext &context) const override; - virtual void do_write(HierarchyContext &context) override; + bool check_is_animated(const HierarchyContext &context) const override; + void do_write(HierarchyContext &context) override; private: /* Try to ensure that external `.vdb` file is available for USD to be referenced. Blender can diff --git a/source/blender/io/usd/tests/usd_export_test.cc b/source/blender/io/usd/tests/usd_export_test.cc index 5a6eaf6eaa8..17a6817c088 100644 --- a/source/blender/io/usd/tests/usd_export_test.cc +++ b/source/blender/io/usd/tests/usd_export_test.cc @@ -69,12 +69,12 @@ class UsdExportTest : public BlendfileLoadingBaseTest { return true; } - virtual void SetUp() override + void SetUp() override { BlendfileLoadingBaseTest::SetUp(); } - virtual void TearDown() override + void TearDown() override { BlendfileLoadingBaseTest::TearDown(); CTX_free(context); @@ -85,7 +85,7 @@ class UsdExportTest : public BlendfileLoadingBaseTest { } } - const pxr::UsdPrim get_first_child_mesh(const pxr::UsdPrim prim) + pxr::UsdPrim get_first_child_mesh(const pxr::UsdPrim prim) { for (auto child : prim.GetChildren()) { if (child.IsA()) { @@ -99,13 +99,12 @@ class UsdExportTest : public BlendfileLoadingBaseTest { * Loop the sockets on the Blender `bNode`, and fail if any of their values do * not match the equivalent Attribute values on the `UsdPrim`. */ - const void compare_blender_node_to_usd_prim(const bNode *bsdf_node, - const pxr::UsdPrim &bsdf_prim) + void compare_blender_node_to_usd_prim(const bNode *bsdf_node, const pxr::UsdPrim &bsdf_prim) { ASSERT_NE(bsdf_node, nullptr); ASSERT_TRUE(bool(bsdf_prim)); - for (auto socket : bsdf_node->input_sockets()) { + for (const auto *socket : bsdf_node->input_sockets()) { const pxr::TfToken attribute_token = blender::io::usd::token_for_input(socket->name); if (attribute_token.IsEmpty()) { /* This socket is not translated between Blender and USD. */ @@ -152,8 +151,8 @@ class UsdExportTest : public BlendfileLoadingBaseTest { } } - const void compare_blender_image_to_usd_image_shader(const bNode *image_node, - const pxr::UsdPrim &image_prim) + void compare_blender_image_to_usd_image_shader(const bNode *image_node, + const pxr::UsdPrim &image_prim) { const Image *image = reinterpret_cast(image_node->id); @@ -178,7 +177,7 @@ class UsdExportTest : public BlendfileLoadingBaseTest { * Determine if a Blender Mesh matches a UsdGeomMesh prim by checking counts * on vertices, faces, face indices, and normals. */ - const void compare_blender_mesh_to_usd_prim(const Mesh *mesh, const pxr::UsdGeomMesh &mesh_prim) + void compare_blender_mesh_to_usd_prim(const Mesh *mesh, const pxr::UsdGeomMesh &mesh_prim) { pxr::VtIntArray face_indices; pxr::VtIntArray face_counts; diff --git a/source/blender/io/usd/tests/usd_stage_creation_test.cc b/source/blender/io/usd/tests/usd_stage_creation_test.cc index 09d87a2114a..55c027e6f44 100644 --- a/source/blender/io/usd/tests/usd_stage_creation_test.cc +++ b/source/blender/io/usd/tests/usd_stage_creation_test.cc @@ -8,11 +8,6 @@ #include -#include "BLI_path_utils.hh" -#include "BLI_utildefines.h" - -#include "BKE_appdir.hh" - namespace blender::io::usd { class USDStageCreationTest : public testing::Test {}; diff --git a/source/blender/io/usd/tests/usd_usdz_export_test.cc b/source/blender/io/usd/tests/usd_usdz_export_test.cc index 0d14d5b8a14..41e540c169c 100644 --- a/source/blender/io/usd/tests/usd_usdz_export_test.cc +++ b/source/blender/io/usd/tests/usd_usdz_export_test.cc @@ -48,7 +48,7 @@ class UsdUsdzExportTest : public BlendfileLoadingBaseTest { return true; } - virtual void SetUp() override + void SetUp() override { BlendfileLoadingBaseTest::SetUp(); @@ -64,7 +64,7 @@ class UsdUsdzExportTest : public BlendfileLoadingBaseTest { BLI_path_join(output_filepath, FILE_MAX, temp_output_dir, "output_новый.usdz"); } - virtual void TearDown() override + void TearDown() override { BlendfileLoadingBaseTest::TearDown(); CTX_free(context); diff --git a/source/blender/io/usd/usd.hh b/source/blender/io/usd/usd.hh index 3ff67fe051c..528bfc46e35 100644 --- a/source/blender/io/usd/usd.hh +++ b/source/blender/io/usd/usd.hh @@ -113,7 +113,7 @@ enum eUSDTexExportMode { USD_TEX_EXPORT_NEW_PATH, }; -typedef enum eUSDSceneUnits { +enum eUSDSceneUnits { USD_SCENE_UNITS_CUSTOM = -1, USD_SCENE_UNITS_METERS = 0, USD_SCENE_UNITS_KILOMETERS = 1, @@ -122,7 +122,7 @@ typedef enum eUSDSceneUnits { USD_SCENE_UNITS_INCHES = 4, USD_SCENE_UNITS_FEET = 5, USD_SCENE_UNITS_YARDS = 6, -} eUSDSceneUnits; +}; struct USDExportParams { bool export_animation = false; diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc index 809335015bd..d77ecdd7372 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc @@ -15,6 +15,7 @@ #include "BLI_color.hh" #include "BLI_enumerable_thread_specific.hh" +#include "BLI_fileops.h" #include "BLI_math_matrix.hh" #include "BLI_path_utils.hh" #include "BLI_string.h" diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.hh b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.hh index e4e14399377..cae5d0848d2 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.hh +++ b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.hh @@ -14,6 +14,7 @@ #include "IO_wavefront_obj.hh" #include "obj_export_io.hh" +#include "obj_export_mesh.hh" #include "obj_export_mtl.hh" namespace blender::io::obj { diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_io.hh b/source/blender/io/wavefront_obj/exporter/obj_export_io.hh index 171fd522e13..f540ca852f3 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_io.hh +++ b/source/blender/io/wavefront_obj/exporter/obj_export_io.hh @@ -9,10 +9,7 @@ #pragma once #include -#include -#include "BLI_compiler_attrs.h" -#include "BLI_fileops.h" #include "BLI_string_ref.hh" #include "BLI_utility_mixins.hh" #include "BLI_vector.hh" diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh index 05c2b142e00..ae60551e105 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh +++ b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh @@ -8,8 +8,6 @@ #pragma once -#include - #include "BLI_math_matrix_types.hh" #include "BLI_math_vector_types.hh" #include "BLI_offset_indices.hh" @@ -137,7 +135,7 @@ class OBJMesh : NonCopyable { */ void store_uv_coords_and_indices(); /* Get UV coordinates computed by store_uv_coords_and_indices. */ - const Span get_uv_coords() const + Span get_uv_coords() const { return uv_coords_; } diff --git a/source/blender/io/wavefront_obj/exporter/obj_exporter.cc b/source/blender/io/wavefront_obj/exporter/obj_exporter.cc index 145d4aab711..a348cd3eb09 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_exporter.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_exporter.cc @@ -173,7 +173,7 @@ static void write_mesh_objects(const Span> exportable_a } mtlindices.reserve(count); } - for (auto &obj_mesh : exportable_as_mesh) { + for (const auto &obj_mesh : exportable_as_mesh) { OBJMesh &obj = *obj_mesh; if (mtl_writer) { mtlindices.append(mtl_writer->add_materials(obj)); @@ -198,7 +198,7 @@ static void write_mesh_objects(const Span> exportable_a Vector index_offsets; index_offsets.reserve(count); IndexOffsets offsets{0, 0, 0}; - for (auto &obj_mesh : exportable_as_mesh) { + for (const auto &obj_mesh : exportable_as_mesh) { OBJMesh &obj = *obj_mesh; index_offsets.append(offsets); offsets.vertex_offset += obj.tot_vertices(); diff --git a/source/blender/io/wavefront_obj/importer/importer_mesh_utils.hh b/source/blender/io/wavefront_obj/importer/importer_mesh_utils.hh index 6a990a25c03..2743374b87a 100644 --- a/source/blender/io/wavefront_obj/importer/importer_mesh_utils.hh +++ b/source/blender/io/wavefront_obj/importer/importer_mesh_utils.hh @@ -29,7 +29,7 @@ namespace blender::io::obj { * \return List of faces with each element containing indices of one face. The indices * are into face_vert_indices array. */ -Vector> fixup_invalid_face(Span vert_coords, Span face_vert_indices); +Vector> fixup_invalid_face(Span vert_positions, Span face_verts); /** * Apply axes transform to the Object, and clamp object dimensions to the specified value. diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc index d49f39c4af4..ac81834c16e 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc @@ -6,6 +6,8 @@ * \ingroup obj */ +#include + #include "DNA_customdata_types.h" #include "DNA_material_types.h" #include "DNA_meshdata_types.h" @@ -236,9 +238,7 @@ void MeshFromGeometry::create_faces(Mesh *mesh, bool use_vertex_groups) material_indices.span[face_idx] = curr_face.material_index; /* Importing obj files without any materials would result in negative indices, which is not * supported. */ - if (material_indices.span[face_idx] < 0) { - material_indices.span[face_idx] = 0; - } + material_indices.span[face_idx] = std::max(material_indices.span[face_idx], 0); for (int idx = 0; idx < curr_face.corner_count_; ++idx) { const FaceCorner &curr_corner = mesh_geometry_.face_corners_[curr_face.start_index_ + idx]; diff --git a/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc b/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc index 22f1f360f85..746fa6103b0 100644 --- a/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc +++ b/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc @@ -22,7 +22,6 @@ #include "DEG_depsgraph.hh" #include "obj_export_file_writer.hh" -#include "obj_export_mesh.hh" #include "obj_export_nurbs.hh" #include "obj_exporter.hh" diff --git a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc index 3ab916735b5..f28c6a843a0 100644 --- a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc +++ b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc @@ -11,7 +11,6 @@ #include "CLG_log.h" #include "obj_import_file_reader.hh" -#include "obj_importer.hh" namespace blender::io::obj {