forked from bartvdbraak/blender
refactor: Collada reorganize class constructors
- Class constructors without body (only attribute initialisations) can safely be kept in the class header files - Constructor variables should be initialized in the order of their definition in the header files This change is also aimed to remove a couple of build warnings from the linux builds.
This commit is contained in:
parent
31e3b7790a
commit
0c8b0771f2
@ -38,13 +38,13 @@ private:
|
||||
public:
|
||||
|
||||
AnimationClipExporter(Depsgraph *depsgraph , COLLADASW::StreamWriter *sw, const ExportSettings *export_settings, std::vector<std::vector<std::string>> anim_meta) :
|
||||
depsgraph(depsgraph),
|
||||
COLLADASW::LibraryAnimationClips(sw),
|
||||
depsgraph(depsgraph),
|
||||
scene(nullptr),
|
||||
sw(sw),
|
||||
export_settings(export_settings),
|
||||
anim_meta(anim_meta)
|
||||
{
|
||||
this->sw = sw;
|
||||
}
|
||||
{}
|
||||
|
||||
void exportAnimationClips(Scene *sce);
|
||||
};
|
||||
|
@ -98,16 +98,16 @@ class AnimationExporter: COLLADASW::LibraryAnimations
|
||||
private:
|
||||
BlenderContext &blender_context;
|
||||
COLLADASW::StreamWriter *sw;
|
||||
const ExportSettings *export_settings;
|
||||
|
||||
public:
|
||||
|
||||
AnimationExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings):
|
||||
blender_context(blender_context),
|
||||
COLLADASW::LibraryAnimations(sw),
|
||||
blender_context(blender_context),
|
||||
sw(sw),
|
||||
export_settings(export_settings)
|
||||
{
|
||||
this->sw = sw;
|
||||
}
|
||||
{}
|
||||
|
||||
bool exportAnimations();
|
||||
|
||||
@ -115,7 +115,6 @@ public:
|
||||
void operator() (Object *ob);
|
||||
|
||||
protected:
|
||||
const ExportSettings *export_settings;
|
||||
|
||||
void export_object_constraint_animation(Object *ob);
|
||||
|
||||
|
@ -244,11 +244,6 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain, Object *ob, std::vect
|
||||
}
|
||||
}
|
||||
|
||||
AnimationImporter::AnimationImporter(bContext *C, UnitConverter *conv, ArmatureImporter *arm, Scene *scene) :
|
||||
mContext(C),
|
||||
TransformReader(conv), armature_importer(arm), scene(scene) {
|
||||
}
|
||||
|
||||
AnimationImporter::~AnimationImporter()
|
||||
{
|
||||
// free unused FCurves
|
||||
|
@ -139,7 +139,11 @@ private:
|
||||
};
|
||||
public:
|
||||
|
||||
AnimationImporter(bContext *C, UnitConverter *conv, ArmatureImporter *arm, Scene *scene);
|
||||
AnimationImporter(bContext *C, UnitConverter *conv, ArmatureImporter *arm, Scene *scene) :
|
||||
TransformReader(conv),
|
||||
mContext(C),
|
||||
armature_importer(arm),
|
||||
scene(scene) {}
|
||||
|
||||
~AnimationImporter();
|
||||
|
||||
|
@ -53,15 +53,6 @@ extern "C" {
|
||||
|
||||
#include "collada_utils.h"
|
||||
|
||||
// XXX exporter writes wrong data for shared armatures. A separate
|
||||
// controller should be written for each armature-mesh binding how do
|
||||
// we make controller ids then?
|
||||
ArmatureExporter::ArmatureExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) :
|
||||
blender_context(blender_context),
|
||||
COLLADASW::LibraryControllers(sw), export_settings(export_settings)
|
||||
{
|
||||
}
|
||||
|
||||
// write bone nodes
|
||||
void ArmatureExporter::add_armature_bones(
|
||||
Object *ob_arm,
|
||||
|
@ -57,7 +57,15 @@ class SceneExporter;
|
||||
class ArmatureExporter : public COLLADASW::LibraryControllers, protected TransformWriter, protected InstanceWriter
|
||||
{
|
||||
public:
|
||||
ArmatureExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
|
||||
|
||||
// XXX exporter writes wrong data for shared armatures. A separate
|
||||
// controller should be written for each armature-mesh binding how do
|
||||
// we make controller ids then?
|
||||
ArmatureExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) :
|
||||
COLLADASW::LibraryControllers(sw),
|
||||
blender_context(blender_context),
|
||||
export_settings(export_settings)
|
||||
{}
|
||||
|
||||
void add_armature_bones(
|
||||
Object *ob_arm,
|
||||
@ -68,9 +76,8 @@ public:
|
||||
bool add_instance_controller(Object *ob);
|
||||
|
||||
private:
|
||||
UnitConverter converter;
|
||||
const ExportSettings *export_settings;
|
||||
BlenderContext &blender_context;
|
||||
const ExportSettings *export_settings;
|
||||
|
||||
#if 0
|
||||
std::vector<Object *> written_armatures;
|
||||
|
@ -55,13 +55,6 @@ extern "C" {
|
||||
|
||||
#include "collada_utils.h"
|
||||
|
||||
// XXX exporter writes wrong data for shared armatures. A separate
|
||||
// controller should be written for each armature-mesh binding how do
|
||||
// we make controller ids then?
|
||||
ControllerExporter::ControllerExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) :
|
||||
blender_context(blender_context),
|
||||
COLLADASW::LibraryControllers(sw), export_settings(export_settings) {
|
||||
}
|
||||
|
||||
bool ControllerExporter::is_skinned_mesh(Object *ob)
|
||||
{
|
||||
@ -428,8 +421,7 @@ void ControllerExporter::add_joints_element(ListBase *defbase,
|
||||
void ControllerExporter::add_bind_shape_mat(Object *ob)
|
||||
{
|
||||
double bind_mat[4][4];
|
||||
|
||||
converter.mat4_to_dae_double(bind_mat, ob->obmat);
|
||||
UnitConverter::mat4_to_dae_double(bind_mat, ob->obmat);
|
||||
|
||||
addBindShapeTransform(bind_mat);
|
||||
}
|
||||
@ -539,7 +531,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, ListBas
|
||||
mul_m4_m4m4(world, ob_arm->obmat, bind_mat);
|
||||
|
||||
invert_m4_m4(mat, world);
|
||||
converter.mat4_to_dae(inv_bind_mat, mat);
|
||||
UnitConverter::mat4_to_dae(inv_bind_mat, mat);
|
||||
if (this->export_settings->limit_precision)
|
||||
bc_sanitize_mat(inv_bind_mat, 6);
|
||||
source.appendValues(inv_bind_mat);
|
||||
|
@ -60,7 +60,14 @@ class SceneExporter;
|
||||
class ControllerExporter : public COLLADASW::LibraryControllers, protected TransformWriter, protected InstanceWriter
|
||||
{
|
||||
public:
|
||||
ControllerExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
|
||||
// XXX exporter writes wrong data for shared armatures. A separate
|
||||
// controller should be written for each armature-mesh binding how do
|
||||
// we make controller ids then?
|
||||
ControllerExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) :
|
||||
COLLADASW::LibraryControllers(sw),
|
||||
blender_context(blender_context),
|
||||
export_settings(export_settings) {
|
||||
}
|
||||
|
||||
bool is_skinned_mesh(Object *ob);
|
||||
|
||||
@ -72,7 +79,6 @@ public:
|
||||
|
||||
private:
|
||||
BlenderContext &blender_context;
|
||||
UnitConverter converter;
|
||||
const ExportSettings *export_settings;
|
||||
|
||||
#if 0
|
||||
|
@ -50,12 +50,6 @@ extern "C" {
|
||||
#include "collada_internal.h"
|
||||
#include "collada_utils.h"
|
||||
|
||||
// TODO: optimize UV sets by making indexed list with duplicates removed
|
||||
GeometryExporter::GeometryExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) :
|
||||
blender_context(blender_context),
|
||||
COLLADASW::LibraryGeometries(sw), export_settings(export_settings)
|
||||
{
|
||||
}
|
||||
|
||||
void GeometryExporter::exportGeom()
|
||||
{
|
||||
|
@ -75,7 +75,13 @@ class GeometryExporter : COLLADASW::LibraryGeometries
|
||||
Normal n;
|
||||
|
||||
public:
|
||||
GeometryExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
|
||||
|
||||
// TODO: optimize UV sets by making indexed list with duplicates removed
|
||||
GeometryExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) :
|
||||
COLLADASW::LibraryGeometries(sw),
|
||||
blender_context(blender_context),
|
||||
export_settings(export_settings)
|
||||
{}
|
||||
|
||||
void exportGeom();
|
||||
|
||||
|
@ -24,8 +24,8 @@
|
||||
|
||||
MaterialNode::MaterialNode(bContext *C, Material *ma, KeyImageMap &key_image_map) :
|
||||
mContext(C),
|
||||
effect(nullptr),
|
||||
material(ma),
|
||||
effect(nullptr),
|
||||
key_image_map(&key_image_map)
|
||||
{
|
||||
ntree = prepare_material_nodetree();
|
||||
@ -34,8 +34,8 @@ MaterialNode::MaterialNode(bContext *C, Material *ma, KeyImageMap &key_image_map
|
||||
|
||||
MaterialNode::MaterialNode(bContext *C, COLLADAFW::EffectCommon *ef, Material *ma, UidImageMap &uid_image_map) :
|
||||
mContext(C),
|
||||
effect(ef),
|
||||
material(ma),
|
||||
effect(ef),
|
||||
uid_image_map(&uid_image_map)
|
||||
{
|
||||
ntree = prepare_material_nodetree();
|
||||
|
@ -53,6 +53,7 @@ private:
|
||||
COLLADAFW::EffectCommon *effect;
|
||||
UidImageMap *uid_image_map = nullptr;
|
||||
KeyImageMap *key_image_map = nullptr;
|
||||
|
||||
NodeMap node_map;
|
||||
bNodeTree *ntree;
|
||||
|
||||
|
@ -34,12 +34,6 @@ extern "C" {
|
||||
#include "SceneExporter.h"
|
||||
#include "collada_utils.h"
|
||||
|
||||
SceneExporter::SceneExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, ArmatureExporter *arm, const ExportSettings *export_settings):
|
||||
blender_context(blender_context),
|
||||
COLLADASW::LibraryVisualScenes(sw), arm_exporter(arm), export_settings(export_settings)
|
||||
{
|
||||
}
|
||||
|
||||
void SceneExporter::exportScene()
|
||||
{
|
||||
ViewLayer *view_layer = blender_context.get_view_layer();
|
||||
|
@ -94,18 +94,26 @@ extern "C" {
|
||||
class SceneExporter: COLLADASW::LibraryVisualScenes, protected TransformWriter, protected InstanceWriter
|
||||
{
|
||||
public:
|
||||
SceneExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, ArmatureExporter *arm, const ExportSettings *export_settings);
|
||||
|
||||
SceneExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, ArmatureExporter *arm, const ExportSettings *export_settings) :
|
||||
COLLADASW::LibraryVisualScenes(sw),
|
||||
blender_context(blender_context),
|
||||
arm_exporter(arm),
|
||||
export_settings(export_settings)
|
||||
{}
|
||||
|
||||
void exportScene();
|
||||
|
||||
private:
|
||||
friend class ArmatureExporter;
|
||||
BlenderContext &blender_context;
|
||||
friend class ArmatureExporter;
|
||||
ArmatureExporter *arm_exporter;
|
||||
const ExportSettings *export_settings;
|
||||
|
||||
void exportHierarchy();
|
||||
void writeNodeList(std::vector<Object *> &child_objects, Object *parent);
|
||||
void writeNodes(Object *ob);
|
||||
|
||||
ArmatureExporter *arm_exporter;
|
||||
const ExportSettings *export_settings;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -73,11 +73,9 @@ public:
|
||||
|
||||
// TODO need also for angle conversion, time conversion...
|
||||
|
||||
void dae_matrix_to_mat4_(float out[4][4], const COLLADABU::Math::Matrix4& in);
|
||||
|
||||
void mat4_to_dae(float out[4][4], float in[4][4]);
|
||||
|
||||
void mat4_to_dae_double(double out[4][4], float in[4][4]);
|
||||
static void dae_matrix_to_mat4_(float out[4][4], const COLLADABU::Math::Matrix4& in);
|
||||
static void mat4_to_dae(float out[4][4], float in[4][4]);
|
||||
static void mat4_to_dae_double(double out[4][4], float in[4][4]);
|
||||
|
||||
float(&get_rotation())[4][4];
|
||||
float(&get_scale())[4][4];
|
||||
|
Loading…
Reference in New Issue
Block a user