summaryrefslogtreecommitdiff
path: root/modules/assimp/import_state.h
diff options
context:
space:
mode:
Diffstat (limited to 'modules/assimp/import_state.h')
-rw-r--r--modules/assimp/import_state.h53
1 files changed, 34 insertions, 19 deletions
diff --git a/modules/assimp/import_state.h b/modules/assimp/import_state.h
index 56d89ffea7..9859a88c1c 100644
--- a/modules/assimp/import_state.h
+++ b/modules/assimp/import_state.h
@@ -52,28 +52,42 @@
namespace AssimpImporter {
/** Import state is for global scene import data
- * This makes the code simpler and contains useful lookups.
- */
+ * This makes the code simpler and contains useful lookups.
+ */
struct ImportState {
String path;
+ Spatial *root;
const aiScene *assimp_scene;
uint32_t max_bone_weights;
- Spatial *root;
Map<String, Ref<Mesh> > mesh_cache;
Map<int, Ref<Material> > material_cache;
Map<String, int> light_cache;
Map<String, int> camera_cache;
- //Vector<Skeleton *> skeletons;
- Map<Skeleton *, const Spatial *> armature_skeletons; // maps skeletons based on their armature nodes.
- Map<const aiBone *, Skeleton *> bone_to_skeleton_lookup; // maps bones back into their skeleton
+
// very useful for when you need to ask assimp for the bone mesh
- Map<String, Node *> node_map;
- Map<const aiNode *, const Node *> assimp_node_map;
+
+ Map<const aiNode *, Node *> assimp_node_map;
Map<String, Ref<Image> > path_to_image_cache;
- bool fbx; //for some reason assimp does some things different for FBX
+
+ // Generation 3 - determinisitic iteration
+ // to lower potential recursion errors
+ List<const aiNode *> nodes;
+ Map<const aiNode *, Spatial *> flat_node_map;
AnimationPlayer *animation_player;
+
+ // Generation 3 - deterministic armatures
+ // list of armature nodes - flat and simple to parse
+ // assimp node, node in godot
+ List<aiNode *> armature_nodes;
+ Map<const aiNode *, Skeleton *> armature_skeletons;
+ Map<aiBone *, Skeleton *> skeleton_bone_map;
+ // Generation 3 - deterministic bone handling
+ // bones from the stack are popped when found
+ // this means we can detect
+ // what bones are for other armatures
+ List<aiBone *> bone_stack;
};
struct AssimpImageData {
@@ -86,14 +100,15 @@ struct AssimpImageData {
* This makes the code easier to handle too and add extra arguments without breaking things
*/
struct RecursiveState {
+ RecursiveState() {} // do not construct :)
RecursiveState(
Transform &_node_transform,
Skeleton *_skeleton,
Spatial *_new_node,
- const String &_node_name,
- const aiNode *_assimp_node,
+ String &_node_name,
+ aiNode *_assimp_node,
Node *_parent_node,
- const aiBone *_bone) :
+ aiBone *_bone) :
node_transform(_node_transform),
skeleton(_skeleton),
new_node(_new_node),
@@ -102,13 +117,13 @@ struct RecursiveState {
parent_node(_parent_node),
bone(_bone) {}
- Transform &node_transform;
- Skeleton *skeleton;
- Spatial *new_node;
- const String &node_name;
- const aiNode *assimp_node;
- Node *parent_node;
- const aiBone *bone;
+ Transform node_transform;
+ Skeleton *skeleton = NULL;
+ Spatial *new_node = NULL;
+ String node_name;
+ aiNode *assimp_node = NULL;
+ Node *parent_node = NULL;
+ aiBone *bone = NULL;
};
} // namespace AssimpImporter