On Thursday, May 30, 2013 12:55:49 AM UTC-3, Claudio Canepa wrote:

> On Tue, May 28, 2013 at 12:09 PM, Gerardo Marset 
> <[email protected]<javascript:>
> > wrote:
>
>> I think there's a bug in tiles.RectMap.get_in_region.
>>
> [...] 
>
> You are right, thanks for the report, analysis and fix suggestion. 
>
 
You're welcome =).


The solution I found is the following:
>> x2 = min(len(self.cells), math.ceil(float(x2 - ox) / self.tw))
>> y2 = min(len(self.cells[0]), math.ceil(float(y2 - oy) / self.th))
>>
>> In this example, the first equation is:
>> 4 for x2 = 8
>> 4 for x2 = 7
>> 3 for x2 = 6
>> 5 for x2 = 8.1
>>
>> Which is perfect if I'm not mistaken.
>>  
>
>
> It works, but instead of 
>      math.ceil(float(x2 - ox) / self.tw) 
> I used
>     (x2 - ox - 1) // self.tw + 1
> which is a bit faster.
>

Well, that's OK but this:

> Caveat: the corner case where the rect is a segment is a bit inconsistent, 
> see [0] for details.
>
bothers me (I take it you are referring to cases like the 8.1 I mentioned 
above?).
If you are concerned about speed, why don't you take these int() calls out 
of the loops and change the range() calls to xrange() calls? If you do 
that, even with my version the method becomes faster. I tested it.
Also it seems you can replace the call to float() in my version for another 
call to math.ceil(), and that makes it slightly faster. No, I'm not even 
kidding.

PD: I will need one or two days to integrate the patch for anisotropic 
> scaling, thanks.
>

Take your time.

-- 
You received this message because you are subscribed to the Google Groups 
"cocos2d discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cocos-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to