2023-10-09 20:19:38 +00:00
|
|
|
#ifndef __PHYSICSCOMPONENT__H__
|
|
|
|
#define __PHYSICSCOMPONENT__H__
|
|
|
|
|
|
|
|
#include "Component.h"
|
|
|
|
#include "NiPoint3.h"
|
|
|
|
#include "NiQuaternion.h"
|
|
|
|
|
|
|
|
namespace Raknet {
|
|
|
|
class BitStream;
|
|
|
|
};
|
|
|
|
|
2024-05-10 14:22:26 +00:00
|
|
|
enum class eReplicaComponentType : uint32_t;
|
|
|
|
|
|
|
|
class dpEntity;
|
|
|
|
|
2023-10-09 20:19:38 +00:00
|
|
|
class PhysicsComponent : public Component {
|
|
|
|
public:
|
2024-12-16 05:44:57 +00:00
|
|
|
PhysicsComponent(Entity* parent, int32_t componentId);
|
2023-10-09 20:19:38 +00:00
|
|
|
virtual ~PhysicsComponent() = default;
|
|
|
|
|
2024-02-27 07:25:44 +00:00
|
|
|
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
2023-10-09 20:19:38 +00:00
|
|
|
|
|
|
|
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; }
|
2024-12-16 05:44:57 +00:00
|
|
|
|
|
|
|
int32_t GetCollisionGroup() const noexcept { return m_CollisionGroup; }
|
|
|
|
void SetCollisionGroup(int32_t group) noexcept { m_CollisionGroup = group; }
|
2023-10-09 20:19:38 +00:00
|
|
|
protected:
|
2024-05-10 14:22:26 +00:00
|
|
|
dpEntity* CreatePhysicsEntity(eReplicaComponentType type);
|
|
|
|
|
|
|
|
dpEntity* CreatePhysicsLnv(const float scale, const eReplicaComponentType type) const;
|
|
|
|
|
|
|
|
void SpawnVertices(dpEntity* entity) const;
|
|
|
|
|
2023-10-09 20:19:38 +00:00
|
|
|
NiPoint3 m_Position;
|
|
|
|
|
|
|
|
NiQuaternion m_Rotation;
|
|
|
|
|
|
|
|
bool m_DirtyPosition;
|
2024-12-16 05:44:57 +00:00
|
|
|
|
|
|
|
int32_t m_CollisionGroup{};
|
2023-10-09 20:19:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //!__PHYSICSCOMPONENT__H__
|