| 561 | |
| 562 | |
| 563 | void cBFSPieceGenerator::PlacePieces(int a_BlockX, int a_BlockY, int a_BlockZ, int a_MaxDepth, cPlacedPieces & a_OutPieces) |
| 564 | { |
| 565 | a_OutPieces.clear(); |
| 566 | cFreeConnectors ConnectorPool; |
| 567 | |
| 568 | // Place the starting piece: |
| 569 | a_OutPieces.push_back(PlaceStartingPiece(a_BlockX, a_BlockY, a_BlockZ, ConnectorPool)); |
| 570 | |
| 571 | /* |
| 572 | // DEBUG: |
| 573 | printf("Placed the starting piece at {%d, %d, %d}\n", a_BlockX, a_BlockY, a_BlockZ); |
| 574 | cCuboid Hitbox = a_OutPieces[0]->GetHitBox(); |
| 575 | Hitbox.Sort(); |
| 576 | printf(" Hitbox: {%d, %d, %d} - {%d, %d, %d} (%d * %d * %d)\n", |
| 577 | Hitbox.p1.x, Hitbox.p1.y, Hitbox.p1.z, |
| 578 | Hitbox.p2.x, Hitbox.p2.y, Hitbox.p2.z, |
| 579 | Hitbox.DifX() + 1, Hitbox.DifY() + 1, Hitbox.DifZ() + 1 |
| 580 | ); |
| 581 | DebugConnectorPool(ConnectorPool, 0); |
| 582 | //*/ |
| 583 | |
| 584 | // Place pieces at the available connectors: |
| 585 | /* |
| 586 | Instead of removing them one by one from the pool, we process them sequentially and take note of the last |
| 587 | processed one. To save on memory, once the number of processed connectors reaches a big number, a chunk |
| 588 | of the connectors is removed. |
| 589 | */ |
| 590 | size_t NumProcessed = 0; |
| 591 | while (ConnectorPool.size() > NumProcessed) |
| 592 | { |
| 593 | cFreeConnector & Conn = ConnectorPool[NumProcessed]; |
| 594 | if (Conn.m_Piece->GetDepth() < a_MaxDepth) |
| 595 | { |
| 596 | if (TryPlacePieceAtConnector(*Conn.m_Piece, Conn.m_Connector, a_OutPieces, ConnectorPool)) |
| 597 | { |
| 598 | /* |
| 599 | // DEBUG: |
| 600 | const cPlacedPiece * NewPiece = a_OutPieces.back(); |
| 601 | const Vector3i & Coords = NewPiece->GetCoords(); |
| 602 | printf("Placed a new piece at {%d, %d, %d}, rotation %d\n", Coords.x, Coords.y, Coords.z, NewPiece->GetNumCCWRotations()); |
| 603 | cCuboid Hitbox = NewPiece->GetHitBox(); |
| 604 | Hitbox.Sort(); |
| 605 | printf(" Hitbox: {%d, %d, %d} - {%d, %d, %d} (%d * %d * %d)\n", |
| 606 | Hitbox.p1.x, Hitbox.p1.y, Hitbox.p1.z, |
| 607 | Hitbox.p2.x, Hitbox.p2.y, Hitbox.p2.z, |
| 608 | Hitbox.DifX() + 1, Hitbox.DifY() + 1, Hitbox.DifZ() + 1 |
| 609 | ); |
| 610 | DebugConnectorPool(ConnectorPool, NumProcessed + 1); |
| 611 | //*/ |
| 612 | } |
| 613 | } |
| 614 | NumProcessed++; |
| 615 | if (NumProcessed > 1000) |
| 616 | { |
| 617 | ConnectorPool.erase(ConnectorPool.begin(), ConnectorPool.begin() + NumProcessed); |
| 618 | NumProcessed = 0; |
| 619 | } |
| 620 | } |
no test coverage detected