Commit graph

342 commits

Author SHA1 Message Date
Rémi Verschelde
a828398655
Style: Replaces uses of 0/NULL by nullptr (C++11)
Using clang-tidy's `modernize-use-nullptr`.
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
2021-05-04 16:30:23 +02:00
Rémi Verschelde
b5e1e05ef2
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks 2021-05-04 14:45:16 +02:00
Rémi Verschelde
64a63e0861
Style: clang-format: Disable AllowShortCaseLabelsOnASingleLine 2021-05-04 14:45:15 +02:00
Rémi Verschelde
6e600cb3f0
Style: Set clang-format Standard to c++14 2021-05-04 14:45:15 +02:00
Shatur95
41e7cefaa4
Move duplicated code into a function
(cherry picked from commit a1cfc1032c)
2021-04-26 13:07:59 +02:00
Lyuma
d92a172879 Add an import setting use_legacy_names.
During the development of 3.3, internationalization features were added to allow arbitrary bone and node names.
However, doing so will break all references and existing animation clips for projects upgraded from 3.2
This adds an import setting, enabled by default, but disabled for newly generated .import files which restores the old behavior.
2021-04-20 22:48:52 -07:00
Morris Tabor
d9e9aec9b9 fix gltf importer regression from b032067e42, causing different BoneAttachment names 2021-04-09 10:25:45 +02:00
Rémi Verschelde
60c36af6dc
Remove now unnecessary ResourceImporterCSV importer
Its only purpose was to prevent importing CSV files as translations, but it
would still import them as *nothing*, leading to workflow issues.

This is now properly fixed with #47268 which allows disabling the import for
specific files.

(cherry picked from commit 7ed2220928)
2021-03-24 10:29:16 +01:00
Alex Hirsch
9d7f44c9aa
Add additional index checks to COLLADA importer
ref #46548

(cherry picked from commit 8faeb72f10)
2021-03-21 00:15:53 +01:00
ArdaE
87573e92dc
GLTF import: Prevent significant numerical errors in keyframe times
Keyframe times shift slowly in imported animations, starting with a zero shift
at the beginning and increasing and becoming erratic slowly farther into an
animation, reaching significant levels at times after about 3 minutes into an
animation. This commit fixes the issue by increasing the precision of the
floating point numbers used for keyframe time calculations. Only the most
significant cases that cause fast accumulation of errors over a short animation
duration are fixed. Other cases that would have a marginal benefit from
switching to double precision numbers are left for another PR/further analysis.
Note that this change has no impact on the runtime performance of games/apps
created using Godot. It only affects the GLTF importer.

Fixes #47127.

(cherry picked from commit 6770a9413b)
2021-03-19 10:53:37 +01:00
K. S. Ernest (iFire) Lee
f1e8ec942d
Expand bone name possibilities.
(cherry picked from commit c203fbfa8c)
2021-03-17 15:17:02 +01:00
abaire
b032067e42 Relaxes Node naming constraints in glTF documents to match the Editor. 2021-03-12 08:35:50 -08:00
Pedro J. Estébanez
4ddcdc031b Modernize Mutex
- Based on C++11's `mutex`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed
- Simpler for `NO_THREADS`
- `BinaryMutex` added for special cases as the non-recursive version
- `MutexLock` now takes a reference. At this point the cases of null `Mutex`es are rare. If you ever need that, just don't use `MutexLock`.
- `ScopedMutexLock` is dropped and replaced by `MutexLock`, because they were pretty much the same.
2021-02-18 11:58:08 +01:00
Rémi Verschelde
497653ab53
Merge pull request #44628 from JFonS/new_cpu_lightmapper_3.2
[3.2] New CPU lightmapper
2021-01-15 13:25:46 +01:00
JFonS
112b416056 Implement new CPU lightmapper
Completely re-write the lightmap generation code:
- Follow the general lightmapper code structure from 4.0.
- Use proper path tracing to compute the global illumination.
- Use atlassing to merge all lightmaps into a single texture (done by @RandomShaper)
- Use OpenImageDenoiser to improve the generated lightmaps.
- Take into account alpha transparency in material textures.
- Allow baking environment lighting.
- Add bicubic lightmap filtering.

There is some minor compatibility breakage in some properties and methods
in BakedLightmap, but lightmaps generated in previous engine versions
should work fine out of the box.

The scene importer has been changed to generate `.unwrap_cache` files
next to the imported scene files. These files *SHOULD* be added to any
version control system as they guarantee there won't be differences when
re-importing the scene from other OSes or engine versions.

This work started as a Google Summer of Code project; Was later funded by IMVU for a good amount of progress;
Was then finished and polished by me on my free time.

Co-authored-by: Pedro J. Estébanez <pedrojrulez@gmail.com>
2021-01-14 18:05:56 +01:00
Fabian Stiewitz
ba81e8ca09 fix gltf not importing files w/o bufferViews or accessors 2021-01-14 00:14:55 +01:00
Rémi Verschelde
49646383f1
Update copyright statements to 2021
Happy new year to the wonderful Godot community!

2020 has been a tough year for most of us personally, but a good year for
Godot development nonetheless with a huge amount of work done towards Godot
4.0 and great improvements backported to the long-lived 3.2 branch.

We've had close to 400 contributors to engine code this year, authoring near
7,000 commit! (And that's only for the `master` branch and for the engine code,
there's a lot more when counting docs, demos and other first-party repos.)

Here's to a great year 2021 for all Godot users 🎆

(cherry picked from commit b5334d14f7)
2021-01-13 16:17:06 +01:00
Rémi Verschelde
9d916b8540
glTF: Fix loading external images as buffer
We should first attempt loading as external files, thus creating a dependency.
Loading as a buffer should only be used as fallback to support manually loading
as PNG or JPEG depending on the defined mimeType.

Fixes #44309, was a regression from #42504.

(cherry picked from commit e268a8e523)
2021-01-05 21:33:34 +01:00
Adam Scott
d96fdcd45e Add missing "normalized" accessor property to glTF document for the 3.2 branch 2020-12-28 03:17:37 -05:00
Rémi Verschelde
68973cadf7
glTF: Workaround import failure with invalid embedded images
image/gif is not supported in the glTF 2.0 specification,
these files are broken. But let's be lenient...

Fixes #43638.

(cherry picked from commit f70cc0a60e)
2020-11-18 13:28:51 +01:00
K. S. Ernest (iFire) Lee
1f87bca8fb
Better non alphanumeric bone names.
1. _gen_unique_bone_name(Ref<GLTFState> state, const GLTFSkeletonIndex skel_i, const String &p_name) won't return an empty string.

2. String GLTFDocument::_sanitize_bone_name(const String &name) will keep Japanese characters. Like: "全ての親".

3. The sanitize function allows  the bone name to be not just alphanumeric. The only required conditions are the ones in add_bone.

> ERR_FAIL_COND(p_name == "" || p_name.find(":") != -1 || p_name.find("/") != -1);

(cherry picked from commit 7b76f8783f)
2020-10-05 20:46:01 +02:00
Rémi Verschelde
9529ce41eb
glTF: Fix parsing image data with mimeType undefined
The glTF 2.0 spec only makes `mimeType` mandatory for `bufferView` image data,
so the previous logic to handle URIs with base64-encoded images could fail if
`mimeType` is undefined.

The logic was documented and refactored to better handle the spec, notably:

- `uri` and `bufferView` are now mutually exclusive, and only the latter fails
  if `mimeType` is undefined.
- `uri` with a file path will now respect the `mimeType` if defined, and thus
  attempt loading the file with the specified format (even if its extension is
  not the one expected for this format). So we can support bad extensions (PNG
  data with `.jpg` extension) or custom ones (PNG data in `.img` file for
  example).
- `uri` with base64 encoded data will infer MIME type from `data:image/png` or
  `data:image/jpeg` if it was not documented in `mimeType` initially.
- `uri` with base64 encoded data, no `mimeType` and `application/octet-stream`
  or `application/gltf-buffer` will fall back to trying both PNG and JPEG
  loaders.

Fully fixes #33796 (and fixes up #42501).

(cherry picked from commit 2e99d0b26f)
2020-10-05 14:41:53 +02:00
Rémi Verschelde
177d16c01c
glTF: Fix parsing buffer data with application/gltf-buffer and image/* MIME types
See https://github.com/KhronosGroup/glTF/issues/944 for context on the
application/gltf-buffer MIME type.

The glTF 2.0 spec supports `image/jpeg` and `image/png` which can also be
base64-encoded in buffer URIs.

Fixes #33796.

(cherry picked from commit 34a50310ad)
2020-10-05 14:38:48 +02:00
K. S. Ernest (iFire) Lee
460ab353b4
Use the vertex colors by default in gltf.
(cherry picked from commit 43424e1321)
2020-09-29 13:57:57 +02:00
Adrien
e90467ef66 Fix #42043, mismatched compress options in ResourceImporterLayeredTexture 2020-09-14 15:36:46 +08:00
K. S. Ernest (iFire) Lee
f189d0e1f3 Allow gltf2 morph targets with no default values. Changes for bug 38751
(cherry picked from commit 71ae0ff46d)
2020-07-24 09:37:43 +02:00
lordkettune
c68ef4d754 Fix issues with custom tracks on reimport
(cherry picked from commit 4313a7bdc8)
2020-07-03 13:17:57 +02:00
Sl3dge78
d99f6c4d5c Fix #20467. The "Anim imported" warning gets displayed properly when working on imported anims.
(cherry picked from commit 95cd74fc4b)
2020-06-21 21:36:12 +02:00
Aaron Franke
e3cf64a7d8
[3.2] Add GLTF light import
Co-authored-by: K.S. Ernest (iFire) Lee <ernest.lee@chibifire.com>
2020-06-10 23:51:34 -04:00
Rémi Verschelde
7bf9787921 SCons: Format buildsystem files with psf/black
Configured for a max line length of 120 characters.

psf/black is very opinionated and purposely doesn't leave much room for
configuration. The output is mostly OK so that should be fine for us,
but some things worth noting:

- Manually wrapped strings will be reflowed, so by using a line length
  of 120 for the sake of preserving readability for our long command
  calls, it also means that some manually wrapped strings are back on
  the same line and should be manually merged again.

- Code generators using string concatenation extensively look awful,
  since black puts each operand on a single line. We need to refactor
  these generators to use more pythonic string formatting, for which
  many options are available (`%`, `format` or f-strings).

- CI checks and a pre-commit hook will be added to ensure that future
  buildsystem changes are well-formatted.

(cherry picked from commit cd4e46ee65)
2020-06-10 15:30:52 +02:00
Rémi Verschelde
e891fae52b
Merge pull request #39134 from abustin/fbx_mesh_compression_fix
Respect 'mesh compression' editor import option in Assimp and glTF importers
2020-06-08 13:16:39 +02:00
Hugo Locurcio
b0fe8cab14 Tweak the import compression property hint for clarity
(cherry picked from commit 1439447071)
2020-06-04 12:16:39 +02:00
Pedro J. Estébanez
b2a64b144f Fix excessive bottom cropping in atlas generation
(cherry picked from commit fb7ae73045)
2020-06-04 12:16:39 +02:00
Alex Bustin
8a024ca294 Respect 'mesh compression' editor import option in Assimp (ie. FBX) and glTF importers 2020-05-28 15:28:47 -07:00
Hugo Locurcio
6692681618 Tweak the error message displayd when a post-import script fails
See #38662.

(cherry picked from commit 0d7b627936)
2020-05-13 16:12:03 +02:00
Rémi Verschelde
5f5ef98832 glTF: Fix tangent generation for non-blend shapes
PR #30877 was bogus as it made a blend shape-specific code block apply
to everything but blend shapes (as it seemed not to work properly *for*
blend shapes).

The proper fix should thus be to simply remove the problematic
block (and thus cleanup unnecessary logic).

Fixes #32712.

(cherry picked from commit 0034c88c57)
2020-05-01 10:56:58 +02:00
Maurizio Petrarota
53b4689979 Fixed TextureAtlas import.
(cherry picked from commit 744c1fafff)
2020-03-04 12:40:14 +01:00
Juan Linietsky
03c8e12d54 Add support for named binds in Skin.
Helps better reutilization of skeletons from Maya exported files.

(cherry picked from commit 9a34f39d32)
2020-03-04 12:40:14 +01:00
Hugo Locurcio
a002b93d86
Add explanations for errors related to Vector/Quat normalization 2020-01-24 14:19:23 +01:00
Rémi Verschelde
4faaf6089a Remove unused #if 0'ed code 2020-01-21 21:41:54 +01:00
Haoyu Qiu
92b36d4706 Adds NULL check before using image loader 2020-01-16 21:49:23 +08:00
Bastiaan Olij
ad6d06dc21 Add option to apply an offset to obj mesh import 2020-01-11 19:27:00 +11:00
K. S. Ernest (iFire) Lee
0172a7f932 Use cycle and loop hint flags in glTF2. 2020-01-10 08:02:16 -08:00
K. S. Ernest (iFire) Lee
f028b8b0e4 Support GLTF2 alpha scissors. 2020-01-02 11:52:08 -08:00
Rémi Verschelde
bde52cc688
Merge pull request #34618 from qarmin/vector_please_dont_crash
Don't use constant reference in Vector push_back, insert and append_array
2020-01-02 15:44:41 +01:00
Rémi Verschelde
a7f49ac9a1 Update copyright statements to 2020
Happy new year to the wonderful Godot community!

We're starting a new decade with a well-established, non-profit, free
and open source game engine, and tons of further improvements in the
pipeline from hundreds of contributors.

Godot will keep getting better, and we're looking forward to all the
games that the community will keep developing and releasing with it.
2020-01-01 11:16:22 +01:00
Rafał Mikrut
1ac701cc37 Don't use constant reference in Vector push_back, insert and append_array 2019-12-26 17:38:08 +01:00
Marios Staikopoulos
d3cf8cfb7d Fix Hard Crash on glTF Color Accessor Import 2019-12-24 15:03:24 -08:00
Rafał Mikrut
ed1c4bc77d Removed unused variables, add some constants numbers 2019-12-10 05:13:02 +01:00
Marios Staikopoulos
4b28fd4f23 Bugfix: Sanitize glTF importer Animation Names and do not set bone_pose 2019-11-27 12:20:38 -08:00