PathFinder - Crash fix, chunks in parameters are now references
This commit is contained in:
parent
9226bdbd4c
commit
599ad97b65
@ -131,12 +131,12 @@ void cMonster::TickPathFinding(cChunk & a_Chunk)
|
|||||||
|
|
||||||
// Can someone explain why are these two NOT THE SAME???
|
// Can someone explain why are these two NOT THE SAME???
|
||||||
// m_Path = new cPath(GetWorld(), GetPosition(), m_FinalDestination, 30);
|
// m_Path = new cPath(GetWorld(), GetPosition(), m_FinalDestination, 30);
|
||||||
m_Path = new cPath(&a_Chunk, Vector3d(floor(position.x), floor(position.y), floor(position.z)), Vector3d(floor(Dest.x), floor(Dest.y), floor(Dest.z)), 20);
|
m_Path = new cPath(a_Chunk, Vector3d(floor(position.x), floor(position.y), floor(position.z)), Vector3d(floor(Dest.x), floor(Dest.y), floor(Dest.z)), 20);
|
||||||
|
|
||||||
|
|
||||||
m_IsFollowingPath = false;
|
m_IsFollowingPath = false;
|
||||||
}
|
}
|
||||||
m_PathStatus = m_Path->Step(&a_Chunk);
|
m_PathStatus = m_Path->Step(a_Chunk);
|
||||||
switch (m_PathStatus)
|
switch (m_PathStatus)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -35,17 +35,16 @@ bool compareHeuristics::operator()(cPathCell * & a_Cell1, cPathCell * & a_Cell2)
|
|||||||
|
|
||||||
/* cPath implementation */
|
/* cPath implementation */
|
||||||
cPath::cPath(
|
cPath::cPath(
|
||||||
cChunk * a_Chunk,
|
cChunk & a_Chunk,
|
||||||
const Vector3d & a_StartingPoint, const Vector3d & a_EndingPoint, int a_MaxSteps,
|
const Vector3d & a_StartingPoint, const Vector3d & a_EndingPoint, int a_MaxSteps,
|
||||||
double a_BoundingBoxWidth, double a_BoundingBoxHeight,
|
double a_BoundingBoxWidth, double a_BoundingBoxHeight,
|
||||||
int a_MaxUp, int a_MaxDown
|
int a_MaxUp, int a_MaxDown
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT(m_Chunk != nullptr);
|
|
||||||
// TODO: if src not walkable OR dest not walkable, then abort.
|
// TODO: if src not walkable OR dest not walkable, then abort.
|
||||||
// Borrow a new "isWalkable" from ProcessIfWalkable, make ProcessIfWalkable also call isWalkable
|
// Borrow a new "isWalkable" from ProcessIfWalkable, make ProcessIfWalkable also call isWalkable
|
||||||
|
|
||||||
m_Chunk = a_Chunk;
|
m_Chunk = &a_Chunk;
|
||||||
m_Source = a_StartingPoint.Floor();
|
m_Source = a_StartingPoint.Floor();
|
||||||
m_Destination = a_EndingPoint.Floor();
|
m_Destination = a_EndingPoint.Floor();
|
||||||
|
|
||||||
@ -80,10 +79,9 @@ cPath::~cPath()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
ePathFinderStatus cPath::Step(cChunk * a_Chunk)
|
ePathFinderStatus cPath::Step(cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
m_Chunk = a_Chunk;
|
m_Chunk = &a_Chunk;
|
||||||
ASSERT(m_Chunk != nullptr);
|
|
||||||
if (m_Status != ePathFinderStatus::CALCULATING)
|
if (m_Status != ePathFinderStatus::CALCULATING)
|
||||||
{
|
{
|
||||||
return m_Status;
|
return m_Status;
|
||||||
|
@ -52,7 +52,7 @@ public:
|
|||||||
@param a_EndingPoint "The block where the Zombie's knees want to be".
|
@param a_EndingPoint "The block where the Zombie's knees want to be".
|
||||||
@param a_MaxSteps The maximum steps before giving up. */
|
@param a_MaxSteps The maximum steps before giving up. */
|
||||||
cPath(
|
cPath(
|
||||||
cChunk * a_Chunk,
|
cChunk & a_Chunk,
|
||||||
const Vector3d & a_StartingPoint, const Vector3d & a_EndingPoint, int a_MaxSteps,
|
const Vector3d & a_StartingPoint, const Vector3d & a_EndingPoint, int a_MaxSteps,
|
||||||
double a_BoundingBoxWidth = 1, double a_BoundingBoxHeight = 2,
|
double a_BoundingBoxWidth = 1, double a_BoundingBoxHeight = 2,
|
||||||
int a_MaxUp = 1, int a_MaxDown = 1
|
int a_MaxUp = 1, int a_MaxDown = 1
|
||||||
@ -62,7 +62,7 @@ public:
|
|||||||
~cPath();
|
~cPath();
|
||||||
|
|
||||||
/** Performs part of the path calculation and returns true if the path computation has finished. */
|
/** Performs part of the path calculation and returns true if the path computation has finished. */
|
||||||
ePathFinderStatus Step(cChunk * a_Chunk);
|
ePathFinderStatus Step(cChunk & a_Chunk);
|
||||||
|
|
||||||
/* Point retrieval functions, inlined for performance. */
|
/* Point retrieval functions, inlined for performance. */
|
||||||
/** Returns the next point in the path. */
|
/** Returns the next point in the path. */
|
||||||
|
Loading…
Reference in New Issue
Block a user