jPCT-AE - a 3d engine for Android > Support

checkForCollisionEllipsoid() framerate drop

(1/4) > >>

K24A3:
Basically I'm trying to increase the frame rate as much as possible.

I'm using checkForCollisionEllipsoid to collision check the main character but it's dropping the frame rate down from 60FPS+ to about 30-35 FPS, even when using the lowest recursionDepth of 1.

The checkForCollisionEllipsoid frame rate drops even when there are no COLLISION_CHECK_OTHERS objects nearby (they are visible though), does checkForCollisionEllipsoid do any object/mesh distance filtering before calculating using ellipsoid collision?
Perhaps the function could be modified to do a translation/boundingbox distance check before focusing on the ellipsoid precision.
The function seems to be based on the visibility of objects since the framerate dropped as soon as the objects were visible.

I tried using three checkForCollisionSpherical() checks which helped considerably, the frame rate was around 45-50FPS. However I would like to improve the FPS a bit more if possible


Perhaps a new checkForCollisionDualBox() function can be introduced that does dual-box calculations?
i.e. the function would parse two boxes, one large/main box to cover the main body, and another smaller box to cover the head and feet.
checkForCollisionDualBox(SimpleVector translation, SimpleVector box1size, SimpleVector box2size)

Thomas.:
Checking collision is very expensive for CPU, for improve frame rate you can divide level geometry and create special object for some complicated geometry (for example you do not need checking collision of your character with car that has thousand triangles, but is easier checking collision with only simple box) ... in this time, my game has something around 20 thousand triangles and is running 50-65fps (I used more optimalization, but creating a map takes much more time)
edit: firstly is used AABB, after that if it makes sense is calculating collision with real geometry... Egon, please correct me if it is not

EgonOlsen:

--- Quote from: Thomas. on October 08, 2011, 07:05:41 pm ---edit: firstly is used AABB, after that if it makes sense is calculating collision with real geometry... Egon, please correct me if it is not

--- End quote ---
Yes, that's the way it works. Collision detection has absolutely nothing to do with objects' visibility on screen. I'm not sure why this should cause such a huge drop unless you are using a large amount of objects...are you? Does it slow down further, if you increase the recursion depth? If it does, there have to be some intersections between the ellipsoid and the bounding boxes.

K24A3:
@Thomas, I am using my own code to set objects invisible (using Object3D.SetVisibility) if they are not in the camera's bounding box. Plus I am recycling objects so they respawn in front of the camera when they are not visible.

@Egon, I have about 32 objects set to _OTHERS, but only about 16 are within the immediate area at any time. And those objects are quite far away most of the time, with only 1 or 2 objects very close to the camera/player (say 50 translation units). I could have 16 objects 1000 translation units away, but the ellipsoid function still processes them.

It makes no difference if the objects are visible in the camera frame or behind the camera.

I removed the skydome and removed various objects to check if an object has strange geometry or something, but it made no difference. The frames drop further when there are more objects nearby.

I think there might be a bounding box glitch in the checkForCollisionEllipsoid function because the Sphere function is not dropping frames much at all.
I tested each one at the same location in a frozen state:

45FPS = No collision
41FPS = Sphere collision
31FPS = Ellipsoid collision (1 recursion)
31FPS = Ellipsoid collision (5 recursion)
31FPS = Ellipsoid collision (50 recursion)

Does the Ellipsoid function use the same bounding box filtering as the Sphere function?


Edit: Here's the collision calling section:


--- Code: --- SimpleVector vcoll = new SimpleVector();
if(nDebug == 0) vcoll = newpos;
if(nDebug == 1) vcoll = player.checkForCollisionSpherical(newpos, 2f);
if(nDebug == 2) vcoll = player.checkForCollisionEllipsoid(newpos, new SimpleVector(2f,2f,2f), 1);
if(nDebug == 3) vcoll = player.checkForCollisionEllipsoid(newpos, new SimpleVector(2f,2f,2f), 5);
if(nDebug == 4) vcoll = player.checkForCollisionEllipsoid(newpos, new SimpleVector(2f,2f,2f), 50);


--- End code ---

EgonOlsen:
The bounding box calculations are fine. Otherwise, you would get a massive drop in frame rate when going from 1 to 50 as recursion depth. The calculations differ between spherical and ellipsoid detection, because the ellipsoid one has to happen in ellipsoid space, which requires some transformations on the bounding box. In addition, it happens multiple times for each detection because it's a swept algorithm. However, i'm wondering why the drop is so huge in your case...which version of jPCT-AE are you using and on which hardware?

Navigation

[0] Message Index

[#] Next page

Go to full version