[Bf-extensions-cvs] [9a285d80] master: FBX export / subdivision: Write proper boundary rule
Samuli Raivio
noreply at git.blender.org
Wed Sep 29 18:00:48 CEST 2021
Commit: 9a285d80167fc8c9e8b0c7ab2f2fd3c7487fa01d
Author: Samuli Raivio
Date: Wed Sep 29 17:58:50 2021 +0200
Branches: master
https://developer.blender.org/rBA9a285d80167fc8c9e8b0c7ab2f2fd3c7487fa01d
FBX export / subdivision: Write proper boundary rule
Currently when exporting a subdivision surface (//Geometry / Export Subdivision Surface// enabled) the exporter uses a hard-coded BoundaryRule rule of 2 (CreaseAll, meaning hard corners). The subdivision surface modifier has an option for boundary smoothing mode so this patch propagates that information to the FBX exporter.
Example .fbx file with this feature exported from modified Blender 2.93: https://github.com/bqqbarbhg/ufbx/blob/overhaul/data/blender_293x_subsurf_boundary_7400_binary.fbx
Reviewed By: mont29
Differential Revision: https://developer.blender.org/D12204
===================================================================
M io_scene_fbx/__init__.py
M io_scene_fbx/export_fbx_bin.py
M io_scene_fbx/import_fbx.py
===================================================================
diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index 495e62d2..a9c58915 100644
--- a/io_scene_fbx/__init__.py
+++ b/io_scene_fbx/__init__.py
@@ -21,7 +21,7 @@
bl_info = {
"name": "FBX format",
"author": "Campbell Barton, Bastien Montagne, Jens Restemeier",
- "version": (4, 24, 0),
+ "version": (4, 25, 0),
"blender": (2, 90, 0),
"location": "File > Import-Export",
"description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions",
diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py
index 3950ed5b..09dfaa9f 100644
--- a/io_scene_fbx/export_fbx_bin.py
+++ b/io_scene_fbx/export_fbx_bin.py
@@ -879,7 +879,10 @@ def fbx_data_mesh_elements(root, me_obj, scene_data, done_meshes):
if last_subsurf:
elem_data_single_int32(geom, b"Smoothness", 2) # Display control mesh and smoothed
- elem_data_single_int32(geom, b"BoundaryRule", 2) # Round edges like Blender
+ if last_subsurf.boundary_smooth == "PRESERVE_CORNERS":
+ elem_data_single_int32(geom, b"BoundaryRule", 2) # CreaseAll
+ else:
+ elem_data_single_int32(geom, b"BoundaryRule", 1) # CreaseEdge
elem_data_single_int32(geom, b"PreviewDivisionLevels", last_subsurf.levels)
elem_data_single_int32(geom, b"RenderDivisionLevels", last_subsurf.render_levels)
diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py
index ba11757a..a07e919e 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -2928,6 +2928,11 @@ def load(operator, context, filepath="",
mod = parent.bl_obj.modifiers.new('subsurf', 'SUBSURF')
mod.levels = preview_levels
mod.render_levels = render_levels
+ boundary_rule = elem_prop_first(elem_find_first(fbx_sdata, b'BoundaryRule'), default=1)
+ if boundary_rule == 2:
+ mod.boundary_smooth = "PRESERVE_CORNERS"
+ else:
+ mod.boundary_smooth = "ALL"
_(); del _
More information about the Bf-extensions-cvs
mailing list