adonthell-devel
[Top][All Lists]
Advanced

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

Re: [Adonthell-devel] Shadow on the stairs.


From: Kai Sterker
Subject: Re: [Adonthell-devel] Shadow on the stairs.
Date: Mon, 29 Mar 2010 12:08:42 +0200

On Mon, Mar 29, 2010 at 1:43 AM, Tyler Nielsen <address@hidden> wrote:

> So I came up with a change to sort of fix the shadow on the stairs.  I'm
> attaching it instead of pushing it because it is a pretty big hack.  One
> problem with it, I assume because of some Z sorting, the shadow shows on top
> of the character.  Another problem, I'm not sure that this is the correct
> place for it.  I assumed that shadow::cast_on would get called for each
> stair in the staircase, but it doesn't.

Yeah, the problem is that the shadow is attached to the placeable as a
whole, not to the individual parts/shapes of a placeable. (It's that
way, because a placeable instance will appear on the map more than
once).


> The good news is, if this is the
> correct place for it, then I think making the shadow work on the original
> stairs shouldn't be too hard.

I'm wondering if the calculations could be somehow done in
shadow_cast::on. There the shadow is already cropped to the placeables
size. It might be possible to split it further for the individual
parts of the placeable. That way, the calculation would not occur for
every frame that is rendered, only when a character moves and its
shadow changes. I think the different parts of the shadow can still be
stored in shadow_info, provided we replace its Distance member with a
list of distances, one for each part of the shadow that needs to be
rendered.

So, after the current code in shadow::cast_on has assigned a list of
shadow areas to the object, you take that list (shadow_info::Areas)
again and split the areas according to the underlying shapes. I assume
that refactoring the shadow class a bit would allow for some nice
code-reuse as you essentially do the operation of breaking down the
shadow into smaller pieces twice.


> Other more caveat on the code:  I assume there is a function that returns
> the intersection of two squares, but I couldn't find it.

That would be

  gfx::drawing_area::setup_rects ()

If you have two drawing area A and B, you can do

  A.assign_drawing_area (&B);
  C = A.setup_rects();

and you will have the intersection of A and B stored in C. By
assigning another area to B beforehand, you can get the intersection
of all three areas, etc. pp.

But if you do the code in shadow::cast_on, you might not even need it,
since shadow::subtract_area does the splitting for you.

Kai




reply via email to

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