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:
|
public:
|
||||||
|
|
||||||
AnimationClipExporter(Depsgraph *depsgraph , COLLADASW::StreamWriter *sw, const ExportSettings *export_settings, std::vector<std::vector<std::string>> anim_meta) :
|
AnimationClipExporter(Depsgraph *depsgraph , COLLADASW::StreamWriter *sw, const ExportSettings *export_settings, std::vector<std::vector<std::string>> anim_meta) :
|
||||||
depsgraph(depsgraph),
|
|
||||||
COLLADASW::LibraryAnimationClips(sw),
|
COLLADASW::LibraryAnimationClips(sw),
|
||||||
|
depsgraph(depsgraph),
|
||||||
|
scene(nullptr),
|
||||||
|
sw(sw),
|
||||||
export_settings(export_settings),
|
export_settings(export_settings),
|
||||||
anim_meta(anim_meta)
|
anim_meta(anim_meta)
|
||||||
{
|
{}
|
||||||
this->sw = sw;
|
|
||||||
}
|
|
||||||
|
|
||||||
void exportAnimationClips(Scene *sce);
|
void exportAnimationClips(Scene *sce);
|
||||||
};
|
};
|
||||||
|
@ -98,16 +98,16 @@ class AnimationExporter: COLLADASW::LibraryAnimations
|
|||||||
private:
|
private:
|
||||||
BlenderContext &blender_context;
|
BlenderContext &blender_context;
|
||||||
COLLADASW::StreamWriter *sw;
|
COLLADASW::StreamWriter *sw;
|
||||||
|
const ExportSettings *export_settings;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AnimationExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings):
|
AnimationExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings):
|
||||||
blender_context(blender_context),
|
|
||||||
COLLADASW::LibraryAnimations(sw),
|
COLLADASW::LibraryAnimations(sw),
|
||||||
|
blender_context(blender_context),
|
||||||
|
sw(sw),
|
||||||
export_settings(export_settings)
|
export_settings(export_settings)
|
||||||
{
|
{}
|
||||||
this->sw = sw;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool exportAnimations();
|
bool exportAnimations();
|
||||||
|
|
||||||
@ -115,7 +115,6 @@ public:
|
|||||||
void operator() (Object *ob);
|
void operator() (Object *ob);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const ExportSettings *export_settings;
|
|
||||||
|
|
||||||
void export_object_constraint_animation(Object *ob);
|
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()
|
AnimationImporter::~AnimationImporter()
|
||||||
{
|
{
|
||||||
// free unused FCurves
|
// free unused FCurves
|
||||||
|
@ -139,7 +139,11 @@ private:
|
|||||||
};
|
};
|
||||||
public:
|
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();
|
~AnimationImporter();
|
||||||
|
|
||||||
|
@ -53,15 +53,6 @@ extern "C" {
|
|||||||
|
|
||||||
#include "collada_utils.h"
|
#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
|
// write bone nodes
|
||||||
void ArmatureExporter::add_armature_bones(
|
void ArmatureExporter::add_armature_bones(
|
||||||
Object *ob_arm,
|
Object *ob_arm,
|
||||||
|
@ -57,7 +57,15 @@ class SceneExporter;
|
|||||||
class ArmatureExporter : public COLLADASW::LibraryControllers, protected TransformWriter, protected InstanceWriter
|
class ArmatureExporter : public COLLADASW::LibraryControllers, protected TransformWriter, protected InstanceWriter
|
||||||
{
|
{
|
||||||
public:
|
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(
|
void add_armature_bones(
|
||||||
Object *ob_arm,
|
Object *ob_arm,
|
||||||
@ -68,9 +76,8 @@ public:
|
|||||||
bool add_instance_controller(Object *ob);
|
bool add_instance_controller(Object *ob);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UnitConverter converter;
|
|
||||||
const ExportSettings *export_settings;
|
|
||||||
BlenderContext &blender_context;
|
BlenderContext &blender_context;
|
||||||
|
const ExportSettings *export_settings;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
std::vector<Object *> written_armatures;
|
std::vector<Object *> written_armatures;
|
||||||
|
@ -55,13 +55,6 @@ extern "C" {
|
|||||||
|
|
||||||
#include "collada_utils.h"
|
#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)
|
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)
|
void ControllerExporter::add_bind_shape_mat(Object *ob)
|
||||||
{
|
{
|
||||||
double bind_mat[4][4];
|
double bind_mat[4][4];
|
||||||
|
UnitConverter::mat4_to_dae_double(bind_mat, ob->obmat);
|
||||||
converter.mat4_to_dae_double(bind_mat, ob->obmat);
|
|
||||||
|
|
||||||
addBindShapeTransform(bind_mat);
|
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);
|
mul_m4_m4m4(world, ob_arm->obmat, bind_mat);
|
||||||
|
|
||||||
invert_m4_m4(mat, world);
|
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)
|
if (this->export_settings->limit_precision)
|
||||||
bc_sanitize_mat(inv_bind_mat, 6);
|
bc_sanitize_mat(inv_bind_mat, 6);
|
||||||
source.appendValues(inv_bind_mat);
|
source.appendValues(inv_bind_mat);
|
||||||
|
@ -60,7 +60,14 @@ class SceneExporter;
|
|||||||
class ControllerExporter : public COLLADASW::LibraryControllers, protected TransformWriter, protected InstanceWriter
|
class ControllerExporter : public COLLADASW::LibraryControllers, protected TransformWriter, protected InstanceWriter
|
||||||
{
|
{
|
||||||
public:
|
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);
|
bool is_skinned_mesh(Object *ob);
|
||||||
|
|
||||||
@ -72,7 +79,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
BlenderContext &blender_context;
|
BlenderContext &blender_context;
|
||||||
UnitConverter converter;
|
|
||||||
const ExportSettings *export_settings;
|
const ExportSettings *export_settings;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -50,12 +50,6 @@ extern "C" {
|
|||||||
#include "collada_internal.h"
|
#include "collada_internal.h"
|
||||||
#include "collada_utils.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()
|
void GeometryExporter::exportGeom()
|
||||||
{
|
{
|
||||||
|
@ -75,7 +75,13 @@ class GeometryExporter : COLLADASW::LibraryGeometries
|
|||||||
Normal n;
|
Normal n;
|
||||||
|
|
||||||
public:
|
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();
|
void exportGeom();
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
MaterialNode::MaterialNode(bContext *C, Material *ma, KeyImageMap &key_image_map) :
|
MaterialNode::MaterialNode(bContext *C, Material *ma, KeyImageMap &key_image_map) :
|
||||||
mContext(C),
|
mContext(C),
|
||||||
effect(nullptr),
|
|
||||||
material(ma),
|
material(ma),
|
||||||
|
effect(nullptr),
|
||||||
key_image_map(&key_image_map)
|
key_image_map(&key_image_map)
|
||||||
{
|
{
|
||||||
ntree = prepare_material_nodetree();
|
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) :
|
MaterialNode::MaterialNode(bContext *C, COLLADAFW::EffectCommon *ef, Material *ma, UidImageMap &uid_image_map) :
|
||||||
mContext(C),
|
mContext(C),
|
||||||
effect(ef),
|
|
||||||
material(ma),
|
material(ma),
|
||||||
|
effect(ef),
|
||||||
uid_image_map(&uid_image_map)
|
uid_image_map(&uid_image_map)
|
||||||
{
|
{
|
||||||
ntree = prepare_material_nodetree();
|
ntree = prepare_material_nodetree();
|
||||||
|
@ -53,6 +53,7 @@ private:
|
|||||||
COLLADAFW::EffectCommon *effect;
|
COLLADAFW::EffectCommon *effect;
|
||||||
UidImageMap *uid_image_map = nullptr;
|
UidImageMap *uid_image_map = nullptr;
|
||||||
KeyImageMap *key_image_map = nullptr;
|
KeyImageMap *key_image_map = nullptr;
|
||||||
|
|
||||||
NodeMap node_map;
|
NodeMap node_map;
|
||||||
bNodeTree *ntree;
|
bNodeTree *ntree;
|
||||||
|
|
||||||
|
@ -34,12 +34,6 @@ extern "C" {
|
|||||||
#include "SceneExporter.h"
|
#include "SceneExporter.h"
|
||||||
#include "collada_utils.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()
|
void SceneExporter::exportScene()
|
||||||
{
|
{
|
||||||
ViewLayer *view_layer = blender_context.get_view_layer();
|
ViewLayer *view_layer = blender_context.get_view_layer();
|
||||||
|
@ -94,18 +94,26 @@ extern "C" {
|
|||||||
class SceneExporter: COLLADASW::LibraryVisualScenes, protected TransformWriter, protected InstanceWriter
|
class SceneExporter: COLLADASW::LibraryVisualScenes, protected TransformWriter, protected InstanceWriter
|
||||||
{
|
{
|
||||||
public:
|
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();
|
void exportScene();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class ArmatureExporter;
|
|
||||||
BlenderContext &blender_context;
|
BlenderContext &blender_context;
|
||||||
|
friend class ArmatureExporter;
|
||||||
|
ArmatureExporter *arm_exporter;
|
||||||
|
const ExportSettings *export_settings;
|
||||||
|
|
||||||
void exportHierarchy();
|
void exportHierarchy();
|
||||||
void writeNodeList(std::vector<Object *> &child_objects, Object *parent);
|
void writeNodeList(std::vector<Object *> &child_objects, Object *parent);
|
||||||
void writeNodes(Object *ob);
|
void writeNodes(Object *ob);
|
||||||
|
|
||||||
ArmatureExporter *arm_exporter;
|
|
||||||
const ExportSettings *export_settings;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -73,11 +73,9 @@ public:
|
|||||||
|
|
||||||
// TODO need also for angle conversion, time conversion...
|
// TODO need also for angle conversion, time conversion...
|
||||||
|
|
||||||
void dae_matrix_to_mat4_(float out[4][4], const COLLADABU::Math::Matrix4& in);
|
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]);
|
||||||
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]);
|
||||||
|
|
||||||
void mat4_to_dae_double(double out[4][4], float in[4][4]);
|
|
||||||
|
|
||||||
float(&get_rotation())[4][4];
|
float(&get_rotation())[4][4];
|
||||||
float(&get_scale())[4][4];
|
float(&get_scale())[4][4];
|
||||||
|
Loading…
Reference in New Issue
Block a user