[ODE] ODE freezes, can you help?

Ivan Bolcina ivan.bolcina at volja.net
Thu Dec 19 13:10:02 2002


This is a multi-part message in MIME format.

------=_NextPart_000_000B_01C2A7A2.EA64CB90
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi!

Thanks for all useful info about debugging. Unfortunately, I am still =
having big trouble with ode.
Cases:

world gravity=3D0   =3D=3D> error
world gravity!=3D0 =3D=3D> OK
world gravity!=3D0 && body gravity mode=3D0 =3D=3D> error

so if force of gravity becomes one way or another 0, than all my objects =
are throw way out of context. ODE throws all objects in the same spot, =
so Collision function is busy as hell.
How could I have influenced ODE with my code this =
way????!!!!??!?!??!?!?!

Here is my code which has something to do with ode. Can someone PLEASE =
please have a look, I am going crazy here.


initialization:

HRESULT WFMApp::OneTimeSceneInit()
{
world =3D dWorldCreate();
space =3D dSimpleSpaceCreate (0);
contactgroup =3D dJointGroupCreate (1000000);
dWorldSetGravity (world,0.0001f,0.0001f,0.0001f); //if I uncomment this, =
I get error
....
}

For objects:

void SObject::createPhy(int mode)
{
  PhyBody =3D dBodyCreate (app->world);
  dBodySetPosition (PhyBody,m_Position.x,m_Position.y,m_Position.z);=20
  dMass m;
  float vol=3Dm_radius*m_radius*m_radius*3.1459;
  float den=3DMass/vol;
  dMassSetSphere (&m,den,m_radius);=20
  dBodySetMass (PhyBody,&m);
  PhyGeom =3D dCreateSphere(app->space,m_radius);
  dGeomSetBody (PhyGeom,PhyBody);
}

and world step:

dWorldStep (this->world, getElapsedTime());
dJointGroupEmpty (contactgroup);

and finally,collsion which I do by hand

for (Ship_Iterator =
itr=3Dapp->ships.begin();itr!=3Dapp->ships.end();itr++)
{
  SOShip * tmp=3D*itr;
  if (tmp=3D=3Dthis || !tmp->alive) continue;
  if (Collision(tmp))
  {
    if (!PhyBody || !tmp->PhyBody) return;
    if (dAreConnected(PhyBody,tmp->PhyBody)) return;
    D3DXVECTOR3 diff=3Dm_Position-tmp->GetPosition();
    float len=3DD3DXVec3Length(&diff);
    if (len<=3D0.0f)
    {
      diff=3DD3DXVECTOR3(1,0,0);
      len=3D1;
    }
    diff*=3D(1.0f/len);
    dContact contact;
    contact.surface.mode =3D 0;
    contact.surface.mu =3D 0.1;
    contact.surface.mu2 =3D 0;
    convertVector(diff,contact.geom.normal);
    convertVector(m_Position-diff*m_radius,contact.geom.pos);
    D3DXVECTOR3 spe=3Dmove-tmp->move;
    len=3DD3DXVec3Length(&spe);
    len*=3Dapp->getElapsedTime();
    contact.geom.depth=3D3+len;
    contact.geom.g1=3Dthis->PhyGeom;
    contact.geom.g2=3Dtmp->PhyGeom;
    dJointID c =3D dJointCreateContact =
(app->world,app->contactgroup,&contact);
    dJointAttach (c,this->PhyBody,tmp->PhyBody);
  }
}

other than that, I just apply forces and torques to objects.





------=_NextPart_000_000B_01C2A7A2.EA64CB90
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1106" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV>Hi!</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV>Thanks for all useful info about debugging. Unfortunately, I am =
still=20
having big trouble with ode.</DIV>
<DIV>Cases:</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV>world gravity=3D0&nbsp;&nbsp; =3D=3D&gt; error</DIV>
<DIV>world gravity!=3D0 =3D=3D&gt; OK</DIV>
<DIV>world gravity!=3D0 &amp;&amp; body gravity mode=3D0 =3D=3D&gt; =
error</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV>so if force of gravity becomes one way or another 0, than all my =
objects=20
are throw way out of context. ODE throws all objects in the same spot, =
so=20
Collision function is busy as hell.</DIV>
<DIV>How could I have influenced ODE with my code this=20
way????!!!!??!?!??!?!?!</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV>Here is my code which has something to do with ode. Can someone =
PLEASE=20
please have a look, I am going crazy here.</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV>initialization:</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>
<P>HRESULT WFMApp::OneTimeSceneInit()<BR>{<BR>world =3D =
dWorldCreate();<BR>space =3D=20
dSimpleSpaceCreate (0);<BR>contactgroup =3D dJointGroupCreate=20
(1000000);<BR>dWorldSetGravity (world,0.0001f,0.0001f,0.0001f); //if I =
uncomment=20
this, I get error<BR>....<BR>}</P>
<P>For objects:</P><FONT color=3D#0000ff size=3D2>
<P>void</FONT><FONT size=3D2> SObject::createPhy(</FONT><FONT =
color=3D#0000ff=20
size=3D2>int</FONT><FONT size=3D2> mode)<BR></FONT><FONT =
size=3D2>{<BR>&nbsp; PhyBody=20
=3D dBodyCreate (app-&gt;world);<BR>&nbsp; dBodySetPosition=20
(PhyBody,m_Position.x,m_Position.y,m_Position.z); <BR>&nbsp; dMass=20
m;<BR></FONT><FONT color=3D#0000ff size=3D2>&nbsp; float</FONT><FONT =
size=3D2>=20
vol=3Dm_radius*m_radius*m_radius*3.1459;<BR></FONT><FONT color=3D#0000ff =

size=3D2>&nbsp; float</FONT><FONT size=3D2> den=3DMass/vol;<BR>&nbsp; =
dMassSetSphere=20
(&amp;m,den,m_radius); <BR>&nbsp; dBodySetMass =
(PhyBody,&amp;m);<BR>&nbsp;=20
PhyGeom =3D dCreateSphere(app-&gt;space,m_radius);<BR>&nbsp; =
dGeomSetBody=20
(PhyGeom,PhyBody);<BR></FONT><FONT size=3D2>}</FONT></P>
<P><FONT size=3D2>and world step:</FONT></P><FONT size=3D2>
<P>dWorldStep (</FONT><FONT color=3D#0000ff size=3D2>this</FONT><FONT=20
size=3D2>-&gt;world, getElapsedTime());<BR>dJointGroupEmpty=20
(contactgroup);</P></FONT>
<P><FONT size=3D2>and finally,collsion which I do by =
hand</FONT></P><FONT size=3D2>
<P></FONT><FONT color=3D#0000ff size=3D2>for</FONT><FONT size=3D2> =
(Ship_Iterator=20
itr=3Dapp-&gt;ships.begin();itr!=3Dapp-&gt;ships.end();itr++)<BR>{<BR>&nb=
sp; SOShip=20
* tmp=3D*itr;<BR>&nbsp; </FONT><FONT color=3D#0000ff =
size=3D2>if</FONT><FONT size=3D2>=20
(tmp=3D=3D</FONT><FONT color=3D#0000ff size=3D2>this</FONT><FONT =
size=3D2> ||=20
!tmp-&gt;alive) </FONT><FONT color=3D#0000ff =
size=3D2>continue</FONT><FONT=20
size=3D2>;<BR>&nbsp; </FONT><FONT color=3D#0000ff =
size=3D2>if</FONT><FONT size=3D2>=20
(Collision(tmp))<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; </FONT><FONT =
color=3D#0000ff=20
size=3D2>if</FONT><FONT size=3D2> (!PhyBody || !tmp-&gt;PhyBody) =
</FONT><FONT=20
color=3D#0000ff size=3D2>return</FONT><FONT =
size=3D2>;<BR>&nbsp;&nbsp;&nbsp;=20
</FONT><FONT color=3D#0000ff size=3D2>if</FONT><FONT size=3D2>=20
(dAreConnected(PhyBody,tmp-&gt;PhyBody)) </FONT><FONT color=3D#0000ff=20
size=3D2>return</FONT><FONT size=3D2>;<BR>&nbsp;&nbsp;&nbsp; D3DXVECTOR3 =

diff=3Dm_Position-tmp-&gt;GetPosition();<BR>&nbsp;&nbsp;&nbsp; =
</FONT><FONT=20
color=3D#0000ff size=3D2>float</FONT><FONT size=3D2>=20
len=3DD3DXVec3Length(&amp;diff);<BR>&nbsp;&nbsp;&nbsp; </FONT><FONT =
color=3D#0000ff=20
size=3D2>if</FONT><FONT size=3D2> (len&lt;=3D0.0f)<BR>&nbsp;&nbsp;&nbsp; =

{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
diff=3DD3DXVECTOR3(1,0,0);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
len=3D1;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;=20
diff*=3D(1.0f/len);<BR>&nbsp;&nbsp;&nbsp; dContact =
contact;<BR>&nbsp;&nbsp;&nbsp;=20
contact.surface.mode =3D 0;<BR>&nbsp;&nbsp;&nbsp; contact.surface.mu =3D =

0.1;<BR>&nbsp;&nbsp;&nbsp; contact.surface.mu2 =3D =
0;<BR>&nbsp;&nbsp;&nbsp;=20
convertVector(diff,contact.geom.normal);<BR>&nbsp;&nbsp;&nbsp;=20
convertVector(m_Position-diff*m_radius,contact.geom.pos);<BR>&nbsp;&nbsp;=
&nbsp;=20
D3DXVECTOR3 spe=3Dmove-tmp-&gt;move;<BR>&nbsp;&nbsp;&nbsp;=20
len=3DD3DXVec3Length(&amp;spe);<BR>&nbsp;&nbsp;&nbsp;=20
len*=3Dapp-&gt;getElapsedTime();<BR>&nbsp;&nbsp;&nbsp;=20
contact.geom.depth=3D3+len;<BR>&nbsp;&nbsp;&nbsp; =
contact.geom.g1=3D</FONT><FONT=20
color=3D#0000ff size=3D2>this</FONT><FONT =
size=3D2>-&gt;PhyGeom;<BR>&nbsp;&nbsp;&nbsp;=20
contact.geom.g2=3Dtmp-&gt;PhyGeom;<BR>&nbsp;&nbsp;&nbsp; dJointID c =3D=20
dJointCreateContact=20
(app-&gt;world,app-&gt;contactgroup,&amp;contact);<BR>&nbsp;&nbsp;&nbsp; =

dJointAttach (c,</FONT><FONT color=3D#0000ff size=3D2>this</FONT><FONT=20
size=3D2>-&gt;PhyBody,tmp-&gt;PhyBody);<BR>&nbsp; </FONT><FONT=20
size=3D2>}<BR>}</P></FONT>
<P>other than that, I just apply forces and torques to objects.</P>
<P>&nbsp;</P>
<P><FONT size=3D2>&nbsp;</P></FONT></FONT></DIV></BODY></HTML>

------=_NextPart_000_000B_01C2A7A2.EA64CB90--