working physics

This commit is contained in:
2026-03-04 00:18:56 +02:00
parent 02898d62c0
commit 9884006888
12 changed files with 462 additions and 53 deletions

View File

@@ -2,11 +2,19 @@
#define BASE_MODEL_ENTITY_H
#include "baseentity.h"
#include "iphysics.h"
class CBaseModelEntity: public CBaseEntity
{
public:
DECLARE_CLASS(CBaseModelEntity, CBaseEntity);
DECLARE_CLASS(CBaseModelEntity, CBaseEntity);
virtual void Spawn() override;
virtual void Precache() override;
private:
HShape m_hShape;
HCollider m_hCollider;
IPhysicsBody *m_pBody;
};
#endif

View File

@@ -2,9 +2,10 @@
#include "c.h"
#include "ld.h"
#define EXTERNAL "../../external/"
#define ROOT "../../"
#define EXTERNAL ROOT"external/"
#define FUNNYSTDLIB EXTERNAL"funnystdlib/"
ADD_DEPENDENCY_BUILD_FILE(cfg, "../../buildcfg.cpp");
ADD_DEPENDENCY_BUILD_FILE(cfg, ROOT"buildcfg.cpp");
ADD_DEPENDENCY_BUILD_FILE(tier0, FUNNYSTDLIB"tier0/build.cpp");
ADD_DEPENDENCY_BUILD_FILE(tier1, FUNNYSTDLIB"tier1/build.cpp");
ADD_DEPENDENCY_BUILD_FILE(tier2, FUNNYSTDLIB"tier2/build.cpp");

View File

@@ -6,6 +6,7 @@
#include "inetworkserver.h"
#include "netprotocol.h"
#include "tier1/utlvector.h"
#include "iphysics.h"
#ifdef STEAM
#include "steam/isteamgameserver.h"
#include "steam/steam_gameserver.h"
@@ -22,6 +23,9 @@ INetworkBase *g_pClientBridge;
INetworkBase *g_pPublicConnection;
INetworkBase *g_pCurrentConnection;
IPhysics *g_pPhysics;
IPhysicsWorld *g_pPhysicsWorld;
class CFunnyGameBridge: public IEngineBridge
{
virtual void Init() override;
@@ -115,8 +119,13 @@ void CFunnyGameBridge::Init()
#endif
m_fNetUpdateTimer = 0;
CreateInterfaceFn fnPhysicsFactory = Sys_GetFactory("RapierPhysics");
g_pPhysics = (IPhysics*)fnPhysicsFactory(PHYSICS_INTERFACE_VERSION, NULL);
g_pPhysicsWorld = g_pPhysics->CreateWorld();
}
void CFunnyGameBridge::Tick( float fDelta )
{
@@ -183,9 +192,10 @@ void CFunnyGameBridge::Frame( float fDelta )
while (m_fNetUpdateTimer >= fTickRate)
{
m_fNetUpdateTimer-=fTickRate;
EntitySystem()->Think();
if (g_pCurrentConnection)
{
g_pPhysicsWorld->Frame(fTickRate);
EntitySystem()->Think();
EntitySystem()->NetThink(g_pCurrentConnection);
}
}

View File

16
game/server/physicsprop.h Normal file
View File

@@ -0,0 +1,16 @@
#ifndef PHYSICS_PROP_H
#define PHYSICS_PROP_H
#include "basemodelentity.h"
class CPhysicsProp: public CBaseModelEntity
{
friend CBaseModelEntity;
public:
DECLARE_CLASS(CPhysicsProp, CBaseModelEntity);
virtual void Spawn() override;
virtual void EnableMovement();
virtual void DisableMovement();
};
#endif