improved physics, added better caching
This commit is contained in:
@@ -25,6 +25,7 @@ int client_build()
|
||||
const char *szGameName = ICommandLine::ParamValue("-game");
|
||||
if (szGameName == NULL)
|
||||
szGameName = "funnygame";
|
||||
IFileSystem2::MakeDirectory(CUtlString("build/%s/game/%s/bin",szGameName, szGameName));
|
||||
IFileSystem2::CopyFile(CUtlString("build/%s/game/%s/bin",szGameName,szGameName), outputProject);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -1,4 +1,22 @@
|
||||
#include "baseentity.h"
|
||||
#include "cglm/affine-pre.h"
|
||||
#include "cglm/mat4.h"
|
||||
#include "physics.h"
|
||||
|
||||
|
||||
class CBasePlayer: public CBaseEntity
|
||||
{
|
||||
public:
|
||||
virtual void Precache ( void ) override;
|
||||
virtual void Spawn( void ) override;
|
||||
virtual void ReadParameter( const char *szName, const char *szValue ) override;
|
||||
virtual void Destroy( void ) override;
|
||||
virtual void Think( float fDelta ) override;
|
||||
|
||||
CPxBoxMesh m_Collider;
|
||||
CPxRigidBody m_RigidBody;
|
||||
};
|
||||
|
||||
|
||||
class C_BasePlayer: public C_BaseEntity
|
||||
{
|
||||
@@ -10,6 +28,9 @@ public:
|
||||
};
|
||||
|
||||
|
||||
|
||||
extern mat4 g_cameraView;
|
||||
|
||||
void C_BasePlayer::Precache()
|
||||
{
|
||||
|
||||
@@ -17,7 +38,6 @@ void C_BasePlayer::Precache()
|
||||
|
||||
void C_BasePlayer::Spawn()
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
void C_BasePlayer::Destroy()
|
||||
@@ -26,6 +46,9 @@ void C_BasePlayer::Destroy()
|
||||
}
|
||||
void C_BasePlayer::Think( float fDelta )
|
||||
{
|
||||
CBasePlayer *pPlayer = (CBasePlayer*)pEntity;
|
||||
glm_mat4_identity(g_cameraView);
|
||||
V_memcpy(&g_cameraView[3][0], pPlayer->m_RigidBody.GetPosition().m, 12);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ int server_build()
|
||||
const char *szGameName = ICommandLine::ParamValue("-game");
|
||||
if (szGameName == NULL)
|
||||
szGameName = "funnygame";
|
||||
IFileSystem2::MakeDirectory(CUtlString("build/%s/game/%s/bin",szGameName, szGameName));
|
||||
IFileSystem2::CopyFile(CUtlString("build/%s/game/%s/bin",szGameName,szGameName), outputProject);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "baseentity.h"
|
||||
#include "physics.h"
|
||||
|
||||
class CBasePlayer: public CBaseEntity
|
||||
{
|
||||
@@ -8,9 +9,11 @@ public:
|
||||
virtual void ReadParameter( const char *szName, const char *szValue ) override;
|
||||
virtual void Destroy( void ) override;
|
||||
virtual void Think( float fDelta ) override;
|
||||
|
||||
CPxBoxMesh m_Collider;
|
||||
CPxRigidBody m_RigidBody;
|
||||
};
|
||||
|
||||
|
||||
void CBasePlayer::Precache()
|
||||
{
|
||||
|
||||
@@ -18,7 +21,24 @@ void CBasePlayer::Precache()
|
||||
|
||||
void CBasePlayer::Spawn()
|
||||
{
|
||||
|
||||
m_Collider.m_fRadius[0] = 1;
|
||||
m_Collider.m_fRadius[1] = 1;
|
||||
m_Collider.m_fRadius[2] = 1;
|
||||
m_Collider.Spawn(0.0);
|
||||
px_matrix matrix = {
|
||||
.m = {
|
||||
1,0,0,0,
|
||||
0,1,0,0,
|
||||
0,0,1,0,
|
||||
5,0,0,1,
|
||||
}
|
||||
};
|
||||
m_RigidBody.Spawn(&m_Collider, matrix, {
|
||||
.gravity_scale = 1,
|
||||
.lockrotx = 1,
|
||||
.lockroty = 1,
|
||||
.lockrotz = 1,
|
||||
});
|
||||
};
|
||||
void CBasePlayer::ReadParameter( const char *szName, const char *szValue )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user