25 Commits

Author SHA1 Message Date
Jesse Yurkovich
024f396d06 Cleanup: Fix typos in tests subdirectory
Fixes various typos

Co-authored-by: luz paz
Pull Request: https://projects.blender.org/blender/blender/pulls/148090
2025-10-14 22:35:54 +02:00
Habib Gahbiche
1b4daf9d2e Nodes: remove "Use Nodes" in Shader Editor for Object Materials
"Use Nodes" was removed in the compositor to simplify the compositing
workflow. This introduced a slight inconsistency with the Shader Node
Editor.

This PR removes "Use Nodes" for object materials.

For Line Style, no changes are planned (not sure how to preserve
compatibility yet).
This simplifies the state of objects; either they have a material or
they don't.

Backward compatibility:
- If Use Nodes is turned Off, new nodes are added to the node tree to
simulate the same material:
- DNA: Only `use_nodes` is marked deprecated
- Python API:
  - `material.use_nodes` is marked deprecated and will be removed in
6.0. Reading it always returns `True` and setting it has no effect.
  - `material.diffuse_color`, `material.specular` etc.. Are not used by
EEVEE anymore but are kept because they are used by Workbench.

Forward compatibility:
Always enable 'Use Nodes' when writing blend files.

Known Issues:
Some UI tests are failing on macOS

Pull Request: https://projects.blender.org/blender/blender/pulls/141278
2025-09-14 17:53:54 +02:00
Mattias Fredriksson
ccd8926717 Curves: Simplify calculation of NURBS basis functions
Replaces current basis function calculation which seems to be a direct
implementation of the recursive NURBS formulation. New implementation
avoids the need to check for zero divisions during iteration. Out of
bounds checks are also converted to asserts, assuming input provides
valid span index.

Performance wise this nets a 7+% performance improvement with the
average result being as fast or faster then the fastest execution
from previous implementation!

Pull Request: https://projects.blender.org/blender/blender/pulls/144457
2025-09-04 21:49:58 +02:00
Aras Pranckevicius
eb96ef2dff Fix #145116: new FBX importer does not handle geometry transform + instancing properly
When instanced meshes were using FBX geometric transforms, the code
was not telling ufbx to create proper adjustment helper nodes due to
UFBX_GEOMETRY_TRANSFORM_HANDLING_MODIFY_GEOMETRY_NO_FALLBACK flag.
That flag was put in earlier, before import of armatures was solidified,
turns out using the proper flag (UFBX_GEOMETRY_TRANSFORM_HANDLING_MODIFY_GEOMETRY)
is not a problem anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/145527
2025-09-01 19:39:54 +02:00
Sybren A. Stüvel
3016cf650d Geometry Nodes: implement file path callback for import nodes
Add geometry file import nodes support to the for-each-path logic.
This will make `bpy.data.file_path_map()` report the input files for
OBJ, PLY, etc. import nodes (and any other node that has a string
property of subtype `PROP_FILEPATH`).

Currently this only supports static file paths, so where the file path
is set as the input socket's default value. When the path is
determined via any noodle, this is ignored and the default value is
reported anyway.

This is necessary for the new version of Blender Asset Tracer, which
in turn is needed to resolve studio/flamenco#104423.

Pull Request: https://projects.blender.org/blender/blender/pulls/144874
2025-08-26 11:03:27 +02:00
Mattias Fredriksson
e191d3d243 IO: OBJ improvements for NURBS curves
* Bezier (NURBS) import, supporting both Blender and external variants.
* Cleaner Bezier export, with better results importing in Rhino.
* Internal support for exporting the new Curves type.
* Tests covering a broad number of related cases.

The current NURBS exporter writes curve data directly, without accounting
for internal padding or how knots are generated from modes. This adjusts the
export behavior to omit data that does not influence the geometry of the
curve. The result is a simplified output that is easier to parse during import,
both for the importer and when importing to other platforms (Rhino).
Visual explanation to the adjustment can be found in #139174.

Importer is also adjusted to support variations in knot patterns. Extending
it to support the data generated by the exporter and by other platforms (Rhino).
This should resolve some issues in relation to #138732.

Integrated tests are added to broadly validate the common cases generated
by the exporter, including variations of different modes and NURBS order.

Regression tests are added to validate that the NURBS generated in Rhino
are imported as expected.

More details in the PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/139174
2025-08-01 06:37:28 +02:00
Aras Pranckevicius
e57b73bdf7 Fix #142333: new FBX importer produces broken rotation fcurves in some cases
Need to ensure that interpolation between neighboring quaternions
takes the shortest path. The Python FBX importer was doing this;
due to oversight was missed in the new importer.

Pull Request: https://projects.blender.org/blender/blender/pulls/142659
2025-07-21 10:50:48 +02:00
Aras Pranckevicius
65ce05eae7 Merge branch 'blender-v4.5-release' 2025-07-04 11:37:22 +03:00
Aras Pranckevicius
641824753a Fix #141434: OBJ importer should apply bounds clamp size to the whole scene
It was applying the bounds clamp to each object individually,
which changed spatial relationships between objects. Make the logic
match what used to be done in the Python OBJ importer back in the day.

Pull Request: https://projects.blender.org/blender/blender/pulls/141446
2025-07-04 10:36:18 +02:00
Jacques Lucke
f0c7e52ff2 Core: extract blendfile_header.py as common utility for parsing .blend files
This new file can parse the file header (first few bytes) as well as the block
headers.

Right now, this is used by two places:
* `blendfile.py` which is used by `blend2json.py`
* `blend_render_info.py`

This new module is shipped with Blender because it's needed for
`blend_render_info.py` which is shipped with Blender too. This makes using it in
`blendfile.py` (which is not shipped with Blender) a bit more annoying. However,
this is already not ideal, because e.g. `blend2json` also has to add to
`sys.path` already to be able to import `blendfile.py`.

This new file could also be used by blender-asset-tracer (BAT).

The new `BlendFileHeader` and `BlockHeader` types may be subclassed by code
using it, because it wants to store additional derived data (`blendfile.py` and
BAT need this).

New tests have been added that check that the file and block header is parsed
correctly for different kinds of .blend files.

Pull Request: https://projects.blender.org/blender/blender/pulls/140341
2025-06-23 12:53:55 +02:00
Michal Krupa
fdaaea6328 Core: Increase MAX_ID_NAME length from 66 to 258 (Blender 5.0)
Change the maximum data-block name from 64 to 256 bytes by increasing MAX_ID_NAME value.

Also increase a few related non-ID data name max size, essentially the action slots identifiers, as these are the primary key used to match an Action's slot to an ID by name.

Other sub-data (bones, modifiers, etc.) lengths are not modified here, as these can be made actual dynamic strings in the future, while keeping (a reasonable level of) forward compatibility, during the course of Blender 5 release cycles.

Implements #137608.

Co-authored-by: Bastien Montagne <bastien@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/137196
2025-06-19 16:39:20 +02:00
Aras Pranckevicius
d9ef240311 Merge branch 'blender-v4.5-release' 2025-06-14 22:15:36 +03:00
Aras Pranckevicius
074fcfe1a5 Fix #138834: FBX importer sets pivots incorrectly in some cases
Fix the rest of #138834, pivot adjustment was not done
when rotation pivot and scaling pivot inside FBX were not matching.

Pull Request: https://projects.blender.org/blender/blender/pulls/140411
2025-06-14 21:14:27 +02:00
Laurynas Duburas
3c407ebeaa Curves: Enhance tesselation of NURBS with corners
Current NURBS evaluation handles corners or sharp angles poorly. Sharp
edges appear when a knot vector value is repeated `order - 1` times.
Users can make sharp corners by creating NURBS curve with `Bezier` knot
mode or by setting `order` to 2 for legacy curves. The problem occurs
because current algorithm takes all the curve's definition interval,
divides it into equal parts and evaluates at those points, but corners
are exactly on repeated knot's. To hit those, the resolution has to be
increased higher than required for the rest of the curve.

The new algorithm divides non zero length intervals between two adjacent
knots into equal parts. This way corners are hit with a resolution of 1.
This does change the evaluated points of NURBS curves, which is why some
test results have to be updated in this commit.

Pull Request: https://projects.blender.org/blender/blender/pulls/138565
2025-06-12 16:22:21 +02:00
Aras Pranckevicius
ba0b1acb4e Fix #139656: FBX importer does not set normalmap textures as "non-color"
Normal maps (and generally all other non-color textures) were not
marked as non-color in the new FBX importer.

Pull Request: https://projects.blender.org/blender/blender/pulls/139725
2025-06-02 15:15:05 +02:00
Aras Pranckevicius
4e7acc4be8 Fix #138834: FBX import improved pivot handling
This does not fully fix the issue (pivots are still not handled
correctly when an object contains negative scale -- filed upstream
ufbx issue https://github.com/ufbx/ufbx/issues/218), but for regular
cases the pivots are in much better places now.

Pull Request: https://projects.blender.org/blender/blender/pulls/139381
2025-05-24 15:22:19 +02:00
Campbell Barton
a0e1938021 Cleanup: remove spaces from filenames, unix line endings
Also rename "blender export import test suite description.txt" to
"readme.txt" as the filename was including information available
in the leading path.
2025-05-23 14:32:45 +10:00
Aras Pranckevicius
8119e4baa7 Fix: FBX importer was not skipping special MotionBuilder viewport cameras
Reported on devtalk: MotionBuilder produced FBX files contain
"cameras" that are not really user visible cameras, but rather map to
MotionBuilder viewports. They are at root, have no child elements,
and have special names. There is also a "camera switcher";
ignore that too.

Pull Request: https://projects.blender.org/blender/blender/pulls/139204
2025-05-21 11:15:20 +02:00
Aras Pranckevicius
389d770bf4 Fix #122256, #123862: OBJ import Clamp Size option issues
- #122256: Clamp Size option did not work at all, due to mesh
  bounding box still not being calculated (and was firing an assert
  in Debug build).
- #123862: Clamp Size option was rounding the resulting scale to
  powers of ten, which is not what anyone would expect.

This fixes both issues, and adds test coverage.

Co-authored-by: dshot92 <dshot92@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/139145
2025-05-20 11:57:42 +02:00
Aras Pranckevicius
de5d0cfdc5 Fix #138795: FBX importer was not handling armatures with non-bone nodes
File under #138795 showed several issues, which, while investigating
them, led to also fixing some other issues.

- FBX files can contain non-bone nodes in between actual bone nodes
  ("fake bones" as they used to be called in Python importer). Handling
  this case was missing in the new importer.
- Due to above, some armatures had what appeared like multiple
  "root bones" inside them, which led to crashes while importing
  animations.
- Meshes with multiple armature modifiers (multiple skin deformers
  in FBX) were not handled correctly, see
  https://projects.blender.org/blender/blender-addons/issues/45171
  for when the same issue was fixed in the Python importer.

Extended test coverage to encompass the above.

Pull Request: https://projects.blender.org/blender/blender/pulls/138992
2025-05-16 21:45:27 +02:00
Mattias Fredriksson
bc0913240f Fix: Improve Obj importers parsing and detection of NURBS knot mode
Reworks the implementation for how knots are interpreted when importing
NURBS in .obj format. It refactors each test into a separate function
and simplifies functions using a 'multiplicity sequence' which counts
repeated occurances of knot values (or their 'multiplicity'). Making
comparisons simpler, clearer, and with improved correctness.

With regard to regression tests behavior is almost the same, noticable
difference is consideration of cyclic. Allowing curves with multiplicity
at the endpoints to be cyclic (so Bezier curves can be cyclic given
one repeated point). Untested behavior may also have been 'refined'
(changed), but additional tests would be needed to identify those cases.

Pull Request: https://projects.blender.org/blender/blender/pulls/138778
2025-05-16 15:44:38 +02:00
Aras Pranckevicius
6a0e6f5cff Fix: New FBX importer was not handling blender specific FullWeights
- Update to latest ufbx version that adds support for FullWeights
- Handle that in the same way as the Python importer did
- Add test files from ufbx test suite

Pull Request: https://projects.blender.org/blender/blender/pulls/138811
2025-05-13 15:43:08 +02:00
Mattias Fredriksson
d0cf7dd8b5 Fix: Improve OBJ NURBS IO, support exporting custom knots
Corrects behavior with NURBS knot values in .obj exporter. Knot values
denoting the curve parameter range and values at the boundary region
in the span ends had hardcoded knot values. It also implemented its own
knot calculation, which is not ideal...

Importer is updated to not try to second guess the knot values.
Not entirely sure what it was trying to do but it used wrong indices
and missed writing the end of the knot vector. Combined the changes
should make it possible to import and export a simple NURBS curve with
custom knots and leaving it intact.

This replaces some of the erronous behavior using functions from [new]
Curves implementation. Mixing new and legacy curve implementation is not
ideal but exporter is exporting POLY curves as NURBS while legacy method
does not support computing the knot vector. To avoid introducing
additional branch cases nor update legacy functions, using the new
functions seems to be the correct choice. These functions should be
functionally equivalent but is not identical (e.g. legacy curve returns
knots in [0, 1] range). It should also make it easier to transition to
exporting new Curves.

Pull Request: https://projects.blender.org/blender/blender/pulls/138732
2025-05-12 16:51:21 +02:00
Aras Pranckevicius
a96ecd2834 Fix #137768: new FBX importer does not import some animations correctly
- FBX "root bone" should become the Armature object itself, and not
  an extra bone (follow same logic as Python importer did).
- "World to armature matrix" was not correct for armatures that are
  parented under some other objects with transforms.
- Parenting imported meshes under an Armature was not taking into
  account that the mesh bind transform might not be the same as the
  current mesh node transform (i.e. was not setting "matrix parent
  inverse" to compensate like the Python importer did).
- The repro file in #137768 also exposed an issue that importing custom
  vertex normals was not working correctly in the new importer, when
  mesh is partially invalid (validation alters the mesh, custom normals
  have to be set afterwards).

Pull Request: https://projects.blender.org/blender/blender/pulls/138736
2025-05-12 10:56:07 +02:00
Sergey Sharybin
bbfc97ad6f Move tests/data and assets to the main repository
This change moves the tests data files and publish folder of assets
repository to the main blender.git repository as LFS files.

The goal of this change is to eliminate toil of modifying tests,
cherry-picking changes to LFS branches, adding tests as part of a
PR which brings new features or fixes.

More detailed explanation and conversation can be found in the
design task.

Ref #137215

Pull Request: https://projects.blender.org/blender/blender/pulls/137219
2025-05-05 15:10:22 +02:00