diff options
author | Marius Kintel <marius@kintel.net> | 2010-08-28 19:21:44 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2010-10-31 00:42:38 (GMT) |
commit | d0390c41a2268ce23d3010c7085e4365725d2f49 (patch) | |
tree | d3f2e6b0cc58a66ff759740ddcf27191335076aa /src/transform.cc | |
parent | 93f3d4a1b6251523428179261dc070df44b0b317 (diff) |
Added AbstractNode::name(), changed CSGTextRenderer to use this instead of the rtti name
Diffstat (limited to 'src/transform.cc')
-rw-r--r-- | src/transform.cc | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/src/transform.cc b/src/transform.cc index 6b4d926..ccfc1aa 100644 --- a/src/transform.cc +++ b/src/transform.cc @@ -34,6 +34,7 @@ #include "printutils.h" #include "visitor.h" #include <sstream> +#include <assert.h> enum transform_type_e { SCALE, @@ -64,29 +65,33 @@ AbstractNode *TransformModule::evaluate(const Context *ctx, const ModuleInstanti QVector<QString> argnames; QVector<Expression*> argexpr; - if (type == SCALE) { + switch (this->type) { + case SCALE: argnames = QVector<QString>() << "v"; - } - if (type == ROTATE) { + break; + case ROTATE: argnames = QVector<QString>() << "a" << "v"; - } - if (type == MIRROR) { + break; + case MIRROR: argnames = QVector<QString>() << "v"; - } - if (type == TRANSLATE) { + break; + case TRANSLATE: argnames = QVector<QString>() << "v"; - } - if (type == MULTMATRIX) { + break; + case MULTMATRIX: argnames = QVector<QString>() << "m"; - } - if (type == COLOR) { + break; + case COLOR: argnames = QVector<QString>() << "c"; + break; + default: + assert(false); } Context c(ctx); c.args(argnames, argexpr, inst->argnames, inst->argvalues); - if (type == SCALE) + if (this->type == SCALE) { Value v = c.lookup_variable("v"); v.getnum(node->matrix[0]); @@ -96,7 +101,7 @@ AbstractNode *TransformModule::evaluate(const Context *ctx, const ModuleInstanti if (node->matrix[10] <= 0) node->matrix[10] = 1; } - if (type == ROTATE) + else if (this->type == ROTATE) { Value val_a = c.lookup_variable("a"); if (val_a.type == Value::VECTOR) @@ -167,7 +172,7 @@ AbstractNode *TransformModule::evaluate(const Context *ctx, const ModuleInstanti } } } - if (type == MIRROR) + else if (this->type == MIRROR) { Value val_v = c.lookup_variable("v"); double x = 1, y = 0, z = 0; @@ -194,12 +199,12 @@ AbstractNode *TransformModule::evaluate(const Context *ctx, const ModuleInstanti node->matrix[10] = 1-2*z*z; } } - if (type == TRANSLATE) + else if (this->type == TRANSLATE) { Value v = c.lookup_variable("v"); v.getv3(node->matrix[12], node->matrix[13], node->matrix[14]); } - if (type == MULTMATRIX) + else if (this->type == MULTMATRIX) { Value v = c.lookup_variable("m"); if (v.type == Value::VECTOR) { @@ -210,7 +215,7 @@ AbstractNode *TransformModule::evaluate(const Context *ctx, const ModuleInstanti } } } - if (type == COLOR) + else if (this->type == COLOR) { Value v = c.lookup_variable("c"); if (v.type == Value::VECTOR) { @@ -253,6 +258,11 @@ std::string TransformNode::toString() const return stream.str(); } +std::string TransformNode::name() const +{ + return "transform"; +} + void register_builtin_transform() { builtin_modules["scale"] = new TransformModule(SCALE); |