Remove flags in controllablePhysics

This commit is contained in:
David Markowitz 2023-08-19 22:44:02 -07:00
parent 2bb39f4fa5
commit 11b1f5b9d4
4 changed files with 7 additions and 47 deletions

View File

@ -24,8 +24,6 @@ ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity) : Com
m_IsOnGround = true;
m_IsOnRail = false;
m_DirtyPosition = true;
m_DirtyVelocity = true;
m_DirtyAngularVelocity = true;
m_dpEntity = nullptr;
m_Static = false;
m_SpeedMultiplier = 1;
@ -134,20 +132,20 @@ void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
outBitStream->Write(m_IsOnGround);
outBitStream->Write(m_IsOnRail);
outBitStream->Write(m_DirtyVelocity);
if (m_DirtyVelocity) {
bool isVelocityZero = m_Velocity != NiPoint3::ZERO;
outBitStream->Write(isVelocityZero);
if (isVelocityZero) {
outBitStream->Write(m_Velocity.x);
outBitStream->Write(m_Velocity.y);
outBitStream->Write(m_Velocity.z);
m_DirtyVelocity = false;
}
outBitStream->Write(m_DirtyAngularVelocity);
if (m_DirtyAngularVelocity) {
bool isAngularVelocityZero = m_AngularVelocity != NiPoint3::ZERO;
outBitStream->Write(isAngularVelocityZero);
if (isAngularVelocityZero) {
outBitStream->Write(m_AngularVelocity.x);
outBitStream->Write(m_AngularVelocity.y);
outBitStream->Write(m_AngularVelocity.z);
m_DirtyAngularVelocity = false;
}
outBitStream->Write0(); // LocalSpaceInfo
@ -230,7 +228,6 @@ void ControllablePhysicsComponent::SetVelocity(const NiPoint3& vel) {
m_Velocity = vel;
m_DirtyPosition = true;
m_DirtyVelocity = true;
if (m_dpEntity) m_dpEntity->SetVelocity(vel);
}
@ -242,7 +239,6 @@ void ControllablePhysicsComponent::SetAngularVelocity(const NiPoint3& vel) {
m_AngularVelocity = vel;
m_DirtyPosition = true;
m_DirtyAngularVelocity = true;
}
void ControllablePhysicsComponent::SetIsOnGround(bool val) {
@ -261,14 +257,6 @@ void ControllablePhysicsComponent::SetDirtyPosition(bool val) {
m_DirtyPosition = val;
}
void ControllablePhysicsComponent::SetDirtyVelocity(bool val) {
m_DirtyVelocity = val;
}
void ControllablePhysicsComponent::SetDirtyAngularVelocity(bool val) {
m_DirtyAngularVelocity = val;
}
void ControllablePhysicsComponent::AddPickupRadiusScale(float value) {
m_ActivePickupRadiusScales.push_back(value);
if (value > m_PickupRadius) {

View File

@ -116,18 +116,6 @@ public:
*/
void SetDirtyPosition(bool val);
/**
* Mark the velocity as dirty, forcing a serializtion update next tick
* @param val whether or not the velocity is dirty
*/
void SetDirtyVelocity(bool val);
/**
* Mark the angular velocity as dirty, forcing a serialization update next tick
* @param val whether or not the angular velocity is dirty
*/
void SetDirtyAngularVelocity(bool val);
/**
* Sets whether or not the entity is currently wearing a jetpack
* @param val whether or not the entity is currently wearing a jetpack
@ -337,21 +325,11 @@ private:
*/
NiQuaternion m_Rotation;
/**
* Whether or not the velocity is dirty, forcing a serialization of the velocity
*/
bool m_DirtyVelocity;
/**
* The current velocity of the entity
*/
NiPoint3 m_Velocity;
/**
* Whether or not the angular velocity is dirty, forcing a serialization
*/
bool m_DirtyAngularVelocity;
/**
* The current angular velocity of the entity
*/

View File

@ -347,7 +347,7 @@ int main(int argc, char** argv) {
StartChatServer();
Game::im->GetInstance(0, false, 0);
Game::im->GetInstance(1800, false, 0);
Game::im->GetInstance(1200, false, 0);
StartAuthServer();
}

View File

@ -182,9 +182,7 @@ void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Pac
vehiclePhysicsComponent->SetIsOnGround(onGround);
vehiclePhysicsComponent->SetIsOnRail(onRail);
vehiclePhysicsComponent->SetVelocity(velocity);
vehiclePhysicsComponent->SetDirtyVelocity(velocityFlag);
vehiclePhysicsComponent->SetAngularVelocity(angVelocity);
vehiclePhysicsComponent->SetDirtyAngularVelocity(angVelocityFlag);
vehiclePhysicsComponent->SetRemoteInputInfo(remoteInput);
} else {
// Need to get the mount's controllable physics
@ -195,9 +193,7 @@ void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Pac
controllablePhysicsComponent->SetIsOnGround(onGround);
controllablePhysicsComponent->SetIsOnRail(onRail);
controllablePhysicsComponent->SetVelocity(velocity);
controllablePhysicsComponent->SetDirtyVelocity(velocityFlag);
controllablePhysicsComponent->SetAngularVelocity(angVelocity);
controllablePhysicsComponent->SetDirtyAngularVelocity(angVelocityFlag);
}
Game::entityManager->SerializeEntity(possassableEntity);
}
@ -221,9 +217,7 @@ void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Pac
comp->SetIsOnGround(onGround);
comp->SetIsOnRail(onRail);
comp->SetVelocity(velocity);
comp->SetDirtyVelocity(velocityFlag);
comp->SetAngularVelocity(angVelocity);
comp->SetDirtyAngularVelocity(angVelocityFlag);
auto* player = static_cast<Player*>(entity);
player->SetGhostReferencePoint(position);