mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-09-05 14:58:27 +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:
@@ -1,71 +1,29 @@
|
||||
/*
|
||||
* Darkflame Universe
|
||||
* Copyright 2019
|
||||
* Copyright 2023
|
||||
*/
|
||||
|
||||
#ifndef RIGIDBODYPHANTOMPHYSICS_H
|
||||
#define RIGIDBODYPHANTOMPHYSICS_H
|
||||
#ifndef __RIGIDBODYPHANTOMPHYSICS_H__
|
||||
#define __RIGIDBODYPHANTOMPHYSICS_H__
|
||||
|
||||
#include "BitStream.h"
|
||||
#include "dCommonVars.h"
|
||||
#include "NiPoint3.h"
|
||||
#include "NiQuaternion.h"
|
||||
#include "Component.h"
|
||||
#include "PhysicsComponent.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
|
||||
/**
|
||||
* Component that handles rigid bodies that can be interacted with, mostly client-side rendered. An example is the
|
||||
* bananas that fall from trees in GF.
|
||||
*/
|
||||
class RigidbodyPhantomPhysicsComponent : public Component {
|
||||
class RigidbodyPhantomPhysicsComponent : public PhysicsComponent {
|
||||
public:
|
||||
static const eReplicaComponentType ComponentType = eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS;
|
||||
|
||||
RigidbodyPhantomPhysicsComponent(Entity* parent);
|
||||
~RigidbodyPhantomPhysicsComponent() override;
|
||||
|
||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
|
||||
|
||||
/**
|
||||
* Returns the position of this entity
|
||||
* @return the position of this entity
|
||||
*/
|
||||
NiPoint3& GetPosition() { return m_Position; }
|
||||
|
||||
/**
|
||||
* Sets the position of this entity
|
||||
* @param pos the position to set
|
||||
*/
|
||||
void SetPosition(const NiPoint3& pos) { m_Position = pos; m_IsDirty = true; }
|
||||
|
||||
/**
|
||||
* Returns the rotation of this entity
|
||||
* @return the rotation of this entity
|
||||
*/
|
||||
NiQuaternion& GetRotation() { return m_Rotation; }
|
||||
|
||||
/**
|
||||
* Sets the rotation for this entity
|
||||
* @param rot the rotation to tset
|
||||
*/
|
||||
void SetRotation(const NiQuaternion& rot) { m_Rotation = rot; m_IsDirty = true; }
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The position of this entity
|
||||
*/
|
||||
NiPoint3 m_Position;
|
||||
|
||||
/**
|
||||
* The rotation of this entity
|
||||
*/
|
||||
NiQuaternion m_Rotation;
|
||||
|
||||
/**
|
||||
* Whether or not the component should be serialized
|
||||
*/
|
||||
bool m_IsDirty;
|
||||
};
|
||||
|
||||
#endif // RIGIDBODYPHANTOMPHYSICS_H
|
||||
#endif // __RIGIDBODYPHANTOMPHYSICS_H__
|
||||
|
Reference in New Issue
Block a user