Follow-up Comment #9, patch #1141 (project wesnoth):
I've attached a slightly more correct patch... still no comments, sorry, I'll
get to them this weekend at the latest...
The std::unique call should be fine. First, two events will only be equal if
the rectangles that they are from are equal. Second, if unique removes a left
event, it will remove a matching right event (and vice versa). These are both
due to the fact that sort and unique use all of the fields in the event
struct (x, y, w, h, in).
I've tried rewriting the inserts to be done in one call and I find it less
readable. It may be worth it for the speed gain...
As far as the =prev->x assignments, those should be fine too. First note that
x here should probably be renamed to left as it is the x value of the left
edge of this segment. The idea is that the height of a segment is defined by
the iterator above and below it, so when we insert iterators, each of lower
and upper could split a segment in two. In this case, we want to maintain the
count and left edge of the segment that was already there. It's possible that
the count is 0 (if the iterator is just the placeholder at the top of a
segment) and in that case we want to use the current x value (if we didn't do
this then we could get what you describe where a segment's left edge is
farther left than it should be). We are basically only merging segments
horizontally, which is precisely what we want.
I don't see what you do about pushing rectangles past the current event
column.
As far as comments, yes it definitely needs them there is a lot of stuff
going on here, some of which is subtle and easy to get wrong. For example,
the sort order of events should be such that "in" events come before "out"
events so that we naturally merge horizontally adjacent rectangles... I got
that comparison wrong :).
(file #5718)
_______________________________________________________
Additional Item Attachment:
File name: sweep3.patch Size:4 KB
_______________________________________________________
Reply to this item at:
<http://gna.org/patch/?1141>
_______________________________________________
Message sent via/by Gna!
http://gna.org/
_______________________________________________
Wesnoth-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-bugs