Revert "Show remote player in the past"

Use a proper smoothing for all players later
This commit is contained in:
Benau 2018-06-16 14:08:02 +08:00
parent bd6492f5cf
commit e8c4f74a20
6 changed files with 6 additions and 61 deletions

View File

@ -1687,21 +1687,6 @@ void Kart::update(int ticks)
} // update
//-----------------------------------------------------------------------------
void Kart::handleRewoundTransform()
{
if (!m_controller->isLocalPlayerController())
{
if (RewindManager::get()->isRewinding())
m_rewound_transforms.push_back(getTrans());
else if (!m_rewound_transforms.empty())
{
setTrans(m_rewound_transforms.front());
m_rewound_transforms.pop_front();
}
}
} // handleRewoundTransform
//-----------------------------------------------------------------------------
/** Updates the local speed based on the current physical velocity. The value
* is smoothed exponentially to avoid camera stuttering (camera distance

View File

@ -32,7 +32,6 @@
#include "karts/abstract_kart.hpp"
#include "utils/no_copy.hpp"
#include <deque>
#include <SColor.h>
class AbstractKartAnimation;
@ -251,8 +250,6 @@ protected:
int m_ticks_last_crash;
RaceManager::KartType m_type;
std::deque<btTransform> m_rewound_transforms;
/** To prevent using nitro in too short bursts */
int m_min_nitro_ticks;
@ -550,9 +547,6 @@ public:
virtual void playSound(SFXBuffer* buffer) OVERRIDE;
// ------------------------------------------------------------------------
virtual bool isVisible() OVERRIDE;
// ------------------------------------------------------------------------
void handleRewoundTransform();
}; // Kart

View File

@ -60,39 +60,15 @@ void KartRewinder::reset()
void KartRewinder::saveTransform()
{
m_saved_transform = getTrans();
m_rewound_transforms.clear();
} // saveTransform
// ----------------------------------------------------------------------------
void KartRewinder::computeError()
{
// Local player kart doesn't need showing in the past
if (m_rewound_transforms.empty())
return;
std::deque<btTransform> copied = m_rewound_transforms;
// Find the closest position that matches previous rewound one
Vec3 saved_position = m_saved_transform.getOrigin();
while (!copied.empty())
{
Vec3 cur_position = copied.front().getOrigin();
if ((cur_position - saved_position).length() < 0.25f)
{
setTrans(copied.front());
copied.pop_front();
std::swap(m_rewound_transforms, copied);
return;
}
copied.pop_front();
}
// Use newly rewound one if no matching transformation
setTrans(m_rewound_transforms.front());
m_rewound_transforms.pop_front();
//btTransform error = getTrans() - m_saved_transform;
//Vec3 pos_error = getTrans().getOrigin() - m_saved_transform.getOrigin();
//btQuaternion rot_error(0, 0, 0, 1);
//Kart::addError(pos_error, rot_error);
Vec3 pos_error = getTrans().getOrigin() - m_saved_transform.getOrigin();
btQuaternion rot_error(0, 0, 0, 1);
Kart::addError(pos_error, rot_error);
} // computeError
// ----------------------------------------------------------------------------

View File

@ -106,7 +106,7 @@ void Moveable::updateGraphics(float dt, const Vec3& offset_xyz,
#endif
}
#ifndef SERVER_ONLY
Vec3 xyz=getXYZ()+offset_xyz;
Vec3 xyz=getXYZ()+offset_xyz - m_positional_error;
m_node->setPosition(xyz.toIrrVector());
btQuaternion r_all = getRotation()*rotation;
if(btFuzzyZero(r_all.getX()) && btFuzzyZero(r_all.getY()-0.70710677f) &&

View File

@ -1056,16 +1056,6 @@ void World::update(int ticks)
Physics::getInstance()->update(ticks);
if (NetworkConfig::get()->isNetworking() &&
NetworkConfig::get()->isClient())
{
for (int i = 0 ; i < kart_amount; i++)
{
if (!m_karts[i]->isEliminated())
static_cast<Kart*>(m_karts[i])->handleRewoundTransform();
}
}
PROFILER_PUSH_CPU_MARKER("World::update (projectiles)", 0xa0, 0x7F, 0x00);
projectile_manager->update(ticks);
PROFILER_POP_CPU_MARKER();

View File

@ -210,6 +210,7 @@ void RewindQueue::mergeNetworkData(int world_ticks, bool *needs_rewind,
// Only a client ever rewinds. So the rewind time should be the latest
// received state before current world time (if any)
*rewind_ticks = -9999;
bool adjust_next = false;
// FIXME: making m_network_events sorted would prevent the need to
// go through the whole list of events
@ -260,8 +261,7 @@ void RewindQueue::mergeNetworkData(int world_ticks, bool *needs_rewind,
// any server message should be in the client's past - but it can
// happen during debugging) we need to rewind to getTicks (in order
// to get the latest state).
if (NetworkConfig::get()->isClient() && (*i)->getTicks() <= world_ticks
&& (*i)->isState())
if (NetworkConfig::get()->isClient() && (*i)->getTicks() <= world_ticks)
{
// We need rewind if we receive an event in the past. This will
// then trigger a rewind later. Note that we only rewind to the