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

@@ -11,8 +11,8 @@
#include <vector>
#include "CppScripts.h"
#include "InvalidScript.h"
#include "Component.h"
#include "eReplicaComponentType.h"
#include "PhysicsComponent.h"
class LDFBaseData;
class Entity;
@@ -25,7 +25,7 @@ enum class ePhysicsEffectType : uint32_t ;
* trigger gameplay events, for example the bus in Avant Gardens that moves around when the player touches its physics
* body. Optionally this object can also have effects, like the fans in AG.
*/
class PhantomPhysicsComponent : public Component {
class PhantomPhysicsComponent : public PhysicsComponent {
public:
static const eReplicaComponentType ComponentType = eReplicaComponentType::PHANTOM_PHYSICS;
@@ -75,29 +75,17 @@ public:
*/
void SetPhysicsEffectActive(bool val) { m_IsPhysicsEffectActive = val; m_EffectInfoDirty = true; }
/**
* Returns the position of this physics object
* @return the position of this physics object
*/
const NiPoint3& GetPosition() const { return m_Position; }
/**
* Sets the position of this physics object
* @param pos the position to set
*/
void SetPosition(const NiPoint3& pos);
/**
* Returns the rotation of this physics object
* @return the rotation of this physics object
*/
const NiQuaternion& GetRotation() const { return m_Rotation; }
void SetPosition(const NiPoint3& pos) override;
/**
* Sets the rotation of this physics object
* @param rot the rotation to set
*/
void SetRotation(const NiQuaternion& rot);
void SetRotation(const NiQuaternion& rot) override;
/**
* Returns the effect that's currently active, defaults to 0
@@ -134,27 +122,11 @@ public:
void SetMax(uint32_t max);
private:
/**
* The position of the physics object
*/
NiPoint3 m_Position;
/**
* The rotation of the physics object
*/
NiQuaternion m_Rotation;
/**
* A scale to apply to the size of the physics object
*/
float m_Scale;
/**
* Whether or not the position has changed and needs to be serialized
*/
bool m_PositionInfoDirty;
/**
* Whether or not the effect has changed and needs to be serialized
*/