ODE hangs on collision.

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
LarryTM
Posts: 30
Joined: Tue Jul 04, 2006 4:05 am
Contact:

ODE hangs on collision.

Post by LarryTM »

Hi,

I have strange problem with ODE. When i compile sample app from ODE or my own app, it works fine on PC, but hangs up on PSP.

My psp hangs up when objects gets collision. When objects don't collide my app is working.

I use latest pspsdk and ODE from ps2dev SVN.

Anyone can help me?
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

If I remember correctly, the last time someone had this same problem, it was because the stack was too small. The ODE collision example needs at least a 1MB stack to run. The default stack on the PSP is 256KB.
LarryTM
Posts: 30
Joined: Tue Jul 04, 2006 4:05 am
Contact:

Post by LarryTM »

How to increase stack size?

I've made a few tests and i think that the problem exists when i use CCylinder collision with Trimesh.

When i use Box object with Trimesh everything works fine. Here's my code :

Creating trimesh

Code: Select all

  fiz_info.world = dWorldCreate();
  fiz_info.space = dHashSpaceCreate (0);

  fiz_info.contactgroup = dJointGroupCreate (0);
  dWorldSetGravity (fiz_info.world,0,0,-9.8);
  dWorldSetQuickStepNumIterations (fiz_info.world, 64); 

  dTriMeshDataID Data = dGeomTriMeshDataCreate(); 
 
   dGeomTriMeshDataBuildSingle
  (
    Data, 
	fiz_info.vertexy,
    3 *sizeof(dReal), 
	fiz_info.ile_vert/3, 
	fiz_info.indexy,
	fiz_info.ile_ind, 
    3*sizeof(int)
  );
    
  fiz_info.world_mesh = dCreateTriMesh(fiz_info.space, Data, 0, 0, 0);
  dGeomTriMeshEnableTC(fiz_info.world_mesh, dSphereClass, false);
  dGeomTriMeshEnableTC(fiz_info.world_mesh, dBoxClass, false);
  dGeomSetPosition(fiz_info.world_mesh, 0, 0, 0);
  dRFromAxisAndAngle (R, 0,1,0, 0);
  dGeomSetRotation (fiz_info.world_mesh, R); 
Creating Cylinder object :

Code: Select all

	robot->obiekt.TriBody=dBodyCreate (Level01->fiz_info.world); 
	dMassSetCylinderTotal (&robot->obiekt.masa,4,1,robot->obiekt.wymiary.x/2,robot->obiekt.wymiary.z/2);
	dBodySetMass (robot->obiekt.TriBody,&robot->obiekt.masa);
	robot->obiekt.TriMesh=dCreateCCylinder(Level01->fiz_info.space,robot->obiekt.wymiary.x/2,robot->obiekt.wymiary.z/2);
	dGeomSetBody (robot->obiekt.TriMesh,robot->obiekt.TriBody);
And collision :

Code: Select all

static void nearCallback (void *data, dGeomID o1, dGeomID o2)
{
    const int MAX_CONTACTS = 5;
    int i;

    dBodyID b1 = dGeomGetBody(o1);
    dBodyID b2 = dGeomGetBody(o2);

    dContact contact[MAX_CONTACTS];
 
    for &#40;i = 0; i < MAX_CONTACTS; i++&#41;
    &#123;
      contact&#91;i&#93;.surface.mode = dContactSlip1 | dContactSlip2 |
	dContactSoftERP | dContactSoftCFM | dContactApprox1;
      contact&#91;i&#93;.surface.mu = dInfinity;
      contact&#91;i&#93;.surface.slip1 = 0.1;
      contact&#91;i&#93;.surface.slip2 = 0.1;
      contact&#91;i&#93;.surface.soft_erp = 0.5;
      contact&#91;i&#93;.surface.soft_cfm = 0.3;
    &#125;

    if &#40;int numc = dCollide&#40;o1, o2, MAX_CONTACTS, &contact&#91;0&#93;.geom, sizeof&#40;dContact&#41;&#41;&#41;
    &#123;

        for &#40;i = 0; i < numc; i++&#41;
        &#123;
			dJointID c = dJointCreateContact&#40;Level01->fiz_info.world, Level01->fiz_info.contactgroup, contact + i&#41;;
            dJointAttach&#40;c, b1, b2&#41;;
        &#125;
    &#125;
&#125;



static void simLoop &#40;atr3d *scenka&#41;
&#123;
 
	dSpaceCollide&#40;scenka->fiz_info.space, 0, &nearCallback&#41;;
	dWorldQuickStep&#40;scenka->fiz_info.world, 0.1&#41;;
	dJointGroupEmpty&#40;scenka->fiz_info.contactgroup&#41;;
 
&#125; 
Any ideas?
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

LarryTM wrote:How to increase stack size?

Any ideas?
Click the search button at the top of the page, set the forum to PSP Development, then enter the term "STACK_SIZE". SHEESH! Kids these days... in MY day, we had to walk twenty miles to find the answer! In the snow! Uphill!
:D
Post Reply