Jump to content
RCA3

Best way to use calculatePath and addEventHandler PathCalculated?

Recommended Posts

@RCA3 how many data points did you end up with? aka you should be getting tons of waypoints as result with this approach

Share this post


Link to post
Share on other sites
On 11/22/2019 at 3:44 PM, johnnyboy said:

Way to persevere man.

👍

Thank you, brother.

 

On 11/22/2019 at 3:44 PM, johnnyboy said:

Are you experimenting to understand calculatePath usage, or do you have a specific purpose in mind? 

I actually needed this to finish a script i've been writing for a few weeks.

Specifically was for infantry patrols on roads.

 

On 11/23/2019 at 3:51 AM, .kju said:

@RCA3 how many data points did you end up with? aka you should be getting tons of waypoints as result with this approach

237 (per group) 😄

I'm using a derivative from this by @davidoss  to delete waypoints in between 100 meters. Not on this example though so i can't count that for you.

 

Spoiler

//Params:
// Array - array of positions (needs array if single param)
// Scalar - minimum distance. default 100
// Boolean - random. default false
//
//Returns:
//Array - positions within distance
//
//Author (original):
//Davidoss
//https://forums.bohemia.net/forums/topic/199978-combine-array/?do=findComment&comment=3126476

 

if (param [0] isEqualTo "preInit") exitWith{[]}; //preinit (no message)

 

if !(params[
    ["_posarray", [], [[]]] //Array of positions (needs array if single param)

]) exitWith{["Invalid parameter: %1.", param [0]] call BIS_fnc_error; []};

 

//Optional params
private _mindist = param [1, 100, [0]]; //Minimum distance to apply to points
private _random = param [2, false, [true]]; //Random delete point

 

//One or no points
if (count _posarray isEqualTo 0) exitWith{[]};
if (count _posarray isEqualTo 1) exitWith{_posarray};

 

private _ptsmindist = [_posarray # 0];

{
    private _curpt = _x;

    if (_ptsmindist findIf {(_x distance2D _curpt) < _mindist} isEqualTo -1 && {[true, ([true, false] select (round (random 1) isEqualTo 0))] select _random}) then{
        _ptsmindist pushBackUnique _curpt;
    };
}forEach _posarray;

_ptsmindist

 

Edit:

Might I add that this method (previous post) is calculated almost instantaneously despite the amount of data, sadly not being shown on the video.

Edited by RCA3
  • Thanks 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×