Fixed bitbuf compilation
This commit is contained in:
parent
cd6badfe1f
commit
9834880bc5
@ -7,11 +7,8 @@
|
|||||||
//=============================================================================//
|
//=============================================================================//
|
||||||
|
|
||||||
#include "bitbuf.h"
|
#include "bitbuf.h"
|
||||||
#include "coordsize.h"
|
#include <string.h>
|
||||||
#include "mathlib/vector.h"
|
#include <math.h>
|
||||||
#include "mathlib/mathlib.h"
|
|
||||||
#include "tier1/strtools.h"
|
|
||||||
#include "bitvec.h"
|
|
||||||
|
|
||||||
// FIXME: Can't use this until we get multithreaded allocations in tier0 working for tools
|
// FIXME: Can't use this until we get multithreaded allocations in tier0 working for tools
|
||||||
// This is used by VVIS and fails to link
|
// This is used by VVIS and fails to link
|
||||||
@ -476,7 +473,7 @@ bool bf_write::WriteBits(const void *pInData, int nBits)
|
|||||||
int numbytes = nBitsLeft >> 3;
|
int numbytes = nBitsLeft >> 3;
|
||||||
int numbits = numbytes << 3;
|
int numbits = numbytes << 3;
|
||||||
|
|
||||||
Q_memcpy( (char*)m_pData+(m_iCurBit>>3), pOut, numbytes );
|
memcpy( (char*)m_pData+(m_iCurBit>>3), pOut, numbytes );
|
||||||
pOut += numbytes;
|
pOut += numbytes;
|
||||||
nBitsLeft -= numbits;
|
nBitsLeft -= numbits;
|
||||||
m_iCurBit += numbits;
|
m_iCurBit += numbits;
|
||||||
@ -1446,7 +1443,7 @@ void bf_read::ExciseBits( int startbit, int bitstoremove )
|
|||||||
m_nDataBytes = m_nDataBits >> 3;
|
m_nDataBytes = m_nDataBits >> 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bf_read::CompareBitsAt( int offset, bf_read * RESTRICT other, int otherOffset, int numbits ) RESTRICT
|
int bf_read::CompareBitsAt( int offset, bf_read * __restrict other, int otherOffset, int numbits ) __restrict
|
||||||
{
|
{
|
||||||
extern unsigned long g_ExtraMasks[33];
|
extern unsigned long g_ExtraMasks[33];
|
||||||
|
|
@ -8,25 +8,9 @@
|
|||||||
|
|
||||||
// NOTE: bf_read is guaranteed to return zeros if it overflows.
|
// NOTE: bf_read is guaranteed to return zeros if it overflows.
|
||||||
|
|
||||||
#ifndef BITBUF_H
|
|
||||||
#define BITBUF_H
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#include "valve_support.h"
|
||||||
#include "mathlib/mathlib.h"
|
|
||||||
#include "mathlib/vector.h"
|
|
||||||
#include "basetypes.h"
|
|
||||||
#include "tier0/dbg.h"
|
|
||||||
|
|
||||||
|
|
||||||
#if _DEBUG
|
|
||||||
#define BITBUF_INLINE inline
|
|
||||||
#else
|
|
||||||
#define BITBUF_INLINE FORCEINLINE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Forward declarations.
|
// Forward declarations.
|
||||||
@ -255,7 +239,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// The current buffer.
|
// The current buffer.
|
||||||
unsigned long* RESTRICT m_pData;
|
unsigned long* __restrict m_pData;
|
||||||
int m_nDataBytes;
|
int m_nDataBytes;
|
||||||
int m_nDataBits;
|
int m_nDataBits;
|
||||||
|
|
||||||
@ -312,7 +296,7 @@ inline const unsigned char* bf_write::GetData() const
|
|||||||
return (unsigned char*) m_pData;
|
return (unsigned char*) m_pData;
|
||||||
}
|
}
|
||||||
|
|
||||||
BITBUF_INLINE bool bf_write::CheckForOverflow(int nBits)
|
inline bool bf_write::CheckForOverflow(int nBits)
|
||||||
{
|
{
|
||||||
if ( m_iCurBit + nBits > m_nDataBits )
|
if ( m_iCurBit + nBits > m_nDataBits )
|
||||||
{
|
{
|
||||||
@ -323,7 +307,7 @@ BITBUF_INLINE bool bf_write::CheckForOverflow(int nBits)
|
|||||||
return m_bOverflow;
|
return m_bOverflow;
|
||||||
}
|
}
|
||||||
|
|
||||||
BITBUF_INLINE void bf_write::SetOverflowFlag()
|
inline void bf_write::SetOverflowFlag()
|
||||||
{
|
{
|
||||||
#ifdef DBGFLAG_ASSERT
|
#ifdef DBGFLAG_ASSERT
|
||||||
if ( m_bAssertOnOverflow )
|
if ( m_bAssertOnOverflow )
|
||||||
@ -334,7 +318,7 @@ BITBUF_INLINE void bf_write::SetOverflowFlag()
|
|||||||
m_bOverflow = true;
|
m_bOverflow = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BITBUF_INLINE void bf_write::WriteOneBitNoCheck(int nValue)
|
inline void bf_write::WriteOneBitNoCheck(int nValue)
|
||||||
{
|
{
|
||||||
#if __i386__
|
#if __i386__
|
||||||
if(nValue)
|
if(nValue)
|
||||||
@ -387,7 +371,7 @@ inline void bf_write::WriteOneBitAt( int iBit, int nValue )
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
BITBUF_INLINE void bf_write::WriteUBitLong( unsigned int curData, int numbits, bool bCheckRange ) RESTRICT
|
inline void bf_write::WriteUBitLong( unsigned int curData, int numbits, bool bCheckRange ) __restrict
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
// Make sure it doesn't overflow.
|
// Make sure it doesn't overflow.
|
||||||
@ -414,8 +398,8 @@ BITBUF_INLINE void bf_write::WriteUBitLong( unsigned int curData, int numbits, b
|
|||||||
m_iCurBit += numbits;
|
m_iCurBit += numbits;
|
||||||
|
|
||||||
// Mask in a dword.
|
// Mask in a dword.
|
||||||
Assert( (iDWord*4 + sizeof(long)) <= (unsigned int)m_nDataBytes );
|
assert( (iDWord*4 + sizeof(long)) <= (unsigned int)m_nDataBytes );
|
||||||
unsigned long * RESTRICT pOut = &m_pData[iDWord];
|
unsigned long * __restrict pOut = &m_pData[iDWord];
|
||||||
|
|
||||||
// Rotate data into dword alignment
|
// Rotate data into dword alignment
|
||||||
curData = (curData << iCurBitMasked) | (curData >> (32 - iCurBitMasked));
|
curData = (curData << iCurBitMasked) | (curData >> (32 - iCurBitMasked));
|
||||||
@ -440,7 +424,7 @@ BITBUF_INLINE void bf_write::WriteUBitLong( unsigned int curData, int numbits, b
|
|||||||
}
|
}
|
||||||
|
|
||||||
// writes an unsigned integer with variable bit length
|
// writes an unsigned integer with variable bit length
|
||||||
BITBUF_INLINE void bf_write::WriteUBitVar( unsigned int data )
|
inline void bf_write::WriteUBitVar( unsigned int data )
|
||||||
{
|
{
|
||||||
/* Reference:
|
/* Reference:
|
||||||
if ( data < 0x10u )
|
if ( data < 0x10u )
|
||||||
@ -463,7 +447,7 @@ BITBUF_INLINE void bf_write::WriteUBitVar( unsigned int data )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// write raw IEEE float bits in little endian form
|
// write raw IEEE float bits in little endian form
|
||||||
BITBUF_INLINE void bf_write::WriteBitFloat(float val)
|
inline void bf_write::WriteBitFloat(float val)
|
||||||
{
|
{
|
||||||
long intVal;
|
long intVal;
|
||||||
|
|
||||||
@ -542,7 +526,7 @@ public:
|
|||||||
// Get the base pointer.
|
// Get the base pointer.
|
||||||
const unsigned char* GetBasePointer() { return m_pData; }
|
const unsigned char* GetBasePointer() { return m_pData; }
|
||||||
|
|
||||||
BITBUF_INLINE int TotalBytesAvailable( void ) const
|
inline int TotalBytesAvailable( void ) const
|
||||||
{
|
{
|
||||||
return m_nDataBytes;
|
return m_nDataBytes;
|
||||||
}
|
}
|
||||||
@ -565,8 +549,8 @@ public:
|
|||||||
|
|
||||||
float ReadBitAngle( int numbits );
|
float ReadBitAngle( int numbits );
|
||||||
|
|
||||||
unsigned int ReadUBitLong( int numbits ) RESTRICT;
|
unsigned int ReadUBitLong( int numbits ) __restrict;
|
||||||
unsigned int ReadUBitLongNoInline( int numbits ) RESTRICT;
|
unsigned int ReadUBitLongNoInline( int numbits ) __restrict;
|
||||||
unsigned int PeekUBitLong( int numbits );
|
unsigned int PeekUBitLong( int numbits );
|
||||||
int ReadSBitLong( int numbits );
|
int ReadSBitLong( int numbits );
|
||||||
|
|
||||||
@ -599,11 +583,11 @@ public:
|
|||||||
// Byte functions (these still read data in bit-by-bit).
|
// Byte functions (these still read data in bit-by-bit).
|
||||||
public:
|
public:
|
||||||
|
|
||||||
BITBUF_INLINE int ReadChar() { return (char)ReadUBitLong(8); }
|
inline int ReadChar() { return (char)ReadUBitLong(8); }
|
||||||
BITBUF_INLINE int ReadByte() { return ReadUBitLong(8); }
|
inline int ReadByte() { return ReadUBitLong(8); }
|
||||||
BITBUF_INLINE int ReadShort() { return (short)ReadUBitLong(16); }
|
inline int ReadShort() { return (short)ReadUBitLong(16); }
|
||||||
BITBUF_INLINE int ReadWord() { return ReadUBitLong(16); }
|
inline int ReadWord() { return ReadUBitLong(16); }
|
||||||
BITBUF_INLINE long ReadLong() { return ReadUBitLong(32); }
|
inline long ReadLong() { return ReadUBitLong(32); }
|
||||||
int64 ReadLongLong();
|
int64 ReadLongLong();
|
||||||
float ReadFloat();
|
float ReadFloat();
|
||||||
bool ReadBytes(void *pOut, int nBytes);
|
bool ReadBytes(void *pOut, int nBytes);
|
||||||
@ -628,8 +612,8 @@ public:
|
|||||||
char* ReadAndAllocateString( bool *pOverflow = 0 );
|
char* ReadAndAllocateString( bool *pOverflow = 0 );
|
||||||
|
|
||||||
// Returns nonzero if any bits differ
|
// Returns nonzero if any bits differ
|
||||||
int CompareBits( bf_read * RESTRICT other, int bits ) RESTRICT;
|
int CompareBits( bf_read * __restrict other, int bits ) __restrict;
|
||||||
int CompareBitsAt( int offset, bf_read * RESTRICT other, int otherOffset, int bits ) RESTRICT;
|
int CompareBitsAt( int offset, bf_read * __restrict other, int otherOffset, int bits ) __restrict;
|
||||||
|
|
||||||
// Status.
|
// Status.
|
||||||
public:
|
public:
|
||||||
@ -651,7 +635,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
// The current buffer.
|
// The current buffer.
|
||||||
const unsigned char* RESTRICT m_pData;
|
const unsigned char* __restrict m_pData;
|
||||||
int m_nDataBytes;
|
int m_nDataBytes;
|
||||||
int m_nDataBits;
|
int m_nDataBits;
|
||||||
|
|
||||||
@ -727,13 +711,19 @@ inline bool bf_read::CheckForOverflow(int nBits)
|
|||||||
|
|
||||||
inline int bf_read::ReadOneBitNoCheck()
|
inline int bf_read::ReadOneBitNoCheck()
|
||||||
{
|
{
|
||||||
#if VALVE_LITTLE_ENDIAN
|
int ret;
|
||||||
unsigned int value = ((unsigned long * RESTRICT)m_pData)[m_iCurBit >> 5] >> (m_iCurBit & 31);
|
if (is_little_endian())
|
||||||
#else
|
{
|
||||||
|
unsigned int value = ((unsigned long * __restrict)m_pData)[m_iCurBit >> 5] >> (m_iCurBit & 31);
|
||||||
|
ret = value & 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
unsigned char value = m_pData[m_iCurBit >> 3] >> (m_iCurBit & 7);
|
unsigned char value = m_pData[m_iCurBit >> 3] >> (m_iCurBit & 7);
|
||||||
#endif
|
ret = value & 1;
|
||||||
|
}
|
||||||
++m_iCurBit;
|
++m_iCurBit;
|
||||||
return value & 1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int bf_read::ReadOneBit()
|
inline int bf_read::ReadOneBit()
|
||||||
@ -753,7 +743,7 @@ inline float bf_read::ReadBitFloat()
|
|||||||
return c.f;
|
return c.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
BITBUF_INLINE unsigned int bf_read::ReadUBitVar()
|
inline unsigned int bf_read::ReadUBitVar()
|
||||||
{
|
{
|
||||||
// six bits: low 2 bits for encoding + first 4 bits of value
|
// six bits: low 2 bits for encoding + first 4 bits of value
|
||||||
unsigned int sixbits = ReadUBitLong(6);
|
unsigned int sixbits = ReadUBitLong(6);
|
||||||
@ -766,7 +756,7 @@ BITBUF_INLINE unsigned int bf_read::ReadUBitVar()
|
|||||||
return sixbits >> 2;
|
return sixbits >> 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
BITBUF_INLINE unsigned int bf_read::ReadUBitLong( int numbits ) RESTRICT
|
inline unsigned int bf_read::ReadUBitLong( int numbits ) __restrict
|
||||||
{
|
{
|
||||||
Assert( numbits > 0 && numbits <= 32 );
|
Assert( numbits > 0 && numbits <= 32 );
|
||||||
|
|
||||||
@ -791,19 +781,14 @@ BITBUF_INLINE unsigned int bf_read::ReadUBitLong( int numbits ) RESTRICT
|
|||||||
unsigned int bitmask = g_ExtraMasks[numbits];
|
unsigned int bitmask = g_ExtraMasks[numbits];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned int dw1 = LoadLittleDWord( (unsigned long* RESTRICT)m_pData, iWordOffset1 ) >> iStartBit;
|
unsigned int dw1 = LoadLittleDWord( (unsigned long* __restrict)m_pData, iWordOffset1 ) >> iStartBit;
|
||||||
unsigned int dw2 = LoadLittleDWord( (unsigned long* RESTRICT)m_pData, iWordOffset2 ) << (32 - iStartBit);
|
unsigned int dw2 = LoadLittleDWord( (unsigned long* __restrict)m_pData, iWordOffset2 ) << (32 - iStartBit);
|
||||||
|
|
||||||
return (dw1 | dw2) & bitmask;
|
return (dw1 | dw2) & bitmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
BITBUF_INLINE int bf_read::CompareBits( bf_read * RESTRICT other, int numbits ) RESTRICT
|
inline int bf_read::CompareBits( bf_read * __restrict other, int numbits ) __restrict
|
||||||
{
|
{
|
||||||
return (ReadUBitLong(numbits) != other->ReadUBitLong(numbits));
|
return (ReadUBitLong(numbits) != other->ReadUBitLong(numbits));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
158
external/sourcesdk/valve_support.h
vendored
Normal file
158
external/sourcesdk/valve_support.h
vendored
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cassert>
|
||||||
|
#include "vector.h"
|
||||||
|
|
||||||
|
using uint64 = std::uint64_t;
|
||||||
|
using uint32 = std::uint32_t;
|
||||||
|
using uint16 = std::uint16_t;
|
||||||
|
using uint8 = std::uint8_t;
|
||||||
|
using int64 = std::int64_t;
|
||||||
|
using int32 = std::int32_t;
|
||||||
|
using int16 = std::int16_t;
|
||||||
|
using int8 = std::int8_t;
|
||||||
|
using uint = unsigned int;
|
||||||
|
using byte = char;
|
||||||
|
|
||||||
|
#if defined(_M_IX86)
|
||||||
|
#define __i386__ 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define IsPC() true
|
||||||
|
#ifdef _WIN64
|
||||||
|
#define PLATFORM_WINDOWS_PC64 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define NULL nullptr
|
||||||
|
|
||||||
|
#define Assert(x) assert(x)
|
||||||
|
#define AssertMsg(x, ...) assert(x)
|
||||||
|
#define AssertMsg2(x, ...) assert(x)
|
||||||
|
#define AssertFatalMsg(x, ...) assert(x)
|
||||||
|
|
||||||
|
#define Q_memcpy memcpy
|
||||||
|
|
||||||
|
bool is_little_endian()
|
||||||
|
{
|
||||||
|
union {
|
||||||
|
uint32 i;
|
||||||
|
uint8 c[4];
|
||||||
|
} bint = { 0x01020304 };
|
||||||
|
|
||||||
|
return bint.c[0] == 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// OVERALL Coordinate Size Limits used in COMMON.C MSG_*BitCoord() Routines (and someday the HUD)
|
||||||
|
#define COORD_INTEGER_BITS 14
|
||||||
|
#define COORD_FRACTIONAL_BITS 5
|
||||||
|
#define COORD_DENOMINATOR (1<<(COORD_FRACTIONAL_BITS))
|
||||||
|
#define COORD_RESOLUTION (1.0/(COORD_DENOMINATOR))
|
||||||
|
|
||||||
|
// Special threshold for networking multiplayer origins
|
||||||
|
#define COORD_INTEGER_BITS_MP 11
|
||||||
|
#define COORD_FRACTIONAL_BITS_MP_LOWPRECISION 3
|
||||||
|
#define COORD_DENOMINATOR_LOWPRECISION (1<<(COORD_FRACTIONAL_BITS_MP_LOWPRECISION))
|
||||||
|
#define COORD_RESOLUTION_LOWPRECISION (1.0/(COORD_DENOMINATOR_LOWPRECISION))
|
||||||
|
|
||||||
|
#define NORMAL_FRACTIONAL_BITS 11
|
||||||
|
#define NORMAL_DENOMINATOR ( (1<<(NORMAL_FRACTIONAL_BITS)) - 1 )
|
||||||
|
#define NORMAL_RESOLUTION (1.0/(NORMAL_DENOMINATOR))
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline T DWordSwapC( T dw )
|
||||||
|
{
|
||||||
|
uint32 temp;
|
||||||
|
temp = *((uint32 *)&dw) >> 24;
|
||||||
|
temp |= ((*((uint32 *)&dw) & 0x00FF0000) >> 8);
|
||||||
|
temp |= ((*((uint32 *)&dw) & 0x0000FF00) << 8);
|
||||||
|
temp |= ((*((uint32 *)&dw) & 0x000000FF) << 24);
|
||||||
|
return *((T*)&temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined( _MSC_VER ) && !defined( PLATFORM_WINDOWS_PC64 )
|
||||||
|
#define DWordSwap DWordSwapAsm
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning (disable:4035) // no return value
|
||||||
|
template <typename T>
|
||||||
|
inline T DWordSwapAsm( T dw )
|
||||||
|
{
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov eax, dw
|
||||||
|
bswap eax
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#pragma warning(pop)
|
||||||
|
#else
|
||||||
|
#define DWordSwap DWordSwapC
|
||||||
|
#endif
|
||||||
|
|
||||||
|
inline unsigned long LoadLittleDWord(const unsigned long *base, unsigned int dwordIndex)
|
||||||
|
{
|
||||||
|
return (is_little_endian() ? base[dwordIndex] : (DWordSwap(base[dwordIndex])));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void StoreLittleDWord(unsigned long *base, unsigned int dwordIndex, unsigned long dword)
|
||||||
|
{
|
||||||
|
base[dwordIndex] = (is_little_endian() ? dword : (DWordSwap(dword)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// If a swapped float passes through the fpu, the bytes may get changed.
|
||||||
|
// Prevent this by swapping floats as DWORDs.
|
||||||
|
#define SafeSwapFloat( pOut, pIn ) (*((uint*)pOut) = DWordSwap( *((uint*)pIn) ))
|
||||||
|
|
||||||
|
inline void LittleFloat(float* pOut, float* pIn)
|
||||||
|
{
|
||||||
|
if (is_little_endian())
|
||||||
|
{
|
||||||
|
*pOut = *pIn;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SafeSwapFloat(pOut, pIn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define BITS_PER_INT 32
|
||||||
|
|
||||||
|
inline int GetBitForBitnum( int bitNum )
|
||||||
|
{
|
||||||
|
static int bitsForBitnum[] =
|
||||||
|
{
|
||||||
|
( 1 << 0 ),
|
||||||
|
( 1 << 1 ),
|
||||||
|
( 1 << 2 ),
|
||||||
|
( 1 << 3 ),
|
||||||
|
( 1 << 4 ),
|
||||||
|
( 1 << 5 ),
|
||||||
|
( 1 << 6 ),
|
||||||
|
( 1 << 7 ),
|
||||||
|
( 1 << 8 ),
|
||||||
|
( 1 << 9 ),
|
||||||
|
( 1 << 10 ),
|
||||||
|
( 1 << 11 ),
|
||||||
|
( 1 << 12 ),
|
||||||
|
( 1 << 13 ),
|
||||||
|
( 1 << 14 ),
|
||||||
|
( 1 << 15 ),
|
||||||
|
( 1 << 16 ),
|
||||||
|
( 1 << 17 ),
|
||||||
|
( 1 << 18 ),
|
||||||
|
( 1 << 19 ),
|
||||||
|
( 1 << 20 ),
|
||||||
|
( 1 << 21 ),
|
||||||
|
( 1 << 22 ),
|
||||||
|
( 1 << 23 ),
|
||||||
|
( 1 << 24 ),
|
||||||
|
( 1 << 25 ),
|
||||||
|
( 1 << 26 ),
|
||||||
|
( 1 << 27 ),
|
||||||
|
( 1 << 28 ),
|
||||||
|
( 1 << 29 ),
|
||||||
|
( 1 << 30 ),
|
||||||
|
( 1 << 31 ),
|
||||||
|
};
|
||||||
|
return bitsForBitnum[ (bitNum) & (BITS_PER_INT-1) ];
|
||||||
|
}
|
53
external/sourcesdk/vector.h
vendored
Normal file
53
external/sourcesdk/vector.h
vendored
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
class QAngle
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
float x, y, z;
|
||||||
|
void Init( void )
|
||||||
|
{
|
||||||
|
x = y = z = 0.0f;
|
||||||
|
}
|
||||||
|
void Init( float _x, float _y, float _z )
|
||||||
|
{
|
||||||
|
x = _x;
|
||||||
|
y = _y;
|
||||||
|
z = _z;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class Vector
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
float x, y, z;
|
||||||
|
Vector()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
Vector(float X, float Y, float Z)
|
||||||
|
{
|
||||||
|
x = X; y = Y; z = Z;
|
||||||
|
}
|
||||||
|
void Init( void )
|
||||||
|
{
|
||||||
|
x = y = z = 0.0f;
|
||||||
|
}
|
||||||
|
void Init( float _x, float _y, float _z )
|
||||||
|
{
|
||||||
|
x = _x;
|
||||||
|
y = _y;
|
||||||
|
z = _z;
|
||||||
|
}
|
||||||
|
float& Vector::operator[](int i)
|
||||||
|
{
|
||||||
|
assert( (i >= 0) && (i < 3) );
|
||||||
|
return ((float*)this)[i];
|
||||||
|
}
|
||||||
|
float Vector::operator[](int i) const
|
||||||
|
{
|
||||||
|
assert( (i >= 0) && (i < 3) );
|
||||||
|
return ((float*)this)[i];
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user