|
ORTS
|
An implementation of the TerrainBase interface using forcefields for local pathfinding. More...
#include <ST_ForceField.H>
Public Types | |
| typedef std::map< const Object *, Loc > | Obj2LocMap |
| typedef std::map< Loc, bool, Loc_less > | SegmentEndsMap |
| typedef const void * | PathId |
| typedef const void * | TaskId |
Internal typedefs | |
public to allow REGISTER_TYPEOF definitions | |
| typedef std::list< FF_Task > | Tasks |
| typedef Tasks::iterator | TIter |
| typedef std::deque< TIter > | TaskQueue |
| typedef std::map < TerrainBase::TaskId, TIter > | TaskId2Task |
| typedef std::map< const Object *, TerrainBase::TaskId > | Obj2TaskId |
| typedef std::multimap< const Object *, TerrainBase::TaskId > | ObjIsGoalInTaskId |
Requests for an immediate planning of a path | |
| enum | ConsiderObjects { CONSIDER_ALL = 0, IGNORE_MOBILE_FRIENDS = 0x001, IGNORE_MOBILE_FOES = 0x010, IGNORE_MOBILE_NEUTRALS = 0x100, IGNORE_ALL_MOBILE_OBJS = IGNORE_MOBILE_FRIENDS | IGNORE_MOBILE_FOES | IGNORE_MOBILE_NEUTRALS } |
Flags that specify what objects to consider as obstacles. More... | |
Public Member Functions | |
| ST_ForceField () | |
| virtual | ~ST_ForceField () |
Implementation of relevant parts of the TerrainBase interface | |
| virtual void | init (sint4 tiles_x_, sint4 tiles_y_, sint4 tile_points_, sint4 client_pID_, sint4 neutral_pID) |
| Set map dimensions. | |
| virtual void | add_obj (const Object *obj) |
| virtual void | update_obj (const Object *obj) |
| virtual void | remove_obj (const Object *obj) |
| virtual void | add_segments (const Vector< TerrainBase::Segment > &s) |
| virtual void | cancel_task (const Object *obj) |
| virtual void | remove_task (TaskId tid) |
| TaskId | execute_task (const Task &task, const Path &path) |
| virtual void | execute_tasks (Vector< MoveCmd > &cmds, Vector< StatusMsg > &msgs) |
| Monitor path execution. | |
| virtual bool | plan_tasks (uint4 max_time=0) |
| Plan the paths you're handling. | |
| virtual real8 | find_path (const Loc &l1, const Loc &l2, sint4 radius, Path *path, ConsiderObjects consider=CONSIDER_ALL) |
| Compute path between l1 and l2 for a circular object. | |
| virtual real8 | find_path (const Object *obj, const Goal &goal, Path *path, ConsiderObjects consider=CONSIDER_ALL) |
| Compute path for a given (circular only) Object with a given Goal,. | |
Implementations for abstract TerrainBase Task-handling methods. | |
| virtual TaskId | add_task (const TerrainBase::Task &task) |
| Some of the method implementations are empty stubs, allowing derived classes to call TerrainBasicImp::X() as the first action in each method. | |
Static Public Member Functions | |
| static void | add_options (void) |
| add command-line options specific to this implementation, using static methods of class Options | |
Protected Member Functions | |
| void | eraseFromFailed (const TIter &it) |
| void | eraseFromPending (const TIter &it) |
| void | eraseObjIsGoalFor (const typename TaskId2Task::iterator &ti2tIt) |
Internal removal of tasks | |
| virtual void | clean_task_for_obj (const Object *obj) |
| These methods should be called internally (including by derived classes) to remove tasks, to differentiate requests by the outside world from internal bookkeeping. | |
| virtual void | clean_task (TerrainBase::TaskId task_id) |
Protected Attributes | |
| sint4 | tiles_x |
| playfield width | |
| sint4 | tiles_y |
| playfield height | |
| sint4 | tile_points |
| points on tile edge on fine grid | |
| sint4 | client_pID |
| ID of the client player. | |
| sint4 | neutral_pID |
| ID of neutral player (eg. sheep) | |
Internal book-keeping of tasks | |
| Tasks | tasks |
| TaskQueue | pendingTasks |
| TaskQueue | failedTasks |
| TaskId2Task | taskId2task |
| Obj2TaskId | obj2taskId |
| ObjIsGoalInTaskId | objIsGoalInTaskId |
Private Member Functions | |
| bool | plan_pending_task (uint4 stop_time) |
| Perform PF for a single pending task, and insert results to data structures. | |
| bool | plan_failed_task (uint4 stop_time) |
| Perform PF for a single failed task, and insert results to data structures. | |
| void | plan_task (TIter tit, uint4 stop_time) |
| Accessory function for planning either a pending or a failed task. | |
| TIter | get_random_failed_task (void) |
| Randomly choose a failed task. | |
| void | invalidate_paths (const Vector< Segment > &segments) |
| Invalidate existing paths that intersect a given new boundary. | |
| bool | is_at_goal (const Object *obj, const Task &task) |
| Test if the object is at the goal of the given task, implementing (some) of the various definitions of 'goal'. | |
| void | add_move_command (const Object *obj, Loc target, Vector< TerrainBase::MoveCmd > &cmds) |
| Add a move command to the Vector of commands, telling the object to move to the target location at maximum speed. | |
| sint4 | what_team (const Object *obj) |
| Determines what team an object is on. | |
Force Field methods | |
| void | get_forcefield_target (UnitPath_FF &path, Loc &output) |
| Calculates the direction that an object should move to, based on the path they are following and any obstacles in the vicinity. | |
| void | get_forcefield_target (const Object *obj, const Loc &attractor, Loc &output) |
| void | get_push_target (const Object *obj, Loc &output) |
| used for pushing, where there is no attractor | |
| void | restrict_vector (const Vec_2D &target_vec, Vec_2D &vec) |
| Adjusts the vector so that it is not directed more than 90 degrees on either side of the target vector. | |
| Loc | find_point_on_line (Loc loc, Loc line_start, Loc line_end) |
| Finds the location of point on a line that is closest to the given location. | |
| Vec_2D | get_point_repulsion (const Object *moving_obj, const Loc &point, sint4 radius=0) |
| Calculates the repulsion caused by a point on an object and returns it as a vector. | |
| Vec_2D | get_line_repulsion (const Object *moving_obj, const Segment &seg) |
| Calculates the repulsion caused by a line on an object and returns it as a vector. | |
| Loc | get_attractor (UnitPath_FF &path) |
| Calculates the position of the attractor along the path. | |
Static Private Member Functions | |
| static bool | is_at_location (const Object *obj, const Loc &target) |
| Test if the object is at the given location, accounting for a 1-tick look-ahead for moving objects. | |
| static bool | is_near_location (const Object *obj, const Loc &target, sint4 range) |
| Test if the distance from the object to the target is within the given range. | |
| static bool | is_in_range (const Object *moving_obj, const Object *goal_obj) |
| Test if the object is within firing range. | |
| static bool | is_in_range (const Object *moving_obj, const Loc goal_loc) |
Private Attributes | |
| Obj2LocMap | objects |
| Used to calculate object repulsion. | |
| Vector< Segment > | segments |
| Used to calculate wall repulsion. | |
| SegmentEndsMap | segment_ends |
| Used to calculate repulsion from the ends of walls. | |
| boost::shared_ptr < ST_Terrain::PFEngine > | pfEngine |
| The internal Path Finding engine. | |
| std::set< const Object * > | objsToStop |
| Objects for which we should set a stop-moving action. | |
| Random | rand |
| bool | pushing_on |
| bool | wp_attract |
| bool | stop_to_plan |
Static Private Attributes | |
| static const sint4 | FIELD_RANGE_MULTIPLIER = 2 |
| This multiplied by the max speed of an object gives the range at which objects and walls will exert a force on the objec. | |
| static const sint4 | ATTRACTOR_FORCE = 26 |
| The strength of attractors (does not vary with distance) | |
| static const sint4 | REPULSOR_BASELINE = 200 |
| This divided by the distance squared to the moving object gives the strength of the repulsors. | |
| static const sint4 | WAYPOINT_PROX = 2 |
| No longer used. | |
| static const sint4 | PATH_LOOK_AHEAD = 3 |
| this multiplied by the object max speed gives the distance ahead of the object on the path that the attractor will be set to | |
| static const uint4 | REPLAN_HARDCAP = 2 |
| Max number of replans for a task. | |
| static const sint4 | REPLAN_TRIGGER = 5 |
| Number of occilation steps before a replan will be triggered. | |
| static const sint4 | OCCILATION_TRIGGER = 15 |
| Number of occilation steps before a path movement failure will be passed. | |
Friends | |
| class | SimpleTerrainWidget |
| class | SimpleTerrainOverlay |
| class | ST_Terrain::PFEngine |
An implementation of the TerrainBase interface using forcefields for local pathfinding.
Definition at line 118 of file ST_ForceField.H.
| typedef std::map<const Object*, Loc> SimpleTerrain::ST_ForceField::Obj2LocMap |
Definition at line 153 of file ST_ForceField.H.
typedef std::map<const Object*,TerrainBase::TaskId> TerrainBasicImp< FF_Task >::Obj2TaskId [inherited] |
Definition at line 59 of file TerrainBasicImp.H.
typedef std::multimap<const Object*,TerrainBase::TaskId> TerrainBasicImp< FF_Task >::ObjIsGoalInTaskId [inherited] |
Definition at line 60 of file TerrainBasicImp.H.
typedef const void* TerrainBase::PathId [inherited] |
Definition at line 30 of file TerrainBase.H.
| typedef std::map<Loc, bool, Loc_less> SimpleTerrain::ST_ForceField::SegmentEndsMap |
Definition at line 154 of file ST_ForceField.H.
typedef const void* TerrainBase::TaskId [inherited] |
Definition at line 31 of file TerrainBase.H.
typedef std::map<TerrainBase::TaskId,TIter> TerrainBasicImp< FF_Task >::TaskId2Task [inherited] |
Definition at line 58 of file TerrainBasicImp.H.
typedef std::deque<TIter> TerrainBasicImp< FF_Task >::TaskQueue [inherited] |
Definition at line 57 of file TerrainBasicImp.H.
typedef std::list<FF_Task > TerrainBasicImp< FF_Task >::Tasks [inherited] |
Definition at line 52 of file TerrainBasicImp.H.
typedef Tasks::iterator TerrainBasicImp< FF_Task >::TIter [inherited] |
Definition at line 53 of file TerrainBasicImp.H.
enum TerrainBase::ConsiderObjects [inherited] |
Flags that specify what objects to consider as obstacles.
Definition at line 265 of file TerrainBase.H.
| SimpleTerrain::ST_ForceField::ST_ForceField | ( | ) |
Definition at line 87 of file ST_ForceField.C.
References Options::get().
| virtual SimpleTerrain::ST_ForceField::~ST_ForceField | ( | ) | [inline, virtual] |
Definition at line 123 of file ST_ForceField.H.
| void SimpleTerrain::ST_ForceField::add_move_command | ( | const Object * | obj, |
| Loc | target, | ||
| Vector< TerrainBase::MoveCmd > & | cmds | ||
| ) | [private] |
Add a move command to the Vector of commands, telling the object to move to the target location at maximum speed.
Also, updates the location associated with the object for forcefield purposes
Definition at line 603 of file ST_ForceField.C.
References FIND, Object::get_center(), Object::get_max_speed(), SimpleTerrain::Vec_2D::length(), min(), SimpleTerrain::Vec_2D::multiply(), TerrainBase::MoveCmd::next_loc, TerrainBase::MoveCmd::obj, objects, TerrainBase::MoveCmd::speed, speed, SimpleTerrain::Vec_2D::x, TerrainBase::Loc::x, SimpleTerrain::Vec_2D::y, and TerrainBase::Loc::y.
| void SimpleTerrain::ST_ForceField::add_obj | ( | const Object * | obj | ) | [virtual] |
Reimplemented from TerrainBasicImp< FF_Task >.
Definition at line 154 of file ST_ForceField.C.
References assert(), SimpleTerrain::is_obj_static(), objects, and pfEngine.
| void SimpleTerrain::ST_ForceField::add_options | ( | void | ) | [static] |
add command-line options specific to this implementation, using static methods of class Options
Definition at line 22 of file ST_ForceField.C.
| void SimpleTerrain::ST_ForceField::add_segments | ( | const Vector< TerrainBase::Segment > & | s | ) | [virtual] |
Reimplemented from TerrainBasicImp< FF_Task >.
Definition at line 216 of file ST_ForceField.C.
| virtual TaskId TerrainBasicImp< FF_Task >::add_task | ( | const TerrainBase::Task & | task | ) | [virtual, inherited] |
Some of the method implementations are empty stubs, allowing derived classes to call TerrainBasicImp::X() as the first action in each method.
Since this call is needed in remove_obj() (to remove tasks associated with this object), completeness calls for creating these stubs.
Implements TerrainBase.
| void SimpleTerrain::ST_ForceField::cancel_task | ( | const Object * | obj | ) | [virtual] |
Reimplemented from TerrainBasicImp< FF_Task >.
Definition at line 231 of file ST_ForceField.C.
References objsToStop.
| virtual void TerrainBasicImp< FF_Task >::clean_task | ( | TerrainBase::TaskId | task_id | ) | [protected, virtual, inherited] |
| virtual void TerrainBasicImp< FF_Task >::clean_task_for_obj | ( | const Object * | obj | ) | [protected, virtual, inherited] |
These methods should be called internally (including by derived classes) to remove tasks, to differentiate requests by the outside world from internal bookkeeping.
For example, add_task() first removes any existing tasks for the same objects, but this should not create stop-actions for them, etc.
| void TerrainBasicImp< FF_Task >::eraseFromFailed | ( | const TIter & | it | ) | [protected, inherited] |
| void TerrainBasicImp< FF_Task >::eraseFromPending | ( | const TIter & | it | ) | [protected, inherited] |
| void TerrainBasicImp< FF_Task >::eraseObjIsGoalFor | ( | const typename TaskId2Task::iterator & | ti2tIt | ) | [protected, inherited] |
| void SimpleTerrain::ST_ForceField::execute_tasks | ( | Vector< MoveCmd > & | cmds, |
| Vector< StatusMsg > & | msgs | ||
| ) | [virtual] |
Monitor path execution.
Should return move commands and status messages, and is expected to return quickly.
Implements TerrainBase.
Definition at line 323 of file ST_ForceField.C.
References SimpleTerrain::__assert_object_set_valid(), add_move_command, TerrainBase::StatusMsg::ARRIVED, SimpleTerrain::UnitPath::collision_step, SimpleTerrain::UnitPath::current_target, TerrainBase::Loc::distance(), Distance::distance(), FIND, FORALL, Object::get_center(), Object::get_moving(), Object::get_speed(), TerrainBase::Goal::LOCATION, TerrainBase::StatusMsg::MOVEMENT_FAILURE, TerrainBase::MoveCmd::next_loc, TerrainBase::StatusMsg::NO_PATH_FAILURE, TerrainBase::MoveCmd::obj, SimpleTerrain::UnitPath::obj, TerrainBase::StatusMsg::obj, objects, objsToStop, ServerObjData::owner, SimpleTerrain::UnitPath::path, GameObj::sod, TerrainBase::MoveCmd::speed, SimpleTerrain::UnitPath::spot, TerrainBase::StatusMsg::task_id, TEST, TerrainBase::StatusMsg::type, typeof, TerrainBase::Loc::x, and TerrainBase::Loc::y.
| real8 SimpleTerrain::ST_ForceField::find_path | ( | const Loc & | l1, |
| const Loc & | l2, | ||
| sint4 | radius, | ||
| Path * | path, | ||
| ConsiderObjects | consider = CONSIDER_ALL |
||
| ) | [virtual] |
Compute path between l1 and l2 for a circular object.
| l1 | Start of requested path. |
| l2 | End of requested path. |
| radius | Radius (half width) of the requested path. |
| path | If != NULL, and a path was found, this will contain the it (including l2 but not l1), with the first waypoint in locs[0]. |
| consider | What objects to consider as obstacles when searching for a path. |
Implements TerrainBase.
Definition at line 250 of file ST_ForceField.C.
References found, TerrainBase::Path::locs, path_length_from(), and pfEngine.
| real8 SimpleTerrain::ST_ForceField::find_path | ( | const Object * | obj, |
| const Goal & | goal, | ||
| Path * | path, | ||
| ConsiderObjects | consider = CONSIDER_ALL |
||
| ) | [virtual] |
Compute path for a given (circular only) Object with a given Goal,.
| obj | The object to move, including the start position and radius. |
| goal | Target of the requested path (location or object etc.). |
| path | If != NULL, and a path was found, this will contain it (including the final but not the start position), with the first waypoint in locs[0]. |
| consider | What objects to consider as obstacles when searching for a path. |
Implements TerrainBase.
Definition at line 273 of file ST_ForceField.C.
References assert(), found, get_center_loc(), TerrainBase::Goal::loc, TerrainBase::Goal::LOCATION, TerrainBase::Path::locs, TerrainBase::Goal::mode, TerrainBase::Goal::obj, TerrainBase::Goal::OBJ, path_length_from(), pfEngine, TerrainBase::Goal::target, and TerrainBase::Goal::TOUCH.
| Loc SimpleTerrain::ST_ForceField::find_point_on_line | ( | Loc | loc, |
| Loc | line_start, | ||
| Loc | line_end | ||
| ) | [private] |
Finds the location of point on a line that is closest to the given location.
Definition at line 953 of file ST_ForceField.C.
References TerrainBase::Loc::x, and TerrainBase::Loc::y.
| Loc SimpleTerrain::ST_ForceField::get_attractor | ( | UnitPath_FF & | path | ) | [private] |
Calculates the position of the attractor along the path.
The attractor is positioned a set distance ahead of the point closest to the object on the path.
Definition at line 896 of file ST_ForceField.C.
References SimpleTerrain::UnitPath::current_target, Object::get_center(), Object::get_max_speed(), SimpleTerrain::Vec_2D::length(), SimpleTerrain::Vec_2D::multiply(), SimpleTerrain::UnitPath::obj, SimpleTerrain::UnitPath::path, SimpleTerrain::Vec_2D::x, TerrainBase::Loc::x, SimpleTerrain::Vec_2D::y, and TerrainBase::Loc::y.
| void SimpleTerrain::ST_ForceField::get_forcefield_target | ( | const Object * | obj, |
| const Loc & | attractor, | ||
| Loc & | output | ||
| ) | [private] |
| object | The object that is moving |
| attractor | The point that is attracting the object |
| output | reference to a location that is in the direction that the object should move to. |
Definition at line 767 of file ST_ForceField.C.
References assert(), ATTRACTOR_FORCE, Object::CIRCLE, FIND, FORALL, Object::get_center(), Object::get_shape(), TerrainBase::Segment::l1, TerrainBase::Segment::l2, SimpleTerrain::Vec_2D::length(), SimpleTerrain::Vec_2D::multiply(), objects, Object::RECTANGLE, segments, SimpleTerrain::Vec_2D::x, TerrainBase::Loc::x, SimpleTerrain::Vec_2D::y, and TerrainBase::Loc::y.
| void SimpleTerrain::ST_ForceField::get_forcefield_target | ( | UnitPath_FF & | path, |
| Loc & | output | ||
| ) | [private] |
Calculates the direction that an object should move to, based on the path they are following and any obstacles in the vicinity.
| path | Path data |
| output | reference to a location that in the direction that the object should move to. fixme: maybe a location should be returned, instead of the pass by reference |
Definition at line 890 of file ST_ForceField.C.
References SimpleTerrain::UnitPath::obj.
| Vec_2D SimpleTerrain::ST_ForceField::get_line_repulsion | ( | const Object * | moving_obj, |
| const Segment & | seg | ||
| ) | [private] |
Calculates the repulsion caused by a line on an object and returns it as a vector.
Definition at line 1060 of file ST_ForceField.C.
References TerrainBase::Loc::distance(), SimpleTerrain::Vec_2D::dot_prod(), FIELD_RANGE_MULTIPLIER, Object::get_center(), Object::get_radius(), TerrainBase::Segment::l1, TerrainBase::Segment::l2, SimpleTerrain::Vec_2D::length(), SimpleTerrain::Vec_2D::multiply(), REPULSOR_BASELINE, TerrainBase::Loc::x, and TerrainBase::Loc::y.
| Vec_2D SimpleTerrain::ST_ForceField::get_point_repulsion | ( | const Object * | moving_obj, |
| const Loc & | point, | ||
| sint4 | radius = 0 |
||
| ) | [private] |
Calculates the repulsion caused by a point on an object and returns it as a vector.
Definition at line 1010 of file ST_ForceField.C.
References TerrainBase::Loc::distance(), FIELD_RANGE_MULTIPLIER, Object::get_center(), Object::get_radius(), SimpleTerrain::Vec_2D::length(), SimpleTerrain::Vec_2D::multiply(), REPULSOR_BASELINE, SimpleTerrain::Vec_2D::x, TerrainBase::Loc::x, SimpleTerrain::Vec_2D::y, and TerrainBase::Loc::y.
used for pushing, where there is no attractor
Definition at line 647 of file ST_ForceField.C.
References Object::CIRCLE, FIND, FORALL, Object::get_center(), Object::get_shape(), TerrainBase::Segment::l1, TerrainBase::Segment::l2, SimpleTerrain::Vec_2D::length(), objects, ServerObjData::owner, Object::RECTANGLE, round(), segments, GameObj::sod, SimpleTerrain::Vec_2D::x, TerrainBase::Loc::x, SimpleTerrain::Vec_2D::y, and TerrainBase::Loc::y.
| ST_ForceField::TIter SimpleTerrain::ST_ForceField::get_random_failed_task | ( | void | ) | [private] |
Randomly choose a failed task.
Return tasks.end() if no failed task exists.
Definition at line 1260 of file ST_ForceField.C.
| void SimpleTerrain::ST_ForceField::init | ( | sint4 | tiles_x_, |
| sint4 | tiles_y_, | ||
| sint4 | tile_points_, | ||
| sint4 | client_pID_, | ||
| sint4 | neutral_pID_ | ||
| ) | [virtual] |
Set map dimensions.
set playfield dimensions and gives the pathfinder the IDs of the client and the neutral players tiles_x/y : dimensions in tiles tile_points : points on tile edge on fine grid
Reimplemented from TerrainBase.
Definition at line 107 of file ST_ForceField.C.
References Options::get(), init(), pfEngine, segments, TerrainBase::Loc::x, and TerrainBase::Loc::y.
Invalidate existing paths that intersect a given new boundary.
Definition at line 304 of file ST_ForceField.C.
References FORALL, and Object::ON_LAND.
Test if the object is at the goal of the given task, implementing (some) of the various definitions of 'goal'.
Definition at line 1447 of file ST_ForceField.C.
References TerrainBase::Goal::ATTACK, TerrainBase::Goal::distance, Object::distance_to(), ERR, TerrainBase::Task::goal, TerrainBase::Goal::loc, TerrainBase::Goal::LOCATION, TerrainBase::Goal::mode, TerrainBase::Goal::obj, TerrainBase::Goal::OBJ, TerrainBase::Goal::target, TerrainBase::Goal::TOUCH, typeof, and TerrainBase::Goal::VICINITY.
| bool SimpleTerrain::ST_ForceField::is_at_location | ( | const Object * | obj, |
| const Loc & | target | ||
| ) | [static, private] |
Test if the object is at the given location, accounting for a 1-tick look-ahead for moving objects.
Definition at line 1431 of file ST_ForceField.C.
References TerrainBase::Loc::distance(), Object::get_center(), Object::get_max_speed(), TerrainBase::Loc::x, and TerrainBase::Loc::y.
| bool SimpleTerrain::ST_ForceField::is_in_range | ( | const Object * | moving_obj, |
| const Object * | goal_obj | ||
| ) | [static, private] |
Test if the object is within firing range.
Definition at line 1528 of file ST_ForceField.C.
References GameObj::component(), Object::distance_to(), and ScriptObj::get_int_ptr().
| bool SimpleTerrain::ST_ForceField::is_in_range | ( | const Object * | moving_obj, |
| const Loc | goal_loc | ||
| ) | [static, private] |
Definition at line 1505 of file ST_ForceField.C.
References GameObj::component(), TerrainBase::Loc::distance(), Object::get_center(), and ScriptObj::get_int_ptr().
| bool SimpleTerrain::ST_ForceField::is_near_location | ( | const Object * | obj, |
| const Loc & | target, | ||
| sint4 | range | ||
| ) | [static, private] |
Test if the distance from the object to the target is within the given range.
Definition at line 1441 of file ST_ForceField.C.
References TerrainBase::Loc::distance(), Object::get_center(), TerrainBase::Loc::x, and TerrainBase::Loc::y.
| bool SimpleTerrain::ST_ForceField::plan_failed_task | ( | uint4 | stop_time | ) | [private] |
Perform PF for a single failed task, and insert results to data structures.
Return true iff did some planning.
Definition at line 1285 of file ST_ForceField.C.
References SimpleTerrain::__assert_object_set_valid(), assert(), FORALL, objsToStop, and TEST.
| bool SimpleTerrain::ST_ForceField::plan_pending_task | ( | uint4 | stop_time | ) | [private] |
Perform PF for a single pending task, and insert results to data structures.
Return true iff did some planning.
Definition at line 1169 of file ST_ForceField.C.
References SimpleTerrain::__assert_object_set_valid(), ScriptObj::check_ptr(), ERR, FORALL, Object::get_moving(), ScriptObj::get_obj_id(), Object::get_speed(), objsToStop, and TEST.
Accessory function for planning either a pending or a failed task.
Definition at line 1376 of file ST_ForceField.C.
References SimpleTerrain::__assert_object_set_valid(), assert(), found, TerrainBase::Goal::LOCATION, TerrainBase::Path::locs, newpath, TerrainBase::Goal::OBJ, and pfEngine.
| bool SimpleTerrain::ST_ForceField::plan_tasks | ( | uint4 | max_time = 0 | ) | [virtual] |
Plan the paths you're handling.
This is where long thinking should be done. Return true iff did some lengthy processing. Try to use only the specified amount of time (milliseconds) for planning before returning control to the caller. If max_time == 0 then there is no requested time limit.
Implements TerrainBase.
Definition at line 1135 of file ST_ForceField.C.
| void SimpleTerrain::ST_ForceField::remove_obj | ( | const Object * | obj | ) | [virtual] |
Reimplemented from TerrainBasicImp< FF_Task >.
Definition at line 178 of file ST_ForceField.C.
References assert(), FIND, SimpleTerrain::is_obj_static(), TerrainBase::Goal::LOCATION, objects, objsToStop, pfEngine, TerrainBase::Loc::x, and TerrainBase::Loc::y.
| void SimpleTerrain::ST_ForceField::remove_task | ( | TaskId | tid | ) | [virtual] |
Reimplemented from TerrainBasicImp< FF_Task >.
Definition at line 238 of file ST_ForceField.C.
References SimpleTerrain::__assert_object_set_valid(), FIND, TerrainBase::Task::objs, and objsToStop.
| void SimpleTerrain::ST_ForceField::restrict_vector | ( | const Vec_2D & | target_vec, |
| Vec_2D & | vec | ||
| ) | [private] |
Adjusts the vector so that it is not directed more than 90 degrees on either side of the target vector.
Definition at line 999 of file ST_ForceField.C.
References SimpleTerrain::Vec_2D::dot_prod(), SimpleTerrain::Vec_2D::project_onto(), SimpleTerrain::Vec_2D::x, and SimpleTerrain::Vec_2D::y.
| void SimpleTerrain::ST_ForceField::update_obj | ( | const Object * | obj | ) | [virtual] |
Reimplemented from TerrainBasicImp< FF_Task >.
Definition at line 167 of file ST_ForceField.C.
References assert(), SimpleTerrain::is_obj_static(), and pfEngine.
Determines what team an object is on.
If the team cannot be determined, returns -1
Definition at line 638 of file ST_ForceField.C.
References ServerObjData::owner, and GameObj::sod.
friend class SimpleTerrainOverlay [friend] |
Definition at line 278 of file ST_ForceField.H.
friend class SimpleTerrainWidget [friend] |
Definition at line 277 of file ST_ForceField.H.
friend class ST_Terrain::PFEngine [friend] |
Definition at line 279 of file ST_ForceField.H.
const sint4 SimpleTerrain::ST_ForceField::ATTRACTOR_FORCE = 26 [static, private] |
The strength of attractors (does not vary with distance)
Definition at line 255 of file ST_ForceField.H.
sint4 TerrainBase::client_pID [protected, inherited] |
ID of the client player.
Definition at line 335 of file TerrainBase.H.
Referenced by TerrainBase::init(), and TerrainBase::TerrainBase().
TaskQueue TerrainBasicImp< FF_Task >::failedTasks [protected, inherited] |
Definition at line 119 of file TerrainBasicImp.H.
const sint4 SimpleTerrain::ST_ForceField::FIELD_RANGE_MULTIPLIER = 2 [static, private] |
This multiplied by the max speed of an object gives the range at which objects and walls will exert a force on the objec.
Definition at line 252 of file ST_ForceField.H.
sint4 TerrainBase::neutral_pID [protected, inherited] |
ID of neutral player (eg. sheep)
Definition at line 335 of file TerrainBase.H.
Referenced by TerrainBase::init(), and TerrainBase::TerrainBase().
Obj2TaskId TerrainBasicImp< FF_Task >::obj2taskId [protected, inherited] |
Definition at line 121 of file TerrainBasicImp.H.
Used to calculate object repulsion.
Definition at line 239 of file ST_ForceField.H.
ObjIsGoalInTaskId TerrainBasicImp< FF_Task >::objIsGoalInTaskId [protected, inherited] |
Definition at line 122 of file TerrainBasicImp.H.
std::set<const Object*> SimpleTerrain::ST_ForceField::objsToStop [private] |
Objects for which we should set a stop-moving action.
Definition at line 244 of file ST_ForceField.H.
const sint4 SimpleTerrain::ST_ForceField::OCCILATION_TRIGGER = 15 [static, private] |
Number of occilation steps before a path movement failure will be passed.
Definition at line 274 of file ST_ForceField.H.
const sint4 SimpleTerrain::ST_ForceField::PATH_LOOK_AHEAD = 3 [static, private] |
this multiplied by the object max speed gives the distance ahead of the object on the path that the attractor will be set to
Definition at line 266 of file ST_ForceField.H.
TaskQueue TerrainBasicImp< FF_Task >::pendingTasks [protected, inherited] |
Definition at line 118 of file TerrainBasicImp.H.
boost::shared_ptr<ST_Terrain::PFEngine> SimpleTerrain::ST_ForceField::pfEngine [private] |
The internal Path Finding engine.
Definition at line 243 of file ST_ForceField.H.
Referenced by SimpleTerrain::SimpleTerrainWidget::draw(), SimpleTerrain::SimpleTerrainOverlay::draw(), and SimpleTerrain::SimpleTerrainWidget::event_key_down().
bool SimpleTerrain::ST_ForceField::pushing_on [private] |
Definition at line 246 of file ST_ForceField.H.
Random SimpleTerrain::ST_ForceField::rand [private] |
Definition at line 245 of file ST_ForceField.H.
const uint4 SimpleTerrain::ST_ForceField::REPLAN_HARDCAP = 2 [static, private] |
Max number of replans for a task.
Definition at line 272 of file ST_ForceField.H.
const sint4 SimpleTerrain::ST_ForceField::REPLAN_TRIGGER = 5 [static, private] |
Number of occilation steps before a replan will be triggered.
Definition at line 273 of file ST_ForceField.H.
const sint4 SimpleTerrain::ST_ForceField::REPULSOR_BASELINE = 200 [static, private] |
This divided by the distance squared to the moving object gives the strength of the repulsors.
Definition at line 259 of file ST_ForceField.H.
Used to calculate repulsion from the ends of walls.
Definition at line 241 of file ST_ForceField.H.
Vector<Segment> SimpleTerrain::ST_ForceField::segments [private] |
Used to calculate wall repulsion.
Definition at line 240 of file ST_ForceField.H.
bool SimpleTerrain::ST_ForceField::stop_to_plan [private] |
Definition at line 248 of file ST_ForceField.H.
TaskId2Task TerrainBasicImp< FF_Task >::taskId2task [protected, inherited] |
Definition at line 120 of file TerrainBasicImp.H.
Tasks TerrainBasicImp< FF_Task >::tasks [protected, inherited] |
Definition at line 117 of file TerrainBasicImp.H.
sint4 TerrainBase::tile_points [protected, inherited] |
points on tile edge on fine grid
Definition at line 334 of file TerrainBase.H.
Referenced by SimplePathfinderWidget::draw(), SimplePathfinderOverlay::draw(), TerrainBase::init(), and TerrainBase::TerrainBase().
sint4 TerrainBase::tiles_x [protected, inherited] |
playfield width
Definition at line 332 of file TerrainBase.H.
Referenced by SimplePathfinderWidget::draw(), SimplePathfinderOverlay::draw(), TerrainBase::init(), and TerrainBase::TerrainBase().
sint4 TerrainBase::tiles_y [protected, inherited] |
playfield height
Definition at line 332 of file TerrainBase.H.
Referenced by SimplePathfinderOverlay::draw(), TerrainBase::init(), and TerrainBase::TerrainBase().
const sint4 SimpleTerrain::ST_ForceField::WAYPOINT_PROX = 2 [static, private] |
No longer used.
Definition at line 262 of file ST_ForceField.H.
bool SimpleTerrain::ST_ForceField::wp_attract [private] |
Definition at line 247 of file ST_ForceField.H.