Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FBX Importer Rewrite [4.0, wip] #41985

Conversation

RevoluPowered
Copy link
Contributor

@RevoluPowered RevoluPowered commented Sep 11, 2020

Co-authored-by: Gordon MacPherson gordon@gordonite.tech
Co-authored-by: Andrea Catania info@andreacatania.com
Co-authored-by: K. S. Ernest (iFire) Lee ernest.lee@chibifire.com

This is a complete rewrite of the importer. It will give more deterministic behaviour and has been sponsored by IMVU inc, over 1 year has gone into the development of this importer to remove the burden of the FBX SDK.

This was my project for 1 entire year and I really enjoyed the opportunity to add to Godot.

Along the road of implementing fixes we implemented fbx pivots, animations and inheritance type handling, which in most cases works properly.

We have implemented animation and mesh skinning too this should work out of the box, if there are issues let us know.

It's designed so that you can expand this with ease, and fix bugs easily too.

It can import from Autodesk Maya and import into Godot, with pivots.

There are bits we could polish but for now this is good enough.

This was sponsored by IMVU, and a special thanks to everyone who supported this project.

Signed-off-by: Gordon MacPherson gordon@gordonite.tech

Additional fixes made before upstreaming:

  • fixed memory leak
  • ensure consistent ordering on mac linux and windows for fbx tree. (very important for material import to be deterministic)
  • disabled incorrect warnings for fbx_material
  • added compatibility code for /RootNode/ so compat is not broken
  • Optimise FBX - directly import triangles
  • remove debug messages
  • add messages for mesh id, mesh re-import is sometimes slow and we need to know what mesh is being worked on
  • correct culling settings on materials
  • Document no longer uses unordered maps
  • Removed some usages of &GetRequiredToken replaced with safe *GetRequiredToken() function
  • Added parser debugging
  • Added ERR_FAIL_CONDS for unsupported mesh formats (we can add these later super easy to do now)
  • Add memory debugging for the Tokens and the TokenParser to make it safe
  • Add memory initialisation to mesh.cpp surface_tool.h and mesh.h
  • Initialize boolean flags properly
  • Refactored to correct naming for the fbx_mesh_data.h so you know what data you are working on
  • Disabled corruption caused by the FIXME:
  • Fixed document reading indexes and index_to_direct vs indexes mode
  • Fixed UV1 and UV2 coordinates
  • Fixed importer failing to import version 7700 files
  • Replaced memory handling in the FBX Document with pointers, before it was dereferencing invalid memory.
  • Fixed typed properties
  • Improved Document API
  • Fixed bug with ProcessDOMConnection() not working with the bool flag set to true.
  • Fixed FBX skinning not deforming for more than one single mesh
  • Fixed FBX skeleton mapping and skin mapping not being applied properly (now retrieved from document skin list)
  • Fixed set_bone_pose being used in final version()
  • Fixed material properties exceeding 1.0.
  • FBX Document parser revamped to use safe memory practices, and with graceful error messages.
  • ScopePtr, TokenPtr and various internal types have been fleshed out to use proper typedefs across the codebase.
  • Fixed memory leaks caused by token cleanup failing (now explicit cleanup step, no shared_ptr, etc)
  • Fixed bug with PropertyTable not reading all properties and not cleaning up properly.

@RevoluPowered RevoluPowered changed the title FBX Importer Rewrite [4.0] FBX Importer Rewrite [4.0, wip] Sep 11, 2020
@akien-mga akien-mga added this to the 4.0 milestone Sep 11, 2020
@RevoluPowered
Copy link
Contributor Author

Sorry not had time to port this yet fully! Right now editor code needs ported, so been very busy, I will be away from Tuesday for two weeks, 29th of September 2020 to 6th of October.

I will submit all the patches we made over the past week too which should resolve all character related problems.

Co-authored-by: Gordon MacPherson <gordon@gordonite.tech>
Co-authored-by: Andrea Catania <info@andreacatania.com>
Co-authored-by: K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>

This is a complete rewrite of the importer. It will give more deterministic behaviour and has been sponsored by IMVU inc, over 1 year has gone into the development of this importer to remove the burden of the FBX SDK.

This was my project for 1 entire year and I really enjoyed the opportunity to add to Godot.

Along the road of implementing fixes we implemented fbx pivots, animations and inheritance type handling, which in most cases works properly.

We have implemented animation and mesh skinning too this should work out of the box, if there are issues let us know.

It's designed so that you can expand this with ease, and fix bugs easily too.

It can import from Autodesk Maya and import into Godot, with pivots.

There are bits we could polish but for now this is good enough.

This was sponsored by IMVU, and a special thanks to everyone who supported this project.

Signed-off-by: Gordon MacPherson <gordon@gordonite.tech>

Additional fixes made before upstreaming:
- fixed memory leak
- ensure consistent ordering on mac linux and windows for fbx tree. (very important for material import to be deterministic)
- disabled incorrect warnings for fbx_material
- added compatibility code for /RootNode/ so compat is not broken
- Optimise FBX - directly import triangles
- remove debug messages
- add messages for mesh id, mesh re-import is sometimes slow and we need to know what mesh is being worked on
- correct culling settings on materials

fix importer failing to import 7700 files, and correct args for version

also fixed some cleanup notes
working uv2?

Fix UV2 coordinates and various problems with FBX
- Document no longer uses unordered maps
- Removed some usages of &GetRequiredToken replaced with safe *GetRequiredToken() function
- Added parser debugging
- Added ERR_FAIL_CONDS for unsupported mesh formats (we can add these later super easy to do now)
- Add memory debugging for the Tokens and the TokenParser to make it safe
- Add memory initialisation to mesh.cpp surface_tool.h and mesh.h
- Initialize boolean flags properly
- Refactored to correct naming for the fbx_mesh_data.h so you know what data you are working on
- Disabled corruption caused by the FIXME:
- Fixed document reading indexes and index_to_direct vs indexes mode
- Fixed UV1 and UV2 coordinates
- Fixed importer failing to import version 7700 files
- Replaced memory handling in the FBX Document with pointers, before it was dereferencing invalid memory.
- Fixed typed properties
- Improved Document API
- Fixed bug with ProcessDOMConnection() not working with the bool flag set to true.
- Fixed FBX skinning not deforming for more than one single mesh
- Fixed FBX skeleton mapping and skin mapping not being applied properly (now retrieved from document skin list)
- Fixed set_bone_pose being used in final version()
- Fixed material properties exceeding 1.0.
- FBX Document parser revamped to use safe memory practices, and with graceful error messages.
- ScopePtr, TokenPtr and various internal types have been fleshed out to use proper typedefs across the codebase.
- Fixed memory leaks caused by token cleanup failing (now explicit cleanup step, no shared_ptr, etc)
- Fixed bug with PropertyTable not reading all properties and not cleaning up properly.
@RevoluPowered RevoluPowered force-pushed the fbx-rewrite-parser-and-enhanced-skinning-4.0 branch from c7602fc to 860f5cf Compare October 5, 2020 12:11
@RevoluPowered
Copy link
Contributor Author

RevoluPowered commented Oct 5, 2020

OK so 'it builds' but it's not quite working properly yet for 4.0, you should use the 3.2 importer if you're wanting to evaluate this.

Things broken compared to the 3.2 branch:

  • Port Unit Tests from 3.2 tests to DOCTEST
  • Materials are black (i guess a rewrite is in order of the flag mapping code)
  • Bone orientation changes incorrectly when compared to the working 3.2 one... I think a regression in the keyframe handler in the importer which differs / EulerToQuaternion
  • Mesh code crashes in some cases with complex models (but not in 3.2 relating to bone aabb but can't share the model since it's commercial)
  • Skin is scaled up 100 times on some bones / bug

Animations working for example: but again had to workaround the skin difference in the 3.2 vs 4.0 importer.
https://www.youtube.com/watch?v=4LY1qSNNmsg

@RevoluPowered
Copy link
Contributor Author

RevoluPowered commented Dec 18, 2020

Superseded by #44499

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants