diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-05-03 22:24:35 -0600 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-05-03 22:24:35 -0600 |
commit | 3a4da35d5c52d13a5353c6779213505aa862b371 (patch) | |
tree | 4c06d711ab168e8ed038b2d64cf7addacc003d35 | |
parent | c50dfa559693664b707ca83a67da268e9959a8e4 (diff) | |
download | dimension-3a4da35d5c52d13a5353c6779213505aa862b371.tar.xz |
Don't apply the transformations which create an object to its textures.
For example, sphere { 0, 2 } would scale the texture by a factor of 2.
-rw-r--r-- | dimension/realize.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/dimension/realize.c b/dimension/realize.c index aa019ed..6771782 100644 --- a/dimension/realize.c +++ b/dimension/realize.c @@ -684,6 +684,9 @@ dmnsn_realize_object_modifiers(dmnsn_astnode astnode, dmnsn_object *object) dmnsn_assert(astnode.type == DMNSN_AST_OBJECT_MODIFIERS, "Expected object modifiers."); + /* Save the pre-existing transformations */ + dmnsn_matrix existing_trans = dmnsn_matrix_inverse(object->trans); + unsigned int i; for (i = 0; i < dmnsn_array_size(astnode.children); ++i) { dmnsn_astnode modifier; @@ -725,6 +728,16 @@ dmnsn_realize_object_modifiers(dmnsn_astnode astnode, dmnsn_object *object) dmnsn_assert(false, "Invalid object modifier."); } } + + if (object->texture) { + /* Right-multiply to counteract any pre-existing transformations -- this + means, for example, that the transformation that makes a sphere have + radius 2 doesn't scale the texture by a factor of 2 */ + object->texture->trans = dmnsn_matrix_mul( + object->texture->trans, + existing_trans + ); + } } static void |