Author Topic: collision spherical x ellipsoid  (Read 4552 times)

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
collision spherical x ellipsoid
« on: December 31, 2010, 10:56:49 pm »
Why is ellipsoid camera collision so slow? I tried checkCameraCollisionSpherical and game is running stable 54-55 fps but if I use checkCameraCollisionEllipsoid frames drops to 17 fps

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: collision spherical x ellipsoid
« Reply #1 on: January 01, 2011, 01:06:26 am »
Simply because it's much more demanding. You can play around with the recursion depth to tweak it a little bit.

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: collision spherical x ellipsoid
« Reply #2 on: January 01, 2011, 03:41:40 am »
it is extremly demanding, I have same result with number 1 or 5 on recursion depth... and collide offset is sets to 40

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: collision spherical x ellipsoid
« Reply #3 on: January 01, 2011, 12:39:46 pm »
Well...yes. It's much heavier on the fpu (or its emulation on older devices), because it has to transform vertices of objects in question into ellipsoid space, which can be expensive on Android. What's the exact scenario in which you are using this? If it's a rather complex and huge mesh (like a level), you might want to try to use an octree for collision detection. Or you can use a alternative, simpler mesh for collision than for rendering. To do this, simply make the simple one visible and hide the complex one, do the detection and reverse the process again for rendering.
« Last Edit: January 01, 2011, 12:46:57 pm by EgonOlsen »

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: collision spherical x ellipsoid
« Reply #4 on: January 01, 2011, 01:14:35 pm »
I see... I am doing first person shooter game... the "main" object has not so much polygons, but almost every object in level has about 500 polygons and those are a lot of... I will try to do another system for check player collision ...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: collision spherical x ellipsoid
« Reply #5 on: January 01, 2011, 01:54:41 pm »
Polygon count matters only if an object is the way of the translation of the ellipsoid. Everything else will be discarded pretty quickly by a bounding box check.

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: collision spherical x ellipsoid
« Reply #6 on: January 01, 2011, 04:08:49 pm »
Thanks for explanations :) ... I want to do everything the most modifiable, so alternative simpler mesh can not be and check collision spherical is doing issue...

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: collision spherical x ellipsoid
« Reply #7 on: April 11, 2011, 12:24:40 pm »
My game is much more complicated now and I want to use alternative objects for collision... but when I use obj.setVisibility(false) object is not visible, but also is not calculated for collision... how can I set object just for collision? and why jPCT-AE is not supporting for portals?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: collision spherical x ellipsoid
« Reply #8 on: April 11, 2011, 08:47:22 pm »
You have to toggle the objects, i.e. make the collision objects visible, do the detection, make them invisible again. Or use another world that only stores the collision meshes.

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: collision spherical x ellipsoid
« Reply #9 on: April 11, 2011, 10:40:56 pm »
thanks, what will be faster world or toggle? or it is same?
PS: I have tested toggle now, but this collision running in another thread and object is blinking
« Last Edit: April 11, 2011, 10:49:01 pm by Thomas. »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: collision spherical x ellipsoid
« Reply #10 on: April 11, 2011, 11:01:00 pm »
Then either opt for an additional world, sync the rendering with the collision detection or don't do it in multiple threads. Doing this in multiple threads is asking for trouble anyway IMHO. I wouldn't recommend it.

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: collision spherical x ellipsoid
« Reply #11 on: April 12, 2011, 12:08:42 am »
this collision is from touch event thread

Offline Kaiidyn

  • long
  • ***
  • Posts: 103
    • View Profile
Re: collision spherical x ellipsoid
« Reply #12 on: April 13, 2011, 10:52:46 am »
the touch event itself is also pretty demanding,
I dont know if you have already done so, but adding a Thread.sleep(25); to the touch method might help a little bit..
Clean code is simple and direct. Clean code reads like well-written prose. Clean code never obscures the designer’s intent but rather is full of crisp abstractions and straightforward lines of control. - Grady Booch

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: collision spherical x ellipsoid
« Reply #13 on: April 13, 2011, 12:12:37 pm »
this collision is from touch event thread
Don't do this...doing the collision detection and especially transformations in parallel to the rendering thread is asking for trouble. I quote myself: http://www.jpct.net/forum2/index.php/topic,1994.msg14695.html#msg14695 and http://www.jpct.net/wiki/index.php/Multithreading#Thread_safety
« Last Edit: April 13, 2011, 12:14:33 pm by EgonOlsen »

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: collision spherical x ellipsoid
« Reply #14 on: April 14, 2011, 10:16:57 pm »
Are possible to do some objects for collision by player "body", some objects for shoot, some for enemies,... ?
PS: solved
« Last Edit: April 15, 2011, 11:13:54 pm by Thomas. »