mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-08 11:44:11 +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:
32
dGame/dComponents/PhysicsComponent.h
Normal file
32
dGame/dComponents/PhysicsComponent.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef __PHYSICSCOMPONENT__H__
|
||||
#define __PHYSICSCOMPONENT__H__
|
||||
|
||||
#include "Component.h"
|
||||
#include "NiPoint3.h"
|
||||
#include "NiQuaternion.h"
|
||||
|
||||
namespace Raknet {
|
||||
class BitStream;
|
||||
};
|
||||
|
||||
class PhysicsComponent : public Component {
|
||||
public:
|
||||
PhysicsComponent(Entity* parent);
|
||||
virtual ~PhysicsComponent() = default;
|
||||
|
||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
|
||||
|
||||
const NiPoint3& GetPosition() const { return m_Position; }
|
||||
virtual void SetPosition(const NiPoint3& pos) { if (m_Position == pos) return; m_Position = pos; m_DirtyPosition = true; }
|
||||
|
||||
const NiQuaternion& GetRotation() const { return m_Rotation; }
|
||||
virtual void SetRotation(const NiQuaternion& rot) { if (m_Rotation == rot) return; m_Rotation = rot; m_DirtyPosition = true; }
|
||||
protected:
|
||||
NiPoint3 m_Position;
|
||||
|
||||
NiQuaternion m_Rotation;
|
||||
|
||||
bool m_DirtyPosition;
|
||||
};
|
||||
|
||||
#endif //!__PHYSICSCOMPONENT__H__
|
Reference in New Issue
Block a user