From 1b0ecb2f891e256eabea9f71575aea207fbee08f Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Mon, 17 May 2021 20:04:56 +0200 Subject: refactor: minor changes to previous commit - rename boolean is_zero by more descriptive has_specularity - add some clarifying comments (and TODO) --- source/blender/io/collada/Materials.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'source/blender/io/collada') diff --git a/source/blender/io/collada/Materials.cpp b/source/blender/io/collada/Materials.cpp index 508844de042..4b90e459e61 100644 --- a/source/blender/io/collada/Materials.cpp +++ b/source/blender/io/collada/Materials.cpp @@ -376,13 +376,13 @@ void MaterialNode::set_opacity(COLLADAFW::ColorOrTexture &cot) void MaterialNode::set_specular(COLLADAFW::ColorOrTexture &cot) { - bool is_zero = false; + bool has_specularity = true; int locy = -300 * (node_map.size() - 2); if (cot.isColor()) { COLLADAFW::Color col = cot.getColor(); if (col.getRed() == 0 && col.getGreen() == 0 && col.getBlue() == 0) { - is_zero = true; + has_specularity = false; } else { bNode *node = add_node(SH_NODE_RGB, -300, locy, "Specular"); @@ -390,17 +390,21 @@ void MaterialNode::set_specular(COLLADAFW::ColorOrTexture &cot) /* TODO: Connect node */ } } - /* texture */ else if (cot.isTexture()) { add_texture_node(cot, -300, locy, "Specular"); /* TODO: Connect node */ } - /* not specified (no specular term) */ else { - is_zero = true; + /* no specular term) */ + has_specularity = false; } - if (is_zero) { + if (!has_specularity) { + /* If specularity is black or not defined reset the Specular value to 0 + TODO: This is a solution only for a corner case. We must find a better + way to handle specularity in general. Also note that currently we + do not export specularity values, see EffectExporter::operator() + */ bNodeSocket *socket = nodeFindSocket(shader_node, SOCK_IN, "Specular"); ((bNodeSocketValueFloat *)socket->default_value)->value = 0.0f; } -- cgit v1.2.3