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:
David Markowitz
2023-10-09 13:19:38 -07:00
committed by GitHub
parent d8ac148cee
commit ad003634f4
15 changed files with 242 additions and 279 deletions

View File

@@ -2,7 +2,7 @@
#include "BitStream.h"
#include "Entity.h"
#include "Component.h"
#include "PhysicsComponent.h"
#include "eReplicaComponentType.h"
struct RemoteInputInfo {
@@ -26,41 +26,16 @@ struct RemoteInputInfo {
/**
* Physics component for vehicles.
*/
class VehiclePhysicsComponent : public Component {
class VehiclePhysicsComponent : public PhysicsComponent {
public:
static const eReplicaComponentType ComponentType = eReplicaComponentType::VEHICLE_PHYSICS;
VehiclePhysicsComponent(Entity* parentEntity);
~VehiclePhysicsComponent() override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
void Update(float deltaTime) override;
/**
* Sets the position
* @param pos the new position
*/
void SetPosition(const NiPoint3& pos);
/**
* Gets the position
* @return the position
*/
const NiPoint3& GetPosition() const { return m_Position; }
/**
* Sets the rotation
* @param rot the new rotation
*/
void SetRotation(const NiQuaternion& rot);
/**
* Gets the rotation
* @return the rotation
*/
const NiQuaternion& GetRotation() const { return m_Rotation; }
/**
* Sets the velocity
* @param vel the new velocity
@@ -115,10 +90,6 @@ public:
void SetRemoteInputInfo(const RemoteInputInfo&);
private:
bool m_DirtyPosition;
NiPoint3 m_Position;
NiQuaternion m_Rotation;
bool m_DirtyVelocity;
NiPoint3 m_Velocity;