added command line, added basic character
This commit is contained in:
@@ -10,26 +10,31 @@ CUtlVector<CUtlString> engine_CompiledFiles = {
|
|||||||
"engine/server.cpp",
|
"engine/server.cpp",
|
||||||
"engine/engine.cpp",
|
"engine/engine.cpp",
|
||||||
"engine/physics.cpp",
|
"engine/physics.cpp",
|
||||||
|
"engine/gamemode.cpp",
|
||||||
|
|
||||||
/* rendering */
|
|
||||||
"engine/vk_video.cpp",
|
|
||||||
"engine/vk_mesh.cpp",
|
|
||||||
"engine/vk_postprocessing.cpp",
|
|
||||||
|
|
||||||
/* entities */
|
/* entities */
|
||||||
"engine/baseentity.cpp",
|
"engine/baseentity.cpp",
|
||||||
"engine/level.cpp",
|
"engine/level.cpp",
|
||||||
"engine/brush.cpp",
|
"engine/brush.cpp",
|
||||||
|
/* server entities */
|
||||||
/* server */
|
|
||||||
"engine/sv_worldspawn.cpp",
|
"engine/sv_worldspawn.cpp",
|
||||||
"engine/sv_light.cpp",
|
"engine/sv_light.cpp",
|
||||||
|
"engine/sv_playerstart.cpp",
|
||||||
|
|
||||||
/* client */
|
/* client entities */
|
||||||
"engine/cl_worldspawn.cpp",
|
"engine/cl_worldspawn.cpp",
|
||||||
"engine/cl_light.cpp",
|
"engine/cl_light.cpp",
|
||||||
|
|
||||||
|
/* rendering */
|
||||||
"engine/vk_videosdl.cpp",
|
"engine/vk_videosdl.cpp",
|
||||||
|
"engine/vk_video.cpp",
|
||||||
|
"engine/vk_mesh.cpp",
|
||||||
|
"engine/vk_postprocessing.cpp",
|
||||||
|
|
||||||
|
/* io */
|
||||||
|
"engine/input.cpp",
|
||||||
|
"engine/net.cpp"
|
||||||
};
|
};
|
||||||
|
|
||||||
CUtlVector<CUtlString> engine_Libraries = {
|
CUtlVector<CUtlString> engine_Libraries = {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "baseentity.h"
|
#include "baseentity.h"
|
||||||
#include "cglm/mat4.h"
|
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#include "brush.h"
|
#include "brush.h"
|
||||||
#include "baseentity.h"
|
#include "baseentity.h"
|
||||||
#include "cglm/mat4.h"
|
|
||||||
#include "physics.h"
|
#include "physics.h"
|
||||||
#include "rendering.h"
|
#include "rendering.h"
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
#include "tier1/utlbuffer.h"
|
#include "tier1/utlbuffer.h"
|
||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
|
#include "math3d.h"
|
||||||
|
|
||||||
void CBrushEntity::Precache()
|
void CBrushEntity::Precache()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
#include "console.h"
|
#include "console.h"
|
||||||
|
#include "tier1/utlstring.h"
|
||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
|
|
||||||
|
CUtlVector<ConVar*> g_convars;
|
||||||
|
CUtlVector<ConCommand*> g_commands;
|
||||||
|
|
||||||
void IConsole::RegisterVar( ConVar *cvar )
|
void IConsole::RegisterVar( ConVar *cvar )
|
||||||
{
|
{
|
||||||
|
g_convars.AppendTail(cvar);
|
||||||
}
|
}
|
||||||
void IConsole::UnRegisterVar( ConVar *cvar )
|
void IConsole::UnRegisterVar( ConVar *cvar )
|
||||||
{
|
{
|
||||||
@@ -11,35 +15,112 @@ void IConsole::UnRegisterVar( ConVar *cvar )
|
|||||||
}
|
}
|
||||||
ConVar *IConsole::FindVar( const char *pName )
|
ConVar *IConsole::FindVar( const char *pName )
|
||||||
{
|
{
|
||||||
|
for (auto &var: g_convars)
|
||||||
|
{
|
||||||
|
if (!V_strcmp(var->GetName(), pName))
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IConsole::RegisterCommand( ConVar *cvar )
|
void IConsole::RegisterCommand( ConCommand *cvar )
|
||||||
{
|
{
|
||||||
|
g_commands.AppendTail(cvar);
|
||||||
}
|
}
|
||||||
void IConsole::UnRegisterCommand( ConVar *cvar )
|
void IConsole::UnRegisterCommand( ConCommand *cvar )
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
ConCommand *IConsole::FindCommand( const char *pName )
|
ConCommand *IConsole::FindCommand( const char *pName )
|
||||||
{
|
{
|
||||||
|
for (auto &var: g_commands)
|
||||||
|
{
|
||||||
|
if (!V_strcmp(var->GetName(), pName))
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
CUtlString g_commandBuffer;
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Executes arguments from IConsole::Execute
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void IConsole::Execute2( CUtlVector<CUtlString> &args )
|
||||||
|
{
|
||||||
|
if (args.GetSize()<1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ConCommand *cmd = IConsole::FindCommand(args[0]);
|
||||||
|
if (!cmd)
|
||||||
|
{
|
||||||
|
V_printf("%s not found\n", args[0].GetString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CUtlBuffer<char*> strbuffer(args.GetSize());
|
||||||
|
for ( size_t i = 0; i < args.GetSize(); i++)
|
||||||
|
{
|
||||||
|
strbuffer[i] = args[i].GetString();
|
||||||
|
};
|
||||||
|
(cmd->GetCallback())(args.GetSize(), strbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Parses command buffer.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
void IConsole::Execute( void )
|
void IConsole::Execute( void )
|
||||||
{
|
{
|
||||||
|
CUtlVector<CUtlString> arguments;
|
||||||
|
CUtlString szArgument;
|
||||||
|
bool bIsQuote = false;
|
||||||
|
for (auto &c: (CUtlVector<char>&)g_commandBuffer)
|
||||||
|
{
|
||||||
|
if (c == '\"')
|
||||||
|
{
|
||||||
|
bIsQuote = !bIsQuote;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c == ';' || c == '\n' || c == '\0')
|
||||||
|
{
|
||||||
|
if (bIsQuote)
|
||||||
|
{
|
||||||
|
if (c != '\0')
|
||||||
|
szArgument.AppendTail(c);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (szArgument != 0)
|
||||||
|
arguments.AppendTail(szArgument);
|
||||||
|
IConsole::Execute2(arguments);
|
||||||
|
szArgument = 0;
|
||||||
|
arguments = {};
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ( c == '\t' || c == ' ' )
|
||||||
|
{
|
||||||
|
if (bIsQuote)
|
||||||
|
{
|
||||||
|
szArgument.AppendTail(c);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (szArgument != 0)
|
||||||
|
arguments.AppendTail(szArgument);
|
||||||
|
szArgument = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
szArgument.AppendTail(c);
|
||||||
|
};
|
||||||
|
g_commandBuffer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IConsole::AddCommand( const char *psz )
|
void IConsole::AddCommand( const char *psz )
|
||||||
{
|
{
|
||||||
|
g_commandBuffer.AppendTail(psz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IConsole::InsertCommand( const char *psz )
|
void IConsole::InsertCommand( const char *psz )
|
||||||
{
|
{
|
||||||
|
g_commandBuffer.AppendHead(psz);
|
||||||
};
|
};
|
||||||
|
|
||||||
ConVar::ConVar( const char *pName, const char *pDefaultValue, int flags )
|
ConVar::ConVar( const char *pName, const char *pDefaultValue, int flags )
|
||||||
@@ -55,7 +136,7 @@ ConVar::ConVar( const char *pName, const char *pDefaultValue, int flags,
|
|||||||
ConVar::ConVar( const char *pName, const char *pDefaultValue, int flags,
|
ConVar::ConVar( const char *pName, const char *pDefaultValue, int flags,
|
||||||
const char *pHelpString, ConCommandFn callback )
|
const char *pHelpString, ConCommandFn callback )
|
||||||
{
|
{
|
||||||
m_szName = CUtlString(pName);
|
m_szName = pName;
|
||||||
m_flags = flags;
|
m_flags = flags;
|
||||||
m_szValue = pDefaultValue;
|
m_szValue = pDefaultValue;
|
||||||
m_fValue = V_atof(pDefaultValue);
|
m_fValue = V_atof(pDefaultValue);
|
||||||
@@ -69,7 +150,7 @@ bool ConVar::IsFlagSet( int flag )
|
|||||||
}
|
}
|
||||||
const char *ConVar::GetHelpText( void )
|
const char *ConVar::GetHelpText( void )
|
||||||
{
|
{
|
||||||
|
return m_szHelpString;
|
||||||
}
|
}
|
||||||
bool ConVar::IsRegistered( void )
|
bool ConVar::IsRegistered( void )
|
||||||
{
|
{
|
||||||
@@ -77,7 +158,7 @@ bool ConVar::IsRegistered( void )
|
|||||||
}
|
}
|
||||||
const char *ConVar::GetName( void )
|
const char *ConVar::GetName( void )
|
||||||
{
|
{
|
||||||
|
return m_szName;
|
||||||
}
|
}
|
||||||
void ConVar::AddFlags( int flags )
|
void ConVar::AddFlags( int flags )
|
||||||
{
|
{
|
||||||
@@ -130,3 +211,24 @@ void ConVar::SetValue( int iValue )
|
|||||||
m_nValue = iValue;
|
m_nValue = iValue;
|
||||||
m_szValue = CUtlString("%i\n",iValue);
|
m_szValue = CUtlString("%i\n",iValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConCommand::ConCommand(const char *pName, ConCommandFn callback,
|
||||||
|
const char *pHelpString, int flags)
|
||||||
|
{
|
||||||
|
m_szName = pName;
|
||||||
|
m_callback = callback;
|
||||||
|
m_flags = flags;
|
||||||
|
IConsole::RegisterCommand(this);
|
||||||
|
};
|
||||||
|
const char *ConCommand::GetHelpText( void )
|
||||||
|
{
|
||||||
|
return m_szHelpString;
|
||||||
|
}
|
||||||
|
const char *ConCommand::GetName( void )
|
||||||
|
{
|
||||||
|
return m_szName;
|
||||||
|
}
|
||||||
|
ConCommandFn ConCommand::GetCallback( void )
|
||||||
|
{
|
||||||
|
return m_callback;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include "input.h"
|
||||||
#include "tier1/commandline.h"
|
#include "tier1/commandline.h"
|
||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
#include "tier0/lib.h"
|
#include "tier0/lib.h"
|
||||||
@@ -14,6 +15,11 @@ double fPrev = 0;
|
|||||||
double fCurrent = 0;
|
double fCurrent = 0;
|
||||||
|
|
||||||
funnyphysics *px;
|
funnyphysics *px;
|
||||||
|
|
||||||
|
IIClient g_localClient;
|
||||||
|
|
||||||
|
CUtlVector<IIClient*> g_clients;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: Engine entry point
|
// Purpose: Engine entry point
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -30,6 +36,9 @@ extern "C" void FunnyMain( int argc, char **argv ) {
|
|||||||
/* deinit is handled explicitly */
|
/* deinit is handled explicitly */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Recieves signals from the system
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
void IEngine_Signal(int sig)
|
void IEngine_Signal(int sig)
|
||||||
{
|
{
|
||||||
printf("Trapped signal %i\n",sig);
|
printf("Trapped signal %i\n",sig);
|
||||||
@@ -48,7 +57,9 @@ void IEngine_Signal(int sig)
|
|||||||
_exit(0);
|
_exit(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Initializes engine
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
void IEngine::Init()
|
void IEngine::Init()
|
||||||
{
|
{
|
||||||
/* trap signals */
|
/* trap signals */
|
||||||
@@ -66,36 +77,52 @@ void IEngine::Init()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
IFileSystem::InitFilesystem();
|
IFileSystem::InitFilesystem();
|
||||||
IVideo::Init();
|
|
||||||
px = px_init();
|
px = px_init();
|
||||||
|
|
||||||
|
if (!ICommandLine::CheckParam("-dedicated"))
|
||||||
|
{
|
||||||
|
g_localClient = {
|
||||||
|
|
||||||
|
};
|
||||||
|
IIEngine::ConnectClient(&g_localClient);
|
||||||
|
|
||||||
|
IVideo::Init();
|
||||||
|
IInput::Init();
|
||||||
|
}
|
||||||
IServer::LoadGame("funnygame");
|
IServer::LoadGame("funnygame");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Updates every frame
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
void IEngine::Frame(float fDelta)
|
void IEngine::Frame(float fDelta)
|
||||||
{
|
{
|
||||||
IServer::Think(fDelta);
|
IServer::Think(fDelta);
|
||||||
IVideo::Frame(fDelta);
|
IVideo::Frame(fDelta);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Deinitializes engine
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
void IEngine::Shutdown()
|
void IEngine::Shutdown()
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Spawns entity in the world
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
CBaseEntity *IIEngine::SpawnEntity( const char *szName )
|
CBaseEntity *IIEngine::SpawnEntity( const char *szName )
|
||||||
{
|
{
|
||||||
V_printf("%s\n", szName);
|
|
||||||
for (auto &entity: g_RegisteredEntities)
|
for (auto &entity: g_RegisteredEntities)
|
||||||
{
|
{
|
||||||
if (!V_strcmp(entity->m_szName, szName))
|
if (!V_strcmp(entity->m_szName, szName))
|
||||||
{
|
{
|
||||||
CBaseEntity *pEnt = entity->m_pfn();
|
CBaseEntity *pEnt = entity->m_pfn();
|
||||||
pEnt->Spawn();
|
|
||||||
g_entities.AppendTail(pEnt);
|
g_entities.AppendTail(pEnt);
|
||||||
if (entity->m_pClientfn)
|
if (entity->m_pClientfn)
|
||||||
{
|
{
|
||||||
pEnt->pClientEntity = entity->m_pClientfn();
|
pEnt->pClientEntity = entity->m_pClientfn();
|
||||||
pEnt->pClientEntity->Spawn();
|
|
||||||
pEnt->pClientEntity->pEntity = pEnt;
|
pEnt->pClientEntity->pEntity = pEnt;
|
||||||
}
|
}
|
||||||
return pEnt;
|
return pEnt;
|
||||||
@@ -104,7 +131,38 @@ CBaseEntity *IIEngine::SpawnEntity( const char *szName )
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Spawns entity without any parameters
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void IIEngine::InitEntity( CBaseEntity *pEntity )
|
||||||
|
{
|
||||||
|
if (!pEntity)
|
||||||
|
return;
|
||||||
|
pEntity->Spawn();
|
||||||
|
if (pEntity->pClientEntity)
|
||||||
|
pEntity->pClientEntity->Spawn();
|
||||||
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Destroys entity
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
void IIEngine::DestroyEntity( CBaseEntity *pEntity )
|
void IIEngine::DestroyEntity( CBaseEntity *pEntity )
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Connects client to the server
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void IIEngine::ConnectClient( IIClient *pClient)
|
||||||
|
{
|
||||||
|
g_clients.AppendTail(pClient);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Disconnects client from the server
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void IIEngine::DisconnectClient( IIClient *pClient)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
64
engine/gamemode.cpp
Normal file
64
engine/gamemode.cpp
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
#include "gamemode.h"
|
||||||
|
#include "playerstart.h"
|
||||||
|
#include "tier1/utlvector.h"
|
||||||
|
|
||||||
|
CGameMode *pCurrentMode = NULL;
|
||||||
|
|
||||||
|
void CGameMode::RoundBegin( void )
|
||||||
|
{
|
||||||
|
size_t i = 0;
|
||||||
|
for (auto &start: g_PlayerStarts)
|
||||||
|
{
|
||||||
|
start->RoundEnd();
|
||||||
|
}
|
||||||
|
for (auto &player: g_clients)
|
||||||
|
{
|
||||||
|
CPlayerStart *pSelectedStart = NULL;
|
||||||
|
for (auto &start: g_PlayerStarts)
|
||||||
|
{
|
||||||
|
if (start->m_bIsRunning == false)
|
||||||
|
pSelectedStart = start;
|
||||||
|
};
|
||||||
|
pSelectedStart->RoundStart(player);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGameMode::RoundEnd( void )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void IGameModeManager::Init( void )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void IGameModeManager::Frame( void )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void IGameModeManager::StartGameMode(CGameMode *pGameMode)
|
||||||
|
{
|
||||||
|
if (pCurrentMode)
|
||||||
|
pCurrentMode->RoundEnd();
|
||||||
|
pCurrentMode = pGameMode;
|
||||||
|
if (pCurrentMode)
|
||||||
|
pCurrentMode->RoundBegin();
|
||||||
|
}
|
||||||
|
|
||||||
|
CGameMode *IGameModeManager::GetCurrentMode( void )
|
||||||
|
{
|
||||||
|
return pCurrentMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IGameModeManager::RestartCurrentMode( void )
|
||||||
|
{
|
||||||
|
if (!pCurrentMode)
|
||||||
|
return;
|
||||||
|
pCurrentMode->RoundEnd();
|
||||||
|
pCurrentMode->RoundBegin();
|
||||||
|
}
|
||||||
|
|
||||||
52
engine/input.cpp
Normal file
52
engine/input.cpp
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
#include "input.h"
|
||||||
|
#include "console.h"
|
||||||
|
#include "tier0/lib.h"
|
||||||
|
|
||||||
|
char g_PressedKeys[256];
|
||||||
|
float g_fXAxisEvent[256];
|
||||||
|
float g_fYAxisEvent[256];
|
||||||
|
CUtlString g_bindings[256];
|
||||||
|
|
||||||
|
void IInput::Init( void )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void IInput::KeyEvent( EInputKey key, EKeyEventType event )
|
||||||
|
{
|
||||||
|
V_printf("key\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void IInput::AxisEvent( unsigned char cAxis, float fX, float fY )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void IInput::Frame( void )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void IInput::Deinit( void )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void IInput_Bind( int argc, char **argv )
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
void IInput_Unbind( int argc, char **argv )
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
void IInput_UnbindAll( int argc, char **argv )
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
ConCommand BindCmd("bind", IInput_Bind, 0);
|
||||||
|
ConCommand UnbindCmd("unbind", IInput_Bind, 0);
|
||||||
|
ConCommand unbindAllcmd("unbindall", IInput_Bind, 0);
|
||||||
@@ -51,6 +51,9 @@ void ILevel::LoadLevel( const char *szLevelName )
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!pEntity)
|
||||||
|
continue;
|
||||||
|
|
||||||
for ( uint32_t j = 0; j<pEntityHeader->nProperties; j++ )
|
for ( uint32_t j = 0; j<pEntityHeader->nProperties; j++ )
|
||||||
{
|
{
|
||||||
CUtlBuffer<char> szParamName(V_strlen(pData)+1);
|
CUtlBuffer<char> szParamName(V_strlen(pData)+1);
|
||||||
|
|||||||
0
engine/net.cpp
Normal file
0
engine/net.cpp
Normal file
@@ -1,5 +1,4 @@
|
|||||||
#include "physics.h"
|
#include "physics.h"
|
||||||
#include "cglm/mat4.h"
|
|
||||||
#include "physics_gen.h"
|
#include "physics_gen.h"
|
||||||
|
|
||||||
void CPxCollider::Spawn( float fFriction )
|
void CPxCollider::Spawn( float fFriction )
|
||||||
@@ -41,14 +40,48 @@ void CPxTriangleMesh::Destroy()
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void CPxRigidKinematicPosition::Spawn( CPxCollider *pCollider, px_matrix matrix, px_rigidbody_params params )
|
||||||
|
{
|
||||||
|
m_pRigidBody = px_kinematic_position_body(px, pCollider->m_pCollider, matrix, params);
|
||||||
|
};
|
||||||
|
px_vec3 CPxRigidKinematicPosition::GetPosition( void )
|
||||||
|
{
|
||||||
|
return px_getposition(px, m_pRigidBody);
|
||||||
|
};
|
||||||
|
px_matrix CPxRigidKinematicPosition::GetMatrix ( void )
|
||||||
|
{
|
||||||
|
return px_getmatrix(px, m_pRigidBody);
|
||||||
|
};
|
||||||
|
|
||||||
|
void CPxRigidKinematicPosition::Destroy()
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
void CPxRigidBody::Spawn( CPxCollider *pCollider, px_matrix matrix, px_rigidbody_params params )
|
void CPxRigidBody::Spawn( CPxCollider *pCollider, px_matrix matrix, px_rigidbody_params params )
|
||||||
{
|
{
|
||||||
m_pRigidBody = px_rigidbody(px, pCollider->m_pCollider, matrix, params);
|
m_pRigidBody = px_rigidbody(px, pCollider->m_pCollider, matrix, params);
|
||||||
};
|
};
|
||||||
|
void CPxRigidBody::SetPosition( px_vec3 position )
|
||||||
|
{
|
||||||
|
px_setposition(px, m_pRigidBody, position);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPxRigidBody::SetVelocity( px_vec3 velocity )
|
||||||
|
{
|
||||||
|
px_setvelocity(px, m_pRigidBody, velocity);
|
||||||
|
}
|
||||||
|
|
||||||
px_vec3 CPxRigidBody::GetPosition( void )
|
px_vec3 CPxRigidBody::GetPosition( void )
|
||||||
{
|
{
|
||||||
return px_getposition(px, m_pRigidBody);
|
return px_getposition(px, m_pRigidBody);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
px_vec3 CPxRigidBody::GetVelocity( void )
|
||||||
|
{
|
||||||
|
return px_getvelocity(px, m_pRigidBody);
|
||||||
|
};
|
||||||
|
|
||||||
px_matrix CPxRigidBody::GetMatrix ( void )
|
px_matrix CPxRigidBody::GetMatrix ( void )
|
||||||
{
|
{
|
||||||
return px_getmatrix(px, m_pRigidBody);
|
return px_getmatrix(px, m_pRigidBody);
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
#include "input.h"
|
||||||
|
#include "tier1/commandline.h"
|
||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
#include "baseentity.h"
|
#include "baseentity.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "physics.h"
|
#include "physics.h"
|
||||||
|
#include "input.h"
|
||||||
|
#include "net.h"
|
||||||
|
|
||||||
void *g_serverdll;
|
void *g_serverdll;
|
||||||
ConVar g_tickrate("tickrate","64",FCVAR_PROTECTED);
|
ConVar g_tickrate("tickrate","64",FCVAR_PROTECTED);
|
||||||
@@ -28,9 +32,13 @@ void IServer::Think( float fDelta )
|
|||||||
{
|
{
|
||||||
g_fAccumulator += fDelta;
|
g_fAccumulator += fDelta;
|
||||||
float fTickrate = 1.0/g_tickrate.GetFloat();
|
float fTickrate = 1.0/g_tickrate.GetFloat();
|
||||||
|
|
||||||
/* tickrate */
|
/* tickrate */
|
||||||
while(g_fAccumulator>=fTickrate)
|
while(g_fAccumulator>=fTickrate)
|
||||||
{
|
{
|
||||||
|
IInput::Frame();
|
||||||
|
IConsole::AddCommand("+forward;");
|
||||||
|
IConsole::Execute();
|
||||||
g_fAccumulator-=fTickrate;
|
g_fAccumulator-=fTickrate;
|
||||||
for (auto &entity: g_entities)
|
for (auto &entity: g_entities)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
#include "baseentity.h"
|
#include "baseentity.h"
|
||||||
#include "cglm/mat4.h"
|
|
||||||
#include "physics.h"
|
#include "physics.h"
|
||||||
#include "cglm/cglm.h"
|
|
||||||
|
|
||||||
class CLight: public CBaseEntity
|
class CLight: public CBaseEntity
|
||||||
{
|
{
|
||||||
|
|||||||
54
engine/sv_playerstart.cpp
Normal file
54
engine/sv_playerstart.cpp
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#include "baseentity.h"
|
||||||
|
#include "baseplayer.h"
|
||||||
|
#include "engine.h"
|
||||||
|
#include "tier1/utlvector.h"
|
||||||
|
|
||||||
|
|
||||||
|
CUtlVector<CPlayerStart*> g_PlayerStarts;
|
||||||
|
|
||||||
|
void CPlayerStart::Precache()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPlayerStart::Spawn()
|
||||||
|
{
|
||||||
|
g_PlayerStarts.AppendTail(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
void CPlayerStart::ReadParameter( const char *szName, const char *szValue )
|
||||||
|
{
|
||||||
|
CBaseEntity::ReadParameter(szName, szValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPlayerStart::Destroy()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPlayerStart::Think( float fDelta )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPlayerStart::RoundEnd( void )
|
||||||
|
{
|
||||||
|
m_bIsRunning = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPlayerStart::RoundStart(IIClient *pClient)
|
||||||
|
{
|
||||||
|
IIEngine::DestroyEntity(pOwningPlayer);
|
||||||
|
if (!pClient)
|
||||||
|
return;
|
||||||
|
m_bIsRunning = true;
|
||||||
|
pOwningPlayer = (CBasePlayer*)IIEngine::SpawnEntity("player");
|
||||||
|
if (pOwningPlayer)
|
||||||
|
{
|
||||||
|
pOwningPlayer->pOwningSpawn = this;
|
||||||
|
pOwningPlayer->SetPosition(m_position);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
V_printf("Failed to spawn player\n");
|
||||||
|
IIEngine::InitEntity(pOwningPlayer);
|
||||||
|
pClient->pBasePlayer = pOwningPlayer;
|
||||||
|
};
|
||||||
|
|
||||||
|
DECLARE_ENTITY(info_player_start, CPlayerStart);
|
||||||
@@ -14,8 +14,6 @@
|
|||||||
#include "vk_external_functions.cpp"
|
#include "vk_external_functions.cpp"
|
||||||
#undef VK_DEVICE_FUNCTION
|
#undef VK_DEVICE_FUNCTION
|
||||||
|
|
||||||
#include "cglm/affine.h"
|
|
||||||
#include "cglm/cglm.h"
|
|
||||||
|
|
||||||
class CVertexBuffer: public IVertexBuffer
|
class CVertexBuffer: public IVertexBuffer
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include "cglm/mat4.h"
|
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
#include "rendering.h"
|
#include "rendering.h"
|
||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
#include "vk_helper.h"
|
#include "vk_helper.h"
|
||||||
#include "vulkan/vulkan_core.h"
|
#include "vulkan/vulkan_core.h"
|
||||||
|
#include "math3d.h"
|
||||||
|
|
||||||
|
|
||||||
vk_tripipeline_t g_meshPipeline = {};
|
vk_tripipeline_t g_meshPipeline = {};
|
||||||
@@ -112,7 +112,7 @@ void IMeshRenderer::Init()
|
|||||||
bindings[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
bindings[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||||
bindings[1].descriptorCount = 1024;
|
bindings[1].descriptorCount = 1024;
|
||||||
CUtlVector<VkFormat> formats(1);
|
CUtlVector<VkFormat> formats(1);
|
||||||
formats[0] = g_meshColor.m_format;
|
formats[0] = VK_FORMAT_R16G16B16A16_SFLOAT;
|
||||||
g_meshPipeline.Create(shaders, bindings, 76, formats);
|
g_meshPipeline.Create(shaders, bindings, 76, formats);
|
||||||
shaders[1].Destroy();
|
shaders[1].Destroy();
|
||||||
shaders[0].Destroy();
|
shaders[0].Destroy();
|
||||||
@@ -285,7 +285,7 @@ void IMeshRenderer::Frame( float fDelta )
|
|||||||
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
|
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
|
||||||
.imageView = g_meshDepthMSAA.m_imageView,
|
.imageView = g_meshDepthMSAA.m_imageView,
|
||||||
.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL,
|
.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL,
|
||||||
.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT,
|
.resolveMode = VK_RESOLVE_MODE_MIN_BIT,
|
||||||
.resolveImageView = g_meshDepth.m_imageView,
|
.resolveImageView = g_meshDepth.m_imageView,
|
||||||
.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL,
|
.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL,
|
||||||
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
|
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
|
||||||
@@ -385,7 +385,7 @@ void IMeshRenderer::Frame( float fDelta )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vkCmdDraw(g_vkCommandBuffer, mesh.m_pVertexBuffer->m_buffer.m_nSize/12,1,0,0);
|
vkCmdDraw(g_vkCommandBuffer, mesh.m_pVertexBuffer->m_buffer.m_nSize/20,1,0,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vkCmdEndRendering(g_vkCommandBuffer);
|
vkCmdEndRendering(g_vkCommandBuffer);
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ void IPostProcessRenderer::Frame(float fDelta)
|
|||||||
.srcAccessMask = 0,
|
.srcAccessMask = 0,
|
||||||
.dstAccessMask = VK_ACCESS_SHADER_READ_BIT,
|
.dstAccessMask = VK_ACCESS_SHADER_READ_BIT,
|
||||||
.oldLayout = VK_IMAGE_LAYOUT_GENERAL,
|
.oldLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
.newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||||
.image = g_meshColor.m_image,
|
.image = g_meshColor.m_image,
|
||||||
.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}
|
.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}
|
||||||
},
|
},
|
||||||
@@ -92,7 +92,7 @@ void IPostProcessRenderer::Frame(float fDelta)
|
|||||||
|
|
||||||
VkDescriptorImageInfo dii1 = {
|
VkDescriptorImageInfo dii1 = {
|
||||||
.imageView = g_meshColor.m_imageView,
|
.imageView = g_meshColor.m_imageView,
|
||||||
.imageLayout = VK_IMAGE_LAYOUT_GENERAL,
|
.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||||
.sampler = NULL,
|
.sampler = NULL,
|
||||||
};
|
};
|
||||||
VkDescriptorImageInfo dii2 = {
|
VkDescriptorImageInfo dii2 = {
|
||||||
@@ -116,7 +116,15 @@ void IPostProcessRenderer::Frame(float fDelta)
|
|||||||
vkCmdDispatch(g_vkCommandBuffer, (g_nWindowWidth+31)/32, (g_nWindowHeight+31)/32, 1);
|
vkCmdDispatch(g_vkCommandBuffer, (g_nWindowWidth+31)/32, (g_nWindowHeight+31)/32, 1);
|
||||||
|
|
||||||
barriers = {
|
barriers = {
|
||||||
|
{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||||
|
.srcAccessMask = 0,
|
||||||
|
.dstAccessMask = 0,
|
||||||
|
.oldLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||||
|
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||||
|
.image = g_meshColor.m_image,
|
||||||
|
.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||||
.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
|
.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "cglm/mat4.h"
|
#include "math3d.h"
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
#include "rendering.h"
|
#include "rendering.h"
|
||||||
#include "tier0/lib.h"
|
#include "tier0/lib.h"
|
||||||
@@ -69,6 +69,7 @@ void IVulkan::Init()
|
|||||||
g_meshDepthMSAA.Create(1280, 720, VK_FORMAT_D32_SFLOAT, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, VK_SAMPLE_COUNT_4_BIT);
|
g_meshDepthMSAA.Create(1280, 720, VK_FORMAT_D32_SFLOAT, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, VK_SAMPLE_COUNT_4_BIT);
|
||||||
g_meshColor.Create(1280, 720, VK_FORMAT_R16G16B16A16_SFLOAT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_STORAGE_BIT, VK_SAMPLE_COUNT_1_BIT);
|
g_meshColor.Create(1280, 720, VK_FORMAT_R16G16B16A16_SFLOAT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_STORAGE_BIT, VK_SAMPLE_COUNT_1_BIT);
|
||||||
g_meshColorMSAA.Create(1280, 720, VK_FORMAT_R16G16B16A16_SFLOAT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, VK_SAMPLE_COUNT_4_BIT);
|
g_meshColorMSAA.Create(1280, 720, VK_FORMAT_R16G16B16A16_SFLOAT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, VK_SAMPLE_COUNT_4_BIT);
|
||||||
|
glm_mat4_identity(g_cameraView);
|
||||||
|
|
||||||
IMeshRenderer::Init();
|
IMeshRenderer::Init();
|
||||||
IPostProcessRenderer::Init();
|
IPostProcessRenderer::Init();
|
||||||
@@ -93,8 +94,8 @@ void IVulkan::Frame()
|
|||||||
|
|
||||||
g_meshDepth.Create(g_nWindowWidth, g_nWindowHeight, VK_FORMAT_D32_SFLOAT, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_SAMPLE_COUNT_1_BIT);
|
g_meshDepth.Create(g_nWindowWidth, g_nWindowHeight, VK_FORMAT_D32_SFLOAT, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_SAMPLE_COUNT_1_BIT);
|
||||||
g_meshDepthMSAA.Create(g_nWindowWidth, g_nWindowHeight, VK_FORMAT_D32_SFLOAT, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, VK_SAMPLE_COUNT_4_BIT);
|
g_meshDepthMSAA.Create(g_nWindowWidth, g_nWindowHeight, VK_FORMAT_D32_SFLOAT, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, VK_SAMPLE_COUNT_4_BIT);
|
||||||
g_meshColor.Create(g_nWindowWidth, g_nWindowHeight, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_STORAGE_BIT, VK_SAMPLE_COUNT_1_BIT);
|
g_meshColor.Create(g_nWindowWidth, g_nWindowHeight, VK_FORMAT_R16G16B16A16_SFLOAT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_STORAGE_BIT, VK_SAMPLE_COUNT_1_BIT);
|
||||||
g_meshColorMSAA.Create(g_nWindowWidth, g_nWindowHeight, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, VK_SAMPLE_COUNT_4_BIT);
|
g_meshColorMSAA.Create(g_nWindowWidth, g_nWindowHeight, VK_FORMAT_R16G16B16A16_SFLOAT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, VK_SAMPLE_COUNT_4_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
IMeshRenderer::Frame(0);
|
IMeshRenderer::Frame(0);
|
||||||
@@ -172,8 +173,6 @@ void vk_tripipeline_t::Create(
|
|||||||
/* pInputAssemblyState */
|
/* pInputAssemblyState */
|
||||||
VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE,
|
VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE,
|
||||||
VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY,
|
VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY,
|
||||||
/* pTessellationState */
|
|
||||||
VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT,
|
|
||||||
/* pViewportState */
|
/* pViewportState */
|
||||||
VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT,
|
VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT,
|
||||||
VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT,
|
VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT,
|
||||||
@@ -200,7 +199,6 @@ void vk_tripipeline_t::Create(
|
|||||||
VK_DYNAMIC_STATE_DEPTH_BOUNDS,
|
VK_DYNAMIC_STATE_DEPTH_BOUNDS,
|
||||||
/* pColorBlendState */
|
/* pColorBlendState */
|
||||||
VK_DYNAMIC_STATE_LOGIC_OP_ENABLE_EXT,
|
VK_DYNAMIC_STATE_LOGIC_OP_ENABLE_EXT,
|
||||||
VK_DYNAMIC_STATE_LOGIC_OP_EXT,
|
|
||||||
VK_DYNAMIC_STATE_COLOR_BLEND_ENABLE_EXT,
|
VK_DYNAMIC_STATE_COLOR_BLEND_ENABLE_EXT,
|
||||||
VK_DYNAMIC_STATE_COLOR_BLEND_EQUATION_EXT,
|
VK_DYNAMIC_STATE_COLOR_BLEND_EQUATION_EXT,
|
||||||
VK_DYNAMIC_STATE_COLOR_WRITE_MASK_EXT,
|
VK_DYNAMIC_STATE_COLOR_WRITE_MASK_EXT,
|
||||||
|
|||||||
@@ -3,10 +3,12 @@
|
|||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "tier1/commandline.h"
|
#include "tier1/commandline.h"
|
||||||
|
#include "input.h"
|
||||||
|
|
||||||
#include "vulkan/vulkan.h"
|
#include "vulkan/vulkan.h"
|
||||||
#include "SDL3/SDL.h"
|
#include "SDL3/SDL.h"
|
||||||
#include "vulkan/vulkan_core.h"
|
#include "vulkan/vulkan_core.h"
|
||||||
|
#include <SDL3/SDL_keycode.h>
|
||||||
#define SDL_MAIN_HANDLED
|
#define SDL_MAIN_HANDLED
|
||||||
#include "SDL3/SDL_main.h"
|
#include "SDL3/SDL_main.h"
|
||||||
#include "SDL3/SDL_vulkan.h"
|
#include "SDL3/SDL_vulkan.h"
|
||||||
@@ -17,7 +19,9 @@
|
|||||||
|
|
||||||
#define VMA_VULKAN_VERSION 1004000
|
#define VMA_VULKAN_VERSION 1004000
|
||||||
#define VMA_IMPLEMENTATION
|
#define VMA_IMPLEMENTATION
|
||||||
|
#include "tier0/minmax_off.h"
|
||||||
#include "vk_mem_alloc.h"
|
#include "vk_mem_alloc.h"
|
||||||
|
#include "tier0/minmax.h"
|
||||||
|
|
||||||
SDL_Window *g_window;
|
SDL_Window *g_window;
|
||||||
|
|
||||||
@@ -181,6 +185,51 @@ void IVideo_SwapchainDestroy()
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
EInputKey ISDL_KeyName(SDL_Keycode key)
|
||||||
|
{
|
||||||
|
switch(key)
|
||||||
|
{
|
||||||
|
case SDLK_1: return KEY_1;
|
||||||
|
case SDLK_2: return KEY_2;
|
||||||
|
case SDLK_3: return KEY_3;
|
||||||
|
case SDLK_4: return KEY_4;
|
||||||
|
case SDLK_5: return KEY_5;
|
||||||
|
case SDLK_6: return KEY_6;
|
||||||
|
case SDLK_7: return KEY_7;
|
||||||
|
case SDLK_8: return KEY_8;
|
||||||
|
case SDLK_9: return KEY_9;
|
||||||
|
case SDLK_0: return KEY_0;
|
||||||
|
|
||||||
|
case SDLK_A: return KEY_A;
|
||||||
|
case SDLK_B: return KEY_B;
|
||||||
|
case SDLK_C: return KEY_C;
|
||||||
|
case SDLK_D: return KEY_D;
|
||||||
|
case SDLK_E: return KEY_E;
|
||||||
|
case SDLK_F: return KEY_F;
|
||||||
|
case SDLK_G: return KEY_G;
|
||||||
|
case SDLK_H: return KEY_H;
|
||||||
|
case SDLK_I: return KEY_I;
|
||||||
|
case SDLK_J: return KEY_J;
|
||||||
|
case SDLK_K: return KEY_K;
|
||||||
|
case SDLK_L: return KEY_L;
|
||||||
|
case SDLK_M: return KEY_M;
|
||||||
|
case SDLK_N: return KEY_N;
|
||||||
|
case SDLK_O: return KEY_O;
|
||||||
|
case SDLK_P: return KEY_P;
|
||||||
|
case SDLK_Q: return KEY_Q;
|
||||||
|
case SDLK_R: return KEY_R;
|
||||||
|
case SDLK_S: return KEY_S;
|
||||||
|
case SDLK_T: return KEY_T;
|
||||||
|
case SDLK_U: return KEY_U;
|
||||||
|
case SDLK_V: return KEY_V;
|
||||||
|
case SDLK_W: return KEY_W;
|
||||||
|
case SDLK_X: return KEY_X;
|
||||||
|
case SDLK_Y: return KEY_Y;
|
||||||
|
case SDLK_Z: return KEY_Z;
|
||||||
|
}
|
||||||
|
return KEY_NONE;
|
||||||
|
};
|
||||||
|
|
||||||
void IVideo::Init()
|
void IVideo::Init()
|
||||||
{
|
{
|
||||||
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS);
|
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS);
|
||||||
@@ -276,16 +325,9 @@ void IVideo::Init()
|
|||||||
.extendedDynamicState3ColorWriteMask = VK_TRUE,
|
.extendedDynamicState3ColorWriteMask = VK_TRUE,
|
||||||
};
|
};
|
||||||
|
|
||||||
VkPhysicalDeviceExtendedDynamicState2FeaturesEXT pdeds2fe = {
|
|
||||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_2_FEATURES_EXT,
|
|
||||||
.pNext = &pdeds3fe,
|
|
||||||
.extendedDynamicState2LogicOp = VK_TRUE,
|
|
||||||
.extendedDynamicState2PatchControlPoints = VK_TRUE,
|
|
||||||
};
|
|
||||||
|
|
||||||
VkPhysicalDeviceVulkan13Features pdv13f = {
|
VkPhysicalDeviceVulkan13Features pdv13f = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES,
|
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES,
|
||||||
.pNext = &pdeds2fe,
|
.pNext = &pdeds3fe,
|
||||||
.synchronization2 = VK_TRUE,
|
.synchronization2 = VK_TRUE,
|
||||||
.dynamicRendering = VK_TRUE,
|
.dynamicRendering = VK_TRUE,
|
||||||
};
|
};
|
||||||
@@ -346,12 +388,22 @@ void IVideo_HandleEvents()
|
|||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(&event))
|
while (SDL_PollEvent(&event))
|
||||||
{
|
{
|
||||||
|
SDL_KeyboardEvent *key = &event.key;
|
||||||
switch (event.type)
|
switch (event.type)
|
||||||
{
|
{
|
||||||
case SDL_EVENT_WINDOW_RESIZED:
|
case SDL_EVENT_WINDOW_RESIZED:
|
||||||
g_nWindowWidth = event.window.data1;
|
g_nWindowWidth = event.window.data1;
|
||||||
g_nWindowHeight = event.window.data2;
|
g_nWindowHeight = event.window.data2;
|
||||||
g_bConfigNotify = 2;
|
g_bConfigNotify = 2;
|
||||||
|
break;
|
||||||
|
case SDL_EVENT_KEY_DOWN:
|
||||||
|
if (!key->repeat)
|
||||||
|
IInput::KeyEvent(ISDL_KeyName(key->key),KEY_EVENT_TYPE_UP);
|
||||||
|
break;
|
||||||
|
case SDL_EVENT_KEY_UP:
|
||||||
|
key = &event.key;
|
||||||
|
SDL_Log("Key Up: %s", SDL_GetKeyName(key->key));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
11
fpc/Makefile
11
fpc/Makefile
@@ -2,13 +2,22 @@ TIER_FILES := ../tier0/lib.cpp ../tier0/mem.cpp ../tier0/platform.cpp ../tier1/u
|
|||||||
FPC_FILES := main.cpp library/runner.cpp library/helper.cpp library/c.cpp library/ld.cpp library/target.cpp
|
FPC_FILES := main.cpp library/runner.cpp library/helper.cpp library/c.cpp library/ld.cpp library/target.cpp
|
||||||
CC = clang
|
CC = clang
|
||||||
OUTPUT_DIR = fpc
|
OUTPUT_DIR = fpc
|
||||||
|
CCFLAGS = -I../public -Ipublic -lc -lstdc++
|
||||||
|
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
|
ifeq ($(UNAME_S),Darwin)
|
||||||
|
CCFLAGS += -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -std=c++11 -Wl,-export_dynamic
|
||||||
|
endif
|
||||||
|
ifeq ($(UNAME_S),Linux)
|
||||||
|
CCFLAGS += -rdynamic
|
||||||
|
endif
|
||||||
|
|
||||||
recompile: ../build/tools
|
recompile: ../build/tools
|
||||||
./fpc build
|
./fpc build
|
||||||
mv fpc_temp fpc
|
mv fpc_temp fpc
|
||||||
|
|
||||||
install: $(FPC_FILES) ../build/tools
|
install: $(FPC_FILES) ../build/tools
|
||||||
$(CC) -g -rdynamic $(TIER_FILES) $(FPC_FILES) -I../public -Ipublic -lc -lstdc++ -o $(OUTPUT_DIR)
|
$(CC) -g $(TIER_FILES) $(FPC_FILES) $(CCFLAGS) -o $(OUTPUT_DIR)
|
||||||
./fpc build
|
./fpc build
|
||||||
mv fpc_temp fpc
|
mv fpc_temp fpc
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
#include "c.h"
|
#include "c.h"
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
|
#include "target.h"
|
||||||
|
#include "tier0/lib.h"
|
||||||
|
#include "tier0/platform.h"
|
||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
#include "libgen.h"
|
#include "libgen.h"
|
||||||
|
#include "ctype.h"
|
||||||
|
|
||||||
struct ClangFile_t
|
struct ClangFile_t
|
||||||
{
|
{
|
||||||
@@ -19,18 +23,46 @@ CLDProject CCProject::Compile()
|
|||||||
unsigned int hash = GenerateProjectHash();
|
unsigned int hash = GenerateProjectHash();
|
||||||
for (auto &file: files)
|
for (auto &file: files)
|
||||||
{
|
{
|
||||||
V_printf(" CC %s\n", file.GetString());
|
|
||||||
CUtlString szOutputFile = CUtlString("%s/cc/%u_%s/%s/%s.o",FPC_TEMPORAL_DIRNAME, hash, m_szName.GetString(), IFileSystem2::OwnDirectory(), file.GetString());
|
|
||||||
CUtlString szOutputDir;
|
|
||||||
CUtlVector<CUtlString> args;
|
CUtlVector<CUtlString> args;
|
||||||
|
V_printf(" CC %s\n", file.GetString());
|
||||||
|
CUtlString szTarget = "";
|
||||||
|
if (m_target.cpu == TARGET_CPU_AMD64)
|
||||||
|
{
|
||||||
|
if (m_target.kernel == TARGET_KERNEL_WINDOWS)
|
||||||
|
{
|
||||||
|
szTarget = "x86_64-pc-windows-gnu";
|
||||||
|
}
|
||||||
|
if (m_target.kernel == TARGET_KERNEL_LINUX)
|
||||||
|
{
|
||||||
|
szTarget = "x86_64-unknown-linux-gnu";
|
||||||
|
}
|
||||||
|
if (m_target.kernel == TARGET_KERNEL_DARWIN)
|
||||||
|
{
|
||||||
|
szTarget = "x86_64-apple-darwin";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
CUtlString szOutputFile = CUtlString("%s/%s/cc/%u_%s/%s/%s.o",FPC_TEMPORAL_DIRNAME, szTarget.GetString(), hash, m_szName.GetString(), IFileSystem2::BuildDirectory(), file.GetString());
|
||||||
|
CUtlString szOutputDir;
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
|
"-target",
|
||||||
|
szTarget,
|
||||||
"-g",
|
"-g",
|
||||||
"-c",
|
"-c",
|
||||||
"-o",
|
"-o",
|
||||||
szOutputFile,
|
szOutputFile,
|
||||||
file,
|
file,
|
||||||
};
|
};
|
||||||
|
if (!strcmp(Plat_GetExtension(file),"cpp"))
|
||||||
|
args.AppendTail("-std=c++17");
|
||||||
|
else
|
||||||
|
args.AppendTail("-std=c99");
|
||||||
|
|
||||||
|
if (m_target.kernel == TARGET_KERNEL_DARWIN)
|
||||||
|
{
|
||||||
|
args.AppendTail("-isysroot");
|
||||||
|
args.AppendTail("/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk");
|
||||||
|
}
|
||||||
if (bFPIC)
|
if (bFPIC)
|
||||||
args.AppendTail("-fPIC");
|
args.AppendTail("-fPIC");
|
||||||
if (bFPIE)
|
if (bFPIE)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "ld.h"
|
#include "ld.h"
|
||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
#include "libgen.h"
|
#include "libgen.h"
|
||||||
|
#include "target.h"
|
||||||
|
|
||||||
CUtlString CLDProject::Link( void )
|
CUtlString CLDProject::Link( void )
|
||||||
{
|
{
|
||||||
@@ -15,7 +16,10 @@ CUtlString CLDProject::Link( void )
|
|||||||
szFileName = CUtlString("lib%s.a", m_szName.GetString());
|
szFileName = CUtlString("lib%s.a", m_szName.GetString());
|
||||||
break;
|
break;
|
||||||
case ELINK_DYNAMIC_LIBRARY:
|
case ELINK_DYNAMIC_LIBRARY:
|
||||||
szFileName = CUtlString("lib%s.so", m_szName.GetString());
|
if (m_target.kernel == TARGET_KERNEL_DARWIN)
|
||||||
|
szFileName = CUtlString("lib%s.dylib", m_szName.GetString());
|
||||||
|
if (m_target.kernel == TARGET_KERNEL_LINUX)
|
||||||
|
szFileName = CUtlString("lib%s.so", m_szName.GetString());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CUtlString szOutputFile = CUtlString("%s/ld/%u_%s/%s",FPC_TEMPORAL_DIRNAME, hash, m_szName.GetString(), szFileName.GetString());
|
CUtlString szOutputFile = CUtlString("%s/ld/%u_%s/%s",FPC_TEMPORAL_DIRNAME, hash, m_szName.GetString(), szFileName.GetString());
|
||||||
@@ -59,12 +63,23 @@ CUtlString CLDProject::Link( void )
|
|||||||
if (!shouldRecompile)
|
if (!shouldRecompile)
|
||||||
goto compiled;
|
goto compiled;
|
||||||
args = {
|
args = {
|
||||||
"-rdynamic",
|
|
||||||
"-o",
|
"-o",
|
||||||
szOutputFile,
|
szOutputFile,
|
||||||
};
|
};
|
||||||
|
if (m_target.kernel == TARGET_KERNEL_LINUX)
|
||||||
|
{
|
||||||
|
args.AppendTail("-rdynamic");
|
||||||
|
}
|
||||||
|
if (m_target.kernel == TARGET_KERNEL_DARWIN)
|
||||||
|
{
|
||||||
|
args.AppendTail("-Wl,-export_dynamic");
|
||||||
|
args.AppendTail("-undefined");
|
||||||
|
args.AppendTail("dynamic_lookup");
|
||||||
|
}
|
||||||
if (linkType == ELINK_DYNAMIC_LIBRARY)
|
if (linkType == ELINK_DYNAMIC_LIBRARY)
|
||||||
|
{
|
||||||
args.AppendTail("-shared");
|
args.AppendTail("-shared");
|
||||||
|
}
|
||||||
for (auto object: objects)
|
for (auto object: objects)
|
||||||
args.AppendTail(object.m_szObjectFile);
|
args.AppendTail(object.m_szObjectFile);
|
||||||
for (auto lib: libraries)
|
for (auto lib: libraries)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
#include "unistd.h"
|
#include "unistd.h"
|
||||||
#include "sys/wait.h"
|
#include "sys/wait.h"
|
||||||
|
#include "tier1/commandline.h"
|
||||||
int IRunner::Run(CUtlString szName, CUtlVector<CUtlString>& args)
|
int IRunner::Run(CUtlString szName, CUtlVector<CUtlString>& args)
|
||||||
{
|
{
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
@@ -14,10 +15,16 @@ int IRunner::Run(CUtlString szName, CUtlVector<CUtlString>& args)
|
|||||||
{
|
{
|
||||||
CUtlVector<const char*> execargs;
|
CUtlVector<const char*> execargs;
|
||||||
execargs.AppendTail(szName);
|
execargs.AppendTail(szName);
|
||||||
|
if (ICommandLine::CheckParam("-fpcdebug"))
|
||||||
|
V_printf("%s",szName.GetString());
|
||||||
for (auto &arg: args)
|
for (auto &arg: args)
|
||||||
{
|
{
|
||||||
execargs.AppendTail(arg);
|
execargs.AppendTail(arg);
|
||||||
|
if (ICommandLine::CheckParam("-fpcdebug"))
|
||||||
|
V_printf(" %s",arg.GetString());
|
||||||
}
|
}
|
||||||
|
if (ICommandLine::CheckParam("-fpcdebug"))
|
||||||
|
V_printf("\n");
|
||||||
execargs.AppendTail(0);
|
execargs.AppendTail(0);
|
||||||
execvp(szName, (char *const*)execargs.GetData());
|
execvp(szName, (char *const*)execargs.GetData());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,34 @@
|
|||||||
#include "target.h"
|
#include "target.h"
|
||||||
#include <god/build.h>
|
#include "tier1/commandline.h"
|
||||||
|
#include "tier1/utlstring.h"
|
||||||
|
|
||||||
Target_t Target_t::DefaultTarget()
|
Target_t Target_t::DefaultTarget()
|
||||||
{
|
{
|
||||||
|
CUtlString szDevice = ICommandLine::ParamValue("-device");
|
||||||
|
CUtlString szOS = ICommandLine::ParamValue("-os");
|
||||||
|
CUtlString szArch = ICommandLine::ParamValue("-arch");
|
||||||
|
|
||||||
|
ETargetKernel kernel =
|
||||||
|
#if defined(__linux__)
|
||||||
|
TARGET_KERNEL_LINUX
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
TARGET_KERNEL_DARWIN
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
ETargetCPU cpu = TARGET_CPU_AMD64;
|
||||||
|
|
||||||
|
if ( szOS == "windows" )
|
||||||
|
kernel = TARGET_KERNEL_WINDOWS;
|
||||||
|
else if ( szOS == "linux" )
|
||||||
|
kernel = TARGET_KERNEL_LINUX;
|
||||||
|
else if ( szOS == "macos" )
|
||||||
|
kernel = TARGET_KERNEL_DARWIN;
|
||||||
|
else if ( szOS != 0 )
|
||||||
|
V_printf("Unknown OS: %s\n", szOS.GetString());
|
||||||
|
|
||||||
return {
|
return {
|
||||||
.kernel = TARGET_KERNEL_LINUX,
|
.kernel = kernel,
|
||||||
#ifdef __x86_64__
|
.cpu = cpu,
|
||||||
.cpu = TARGET_CPU_AMD64,
|
|
||||||
#endif
|
|
||||||
#ifdef __x86__
|
|
||||||
.cpu = TARGET_CPU_I386,
|
|
||||||
#endif
|
|
||||||
.optimization = TARGET_DEBUG,
|
.optimization = TARGET_DEBUG,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,27 @@ struct C_Macro_t
|
|||||||
CUtlString szValue;
|
CUtlString szValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ECVersion
|
||||||
|
{
|
||||||
|
CVERSION_89,
|
||||||
|
CVERSION_99 = 0,
|
||||||
|
CVERSION_11,
|
||||||
|
CVERSION_17,
|
||||||
|
CVERSION_23,
|
||||||
|
CVERSION_2Y,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ECPPVersion
|
||||||
|
{
|
||||||
|
CPPVERSION_98 = 1,
|
||||||
|
CPPVERSION_11 = 0,
|
||||||
|
CPPVERSION_14 = 2,
|
||||||
|
CPPVERSION_17 = 3,
|
||||||
|
CPPVERSION_20 = 4,
|
||||||
|
CPPVERSION_23 = 5,
|
||||||
|
CPPVERSION_2C = 6,
|
||||||
|
};
|
||||||
|
|
||||||
class CCProject : public CProject
|
class CCProject : public CProject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -24,6 +45,8 @@ public:
|
|||||||
bool bFPIE;
|
bool bFPIE;
|
||||||
bool bFPIC;
|
bool bFPIC;
|
||||||
bool bDebug = m_target.optimization == TARGET_DEBUG;
|
bool bDebug = m_target.optimization == TARGET_DEBUG;
|
||||||
|
ECVersion cVersion;
|
||||||
|
ECPPVersion cppVersion;
|
||||||
CLDProject Compile();
|
CLDProject Compile();
|
||||||
static void GenerateCompileCommands();
|
static void GenerateCompileCommands();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ enum ETargetKernel
|
|||||||
{
|
{
|
||||||
TARGET_KERNEL_LINUX,
|
TARGET_KERNEL_LINUX,
|
||||||
TARGET_KERNEL_WINDOWS,
|
TARGET_KERNEL_WINDOWS,
|
||||||
|
TARGET_KERNEL_DARWIN,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ETargetCPU
|
enum ETargetCPU
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ int assets_build()
|
|||||||
build_shader("mesh_frag");
|
build_shader("mesh_frag");
|
||||||
build_shader("mesh_vert");
|
build_shader("mesh_vert");
|
||||||
build_shader("agx_comp");
|
build_shader("agx_comp");
|
||||||
|
build_shader("mesh_edge_detection_comp");
|
||||||
CUtlVector<CUtlString> python_args = {
|
CUtlVector<CUtlString> python_args = {
|
||||||
"build/tools/makepak64.py",
|
"build/tools/makepak64.py",
|
||||||
CUtlString("build/%s/assets", szGameName),
|
CUtlString("build/%s/assets", szGameName),
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ void main(uint3 threadId: SV_DispatchThreadID)
|
|||||||
color = agxLook(color);
|
color = agxLook(color);
|
||||||
color = agxEotf(color);
|
color = agxEotf(color);
|
||||||
color = pow(color,0.45);
|
color = pow(color,0.45);
|
||||||
|
color = clamp(color, 0, 1);
|
||||||
g_imageOut[coord] = float4(color,1);
|
g_imageOut[coord] = float4(color,1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
0
funnyassets/gfx_shaders/mesh_deferred_hit.slang
Normal file
0
funnyassets/gfx_shaders/mesh_deferred_hit.slang
Normal file
0
funnyassets/gfx_shaders/mesh_deferred_raygen.slang
Normal file
0
funnyassets/gfx_shaders/mesh_deferred_raygen.slang
Normal file
0
funnyassets/gfx_shaders/mesh_deferred_shadow.slang
Normal file
0
funnyassets/gfx_shaders/mesh_deferred_shadow.slang
Normal file
0
funnyassets/gfx_shaders/mesh_deferred_sky.slang
Normal file
0
funnyassets/gfx_shaders/mesh_deferred_sky.slang
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 863 KiB After Width: | Height: | Size: 7.0 KiB |
@@ -5,7 +5,7 @@
|
|||||||
#include "tier1/commandline.h"
|
#include "tier1/commandline.h"
|
||||||
|
|
||||||
CUtlVector<CUtlString> client_CompiledFiles = {
|
CUtlVector<CUtlString> client_CompiledFiles = {
|
||||||
"game/client/baseplayer.cpp",
|
"game/client/milmoba/player.cpp",
|
||||||
};
|
};
|
||||||
|
|
||||||
int client_build()
|
int client_build()
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
#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
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual void Precache ( void ) override;
|
|
||||||
virtual void Spawn( void ) override;
|
|
||||||
virtual void Destroy( void ) override;
|
|
||||||
virtual void Think( float fDelta ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern mat4 g_cameraView;
|
|
||||||
|
|
||||||
void C_BasePlayer::Precache()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void C_BasePlayer::Spawn()
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
LINK_CLIENT_ENTITY(C_BasePlayer, CBasePlayer)
|
|
||||||
38
game/client/milmoba/player.cpp
Normal file
38
game/client/milmoba/player.cpp
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#include "baseplayer.h"
|
||||||
|
#include "engine.h"
|
||||||
|
#include "rendering.h"
|
||||||
|
|
||||||
|
class C_MOBAPlayer: public C_BaseEntity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void Precache ( void ) override;
|
||||||
|
virtual void Spawn( void ) override;
|
||||||
|
virtual void Destroy( void ) override;
|
||||||
|
virtual void Think( float fDelta ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
void C_MOBAPlayer::Precache()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_MOBAPlayer::Spawn()
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
void C_MOBAPlayer::Destroy()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void C_MOBAPlayer::Think( float fDelta )
|
||||||
|
{
|
||||||
|
if (g_localClient.pBasePlayer == pEntity)
|
||||||
|
{
|
||||||
|
g_cameraView[3][0] = pEntity->m_position[0];
|
||||||
|
g_cameraView[3][1] = pEntity->m_position[1];
|
||||||
|
g_cameraView[3][2] = pEntity->m_position[2]+0.7;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
LINK_CLIENT_ENTITY(C_MOBAPlayer, CMOBAPlayer)
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
CUtlVector<CUtlString> server_CompiledFiles = {
|
CUtlVector<CUtlString> server_CompiledFiles = {
|
||||||
"game/server/game.cpp",
|
"game/server/game.cpp",
|
||||||
"game/server/baseplayer.cpp",
|
"game/server/milmoba/player.cpp",
|
||||||
};
|
};
|
||||||
|
|
||||||
int server_build()
|
int server_build()
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
#include "baseentity.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;
|
|
||||||
};
|
|
||||||
|
|
||||||
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 )
|
|
||||||
{
|
|
||||||
CBaseEntity::ReadParameter(szName, szValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CBasePlayer::Destroy()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
void CBasePlayer::Think( float fDelta )
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
DECLARE_ENTITY(player, CBasePlayer);
|
|
||||||
@@ -1,12 +1,17 @@
|
|||||||
|
|
||||||
|
#include "console.h"
|
||||||
|
#include "gamemode.h"
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "level.h"
|
#include "level.h"
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
|
#include "tier0/lib.h"
|
||||||
|
|
||||||
|
CGameMode testMode;
|
||||||
|
|
||||||
DLL_EXPORT void IGame_Load()
|
DLL_EXPORT void IGame_Load()
|
||||||
{
|
{
|
||||||
ILevel::LoadLevel("maps/test_map");
|
ILevel::LoadLevel("maps/test_map");
|
||||||
|
IGameModeManager::StartGameMode(&testMode);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|||||||
168
game/server/milmoba/player.cpp
Normal file
168
game/server/milmoba/player.cpp
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
#include "baseentity.h"
|
||||||
|
#include "baseplayer.h"
|
||||||
|
#include "cglm/mat4.h"
|
||||||
|
#include "cglm/util.h"
|
||||||
|
#include "cglm/vec2.h"
|
||||||
|
#include "cglm/vec3.h"
|
||||||
|
#include "console.h"
|
||||||
|
#include "engine.h"
|
||||||
|
#include "physics.h"
|
||||||
|
#include "physics_gen.h"
|
||||||
|
|
||||||
|
class CMOBAPlayer: public CBasePlayer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void Precache() override;
|
||||||
|
virtual void Spawn( void ) override;
|
||||||
|
virtual void Destroy( void ) override;
|
||||||
|
virtual void ReadParameter( const char *szName, const char *szValue ) override;
|
||||||
|
virtual void Think( float fDelta ) override;
|
||||||
|
|
||||||
|
void AirAccelerate();
|
||||||
|
void Accelerate( float fDelta, vec2 wishDir, float fWishSpeed, float fAcceleration );
|
||||||
|
void Move( float fDelta );
|
||||||
|
|
||||||
|
|
||||||
|
bool bIsForward = 0;
|
||||||
|
bool bIsBack = 0;
|
||||||
|
bool bIsLeft = 0;
|
||||||
|
bool bIsRight = 0;
|
||||||
|
|
||||||
|
bool bIsJumping = 0;
|
||||||
|
bool bIsCrouching = 0;
|
||||||
|
bool bIsProning = 0;
|
||||||
|
bool bIsFiring = 0;
|
||||||
|
bool bIsFiring2 = 0;
|
||||||
|
|
||||||
|
float fPitch = 0;
|
||||||
|
float fYaw = 0;
|
||||||
|
|
||||||
|
vec3 m_velocity;
|
||||||
|
|
||||||
|
CPxBoxMesh mesh;
|
||||||
|
CPxRigidBody rigidbody;
|
||||||
|
};
|
||||||
|
|
||||||
|
void CMOBAPlayer::Precache()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMOBAPlayer::Spawn()
|
||||||
|
{
|
||||||
|
mesh.m_fRadius[0] = 0.3;
|
||||||
|
mesh.m_fRadius[1] = 0.3;
|
||||||
|
mesh.m_fRadius[2] = 0.8;
|
||||||
|
mesh.Spawn();
|
||||||
|
px_matrix m = {};
|
||||||
|
m.m[0] = 1;
|
||||||
|
m.m[5] = 1;
|
||||||
|
m.m[10] = 1;
|
||||||
|
m.m[15] = 1;
|
||||||
|
m.m[12] = m_position[0];
|
||||||
|
m.m[13] = m_position[1];
|
||||||
|
m.m[14] = m_position[2];
|
||||||
|
rigidbody.Spawn(&mesh, m, {
|
||||||
|
.gravity_scale = 1,
|
||||||
|
.continous = true,
|
||||||
|
.lockrotx = 1,
|
||||||
|
.lockroty = 1,
|
||||||
|
.lockrotz = 1,
|
||||||
|
.dominance = 127,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void CMOBAPlayer::ReadParameter( const char *szName, const char *szValue )
|
||||||
|
{
|
||||||
|
CBaseEntity::ReadParameter(szName, szValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMOBAPlayer::Destroy()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMOBAPlayer::AirAccelerate()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMOBAPlayer::Accelerate( float fDelta, vec2 wishDir, float fWishSpeed, float fAcceleration )
|
||||||
|
{
|
||||||
|
float fCurrentSpeed = glm_vec2_dot(wishDir, m_velocity);
|
||||||
|
float fAddSpeed = fWishSpeed - fCurrentSpeed;
|
||||||
|
if ( fAddSpeed < 0 )
|
||||||
|
return;
|
||||||
|
float fAccelSpeed = fAcceleration*fDelta*fWishSpeed;
|
||||||
|
if ( fAccelSpeed > fAddSpeed )
|
||||||
|
fAccelSpeed = fAddSpeed;
|
||||||
|
glm_vec2_scale(wishDir, fAccelSpeed, m_velocity);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMOBAPlayer::Move( float fDelta )
|
||||||
|
{
|
||||||
|
vec2 forward = {(float)bIsForward-(float)bIsBack,0};
|
||||||
|
vec2 right = {0,(float)bIsLeft-(float)bIsRight};
|
||||||
|
vec2 wishDir;
|
||||||
|
float fWishSpeed;
|
||||||
|
|
||||||
|
glm_vec2_rotate(forward, fYaw, forward);
|
||||||
|
glm_vec2_rotate(forward, fYaw, forward);
|
||||||
|
glm_vec2_add(forward, right, wishDir);
|
||||||
|
fWishSpeed = glm_vec2_distance(wishDir, (vec3){0,0,0});
|
||||||
|
|
||||||
|
if (fWishSpeed != 0)
|
||||||
|
{
|
||||||
|
glm_vec2_divs(wishDir, fWishSpeed, wishDir);
|
||||||
|
fWishSpeed = 10;
|
||||||
|
} else {
|
||||||
|
glm_vec2_zero(wishDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
Accelerate(fDelta, wishDir, fWishSpeed, 5.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CMOBAPlayer::Think( float fDelta )
|
||||||
|
{
|
||||||
|
m_position[0] = rigidbody.GetPosition().m[0];
|
||||||
|
m_position[1] = rigidbody.GetPosition().m[1];
|
||||||
|
m_position[2] = rigidbody.GetPosition().m[2];
|
||||||
|
px_vec3 v = rigidbody.GetVelocity();
|
||||||
|
px_vec3 p = rigidbody.GetPosition();
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
m_velocity[i] = v.m[i];
|
||||||
|
|
||||||
|
px_cast_result r = px_box_cast(px, 0.3,0.3,0.01, {p.m[0],p.m[1],p.m[2]-0.79f}, {0,0,0}, {0,0,-1}, 1);
|
||||||
|
if (r.hit)
|
||||||
|
{
|
||||||
|
Move(fDelta);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
v.m[i] = m_velocity[i];
|
||||||
|
|
||||||
|
rigidbody.SetVelocity(v);
|
||||||
|
};
|
||||||
|
|
||||||
|
void PlayerForward(int argc, char **argv) {if (g_localClient.pBasePlayer) ((CMOBAPlayer*)g_localClient.pBasePlayer)->bIsForward = true;};
|
||||||
|
void PlayerForwardUp(int argc, char **argv) {if (g_localClient.pBasePlayer) ((CMOBAPlayer*)g_localClient.pBasePlayer)->bIsForward = false;};
|
||||||
|
void PlayerBack(int argc, char **argv) {if (g_localClient.pBasePlayer) ((CMOBAPlayer*)g_localClient.pBasePlayer)->bIsBack = true;};
|
||||||
|
void PlayerBackUp(int argc, char **argv) {if (g_localClient.pBasePlayer) ((CMOBAPlayer*)g_localClient.pBasePlayer)->bIsBack = false;};
|
||||||
|
void PlayerLeft(int argc, char **argv) {if (g_localClient.pBasePlayer) ((CMOBAPlayer*)g_localClient.pBasePlayer)->bIsLeft = true;};
|
||||||
|
void PlayerLeftUp(int argc, char **argv) {if (g_localClient.pBasePlayer) ((CMOBAPlayer*)g_localClient.pBasePlayer)->bIsLeft = false;};
|
||||||
|
void PlayerRight(int argc, char **argv) {if (g_localClient.pBasePlayer) ((CMOBAPlayer*)g_localClient.pBasePlayer)->bIsRight = true;};
|
||||||
|
void PlayerRightUp(int argc, char **argv) {if (g_localClient.pBasePlayer) ((CMOBAPlayer*)g_localClient.pBasePlayer)->bIsRight = false;};
|
||||||
|
|
||||||
|
ConCommand moveForwardCmd("+forward", PlayerForward, 0);
|
||||||
|
ConCommand moveForwardUpCmd("-forward", PlayerForwardUp, 0);
|
||||||
|
ConCommand moveBackwardCmd("+back", PlayerBack, 0);
|
||||||
|
ConCommand moveBackwardUpCmd("-back", PlayerBackUp, 0);
|
||||||
|
ConCommand moveLeftCmd("+left", PlayerLeft, 0);
|
||||||
|
ConCommand moveLeftUpCmd("-left", PlayerLeftUp, 0);
|
||||||
|
ConCommand moveRightCmd("+right", PlayerRight, 0);
|
||||||
|
ConCommand moveRightUpCmd("-right", PlayerRightUp, 0);
|
||||||
|
|
||||||
|
DECLARE_ENTITY(player, CMOBAPlayer);
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
#include "cglm/cglm.h"
|
#include "math3d.h"
|
||||||
|
|
||||||
class CBaseEntity;
|
class CBaseEntity;
|
||||||
class C_BaseEntity;
|
class C_BaseEntity;
|
||||||
@@ -28,7 +28,7 @@ public:
|
|||||||
void SetRotationMatrix( mat3 matrix );
|
void SetRotationMatrix( mat3 matrix );
|
||||||
void SetScale( vec3 scale );
|
void SetScale( vec3 scale );
|
||||||
|
|
||||||
C_BaseEntity *pClientEntity;
|
C_BaseEntity *pClientEntity = NULL;
|
||||||
mat3 m_matrix;
|
mat3 m_matrix;
|
||||||
vec3 m_position;
|
vec3 m_position;
|
||||||
vec3 m_scale;
|
vec3 m_scale;
|
||||||
|
|||||||
14
public/baseplayer.h
Normal file
14
public/baseplayer.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef BASE_PLAYER_H
|
||||||
|
#define BASE_PLAYER_H
|
||||||
|
|
||||||
|
#include "baseentity.h"
|
||||||
|
#include "playerstart.h"
|
||||||
|
class CBaseEntity;
|
||||||
|
|
||||||
|
class CBasePlayer: public CBaseEntity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CPlayerStart *pOwningSpawn;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
|
#include "tier1/utlvector.h"
|
||||||
|
|
||||||
class ConVar;
|
class ConVar;
|
||||||
class ConCommand;
|
class ConCommand;
|
||||||
@@ -16,13 +17,15 @@ public:
|
|||||||
static void UnRegisterVar( ConVar *cvar );
|
static void UnRegisterVar( ConVar *cvar );
|
||||||
static ConVar *FindVar( const char *pName );
|
static ConVar *FindVar( const char *pName );
|
||||||
|
|
||||||
static void RegisterCommand( ConVar *cvar );
|
static void RegisterCommand( ConCommand *cvar );
|
||||||
static void UnRegisterCommand( ConVar *cvar );
|
static void UnRegisterCommand( ConCommand *cvar );
|
||||||
static ConCommand *FindCommand( const char *pName );
|
static ConCommand *FindCommand( const char *pName );
|
||||||
|
|
||||||
static void Execute( void );
|
static void Execute( void );
|
||||||
static void AddCommand( const char *psz );
|
static void AddCommand( const char *psz );
|
||||||
static void InsertCommand( const char *psz );
|
static void InsertCommand( const char *psz );
|
||||||
|
private:
|
||||||
|
static void Execute2( CUtlVector<CUtlString> &args );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -83,9 +86,13 @@ class ConCommand
|
|||||||
public:
|
public:
|
||||||
ConCommand(const char *pName, ConCommandFn callback,
|
ConCommand(const char *pName, ConCommandFn callback,
|
||||||
const char *pHelpString=0, int flags=0);
|
const char *pHelpString=0, int flags=0);
|
||||||
|
|
||||||
|
const char *GetName( void );
|
||||||
|
const char *GetHelpText( void );
|
||||||
|
ConCommandFn GetCallback( void );
|
||||||
private:
|
private:
|
||||||
char *m_szName;
|
CUtlString m_szName;
|
||||||
char *m_szHelpString = NULL;
|
CUtlString m_szHelpString = NULL;
|
||||||
ConCommandFn m_callback;
|
ConCommandFn m_callback;
|
||||||
|
|
||||||
int m_flags;
|
int m_flags;
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
/* for windows as it sucks */
|
/* for windows as it sucks */
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
|
#include "server.h"
|
||||||
|
#include "tier1/utlvector.h"
|
||||||
|
|
||||||
class CBaseEntity;
|
class CBaseEntity;
|
||||||
|
|
||||||
@@ -14,12 +16,18 @@ public:
|
|||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern IIClient g_localClient;
|
||||||
|
extern CUtlVector<IIClient*> g_clients;
|
||||||
|
|
||||||
|
|
||||||
interface IIEngine
|
interface IIEngine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static CBaseEntity *SpawnEntity( const char *szName );
|
static CBaseEntity *SpawnEntity( const char *szName );
|
||||||
|
static void InitEntity(CBaseEntity *pEntity);
|
||||||
static void DestroyEntity( CBaseEntity *pEntity );
|
static void DestroyEntity( CBaseEntity *pEntity );
|
||||||
|
static void ConnectClient( IIClient *pClient);
|
||||||
|
static void DisconnectClient( IIClient *pClient);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
24
public/gamemode.h
Normal file
24
public/gamemode.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#ifndef GAMEMODE_H
|
||||||
|
#define GAMEMODE_H
|
||||||
|
|
||||||
|
#include "tier0/platform.h"
|
||||||
|
|
||||||
|
class CGameMode
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void RoundBegin( void );
|
||||||
|
virtual void RoundEnd( void );
|
||||||
|
bool bCanPlayerSpawnMidRound;
|
||||||
|
};
|
||||||
|
|
||||||
|
interface IGameModeManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void Init( void );
|
||||||
|
static void Frame( void );
|
||||||
|
static void StartGameMode(CGameMode *pGameMode);
|
||||||
|
static CGameMode *GetCurrentMode( void );
|
||||||
|
static void RestartCurrentMode( void );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
103
public/input.h
103
public/input.h
@@ -0,0 +1,103 @@
|
|||||||
|
#ifndef INPUT_H
|
||||||
|
#define INPUT_H
|
||||||
|
|
||||||
|
#include "tier0/platform.h"
|
||||||
|
|
||||||
|
enum EKeyEventType
|
||||||
|
{
|
||||||
|
KEY_EVENT_TYPE_DOWN,
|
||||||
|
KEY_EVENT_TYPE_UP,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum EInputKey
|
||||||
|
{
|
||||||
|
KEY_NONE = 0,
|
||||||
|
KEY_ESCAPE,
|
||||||
|
KEY_TAB,
|
||||||
|
KEY_TILDE,
|
||||||
|
KEY_CAPSLOCK,
|
||||||
|
KEY_CONTROL,
|
||||||
|
KEY_SHIFT,
|
||||||
|
KEY_WIN,
|
||||||
|
KEY_ALT,
|
||||||
|
KEY_SPACE,
|
||||||
|
|
||||||
|
KEY_BACKSPACE,
|
||||||
|
KEY_LBRACKET,
|
||||||
|
KEY_RBRACKET,
|
||||||
|
KEY_BACKSLASH,
|
||||||
|
KEY_SEMICOLON,
|
||||||
|
KEY_APOSTROPHE,
|
||||||
|
KEY_SLASH,
|
||||||
|
KEY_ENTER,
|
||||||
|
|
||||||
|
KEY_F1,
|
||||||
|
KEY_F2,
|
||||||
|
KEY_F3,
|
||||||
|
KEY_F4,
|
||||||
|
KEY_F5,
|
||||||
|
KEY_F6,
|
||||||
|
KEY_F7,
|
||||||
|
KEY_F8,
|
||||||
|
KEY_F9,
|
||||||
|
KEY_F10,
|
||||||
|
KEY_F11,
|
||||||
|
KEY_F12,
|
||||||
|
|
||||||
|
KEY_1,
|
||||||
|
KEY_2,
|
||||||
|
KEY_3,
|
||||||
|
KEY_4,
|
||||||
|
KEY_5,
|
||||||
|
KEY_6,
|
||||||
|
KEY_7,
|
||||||
|
KEY_8,
|
||||||
|
KEY_9,
|
||||||
|
KEY_0,
|
||||||
|
|
||||||
|
KEY_A,
|
||||||
|
KEY_B,
|
||||||
|
KEY_C,
|
||||||
|
KEY_D,
|
||||||
|
KEY_E,
|
||||||
|
KEY_F,
|
||||||
|
KEY_G,
|
||||||
|
KEY_H,
|
||||||
|
KEY_I,
|
||||||
|
KEY_J,
|
||||||
|
KEY_K,
|
||||||
|
KEY_L,
|
||||||
|
KEY_M,
|
||||||
|
KEY_N,
|
||||||
|
KEY_O,
|
||||||
|
KEY_P,
|
||||||
|
KEY_Q,
|
||||||
|
KEY_R,
|
||||||
|
KEY_S,
|
||||||
|
KEY_T,
|
||||||
|
KEY_U,
|
||||||
|
KEY_V,
|
||||||
|
KEY_W,
|
||||||
|
KEY_X,
|
||||||
|
KEY_Y,
|
||||||
|
KEY_Z,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum EInputAxis
|
||||||
|
{
|
||||||
|
AXIS_MOUSE_X,
|
||||||
|
AXIS_MOUSE_Y,
|
||||||
|
AXIS_MOUSE_SCROLL,
|
||||||
|
};
|
||||||
|
|
||||||
|
interface IInput
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void Init( void );
|
||||||
|
static void KeyEvent( EInputKey key, EKeyEventType event );
|
||||||
|
static void AxisEvent( unsigned char axis, float fX, float fY );
|
||||||
|
static void Frame( void );
|
||||||
|
static void Deinit( void );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
8
public/math3d.h
Normal file
8
public/math3d.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
#ifndef MATH_3D_H
|
||||||
|
#define MATH_3D_H
|
||||||
|
#include "tier0/minmax_off.h"
|
||||||
|
#include "cglm/cglm.h"
|
||||||
|
#include "cglm/affine.h"
|
||||||
|
#include "tier0/minmax.h"
|
||||||
|
#endif
|
||||||
11
public/net.h
Normal file
11
public/net.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#ifndef NET_H
|
||||||
|
#define NET_H
|
||||||
|
|
||||||
|
#include "tier0/platform.h"
|
||||||
|
|
||||||
|
interface INet
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -54,11 +54,25 @@ public:
|
|||||||
virtual void Destroy( void ) override;
|
virtual void Destroy( void ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CPxRigidKinematicPosition
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
RigidBodyHandle *m_pRigidBody;
|
||||||
|
};
|
||||||
|
|
||||||
class CPxRigidBody
|
class CPxRigidBody
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void Spawn( CPxCollider *pCollider, px_matrix matrix, px_rigidbody_params params );
|
void Spawn( CPxCollider *pCollider, px_matrix matrix, px_rigidbody_params params );
|
||||||
px_vec3 GetPosition( void );
|
px_vec3 GetPosition( void );
|
||||||
|
px_vec3 GetVelocity( void );
|
||||||
|
void SetPosition( px_vec3 position );
|
||||||
|
void SetVelocity( px_vec3 velocity );
|
||||||
px_matrix GetMatrix ( void );
|
px_matrix GetMatrix ( void );
|
||||||
void Destroy( void );
|
void Destroy( void );
|
||||||
CPxCollider *m_pCollider;
|
CPxCollider *m_pCollider;
|
||||||
|
|||||||
@@ -72,6 +72,11 @@ struct px_vec3 px_getvelocity(struct funnyphysics *px_world, RigidBodyHandle *bo
|
|||||||
|
|
||||||
struct funnyphysics *px_init(void);
|
struct funnyphysics *px_init(void);
|
||||||
|
|
||||||
|
RigidBodyHandle *px_kinematic_position_body(struct funnyphysics *px_world,
|
||||||
|
Collider *collider,
|
||||||
|
struct px_matrix m,
|
||||||
|
struct px_rigidbody_params params);
|
||||||
|
|
||||||
RigidBodyHandle *px_rigidbody(struct funnyphysics *px_world,
|
RigidBodyHandle *px_rigidbody(struct funnyphysics *px_world,
|
||||||
Collider *collider,
|
Collider *collider,
|
||||||
struct px_matrix m,
|
struct px_matrix m,
|
||||||
|
|||||||
25
public/playerstart.h
Normal file
25
public/playerstart.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef PLAYER_START_H
|
||||||
|
#define PLAYER_START_H
|
||||||
|
|
||||||
|
#include "baseentity.h"
|
||||||
|
#include "server.h"
|
||||||
|
|
||||||
|
|
||||||
|
class CPlayerStart: 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;
|
||||||
|
virtual void RoundEnd( void );
|
||||||
|
virtual void RoundStart( IIClient *pClient );
|
||||||
|
|
||||||
|
CBasePlayer *pOwningPlayer = NULL;
|
||||||
|
bool m_bIsRunning = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern CUtlVector<CPlayerStart*> g_PlayerStarts;
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
#ifndef RENDERING_H
|
#ifndef RENDERING_H
|
||||||
#define RENDERING_H
|
#define RENDERING_H
|
||||||
|
|
||||||
#include "cglm/affine.h"
|
#include "math3d.h"
|
||||||
#include "cglm/cglm.h"
|
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
#include "tier1/utlbuffer.h"
|
#include "tier1/utlbuffer.h"
|
||||||
#include "baseentity.h"
|
#include "baseentity.h"
|
||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
|
|
||||||
|
extern mat4 g_cameraView;
|
||||||
|
|
||||||
interface IVideo
|
interface IVideo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -11,4 +11,13 @@ public:
|
|||||||
static void UnloadGame( const char *psz );
|
static void UnloadGame( const char *psz );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CBasePlayer;
|
||||||
|
|
||||||
|
abstract_class IIClient
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
uint64_t playerID;
|
||||||
|
CBasePlayer *pBasePlayer;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,10 +1,19 @@
|
|||||||
#ifndef TIER0_STDLIB_H
|
#ifndef TIER0_STDLIB_H
|
||||||
#define TIER0_STDLIB_H
|
#define TIER0_STDLIB_H
|
||||||
|
|
||||||
|
#include "tier0/minmax.h"
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
|
#else
|
||||||
|
#include "stdint.h"
|
||||||
|
#include "string.h"
|
||||||
|
#include "stdio.h"
|
||||||
|
#include "stdlib.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// TODO: bad stuff, reimplement it
|
// TODO: bad stuff, reimplement it
|
||||||
|
|
||||||
|
|||||||
8
public/tier0/minmax.h
Normal file
8
public/tier0/minmax.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
#ifdef min
|
||||||
|
#undef min
|
||||||
|
#undef max
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define max(x, y) (((x) > (y)) ? (x) : (y))
|
||||||
|
#define min(x, y) (((x) < (y)) ? (x) : (y))
|
||||||
4
public/tier0/minmax_off.h
Normal file
4
public/tier0/minmax_off.h
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#ifdef min
|
||||||
|
#undef min
|
||||||
|
#undef max
|
||||||
|
#endif
|
||||||
@@ -5,7 +5,9 @@
|
|||||||
#include "tier0/mem.h"
|
#include "tier0/mem.h"
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
#include "tier0/lib.h"
|
#include "tier0/lib.h"
|
||||||
|
#include "tier0/minmax_off.h"
|
||||||
#include "new"
|
#include "new"
|
||||||
|
#include "tier0/minmax.h"
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class CUtlBuffer;
|
class CUtlBuffer;
|
||||||
@@ -161,7 +163,7 @@ public:
|
|||||||
|
|
||||||
size_t GetSize() const;
|
size_t GetSize() const;
|
||||||
size_t GetRealSize() const;
|
size_t GetRealSize() const;
|
||||||
void Resize( size_t nSize );
|
void Resize( size_t nSize, size_t nDataOffset = 0 );
|
||||||
void* GetMemory(void) const;
|
void* GetMemory(void) const;
|
||||||
|
|
||||||
operator T*( void ) const;
|
operator T*( void ) const;
|
||||||
@@ -248,7 +250,7 @@ size_t CUtlResizableBuffer<T>::GetRealSize( void ) const
|
|||||||
// Resizes memory.
|
// Resizes memory.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void CUtlResizableBuffer<T>::Resize( size_t nSize )
|
void CUtlResizableBuffer<T>::Resize( size_t nSize, size_t nDataOffset )
|
||||||
{
|
{
|
||||||
if (nSize > m_nAllocatedSize)
|
if (nSize > m_nAllocatedSize)
|
||||||
{
|
{
|
||||||
@@ -256,14 +258,14 @@ void CUtlResizableBuffer<T>::Resize( size_t nSize )
|
|||||||
T *pData = (T*)V_malloc(nAllocationSize*sizeof(T));
|
T *pData = (T*)V_malloc(nAllocationSize*sizeof(T));
|
||||||
for (size_t i = 0; i < m_nSize; i++)
|
for (size_t i = 0; i < m_nSize; i++)
|
||||||
{
|
{
|
||||||
new (&pData[i]) T(m_pData[i]);
|
new (&pData[i+nDataOffset]) T(m_pData[i]);
|
||||||
m_pData[i].~T();
|
m_pData[i].~T();
|
||||||
}
|
}
|
||||||
V_free(m_pData);
|
V_free(m_pData);
|
||||||
m_pData = pData;
|
m_pData = pData;
|
||||||
m_nAllocatedSize = nAllocationSize;
|
m_nAllocatedSize = nAllocationSize;
|
||||||
}
|
}
|
||||||
for ( size_t i = m_nSize; i < nSize; ++i )
|
for ( size_t i = m_nSize+nDataOffset; i < nSize; ++i )
|
||||||
new (&m_pData[i]) T();
|
new (&m_pData[i]) T();
|
||||||
m_nSize = nSize;
|
m_nSize = nSize;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ public:
|
|||||||
CUtlString( const CUtlString &sz );
|
CUtlString( const CUtlString &sz );
|
||||||
|
|
||||||
void AppendTail( const char *psz );
|
void AppendTail( const char *psz );
|
||||||
|
void AppendTail( char ch );
|
||||||
void AppendHead( const char *psz );
|
void AppendHead( const char *psz );
|
||||||
|
void AppendHead( char ch );
|
||||||
void AppendAt( size_t nPosition, const char *psz );
|
void AppendAt( size_t nPosition, const char *psz );
|
||||||
|
|
||||||
void RemoveTail( size_t nCount );
|
void RemoveTail( size_t nCount );
|
||||||
@@ -20,6 +22,7 @@ public:
|
|||||||
char *GetString( void );
|
char *GetString( void );
|
||||||
size_t GetLenght( void );
|
size_t GetLenght( void );
|
||||||
operator char*( void );
|
operator char*( void );
|
||||||
|
operator CUtlVector<char>&( void );
|
||||||
CUtlString& operator=(const CUtlString &sz);
|
CUtlString& operator=(const CUtlString &sz);
|
||||||
bool operator==(const char* psz);
|
bool operator==(const char* psz);
|
||||||
bool operator!=(const char* psz);
|
bool operator!=(const char* psz);
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ public:
|
|||||||
|
|
||||||
T *GetData( void );
|
T *GetData( void );
|
||||||
size_t GetSize( void );
|
size_t GetSize( void );
|
||||||
void Resize( size_t nSize );
|
void Resize( size_t nSize, size_t nDataOffset = 0 );
|
||||||
void Reserve( size_t nSize );
|
void Reserve( size_t nSize, size_t nDataOffset = 0 );
|
||||||
|
|
||||||
T &operator[]( size_t nIndex );
|
T &operator[]( size_t nIndex );
|
||||||
T &operator[]( size_t nIndex ) const;
|
T &operator[]( size_t nIndex ) const;
|
||||||
@@ -121,7 +121,11 @@ void CUtlVector<T>::AppendHead( const T &data )
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
void CUtlVector<T>::AppendHead( const T *pData, size_t n )
|
void CUtlVector<T>::AppendHead( const T *pData, size_t n )
|
||||||
{
|
{
|
||||||
|
size_t prevSize = m_data.GetSize();
|
||||||
|
m_data.Resize(prevSize+n, n);
|
||||||
|
for ( size_t i = 0; i < n; i++ )
|
||||||
|
new (&m_data[i]) T(pData[i]);
|
||||||
|
m_nSize+=n;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@@ -135,7 +139,7 @@ void CUtlVector<T>::AppendTail( const T *pData, size_t n )
|
|||||||
{
|
{
|
||||||
m_data.Resize(m_data.GetSize()+n);
|
m_data.Resize(m_data.GetSize()+n);
|
||||||
for ( size_t i = 0; i < n; i++ )
|
for ( size_t i = 0; i < n; i++ )
|
||||||
m_data[i+m_nSize] = pData[i];
|
new (&m_data[i+m_nSize]) T(pData[i]);
|
||||||
m_nSize+=n;
|
m_nSize+=n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,15 +184,15 @@ size_t CUtlVector<T>::GetSize( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void CUtlVector<T>::Resize( size_t nSize )
|
void CUtlVector<T>::Resize( size_t nSize, size_t nDataOffset )
|
||||||
{
|
{
|
||||||
m_data.Resize(nSize);
|
m_data.Resize(nSize, nDataOffset);
|
||||||
m_nSize = nSize;
|
m_nSize = nSize;
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void CUtlVector<T>::Reserve( size_t nSize )
|
void CUtlVector<T>::Reserve( size_t nSize, size_t nDataOffset )
|
||||||
{
|
{
|
||||||
m_data.Resize(nSize);
|
m_data.Resize(nSize, nDataOffset);
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
CUtlVector<T> &CUtlVector<T>::operator=(const CUtlVector<T> &vec)
|
CUtlVector<T> &CUtlVector<T>::operator=(const CUtlVector<T> &vec)
|
||||||
|
|||||||
26
rapier/px.rs
26
rapier/px.rs
@@ -147,11 +147,12 @@ pub struct px_rigidbody_params {
|
|||||||
dominance: i8,
|
dominance: i8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[unsafe(no_mangle)]
|
#[unsafe(no_mangle)]
|
||||||
pub unsafe extern "C" fn px_rigidbody(px_world: *mut funnyphysics, collider: *mut Collider, m:px_matrix,params:px_rigidbody_params) -> *mut RigidBodyHandle {
|
pub unsafe extern "C" fn px_kinematic_position_body(px_world: *mut funnyphysics, collider: *mut Collider, m:px_matrix,params:px_rigidbody_params) -> *mut RigidBodyHandle {
|
||||||
let c = &mut *collider;
|
let c = &mut *collider;
|
||||||
let px = px_world.as_mut().unwrap();
|
let px = px_world.as_mut().unwrap();
|
||||||
let rigid_body = RigidBodyBuilder::dynamic()
|
let rigid_body = RigidBodyBuilder::kinematic_position_based()
|
||||||
.translation(vector![m.m[12],m.m[13],m.m[14]])
|
.translation(vector![m.m[12],m.m[13],m.m[14]])
|
||||||
.can_sleep(false)
|
.can_sleep(false)
|
||||||
.gravity_scale(1.0)
|
.gravity_scale(1.0)
|
||||||
@@ -166,6 +167,27 @@ pub unsafe extern "C" fn px_rigidbody(px_world: *mut funnyphysics, collider: *mu
|
|||||||
|
|
||||||
Box::into_raw(Box::new(body))
|
Box::into_raw(Box::new(body))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[unsafe(no_mangle)]
|
||||||
|
pub unsafe extern "C" fn px_rigidbody(px_world: *mut funnyphysics, collider: *mut Collider, m:px_matrix,params:px_rigidbody_params) -> *mut RigidBodyHandle {
|
||||||
|
let c = &mut *collider;
|
||||||
|
let px = px_world.as_mut().unwrap();
|
||||||
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
|
.translation(vector![m.m[12],m.m[13],m.m[14]])
|
||||||
|
.can_sleep(false)
|
||||||
|
.gravity_scale(params.gravity_scale)
|
||||||
|
.enabled_rotations(params.lockrotx==0, params.lockroty==0, params.lockrotz==0)
|
||||||
|
.enabled_translations(params.lockposx==0, params.lockposy==0, params.lockposz==0)
|
||||||
|
.dominance_group(params.dominance)
|
||||||
|
.linear_damping(0.0)
|
||||||
|
.angular_damping(0.0)
|
||||||
|
.ccd_enabled(params.continous == 1)
|
||||||
|
.build();
|
||||||
|
let body = px.rigid_body_set.insert(rigid_body);
|
||||||
|
px.collider_set.insert_with_parent(c.clone(),body,&mut px.rigid_body_set);
|
||||||
|
|
||||||
|
Box::into_raw(Box::new(body))
|
||||||
|
}
|
||||||
#[unsafe(no_mangle)]
|
#[unsafe(no_mangle)]
|
||||||
pub unsafe extern "C" fn px_getposition(px_world: *mut funnyphysics, body: *mut RigidBodyHandle) -> px_vec3 {
|
pub unsafe extern "C" fn px_getposition(px_world: *mut funnyphysics, body: *mut RigidBodyHandle) -> px_vec3 {
|
||||||
let c = &mut *body;
|
let c = &mut *body;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ CUtlString::CUtlString( const char *szFormat, ... )
|
|||||||
m_data.Reserve(nSize + 1);
|
m_data.Reserve(nSize + 1);
|
||||||
va_end(vlArgs2);
|
va_end(vlArgs2);
|
||||||
V_vsnprintf(m_data.GetData(), nSize + 1, szFormat, vlArgs);
|
V_vsnprintf(m_data.GetData(), nSize + 1, szFormat, vlArgs);
|
||||||
m_data.Resize(nSize+1);
|
m_data.Resize(nSize + 1);
|
||||||
va_end(vlArgs);
|
va_end(vlArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,14 +34,26 @@ CUtlString::CUtlString( const CUtlString &sz )
|
|||||||
|
|
||||||
void CUtlString::AppendTail( const char *psz )
|
void CUtlString::AppendTail( const char *psz )
|
||||||
{
|
{
|
||||||
m_data.Resize(m_data.GetSize()-1);
|
m_data.Resize(V_strlen(m_data.GetData()));
|
||||||
m_data.AppendTail(psz,V_strlen(psz));
|
m_data.AppendTail(psz,V_strlen(psz));
|
||||||
m_data.Reserve(m_data.GetSize()+1);
|
m_data.Reserve(m_data.GetSize()+1);
|
||||||
m_data[m_data.GetSize()] = 0;
|
m_data[m_data.GetSize()] = 0;
|
||||||
}
|
}
|
||||||
void CUtlString::AppendHead( const char *psz )
|
void CUtlString::AppendHead( const char *psz )
|
||||||
{
|
{
|
||||||
|
m_data.AppendHead(psz,V_strlen(psz));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CUtlString::AppendTail( char ch )
|
||||||
|
{
|
||||||
|
m_data.Resize(V_strlen(m_data.GetData()));
|
||||||
|
m_data.AppendTail(ch);
|
||||||
|
m_data.Reserve(m_data.GetSize()+1);
|
||||||
|
m_data[m_data.GetSize()] = 0;
|
||||||
|
}
|
||||||
|
void CUtlString::AppendHead( char ch )
|
||||||
|
{
|
||||||
|
m_data.AppendHead(ch);
|
||||||
}
|
}
|
||||||
void CUtlString::AppendAt( size_t nPosition, const char *psz )
|
void CUtlString::AppendAt( size_t nPosition, const char *psz )
|
||||||
{
|
{
|
||||||
@@ -70,6 +82,10 @@ CUtlString::operator char*( void )
|
|||||||
{
|
{
|
||||||
return GetString();
|
return GetString();
|
||||||
}
|
}
|
||||||
|
CUtlString::operator CUtlVector<char>&( void )
|
||||||
|
{
|
||||||
|
return m_data;
|
||||||
|
}
|
||||||
|
|
||||||
CUtlString &CUtlString::operator=(const CUtlString &sz)
|
CUtlString &CUtlString::operator=(const CUtlString &sz)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ def export_my_format(filepath):
|
|||||||
if uv_layer:
|
if uv_layer:
|
||||||
uv = uv_layer[loop_index].uv
|
uv = uv_layer[loop_index].uv
|
||||||
f.write(f"({uv.x:.6f} {uv.y:.6f}) ")
|
f.write(f"({uv.x:.6f} {uv.y:.6f}) ")
|
||||||
f.write(f"BRICK0\n");
|
f.write(f"BRICK1\n");
|
||||||
f.write("}\n")
|
f.write("}\n")
|
||||||
f.write("}\n")
|
f.write("}\n")
|
||||||
for obj in bpy.context.scene.objects:
|
for obj in bpy.context.scene.objects:
|
||||||
|
|||||||
Reference in New Issue
Block a user