Author Topic: The Result of checkForCollisionEllipsoid gets me stuck.  (Read 3448 times)

Offline AGP

  • quad
  • ******
  • Posts: 1519
    • View Profile
Re: The Result of checkForCollisionEllipsoid gets me stuck.
« Reply #15 on: September 28, 2012, 10:11:14 pm »
OK, I understand your suggestion that by moving the hero by the result of calcMinDistance I accordingly affect the collision ellipsoid. But for one thing, where I'm getting stuck the terrain is plain and, for another, I can't see that as being a problem if the wall is 90 degrees to the floor (and for the most part my walls are). This problem really lies in result (or use of) checkForCollisionEllipsoid.

Offline AGP

  • quad
  • ******
  • Posts: 1519
    • View Profile
Re: The Result of checkForCollisionEllipsoid gets me stuck.
« Reply #16 on: September 28, 2012, 10:13:52 pm »
PS: Where I get stuck, the character is already on the ground (he doesn't fall as the one in your illustration).

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: The Result of checkForCollisionEllipsoid gets me stuck.
« Reply #17 on: September 28, 2012, 10:46:33 pm »
It might still be caused by some inaccuracies between the two methods. Try to make the radius of the ellipsoid in y-direction a little lower than the actual distance from the ground so that the ellipsoid doesn't touch it. If that doesn't help, continue to play around with the parameters. There's no reason why it should get stuck on a plain, but it might if (for example) the threshold is very small. I would avoid combining the two methods anyway.

Offline AGP

  • quad
  • ******
  • Posts: 1519
    • View Profile
Re: The Result of checkForCollisionEllipsoid gets me stuck.
« Reply #18 on: September 29, 2012, 09:04:34 am »
For whatever it's worth I added the following code to collide. If it collidedThisFrame, I don't move with calcMinDistance(). As I expected, it did not solve my problem, but at least now we know what the trouble is.

Code: [Select]
if (directionToHead.x != direction.x || directionToHead.z != direction.z)
     collidedThisFrame = true;
else collidedThisFrame = false;

Offline AGP

  • quad
  • ******
  • Posts: 1519
    • View Profile
Re: The Result of checkForCollisionEllipsoid gets me stuck.
« Reply #19 on: September 29, 2012, 08:27:36 pm »
I tried collideOffset, gradually increasing it all the way to 1000. It didn't help.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: The Result of checkForCollisionEllipsoid gets me stuck.
« Reply #20 on: September 29, 2012, 08:47:58 pm »
Just stop using calcMinDistance at all. Try to use ellipsoid detection only.

Offline AGP

  • quad
  • ******
  • Posts: 1519
    • View Profile
Re: The Result of checkForCollisionEllipsoid gets me stuck.
« Reply #21 on: September 29, 2012, 08:54:03 pm »
How would this particular problem be helped by that? Especially since I don't use it after checkForEllipsoidCollision returns a SimpleVector other than the one it's passed.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: The Result of checkForCollisionEllipsoid gets me stuck.
« Reply #22 on: September 29, 2012, 09:03:32 pm »
It cleans up things to make it easier to track down the actual issue. I've no real idea what you are doing right now. The ellipsoid you are using is very small. I've no idea if that actually matches your geometry or not. Then there's some if-clause which decides if calcMinDistance will be used or not where you actually shouldn't use it anyway in this case (as explained in my drawing)...it all seems pretty convoluted to me and that makes it hard to find the real problem here. So i suggest to:

  • Use an ellipsoid that has the size of the hero.
  • Make sure that it covers the hero more or less.
  • Leave out any gravity related code. You don't need it in this test case anyway (judging from the video).
  • Make that work, then add additional stuff. Don't add additional stuff to something that is already broken. Take one or two steps back instead.

Your final collision method should have a few lines only. Do an ellipsoid collision detection for the hero, move the hero according to the results. That's all. No gravity, no ifs, nothing else. To make this work has to be first priority.

Offline AGP

  • quad
  • ******
  • Posts: 1519
    • View Profile
Re: The Result of checkForCollisionEllipsoid gets me stuck.
« Reply #23 on: September 29, 2012, 09:17:57 pm »
Then I propose either (the more likely knowing you) a method like checkForCollisionEllipsoid that automatically gets the size of the Object3D or (less likely knowing what you'll say about the pipeline) a drawEllipsoid(same arguments as checkForColEllipsoid). Otherwise it's too much guesswork, man.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: The Result of checkForCollisionEllipsoid gets me stuck.
« Reply #24 on: September 29, 2012, 09:41:55 pm »
I see your point, but that won't help much IMHO. It might be useful for the y-dimension of an object, but for normal collision detection, you want to extend the ellipsoid into x- and z-direction to some degree. You usually don't want to use a tight fitting ellipsoid. Apart from that, it's not a trivial problem and actually unsolvable in a lot of cases. In your case, you won't use an ellipsoid that covers both feet of your hero, because that would extend into the ground.
Use Mesh.getBoundingBox() for now, subtract the min from the max values, divide them by 2 and you have your basic values for the ellipsoid's radius. Add something to x and z just to be sure. Place it above the ground, so that it's close to it but doesn't intersect.

Offline AGP

  • quad
  • ******
  • Posts: 1519
    • View Profile
Re: The Result of checkForCollisionEllipsoid gets me stuck.
« Reply #25 on: September 29, 2012, 09:51:47 pm »
Covering the feet won't be a big priority (it doesn't have to look absolutely perfect, it just has to work). I'll try your values and report back, thanks.