Reduce collision trapping and improve /unstuck

Add root, branch, thorn, moss, ivy, and other natural doodads to the no-block foliage list. /unstuck now moves the player 5 units forward instead of resetting in place.
This commit is contained in:
Kelsi 2026-02-07 23:34:28 -08:00
parent 394e1a3f31
commit 22b9ee9726
3 changed files with 19 additions and 5 deletions

View file

@ -1,6 +1,7 @@
#include "core/application.hpp"
#include "core/coordinates.hpp"
#include <unordered_set>
#include <cmath>
#include "core/spawn_presets.hpp"
#include "core/logger.hpp"
#include "rendering/renderer.hpp"
@ -539,14 +540,18 @@ void Application::setupUICallbacks() {
loadOnlineWorldTerrain(mapId, x, y, z);
});
// Unstuck callback — re-run spawn search at current XY to find valid floor
// Unstuck callback — move 5 units forward (based on facing) and re-snap to floor
gameHandler->setUnstuckCallback([this]() {
if (!renderer || !renderer->getCameraController()) return;
auto* cc = renderer->getCameraController();
auto* ft = cc->getFollowTargetMutable();
if (!ft) return;
// Use reset() which does a full multi-radius WMO/terrain floor search
cc->setDefaultSpawn(*ft, cc->getYaw(), cc->getPitch());
// Move 5 units in the direction the player is facing
float yaw = cc->getYaw();
ft->x += 5.0f * std::sin(yaw);
ft->y += 5.0f * std::cos(yaw);
// Re-snap to floor at the new position
cc->setDefaultSpawn(*ft, yaw, cc->getPitch());
cc->reset();
});

View file

@ -4014,7 +4014,7 @@ void GameHandler::useItemById(uint32_t itemId) {
void GameHandler::unstuck() {
if (unstuckCallback_) {
unstuckCallback_();
addSystemChatMessage("Unstuck: position reset to floor.");
addSystemChatMessage("Unstuck: moved 5 units forward.");
}
}

View file

@ -715,7 +715,16 @@ bool M2Renderer::loadModel(const pipeline::M2Model& model, uint32_t modelId) {
(lowerName.find("fireflys") != std::string::npos) ||
(lowerName.find("mushroom") != std::string::npos) ||
(lowerName.find("fungus") != std::string::npos) ||
(lowerName.find("toadstool") != std::string::npos);
(lowerName.find("toadstool") != std::string::npos) ||
(lowerName.find("root") != std::string::npos) ||
(lowerName.find("branch") != std::string::npos) ||
(lowerName.find("thorn") != std::string::npos) ||
(lowerName.find("moss") != std::string::npos) ||
(lowerName.find("ivy") != std::string::npos) ||
(lowerName.find("seaweed") != std::string::npos) ||
(lowerName.find("kelp") != std::string::npos) ||
(lowerName.find("cattail") != std::string::npos) ||
(lowerName.find("reed") != std::string::npos);
bool treeLike = (lowerName.find("tree") != std::string::npos);
foliageOrTreeLike = (foliageName || treeLike);
bool hardTreePart =