diff options
author | Marius Kintel <marius@kintel.net> | 2011-04-07 22:36:13 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2011-04-07 22:36:13 (GMT) |
commit | 496cc66cf253b805db73c4ce39fc477591f2c60e (patch) | |
tree | 6b7a7f93b3754723da19ba6b69f92f0ffe4bc0ea /src/primitives.cc | |
parent | 53d0b594700cbdcf43f7f5e2706680dc0bf85b97 (diff) |
Bugfix: Clamp and to 0.01 to fix a crash
Diffstat (limited to 'src/primitives.cc')
-rw-r--r-- | src/primitives.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/primitives.cc b/src/primitives.cc index d0cd1b5..5ba32fe 100644 --- a/src/primitives.cc +++ b/src/primitives.cc @@ -57,6 +57,7 @@ class PrimitiveNode : public AbstractPolyNode public: bool center; double x, y, z, h, r1, r2; + static const double F_MINIMUM = 0.01; double fn, fs, fa; primitive_type_e type; int convexity; @@ -105,6 +106,16 @@ AbstractNode *PrimitiveModule::evaluate(const Context *ctx, const ModuleInstanti node->fs = c.lookup_variable("$fs").num; node->fa = c.lookup_variable("$fa").num; + if (node->fs < PrimitiveNode::F_MINIMUM) { + PRINTF("WARNING: $fs too small - clamping to %f", PrimitiveNode::F_MINIMUM); + node->fs = PrimitiveNode::F_MINIMUM; + } + if (node->fa < PrimitiveNode::F_MINIMUM) { + PRINTF("WARNING: $fa too small - clamping to %f", PrimitiveNode::F_MINIMUM); + node->fa = PrimitiveNode::F_MINIMUM; + } + + if (type == CUBE) { Value size = c.lookup_variable("size"); Value center = c.lookup_variable("center"); |