I just started looking at Love and trying out this Leif library. I was browsing the code, not very thoroughly, and I happened to look at a function in leif.lua called getPanelAt, which is used for determining what panel was clicked on. I noticed 2 things about it:
1. The function checks all the children of a panel first before allowing the parent to claim the click. This is good, because children should exist in front of the parent. But it seems to me that if you first check to see whether the point in question is geometrically inside of the parent, before checking children, then much less checking of children would occur, and recursively and so on and the function would be much less expensive.
2. The function checks children in the same order in which they are drawn. Child objects drawn first appear to be on the bottom and child objects drawn last appear to be on top. Therefore, it would seem to me that if overlap is possible, you would want to check the children in the reverse of the order in which they are drawn.
I have only spent a few minutes looking at the code, so I probably missed or misinterpreted something.
getPanelAt observations
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: getPanelAt observations
That's all right and all, but shouldn't this go under the Leif thread?
Help us help you: attach a .love.
Re: getPanelAt observations
Sorry about the extremely late reply. I don't read these forums anymore.
1. Okay.
2. Actually, leif.drawPanel uses leif.npairs, which is the opposite of ipairs.
The _children table actually has the top-most panel at the index 1, so ipairs checks from the top-most to bottom-most.
1. Okay.
2. Actually, leif.drawPanel uses leif.npairs, which is the opposite of ipairs.
The _children table actually has the top-most panel at the index 1, so ipairs checks from the top-most to bottom-most.
Who is online
Users browsing this forum: Ahrefs [Bot] and 195 guests