Skip to content

Commit

Permalink
Minor code style improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
Flone-dnb committed Dec 30, 2023
1 parent e6c4b3d commit 855ef3b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/engine_lib/private/game/nodes/SpatialNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,20 +300,24 @@ namespace ne {
#if defined(DEBUG)
void SpatialNode::warnIfExceedingWorldBounds() {
std::scoped_lock guard(*getSpawnDespawnMutex(), mtxWorldMatrix.first);
// Make sure we are spawned.
if (!isSpawned()) {
return;
}

// Get game instance.
const auto pGameInstance = getGameInstance();
if (pGameInstance == nullptr) [[unlikely]] {
return;
}

const float worldSizeOneDimention = static_cast<float>(pGameInstance->getWorldSize()) / 2.0F;
// Get half of the world size.
const float worldHalfSize = static_cast<float>(pGameInstance->getWorldSize()) / 2.0F;

if (std::abs(mtxWorldMatrix.second.worldLocation.x) > worldSizeOneDimention ||
std::abs(mtxWorldMatrix.second.worldLocation.y) > worldSizeOneDimention ||
std::abs(mtxWorldMatrix.second.worldLocation.z) > worldSizeOneDimention) {
// Make sure we are not exceeding world bounds.
if (std::abs(mtxWorldMatrix.second.worldLocation.x) > worldHalfSize ||
std::abs(mtxWorldMatrix.second.worldLocation.y) > worldHalfSize ||
std::abs(mtxWorldMatrix.second.worldLocation.z) > worldHalfSize) {
Logger::get().warn(std::format(
"[{}] spatial node \"{}\" is exceeding world bounds, node's world location: "
"({}, {}, {}), world size: {}",
Expand Down

0 comments on commit 855ef3b

Please sign in to comment.