summaryrefslogtreecommitdiffstats
path: root/dimension/realize.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-10-26 19:25:07 -0400
committerTavian Barnes <tavianator@gmail.com>2010-10-26 19:25:07 -0400
commit71b149ad617a7cbca08a2a7cb8ca5e3b0d8143db (patch)
tree9dc0ba264561066a9128292b8ba0d34be424232a /dimension/realize.c
parent3950b4f0d2483cadf006bf2a957aeb820402503a (diff)
downloaddimension-71b149ad617a7cbca08a2a7cb8ca5e3b0d8143db.tar.xz
Add torii to dimension.
Diffstat (limited to 'dimension/realize.c')
-rw-r--r--dimension/realize.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/dimension/realize.c b/dimension/realize.c
index b5f6e50..18de230 100644
--- a/dimension/realize.c
+++ b/dimension/realize.c
@@ -917,6 +917,22 @@ dmnsn_realize_sphere(dmnsn_astnode astnode)
}
static dmnsn_object *
+dmnsn_realize_torus(dmnsn_astnode astnode)
+{
+ dmnsn_assert(astnode.type == DMNSN_AST_TORUS, "Expected a torus.");
+
+ dmnsn_astnode major, minor;
+ dmnsn_array_get(astnode.children, 0, &major);
+ dmnsn_array_get(astnode.children, 1, &minor);
+
+ double R = dmnsn_realize_float(major);
+ double r = dmnsn_realize_float(minor);
+
+ dmnsn_object *torus = dmnsn_new_torus(R, r);
+ return torus;
+}
+
+static dmnsn_object *
dmnsn_realize_plane(dmnsn_astnode astnode)
{
dmnsn_assert(astnode.type == DMNSN_AST_PLANE, "Expected a plane.");
@@ -1064,6 +1080,9 @@ dmnsn_realize_object(dmnsn_astnode astnode, dmnsn_array *lights)
case DMNSN_AST_SPHERE:
object = dmnsn_realize_sphere(onode);
break;
+ case DMNSN_AST_TORUS:
+ object = dmnsn_realize_torus(onode);
+ break;
case DMNSN_AST_UNION:
object = dmnsn_realize_union(onode, modifiers, lights);
break;