mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-06 10:44:08 +00:00
chore: Physics Component abstraction and addition of tests (#1159)
* Make serialize actually virtual yep * Abstract to PhysicsComponent Move shared functionality of all physics related classes to a base class. Tested that there were no failed to unserialize errors when in main gameplay in Gnarled Forest or in a race. Tested that 2 players were able to see each other in the above scenarios just fine as well. * Update PhantomPhysicsComponent.cpp * Add SimplePhysicsTest * Add construction test * Update SimplePhysicsComponentTests.cpp * remove flags and fix override * Update VendorComponent.h
This commit is contained in:
@@ -27,14 +27,13 @@
|
||||
#include "dpShapeBox.h"
|
||||
#include "dpShapeSphere.h"
|
||||
|
||||
PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(parent) {
|
||||
PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : PhysicsComponent(parent) {
|
||||
m_Position = m_Parent->GetDefaultPosition();
|
||||
m_Rotation = m_Parent->GetDefaultRotation();
|
||||
m_Scale = m_Parent->GetDefaultScale();
|
||||
m_dpEntity = nullptr;
|
||||
|
||||
m_EffectInfoDirty = false;
|
||||
m_PositionInfoDirty = false;
|
||||
|
||||
m_IsPhysicsEffectActive = false;
|
||||
m_EffectType = ePhysicsEffectType::PUSH;
|
||||
@@ -307,18 +306,7 @@ void PhantomPhysicsComponent::CreatePhysics() {
|
||||
}
|
||||
|
||||
void PhantomPhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
|
||||
outBitStream->Write(m_PositionInfoDirty || bIsInitialUpdate);
|
||||
if (m_PositionInfoDirty || bIsInitialUpdate) {
|
||||
outBitStream->Write(m_Position.x);
|
||||
outBitStream->Write(m_Position.y);
|
||||
outBitStream->Write(m_Position.z);
|
||||
outBitStream->Write(m_Rotation.x);
|
||||
outBitStream->Write(m_Rotation.y);
|
||||
outBitStream->Write(m_Rotation.z);
|
||||
outBitStream->Write(m_Rotation.w);
|
||||
|
||||
m_PositionInfoDirty = false;
|
||||
}
|
||||
PhysicsComponent::Serialize(outBitStream, bIsInitialUpdate);
|
||||
|
||||
outBitStream->Write(m_EffectInfoDirty || bIsInitialUpdate);
|
||||
if (m_EffectInfoDirty || bIsInitialUpdate) {
|
||||
@@ -426,13 +414,11 @@ void PhantomPhysicsComponent::SetMax(uint32_t max) {
|
||||
}
|
||||
|
||||
void PhantomPhysicsComponent::SetPosition(const NiPoint3& pos) {
|
||||
m_Position = pos;
|
||||
|
||||
PhysicsComponent::SetPosition(pos);
|
||||
if (m_dpEntity) m_dpEntity->SetPosition(pos);
|
||||
}
|
||||
|
||||
void PhantomPhysicsComponent::SetRotation(const NiQuaternion& rot) {
|
||||
m_Rotation = rot;
|
||||
|
||||
PhysicsComponent::SetRotation(rot);
|
||||
if (m_dpEntity) m_dpEntity->SetRotation(rot);
|
||||
}
|
||||
|
Reference in New Issue
Block a user