From 2f44243abb4759388b6a691ebcfc469eeaddc2c5 Mon Sep 17 00:00:00 2001 From: Gent S Date: Fri, 18 Dec 2020 19:18:39 -0500 Subject: [PATCH] Please.... please take the slider.... --- src/TableData.cpp | 20 +++++++++++++------- src/TransportManager.hpp | 1 + tdata | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/TableData.cpp b/src/TableData.cpp index f26aa4b..94f6b07 100644 --- a/src/TableData.cpp +++ b/src/TableData.cpp @@ -11,6 +11,7 @@ #include "contrib/JSON.hpp" #include +#include std::map> TableData::RunningSkywayRoutes; std::map TableData::RunningNPCRotations; @@ -358,18 +359,22 @@ void TableData::loadPaths(int* nextId) { } else if (point["stop"]) { // point B is a stop curve = 0.375f;//0.35f; } - int preLerp = route.size(); TransportManager::lerp(&route, from, to, SLIDER_SPEED * curve, 1); // lerp from A to B (arbitrary speed) - int postLerp = route.size() - preLerp; from = to; // update point A stopTime = point["stop"] ? SLIDER_STOP_TICKS : 0; // set stop ticks for next point A } - // - int l = route.size(); - int numSlidersApprox = 16; // maybe add a config option for this? - for (int pos = 0; pos < l; pos++) { + // Uniform distance calculation + int passedDistance = 0; + // initial point + int pos = 0; + WarpLocation lastPoint = route.front(); + route.pop(); + route.push(lastPoint); + for (pos = 1; pos < route.size(); pos++) { WarpLocation point = route.front(); - if (pos % (l / numSlidersApprox) == 0) { // space them out uniformaly + passedDistance += hypot(point.x - lastPoint.x, point.y - lastPoint.y); + if (passedDistance >= SLIDER_GAP_SIZE) { // space them out uniformaly + passedDistance -= SLIDER_GAP_SIZE; // step down // spawn a slider BaseNPC* slider = new BaseNPC(point.x, point.y, point.z, 0, INSTANCE_OVERWORLD, 1, (*nextId)++, NPC_BUS); NPCManager::NPCs[slider->appearanceData.iNPC_ID] = slider; @@ -379,6 +384,7 @@ void TableData::loadPaths(int* nextId) { // rotate route.pop(); route.push(point); + lastPoint = point; } // npc paths diff --git a/src/TransportManager.hpp b/src/TransportManager.hpp index 24df8f3..c274542 100644 --- a/src/TransportManager.hpp +++ b/src/TransportManager.hpp @@ -7,6 +7,7 @@ const int SLIDER_SPEED = 1200; const int SLIDER_STOP_TICKS = 16; +const int SLIDER_GAP_SIZE = 45000; struct WarpLocation; diff --git a/tdata b/tdata index a36aca3..a6a3841 160000 --- a/tdata +++ b/tdata @@ -1 +1 @@ -Subproject commit a36aca30c9ff69b39a1b128227a6e69c77e3c00e +Subproject commit a6a3841ff219ed57bbfda008782220ac4c111664