Try to use CompressNetworkBody for karts
This commit is contained in:
parent
891abf6360
commit
475cfa4cdb
@ -67,6 +67,7 @@
|
|||||||
#include "modes/overworld.hpp"
|
#include "modes/overworld.hpp"
|
||||||
#include "modes/profile_world.hpp"
|
#include "modes/profile_world.hpp"
|
||||||
#include "modes/soccer_world.hpp"
|
#include "modes/soccer_world.hpp"
|
||||||
|
#include "network/compress_network_body.hpp"
|
||||||
#include "network/network_config.hpp"
|
#include "network/network_config.hpp"
|
||||||
#include "network/protocols/client_lobby.hpp"
|
#include "network/protocols/client_lobby.hpp"
|
||||||
#include "network/race_event_manager.hpp"
|
#include "network/race_event_manager.hpp"
|
||||||
@ -1414,6 +1415,8 @@ void Kart::update(int ticks)
|
|||||||
{
|
{
|
||||||
m_kart_animation->update(ticks);
|
m_kart_animation->update(ticks);
|
||||||
}
|
}
|
||||||
|
else if (NetworkConfig::get()->roundValuesNow())
|
||||||
|
CompressNetworkBody::compress(m_body.get(), m_motion_state.get());
|
||||||
|
|
||||||
float dt = stk_config->ticks2Time(ticks);
|
float dt = stk_config->ticks2Time(ticks);
|
||||||
if (!RewindManager::get()->isRewinding())
|
if (!RewindManager::get()->isRewinding())
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "karts/max_speed.hpp"
|
#include "karts/max_speed.hpp"
|
||||||
#include "karts/skidding.hpp"
|
#include "karts/skidding.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
|
#include "network/compress_network_body.hpp"
|
||||||
#include "network/protocols/client_lobby.hpp"
|
#include "network/protocols/client_lobby.hpp"
|
||||||
#include "network/rewind_manager.hpp"
|
#include "network/rewind_manager.hpp"
|
||||||
#include "network/network_string.hpp"
|
#include "network/network_string.hpp"
|
||||||
@ -201,13 +202,9 @@ BareNetworkString* KartRewinder::saveState(std::vector<std::string>* ru)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
btRigidBody *body = getBody();
|
CompressNetworkBody::compress(
|
||||||
const btTransform &t = body->getWorldTransform();
|
m_body.get(), m_motion_state.get(), buffer);
|
||||||
buffer->add(t.getOrigin());
|
|
||||||
btQuaternion q = t.getRotation();
|
|
||||||
buffer->add(q);
|
|
||||||
buffer->add(body->getLinearVelocity());
|
|
||||||
buffer->add(body->getAngularVelocity());
|
|
||||||
if (m_vehicle->getTimedRotationTicks() > 0)
|
if (m_vehicle->getTimedRotationTicks() > 0)
|
||||||
{
|
{
|
||||||
buffer->addUInt16(m_vehicle->getTimedRotationTicks());
|
buffer->addUInt16(m_vehicle->getTimedRotationTicks());
|
||||||
@ -324,23 +321,13 @@ void KartRewinder::restoreState(BareNetworkString *buffer, int count)
|
|||||||
m_kart_animation = NULL;
|
m_kart_animation = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
btTransform kart_trans;
|
|
||||||
kart_trans.setOrigin(buffer->getVec3());
|
|
||||||
kart_trans.setRotation(buffer->getQuat());
|
|
||||||
Vec3 lv = buffer->getVec3();
|
|
||||||
Vec3 av = buffer->getVec3();
|
|
||||||
|
|
||||||
// Clear any forces applied (like by plunger or bubble gum torque)
|
// Clear any forces applied (like by plunger or bubble gum torque)
|
||||||
btRigidBody *body = getBody();
|
m_body->clearForces();
|
||||||
body->clearForces();
|
CompressNetworkBody::decompress(
|
||||||
body->setLinearVelocity(lv);
|
buffer, m_body.get(), m_motion_state.get());
|
||||||
body->setAngularVelocity(av);
|
|
||||||
// This function also reads the velocity, so it must be called
|
|
||||||
// after the velocities are set
|
|
||||||
body->proceedToTransform(kart_trans);
|
|
||||||
// Update kart transform in case that there are access to its value
|
// Update kart transform in case that there are access to its value
|
||||||
// before Moveable::update() is called (which updates the transform)
|
// before Moveable::update() is called (which updates the transform)
|
||||||
setTrans(kart_trans);
|
m_transform = m_body->getWorldTransform();
|
||||||
|
|
||||||
if (read_timed_rotation)
|
if (read_timed_rotation)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user