[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re[2]: [Gnash-dev] does _height work??

From: strk
Subject: Re: Re[2]: [Gnash-dev] does _height work??
Date: Wed, 11 Oct 2006 15:25:33 +0200

On Wed, Oct 11, 2006 at 12:39:05PM +0100, Martin Guy wrote:
> >Talking about the original question, would it be correct
> >to change the code like this:
> >
> >    virtual float       get_height() const
> >        {
> >            matrix      m = get_world_matrix();
> >-           float       h = m_def->get_height_local() * m.m_[1][1];
> >+           float       h = m_def->get_height_local() * m.get_y_scale();
> >            return h;
> >        }
> erm, without knowing what it means by "height" in this context I can't
> say, and what m_def is, and what information it's trying to create.
> Out of context I have no way of knowing.

I belive get_height_local() gives "relative" height and get_world_matrix
gives a concatenated transform matrix that takes into account transofrmation
matrices of all parents up to the top.

> >matrix::get_y_scale is implemented like:
> >
> >        return sqrtf(m_[1][1] * m_[1][1] + m_[1][0] * m_[1][0]);
> Is this ehat it does already, or what you are proposing?

Current implementation.

> In any case I would think that scaling without rotation and rotation
> without scaling are very common cases, and mul and sqrt are very slow,
> so better
> if (m_[1][0]==0) return fabsf(m_[1][1]);
> if (m_[1][1]==0) return fabsf(m_[1][0]);
> return sqrtf(m_[1][1] * m_[1][1] + m_[1][0] * m_[1][0]);
> ... or some hairy combination of ? and :  but the compiler should
> optimise the ifs to the same thing in any case. fabsf in case they are
> negative...

Good suggestion, anyway we're aimed at corectness now, more then
performance. I just committed a MatrixTest.cpp file in CVS, so
we can as well add the optimization as far as we have some tests 
for that function. I'm currently stuck at construction (ie: how
to create, in the MatrixTest.cpp file, a matrix with a specific 
scale - w/out manually touching the matrix values, that is)

> >BTW, matrix::get_x_scale contains an additional check:
> >
> >        // Are we turned inside out?
> >        if (get_determinant() < 0.f)
> >        {
> >                scale = -scale;
> >        }
> >
> >Should it also apply to get_y_scale ?
> I would have thought so, but can't be sure without poring over that
> specific code to know what it is trying to achieve, and what the value
> in "scale" is supposed to mean.

Good question... I'm not sure myself, we really need to add those docs.
>From a quick look at the code it's related to what's returned by _scale
fetching from actionscript, not sure about how this relates to rotation


reply via email to

[Prev in Thread] Current Thread [Next in Thread]