mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-26 18:33:39 +00:00
disable LTO for now, entity micro-optimizations
This commit is contained in:
parent
abeead819e
commit
85a4e09e17
|
|
@ -12,8 +12,8 @@ project(
|
|||
'unity_size=8', # TODO: mess around with this
|
||||
'buildtype=debugoptimized', # needed for _FORTIFY_SOURCE
|
||||
'b_pch=true', # precompiled headers
|
||||
'b_lto=true', # link-time optimisation (ThinLTO under clang+lld)
|
||||
'b_ndebug=if-release', # drop assert() in --buildtype=release
|
||||
# 'b_lto=true', # link-time optimisation (ThinLTO under clang+lld)
|
||||
# 'b_ndebug=if-release', # drop assert() in --buildtype=release
|
||||
],
|
||||
)
|
||||
|
||||
|
|
@ -27,7 +27,6 @@ global_cpp_defs = [
|
|||
'-DSPLIT_SAVES',
|
||||
'-D_LARGE_WORLDS',
|
||||
'-D_EXTENDED_ACHIEVEMENTS',
|
||||
'-D_FORTIFY_SOURCE=2',
|
||||
'-DMULTITHREAD_ENABLE', # always-on threading flag (formerly in App_Defines.h)
|
||||
]
|
||||
|
||||
|
|
@ -42,6 +41,10 @@ if get_option('buildtype') in ['debug', 'debugoptimized']
|
|||
]
|
||||
endif
|
||||
|
||||
if get_option('buildtype') == 'debugoptimized'
|
||||
global_cpp_defs += ['-D_FORTIFY_SOURCE=2']
|
||||
endif
|
||||
|
||||
# MARK: meson options
|
||||
|
||||
if get_option('enable_vsync')
|
||||
|
|
|
|||
|
|
@ -684,12 +684,14 @@ void Entity::move(double xa, double ya, double za,
|
|||
bool isPlayerSneaking =
|
||||
onGround && isSneaking() && instanceof(eTYPE_PLAYER);
|
||||
|
||||
auto shared = shared_from_this();
|
||||
|
||||
if (isPlayerSneaking) {
|
||||
double d = 0.05;
|
||||
|
||||
AABB translated_bb = bb.move(xa, -1.0, 0.0);
|
||||
while (xa != 0 &&
|
||||
level->getCubes(shared_from_this(), &translated_bb)->empty()) {
|
||||
level->getCubes(shared, &translated_bb)->empty()) {
|
||||
if (xa < d && xa >= -d)
|
||||
xa = 0;
|
||||
else if (xa > 0)
|
||||
|
|
@ -701,7 +703,7 @@ void Entity::move(double xa, double ya, double za,
|
|||
|
||||
translated_bb = bb.move(0, -1.0, za);
|
||||
while (za != 0 &&
|
||||
level->getCubes(shared_from_this(), &translated_bb)->empty()) {
|
||||
level->getCubes(shared, &translated_bb)->empty()) {
|
||||
if (za < d && za >= -d)
|
||||
za = 0;
|
||||
else if (za > 0)
|
||||
|
|
@ -713,7 +715,7 @@ void Entity::move(double xa, double ya, double za,
|
|||
|
||||
translated_bb = bb.move(xa, -1.0, za);
|
||||
while (xa != 0 && za != 0 &&
|
||||
level->getCubes(shared_from_this(), &translated_bb)->empty()) {
|
||||
level->getCubes(shared, &translated_bb)->empty()) {
|
||||
if (xa < d && xa >= -d)
|
||||
xa = 0;
|
||||
else if (xa > 0)
|
||||
|
|
@ -733,7 +735,7 @@ void Entity::move(double xa, double ya, double za,
|
|||
|
||||
AABB expanded = bb.expand(xa, ya, za);
|
||||
std::vector<AABB>* aABBs =
|
||||
level->getCubes(shared_from_this(), &expanded, noEntityCubes, true);
|
||||
level->getCubes(shared, &expanded, noEntityCubes, true);
|
||||
|
||||
// LAND FIRST, then x and z
|
||||
auto itEndAABB = aABBs->end();
|
||||
|
|
|
|||
|
|
@ -1244,8 +1244,12 @@ void LivingEntity::jumpFromGround() {
|
|||
}
|
||||
|
||||
void LivingEntity::travel(float xa, float ya) {
|
||||
std::shared_ptr<Player> thisPlayer =
|
||||
std::dynamic_pointer_cast<Player>(shared_from_this());
|
||||
// AP - dynamic_pointer_cast is a non-trivial call, use raw pointer instead
|
||||
Player* thisPlayer = nullptr;
|
||||
if (this->instanceof(eTYPE_PLAYER)) {
|
||||
thisPlayer = (Player*)this;
|
||||
}
|
||||
|
||||
if (isInWater() && !(thisPlayer && thisPlayer->abilities.flying)) {
|
||||
double yo = y;
|
||||
moveRelative(xa, ya, useNewAi() ? 0.04f : 0.02f);
|
||||
|
|
@ -1273,13 +1277,13 @@ void LivingEntity::travel(float xa, float ya) {
|
|||
}
|
||||
} else {
|
||||
float friction = 0.91f;
|
||||
int frictionTile = 0;
|
||||
if (onGround) {
|
||||
friction = 0.6f * 0.91f;
|
||||
int t = level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1,
|
||||
Mth::floor(z));
|
||||
if (t > 0) {
|
||||
friction = Tile::tiles[t]->friction * 0.91f;
|
||||
}
|
||||
frictionTile = level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1, Mth::floor(z));
|
||||
if (frictionTile > 0) {
|
||||
friction = Tile::tiles[frictionTile]->friction * 0.91f;
|
||||
}
|
||||
}
|
||||
|
||||
float friction2 = (0.6f * 0.6f * 0.91f * 0.91f * 0.6f * 0.91f) /
|
||||
|
|
@ -1297,11 +1301,9 @@ void LivingEntity::travel(float xa, float ya) {
|
|||
friction = 0.91f;
|
||||
if (onGround) {
|
||||
friction = 0.6f * 0.91f;
|
||||
int t = level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1,
|
||||
Mth::floor(z));
|
||||
if (t > 0) {
|
||||
friction = Tile::tiles[t]->friction * 0.91f;
|
||||
}
|
||||
if (frictionTile > 0) {
|
||||
friction = Tile::tiles[frictionTile]->friction * 0.91f;
|
||||
}
|
||||
}
|
||||
if (onLadder()) {
|
||||
float max = 0.15f;
|
||||
|
|
|
|||
Loading…
Reference in a new issue