|PathEngine home||previous: ||next: |
For placing and moving our agent we used iTestBed::testPointCollision().
This tests whether a shape is obstructed at a given position.
For a moving agent, we need to test whether the agent is obstructed for movement along
For this we can use the following functions, provided by
virtual bool testCollisionTo(const iCollisionContext* context, const cPosition& newPosition) const = 0; virtual bool testCollisionTo_XY(const iCollisionContext* context, int32_t x, int32_t y, int32_t& cell) const = 0; virtual bool firstCollisionTo(const iCollisionContext* context, int32_t x, int32_t y, int32_t& cell, cCollidingLine& collidingLine, iAgent*& agent) const = 0;
(Note that corresponding functions are also provided by
The difference between testCollisionTo() and testCollisionTo_XY() is
that testCollisionTo_XY() does not require a fully specified position as an end point of
testCollisionTo_XY() requires only x and y coordinates for the end of the line and fills in the cell appropriately.
This is exactly the behaviour we need to move our agent in a direction from their current position.
firstCollisionTo() also requires only x and y coordinates for the end point,
but this method then returns some additional information about the first obstruction contacted
in the case of a collision.
We will use this information to implement a basic mechanism for sliding against obstructions.
|Documentation for PathEngine release 6.00 - Copyright © 2002-2016 PathEngine||next: |