mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-15 04:38:21 +00:00
fixes
This commit is contained in:
parent
67cd990d98
commit
daf5a7ffa9
@ -118,6 +118,9 @@ void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
|||||||
if (!bIsInitialUpdate) m_DirtyBubble = false;
|
if (!bIsInitialUpdate) m_DirtyBubble = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isVelocityZero = m_Velocity != NiPoint3::ZERO;
|
||||||
|
bool isAngularVelocityZero = m_AngularVelocity != NiPoint3::ZERO;
|
||||||
|
bool shouldWriteFrameStats = m_DirtyPosition || bIsInitialUpdate || isVelocityZero || isAngularVelocityZero;
|
||||||
outBitStream->Write(m_DirtyPosition || bIsInitialUpdate);
|
outBitStream->Write(m_DirtyPosition || bIsInitialUpdate);
|
||||||
if (m_DirtyPosition || bIsInitialUpdate) {
|
if (m_DirtyPosition || bIsInitialUpdate) {
|
||||||
outBitStream->Write(m_Position.x);
|
outBitStream->Write(m_Position.x);
|
||||||
@ -132,7 +135,6 @@ void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
|||||||
outBitStream->Write(m_IsOnGround);
|
outBitStream->Write(m_IsOnGround);
|
||||||
outBitStream->Write(m_IsOnRail);
|
outBitStream->Write(m_IsOnRail);
|
||||||
|
|
||||||
bool isVelocityZero = m_Velocity != NiPoint3::ZERO;
|
|
||||||
outBitStream->Write(isVelocityZero);
|
outBitStream->Write(isVelocityZero);
|
||||||
if (isVelocityZero) {
|
if (isVelocityZero) {
|
||||||
outBitStream->Write(m_Velocity.x);
|
outBitStream->Write(m_Velocity.x);
|
||||||
@ -140,7 +142,6 @@ void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
|||||||
outBitStream->Write(m_Velocity.z);
|
outBitStream->Write(m_Velocity.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAngularVelocityZero = m_AngularVelocity != NiPoint3::ZERO;
|
|
||||||
outBitStream->Write(isAngularVelocityZero);
|
outBitStream->Write(isAngularVelocityZero);
|
||||||
if (isAngularVelocityZero) {
|
if (isAngularVelocityZero) {
|
||||||
outBitStream->Write(m_AngularVelocity.x);
|
outBitStream->Write(m_AngularVelocity.x);
|
||||||
@ -202,9 +203,7 @@ void ControllablePhysicsComponent::SetPosition(const NiPoint3& pos) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Position.x = pos.x;
|
m_Position = pos;
|
||||||
m_Position.y = pos.y;
|
|
||||||
m_Position.z = pos.z;
|
|
||||||
m_DirtyPosition = true;
|
m_DirtyPosition = true;
|
||||||
|
|
||||||
if (m_dpEntity) m_dpEntity->SetPosition(pos);
|
if (m_dpEntity) m_dpEntity->SetPosition(pos);
|
||||||
|
@ -143,11 +143,11 @@ void MovementAIComponent::Update(const float deltaTime) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (m_CurrentSpeed < m_MaxSpeed) {
|
|
||||||
// m_CurrentSpeed += m_Acceleration;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (m_CurrentSpeed < m_MaxSpeed) {
|
if (m_CurrentSpeed < m_MaxSpeed) {
|
||||||
|
m_CurrentSpeed += m_Acceleration;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_CurrentSpeed > m_MaxSpeed) {
|
||||||
m_CurrentSpeed = m_MaxSpeed;
|
m_CurrentSpeed = m_MaxSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,10 +221,15 @@ NiPoint3 MovementAIComponent::GetCurrentWaypoint() const {
|
|||||||
NiPoint3 MovementAIComponent::ApproximateLocation() const {
|
NiPoint3 MovementAIComponent::ApproximateLocation() const {
|
||||||
auto source = m_Parent->GetPosition();
|
auto source = m_Parent->GetPosition();
|
||||||
if (AtFinalWaypoint()) return source;
|
if (AtFinalWaypoint()) return source;
|
||||||
|
NiPoint3 approximation = source;
|
||||||
|
|
||||||
|
// Only have physics sim for controllable physics
|
||||||
|
if (!m_Parent->HasComponent(ControllablePhysicsComponent::ComponentType)) {
|
||||||
|
auto destination = GetNextWaypoint();
|
||||||
|
auto percentageToWaypoint = m_TimeToTravel > 0 ? m_TimeTravelled / m_TimeToTravel : 0;
|
||||||
|
approximation = source + ((destination - source) * percentageToWaypoint);
|
||||||
|
}
|
||||||
|
|
||||||
auto destination = GetNextWaypoint();
|
|
||||||
auto percentageToWaypoint = m_TimeToTravel > 0 ? m_TimeTravelled / m_TimeToTravel : 0;
|
|
||||||
auto approximation = source + ((destination - source) * percentageToWaypoint);
|
|
||||||
if (dpWorld::Instance().IsLoaded()) {
|
if (dpWorld::Instance().IsLoaded()) {
|
||||||
approximation.y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(approximation);
|
approximation.y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(approximation);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user