neSensor activation

  • ravuya

    ravuya - 2009-01-20

    Hi, I'm new to Tokamak and I'm trying out the neSensor type for a car suspension (like the example code has).

    However, I have some problems: my neSensor only seems to 'detect' intersection when the parent rigid body's collision geometry has struck an animated body. The rest of the time, even when it should be intersecting a foreign rigid body or animated body, the collision depth is 0. I was under the impression from the documentation that the neSensor is *always* colliding.

    Is this intentional? If so, how should I think about implementing suspension using this system without having the body of my vehicle smack into and rub against the ground?

    Thanks in advance.

    • manthrax

      manthrax - 2009-01-20

      Hi Ravuya,

      A couple of gotchas with using sensors:

      1.) If the sensors start position is within your rigid body... it will not work consistently. Ensure that your sensor start and end dont penetrate the parent body. This sounds like it could be your problem.

      2.) If the sensors parent body goes to sleep, I believe the sensor will stop working as well. Set the sleep factor to 0 on the parent body when you need the sensor to work idly.

      Hope this helps. Let me know!

    • ravuya

      ravuya - 2009-01-20

      The rigid body's geometry is 1x1x1 centred around the centre of mass of the rigid body (that is, no translation), with a sensor position (0,-1,0) and direction (0,-1,0). That should clear the owning rigid body's hitbox completely, as far as I know. If that's not the case, please let me know; I'm rather unsure about the scale of the sensor vector.

      I went back and put ->SetSleepingParameter(0.0f) on the falling rigid body as well as the target rigid body, but the problem still manifests. The sensor should collide (since the rigid bodies will collide) but the depth remains at 0.

      If the falling rigid body strikes an animated body, then the sensor works as previously defined (only immediately after the collision).

      • manthrax

        manthrax - 2009-01-20

        Try offsetting the sensors origin to be something like -1.001.

        If that doesn't do it, try the setsleepparameter(0) on both objects involved in the potential collision.

        Also, at which point are you checking your sensors values?

        I believe the sensor values are only valid during the RigidBodyControllerCallback, since the simulator does the testing on each physics substep.

        If you are checking them outside of the physics update, they won't work, I think.

        Let me know if this helps!

    • ravuya

      ravuya - 2009-01-20

      Ah yes, that was it. Once I add the code to my RigidBodyControllerCallback, the sensor values are correct.  I assume they're getting set back to zero when it's doing the next rigid body or something, and therefore the values are incorrect. I was checking them from my gameloop, but I see now that the example code is checking it from the callback.

      Thanks a lot!

      • manthrax

        manthrax - 2009-01-20

        Cool!, Glad to help.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks