Skip to content

Commit

Permalink
Initialise all by default
Browse files Browse the repository at this point in the history
  • Loading branch information
RevoluPowered committed Jun 11, 2020
1 parent df8193b commit 8e4a96d
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 47 deletions.
14 changes: 7 additions & 7 deletions modules/fbx_importer/data/fbx_bone.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ struct FBXNode;
struct FBXBone;

struct FBXBone : Reference {
uint64_t parent_bone_id;
uint64_t bone_id;
uint64_t parent_bone_id = 0;
uint64_t bone_id = 0;

bool valid_parent = false; // if the parent bone id is set up.
String bone_name; // bone name
String bone_name = String(); // bone name

bool is_root_bone() const {
return !valid_parent;
Expand Down Expand Up @@ -86,11 +86,11 @@ struct FBXBone : Reference {
}

// pose node / if assigned
Transform pose_node;
Transform pose_node = Transform();
bool assigned_pose_node = false;
Ref<FBXBone> parent_bone;
Ref<PivotTransform> pivot_xform;
Ref<FBXSkeleton> fbx_skeleton;
Ref<FBXBone> parent_bone = Ref<FBXBone>();
Ref<PivotTransform> pivot_xform = Ref<PivotTransform>();
Ref<FBXSkeleton> fbx_skeleton = Ref<FBXSkeleton>();
};

#endif // MODEL_ABSTRACTION_FBX_BONE_H
16 changes: 8 additions & 8 deletions modules/fbx_importer/data/fbx_mesh_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ struct FBXMeshVertexData;
struct FBXBone;

struct FBXSplitBySurfaceVertexMapping {
Vector<size_t> vertex_id;
Vector<Vector2> uv_0, uv_1;
Vector<Vector3> normals;
Vector<Color> colors;
Vector<size_t> vertex_id = Vector<size_t>();
Vector<Vector2> uv_0, uv_1 = Vector<Vector2>();
Vector<Vector3> normals = Vector<Vector3>();
Vector<Color> colors = Vector<Color>();

void add_uv_0(Vector2 vec) {
vec.y = 1.0f - vec.y;
Expand Down Expand Up @@ -142,8 +142,8 @@ struct FBXSplitBySurfaceVertexMapping {
};

struct VertexMapping : Reference {
Vector<float> weights;
Vector<Ref<FBXBone> > bones;
Vector<float> weights = Vector<float>();
Vector<Ref<FBXBone> > bones = Vector<Ref<FBXBone> >();

/*** Will only add a vertex weight if it has been validated that it exists in godot **/
void GetValidatedBoneWeightInfo(Vector<int> &out_bones, Vector<float> &out_weights);
Expand Down Expand Up @@ -193,8 +193,8 @@ struct FBXMeshVertexData : Reference {
/* mesh maximum weight count */
bool valid_weight_count = false;
int max_weight_count = 0;
uint64_t mesh_id; // fbx mesh id
uint64_t armature_id;
uint64_t mesh_id = 0; // fbx mesh id
uint64_t armature_id = 0;
bool valid_armature_id = false;
MeshInstance *godot_mesh_instance = nullptr;
};
Expand Down
12 changes: 7 additions & 5 deletions modules/fbx_importer/data/fbx_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ struct FBXSkeleton;
struct PivotTransform;

struct FBXNode : Reference, ModelAbstraction {
uint64_t current_node_id;
String node_name;
uint64_t current_node_id = 0;
String node_name = String();
Spatial *godot_node = nullptr;
Ref<FBXSkeleton> skeleton_node; // used to parent the skeleton once the tree is built.

// used to parent the skeleton once the tree is built.
Ref<FBXSkeleton> skeleton_node = Ref<FBXSkeleton>();

void set_parent(Ref<FBXNode> p_parent) {
fbx_parent = p_parent;
Expand All @@ -66,8 +68,8 @@ struct FBXNode : Reference, ModelAbstraction {
pivot_transform = p_pivot_transform;
}

Ref<PivotTransform> pivot_transform; // local and global xform data
Ref<FBXNode> fbx_parent; // parent node
Ref<PivotTransform> pivot_transform = Ref<PivotTransform>(); // local and global xform data
Ref<FBXNode> fbx_parent = Ref<FBXNode>(); // parent node
};

#endif // MODEL_ABSTRACTION_FBX_NODE_H
4 changes: 2 additions & 2 deletions modules/fbx_importer/data/fbx_skeleton.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ struct ImportState;
struct FBXBone;

struct FBXSkeleton : Reference, ModelAbstraction {
Ref<FBXNode> fbx_node;
Vector<Ref<FBXBone> > skeleton_bones;
Ref<FBXNode> fbx_node = Ref<FBXNode>();
Vector<Ref<FBXBone> > skeleton_bones = Vector<Ref<FBXBone> >();
Skeleton *skeleton = nullptr;

void init_skeleton(const ImportState &state);
Expand Down
18 changes: 9 additions & 9 deletions modules/fbx_importer/data/import_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ struct FBXNode;
struct FBXSkeleton;

struct ImportState {
String path;
String path = String();
Spatial *root = nullptr;
Ref<FBXNode> fbx_root_node;
Ref<FBXNode> fbx_root_node = Ref<FBXNode>();
// skeleton map - merged automatically when they are on the same x node in the tree so we can merge them automatically.
Map<uint64_t, Ref<FBXSkeleton> > skeleton_map;
Map<uint64_t, Ref<FBXSkeleton> > skeleton_map = Map<uint64_t, Ref<FBXSkeleton> >();

// nodes on the same level get merged automatically.
//Map<uint64_t, Skeleton *> armature_map;
Expand All @@ -74,30 +74,30 @@ struct ImportState {
// Generation 4 - Raw document accessing for bone/skin/joint/kLocators
// joints are not necessarily bones but must be merged into the skeleton
// (bone id), bone
Map<uint64_t, Ref<FBXBone> > fbx_bone_map; // this is the bone name and setup information required for joints
Map<uint64_t, Ref<FBXBone> > fbx_bone_map = Map<uint64_t, Ref<FBXBone> >(); // this is the bone name and setup information required for joints
// this will never contain joints only bones attached to a mesh.

// Generation 4 - Raw document for creating the nodes transforms in the scene
// this is a list of the nodes in the scene
// (id, node)
List<Ref<FBXNode> > fbx_node_list;
List<Ref<FBXNode> > fbx_node_list = List<Ref<FBXNode> >();

// All nodes which have been created in the scene
// this will not contain the root node of the scene
Map<uint64_t, Ref<FBXNode> > fbx_target_map;
Map<uint64_t, Ref<FBXNode> > fbx_target_map = Map<uint64_t, Ref<FBXNode> >();

// mesh nodes which are created in node / mesh step - used for populating skin poses in MeshSkins
Map<uint64_t, Ref<FBXNode> > MeshNodes;
Map<uint64_t, Ref<FBXNode> > MeshNodes = Map<uint64_t, Ref<FBXNode> >();
// mesh skin map
Map<uint64_t, Ref<Skin> > MeshSkins;
Map<uint64_t, Ref<Skin> > MeshSkins = Map<uint64_t, Ref<Skin> >();

// this is the container for the mesh weight information and eventually
// any mesh data
// but not the skin, just stuff important for rendering
// skin is applied to mesh instance so not really required to be in here yet.
// maybe later
// fbx mesh id, FBXMeshData
Map<uint64_t, Ref<FBXMeshVertexData> > renderer_mesh_data;
Map<uint64_t, Ref<FBXMeshVertexData> > renderer_mesh_data = Map<uint64_t, Ref<FBXMeshVertexData> >();
};

#endif // EDITOR_SCENE_IMPORT_STATE_H
18 changes: 9 additions & 9 deletions modules/fbx_importer/data/pivot_transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ struct PivotTransform : Reference, ModelAbstraction {

// at the end we want to keep geometric_ everything, post and pre rotation
// these are used during animation data processing / keyframe ingestion the rest can be simplified down / out.
Quat pre_rotation, post_rotation, rotation, geometric_rotation;
Vector3 rotation_pivot, rotation_offset, scaling_offset, scaling_pivot, translation, scaling, geometric_scaling, geometric_translation;
Vector3 raw_rotation, raw_post_rotation, raw_pre_rotation;
Quat pre_rotation = Quat(), post_rotation = Quat(), rotation = Quat(), geometric_rotation = Quat();
Vector3 rotation_pivot = Vector3(), rotation_offset = Vector3(), scaling_offset = Vector3(), scaling_pivot = Vector3(), translation = Vector3(), scaling = Vector3(), geometric_scaling = Vector3(), geometric_translation = Vector3();
Vector3 raw_rotation = Vector3(), raw_post_rotation = Vector3(), raw_pre_rotation = Vector3();
/* Read pivots from the document */
void ReadTransformChain();

Expand All @@ -82,15 +82,15 @@ struct PivotTransform : Reference, ModelAbstraction {
parent_transform = p_parent;
}
bool computed_global_xform = false;
Ref<PivotTransform> parent_transform;
Ref<PivotTransform> parent_transform = Ref<PivotTransform>();
//Transform chain[TransformationComp_MAXIMUM];

// cached for later use
Transform GlobalTransform;
Transform LocalTransform;
Transform Local_Scaling_Matrix; // used for inherit type.
Transform GeometricTransform; // 3DS max only
Assimp::FBX::TransformInheritance inherit_type; // maya fbx requires this - sorry <3
Transform GlobalTransform = Transform();
Transform LocalTransform = Transform();
Transform Local_Scaling_Matrix = Transform(); // used for inherit type.
Transform GeometricTransform = Transform(); // 3DS max only
Assimp::FBX::TransformInheritance inherit_type = Assimp::FBX::TransformInheritance_MAX; // maya fbx requires this - sorry <3
};

#endif // MODEL_ABSTRACTION_PIVOT_TRANSFORM_H
9 changes: 2 additions & 7 deletions modules/fbx_importer/editor_scene_importer_fbx.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ class EditorSceneImporterFBX : public EditorSceneImporter {
};
};

struct BoneInfo {
Vector<int> bone_id;
Vector<float> weights;
};

// ------------------------------------------------------------------------------------------------
template <typename T>
const T *ProcessDOMConnection(
Expand Down Expand Up @@ -179,8 +174,8 @@ class EditorSceneImporterFBX : public EditorSceneImporter {
void _register_project_setting_import(const String generic, const String import_setting_string, const Vector<String> &exts, List<String> *r_extensions, const bool p_enabled) const;

struct ImportFormat {
Vector<String> extensions;
bool is_default;
Vector<String> extensions = Vector<String>();
bool is_default = false;
};

protected:
Expand Down

0 comments on commit 8e4a96d

Please sign in to comment.