diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-02-25 02:10:26 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-02-25 02:10:26 -0500 |
commit | a893d72c2caf3b8dc457115f6409b6bf66a5adbc (patch) | |
tree | 2f54bd0774cf91189be2f7afd7ae1a8fd8c9c113 /dimension/realize.c | |
parent | 21794278ae305acd5dc13d0cd6a491f420b69880 (diff) | |
download | dimension-a893d72c2caf3b8dc457115f6409b6bf66a5adbc.tar.xz |
Parse interiors.
Diffstat (limited to 'dimension/realize.c')
-rw-r--r-- | dimension/realize.c | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/dimension/realize.c b/dimension/realize.c index 810d86e..b20ec9f 100644 --- a/dimension/realize.c +++ b/dimension/realize.c @@ -504,18 +504,18 @@ dmnsn_realize_texture(dmnsn_astnode astnode) unsigned int i; for (i = 0; i < dmnsn_array_size(astnode.children); ++i) { - dmnsn_astnode modifier; - dmnsn_array_get(astnode.children, i, &modifier); + dmnsn_astnode item; + dmnsn_array_get(astnode.children, i, &item); - switch (modifier.type) { + switch (item.type) { case DMNSN_AST_PIGMENT: dmnsn_delete_pigment(texture->pigment); - texture->pigment = dmnsn_realize_pigment(modifier); + texture->pigment = dmnsn_realize_pigment(item); break; case DMNSN_AST_FINISH: dmnsn_delete_finish(texture->finish); - texture->finish = dmnsn_realize_finish(modifier); + texture->finish = dmnsn_realize_finish(item); break; default: @@ -526,6 +526,35 @@ dmnsn_realize_texture(dmnsn_astnode astnode) return texture; } +static dmnsn_interior * +dmnsn_realize_interior(dmnsn_astnode astnode) +{ + dmnsn_assert(astnode.type == DMNSN_AST_INTERIOR, "Expected a texture."); + + dmnsn_interior *interior = dmnsn_new_interior(); + if (!interior) { + dmnsn_error(DMNSN_SEVERITY_HIGH, "Couldn't allocate interior."); + } + + unsigned int i; + for (i = 0; i < dmnsn_array_size(astnode.children); ++i) { + dmnsn_astnode item, child; + dmnsn_array_get(astnode.children, i, &item); + + switch (item.type) { + case DMNSN_AST_IOR: + dmnsn_array_get(item.children, 0, &child); + interior->ior = dmnsn_realize_float(child); + break; + + default: + dmnsn_assert(false, "Invalid interior item."); + } + } + + return interior; +} + static void dmnsn_realize_object_modifiers(dmnsn_astnode astnode, dmnsn_object *object) { @@ -562,6 +591,11 @@ dmnsn_realize_object_modifiers(dmnsn_astnode astnode, dmnsn_object *object) object->texture = dmnsn_realize_texture(modifier); break; + case DMNSN_AST_INTERIOR: + dmnsn_delete_interior(object->interior); + object->interior = dmnsn_realize_interior(modifier); + break; + default: dmnsn_assert(false, "Invalid object modifier."); } |