BabeDead python fix

This commit is contained in:
Jack Andersen 2016-03-27 11:02:38 -10:00
parent 182f519158
commit a066c66e5b
1 changed files with 8 additions and 3 deletions

View File

@ -3,6 +3,7 @@
#include "BlenderConnection.hpp" #include "BlenderConnection.hpp"
#include "zeus/Math.hpp" #include "zeus/Math.hpp"
#include <cfloat>
namespace DataSpec namespace DataSpec
{ {
@ -50,6 +51,7 @@ void ReadBabeDeadLightToBlender(hecl::BlenderConnection::PyOutStream& os,
os.format("lamp.retro_layer = %u\n" os.format("lamp.retro_layer = %u\n"
"lamp.retro_origtype = %u\n" "lamp.retro_origtype = %u\n"
"lamp.falloff_type = 'INVERSE_COEFFICIENTS'\n" "lamp.falloff_type = 'INVERSE_COEFFICIENTS'\n"
"lamp.constant_coefficient = 0\n"
"lamp.use_nodes = True\n" "lamp.use_nodes = True\n"
"falloff_node = lamp.node_tree.nodes.new('ShaderNodeLightFalloff')\n" "falloff_node = lamp.node_tree.nodes.new('ShaderNodeLightFalloff')\n"
"lamp.energy = 0.0\n" "lamp.energy = 0.0\n"
@ -69,15 +71,18 @@ void ReadBabeDeadLightToBlender(hecl::BlenderConnection::PyOutStream& os,
case BabeDeadLight::Falloff::Constant: case BabeDeadLight::Falloff::Constant:
os << "falloff_node.inputs[0].default_value *= 75.0\n" os << "falloff_node.inputs[0].default_value *= 75.0\n"
"lamp.node_tree.links.new(falloff_node.outputs[2], lamp.node_tree.nodes['Emission'].inputs[1])\n"; "lamp.node_tree.links.new(falloff_node.outputs[2], lamp.node_tree.nodes['Emission'].inputs[1])\n";
os.format("lamp.constant_coefficient = 2.0 / %f\n", light.q); if (light.q > FLT_EPSILON)
os.format("lamp.constant_coefficient = 2.0 / %f\n", light.q);
break; break;
case BabeDeadLight::Falloff::Linear: case BabeDeadLight::Falloff::Linear:
os << "lamp.node_tree.links.new(falloff_node.outputs[1], lamp.node_tree.nodes['Emission'].inputs[1])\n"; os << "lamp.node_tree.links.new(falloff_node.outputs[1], lamp.node_tree.nodes['Emission'].inputs[1])\n";
os.format("lamp.linear_coefficient = 250 / %f\n", light.q); if (light.q > FLT_EPSILON)
os.format("lamp.linear_coefficient = 250 / %f\n", light.q);
break; break;
case BabeDeadLight::Falloff::Quadratic: case BabeDeadLight::Falloff::Quadratic:
os << "lamp.node_tree.links.new(falloff_node.outputs[0], lamp.node_tree.nodes['Emission'].inputs[1])\n"; os << "lamp.node_tree.links.new(falloff_node.outputs[0], lamp.node_tree.nodes['Emission'].inputs[1])\n";
os.format("lamp.quadratic_coefficient = 25000 / %f\n", light.q); if (light.q > FLT_EPSILON)
os.format("lamp.quadratic_coefficient = 25000 / %f\n", light.q);
break; break;
default: break; default: break;
} }