Page 1 of 1
path cost is always zero
Posted: 12 Jan 2014, 07:18
by Shaitan
the following code
Code: Select all
...
for(std::vector<springai::AIFloat3>::iterator i = metalSpots.begin(); i != metalSpots.end(); ++i) {
...
int length = callback->GetPathing()->GetApproximateLength(commanderUnit->GetPos(), *i, 0, 8.0f);
...}
...
always returns zero path cost:
armcom position: (2565.161133, 120.874695, 4570.481934)
spot position: (5960.000000, 2039.000000, 520.000000)
length: 0
spot position: (9720.000000, 2039.000000, 776.000000)
length: 0
and so on.
why is that?
Re: path cost is always zero
Posted: 12 Jan 2014, 14:35
by AF
My initial thoughts are that you have found a bug in the wrapper generation. This will require further investigation
Re: path cost is always zero
Posted: 12 Jan 2014, 16:06
by Shaitan
shall i report the bug? can you inform those who need to know about it?
Re: path cost is always zero
Posted: 12 Jan 2014, 21:13
by AF
Re: path cost is always zero
Posted: 13 Jan 2014, 09:12
by Shaitan
Re: path cost is always zero
Posted: 22 Jan 2014, 11:08
by Shaitan
looks like the returned zero is a path ID, which i'm supposed to pass to
Code: Select all
springai::AIFloat3 GetNextWaypoint(int pathId)
but that function always returns an invalid AIFloat3. so i'm still stuck.
Re: path cost is always zero
Posted: 27 Jan 2014, 14:30
by AF
It's times like this I wish we had doxygen or some other docs, I don't know what the arguments for that method are called from memory or have the headers at hand
Re: path cost is always zero
Posted: 31 Jan 2014, 14:03
by abma
callback->GetPathing()->GetApproximateLength(commanderUnit->GetPos(), *i, 0, 8.0f);
thats a wrapper arround this function it seems:
float GetPathLength(float3 start, float3 end, int pathType, float goalRadius);
and i guess pathType is something from the unitdef, is there a pathType? but imo it makes no sense to set it to 0, thats what kloot meant with "wrong input parameter" i guess.
Code: Select all
* @param pathType For what type of unit should the path be calculated
next time grep the source code of spring for "GetApproximateLength". :)
edit: more code:
https://github.com/spring/spring/blob/d ... k.cpp#L735
Re: path cost is always zero
Posted: 31 Jan 2014, 17:48
by cleanrock
This is the doxygen text for GetApproximateLength:
/**
* Returns the approximate path cost between two points.
* - for pathType @see UnitDef_MoveData_getPathType()
* - goalRadius defines a goal area within which any square could be accepted as
* path target. If a singular goal position is wanted, use 0.0f.
* default: 8.0f
* @param start_posF3 The starting location of the requested path
* @param end_posF3 The goal location of the requested path
* @param pathType For what type of unit should the path be calculated
* @param goalRadius default: 8.0f
*/
I had some trouble finding info about pathType/UnitDef_MoveData_getPathType but hopefully it makes sense to game devs.