SAT with concave/complex polygon for collision response

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
dusoft
Party member
Posts: 539
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: SAT with concave/complex polygon for collision response

Post by dusoft »

Also check this library:
https://github.com/Aweptimum/Strike

It supports both Convex and Concave polygons.
User avatar
Bigfoot71
Party member
Posts: 287
Joined: Fri Mar 11, 2022 11:07 am

Re: SAT with concave/complex polygon for collision response

Post by Bigfoot71 »

Thanks for the suggestion, I'll take a closer look :)
My avatar code for the curious :D V1, V2, V3.
User avatar
dusoft
Party member
Posts: 539
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: SAT with concave/complex polygon for collision response

Post by dusoft »

Bigfoot71 wrote: Sat Apr 15, 2023 10:12 am Thanks for the suggestion, I'll take a closer look :)
Sure, let us know. I have tested it with convex polygons, it works well. But I haven't tested it with concave polygons.
User avatar
Bigfoot71
Party member
Posts: 287
Joined: Fri Mar 11, 2022 11:07 am

Re: SAT with concave/complex polygon for collision response

Post by Bigfoot71 »

Well, finally, it's interesting and it reassures me while also worrying me in a way. There are exactly the same problems in this library as in mine. Here's a picture:
Image

As a reminder, with my module using the latest test to date, knowing that I have made more convincing ones but still similar (the numbers scrolling in the terminal are precisely the number of collision triangles detected before repositioning):
Image

Here's the code I used with Strike:

Code: Select all

local S = require("strike")
local pm = require("polyman")

local p1 = pm.create.random(0, 0, 8, 128)
local p2 = pm.create.random(0, 0, 8, 128)

pm.setReverse(p1)
pm.setReverse(p2)

p1 = S.trikers.Concave(unpack(p1))
p2 = S.trikers.Concave(unpack(p2))

p2:translateTo(
    love.graphics.getWidth()/2,
    love.graphics.getHeight()/2
)

function love.update(dt)

    local mx, my = love.mouse.getPosition()
    p1:translateTo(mx,my)

    local t = S.triking(p1, p2)
    if t then p1:translate(t.x,t.y) end

end

function love.draw()
    p1:draw()
    p2:draw()
end
My avatar code for the curious :D V1, V2, V3.
User avatar
darkfrei
Party member
Posts: 1186
Joined: Sat Feb 08, 2020 11:09 pm

Re: SAT with concave/complex polygon for collision response

Post by darkfrei »

It looks like that every point must have a list of values, bool value to present if this point is inside of each triangle and it cannot be changed while movement.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests