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
This commit is contained in:
Aras Pranckevicius
2025-05-24 15:22:19 +02:00
committed by Aras Pranckevicius
parent 9ffb474e07
commit 4e7acc4be8
5 changed files with 139 additions and 0 deletions

View File

@@ -343,6 +343,8 @@ void importer_main(Main *bmain, Scene *scene, ViewLayer *view_layer, const FBXIm
* cause armatures/skins to not import correctly, when inserted in the middle of bone chain. */
opts.geometry_transform_handling = UFBX_GEOMETRY_TRANSFORM_HANDLING_MODIFY_GEOMETRY_NO_FALLBACK;
opts.pivot_handling = UFBX_PIVOT_HANDLING_ADJUST_TO_PIVOT;
opts.space_conversion = UFBX_SPACE_CONVERSION_ADJUST_TRANSFORMS;
opts.target_axes.right = UFBX_COORDINATE_AXIS_POSITIVE_X;
opts.target_axes.up = UFBX_COORDINATE_AXIS_POSITIVE_Z;

BIN
tests/files/io_tests/fbx/issue138834_pivots.fbx (Stored with Git LFS) Normal file

Binary file not shown.

View File

@@ -0,0 +1,76 @@
==== Meshes: 4
- Mesh 'Mesh' vtx:86 face:67 loop:300 edge:159
- 2 0 1 3 6 ... 36 16 17 41 40
- 2/3 0/2 0/1 1/3 4/6 ... 81/85 13/37 12/36 17/41 16/40
- attr 'position' FLOAT_VECTOR POINT
- (94.377, 9.507, 3.486)
- (8.077, 9.507, 3.486)
- (94.377, 213.684, 3.486)
...
- (93.954, 158.336, 9.005)
- (97.952, 159.099, 8.925)
- (100.487, 156.998, 9.133)
- Mesh 'Mesh.001' vtx:86 face:67 loop:300 edge:159
- 2 3 1 0 6 ... 16 16 40 41 17
- 0/2 2/3 1/3 0/1 6/7 ... 81/85 13/37 12/36 17/41 16/40
- attr 'position' FLOAT_VECTOR POINT
- (-94.377, 9.507, 3.486)
- (-8.077, 9.507, 3.486)
- (-94.377, 213.684, 3.486)
...
- (-93.954, 158.336, 9.005)
- (-97.952, 159.099, 8.925)
- (-100.487, 156.998, 9.133)
- Mesh 'Mesh.002' vtx:86 face:67 loop:300 edge:159
- 2 0 1 3 6 ... 36 16 17 41 40
- 2/3 0/2 0/1 1/3 4/6 ... 81/85 13/37 12/36 17/41 16/40
- attr 'position' FLOAT_VECTOR POINT
- (541.521, 28.042, -164.886)
- (455.221, 28.042, -164.886)
- (541.521, 232.219, -164.886)
...
- (541.098, 176.871, -159.367)
- (545.096, 177.634, -159.447)
- (547.631, 175.533, -159.239)
- Mesh 'Mesh.003' vtx:52 face:44 loop:176 edge:92
- 2 0 1 3 6 ... 50 28 30 48 51
- 2/3 0/2 0/1 1/3 4/6 ... 26/47 30/48 42/49 41/50 28/51
- attr 'position' FLOAT_VECTOR POINT
- (-10.789, 100.289, -4.808)
- (-91.753, 100.289, -4.808)
- (-10.789, 211.997, -4.808)
...
- (-66.088, 88.947, 5.940)
- (-66.088, 93.392, 5.940)
- (-66.088, 93.392, 10.185)
==== Objects: 5
- Obj '01' EMPTY
- pos 0.000, 0.000, 0.000
- rot 1.571, 0.000, 0.000 (XYZ)
- scl 0.010, 0.010, 0.010
- props: str:currentUVSet='map1'
- Obj 'Door_01' MESH data:'Mesh' par:'01'
- pos -102.530, 18.535, 136.567
- rot 0.000, 0.000, 0.000 (XYZ)
- scl 1.000, 1.000, 1.000
- props: str:currentUVSet='map1'
- Obj 'Door_02' MESH data:'Mesh.001' par:'01'
- pos 102.530, 18.535, 136.567
- rot 0.000, 0.000, 0.000 (XYZ)
- scl 1.000, 1.000, 1.000
- props: str:currentUVSet='map1'
- Obj 'Door_03' MESH data:'Mesh.002' par:'01'
- pos 710.133, 300.000, 305.051
- rot 3.142, 0.000, 0.000 (XYZ)
- scl -1.000, -1.000, -1.000
- props: str:currentUVSet='map1'
- Obj 'Door_04' MESH data:'Mesh.003' par:'01'
- pos 203.475, 18.535, -332.622
- rot 0.000, 0.000, 0.000 (XYZ)
- scl 1.000, 1.000, 1.000
- props: str:currentUVSet='map1'

View File

@@ -0,0 +1,55 @@
==== Meshes: 1
- Mesh 'Mesh' vtx:8 face:6 loop:24 edge:12
- 0 1 3 2 2 ... 3 6 0 2 4
- 0/2 0/1 1/3 2/3 2/4 ... 4/6 5/7 6/7 0/6 1/7
- attr 'position' FLOAT_VECTOR POINT
- (-4.183, 1.500, 3.683)
- (-3.317, 1.500, 3.183)
- (-4.183, 2.500, 3.683)
...
- (-3.817, 2.500, 2.317)
- (-4.683, 1.500, 2.817)
- (-3.817, 1.500, 2.317)
- attr 'sharp_edge' BOOLEAN EDGE
- 1 1 1 1 1 ... 1 1 1 1 1
- attr 'material_index' INT FACE
- 0 0 0 0 0 0
- attr 'custom_normal' INT16_2D CORNER
- (0, 0)
- (0, 0)
- (0, 0)
...
- (0, 0)
- (0, 0)
- (0, 0)
- attr 'map1' FLOAT2 CORNER
- (0.375, 0.000)
- (0.625, 0.000)
- (0.625, 0.250)
...
- (0.375, 0.000)
- (0.375, 0.250)
- (0.125, 0.250)
- 1 materials
- 'lambert1'
==== Objects: 1
- Obj 'pCube1' MESH data:'Mesh'
- pos 0.050, 0.000, 0.000
- rot 1.571, 0.000, -0.785 (XYZ)
- scl 0.010, 0.010, 0.010
==== Materials: 1
- Mat 'lambert1'
- base color (0.500, 0.500, 0.500)
- specular ior 0.500
- specular tint (1.000, 1.000, 1.000)
- roughness 0.500
- metallic 0.000
- ior 1.500
- viewport diffuse (0.500, 0.500, 0.500, 1.000)
- viewport specular (1.000, 1.000, 1.000), intensity 0.500
- viewport metallic 0.000, roughness 0.500
- backface False probe True shadow False
- props: f3:Ambient=(0.000, 0.000, 0.000) f3:Diffuse=(0.400, 0.400, 0.400) f3:Emissive=(0.000, 0.000, 0.000) fl:Opacity=1.000

BIN
tests/files/io_tests/fbx/ufbx_motionbuilder_pivot_7700a.fbx (Stored with Git LFS) Normal file

Binary file not shown.