Another Problem, now with checkForCollision

Started by Uija, November 27, 2005, 01:23:33 AM

Previous topic - Next topic

Uija

I have the following scenario:


    O


___________


I have a plane, that is more than big enough to fit the Object above it.
I place the Object around 300 points above the plane and do the following:


// Vector to define Ray
SimpleVector trans = new SimpleVector( 0, 1, 0);
// Check for other object
int id = object.checkForCollision( trans, 30);
// If no object, move
if( id == Object3D.NO_OBJECT)
{
  object.translate( trans);
}


I tried "every" setting with collisionstype (let plane check other, let plane check self let plane check both, same with object and both checking) and the objects falls through the plane all the time.

I am very new to the collision thing and red your documentation in the manual about it.
I wanted to use this type of collison-detecting, as the ellipsoid one let me flow down every floor that is not 100% straight.

Am I using the checkForCollision wrong?

EgonOlsen

Try to adjust Config.collideOffset (and, if that fixes the problem, enable Object3D.setCollisionOptimization() afterwards to get some performance back).
Maybe your plane is too large to be covered by the default setting (most likely, especially if you are already 30 units away from it). Whatever you do, try to make sure that everything in your world takes places in almost the scale or you'll run into accuracy problems sooner or later (for example: don't translate your objects by 100 if your polygons are all one unit in size).

Uija

I think I fixed the problem.
I have 2 "Maps". My big one (400x400 units and 2 Tris) and another one 400x400 with 40x40x2 tris. they look the same so I used the big one all the time. now after changing to the one with 40x40x2 tris, the problem is gone.

the 30 was a testvalue after I checked everything other :P my player is 8 units high and I use a gravityray from 4f to get the result I want.
Another thing: My "Map" contains currently 40x40x2 Triangles. when I build a octree with it, I get a stackoverflow. isnt it meant to be used on big objects?

EgonOlsen

Quote from: "Uija"Another thing: My "Map" contains currently 40x40x2 Triangles. when I build a octree with it, I get a stackoverflow. isnt it meant to be used on big objects?
There are situations, where the subdivision of an object fails and the recursion never ends...i can't remember exactly when this happens, but there should be a thread about it IIRC. To prevent this, you may create the octree with a maxDepth (5 or 10 or whatever) by using the corresponding constructor. What's your setting for maxPoly for that tree (shouldn't be lower than 100 IMHO)?

Edit: A little more on this subject: jPCT doesn't split polygons for creating an octree. It just tries to decrease polygon count in a node by subdividing the node if needed. On some objects, this doesn't work, because the polygons already cover the whole node. There is no way to decrease their number by subdividing that node...they will just cover it even more. By limiting the depth, you make jPCT stop at a certain depth.