Smoothening positions for flat, non-smoothened, triangles is unnecessary and
caused positions to move outside their triangle which caused side-effects as
rays from those positions intersected with triangles which could not be
reached from the original triangle.
This is solved by skipping smoothening of positions for flat triangles.
A triangle is determined to be flas as its vertex normals are equal.
Previously the bounding boxes and triangles were maintained in two separate
arrays (Vectors). As the triangle vector was sorted and the bounding-box array
was not , the order of both arrays differed. This meant that the index in one
was different than the other, which caused lookup issues.
To prevent this, the bounding-box is now part of the triangle structure so that
there is a single structure that cannot become out-of-sync anymore.
Various fixes to UV2 unwrapping and the GPU lightmapper. Listed here for
context in case of git blame/bisect:
* Fix UV2 unwrapping on import, also cleaned up the unwrap cache code.
* Fix saving of RGBA images in EXR format.
* Fixes to the GPU lightmapper:
- Added padding between atlas elements, avoids bleeding.
- Remove old SDF generation code.
- Fix baked attenuation for Omni/Spot lights.
- Fix baking of material properties onto UV2 (wireframe was
wrongly used before).
- Disable statically baked lights for objects that have a
lightmap texture to avoid applying the same light twice.
- Fix lightmap pairing in RendererSceneCull.
- Fix UV2 array generated from `RenderingServer::mesh_surface_get_arrays()`.
- Port autoexposure fix for OIDN from 3.x.
- Save debug textures as EXR when using floating point format.
Inverted the spotlight angle attenuation so a higher value results in
a dimmer light, this makes it more consistent with the distance
attenuation.
Also changed the way spotlighs are computed in SDFGI
and GIPorbes and GPU lightmapper, now it matches the falloff used in the scene rendering
code.
The added `#` prevents clang-format from misinterpreting the meaning
of this statement and thus messing up the formatting of the next
lines up until the first `layout` statement.
Similarly, a semicolon is now enforced on `versions` defines to
prevent clang-format from messing up formatting and putting them
all on a single line. Note: In its current state the code will
ignore chained statements on a single line separated by a semicolon.
Also removed some extraneous lines missed in previous style changes
or added by mistake with said changes (e.g. after uniform definitions
that clang-format messes up somewhat too, but we live with it).
I couldn't find a tool that enforces it, so I went the manual route:
```
find -name "thirdparty" -prune \
-o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \
-o -name "*.glsl" > files
perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files)
misc/scripts/fix_style.sh -c
```
This adds a newline after all `}` on the first column, unless they
are followed by `#` (typically `#endif`). This leads to having lots
of places with two lines between function/class definitions, but
clang-format then fixes it as we enforce max one line of separation.
This doesn't fix potential occurrences of function definitions which
are indented (e.g. for a helper class defined in a .cpp), but it's
better than nothing. Also can't be made to run easily on CI/hooks so
we'll have to be careful with new code.
Part of #33027.
-Added LocalVector (needed it)
-Added stb_rect_pack (It's pretty cool, we could probably use it for other stuff too)
-Fixes and changes all around the place
-Added library for 128 bits fixed point (required for Delaunay3D)