introduced ScaleScalarNode() node type to avoid evaluating expression multiple times
git-svn-id: svn://anubis/fart/branches/scene-file-scripting@327 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
741ca57e11
commit
cd2f565df3
@ -325,6 +325,22 @@ class ScaleBlockNode : public ScaleNode
|
|||||||
bool isTransformBlock() { return true; }
|
bool isTransformBlock() { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ScaleScalarNode : public Node
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ScaleScalarNode(refptr<Node> expr)
|
||||||
|
: m_expr(expr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
refptr<Vector> getVector()
|
||||||
|
{
|
||||||
|
double x = m_expr->getNumber();
|
||||||
|
return new Vector(x, x, x);
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
refptr<Node> m_expr;
|
||||||
|
};
|
||||||
|
|
||||||
class SceneNode : public Node
|
class SceneNode : public Node
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
@ -365,7 +365,7 @@ offset_items: /* empty */
|
|||||||
;
|
;
|
||||||
|
|
||||||
offset_item: SCALE expression {
|
offset_item: SCALE expression {
|
||||||
$$ = new ScaleNode(new VectorNode($2, $2, $2));
|
$$ = new ScaleNode(new ScaleScalarNode($2));
|
||||||
}
|
}
|
||||||
| SCALE vector2 {
|
| SCALE vector2 {
|
||||||
$$ = new ScaleNode($2);
|
$$ = new ScaleNode($2);
|
||||||
@ -542,7 +542,7 @@ transform: TRANSLATE vector3 {
|
|||||||
$$ = new ScaleNode($2);
|
$$ = new ScaleNode($2);
|
||||||
}
|
}
|
||||||
| SCALE expression {
|
| SCALE expression {
|
||||||
$$ = new ScaleNode(new VectorNode($2, $2, $2));
|
$$ = new ScaleNode(new ScaleScalarNode($2));
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -559,7 +559,7 @@ transform_block: TRANSLATE vector3 LCURLY general_items RCURLY {
|
|||||||
$$->addChildren($4);
|
$$->addChildren($4);
|
||||||
}
|
}
|
||||||
| SCALE expression LCURLY general_items RCURLY {
|
| SCALE expression LCURLY general_items RCURLY {
|
||||||
$$ = new ScaleBlockNode(new VectorNode($2, $2, $2));
|
$$ = new ScaleBlockNode(new ScaleScalarNode($2));
|
||||||
$$->addChildren($4);
|
$$->addChildren($4);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user