Started work on build system
This commit is contained in:
@@ -8,16 +8,11 @@
|
||||
class CBaseEntity;
|
||||
class C_BaseEntity;
|
||||
|
||||
struct Triangle_t
|
||||
{
|
||||
float location[9];
|
||||
float uv[6];
|
||||
float normal[9];
|
||||
uint32_t texture;
|
||||
};
|
||||
|
||||
/* server entities */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Base server entity class.
|
||||
// It is updated every 1/tickrate (64) of a second. Does not require special
|
||||
// classes to exist.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBaseEntity
|
||||
{
|
||||
public:
|
||||
@@ -25,10 +20,18 @@ public:
|
||||
virtual void Precache() = 0;
|
||||
virtual void Spawn( void ) = 0;
|
||||
virtual void Destroy( void ) = 0;
|
||||
virtual void ReadParameter( const char *szName, const char *szValue );
|
||||
virtual void Think( float fDelta ) = 0;
|
||||
void SetPosition( vec3 position );
|
||||
void SetRotationEuler( vec3 euler );
|
||||
void SetRotationQuat( vec4 quaternion );
|
||||
void SetRotationMatrix( mat3 matrix );
|
||||
void SetScale( vec3 scale );
|
||||
|
||||
C_BaseEntity *pClientEntity;
|
||||
mat4 m_matrix;
|
||||
mat3 m_matrix;
|
||||
vec3 m_position;
|
||||
vec3 m_scale;
|
||||
};
|
||||
|
||||
|
||||
@@ -55,9 +58,12 @@ CBaseEntity *__entity_alloc_##name() \
|
||||
}; \
|
||||
CEntityRegistry __entity_##name##_registry(#name, #class, __entity_alloc_##name); \
|
||||
|
||||
/* client entities */
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Base client entity class.
|
||||
// It recieves pure server data, which has to be interpolated by the client to
|
||||
// get smoother image.
|
||||
//-----------------------------------------------------------------------------
|
||||
class C_BaseEntity
|
||||
{
|
||||
public:
|
||||
@@ -66,7 +72,6 @@ public:
|
||||
virtual void Precache() = 0;
|
||||
virtual void Spawn( void ) = 0;
|
||||
virtual void Destroy( void ) = 0;
|
||||
/* happens every frame instead of tick */
|
||||
virtual void Think( float fDelta ) = 0;
|
||||
private:
|
||||
};
|
||||
@@ -77,6 +82,10 @@ public:
|
||||
C_EntityRegistry( const char *pName, ClientEntityRegistryFn pfn );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Server-Client sync for entities. When new server entity is created, client
|
||||
// entity gets created as well.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define LINK_CLIENT_ENTITY(client, server) \
|
||||
C_BaseEntity *__c_entity_alloc_##server() \
|
||||
{ \
|
||||
|
||||
@@ -6,11 +6,29 @@
|
||||
#include "baseentity.h"
|
||||
#include "physics.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Basic triangle structure which is used in brush entities.
|
||||
//-----------------------------------------------------------------------------
|
||||
struct Triangle_t
|
||||
{
|
||||
float location[9];
|
||||
float uv[6];
|
||||
float normal[9];
|
||||
uint32_t texture;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Basic brush entity which has its own geometry defined.
|
||||
// They have constant position, shape, and rotation, so it makes them
|
||||
// non-interactable with the game world in terms of ability to modify it at
|
||||
// runtime. Collisions are precise.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBrushEntity: 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;
|
||||
|
||||
@@ -19,6 +37,9 @@ public:
|
||||
RigidBodyHandle *m_body;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Client rendering for brush entitites.
|
||||
//-----------------------------------------------------------------------------
|
||||
class C_BrushEntity: public C_BaseEntity
|
||||
{
|
||||
public:
|
||||
@@ -29,7 +50,7 @@ public:
|
||||
private:
|
||||
IVertexBuffer *vertexBuffer;
|
||||
IIndexBuffer *indexBuffer;
|
||||
IBrush *mesh;
|
||||
IMesh *mesh;
|
||||
IMaterial material;
|
||||
ITexture *pAlbedo;
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "tier1/utlstring.h"
|
||||
#include "engine.h"
|
||||
|
||||
|
||||
enum EFileOptions
|
||||
{
|
||||
IFILE_READ,
|
||||
|
||||
@@ -79,28 +79,6 @@ public:
|
||||
static void SetMaterial( IMaterial *pMaterial );
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Brush handler for the rendering
|
||||
//----------------------------------------------------------------------------
|
||||
abstract_class IBrush
|
||||
{
|
||||
public:
|
||||
virtual void SetVertexBuffer( IVertexBuffer *pBuffer ) = 0;
|
||||
virtual void SetIndexBuffer( IIndexBuffer *pBuffer ) = 0;
|
||||
virtual void Draw() = 0;
|
||||
};
|
||||
|
||||
interface IBrushRenderer
|
||||
{
|
||||
public:
|
||||
static void Init();
|
||||
static void Frame( float fDelta );
|
||||
|
||||
static IBrush *CreateMesh();
|
||||
static void Destroy( IBrush *pModel );
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Mesh handler for the rendering
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -125,7 +103,7 @@ public:
|
||||
static void Frame( float fDelta );
|
||||
|
||||
static IMesh *CreateMesh();
|
||||
static void Destroy( IBrush *pModel );
|
||||
static void Destroy( IMesh *pModel );
|
||||
};
|
||||
|
||||
abstract_class ITexture
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
#define V_putchar putchar
|
||||
#define V_fputchar fputchar
|
||||
#define V_scanf scanf
|
||||
#define V_sscanf sscanf
|
||||
#define V_vscanf vscanf
|
||||
#define V_fscanf fscanf
|
||||
#define V_vfscanf vfscanf
|
||||
|
||||
1
public/tier1/ban_std.h
Normal file
1
public/tier1/ban_std.h
Normal file
@@ -0,0 +1 @@
|
||||
#define std no_you_do_not_use_std
|
||||
1
public/tier1/unban_std.h
Normal file
1
public/tier1/unban_std.h
Normal file
@@ -0,0 +1 @@
|
||||
#undef std
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
CUtlBuffer( const CUtlResizableBuffer<T>& buffer );
|
||||
|
||||
size_t GetSize( void ) const;
|
||||
void* GetMemory(void) const;
|
||||
T* GetMemory(void) const;
|
||||
|
||||
operator T*( void ) const;
|
||||
T& operator []( const size_t nIndex );
|
||||
@@ -89,7 +89,7 @@ size_t CUtlBuffer<T>::GetSize( void ) const
|
||||
// Gets memory address.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void* CUtlBuffer<T>::GetMemory( void ) const
|
||||
T* CUtlBuffer<T>::GetMemory( void ) const
|
||||
{
|
||||
return m_pData;
|
||||
}
|
||||
@@ -110,10 +110,10 @@ template <typename T>
|
||||
T& CUtlBuffer<T>::operator []( const size_t nIndex )
|
||||
{
|
||||
if ( m_pData == 0)
|
||||
Plat_FatalErrorFunc("Buffer was not initialized");
|
||||
Plat_FatalErrorFunc("Buffer was not initialized\n");
|
||||
|
||||
if ( nIndex >= m_nSize )
|
||||
Plat_FatalErrorFunc("Out of bounds indexing: size is %lu and index is %lu", m_nSize/sizeof(T), nIndex);
|
||||
Plat_FatalErrorFunc("Out of bounds indexing: size is %lu and index is %lu\n", m_nSize/sizeof(T), nIndex);
|
||||
|
||||
return m_pData[nIndex];
|
||||
}
|
||||
@@ -125,7 +125,7 @@ template <typename T>
|
||||
T CUtlBuffer<T>::operator []( const size_t nIndex ) const
|
||||
{
|
||||
if ( nIndex >= m_nSize )
|
||||
Plat_FatalErrorFunc("Out of bounds indexing: size is %lu and index is %lu",m_nSize, nIndex);
|
||||
Plat_FatalErrorFunc("Out of bounds indexing: size is %lu and index is %lu\n",m_nSize, nIndex);
|
||||
return m_pData[nIndex];
|
||||
}
|
||||
|
||||
@@ -293,10 +293,10 @@ template <typename T>
|
||||
T& CUtlResizableBuffer<T>::operator []( const size_t nIndex )
|
||||
{
|
||||
if ( m_pData == 0)
|
||||
Plat_FatalErrorFunc("Buffer was not initialized");
|
||||
Plat_FatalErrorFunc("Buffer was not initialized\n");
|
||||
|
||||
if ( nIndex >= m_nSize )
|
||||
Plat_FatalErrorFunc("Out of bounds indexing: size is %lu and index is %lu",m_nSize, nIndex);
|
||||
Plat_FatalErrorFunc("Out of bounds indexing: size is %lu and index is %lu\n",m_nSize, nIndex);
|
||||
|
||||
return m_pData[nIndex];
|
||||
}
|
||||
@@ -308,7 +308,7 @@ template <typename T>
|
||||
T CUtlResizableBuffer<T>::operator []( const size_t nIndex ) const
|
||||
{
|
||||
if ( nIndex >= m_nSize )
|
||||
Plat_FatalErrorFunc("Out of bounds indexing: size is %lu and index is %lu",m_nSize, nIndex);
|
||||
Plat_FatalErrorFunc("Out of bounds indexing: size is %lu and index is %lu\n",m_nSize, nIndex);
|
||||
return m_pData[nIndex];
|
||||
}
|
||||
|
||||
|
||||
19
public/tier1/utlinitlist.h
Normal file
19
public/tier1/utlinitlist.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef TIER1_UTL_INITIALIZER_LIST_H
|
||||
#define TIER1_UTL_INITIALIZER_LIST_H
|
||||
//-----------------------------------------------------------------------------
|
||||
// C++ only supports std::initializer_list. Because of that we are dependent
|
||||
// on libc++. That's why I banned usage of the std.
|
||||
//
|
||||
// fuck C++ once
|
||||
// fuck C++ twice
|
||||
// fuck C++ thrice
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "unban_std.h"
|
||||
|
||||
#include "initializer_list"
|
||||
template<typename T>
|
||||
using CUtlInitializerList = std::initializer_list<T>;
|
||||
|
||||
#include "ban_std.h"
|
||||
|
||||
#endif
|
||||
@@ -6,7 +6,8 @@
|
||||
class CUtlString {
|
||||
public:
|
||||
CUtlString( void );
|
||||
CUtlString( const char *psz, ... );
|
||||
CUtlString( const char *psz, ... );
|
||||
CUtlString( const CUtlString &sz );
|
||||
|
||||
void AppendTail( const char *psz );
|
||||
void AppendHead( const char *psz );
|
||||
@@ -19,6 +20,7 @@ public:
|
||||
char *GetString( void );
|
||||
size_t GetLenght( void );
|
||||
operator char*( void );
|
||||
CUtlString& operator=(const CUtlString &sz);
|
||||
bool operator==(const char* psz);
|
||||
bool operator!=(const char* psz);
|
||||
bool operator==(CUtlString& string);
|
||||
@@ -27,4 +29,4 @@ private:
|
||||
CUtlVector<char> m_data;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
#include "tier1/utlbuffer.h"
|
||||
#include "tier0/lib.h"
|
||||
|
||||
#include "tier1/utlinitlist.h"
|
||||
#include <initializer_list>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Basic vector implementation. There isn't much in them.
|
||||
@@ -14,6 +15,9 @@ class CUtlVector
|
||||
public:
|
||||
CUtlVector( void );
|
||||
CUtlVector( size_t nSize );
|
||||
CUtlVector( CUtlInitializerList<T> initalizerList );
|
||||
CUtlVector( const CUtlVector &vector );
|
||||
~CUtlVector();
|
||||
|
||||
void AppendHead( const T &data );
|
||||
void AppendHead( const T *pData, size_t n );
|
||||
@@ -33,6 +37,7 @@ public:
|
||||
|
||||
T &operator[]( size_t nIndex );
|
||||
T &operator[]( size_t nIndex ) const;
|
||||
CUtlVector<T> &operator=(const CUtlVector<T> &vec);
|
||||
|
||||
// Iterator stuff
|
||||
struct Iterator {
|
||||
@@ -83,6 +88,29 @@ CUtlVector<T>::CUtlVector( size_t nSize )
|
||||
m_nSize = nSize;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Fancy constructor
|
||||
//----------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
CUtlVector<T>::CUtlVector( CUtlInitializerList<T> initalizerList )
|
||||
{
|
||||
m_data.Resize(initalizerList.size());
|
||||
m_nSize = m_data.GetSize();
|
||||
V_memcpy(m_data.GetMemory(), initalizerList.begin(), m_data.GetSize()*sizeof(T));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
CUtlVector<T>::CUtlVector( const CUtlVector& vector )
|
||||
{
|
||||
m_data = vector.m_data;
|
||||
}
|
||||
template<typename T>
|
||||
CUtlVector<T>::~CUtlVector()
|
||||
{
|
||||
for ( uint32_t i = 0; i < m_nSize; i++ )
|
||||
m_data[i].~T();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CUtlVector<T>::AppendHead( const T &data )
|
||||
{
|
||||
@@ -159,6 +187,18 @@ void CUtlVector<T>::Reserve( size_t nSize )
|
||||
{
|
||||
m_data.Resize(nSize);
|
||||
}
|
||||
template<typename T>
|
||||
CUtlVector<T> &CUtlVector<T>::operator=(const CUtlVector<T> &vec)
|
||||
{
|
||||
if (this != &vec)
|
||||
{
|
||||
m_nSize = vec.m_nSize;
|
||||
m_data.Resize(m_nSize);
|
||||
for ( uint32_t i = 0; i < m_nSize; i++ )
|
||||
m_data[i] = vec.m_data[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T &CUtlVector<T>::operator[]( size_t nIndex )
|
||||
|
||||
@@ -34,7 +34,8 @@ struct vk_tripipeline_t
|
||||
void Create(
|
||||
CUtlVector<vk_shader_t> &shaders,
|
||||
CUtlVector<VkDescriptorSetLayoutBinding> &bindings,
|
||||
uint32_t pushConstantsSize
|
||||
uint32_t pushConstantsSize,
|
||||
CUtlVector<VkFormat> formats
|
||||
/* the rest of the stuff is set by the dynamic state */
|
||||
/* literally */
|
||||
);
|
||||
@@ -69,7 +70,7 @@ struct vk_buffer_t
|
||||
|
||||
struct vk_image2d_t
|
||||
{
|
||||
void Create(size_t x, size_t y, VkFormat format, VkImageUsageFlags usage);
|
||||
void Create(size_t x, size_t y, VkFormat format, VkImageUsageFlags usage, VkSampleCountFlagBits samples);
|
||||
void Destroy();
|
||||
|
||||
void CopyTo(struct vk_image2d_t *image);
|
||||
|
||||
Reference in New Issue
Block a user