mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2026-01-11 19:20:14 +00:00
Add curve parameter to lerp
This commit is contained in:
@@ -239,10 +239,11 @@ void TableData::loadPaths(int* nextId) {
|
||||
std::cout << "[INFO] Loaded " << TransportManager::SkywayPaths.size() << " skyway paths" << std::endl;
|
||||
|
||||
// slider circuit
|
||||
int sliders = 0;
|
||||
nlohmann::json pathDataSlider = pathData["slider"];
|
||||
for (nlohmann::json::iterator _sliderPoint = pathDataSlider.begin(); _sliderPoint != pathDataSlider.end(); _sliderPoint++) {
|
||||
auto sliderPoint = _sliderPoint.value();
|
||||
if (sliderPoint["stop"]) { // check if this point in the circuit is a stop
|
||||
if (sliderPoint["stop"] && sliders % 2 == 0) { // check if this point in the circuit is a stop
|
||||
// spawn a slider
|
||||
std::cout << "bus ID was " << *nextId << std::endl;
|
||||
BaseNPC* slider = new BaseNPC(sliderPoint["iX"], sliderPoint["iY"], sliderPoint["iZ"], 1, (*nextId)++, NPC_BUS);
|
||||
@@ -250,6 +251,7 @@ void TableData::loadPaths(int* nextId) {
|
||||
NPCManager::updateNPCPosition(slider->appearanceData.iNPC_ID, slider->appearanceData.iX, slider->appearanceData.iY, slider->appearanceData.iZ);
|
||||
// set slider path to a rotation of the circuit
|
||||
constructPathSlider(pathDataSlider, 0, slider->appearanceData.iNPC_ID);
|
||||
sliders++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,7 +302,13 @@ void TableData::constructPathSlider(nlohmann::json points, int rotations, int sl
|
||||
for (int i = 0; i < stopTime + 1; i++) // repeat point if it's a stop
|
||||
route.push(from); // add point A to the queue
|
||||
WarpLocation to = { point["iX"] , point["iY"] , point["iZ"] }; // point B coords
|
||||
TransportManager::lerp(&route, from, to, SLIDER_SPEED); // lerp from A to B (arbitrary speed)
|
||||
float curve = 1;
|
||||
if (stopTime > 0) { // point A is a stop
|
||||
curve = 2.0f;
|
||||
} else if (point["stop"]) { // point B is a stop
|
||||
curve = 0.35f;
|
||||
}
|
||||
TransportManager::lerp(&route, from, to, SLIDER_SPEED, curve); // lerp from A to B (arbitrary speed)
|
||||
from = to; // update point A
|
||||
stopTime = point["stop"] ? SLIDER_STOP_TICKS : 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user