#307 Stage 2.5D collision detection fix

Release-3.0
closed
Stage (103)
5
2009-01-05
2008-07-24
Nick Wong
No

Hi, This is our attempt to fix the collision detection in stage, currently stage's collision detection only checks for objects sitting on the ground (has a global_zmin = 0) and the raytrace method used by the collision detection is also used for sensors.

Changes:
All raytrace methods now have a parameter called "testBlock". When the raytrace method is used for collision detection, "testBlock" is the block being tested against all models in the world for collision. When the raytrace method is used for sensors, testBlock = NULL.

Added a method "GList* StgModel::GetModelBlocks(GList* currentList){...}" in model.cc which recursively gets all the blocks associated with the model currently being tested. The TestCollision method in the same file uses this method to get the blocks of a model and each block is then passed to raytrace to test for collision.

Two "get" methods are added to the StgBlock class in stage.hh. The methods are used by the raytrace method in world.cc to get the zmin and zmax of the block.

Added IntersectGlobalZ(global_zmax, global_zmin) to the StgBlock class in stage.hh to test the z range of the block.

Nick Wong & Jimmy Peng

Discussion

  • Nick Wong
    Nick Wong
    2008-07-29

    Logged In: YES
    user_id=2037637
    Originator: YES

    There are some issues found related to the old method where all the blocks are put into a list. So we replace the GetModelBlocks method with a method called TestModelCollision which retrieves all the child models related to the current model and TestCollision is called on each model to test for collision.
    File Added: libstage.tar.bz2

     
  • Jeremy Asher
    Jeremy Asher
    2008-08-01

    • milestone: --> Release-3.0
     
  • Toby Collett
    Toby Collett
    2008-08-25

    Logged In: YES
    user_id=974361
    Originator: NO

    Can you attach a diff using 'svn diff' rather than the source tarball, this makes it much easier to apply the changes as SVN trunk changes.

     
  • Nick Wong
    Nick Wong
    2008-08-26

    patch file for collision detection

     
  • Nick Wong
    Nick Wong
    2008-08-26

    Logged In: YES
    user_id=2037637
    Originator: YES

    Attached a diff file.
    The version used to generate the diffs is
    playerstage/code/stage/trunk :6943
    playerstage/code:6977
    File Added: collision_patch.tar.gz

     
    • status: open --> closed
     
  • Collision detection is fixed in trunk, so this patch is probably redundant now.