Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Vector2D edgeAvoidance(Agent &agent, const std::vector<Edge>& edges)
- {
- int ClosestEdge = -1;
- /* What you'd want to do here is iterate through a series of
- * lines connected to the agent ("feelers"; denoted 'flr') and check to see
- * if they intersect with an edge in the list. Do this and find the closest
- * edge for each of them. Once found, we will calculate the steering force
- * AWAY from said edge.*/
- ...
- // for all the "feelers": flr, also iterate through all the edges: curEdge
- {
- if (ClosestEdge >=0)
- {
- Vector2D OverShoot = agent.feelers[flr] - (*curEdge).normal();
- /* Create a force in the direction of the edge's normal, with a
- * magnitude of the overshoot*/
- SteeringForce = edges[ClosestEdge].normal() * OverShoot.length();
- }
- }
- return SteeringForce;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement