|
53 | 53 | #include "llglheaders.h" |
54 | 54 | #include "lldrawpoolterrain.h" |
55 | 55 | #include "lldrawable.h" |
| 56 | +#include "hippogridmanager.h" |
56 | 57 |
|
57 | 58 | extern LLPipeline gPipeline; |
58 | 59 | extern bool gShiftFrame; |
@@ -371,6 +372,14 @@ void LLSurface::connectNeighbor(LLSurface* neighborp, U32 direction) |
371 | 372 | // - Non-power-of-2 regions should work here, but the rest of the viewer code will probably choke on them. |
372 | 373 |
|
373 | 374 | surface_patch_ref patchp, neighbor_patchp; |
| 375 | + if (mNeighbors[direction] == neighborp) |
| 376 | + { |
| 377 | + return; |
| 378 | + } |
| 379 | + if (mNeighbors[direction]) |
| 380 | + { |
| 381 | + mNeighbors[direction]->disconnectNeighbor(this, gDirOpposite[direction]); |
| 382 | + } |
374 | 383 | mNeighbors[direction] = neighborp; |
375 | 384 |
|
376 | 385 | const S32 max_idx = mPatchesPerEdge - 1; |
@@ -480,33 +489,71 @@ void LLSurface::connectNeighbor(LLSurface* neighborp, U32 direction) |
480 | 489 | } |
481 | 490 | } |
482 | 491 |
|
483 | | -void LLSurface::disconnectNeighbor(LLSurface *surfacep) |
| 492 | +void LLSurface::disconnectNeighbor(LLSurface* surfacep, U32 direction) |
484 | 493 | { |
485 | | - S32 i; |
486 | | - for (i = 0; i < 8; i++) |
| 494 | + if (surfacep && surfacep == mNeighbors[direction]) |
487 | 495 | { |
488 | | - if (surfacep == mNeighbors[i]) |
| 496 | + // Iterate through surface patches, removing any connectivity to removed surface. |
| 497 | + // Extra branches for debugging. |
| 498 | + if (!gHippoGridManager->getCurrentGrid()->isSecondLife()) |
489 | 499 | { |
490 | | - mNeighbors[i] = NULL; |
| 500 | + for (auto& patchp : mPatchList) |
| 501 | + { |
| 502 | + patchp->disconnectNeighbor(surfacep); |
| 503 | + } |
| 504 | + } |
| 505 | + if (gHippoGridManager->getCurrentGrid()->isSecondLife()) |
| 506 | + { |
| 507 | + for (auto& patchp : mPatchList) |
| 508 | + { |
| 509 | + patchp->disconnectNeighbor(surfacep); |
| 510 | + } |
491 | 511 | } |
492 | | - } |
493 | | - |
494 | | - // Iterate through surface patches, removing any connectivity to removed surface. |
495 | | - for (auto& patchp : mPatchList) |
496 | | - { |
497 | | - patchp->disconnectNeighbor(surfacep); |
498 | 512 | } |
499 | 513 | } |
500 | 514 |
|
501 | 515 |
|
502 | 516 | void LLSurface::disconnectAllNeighbors() |
503 | 517 | { |
| 518 | + // Pulled out of loop to debug. |
| 519 | + if (mNeighbors[EAST]) |
| 520 | + { |
| 521 | + mNeighbors[EAST]->disconnectNeighbor(this, gDirOpposite[EAST]); |
| 522 | + } |
| 523 | + if (mNeighbors[NORTH]) |
| 524 | + { |
| 525 | + mNeighbors[NORTH]->disconnectNeighbor(this, gDirOpposite[NORTH]); |
| 526 | + } |
| 527 | + if (mNeighbors[WEST]) |
| 528 | + { |
| 529 | + mNeighbors[WEST]->disconnectNeighbor(this, gDirOpposite[WEST]); |
| 530 | + } |
| 531 | + if (mNeighbors[SOUTH]) |
| 532 | + { |
| 533 | + mNeighbors[SOUTH]->disconnectNeighbor(this, gDirOpposite[SOUTH]); |
| 534 | + } |
| 535 | + if (mNeighbors[NORTHEAST]) |
| 536 | + { |
| 537 | + mNeighbors[NORTHEAST]->disconnectNeighbor(this, gDirOpposite[NORTHEAST]); |
| 538 | + } |
| 539 | + if (mNeighbors[NORTHWEST]) |
| 540 | + { |
| 541 | + mNeighbors[NORTHWEST]->disconnectNeighbor(this, gDirOpposite[NORTHWEST]); |
| 542 | + } |
| 543 | + if (mNeighbors[SOUTHWEST]) |
| 544 | + { |
| 545 | + mNeighbors[SOUTHWEST]->disconnectNeighbor(this, gDirOpposite[SOUTHWEST]); |
| 546 | + } |
| 547 | + if (mNeighbors[SOUTHEAST]) |
| 548 | + { |
| 549 | + mNeighbors[SOUTHEAST]->disconnectNeighbor(this, gDirOpposite[SOUTHEAST]); |
| 550 | + } |
504 | 551 | S32 i; |
505 | 552 | for (i = 0; i < 8; i++) |
506 | 553 | { |
507 | 554 | if (mNeighbors[i]) |
508 | 555 | { |
509 | | - mNeighbors[i]->disconnectNeighbor(this); |
| 556 | + //mNeighbors[i]->disconnectNeighbor(this); |
510 | 557 | mNeighbors[i] = NULL; |
511 | 558 | } |
512 | 559 | } |
|
0 commit comments