Search found 239 matches

by RNavega
Mon Mar 25, 2024 12:00 pm
Forum: Libraries and Tools
Topic: Fast 2D point-in-polygon test
Replies: 13
Views: 11462

Re: Fast 2D point-in-polygon test

I'm not too surprised. In LuaJIT, external function calls via standard Lua (as opposed to via FFI) either prevent compilation, or require trace stitching (meaning, switch to interpreter mode, run the function, switch back to compiled mode and resume), both of which are slow. I already got caught by...
by RNavega
Sun Mar 24, 2024 1:33 pm
Forum: Libraries and Tools
Topic: Fast 2D point-in-polygon test
Replies: 13
Views: 11462

Re: Fast 2D point-in-polygon test

Ehhh, here's something weird. From my tests, that Lua-based method in the OP is slightly faster than the Box2D one. Point for LuaJIT I guess, it's probably optimizing that function amazingly. I honestly thought the C++ one would be faster. point-in-polygon_benchmark.png The code I'm using is this (t...
by RNavega
Sun Mar 24, 2024 3:42 am
Forum: Support and Development
Topic: Weird Mobile Screensize Behavior
Replies: 2
Views: 1009

Re: Weird Mobile Screensize Behavior

Also check love.graphics.getWidth() and love.graphics.getPixelWidth(), in the Window section of the graphics page:
https://love2d.org/wiki/love.graphics#Window
by RNavega
Sun Mar 24, 2024 3:20 am
Forum: Libraries and Tools
Topic: Fast 2D point-in-polygon test
Replies: 13
Views: 11462

Re: Fast 2D point-in-polygon test

Yes, this: https://love2d.org/wiki/Shape:testPoint That's cool dusoft, nice tip. That will rely on the fast C++ Box2D implementation. The testing code seems to be this: https://github.com/love2d/love/blob/main/src/libraries/box2d/collision/b2_polygon_shape.cpp#L250 They're using a facingness test b...
by RNavega
Mon Mar 18, 2024 6:06 am
Forum: General
Topic: Code Doodles!
Replies: 195
Views: 259967

Re: Code Doodles!

roundedRectanglePreview.gif Example of drawing a round-corner rectangle using a pixel shader. While there's the rx,ry parameters of love.graphics.rectangle() that make a rounded rectangle using geometry, in this way it's done by fading the alpha of pixels outside of the rounded corners. io.stdout:s...
by RNavega
Sun Mar 17, 2024 12:32 pm
Forum: General
Topic: Gradients (gradient as fill)
Replies: 10
Views: 1674

Re: Gradients (gradient as fill)

Nice, I see what you're after. Thank you for the images.
by RNavega
Fri Mar 15, 2024 10:57 am
Forum: General
Topic: Gradients (gradient as fill)
Replies: 10
Views: 1674

Re: Gradients (gradient as fill)

dusoft wrote: Tue Mar 12, 2024 4:33 pm Thanks for your suggestions, I will be staying with scaled up overlapping polygons for now.
Hi. How does that overlap thing work, can you describe it?
by RNavega
Sun Mar 10, 2024 8:25 pm
Forum: Support and Development
Topic: Finding which object in the table is closest
Replies: 5
Views: 1236

Re: Finding which object in the table is closest

local closest_dist = 999999 --some arbitrarily large number This reminded me, for this "absurdly large initial value" kind of thing, there's that constant that's loaded by default: math.huge But my favorite is in Python: float("inf") creates a positive infinity value, nothing is...
by RNavega
Sun Mar 10, 2024 3:42 am
Forum: Support and Development
Topic: Method doesn't see self variable when called by other method (hump.class)
Replies: 8
Views: 853

Re: Method doesn't see self variable when called by other method (hump.class)

See https://love2d.org/forums/viewtopic.php?p=231457#p231457 and the next post. Thanks for that reference, very interesting. AFAIK it seems that the JIT compiles "hot paths" / frequently executed code when it hits some specific loop cycle count, the default settings for which can be seen ...
by RNavega
Sat Mar 09, 2024 8:17 pm
Forum: Support and Development
Topic: Method doesn't see self variable when called by other method (hump.class)
Replies: 8
Views: 853

Re: Method doesn't see self variable when called by other method (hump.class)

Is there another one you’d recommend/are using? I think that the mechanism being used to simulate this sort of templating / class inheritance (the __index metamethod from a metatable) is simple enough that you can reimplement it yourself, without the need for an entire library (unless you need the ...