Page 4 of 9

Re: Fizz X

Posted: Sat Nov 10, 2012 1:37 am
by Ensayia
I will speak for Taehl since he's a close personal friend:

Taehl has been without internet for nearly a year now due to his living situation but I can tell you that he would not mind anyone using his work as long as proper credit was attributed to him.

Re: Fizz X

Posted: Sun Nov 18, 2012 5:24 pm
by Positive07
Well I downloaded the demo from this post I dont know if it is updated but playing a little I found some little mistakes... spheres through the ground... (there is an sphere missing also that went through the ground and now is not visible any more)

EDIT: Well I tried the new version and its much better than the last but a block fell on me and I disappeared through the ground, it doesnt happen with spheres any more but when blocks fall from the top they have too much force. I may use this physics module in my games thanks :D
here is a pic showing the errorsImage

Re: Fizz X

Posted: Mon Nov 19, 2012 7:04 am
by ivan
Hey thanks a lot for trying the demo.
I'm afraid the version you tested may have not been up to date.
Can you please try the new .love file (version 6) which I uploaded in the original post?
Thanks again for the feedback!

Re: Fizz X

Posted: Sun Nov 25, 2012 5:22 am
by Positive07
UPDATED last message. Thaks for the new demo its pretty good and simple I really like Fizz!

Re: Fizz X

Posted: Sat Dec 08, 2012 2:42 pm
by ivan
Hey thanks again! One of fizz's limitations is "stacking" (when you have more than 2 or 3 shapes on top of each other and gravity is pulling them down). Unfortunately, this turns out to be a non-trivial problem to solve.

Also, I'm looking for help from the Love2D community by somebody with a good understanding of math or geometry.
I'm having trouble with the line-vs-AABB intersection algorithm.
I can detect if a line intersects with an AABB but I can't figure out what the penetration depth is.
Line shapes have a direction (can only be penetrated on one side) so the collision normal is known already.
Here is a diagram which illustrates the value that I'm looking for:
Image
Basically, I'm trying to find out the length of the RED line (penetration depth).

Here is the algorithm with a todo:

Code: Select all

function testLineRect(a, b)
  -- line vector
  local dx, dy = a.x2 - a.x, a.y2 - a.y
  -- line halflength vector
  local hdx, hdy = dx/2, dy/2
  -- line midpoint
  local mx, my = a.x + hdx, a.y + hdy
  -- translate midpoint to rect origin
  mx, my = mx - b.x, my - b.y
  
  -- separating axes tests
  local ahdx = abs(hdx)
  if abs(mx) > b.hw + ahdx then
    return
  end
  local ahdy = abs(hdy)
  if abs(my) > b.hh + ahdy then
    return
  end

  -- wedge product test (cross product in 2D)
  local cross1 = b.hw*ahdy + b.hh*ahdx
  local cross2 = abs(mx*hdy - my*hdx)
  if cross2 > cross1 then
    return
  end

  -- collision normal is the line rotated by 90 degrees
  local d = sqrt(dx*dx + dy*dy)
  local nx, ny = dy/d, -dx/d
  
  -- allow passing through one side of the line
  local vx = (a.xv or 0) - (b.xv or 0)
  local vy = (a.yv or 0) - (b.yv or 0)
  local dot = vx*nx + vy*ny
  if dot > 0 then
    return
  end

  -- todo: WHAT'S THE PENETRATION DEPTH?
  local pen = ???

  return nx, ny, pen
end
Would appreciate any help greatly!

Re: Fizz X

Posted: Sat Dec 08, 2012 9:24 pm
by Positive07
You dont calculate directly the penetration you need the point where both the line and the block crosses, once you have this you calculate the distance between two points, one is the start (or end, depends on wich side is inside the rectangle) and that point thats your penetration. The difficult task here is detecting wich side of the line is inside the block.

Im looking for penetration of rotated forms, that would be great and is not that difficult i may write something so you can add this feature to fizz x.

PS: Your code is awesome

Re: Fizz X

Posted: Sun Dec 09, 2012 1:41 am
by kikito
ivan wrote: I'm having trouble with the line-vs-AABB intersection algorithm.
Check this out: viewtopic.php?f=5&t=11752

Re: Fizz X

Posted: Sun Dec 09, 2012 1:04 pm
by ivan
Positive07 wrote:You dont calculate directly the penetration you need the point where both the line and the block crosses, once you have this you calculate the distance between two points, one is the start (or end, depends on wich side is inside the rectangle) and that point thats your penetration. The difficult task here is detecting wich side of the line is inside the block.
Yes, I think I know what you mean. Unfortunately it seems there isn't a simple solution except for testing which of the 4 corners of the AABB is "penetrating" the line deepest. By "penetrating" the line, I mean which corner of the AABB is deepest "down" in relation to the collision normal. Meh, I think it's too complicated, might as well drop support for line shapes altogether.
Positive07 wrote:Im looking for penetration of rotated forms, that would be great and is not that difficult i may write something so you can add this feature to fizz x.
Sounds interesting, although I'm not sure if it's very applicable for old-school platformer games.
Positive07 wrote:PS: Your code is awesome
Thanks, I can't take full credit though, a lot of the intersection code is based on "Realtime Collision Detection" by Ericsson.

Thanks kikito, I've seen similar algorithms. I'm afraid the issue with Fizz is not detecting IF the line intersects the AABB but what the separation vector should be (in particular, its magnitude).

Re: Fizz X

Posted: Sun Dec 09, 2012 3:53 pm
by kikito
ivan wrote:Thanks kikito, I've seen similar algorithms. I'm afraid the issue with Fizz is not detecting IF the line intersects the AABB but what the separation vector should be (in particular, its magnitude).
You should read it again. The algorithm in fact calculates the magnitude (t0 and t1).

Re: Fizz X

Posted: Sun Dec 09, 2012 4:18 pm
by ivan
kikito wrote:You should read it again. The algorithm in fact calculates the magnitude (t0 and t1).
Yes, I noticed that you find the intersection points between the line and the AABB.
My question is, how would separate the AABB so they are no longer intersecting (assuming the line is static)?
The idea in FizzX was to move the AABB in a direction perpendicular to the line normal (I suppose this could be wrong?)
What do you think?