Move Navmesh code away from dPhysics (#701)

This commit is contained in:
Jett
2022-08-02 06:30:19 +01:00
committed by GitHub
parent a0aa8b2854
commit 9ee219ea42
13 changed files with 349 additions and 323 deletions

View File

@@ -654,7 +654,7 @@ void BaseCombatAIComponent::Wander() {
auto destination = m_StartPosition + delta;
if (dpWorld::Instance().IsLoaded()) {
destination.y = dpWorld::Instance().GetHeightAtPoint(destination);
destination.y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(destination);
}
if (Vector3::DistanceSquared(destination, m_MovementAI->GetCurrentPosition()) < 2 * 2) {

View File

@@ -196,7 +196,7 @@ NiPoint3 MovementAIComponent::ApproximateLocation() const {
NiPoint3 approximation = NiPoint3(x, y, z);
if (dpWorld::Instance().IsLoaded()) {
approximation.y = dpWorld::Instance().GetHeightAtPoint(approximation);
approximation.y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(approximation);
}
return approximation;
@@ -208,7 +208,7 @@ bool MovementAIComponent::Warp(const NiPoint3& point) {
NiPoint3 destination = point;
if (dpWorld::Instance().IsLoaded()) {
destination.y = dpWorld::Instance().GetHeightAtPoint(point);
destination.y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(point);
if (std::abs(destination.y - point.y) > 3) {
return false;
@@ -387,7 +387,7 @@ void MovementAIComponent::SetDestination(const NiPoint3& value) {
std::vector<NiPoint3> computedPath;
if (dpWorld::Instance().IsLoaded()) {
computedPath = dpWorld::Instance().GetPath(GetCurrentPosition(), value, m_Info.wanderSpeed);
computedPath = dpWorld::Instance().GetNavMesh()->GetPath(GetCurrentPosition(), value, m_Info.wanderSpeed);
} else {
// Than take 10 points between the current position and the destination and make that the path
@@ -416,7 +416,7 @@ void MovementAIComponent::SetDestination(const NiPoint3& value) {
// Simply path
for (auto point : computedPath) {
if (dpWorld::Instance().IsLoaded()) {
point.y = dpWorld::Instance().GetHeightAtPoint(point);
point.y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(point);
}
m_CurrentPath.push_back(point);

View File

@@ -267,14 +267,14 @@ void PetComponent::OnUse(Entity* originator) {
if (dpWorld::Instance().IsLoaded()) {
NiPoint3 attempt = petPosition + forward * interactionDistance;
float y = dpWorld::Instance().GetHeightAtPoint(attempt);
float y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(attempt);
while (std::abs(y - petPosition.y) > 4 && interactionDistance > 10) {
const NiPoint3 forward = m_Parent->GetRotation().GetForwardVector();
attempt = originatorPosition + forward * interactionDistance;
y = dpWorld::Instance().GetHeightAtPoint(attempt);
y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(attempt);
interactionDistance -= 0.5f;
}
@@ -819,7 +819,7 @@ void PetComponent::Wander() {
auto destination = m_StartPosition + delta;
if (dpWorld::Instance().IsLoaded()) {
destination.y = dpWorld::Instance().GetHeightAtPoint(destination);
destination.y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(destination);
}
if (Vector3::DistanceSquared(destination, m_MovementAI->GetCurrentPosition()) < 2 * 2) {

View File

@@ -733,7 +733,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
auto control = static_cast<ControllablePhysicsComponent*>(entity->GetComponent(COMPONENT_TYPE_CONTROLLABLE_PHYSICS));
if (!control) return;
float y = dpWorld::Instance().GetHeightAtPoint(control->GetPosition());
float y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(control->GetPosition());
std::u16string msg = u"Navmesh height: " + (GeneralUtils::to_u16string(y));
ChatPackets::SendSystemMessage(sysAddr, msg);
}