#ifndef PHYSICS_H
#define PHYSICS_H

#include "tier0/lib.h"
#include "stdint.h"
#include "tier1/utlvector.h"
#include "math3d.h"


typedef void Collider;
typedef void RigidBodyHandle;

template <typename T>
struct Point {
    T x, y, z;
};

typedef struct u128 {
	uint64_t a;
	uint64_t b;
} u128;

#include "physics_gen.h"

extern funnyphysics *px;

struct PxCastResult_t
{
	bool bHit;
	float fTime;
	vec3 position;
	vec3 normal;
	vec3 normal2;
};

interface IPxWorld
{
public:
	static PxCastResult_t BoxCast( vec3 size, vec3 origin, vec3 destination, vec3 rotation = (vec3){0,0,0} );
};

class CPxCollider
{
public:
	virtual void Spawn( float fFriction = 0.0 ) = 0;
	virtual void Destroy( void );
	Collider *m_pCollider;
};

class CPxBallMesh: public CPxCollider
{
public:
	virtual void Spawn( float fFriction = 0.0 ) override;
	virtual void Destroy( void ) override;
	float m_fRadius;
};

class CPxBoxMesh: public CPxCollider
{
public:
	virtual void Spawn( float fFriction = 0.0 ) override;
	virtual void Destroy( void ) override;
	float m_fRadius[3];
};

class CPxTriangleMesh: public CPxCollider
{
public:
	virtual void Spawn( float fFriction = 0.0 ) override;
	virtual void Destroy( void ) override;
};

class CPxRigidKinematicPosition
{
public:
	void Spawn( CPxCollider *pCollider, px_matrix matrix, px_rigidbody_params params );
	void SetPosition( px_vec3 position );
	void SetPositionTeleport( px_vec3 position );
	px_vec3 GetPosition( void );
	px_matrix GetMatrix ( void );
	void Destroy( void );
	CPxCollider *m_pCollider;
	RigidBodyHandle *m_pRigidBody;
};

class CPxRigidBody
{
public:
	void Spawn( CPxCollider *pCollider, px_matrix matrix, px_rigidbody_params params );
	px_vec3 GetPosition( void );
	px_vec3 GetVelocity( void );
	void SetPosition( px_vec3 position );
	void SetVelocity( px_vec3 velocity );
	px_matrix GetMatrix ( void );
	void Destroy( void );
	CPxCollider *m_pCollider;
	RigidBodyHandle *m_pRigidBody;
};

class CPxStaticBody
{
public:
	void Spawn( CPxCollider *pCollider, px_matrix matrix, px_rigidbody_params params );
	px_vec3 GetPosition( void );
	px_matrix GetMatrix ( void );
	void Destroy( void );
	CPxCollider *m_pCollider;
};

class CPxFixedBody
{
public:
	void Spawn( CPxCollider *pCollider, px_matrix matrix, px_rigidbody_params params );
	px_vec3 GetPosition( void );
	px_matrix GetMatrix ( void );
	void Destroy( void );
	CPxCollider *m_pCollider;
};


#endif
