summaryrefslogtreecommitdiffstats
path: root/libdimension/dimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2011-07-26 09:20:06 -0600
committerTavian Barnes <tavianator@gmail.com>2011-07-26 09:21:23 -0600
commit5f8ce1e256462a9addbe318966a70a4bc6399bad (patch)
tree148cc13bb63691d056d82424435df5347d809331 /libdimension/dimension
parente683539695c720e559139ffd58e1786fbb1ea06c (diff)
downloaddimension-5f8ce1e256462a9addbe318966a70a4bc6399bad.tar.xz
Support multiple texture assignment properly.
Diffstat (limited to 'libdimension/dimension')
-rw-r--r--libdimension/dimension/object.h21
1 files changed, 13 insertions, 8 deletions
diff --git a/libdimension/dimension/object.h b/libdimension/dimension/object.h
index 24e1bcb..673c8bc 100644
--- a/libdimension/dimension/object.h
+++ b/libdimension/dimension/object.h
@@ -25,6 +25,9 @@
#include <stdbool.h>
+/* Forward-declare dmnsn_object */
+typedef struct dmnsn_object dmnsn_object;
+
/** A type to represent a ray-object intersection. */
typedef struct dmnsn_intersection {
dmnsn_line ray; /**< The ray that intersected. */
@@ -33,15 +36,10 @@ typedef struct dmnsn_intersection {
/** The surface normal at the intersection point. */
dmnsn_vector normal;
- /** The texture at the intersection point. */
- const dmnsn_texture *texture;
- /** The interior at the intersection point. */
- const dmnsn_interior *interior;
+ /** The object of intersection. */
+ const dmnsn_object *object;
} dmnsn_intersection;
-/* Forward-declare dmnsn_object */
-typedef struct dmnsn_object dmnsn_object;
-
/**
* Object initialization callback.
* @param[in,out] object The object to initialize.
@@ -74,8 +72,10 @@ struct dmnsn_object {
dmnsn_texture *texture; /**< Surface properties. */
dmnsn_interior *interior; /**< Interior properties. */
- dmnsn_matrix trans; /**< Transformation matrix. */
+ dmnsn_matrix trans; /**< Transformation matrix. */
dmnsn_matrix trans_inv; /**< Inverse of the transformation matrix. */
+ dmnsn_matrix intrinsic_trans; /**< Transformations not affecting the texture. */
+ dmnsn_matrix pigment_trans; /**< Inverse transformation for the texture. */
dmnsn_bounding_box bounding_box; /**< Object bounding box. */
@@ -141,11 +141,16 @@ dmnsn_object_intersection(const dmnsn_object *object, dmnsn_line line,
dmnsn_intersection *intersection)
{
dmnsn_line line_trans = dmnsn_transform_line(object->trans_inv, line);
+ intersection->object = NULL;
if (object->intersection_fn(object, line_trans, intersection)) {
/* Get us back into world coordinates */
intersection->ray = line;
intersection->normal = dmnsn_transform_normal(object->trans,
intersection->normal);
+ if (!intersection->object) {
+ intersection->object = object;
+ }
+
return true;
} else {
return false;