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

View File

@ -116,18 +116,6 @@ public:
*/ */
void SetDirtyPosition(bool val); 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 * Sets whether or not the entity is currently wearing a jetpack
* @param val 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; 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 * The current velocity of the entity
*/ */
NiPoint3 m_Velocity; NiPoint3 m_Velocity;
/**
* Whether or not the angular velocity is dirty, forcing a serialization
*/
bool m_DirtyAngularVelocity;
/** /**
* The current angular velocity of the entity * The current angular velocity of the entity
*/ */

View File

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

View File

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