Potentially fix crash in LLSurface

This commit is contained in:
Shyotl
2020-04-07 23:30:12 -05:00
parent 0aa5e0bb88
commit ed7f73769f
2 changed files with 9 additions and 53 deletions

View File

@@ -493,21 +493,10 @@ void LLSurface::disconnectNeighbor(LLSurface* surfacep, U32 direction)
{ {
if (surfacep && surfacep == mNeighbors[direction]) if (surfacep && surfacep == mNeighbors[direction])
{ {
// Iterate through surface patches, removing any connectivity to removed surface. mNeighbors[direction] = NULL;
// Extra branches for debugging. for (auto& patchp : mPatchList)
if (!gHippoGridManager->getCurrentGrid()->isSecondLife())
{ {
for (auto& patchp : mPatchList) patchp->disconnectNeighbor(surfacep);
{
patchp->disconnectNeighbor(surfacep);
}
}
if (gHippoGridManager->getCurrentGrid()->isSecondLife())
{
for (auto& patchp : mPatchList)
{
patchp->disconnectNeighbor(surfacep);
}
} }
} }
} }
@@ -515,46 +504,13 @@ void LLSurface::disconnectNeighbor(LLSurface* surfacep, U32 direction)
void LLSurface::disconnectAllNeighbors() void LLSurface::disconnectAllNeighbors()
{ {
// Pulled out of loop to debug. for (size_t i = 0; i < mNeighbors.size(); ++i)
if (mNeighbors[EAST])
{ {
mNeighbors[EAST]->disconnectNeighbor(this, gDirOpposite[EAST]); auto& neighbor = mNeighbors[i];
} if (neighbor)
if (mNeighbors[NORTH])
{
mNeighbors[NORTH]->disconnectNeighbor(this, gDirOpposite[NORTH]);
}
if (mNeighbors[WEST])
{
mNeighbors[WEST]->disconnectNeighbor(this, gDirOpposite[WEST]);
}
if (mNeighbors[SOUTH])
{
mNeighbors[SOUTH]->disconnectNeighbor(this, gDirOpposite[SOUTH]);
}
if (mNeighbors[NORTHEAST])
{
mNeighbors[NORTHEAST]->disconnectNeighbor(this, gDirOpposite[NORTHEAST]);
}
if (mNeighbors[NORTHWEST])
{
mNeighbors[NORTHWEST]->disconnectNeighbor(this, gDirOpposite[NORTHWEST]);
}
if (mNeighbors[SOUTHWEST])
{
mNeighbors[SOUTHWEST]->disconnectNeighbor(this, gDirOpposite[SOUTHWEST]);
}
if (mNeighbors[SOUTHEAST])
{
mNeighbors[SOUTHEAST]->disconnectNeighbor(this, gDirOpposite[SOUTHEAST]);
}
S32 i;
for (i = 0; i < 8; i++)
{
if (mNeighbors[i])
{ {
//mNeighbors[i]->disconnectNeighbor(this); neighbor->disconnectNeighbor(this, gDirOpposite[i]);
mNeighbors[i] = NULL; neighbor = NULL;
} }
} }
} }

View File

@@ -167,7 +167,7 @@ public:
// +---+---+---+ // +---+---+---+
// |SW | S | SE| // |SW | S | SE|
// +---+---+---+ // +---+---+---+
LLSurface *mNeighbors[8]; // Adjacent patches std::array<LLSurface*, 8> mNeighbors; // Adjacent patches
U32 mType; // Useful for identifying derived classes U32 mType; // Useful for identifying derived classes