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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMyron Carey <myroncarey>2022-09-14 16:25:31 +0300
committerGaia Clary <gaia.clary@machinimatrix.org>2022-09-14 16:26:11 +0300
commit22bf5ba4d1526c9e942a2dbd6f25e3932e9d71f2 (patch)
treea2b3cd6b63000493a7e9e3d2dc7bd5f9554a344a /source/blender/editors/io
parent8aca0da9521a7a4570f21bc71872f69b4e78d83b (diff)
Fix T49814: Collada Import Ignores Vertex Normals
We now import and apply custom normals using a similar strategy to the STL importer. We store custom normal data for each loop as we read each MPoly and then apply it to the mesh after `BKE_mesh_calc_edges()` is called. The new behavior is optional and may be disabled in the Collada import UI. When disabled, we use the old behavior of only using normals to determine whether or not to smooth shade an MPoly. ---- Patch as requested in {T49814}. The Collada import UI now has an additional checkbox, similar to the glTF and FBX import UIs: {F13428264} Here is a test Collada file with a simple test cube with flipped custom normals: {F13428260} {F13428282} And a sphere where the two halves are disconnected geometry, but has custom normals that make the halves appear to be connected: {F13436363} {F13436368} I've tested it on a number of my own meshes, and the custom normals appear to be imported correctly. I'm not too sure about how I've plumbed the option down, though, or whether this is the most proper way to apply custom normals. Reviewed By: gaiaclary Differential Revision: https://developer.blender.org/D15804
Diffstat (limited to 'source/blender/editors/io')
-rw-r--r--source/blender/editors/io/io_collada.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c
index 3da7c00d5e2..1048d0eca32 100644
--- a/source/blender/editors/io/io_collada.c
+++ b/source/blender/editors/io/io_collada.c
@@ -693,6 +693,7 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op)
int min_chain_length;
int keep_bind_info;
+ int custom_normals;
ImportSettings import_settings;
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
@@ -702,6 +703,7 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op)
/* Options panel */
import_units = RNA_boolean_get(op->ptr, "import_units");
+ custom_normals = RNA_boolean_get(op->ptr, "custom_normals");
find_chains = RNA_boolean_get(op->ptr, "find_chains");
auto_connect = RNA_boolean_get(op->ptr, "auto_connect");
fix_orientation = RNA_boolean_get(op->ptr, "fix_orientation");
@@ -714,6 +716,7 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op)
import_settings.filepath = filename;
import_settings.import_units = import_units != 0;
+ import_settings.custom_normals = custom_normals != 0;
import_settings.auto_connect = auto_connect != 0;
import_settings.find_chains = find_chains != 0;
import_settings.fix_orientation = fix_orientation != 0;
@@ -741,6 +744,7 @@ static void uiCollada_importSettings(uiLayout *layout, PointerRNA *imfptr)
uiItemL(box, IFACE_("Import Data Options"), ICON_MESH_DATA);
uiItemR(box, imfptr, "import_units", 0, NULL, ICON_NONE);
+ uiItemR(box, imfptr, "custom_normals", 0, NULL, ICON_NONE);
box = uiLayoutBox(layout);
uiItemL(box, IFACE_("Armature Options"), ICON_ARMATURE_DATA);
@@ -792,6 +796,12 @@ void WM_OT_collada_import(wmOperatorType *ot)
"otherwise use the settings from the Imported scene");
RNA_def_boolean(ot->srna,
+ "custom_normals",
+ 1,
+ "Custom Normals",
+ "Import custom normals, if available (otherwise Blender will compute them)");
+
+ RNA_def_boolean(ot->srna,
"fix_orientation",
0,
"Fix Leaf Bones",