refactor: remove AABB::newTemp when not returned

This commit is contained in:
orng
2026-03-27 21:56:57 -05:00
parent 534879e2e7
commit d7d99db4c5
24 changed files with 112 additions and 111 deletions
@@ -733,9 +733,9 @@ void ConsoleSchematicFile::generateSchematicFile(
}
tag.put(L"TileEntities", tileEntitiesTag);
AABB* bb = AABB::newTemp(xStart, yStart, zStart, xEnd, yEnd, zEnd);
AABB bb(xStart, yStart, zStart, xEnd, yEnd, zEnd);
std::vector<std::shared_ptr<Entity> >* entities =
level->getEntities(nullptr, bb);
level->getEntities(nullptr, &bb);
ListTag<CompoundTag>* entitiesTag = new ListTag<CompoundTag>(L"entities");
for (AUTO_VAR(it, entities->begin()); it != entities->end(); ++it) {
@@ -253,13 +253,12 @@ void LevelGenerationOptions::addAttribute(const std::wstring& attributeName,
void LevelGenerationOptions::processSchematics(LevelChunk* chunk) {
PIXBeginNamedEvent(0, "Processing schematics for chunk (%d,%d)", chunk->x,
chunk->z);
AABB* chunkBox =
AABB::newTemp(chunk->x * 16, 0, chunk->z * 16, chunk->x * 16 + 16,
Level::maxBuildHeight, chunk->z * 16 + 16);
AABB chunkBox(chunk->x * 16, 0, chunk->z * 16, chunk->x * 16 + 16,
Level::maxBuildHeight, chunk->z * 16 + 16);
for (AUTO_VAR(it, m_schematicRules.begin()); it != m_schematicRules.end();
++it) {
ApplySchematicRuleDefinition* rule = *it;
rule->processSchematic(chunkBox, chunk);
rule->processSchematic(&chunkBox, chunk);
}
int cx = (chunk->x << 4);
@@ -282,13 +281,12 @@ void LevelGenerationOptions::processSchematics(LevelChunk* chunk) {
void LevelGenerationOptions::processSchematicsLighting(LevelChunk* chunk) {
PIXBeginNamedEvent(0, "Processing schematics (lighting) for chunk (%d,%d)",
chunk->x, chunk->z);
AABB* chunkBox =
AABB::newTemp(chunk->x * 16, 0, chunk->z * 16, chunk->x * 16 + 16,
Level::maxBuildHeight, chunk->z * 16 + 16);
AABB chunkBox(chunk->x * 16, 0, chunk->z * 16, chunk->x * 16 + 16,
Level::maxBuildHeight, chunk->z * 16 + 16);
for (AUTO_VAR(it, m_schematicRules.begin()); it != m_schematicRules.end();
++it) {
ApplySchematicRuleDefinition* rule = *it;
rule->processSchematicLighting(chunkBox, chunk);
rule->processSchematicLighting(&chunkBox, chunk);
}
PIXEndNamedEvent();
}
@@ -329,8 +329,8 @@ bool Tile_SPU::isSolidRender(bool isServerLevel) { return true; }
// {
// int newCount =
// ExperienceOrb::getExperienceValue(amount); amount -=
// newCount; level->addEntity(std::shared_ptr<ExperienceOrb>( new
// ExperienceOrb(level, x + .5, y + .5, z + .5, newCount)));
// newCount; level->addEntity(std::shared_ptr<ExperienceOrb>(
// new ExperienceOrb(level, x + .5, y + .5, z + .5, newCount)));
// }
// }
// }
+17 -17
View File
@@ -2481,9 +2481,9 @@ void LevelRenderer::renderHitOutline(std::shared_ptr<Player> player,
double zo = player->zOld + (player->z - player->zOld) * a;
AABB bb = Tile::tiles[tileId]
->getTileAABB(level[iPad], h->x, h->y, h->z)
->grow(ss, ss, ss)
.move(-xo, -yo, -zo);
->getTileAABB(level[iPad], h->x, h->y, h->z)
->grow(ss, ss, ss)
.move(-xo, -yo, -zo);
render(&bb);
}
@@ -3891,20 +3891,20 @@ void LevelRenderer::DestroyedTileManager::destroyingTileAt(Level* level, int x,
// ones, so make a temporary list and then copy over
RecentTile* recentTile = new RecentTile(x, y, z, level);
AABB* box = AABB::newTemp((float)x, (float)y, (float)z, (float)(x + 1),
(float)(y + 1), (float)(z + 1));
AABB box((float)x, (float)y, (float)z, (float)(x + 1), (float)(y + 1),
(float)(z + 1));
Tile* tile = Tile::tiles[level->getTile(x, y, z)];
if (tile != NULL) {
tile->addAABBs(level, x, y, z, box, &recentTile->boxes, nullptr);
tile->addAABBs(level, x, y, z, &box, &recentTile->boxes, nullptr);
}
// Make these temporary AABBs into permanently allocated AABBs
for (unsigned int i = 0; i < recentTile->boxes.size(); i++) {
recentTile->boxes[i] = new AABB(
recentTile->boxes[i]->x0, recentTile->boxes[i]->y0,
recentTile->boxes[i]->z0, recentTile->boxes[i]->x1,
recentTile->boxes[i]->y1, recentTile->boxes[i]->z1);
recentTile->boxes[i] =
new AABB(recentTile->boxes[i]->x0, recentTile->boxes[i]->y0,
recentTile->boxes[i]->z0, recentTile->boxes[i]->x1,
recentTile->boxes[i]->y1, recentTile->boxes[i]->z1);
}
m_destroyedTiles.push_back(recentTile);
@@ -3978,13 +3978,13 @@ void LevelRenderer::DestroyedTileManager::addAABBs(Level* level, AABB* box,
// AABB copy so that we can destroy our own copy without
// worrying about the lifespan of the copy we've passed out
if (m_destroyedTiles[i]->boxes[j]->intersects(*box)) {
boxes->push_back(
AABB::newTemp(m_destroyedTiles[i]->boxes[j]->x0,
m_destroyedTiles[i]->boxes[j]->y0,
m_destroyedTiles[i]->boxes[j]->z0,
m_destroyedTiles[i]->boxes[j]->x1,
m_destroyedTiles[i]->boxes[j]->y1,
m_destroyedTiles[i]->boxes[j]->z1));
AABB bb(m_destroyedTiles[i]->boxes[j]->x0,
m_destroyedTiles[i]->boxes[j]->y0,
m_destroyedTiles[i]->boxes[j]->z0,
m_destroyedTiles[i]->boxes[j]->x1,
m_destroyedTiles[i]->boxes[j]->y1,
m_destroyedTiles[i]->boxes[j]->z1);
boxes->push_back(&bb);
}
}
}