Add a Very Wip Entity Distance option code

TODO:
* maxChunkDistance dont need to be hardcoded.
* Add Entity Distance Slider and Classic Entity Distance Checkbox.
This commit is contained in:
GabsPuNs
2026-05-23 16:17:04 -04:00
parent 1e287ba2c4
commit 064b6b8512
2 changed files with 45 additions and 10 deletions

View File

@@ -1324,18 +1324,48 @@ void Entity::awardKillScore(shared_ptr<Entity> victim, int score)
bool Entity::shouldRender(Vec3 *c)
{
double xd = x - c->x;
double yd = y - c->y;
double zd = z - c->z;
double distance = xd * xd + yd * yd + zd * zd;
return shouldRenderAtSqrDistance(distance);
/*
if (!app.GetGameSettings(localplayer->GetXboxPad(),eGameSetting_ClassicEntityRender))
{
int entityChunkX = (int)std::floor(x / 16.0);
int entityChunkY = (int)std::floor(y / 16.0);
int entityChunkZ = (int)std::floor(z / 16.0);
int cameraChunkX = (int)std::floor(c->x / 16.0);
int cameraChunkY = (int)std::floor(c->y / 16.0);
int cameraChunkZ = (int)std::floor(c->z / 16.0);
int chunkDiffX = std::abs(entityChunkX - cameraChunkX);
int chunkDiffY = std::abs(entityChunkY - cameraChunkY);
int chunkDiffZ = std::abs(entityChunkZ - cameraChunkZ);
int maxXZ = (chunkDiffX > chunkDiffZ) ? chunkDiffX : chunkDiffZ;
int chunkDistance = (maxXZ > chunkDiffY) ? maxXZ : chunkDiffY;
return shouldRenderAtSqrDistance(chunkDistance);
}
else
*/
{
double xd = x - c->x;
double yd = y - c->y;
double zd = z - c->z;
double distance = xd * xd + yd * yd + zd * zd;
return shouldRenderAtSqrDistance(distance);
}
}
bool Entity::shouldRenderAtSqrDistance(double distance)
{
double size = bb->getSize();
size *= 64.0f * viewScale;
return distance < size * size;
/*
if (!app.GetGameSettings(localplayer->GetXboxPad(),eGameSetting_ClassicEntityRender))
return distance <= maxChunkDistance;
else
*/
{
double size = bb->getSize();
size *= 64.0f * viewScale;
return distance < size * size;
}
}
bool Entity::isCreativeModeAllowed()