actor: review use of _apply_modelview_transform_recursive

On reviewing the clutter-actor.c code using
_apply_modelview_transform_recursive I noticed various comments stating
that it will never call the stage's ->apply_transform vfunc to transform
into eye coordinates, but actually looking at the implementation that's
not true. The comments probably got out of sync with an earlier
implementation that had that constraint. This removes the miss-leading
comments and also updates various uses of the api where we were manually
applying the stage->apply_transform.
This commit is contained in:
Robert Bragg 2011-06-17 17:44:16 +01:00
parent ddc9eb5fa5
commit 1720b77d29
3 changed files with 7 additions and 63 deletions

View File

@ -2039,10 +2039,6 @@ _clutter_actor_fully_transform_vertices (ClutterActor *self,
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE); g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE);
/* NB: _clutter_actor_apply_modelview_transform_recursive will never
* include the transformation between stage coordinates and OpenGL
* eye coordinates, we have to explicitly use the
* stage->apply_transform to get that... */
stage = _clutter_actor_get_stage_internal (self); stage = _clutter_actor_get_stage_internal (self);
/* We really can't do anything meaningful in this case so don't try /* We really can't do anything meaningful in this case so don't try
@ -2050,10 +2046,10 @@ _clutter_actor_fully_transform_vertices (ClutterActor *self,
if (stage == NULL) if (stage == NULL)
return FALSE; return FALSE;
/* Setup the modelview */ /* Note: we pass NULL as the ancestor because we don't just want the modelview
cogl_matrix_init_identity (&modelview); * that gets us to stage coordinates, we want to go all the way to eye
_clutter_actor_apply_modelview_transform (stage, &modelview); * coordinates */
_clutter_actor_apply_modelview_transform_recursive (self, stage, &modelview); _clutter_actor_apply_modelview_transform_recursive (self, NULL, &modelview);
/* Fetch the projection and viewport */ /* Fetch the projection and viewport */
_clutter_stage_get_projection_matrix (CLUTTER_STAGE (stage), &projection); _clutter_stage_get_projection_matrix (CLUTTER_STAGE (stage), &projection);
@ -2098,21 +2094,7 @@ clutter_actor_apply_transform_to_point (ClutterActor *self,
/* _clutter_actor_get_relative_modelview: /* _clutter_actor_get_relative_modelview:
* *
* Retrieves the modelview transformation relative to some ancestor * Retrieves the modelview transformation relative to some ancestor
* actor, or the stage if NULL is given for the ancestor. * actor, or eye coordinates if NULL is given for the ancestor.
*
* Note: This will never include the transformations from
* stage::apply_transform since that would give you a modelview
* transform relative to the OpenGL window coordinate space that the
* stage lies within.
*
* If you need to do a full modelview + projective transform and get
* to window coordinates then you should explicitly apply the stage
* transform to an identity matrix and use
* _clutter_actor_apply_modelview_transform like:
*
* cogl_matrix_init_identity (&mtx);
* stage = _clutter_actor_get_stage_internal (self);
* _clutter_actor_apply_modelview_transform (stage, &mtx);
*/ */
/* FIXME: We should be caching the stage relative modelview along with the /* FIXME: We should be caching the stage relative modelview along with the
* actor itself */ * actor itself */
@ -2121,8 +2103,6 @@ _clutter_actor_get_relative_modelview (ClutterActor *self,
ClutterActor *ancestor, ClutterActor *ancestor,
CoglMatrix *matrix) CoglMatrix *matrix)
{ {
g_return_if_fail (ancestor != NULL);
cogl_matrix_init_identity (matrix); cogl_matrix_init_identity (matrix);
_clutter_actor_apply_modelview_transform_recursive (self, ancestor, matrix); _clutter_actor_apply_modelview_transform_recursive (self, ancestor, matrix);

View File

@ -1004,21 +1004,12 @@ _clutter_paint_volume_get_stage_paint_box (ClutterPaintVolume *pv,
_clutter_paint_volume_copy_static (pv, &projected_pv); _clutter_paint_volume_copy_static (pv, &projected_pv);
/* NB: _clutter_actor_apply_modelview_transform_recursive will never
* include the transformation between stage coordinates and OpenGL
* eye coordinates, we have to explicitly use the
* stage->apply_transform to get that... */
cogl_matrix_init_identity (&modelview); cogl_matrix_init_identity (&modelview);
/* If the paint volume isn't already in eye coordinates... */ /* If the paint volume isn't already in eye coordinates... */
if (pv->actor) if (pv->actor)
{ _clutter_actor_apply_modelview_transform_recursive (pv->actor, NULL,
ClutterActor *stage_actor = CLUTTER_ACTOR (stage);
_clutter_actor_apply_modelview_transform (stage_actor, &modelview);
_clutter_actor_apply_modelview_transform_recursive (pv->actor,
stage_actor,
&modelview); &modelview);
}
_clutter_stage_get_projection_matrix (stage, &projection); _clutter_stage_get_projection_matrix (stage, &projection);
_clutter_stage_get_viewport (stage, _clutter_stage_get_viewport (stage,
@ -1052,25 +1043,6 @@ _clutter_paint_volume_transform_relative (ClutterPaintVolume *pv,
_clutter_paint_volume_set_reference_actor (pv, relative_to_ancestor); _clutter_paint_volume_set_reference_actor (pv, relative_to_ancestor);
cogl_matrix_init_identity (&matrix); cogl_matrix_init_identity (&matrix);
if (relative_to_ancestor == NULL)
{
/* NB: _clutter_actor_apply_modelview_transform_recursive will never
* include the transformation between stage coordinates and OpenGL
* eye coordinates, we have to explicitly use the
* stage->apply_transform to get that... */
ClutterActor *stage = _clutter_actor_get_stage_internal (actor);
/* We really can't do anything meaningful in this case so don't try
* to do any transform */
if (G_UNLIKELY (stage == NULL))
return;
_clutter_actor_apply_modelview_transform (stage, &matrix);
relative_to_ancestor = stage;
}
_clutter_actor_apply_modelview_transform_recursive (actor, _clutter_actor_apply_modelview_transform_recursive (actor,
relative_to_ancestor, relative_to_ancestor,
&matrix); &matrix);

View File

@ -530,15 +530,7 @@ update_fbo (ClutterActor *self)
if ((source_parent = clutter_actor_get_parent (priv->fbo_source))) if ((source_parent = clutter_actor_get_parent (priv->fbo_source)))
{ {
CoglMatrix modelview; CoglMatrix modelview;
/* NB: _clutter_actor_apply_modelview_transform_recursive
* will never include the transformation between stage
* coordinates and OpenGL window coordinates, we have to
* explicitly use the stage->apply_transform to get that...
*/
cogl_matrix_init_identity (&modelview); cogl_matrix_init_identity (&modelview);
_clutter_actor_apply_modelview_transform (stage, &modelview);
_clutter_actor_apply_modelview_transform_recursive (source_parent, _clutter_actor_apply_modelview_transform_recursive (source_parent,
NULL, NULL,
&modelview); &modelview);