virtualx-engine/thirdparty
Gordon MacPherson 8197a611fa Rewrite FBX Importer to convert directly to Godot scene format
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.

Additional fixes made before upstreaming:
- fixed memory leaks
- 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
- 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
- Initialise 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.
- Fixed smoothing groups not working
- Fixed normal duplications
- Fixed duplication check for pre-existing coordinates.
- Fixed performance of vertex lookup in large meshes being slow, using lookup table separate to the data for indexing, this reduces import time from 10 minutes of bistro down to 30 seconds.
- Fixed includes requiring absolute path in headers and cpp files using CPPPath.

Bugs/Features wish list:
- locator bones
- quat anim key interpolation (most fbx maya files have euler rotations from blender and maya, nobody uses this)
- some rigs skins scale up when SSC enabled inconsistently per bone
- some skins can disappear entirely
- material mapping needs expanded, but this will be done for 4.0 as it requires rewrite.

Workarounds for issues found until we patch them:
- mesh -> clear skin can resolve most of the bugs above.
- locators can be worked around by removing them before exporting your rig.
- some material properties wont always import, this is okay to override in the material properties.

**If you are having issues or need support fear not!**
Please provide minimal rigs which can reproduce issues as we can't spend a lot of time investigating each rig. We need a small example which breaks and we can then sort the problem. In some cases this is not possible so its okay to privately send models to us via IRC or a ticket and we can provide an email address, we won't reveal or disclose privately sent rig files to any companies, or to companies I work for, they will not be shared, only tested and bugs will be drawn up from the conclusions. Also include identifying information about what you did and how it didn't work. Please file each file separately in a bug report, unless the problem is the same.
This was sponsored by IMVU, and a special thanks to everyone who supported this project.

Signed-off-by: Gordon MacPherson <gordon@gordonite.tech>
2020-10-30 15:59:19 +00:00
..
bullet Apply old method for linear & angular damping in Bullet, in order to 2020-05-27 17:53:43 +01:00
certs certs: Sync with latest ca-certificates-2018.2.26-2.fc29 2018-12-20 13:04:39 +01:00
cvtt Git: Explicitly list binary files as such to avoid EOL change 2019-05-25 10:43:48 +02:00
enet Reorganize ENet pactches. 2020-07-15 12:48:18 +02:00
etc2comp etc2comp: Fix max iterations for RGBA channels 2020-04-16 12:02:34 +02:00
fonts Add Hindi font for editor 2018-08-30 05:11:09 +09:00
freetype freetype: Update to upstream version 2.10.2 2020-05-11 11:12:39 +02:00
glad glad: Sync with upstream 0.1.33 2019-11-12 08:45:51 +01:00
jpeg-compressor Remove no longer needed patches to jpgd.cpp 2020-05-19 10:19:52 +02:00
libogg Update libogg to upstream c8fca6b 2019-10-30 19:03:26 -05:00
libpng libpng: Update to upstream 1.6.37 2019-04-26 10:37:22 +02:00
libsimplewebm Sync libsimplewebm with fe57fd3 (but not the libwebm sub-lib) 2019-02-21 20:43:41 +00:00
libtheora theora: Add upstream patch to fix UB warning 2019-01-23 12:02:36 +01:00
libvorbis Update libvorbis to 1.3.6 2018-05-24 13:52:05 -03:00
libvpx Disable all use of avx instructions 2019-02-24 23:03:48 +01:00
libwebp Update libwebp to 1.1.0 2020-01-17 03:49:31 +09:00
mbedtls Update mbedTLS to version 2.16.8 (+ patch). 2020-09-08 08:56:33 +02:00
miniupnpc miniupnpc: Sync with upstream master (4436632) 2020-03-06 23:54:24 +01:00
minizip Update minizip to 1.2.11 2018-05-16 01:58:34 +09:00
misc stb_vorbis: Update to upstream version 1.20 2020-07-24 10:31:57 +02:00
nanosvg nanosvg: Sync with upstream c1f6e20 2019-11-12 09:12:11 +01:00
opus Revert "Update opus to 1.3.1 and opusfile to 0.11" 2019-11-18 09:56:48 +01:00
pcre2 pcre2: Update to upstream version 10.34 2020-05-01 11:01:57 +02:00
pvrtccompressor Make core/ includes absolute, remove subfolders from include path 2018-09-12 09:52:22 +02:00
recastnavigation Recast: Update to upstream commit 57610fa (2019) 2020-05-01 11:02:29 +02:00
squish Fix GLES2 Red Green Texture Decompression 2018-11-27 20:45:28 +01:00
tinyexr tinyexr: Sync with upstream 1.0.0 2020-09-24 14:43:11 +02:00
vhacd Fix scale calculation in VHACD Volume::Voxelize(). 2020-05-06 23:31:18 +02:00
wslay Update to wslay 1.1.1 . 2020-07-03 15:34:30 +02:00
xatlas xatlas: Sync with upstream 470576d 2020-06-04 11:15:06 +02:00
zlib
zstd zstd: Update to upstream version 1.4.5 2020-09-24 14:43:11 +02:00
README.md Rewrite FBX Importer to convert directly to Godot scene format 2020-10-30 15:59:19 +00:00

Third party libraries

bullet

Files extracted from upstream source:

  • src/* apart from CMakeLists.txt and premake4.lua files
  • LICENSE.txt

certs

File extracted from a recent Fedora install: /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem (It can't be extracted directly from the package, as it's generated on the user's system.)

cvtt

Files extracted from upstream source:

  • all .cpp, .h, and .txt files in ConvectionKernels/

enet

  • Upstream: http://enet.bespin.org
  • Version: 1.3.15 (224f31101fc60939c02f6bbe8e8fc810a7db306b, 2020)
  • License: MIT

Files extracted from upstream source:

  • all .c files in the main directory (except unix.c win32.c)
  • the include/enet/ folder as enet/ (except unix.h win32.h)
  • LICENSE file

Important: enet.h, host.c, protocol.c have been slightly modified to be usable by godot socket implementation and allow IPv6 and DTLS. Apply the patches in the patches/ folder when syncing on newer upstream commits.

Two files (godot.cpp and enet/godot.h) have been added to provide enet socket implementation using Godot classes.

It is still possible to build against a system wide ENet but doing so will limit its functionality to IPv4 only.

etc2comp

Files extracted from upstream source:

  • all .cpp and .h files in EtcLib/
  • README.md, LICENSE, AUTHORS

Important: Some files have Godot-made changes. They are marked with // -- GODOT start -- and // -- GODOT end -- comments.

fonts

Noto Sans

Use UI font variant if available, because it has tight vertical metrics and good for UI.

Hack Regular

DroidSans*.ttf

freetype

Files extracted from upstream source:

  • the src/ folder, stripped of the Jamfile files and the tools subfolder
  • the include/ folder
  • docs/{FTL.TXT,LICENSE.TXT}

glad

The files we package are automatically generated. See the header of glad.c for instructions on how to generate them for the GLES version Godot targets.

jpeg-compressor

Files extracted from upstream source:

  • jpgd*.{c,h}

libogg

  • Upstream: https://www.xiph.org/ogg
  • Version: git (c8fca6b4a02d695b1ceea39b330d4406001c03ed, 2019)
  • License: BSD-3-Clause

Files extracted from upstream source:

  • src/*.{c,h}
  • include/ogg/*.h in ogg/
  • COPYING

libpng

Files extracted from upstream source:

  • all .c and .h files of the main directory, except from example.c and pngtest.c
  • the arm/ folder
  • scripts/pnglibconf.h.prebuilt as pnglibconf.h
  • LICENSE

libsimplewebm

This contains libwebm, but the version in use is updated from the one used by libsimplewebm, and may have unmarked alterations from that.

Files extracted from upstream source:

  • all the .cpp, .hpp files in the main folder except example.cpp
  • LICENSE

Important: Some files have Godot-made changes. They are marked with // -- GODOT start -- and // -- GODOT end -- comments.

libtheora

Files extracted from upstream source:

  • all .c, .h in lib/
  • all .h files in include/theora/ as theora/
  • COPYING and LICENSE

Upstream patches included in the patches directory have been applied on top of the 1.1.1 source (not included in any stable release yet).

libvorbis

Files extracted from upstream source:

  • src/* except from: lookups.pl, Makefile.*
  • include/vorbis/*.h as vorbis/
  • COPYING

libvpx

Files extracted from upstream source:

TODO.

Important: File libvpx/vpx_dsp/x86/vpx_subpixel_8t_intrin_avx2.c has Godot-made change marked with // -- GODOT -- comments.

The files libvpx/third_party/android/cpu-features.{c,h} were copied from the Android NDK r18.

libwebp

Files extracted from upstream source:

  • src/* except from: .am, .rc and .in files
  • AUTHORS, COPYING, PATENTS

Important: The files utils/bit_reader_utils.{c,h} have Godot-made changes to ensure they build for Javascript/HTML5. Those changes are marked with // -- GODOT -- comments.

mbedtls

File extracted from upstream release tarball:

  • All *.h from include/mbedtls/ to thirdparty/mbedtls/include/mbedtls/
  • All *.c from library/ to thirdparty/mbedtls/library/
  • LICENSE and apache-2.0.txt files
  • Applied the patch in thirdparty/mbedtls/patches/1453.diff (PR 1453). Soon to be merged upstream. Check it out at next update.
  • Applied the patch in thirdparty/mbedtls/patches/padlock.diff. This disables VIA padlock support which defines a symbol unsupported which clashes with a pre-defined symbol.
  • Added 2 files godot_core_mbedtls_platform.{c,h} providing configuration for light bundling with core.

miniupnpc

Files extracted from upstream source:

  • All *.c and *.h files from miniupnpc to thirdparty/miniupnpc/miniupnpc
  • Remove test*, minihttptestserver.c and wingenminiupnpcstrings.c

The patch windows_fix.diff is applied to minissdpc.c to fix an upstream issue. The only modified file is miniupnpcstrings.h, which was created for Godot (it is usually autogenerated by cmake).

minizip

Files extracted from the upstream source:

  • contrib/minizip/{crypt.h,ioapi.{c,h},zip.{c,h},unzip.{c,h}}

Important: Some files have Godot-made changes for use in core/io. They are marked with /* GODOT start */ and /* GODOT end */ comments and a patch is provided in the minizip/ folder.

misc

Collection of single-file libraries used in Godot components.

core

modules

platform

scene

nanosvg

Files extracted from the upstream source:

  • All .h files in src/
  • LICENSE.txt

opus

Files extracted from upstream source:

  • all .c and .h files in src/ (both opus and opusfile)
  • all .h files in include/ (both opus and opusfile) as opus/
  • remove unused opus_demo.c,
  • remove http.c, wincerts.c and winerrno.h (part of unused libopusurl)
  • celt/ and silk/ subfolders
  • COPYING

pcre2

Files extracted from upstream source:

  • Files listed in the file NON-AUTOTOOLS-BUILD steps 1-4
  • All .h files in src/ apart from pcre2posix.h
  • src/pcre2_jit_match.c
  • src/pcre2_jit_misc.c
  • src/sljit/*
  • AUTHORS and LICENCE

pvrtccompressor

Files extracted from upstream source:

  • all .cpp and .h files apart from main.cpp
  • LICENSE.TXT

recastnavigation

Files extracted from upstream source:

  • Recast/ folder without CMakeLists.txt
  • License.txt

squish

Files extracted from upstream source:

  • all .cpp, .h and .inl files

Important: Some files have Godot-made changes. They are marked with // -- GODOT start -- and // -- GODOT end -- comments and a patch is provided in the squish/ folder.

tinyexr

Files extracted from upstream source:

  • tinyexr.{cc,h}

vhacd

Files extracted from upstream source:

  • From src/VHACD_Lib/: inc, public and src
  • LICENSE

Some downstream changes have been made and are identified by // -- GODOT start -- and // -- GODOT end -- comments. They can be reapplied using the patches included in the vhacd folder.

wslay

File extracted from upstream release tarball:

  • All *.c and *.h in lib/ and lib/includes/
  • wslay.h has a small Godot addition to fix MSVC build. See thirdparty/wslay/msvcfix.diff

xatlas

Files extracted from upstream source:

  • xatlas.{cpp,h}
  • LICENSE

zlib

Files extracted from upstream source:

  • all .c and .h files

zstd

Files extracted from upstream source:

  • lib/{common/,compress/,decompress/,zstd.h}
  • LICENSE