mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-05-27 13:54:39 +00:00
refactor: remove calls to Vec3::newTemp when not returned
This commit is contained in:
@@ -1478,21 +1478,21 @@ HitResult* Level::clip(Vec3* a, Vec3* b, bool liquid, bool solidOnly) {
|
||||
a->z = zClip;
|
||||
}
|
||||
|
||||
Vec3* tPos = Vec3::newTemp(a->x, a->y, a->z);
|
||||
xTile0 = (int)(tPos->x = floor(a->x));
|
||||
Vec3 tPos(a->x, a->y, a->z);
|
||||
xTile0 = (int)(tPos.x = floor(a->x));
|
||||
if (face == 5) {
|
||||
xTile0--;
|
||||
tPos->x++;
|
||||
tPos.x++;
|
||||
}
|
||||
yTile0 = (int)(tPos->y = floor(a->y));
|
||||
yTile0 = (int)(tPos.y = floor(a->y));
|
||||
if (face == 1) {
|
||||
yTile0--;
|
||||
tPos->y++;
|
||||
tPos.y++;
|
||||
}
|
||||
zTile0 = (int)(tPos->z = floor(a->z));
|
||||
zTile0 = (int)(tPos.z = floor(a->z));
|
||||
if (face == 3) {
|
||||
zTile0--;
|
||||
tPos->z++;
|
||||
tPos.z++;
|
||||
}
|
||||
|
||||
int t = getTile(xTile0, yTile0, zTile0);
|
||||
@@ -2473,7 +2473,7 @@ bool Level::checkAndHandleWater(AABB* box, Material* material,
|
||||
}
|
||||
|
||||
bool ok = false;
|
||||
Vec3* current = Vec3::newTemp(0, 0, 0);
|
||||
Vec3 current(0, 0, 0);
|
||||
for (int x = x0; x < x1; x++) {
|
||||
for (int y = y0; y < y1; y++) {
|
||||
for (int z = z0; z < z1; z++) {
|
||||
@@ -2483,18 +2483,18 @@ bool Level::checkAndHandleWater(AABB* box, Material* material,
|
||||
y + 1 - LiquidTile::getHeight(getData(x, y, z));
|
||||
if (y1 >= yt0) {
|
||||
ok = true;
|
||||
tile->handleEntityInside(this, x, y, z, e, current);
|
||||
tile->handleEntityInside(this, x, y, z, e, ¤t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (current->length() > 0 && e->isPushedByWater()) {
|
||||
*current = current->normalize();
|
||||
if (current.length() > 0 && e->isPushedByWater()) {
|
||||
current = current.normalize();
|
||||
double pow = 0.014;
|
||||
e->xd += current->x * pow;
|
||||
e->yd += current->y * pow;
|
||||
e->zd += current->z * pow;
|
||||
e->xd += current.x * pow;
|
||||
e->yd += current.y * pow;
|
||||
e->zd += current.z * pow;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
@@ -2580,7 +2580,8 @@ float Level::getSeenPercent(Vec3* center, AABB* bb) {
|
||||
double x = bb->x0 + (bb->x1 - bb->x0) * xx;
|
||||
double y = bb->y0 + (bb->y1 - bb->y0) * yy;
|
||||
double z = bb->z0 + (bb->z1 - bb->z0) * zz;
|
||||
HitResult* res = clip(Vec3::newTemp(x, y, z), center);
|
||||
Vec3 a(x, y, z);
|
||||
HitResult* res = clip(&a, center);
|
||||
if (res == NULL) hits++;
|
||||
delete res;
|
||||
count++;
|
||||
|
||||
Reference in New Issue
Block a user