Author Topic: Collision detection tests  (Read 13967 times)

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Collision detection tests
« Reply #15 on: August 05, 2013, 04:11:45 AM »
Hey Peter, are you still interested in helping?  I'll need some tests in the next few days.  If you decided it's too difficult or time intensive to help, no worries :)  I just need to know if I should start speccing it out or if you have this under control and I should just be patient.

Offline Peter

  • Bot God
  • *****
  • Posts: 1177
    • View Profile
Re: Collision detection tests
« Reply #16 on: August 05, 2013, 02:52:33 PM »
I am! :)

It's not that's it's too difficult or time intensive. Just that I haven't spend much time on it. I hope you weren't waiting for me. :x

I'll do my best to create a patch today. Although don't expect there to be a lot of tests in there. If you then could take a look and confirm they work properly. (and with that likely take more of your time then if you would've written then yourselves :wacko:)
Oh my god, who the hell cares.

Offline Peter

  • Bot God
  • *****
  • Posts: 1177
    • View Profile
Re: Collision detection tests
« Reply #17 on: August 05, 2013, 03:07:54 PM »
In SafeStepForward and SafeStepBackward, what is currRoot and nextRoot?
Oh my god, who the hell cares.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Collision detection tests
« Reply #18 on: August 05, 2013, 03:40:56 PM »
Quote
I hope you weren't waiting for me.

Nope; I've been working on fleshing out all the code to look approximately like I want.  I have dozens of tests that are failing right now, so I haven't exhausted my to do list just yet.  But I hope to get things working in the next few days, and then I'll need some new tests to push the code with.

I'll do my best to create a patch today. Although don't expect there to be a lot of tests in there. If you then could take a look and confirm they work properly. (and with that likely take more of your time then if you would've written then yourselves :wacko:)

Yeah, I'll definitely look it over.  To be honest it's not even an issue of the time it takes.  It's just exhausting thinking through the setups.  Especially the more complex ones involving both bodies rotating and moving.

Quote
In SafeStepForward and SafeStepBackward, what is currRoot and nextRoot?
I'm probably going to remove both of those functions, so I wouldn't worry about writing tests for it.  They aren't necessary for the new collision algorithm.

But to answer your question, the idea is that there's an intersection at some given time (the currRoot), and we want to step forward some amount of time until the derivative is non 0, and we haven't passed the next intersection (nextRoot).
« Last Edit: August 05, 2013, 03:43:53 PM by Numsgil »

Offline Peter

  • Bot God
  • *****
  • Posts: 1177
    • View Profile
Re: Collision detection tests
« Reply #19 on: August 05, 2013, 06:52:35 PM »
Added 2 tests. Gotta start somewhere. ;)

In polygon vs. polygon. Does the test EdgeEdgeSolidHit work as it should?

I see CheckEqual(4, output.TOI); From the code behind it I assume it's the same as timeOfImpact. I also assume the polygon position is based on the center of the polygon. That makes from the distance of 10 at the center a effective distance of 8. That would mean the actual time of impact would be ~3.6 instead of 4. If not how does it define the start location of the polygon?
Oh my god, who the hell cares.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Collision detection tests
« Reply #20 on: August 06, 2013, 01:36:29 AM »
Added 2 tests. Gotta start somewhere. ;)

Great!  I've added it to my working copy.  I'm still neck deep in changes or I'd check it in right now.

Quote
In polygon vs. polygon. Does the test EdgeEdgeSolidHit work as it should?

I see CheckEqual(4, output.TOI); From the code behind it I assume it's the same as timeOfImpact. I also assume the polygon position is based on the center of the polygon. That makes from the distance of 10 at the center a effective distance of 8. That would mean the actual time of impact would be ~3.6 instead of 4. If not how does it define the start location of the polygon?

It's 8, yeah.  Hmm... check my math?

1/2 * (-1 ) * t^2 = -8
t = 4

I stopped working on the tests in poly vs poly as it became obvious that I needed to return more than a single hit.  That's what I'm working out right now.  I should have some proper tests for you to use as a template in the next few days.  But if you'd like to think up some tests cases in the mean time, all the better.  This is the struct for a hit I'm using currently:
Code: [Select]
public class Hit
{
    public Scalar TOI;

    public Polygon.Edge Edge;

    public Scalar HitFraction;

    public Polygon.Vertex Vertex;

    public bool IsEntering;
}

In the case of vertex-vertex collisions, the hit fraction is 0 and only one hit is recorded.  Hopefully that's enough to go on for now.  Once I lock down the API a bit more I'll start checking things in.
« Last Edit: August 06, 2013, 01:40:05 AM by Numsgil »

Offline Peter

  • Bot God
  • *****
  • Posts: 1177
    • View Profile
Re: Collision detection tests
« Reply #21 on: August 06, 2013, 02:25:54 PM »
Ah, that math does work out, never mind.

Where would I find the Hit objects. An array in RotatingSimplePolygonvsRotatingSimplePolygon.output or something?
Oh my god, who the hell cares.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Collision detection tests
« Reply #22 on: August 06, 2013, 04:02:08 PM »
It'll be a List<Hit> most likely, sorted by TOIs.

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Re: Collision detection tests
« Reply #23 on: August 13, 2013, 12:46:10 PM »
Just here to say that I would like to help with these tests. :) If you would me to, Peter?

Offline Peter

  • Bot God
  • *****
  • Posts: 1177
    • View Profile
Re: Collision detection tests
« Reply #24 on: August 13, 2013, 05:49:01 PM »
Sure, if you can think of some complicated ways that polygons collide or just miss. If you know how to make the test cases even better.  :)

All I did so far were just some hit and miss tests with squares. Waiting to turn that in till the API locks in so checks can be properly modified.
Oh my god, who the hell cares.

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Re: Collision detection tests
« Reply #25 on: August 15, 2013, 09:00:09 AM »
When I have time, I will try to, but it certainly seems more difficult than I can handle. If I get one done anyway, I'm sure that'll be a little help. If you can think of anything else that will need to be done, then I will try it. :)

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Collision detection tests
« Reply #26 on: August 15, 2013, 06:10:01 PM »
It's mostly a matter of doing physics word problems in reverse.  Which is hard but should be manageable.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Collision detection tests
« Reply #27 on: December 07, 2013, 11:41:45 PM »
I'm back from my hiatus.  I've fixed a bunch of issues that were lingering and checked in the code I was working on last summer.  Also fixed a few issues that might have been hitting on other peoples' machines after a fresh checkout.  Everything compiles and LinevsPoint tests are passing, but everything else is a bit of a mess.  I'm still working through it to clean up everything.

There's some legacy interface stuff I want to ditch, which I'll probably start concentrating on with the LinevsPoint tests first.

Anyone still around interested in helping?

Offline Peter

  • Bot God
  • *****
  • Posts: 1177
    • View Profile
Re: Collision detection tests
« Reply #28 on: December 28, 2013, 05:43:40 PM »
Sure
Oh my god, who the hell cares.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Collision detection tests
« Reply #29 on: December 28, 2013, 07:19:03 PM »
Cool :)  I still need to write a lot of the glancing hit tests.  Do you want to sync to the latest on the repository and see if that looks like something you can do?