[clutter] paint-volumes: remove alignment constraint for completion
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] paint-volumes: remove alignment constraint for completion
- Date: Thu, 16 Jun 2011 11:58:30 +0000 (UTC)
commit a9789616b9705e7c24b5591a1790dfc2fdda51dc
Author: Robert Bragg <robert linux intel com>
Date: Thu Jun 16 12:19:49 2011 +0100
paint-volumes: remove alignment constraint for completion
This removes the constraint that a paint-volume must be axis aligned
before _clutter_paint_volume_complete can be called. NB: A paint volume
is represented by one origin vertex and then three axis vertices to
define the width, height and depth of the volume. It's straightforward
to use the vectors from the origin to the axis vertices to deduce the
other 4 vertices so we can remove the is_axis_aligned assertion.
clutter/clutter-paint-volume.c | 42 +++++++++++++++++++++++++--------------
1 files changed, 27 insertions(+), 15 deletions(-)
---
diff --git a/clutter/clutter-paint-volume.c b/clutter/clutter-paint-volume.c
index 5eea61b..3680fb4 100644
--- a/clutter/clutter-paint-volume.c
+++ b/clutter/clutter-paint-volume.c
@@ -549,33 +549,45 @@ done:
void
_clutter_paint_volume_complete (ClutterPaintVolume *pv)
{
- if (pv->is_complete || pv->is_empty)
+ float dx_l2r, dy_l2r, dz_l2r;
+ float dx_t2b, dy_t2b, dz_t2b;
+
+ if (pv->is_empty)
return;
- /* TODO: it is possible to complete non axis aligned volumes too. */
- g_return_if_fail (pv->is_axis_aligned);
+ /* Find the vector that takes us from any vertex on the left face to
+ * the corresponding vertex on the right face. */
+ dx_l2r = pv->vertices[1].x - pv->vertices[0].x;
+ dy_l2r = pv->vertices[1].y - pv->vertices[0].y;
+ dz_l2r = pv->vertices[1].z - pv->vertices[0].z;
+
+ /* Find the vector that takes us from any vertex on the top face to
+ * the corresponding vertex on the bottom face. */
+ dx_t2b = pv->vertices[3].x - pv->vertices[0].x;
+ dy_t2b = pv->vertices[3].y - pv->vertices[0].y;
+ dz_t2b = pv->vertices[3].z - pv->vertices[0].z;
/* front-bottom-right */
- pv->vertices[2].x = pv->vertices[1].x;
- pv->vertices[2].y = pv->vertices[3].y;
- pv->vertices[2].z = pv->vertices[0].z;
+ pv->vertices[2].x = pv->vertices[3].x + dx_l2r;
+ pv->vertices[2].y = pv->vertices[3].y + dy_l2r;
+ pv->vertices[2].z = pv->vertices[3].z + dz_l2r;
if (G_UNLIKELY (!pv->is_2d))
{
/* back-top-right */
- pv->vertices[5].x = pv->vertices[1].x;
- pv->vertices[5].y = pv->vertices[0].y;
- pv->vertices[5].z = pv->vertices[4].z;
+ pv->vertices[5].x = pv->vertices[4].x + dx_l2r;
+ pv->vertices[5].y = pv->vertices[4].y + dy_l2r;
+ pv->vertices[5].z = pv->vertices[4].z + dz_l2r;
/* back-bottom-right */
- pv->vertices[6].x = pv->vertices[1].x;
- pv->vertices[6].y = pv->vertices[3].y;
- pv->vertices[6].z = pv->vertices[4].z;
+ pv->vertices[6].x = pv->vertices[5].x + dx_t2b;
+ pv->vertices[6].y = pv->vertices[5].y + dy_t2b;
+ pv->vertices[6].z = pv->vertices[5].z + dz_t2b;
/* back-bottom-left */
- pv->vertices[7].x = pv->vertices[0].x;
- pv->vertices[7].y = pv->vertices[3].y;
- pv->vertices[7].z = pv->vertices[4].z;
+ pv->vertices[7].x = pv->vertices[4].x + dx_t2b;
+ pv->vertices[7].y = pv->vertices[4].y + dy_t2b;
+ pv->vertices[7].z = pv->vertices[4].z + dz_t2b;
}
pv->is_complete = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]