Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2015-07-12 13:40:24 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-07-12 13:40:24 +0300
commitdb79c2aa5eed872e44f8462cfbc793011b4a8162 (patch)
tree2dd93a11d60595a4e39c8abf4ece520b444c4351 /io_scene_fbx
parent06545113736d893a3fbfa6d4f4465d297f8df893 (diff)
FBX Import: Add option to not import custom normals.
Diffstat (limited to 'io_scene_fbx')
-rw-r--r--io_scene_fbx/__init__.py10
-rw-r--r--io_scene_fbx/fbx_utils.py2
-rw-r--r--io_scene_fbx/import_fbx.py26
3 files changed, 25 insertions, 13 deletions
diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index b91696df..184e6673 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": (3, 4, 4),
+ "version": (3, 4, 5),
"blender": (2, 74, 0),
"location": "File > Import-Export",
"description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions",
@@ -90,6 +90,12 @@ class ImportFBX(bpy.types.Operator, ImportHelper, IOFBXOrientationHelper):
default=False,
)
+ use_custom_normals = BoolProperty(
+ name="Import Normals",
+ description="Import custom normals, if available (otherwise Blender will recompute them)",
+ default=True,
+ )
+
use_image_search = BoolProperty(
name="Image Search",
description="Search subdirs for any associated images (Warning, may be slow)",
@@ -181,6 +187,8 @@ class ImportFBX(bpy.types.Operator, ImportHelper, IOFBXOrientationHelper):
layout.prop(self, "global_scale")
layout.prop(self, "bake_space_transform")
+ layout.prop(self, "use_custom_normals")
+
layout.prop(self, "use_image_search")
# layout.prop(self, "use_alpha_decals")
layout.prop(self, "decal_offset")
diff --git a/io_scene_fbx/fbx_utils.py b/io_scene_fbx/fbx_utils.py
index 85b64e51..651cac7c 100644
--- a/io_scene_fbx/fbx_utils.py
+++ b/io_scene_fbx/fbx_utils.py
@@ -1223,7 +1223,7 @@ FBXExportData = namedtuple("FBXExportData", (
FBXImportSettings = namedtuple("FBXImportSettings", (
"report", "to_axes", "global_matrix", "global_scale",
"bake_space_transform", "global_matrix_inv", "global_matrix_inv_transposed",
- "use_cycles", "use_image_search",
+ "use_custom_normals", "use_cycles", "use_image_search",
"use_alpha_decals", "decal_offset",
"anim_offset",
"use_custom_props", "use_custom_props_enum_as_string",
diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py
index b9384eb0..e667693d 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -1183,15 +1183,17 @@ def blen_read_geom(fbx_tmpl, fbx_obj, settings):
# must be after edge, face loading.
ok_smooth = blen_read_geom_layer_smooth(fbx_obj, mesh)
- # Note: we store 'temp' normals in loops, since validate() may alter final mesh,
- # we can only set custom lnors *after* calling it.
- mesh.create_normals_split()
- if geom_mat_no is None:
- ok_normals = blen_read_geom_layer_normal(fbx_obj, mesh)
- else:
- def nortrans(v):
- return geom_mat_no * Vector(v)
- ok_normals = blen_read_geom_layer_normal(fbx_obj, mesh, nortrans)
+ ok_normals = False
+ if settings.use_custom_normals:
+ # Note: we store 'temp' normals in loops, since validate() may alter final mesh,
+ # we can only set custom lnors *after* calling it.
+ mesh.create_normals_split()
+ if geom_mat_no is None:
+ ok_normals = blen_read_geom_layer_normal(fbx_obj, mesh)
+ else:
+ def nortrans(v):
+ return geom_mat_no * Vector(v)
+ ok_normals = blen_read_geom_layer_normal(fbx_obj, mesh, nortrans)
mesh.validate(clean_customdata=False) # *Very* important to not remove lnors here!
@@ -1209,7 +1211,8 @@ def blen_read_geom(fbx_tmpl, fbx_obj, settings):
else:
mesh.calc_normals()
- mesh.free_normals_split()
+ if settings.use_custom_normals:
+ mesh.free_normals_split()
if not ok_smooth:
mesh.polygons.foreach_set("use_smooth", [True] * len(mesh.polygons))
@@ -2182,6 +2185,7 @@ def load(operator, context, filepath="",
axis_up='Y',
global_scale=1.0,
bake_space_transform=False,
+ use_custom_normals=True,
use_cycles=True,
use_image_search=False,
use_alpha_decals=False,
@@ -2311,7 +2315,7 @@ def load(operator, context, filepath="",
settings = FBXImportSettings(
operator.report, (axis_up, axis_forward), global_matrix, global_scale,
bake_space_transform, global_matrix_inv, global_matrix_inv_transposed,
- use_cycles, use_image_search,
+ use_custom_normals, use_cycles, use_image_search,
use_alpha_decals, decal_offset,
anim_offset,
use_custom_props, use_custom_props_enum_as_string,