diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-05-31 11:39:36 -0600 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-05-31 11:39:36 -0600 |
commit | 8863129c6e7e57b7c4ca3fce5fece9aae8a9b7b7 (patch) | |
tree | 2f840bdd7301d50975edd3003d8044d5a8b913bf /libdimension/object.c | |
parent | 1b2a77ba356407268b078062fa9ab4ff9853d348 (diff) | |
download | dimension-8863129c6e7e57b7c4ca3fce5fece9aae8a9b7b7.tar.xz |
Add precompute callback to objects.
Diffstat (limited to 'libdimension/object.c')
-rw-r--r-- | libdimension/object.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libdimension/object.c b/libdimension/object.c index 9074d60..acc0163 100644 --- a/libdimension/object.c +++ b/libdimension/object.c @@ -37,10 +37,11 @@ dmnsn_object * dmnsn_new_object() { dmnsn_object *object = dmnsn_malloc(sizeof(dmnsn_object)); - object->texture = NULL; - object->interior = NULL; - object->trans = dmnsn_identity_matrix(); - object->free_fn = NULL; + object->texture = NULL; + object->interior = NULL; + object->trans = dmnsn_identity_matrix(); + object->precompute_fn = NULL; + object->free_fn = NULL; return object; } @@ -62,9 +63,14 @@ dmnsn_delete_object(dmnsn_object *object) void dmnsn_object_precompute(dmnsn_object *object) { + if (object->precompute_fn) { + (*object->precompute_fn)(object); + } + object->bounding_box = dmnsn_transform_bounding_box(object->trans, object->bounding_box); object->trans_inv = dmnsn_matrix_inverse(object->trans); + if (object->texture) { object->texture->trans = dmnsn_matrix_mul(object->trans, object->texture->trans); |