mirror of
https://github.com/ZDoom/ZDRay.git
synced 2024-11-25 21:31:32 +00:00
- remove anti-patterns
This commit is contained in:
parent
405bb743a0
commit
0aa918dcea
34 changed files with 501 additions and 549 deletions
|
@ -25,8 +25,7 @@
|
|||
// distribution.
|
||||
//
|
||||
|
||||
#ifndef __COMMON_H__
|
||||
#define __COMMON_H__
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -160,7 +159,5 @@ typedef union
|
|||
void Error(const char *error, ...);
|
||||
char *Va(const char *str, ...);
|
||||
void Delay(int ms);
|
||||
const int64_t GetSeconds(void);
|
||||
const kexStr &FilePath(void);
|
||||
|
||||
#endif
|
||||
const int64_t GetSeconds();
|
||||
const kexStr &FilePath();
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
// distribution.
|
||||
//
|
||||
|
||||
#ifndef __KEXARRAY_H__
|
||||
#define __KEXARRAY_H__
|
||||
#pragma once
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -34,15 +33,15 @@ template<class type>
|
|||
class kexArray
|
||||
{
|
||||
public:
|
||||
kexArray(void);
|
||||
~kexArray(void);
|
||||
kexArray();
|
||||
~kexArray();
|
||||
|
||||
typedef int compare_t(const type*, const type*);
|
||||
|
||||
void Push(type o);
|
||||
void Pop(void);
|
||||
void Empty(void);
|
||||
void Init(void);
|
||||
void Pop();
|
||||
void Empty();
|
||||
void Init();
|
||||
void Resize(unsigned int size);
|
||||
type IndexOf(unsigned int index) const;
|
||||
bool Contains(const type check) const;
|
||||
|
@ -50,7 +49,7 @@ public:
|
|||
void Sort(compare_t *function);
|
||||
void Sort(compare_t *function, unsigned int count);
|
||||
|
||||
const unsigned int Length(void) const { return length; }
|
||||
const unsigned int Length() const { return length; }
|
||||
type GetData(const int index) { return data[index]; }
|
||||
|
||||
type &operator[](unsigned int index);
|
||||
|
@ -66,7 +65,7 @@ protected:
|
|||
// kexArray::kexArray
|
||||
//
|
||||
template<class type>
|
||||
kexArray<type>::kexArray(void)
|
||||
kexArray<type>::kexArray()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
@ -75,7 +74,7 @@ kexArray<type>::kexArray(void)
|
|||
// kexArray::~kexArray
|
||||
//
|
||||
template<class type>
|
||||
kexArray<type>::~kexArray(void)
|
||||
kexArray<type>::~kexArray()
|
||||
{
|
||||
Empty();
|
||||
}
|
||||
|
@ -84,7 +83,7 @@ kexArray<type>::~kexArray(void)
|
|||
// kexArray::Init
|
||||
//
|
||||
template<class type>
|
||||
void kexArray<type>::Init(void)
|
||||
void kexArray<type>::Init()
|
||||
{
|
||||
data = NULL;
|
||||
length = 0;
|
||||
|
@ -145,7 +144,7 @@ void kexArray<type>::Push(type o)
|
|||
// kexArray::Pop
|
||||
//
|
||||
template<class type>
|
||||
void kexArray<type>::Pop(void)
|
||||
void kexArray<type>::Pop()
|
||||
{
|
||||
if(length == 0)
|
||||
{
|
||||
|
@ -160,7 +159,7 @@ void kexArray<type>::Pop(void)
|
|||
// kexArray::Empty
|
||||
//
|
||||
template<class type>
|
||||
void kexArray<type>::Empty(void)
|
||||
void kexArray<type>::Empty()
|
||||
{
|
||||
if(data && length > 0)
|
||||
{
|
||||
|
@ -308,5 +307,3 @@ kexArray<type> &kexArray<type>::operator=(const kexArray<type> &arr)
|
|||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
// kexBinFile::kexBinFile
|
||||
//
|
||||
|
||||
kexBinFile::kexBinFile(void)
|
||||
kexBinFile::kexBinFile()
|
||||
{
|
||||
this->handle = NULL;
|
||||
this->buffer = NULL;
|
||||
|
@ -49,7 +49,7 @@ kexBinFile::kexBinFile(void)
|
|||
// kexBinFile::~kexBinFile
|
||||
//
|
||||
|
||||
kexBinFile::~kexBinFile(void)
|
||||
kexBinFile::~kexBinFile()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ bool kexBinFile::Create(const char *file)
|
|||
// kexBinFile::Close
|
||||
//
|
||||
|
||||
void kexBinFile::Close(void)
|
||||
void kexBinFile::Close()
|
||||
{
|
||||
if(bOpened == false)
|
||||
{
|
||||
|
@ -185,7 +185,7 @@ void kexBinFile::Duplicate(const char *newFileName)
|
|||
// kexBinFile::Length
|
||||
//
|
||||
|
||||
int kexBinFile::Length(void)
|
||||
int kexBinFile::Length()
|
||||
{
|
||||
long savedpos;
|
||||
long length;
|
||||
|
@ -212,7 +212,7 @@ int kexBinFile::Length(void)
|
|||
// kexBinFile::Read8
|
||||
//
|
||||
|
||||
byte kexBinFile::Read8(void)
|
||||
byte kexBinFile::Read8()
|
||||
{
|
||||
byte result;
|
||||
result = buffer[bufferOffset++];
|
||||
|
@ -223,7 +223,7 @@ byte kexBinFile::Read8(void)
|
|||
// kexBinFile::Read16
|
||||
//
|
||||
|
||||
short kexBinFile::Read16(void)
|
||||
short kexBinFile::Read16()
|
||||
{
|
||||
int result;
|
||||
result = Read8();
|
||||
|
@ -235,7 +235,7 @@ short kexBinFile::Read16(void)
|
|||
// kexBinFile::Read32
|
||||
//
|
||||
|
||||
int kexBinFile::Read32(void)
|
||||
int kexBinFile::Read32()
|
||||
{
|
||||
int result;
|
||||
result = Read8();
|
||||
|
@ -249,7 +249,7 @@ int kexBinFile::Read32(void)
|
|||
// kexBinFile::ReadFloat
|
||||
//
|
||||
|
||||
float kexBinFile::ReadFloat(void)
|
||||
float kexBinFile::ReadFloat()
|
||||
{
|
||||
fint_t fi;
|
||||
fi.i = Read32();
|
||||
|
@ -260,7 +260,7 @@ float kexBinFile::ReadFloat(void)
|
|||
// kexBinFile::ReadVector
|
||||
//
|
||||
|
||||
kexVec3 kexBinFile::ReadVector(void)
|
||||
kexVec3 kexBinFile::ReadVector()
|
||||
{
|
||||
kexVec3 vec;
|
||||
|
||||
|
@ -275,7 +275,7 @@ kexVec3 kexBinFile::ReadVector(void)
|
|||
// kexBinFile::ReadString
|
||||
//
|
||||
|
||||
kexStr kexBinFile::ReadString(void)
|
||||
kexStr kexBinFile::ReadString()
|
||||
{
|
||||
kexStr str;
|
||||
char c = 0;
|
||||
|
|
|
@ -25,30 +25,29 @@
|
|||
// distribution.
|
||||
//
|
||||
|
||||
#ifndef __BINFILE_H__
|
||||
#define __BINFILE_H__
|
||||
#pragma once
|
||||
|
||||
#include "lightmap/kexlib/math/mathlib.h"
|
||||
|
||||
class kexBinFile
|
||||
{
|
||||
public:
|
||||
kexBinFile(void);
|
||||
~kexBinFile(void);
|
||||
kexBinFile();
|
||||
~kexBinFile();
|
||||
|
||||
bool Open(const char *file, kexHeapBlock &heapBlock = hb_static);
|
||||
bool Create(const char *file);
|
||||
void Close(void);
|
||||
void Close();
|
||||
bool Exists(const char *file);
|
||||
int Length(void);
|
||||
int Length();
|
||||
void Duplicate(const char *newFileName);
|
||||
|
||||
byte Read8(void);
|
||||
short Read16(void);
|
||||
int Read32(void);
|
||||
float ReadFloat(void);
|
||||
kexVec3 ReadVector(void);
|
||||
kexStr ReadString(void);
|
||||
byte Read8();
|
||||
short Read16();
|
||||
int Read32();
|
||||
float ReadFloat();
|
||||
kexVec3 ReadVector();
|
||||
kexStr ReadString();
|
||||
|
||||
void Write8(const byte val);
|
||||
void Write16(const short val);
|
||||
|
@ -62,11 +61,11 @@ public:
|
|||
byte *subdata = NULL,
|
||||
int *count = NULL);
|
||||
|
||||
FILE *Handle(void) const { return handle; }
|
||||
byte *Buffer(void) const { return buffer; }
|
||||
FILE *Handle() const { return handle; }
|
||||
byte *Buffer() const { return buffer; }
|
||||
void SetBuffer(byte *ptr) { buffer = ptr; }
|
||||
byte *BufferAt(void) const { return &buffer[bufferOffset]; }
|
||||
bool Opened(void) const { return bOpened; }
|
||||
byte *BufferAt() const { return &buffer[bufferOffset]; }
|
||||
bool Opened() const { return bOpened; }
|
||||
void SetOffset(const int offset) { bufferOffset = offset; }
|
||||
|
||||
private:
|
||||
|
@ -75,5 +74,3 @@ private:
|
|||
unsigned int bufferOffset;
|
||||
bool bOpened;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
// kexStr::Init
|
||||
//
|
||||
|
||||
void kexStr::Init(void)
|
||||
void kexStr::Init()
|
||||
{
|
||||
length = 0;
|
||||
bufferLength = STRING_DEFAULT_SIZE;
|
||||
|
@ -74,7 +74,7 @@ void kexStr::CopyNew(const char *string, int len)
|
|||
// kexStr::kexStr
|
||||
//
|
||||
|
||||
kexStr::kexStr(void)
|
||||
kexStr::kexStr()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ kexStr::kexStr(const kexStr &string)
|
|||
// kexStr::~kexStr
|
||||
//
|
||||
|
||||
kexStr::~kexStr(void)
|
||||
kexStr::~kexStr()
|
||||
{
|
||||
if(charPtr != defaultBuffer)
|
||||
{
|
||||
|
@ -467,7 +467,7 @@ int kexStr::IndexOf(const kexStr &pattern) const
|
|||
// kexStr::NormalizeSlashes
|
||||
//
|
||||
|
||||
kexStr &kexStr::NormalizeSlashes(void)
|
||||
kexStr &kexStr::NormalizeSlashes()
|
||||
{
|
||||
for(int i = 0; i < length; i++)
|
||||
{
|
||||
|
@ -484,7 +484,7 @@ kexStr &kexStr::NormalizeSlashes(void)
|
|||
// kexStr::StripPath
|
||||
//
|
||||
|
||||
kexStr &kexStr::StripPath(void)
|
||||
kexStr &kexStr::StripPath()
|
||||
{
|
||||
int pos = 0;
|
||||
int i = 0;
|
||||
|
@ -513,7 +513,7 @@ kexStr &kexStr::StripPath(void)
|
|||
// kexStr::StripExtension
|
||||
//
|
||||
|
||||
kexStr &kexStr::StripExtension(void)
|
||||
kexStr &kexStr::StripExtension()
|
||||
{
|
||||
int pos = IndexOf(".");
|
||||
|
||||
|
@ -533,7 +533,7 @@ kexStr &kexStr::StripExtension(void)
|
|||
// kexStr::StripFile
|
||||
//
|
||||
|
||||
kexStr &kexStr::StripFile(void)
|
||||
kexStr &kexStr::StripFile()
|
||||
{
|
||||
int pos = 0;
|
||||
int i = 0;
|
||||
|
@ -564,7 +564,7 @@ kexStr &kexStr::StripFile(void)
|
|||
// kexStr::Hash
|
||||
//
|
||||
|
||||
int kexStr::Hash(void)
|
||||
int kexStr::Hash()
|
||||
{
|
||||
unsigned int hash = 0;
|
||||
char *str = (char*)charPtr;
|
||||
|
@ -670,7 +670,7 @@ void kexStr::Split(kexStrList &list, const char seperator)
|
|||
// kexStr::Atoi
|
||||
//
|
||||
|
||||
int kexStr::Atoi(void)
|
||||
int kexStr::Atoi()
|
||||
{
|
||||
return atoi(charPtr);
|
||||
}
|
||||
|
@ -679,7 +679,7 @@ int kexStr::Atoi(void)
|
|||
// kexStr::Atof
|
||||
//
|
||||
|
||||
float kexStr::Atof(void)
|
||||
float kexStr::Atof()
|
||||
{
|
||||
return (float)atof(charPtr);
|
||||
}
|
||||
|
@ -704,7 +704,7 @@ void kexStr::WriteToFile(const char *file)
|
|||
// kexStr::ToUpper
|
||||
//
|
||||
|
||||
kexStr &kexStr::ToUpper(void)
|
||||
kexStr &kexStr::ToUpper()
|
||||
{
|
||||
char c;
|
||||
for(int i = 0; i < length; i++)
|
||||
|
@ -724,7 +724,7 @@ kexStr &kexStr::ToUpper(void)
|
|||
// kexStr::ToLower
|
||||
//
|
||||
|
||||
kexStr &kexStr::ToLower(void)
|
||||
kexStr &kexStr::ToLower()
|
||||
{
|
||||
char c;
|
||||
for(int i = 0; i < length; i++)
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
// distribution.
|
||||
//
|
||||
|
||||
#ifndef __KSTRING_H__
|
||||
#define __KSTRING_H__
|
||||
#pragma once
|
||||
|
||||
#include <string.h>
|
||||
#include "lightmap/common.h"
|
||||
|
@ -39,11 +38,11 @@ typedef kexArray<kexStr> kexStrList;
|
|||
class kexStr
|
||||
{
|
||||
public:
|
||||
kexStr(void);
|
||||
kexStr();
|
||||
kexStr(const char *string);
|
||||
kexStr(const char *string, const int length);
|
||||
kexStr(const kexStr &string);
|
||||
~kexStr(void);
|
||||
~kexStr();
|
||||
|
||||
void CheckSize(int size, bool bKeepString);
|
||||
int IndexOf(const char *pattern) const;
|
||||
|
@ -51,23 +50,23 @@ public:
|
|||
kexStr &Concat(const char *string);
|
||||
kexStr &Concat(const char *string, int len);
|
||||
kexStr &Concat(const char c);
|
||||
kexStr &NormalizeSlashes(void);
|
||||
kexStr &StripPath(void);
|
||||
kexStr &StripExtension(void);
|
||||
kexStr &StripFile(void);
|
||||
kexStr &NormalizeSlashes();
|
||||
kexStr &StripPath();
|
||||
kexStr &StripExtension();
|
||||
kexStr &StripFile();
|
||||
kexStr &Copy(const kexStr &src, int len);
|
||||
kexStr &Copy(const kexStr &src);
|
||||
kexStr &ToUpper(void);
|
||||
kexStr &ToLower(void);
|
||||
int Hash(void);
|
||||
kexStr &ToUpper();
|
||||
kexStr &ToLower();
|
||||
int Hash();
|
||||
kexStr Substr(int start, int len) const;
|
||||
void Split(kexStrList &list, const char seperator);
|
||||
int Atoi(void);
|
||||
float Atof(void);
|
||||
int Atoi();
|
||||
float Atof();
|
||||
void WriteToFile(const char *file);
|
||||
|
||||
int Length(void) const { return length; }
|
||||
const char *c_str(void) const { return charPtr; }
|
||||
int Length() const { return length; }
|
||||
const char *c_str() const { return charPtr; }
|
||||
|
||||
kexStr &operator=(const kexStr &str);
|
||||
kexStr &operator=(const char *str);
|
||||
|
@ -87,8 +86,8 @@ public:
|
|||
friend bool operator==(const char *a, const kexStr &b);
|
||||
friend bool operator==(const kexStr &a, const char *b);
|
||||
|
||||
operator const char *(void) const { return c_str(); }
|
||||
operator const char *(void) { return c_str(); }
|
||||
operator const char *() const { return c_str(); }
|
||||
operator const char *() { return c_str(); }
|
||||
|
||||
static bool CompareCase(const char *s1, const char *s2);
|
||||
static bool CompareCase(const kexStr &a, const kexStr &b);
|
||||
|
@ -103,7 +102,7 @@ private:
|
|||
void CopyNew(const char *string, int len);
|
||||
|
||||
protected:
|
||||
void Init(void);
|
||||
void Init();
|
||||
|
||||
static const int STRING_DEFAULT_SIZE = 32;
|
||||
|
||||
|
@ -127,5 +126,3 @@ d_inline bool operator==(const kexStr &a, const char *b)
|
|||
{
|
||||
return (!strcmp(a.charPtr, b));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
// kexAngle::kexAngle
|
||||
//
|
||||
|
||||
kexAngle::kexAngle(void)
|
||||
kexAngle::kexAngle()
|
||||
{
|
||||
this->yaw = 0;
|
||||
this->pitch = 0;
|
||||
|
@ -85,7 +85,7 @@ kexAngle::kexAngle(const kexAngle &an)
|
|||
// kexAngle::Clamp180
|
||||
//
|
||||
|
||||
kexAngle &kexAngle::Clamp180(void)
|
||||
kexAngle &kexAngle::Clamp180()
|
||||
{
|
||||
#define CLAMP180(x) \
|
||||
if(x < -M_PI) for(; x < -M_PI; x = x + FULLCIRCLE); \
|
||||
|
@ -102,7 +102,7 @@ kexAngle &kexAngle::Clamp180(void)
|
|||
// kexAngle::Clamp180Invert
|
||||
//
|
||||
|
||||
kexAngle &kexAngle::Clamp180Invert(void)
|
||||
kexAngle &kexAngle::Clamp180Invert()
|
||||
{
|
||||
#define CLAMP180(x) \
|
||||
for(; x < -M_PI; x = x + FULLCIRCLE); \
|
||||
|
@ -146,7 +146,7 @@ kexAngle &kexAngle::Clamp180InvertSum(const kexAngle &angle)
|
|||
// kexAngle::Round
|
||||
//
|
||||
|
||||
kexAngle &kexAngle::Round(void)
|
||||
kexAngle &kexAngle::Round()
|
||||
{
|
||||
#define ROUND(x) \
|
||||
x = DEG2RAD((360.0f / 65536.0f) * \
|
||||
|
@ -235,7 +235,7 @@ void kexAngle::ToAxis(kexVec3 *forward, kexVec3 *up, kexVec3 *right)
|
|||
// kexAngle::ToForwardAxis
|
||||
//
|
||||
|
||||
kexVec3 kexAngle::ToForwardAxis(void)
|
||||
kexVec3 kexAngle::ToForwardAxis()
|
||||
{
|
||||
kexVec3 vec;
|
||||
|
||||
|
@ -247,7 +247,7 @@ kexVec3 kexAngle::ToForwardAxis(void)
|
|||
// kexAngle::ToUpAxis
|
||||
//
|
||||
|
||||
kexVec3 kexAngle::ToUpAxis(void)
|
||||
kexVec3 kexAngle::ToUpAxis()
|
||||
{
|
||||
kexVec3 vec;
|
||||
|
||||
|
@ -259,7 +259,7 @@ kexVec3 kexAngle::ToUpAxis(void)
|
|||
// kexAngle::ToRightAxis
|
||||
//
|
||||
|
||||
kexVec3 kexAngle::ToRightAxis(void)
|
||||
kexVec3 kexAngle::ToRightAxis()
|
||||
{
|
||||
kexVec3 vec;
|
||||
|
||||
|
@ -271,7 +271,7 @@ kexVec3 kexAngle::ToRightAxis(void)
|
|||
// kexAngle::ToVec3
|
||||
//
|
||||
|
||||
const kexVec3 &kexAngle::ToVec3(void) const
|
||||
const kexVec3 &kexAngle::ToVec3() const
|
||||
{
|
||||
return *reinterpret_cast<const kexVec3*>(&yaw);
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ const kexVec3 &kexAngle::ToVec3(void) const
|
|||
// kexAngle::ToVec3
|
||||
//
|
||||
|
||||
kexVec3 &kexAngle::ToVec3(void)
|
||||
kexVec3 &kexAngle::ToVec3()
|
||||
{
|
||||
return *reinterpret_cast<kexVec3*>(&yaw);
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ kexVec3 &kexAngle::ToVec3(void)
|
|||
// kexAngle::ToQuat
|
||||
//
|
||||
|
||||
kexQuat kexAngle::ToQuat(void)
|
||||
kexQuat kexAngle::ToQuat()
|
||||
{
|
||||
return
|
||||
(kexQuat(pitch, kexVec3::vecRight) *
|
||||
|
@ -319,7 +319,7 @@ kexAngle kexAngle::operator-(const kexAngle &angle)
|
|||
// kexAngle::operator-
|
||||
//
|
||||
|
||||
kexAngle kexAngle::operator-(void)
|
||||
kexAngle kexAngle::operator-()
|
||||
{
|
||||
return kexAngle(-yaw, -pitch, -roll);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
// kexBBox::kexBBox
|
||||
//
|
||||
|
||||
kexBBox::kexBBox(void)
|
||||
kexBBox::kexBBox()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ kexBBox::kexBBox(const kexVec3 &vMin, const kexVec3 &vMax)
|
|||
// kexBBox::Clear
|
||||
//
|
||||
|
||||
void kexBBox::Clear(void)
|
||||
void kexBBox::Clear()
|
||||
{
|
||||
min.Set(M_INFINITY, M_INFINITY, M_INFINITY);
|
||||
max.Set(-M_INFINITY, -M_INFINITY, -M_INFINITY);
|
||||
|
@ -90,7 +90,7 @@ void kexBBox::AddPoint(const kexVec3 &vec)
|
|||
// kexBBox::Center
|
||||
//
|
||||
|
||||
kexVec3 kexBBox::Center(void) const
|
||||
kexVec3 kexBBox::Center() const
|
||||
{
|
||||
return kexVec3(
|
||||
(max.x + min.x) * 0.5f,
|
||||
|
@ -102,7 +102,7 @@ kexVec3 kexBBox::Center(void) const
|
|||
// kexBBox::Radius
|
||||
//
|
||||
|
||||
float kexBBox::Radius(void) const
|
||||
float kexBBox::Radius() const
|
||||
{
|
||||
int i;
|
||||
float r = 0;
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
// distribution.
|
||||
//
|
||||
|
||||
#ifndef __MATHLIB_H__
|
||||
#define __MATHLIB_H__
|
||||
#pragma once
|
||||
|
||||
#include <math.h>
|
||||
#include "lightmap/common.h"
|
||||
|
@ -87,11 +86,11 @@ class kexRand
|
|||
{
|
||||
public:
|
||||
static void SetSeed(const int randSeed);
|
||||
static int SysRand(void);
|
||||
static int Int(void);
|
||||
static int SysRand();
|
||||
static int Int();
|
||||
static int Max(const int max);
|
||||
static float Float(void);
|
||||
static float CFloat(void);
|
||||
static float Float();
|
||||
static float CFloat();
|
||||
|
||||
private:
|
||||
static int seed;
|
||||
|
@ -100,21 +99,21 @@ private:
|
|||
class kexQuat
|
||||
{
|
||||
public:
|
||||
kexQuat(void);
|
||||
kexQuat();
|
||||
|
||||
explicit kexQuat(const float angle, const float x, const float y, const float z);
|
||||
explicit kexQuat(const float angle, kexVec3 &vector);
|
||||
explicit kexQuat(const float angle, const kexVec3 &vector);
|
||||
|
||||
void Set(const float x, const float y, const float z, const float w);
|
||||
void Clear(void);
|
||||
void Clear();
|
||||
float Dot(const kexQuat &quat) const;
|
||||
float UnitSq(void) const;
|
||||
float Unit(void) const;
|
||||
kexQuat &Normalize(void);
|
||||
float UnitSq() const;
|
||||
float Unit() const;
|
||||
kexQuat &Normalize();
|
||||
kexQuat Slerp(const kexQuat &quat, float movement) const;
|
||||
kexQuat RotateFrom(const kexVec3 &location, const kexVec3 &target, float maxAngle);
|
||||
kexQuat Inverse(void) const;
|
||||
kexQuat Inverse() const;
|
||||
|
||||
kexQuat operator+(const kexQuat &quat);
|
||||
kexQuat &operator+=(const kexQuat &quat);
|
||||
|
@ -129,8 +128,8 @@ public:
|
|||
kexQuat &operator=(const float *vecs);
|
||||
kexVec3 operator|(const kexVec3 &vector);
|
||||
|
||||
const kexVec3 &ToVec3(void) const;
|
||||
kexVec3 &ToVec3(void);
|
||||
const kexVec3 &ToVec3() const;
|
||||
kexVec3 &ToVec3();
|
||||
|
||||
float x;
|
||||
float y;
|
||||
|
@ -141,11 +140,11 @@ public:
|
|||
class kexVec2
|
||||
{
|
||||
public:
|
||||
kexVec2(void);
|
||||
kexVec2();
|
||||
explicit kexVec2(const float x, const float y);
|
||||
|
||||
void Set(const float x, const float y);
|
||||
void Clear(void);
|
||||
void Clear();
|
||||
float Dot(const kexVec2 &vec) const;
|
||||
static float Dot(const kexVec2 &vec1, const kexVec2 &vec2);
|
||||
float CrossScalar(const kexVec2 &vec) const;
|
||||
|
@ -155,23 +154,23 @@ public:
|
|||
static float Dot(const kexVec3 &vec1, const kexVec3 &vec2);
|
||||
kexVec2 Cross(const kexVec3 &vec) const;
|
||||
kexVec2 &Cross(const kexVec3 &vec1, const kexVec3 &vec2);
|
||||
float UnitSq(void) const;
|
||||
float Unit(void) const;
|
||||
float UnitSq() const;
|
||||
float Unit() const;
|
||||
float DistanceSq(const kexVec2 &vec) const;
|
||||
float Distance(const kexVec2 &vec) const;
|
||||
kexVec2 &Normalize(void);
|
||||
kexVec2 &Normalize();
|
||||
kexVec2 Lerp(const kexVec2 &next, float movement) const;
|
||||
kexVec2 &Lerp(const kexVec2 &next, const float movement);
|
||||
kexVec2 &Lerp(const kexVec2 &start, const kexVec2 &next, float movement);
|
||||
kexStr ToString(void) const;
|
||||
float ToYaw(void) const;
|
||||
float *ToFloatPtr(void);
|
||||
kexVec3 ToVec3(void);
|
||||
kexStr ToString() const;
|
||||
float ToYaw() const;
|
||||
float *ToFloatPtr();
|
||||
kexVec3 ToVec3();
|
||||
|
||||
kexVec2 operator+(const kexVec2 &vec);
|
||||
kexVec2 operator+(const kexVec2 &vec) const;
|
||||
kexVec2 operator+(kexVec2 &vec);
|
||||
kexVec2 operator-(void) const;
|
||||
kexVec2 operator-() const;
|
||||
kexVec2 operator-(const kexVec2 &vec) const;
|
||||
kexVec2 operator*(const kexVec2 &vec);
|
||||
kexVec2 operator*(const float val);
|
||||
|
@ -195,7 +194,7 @@ public:
|
|||
float &operator[](int index);
|
||||
bool operator==(const kexVec2 &vec);
|
||||
|
||||
operator float *(void) { return reinterpret_cast<float*>(&x); }
|
||||
operator float *() { return reinterpret_cast<float*>(&x); }
|
||||
|
||||
static kexVec2 vecZero;
|
||||
static const kexVec2 vecRight;
|
||||
|
@ -208,30 +207,30 @@ public:
|
|||
class kexVec3
|
||||
{
|
||||
public:
|
||||
kexVec3(void);
|
||||
kexVec3();
|
||||
explicit kexVec3(const float x, const float y, const float z);
|
||||
|
||||
void Set(const float x, const float y, const float z);
|
||||
void Clear(void);
|
||||
void Clear();
|
||||
float Dot(const kexVec3 &vec) const;
|
||||
static float Dot(const kexVec3 &vec1, const kexVec3 &vec2);
|
||||
kexVec3 Cross(const kexVec3 &vec) const;
|
||||
kexVec3 &Cross(const kexVec3 &vec1, const kexVec3 &vec2);
|
||||
float UnitSq(void) const;
|
||||
float Unit(void) const;
|
||||
float UnitSq() const;
|
||||
float Unit() const;
|
||||
float DistanceSq(const kexVec3 &vec) const;
|
||||
float Distance(const kexVec3 &vec) const;
|
||||
kexVec3 &Normalize(void);
|
||||
kexVec3 &Normalize();
|
||||
kexAngle PointAt(kexVec3 &location) const;
|
||||
kexVec3 Lerp(const kexVec3 &next, float movement) const;
|
||||
kexVec3 &Lerp(const kexVec3 &start, const kexVec3 &next, float movement);
|
||||
kexQuat ToQuat(void);
|
||||
float ToYaw(void) const;
|
||||
float ToPitch(void) const;
|
||||
kexStr ToString(void) const;
|
||||
float *ToFloatPtr(void);
|
||||
kexVec2 ToVec2(void);
|
||||
kexVec2 ToVec2(void) const;
|
||||
kexQuat ToQuat();
|
||||
float ToYaw() const;
|
||||
float ToPitch() const;
|
||||
kexStr ToString() const;
|
||||
float *ToFloatPtr();
|
||||
kexVec2 ToVec2();
|
||||
kexVec2 ToVec2() const;
|
||||
kexVec3 ScreenProject(kexMatrix &proj, kexMatrix &model,
|
||||
const int width, const int height,
|
||||
const int wx, const int wy);
|
||||
|
@ -239,7 +238,7 @@ public:
|
|||
kexVec3 operator+(const kexVec3 &vec);
|
||||
kexVec3 operator+(const kexVec3 &vec) const;
|
||||
kexVec3 operator+(kexVec3 &vec);
|
||||
kexVec3 operator-(void) const;
|
||||
kexVec3 operator-() const;
|
||||
kexVec3 operator-(const kexVec3 &vec) const;
|
||||
kexVec3 operator*(const kexVec3 &vec);
|
||||
kexVec3 operator*(const float val);
|
||||
|
@ -262,7 +261,7 @@ public:
|
|||
float operator[](int index) const;
|
||||
float &operator[](int index);
|
||||
|
||||
operator float *(void) { return reinterpret_cast<float*>(&x); }
|
||||
operator float *() { return reinterpret_cast<float*>(&x); }
|
||||
|
||||
static const kexVec3 vecForward;
|
||||
static const kexVec3 vecUp;
|
||||
|
@ -276,15 +275,15 @@ public:
|
|||
class kexVec4
|
||||
{
|
||||
public:
|
||||
kexVec4(void);
|
||||
kexVec4();
|
||||
explicit kexVec4(const float x, const float y, const float z, const float w);
|
||||
|
||||
void Set(const float x, const float y, const float z, const float w);
|
||||
void Clear(void);
|
||||
float *ToFloatPtr(void);
|
||||
void Clear();
|
||||
float *ToFloatPtr();
|
||||
|
||||
const kexVec3 &ToVec3(void) const;
|
||||
kexVec3 &ToVec3(void);
|
||||
const kexVec3 &ToVec3() const;
|
||||
kexVec3 &ToVec3();
|
||||
kexVec4 operator|(const kexMatrix &mtx);
|
||||
kexVec4 &operator|=(const kexMatrix &mtx);
|
||||
float operator[](int index) const;
|
||||
|
@ -299,13 +298,13 @@ public:
|
|||
class kexMatrix
|
||||
{
|
||||
public:
|
||||
kexMatrix(void);
|
||||
kexMatrix();
|
||||
kexMatrix(const kexMatrix &mtx);
|
||||
kexMatrix(const float x, const float y, const float z);
|
||||
kexMatrix(const kexQuat &quat);
|
||||
kexMatrix(const float angle, const int axis);
|
||||
|
||||
kexMatrix &Identity(void);
|
||||
kexMatrix &Identity();
|
||||
kexMatrix &Identity(const float x, const float y, const float z);
|
||||
kexMatrix &SetTranslation(const float x, const float y, const float z);
|
||||
kexMatrix &SetTranslation(const kexVec3 &vector);
|
||||
|
@ -314,11 +313,11 @@ public:
|
|||
kexMatrix &Scale(const float x, const float y, const float z);
|
||||
kexMatrix &Scale(const kexVec3 &vector);
|
||||
static kexMatrix Scale(const kexMatrix &mtx, const float x, const float y, const float z);
|
||||
kexMatrix &Transpose(void);
|
||||
kexMatrix &Transpose();
|
||||
static kexMatrix Transpose(const kexMatrix &mtx);
|
||||
static kexMatrix Invert(kexMatrix &mtx);
|
||||
kexQuat ToQuat(void);
|
||||
float *ToFloatPtr(void);
|
||||
kexQuat ToQuat();
|
||||
float *ToFloatPtr();
|
||||
void SetViewProjection(float aspect, float fov, float zNear, float zFar);
|
||||
void SetOrtho(float left, float right,
|
||||
float bottom, float top,
|
||||
|
@ -339,10 +338,10 @@ public:
|
|||
class kexPluecker
|
||||
{
|
||||
public:
|
||||
kexPluecker(void);
|
||||
kexPluecker();
|
||||
kexPluecker(const kexVec3 &start, const kexVec3 &end, bool bRay = false);
|
||||
|
||||
void Clear(void);
|
||||
void Clear();
|
||||
void SetLine(const kexVec3 &start, const kexVec3 &end);
|
||||
void SetRay(const kexVec3 &start, const kexVec3 &dir);
|
||||
float InnerProduct(const kexPluecker &pluecker) const;
|
||||
|
@ -353,33 +352,33 @@ public:
|
|||
class kexPlane
|
||||
{
|
||||
public:
|
||||
kexPlane(void);
|
||||
kexPlane();
|
||||
kexPlane(const float a, const float b, const float c, const float d);
|
||||
kexPlane(const kexVec3 &pt1, const kexVec3 &pt2, const kexVec3 &pt3);
|
||||
kexPlane(const kexVec3 &normal, const kexVec3 &point);
|
||||
kexPlane(const kexPlane &plane);
|
||||
|
||||
typedef enum
|
||||
enum planeAxis_t
|
||||
{
|
||||
AXIS_YZ = 0,
|
||||
AXIS_XZ,
|
||||
AXIS_XY
|
||||
} planeAxis_t;
|
||||
};
|
||||
|
||||
const kexVec3 &Normal(void) const;
|
||||
kexVec3 &Normal(void);
|
||||
const kexVec3 &Normal() const;
|
||||
kexVec3 &Normal();
|
||||
kexPlane &SetNormal(const kexVec3 &normal);
|
||||
kexPlane &SetNormal(const kexVec3 &pt1, const kexVec3 &pt2, const kexVec3 &pt3);
|
||||
float Distance(const kexVec3 &point);
|
||||
kexPlane &SetDistance(const kexVec3 &point);
|
||||
bool IsFacing(const float yaw);
|
||||
float ToYaw(void);
|
||||
float ToPitch(void);
|
||||
kexQuat ToQuat(void);
|
||||
const kexVec4 &ToVec4(void) const;
|
||||
kexVec4 &ToVec4(void);
|
||||
const planeAxis_t BestAxis(void) const;
|
||||
kexVec3 GetInclination(void);
|
||||
float ToYaw();
|
||||
float ToPitch();
|
||||
kexQuat ToQuat();
|
||||
const kexVec4 &ToVec4() const;
|
||||
kexVec4 &ToVec4();
|
||||
const planeAxis_t BestAxis() const;
|
||||
kexVec3 GetInclination();
|
||||
|
||||
kexPlane &operator|(const kexQuat &quat);
|
||||
kexPlane &operator|=(const kexQuat &quat);
|
||||
|
@ -395,23 +394,23 @@ public:
|
|||
class kexAngle
|
||||
{
|
||||
public:
|
||||
kexAngle(void);
|
||||
kexAngle();
|
||||
kexAngle(const float yaw, const float pitch, const float roll);
|
||||
kexAngle(const kexVec3 &vector);
|
||||
kexAngle(const kexAngle &an);
|
||||
|
||||
kexAngle &Round(void);
|
||||
kexAngle &Clamp180(void);
|
||||
kexAngle &Clamp180Invert(void);
|
||||
kexAngle &Round();
|
||||
kexAngle &Clamp180();
|
||||
kexAngle &Clamp180Invert();
|
||||
kexAngle &Clamp180InvertSum(const kexAngle &angle);
|
||||
kexAngle Diff(kexAngle &angle);
|
||||
void ToAxis(kexVec3 *forward, kexVec3 *up, kexVec3 *right);
|
||||
kexVec3 ToForwardAxis(void);
|
||||
kexVec3 ToUpAxis(void);
|
||||
kexVec3 ToRightAxis(void);
|
||||
const kexVec3 &ToVec3(void) const;
|
||||
kexVec3 &ToVec3(void);
|
||||
kexQuat ToQuat(void);
|
||||
kexVec3 ToForwardAxis();
|
||||
kexVec3 ToUpAxis();
|
||||
kexVec3 ToRightAxis();
|
||||
const kexVec3 &ToVec3() const;
|
||||
kexVec3 &ToVec3();
|
||||
kexQuat ToQuat();
|
||||
|
||||
kexAngle operator+(const kexAngle &angle);
|
||||
kexAngle operator-(const kexAngle &angle);
|
||||
|
@ -420,7 +419,7 @@ public:
|
|||
kexAngle &operator=(const kexAngle &angle);
|
||||
kexAngle &operator=(const kexVec3 &vector);
|
||||
kexAngle &operator=(const float *vecs);
|
||||
kexAngle operator-(void);
|
||||
kexAngle operator-();
|
||||
float operator[](int index) const;
|
||||
float &operator[](int index);
|
||||
|
||||
|
@ -432,12 +431,12 @@ public:
|
|||
class kexBBox
|
||||
{
|
||||
public:
|
||||
kexBBox(void);
|
||||
kexBBox();
|
||||
explicit kexBBox(const kexVec3 &vMin, const kexVec3 &vMax);
|
||||
|
||||
void Clear(void);
|
||||
kexVec3 Center(void) const;
|
||||
float Radius(void) const;
|
||||
void Clear();
|
||||
kexVec3 Center() const;
|
||||
float Radius() const;
|
||||
void AddPoint(const kexVec3 &vec);
|
||||
bool PointInside(const kexVec3 &vec) const;
|
||||
bool IntersectingBox(const kexBBox &box) const;
|
||||
|
@ -656,6 +655,3 @@ d_inline void kexMath::Clamp(kexVec3 &v, const float min, const float max)
|
|||
if(v.z < min) { v.z = min; }
|
||||
if(v.z > max) { v.z = max; }
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
// kexMatrix::kexMatrix
|
||||
//
|
||||
|
||||
kexMatrix::kexMatrix(void)
|
||||
kexMatrix::kexMatrix()
|
||||
{
|
||||
Identity();
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ kexMatrix::kexMatrix(const float angle, const int axis)
|
|||
// kexMatrix::Identity
|
||||
//
|
||||
|
||||
kexMatrix &kexMatrix::Identity(void)
|
||||
kexMatrix &kexMatrix::Identity()
|
||||
{
|
||||
vectors[0].Set(1, 0, 0, 0);
|
||||
vectors[1].Set(0, 1, 0, 0);
|
||||
|
@ -293,7 +293,7 @@ kexMatrix kexMatrix::Scale(const kexMatrix &mtx, const float x, const float y, c
|
|||
// kexMatrix::Transpose
|
||||
//
|
||||
|
||||
kexMatrix &kexMatrix::Transpose(void)
|
||||
kexMatrix &kexMatrix::Transpose()
|
||||
{
|
||||
kexVec3 v1 = vectors[1].ToVec3();
|
||||
kexVec3 v2 = vectors[2].ToVec3();
|
||||
|
@ -446,7 +446,7 @@ void kexMatrix::SetOrtho(float left, float right,
|
|||
// kexMatrix::ToQuat
|
||||
//
|
||||
|
||||
kexQuat kexMatrix::ToQuat(void)
|
||||
kexQuat kexMatrix::ToQuat()
|
||||
{
|
||||
float t;
|
||||
float d;
|
||||
|
@ -537,7 +537,7 @@ kexMatrix &kexMatrix::operator*=(const kexVec3 &vector)
|
|||
// kexMatrix::ToFloatPtr
|
||||
//
|
||||
|
||||
float *kexMatrix::ToFloatPtr(void)
|
||||
float *kexMatrix::ToFloatPtr()
|
||||
{
|
||||
return reinterpret_cast<float*>(vectors);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
// kexPlane::kexPlane
|
||||
//
|
||||
|
||||
kexPlane::kexPlane(void)
|
||||
kexPlane::kexPlane()
|
||||
{
|
||||
this->a = 0;
|
||||
this->b = 0;
|
||||
|
@ -115,7 +115,7 @@ kexPlane &kexPlane::SetNormal(const kexVec3 &pt1, const kexVec3 &pt2, const kexV
|
|||
// kexPlane::Normal
|
||||
//
|
||||
|
||||
kexVec3 const &kexPlane::Normal(void) const
|
||||
kexVec3 const &kexPlane::Normal() const
|
||||
{
|
||||
return *reinterpret_cast<const kexVec3*>(&a);
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ kexVec3 const &kexPlane::Normal(void) const
|
|||
// kexPlane::Normal
|
||||
//
|
||||
|
||||
kexVec3 &kexPlane::Normal(void)
|
||||
kexVec3 &kexPlane::Normal()
|
||||
{
|
||||
return *reinterpret_cast<kexVec3*>(&a);
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ bool kexPlane::IsFacing(const float yaw)
|
|||
// kexPlane::ToYaw
|
||||
//
|
||||
|
||||
float kexPlane::ToYaw(void)
|
||||
float kexPlane::ToYaw()
|
||||
{
|
||||
float d = Normal().Unit();
|
||||
|
||||
|
@ -184,7 +184,7 @@ float kexPlane::ToYaw(void)
|
|||
// kexPlane::ToPitch
|
||||
//
|
||||
|
||||
float kexPlane::ToPitch(void)
|
||||
float kexPlane::ToPitch()
|
||||
{
|
||||
return kexMath::ACos(kexVec3::vecUp.Dot(Normal()));
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ float kexPlane::ToPitch(void)
|
|||
// kexPlane::ToQuat
|
||||
//
|
||||
|
||||
kexQuat kexPlane::ToQuat(void)
|
||||
kexQuat kexPlane::ToQuat()
|
||||
{
|
||||
kexVec3 cross = kexVec3::vecUp.Cross(Normal()).Normalize();
|
||||
return kexQuat(kexMath::ACos(kexVec3::vecUp.Dot(Normal())), cross);
|
||||
|
@ -203,7 +203,7 @@ kexQuat kexPlane::ToQuat(void)
|
|||
// kexPlane::ToVec4
|
||||
//
|
||||
|
||||
kexVec4 const &kexPlane::ToVec4(void) const
|
||||
kexVec4 const &kexPlane::ToVec4() const
|
||||
{
|
||||
return *reinterpret_cast<const kexVec4*>(&a);
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ kexVec4 const &kexPlane::ToVec4(void) const
|
|||
// kexPlane::ToVec4
|
||||
//
|
||||
|
||||
kexVec4 &kexPlane::ToVec4(void)
|
||||
kexVec4 &kexPlane::ToVec4()
|
||||
{
|
||||
return *reinterpret_cast<kexVec4*>(&a);
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ kexVec4 &kexPlane::ToVec4(void)
|
|||
// kexPlane::BestAxis
|
||||
//
|
||||
|
||||
const kexPlane::planeAxis_t kexPlane::BestAxis(void) const
|
||||
const kexPlane::planeAxis_t kexPlane::BestAxis() const
|
||||
{
|
||||
float na = kexMath::Fabs(a);
|
||||
float nb = kexMath::Fabs(b);
|
||||
|
@ -244,7 +244,7 @@ const kexPlane::planeAxis_t kexPlane::BestAxis(void) const
|
|||
// kexPlane::GetInclination
|
||||
//
|
||||
|
||||
kexVec3 kexPlane::GetInclination(void)
|
||||
kexVec3 kexPlane::GetInclination()
|
||||
{
|
||||
kexVec3 dir = Normal() * kexVec3::vecUp.Dot(Normal());
|
||||
return (kexVec3::vecUp - dir).Normalize();
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
// kexPluecker::kexPluecker
|
||||
//
|
||||
|
||||
kexPluecker::kexPluecker(void)
|
||||
kexPluecker::kexPluecker()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ kexPluecker::kexPluecker(const kexVec3 &start, const kexVec3 &end, bool bRay)
|
|||
// kexPluecker::Clear
|
||||
//
|
||||
|
||||
void kexPluecker::Clear(void)
|
||||
void kexPluecker::Clear()
|
||||
{
|
||||
p[0] = p[1] = p[2] = p[3] = p[4] = p[5] = 0;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
// kexQuat::kexQuat
|
||||
//
|
||||
|
||||
kexQuat::kexQuat(void)
|
||||
kexQuat::kexQuat()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ void kexQuat::Set(const float x, const float y, const float z, const float w)
|
|||
// kexQuat::Clear
|
||||
//
|
||||
|
||||
void kexQuat::Clear(void)
|
||||
void kexQuat::Clear()
|
||||
{
|
||||
x = y = z = 0.0f;
|
||||
w = 1.0f;
|
||||
|
@ -113,7 +113,7 @@ void kexQuat::Clear(void)
|
|||
// kexVec3::UnitSq
|
||||
//
|
||||
|
||||
float kexQuat::UnitSq(void) const
|
||||
float kexQuat::UnitSq() const
|
||||
{
|
||||
return x * x + y * y + z * z + w * w;
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ float kexQuat::UnitSq(void) const
|
|||
// kexVec3::Unit
|
||||
//
|
||||
|
||||
float kexQuat::Unit(void) const
|
||||
float kexQuat::Unit() const
|
||||
{
|
||||
return kexMath::Sqrt(UnitSq());
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ float kexQuat::Unit(void) const
|
|||
// kexQuat::Normalize
|
||||
//
|
||||
|
||||
kexQuat &kexQuat::Normalize(void)
|
||||
kexQuat &kexQuat::Normalize()
|
||||
{
|
||||
float d = Unit();
|
||||
if(d != 0.0f)
|
||||
|
@ -146,7 +146,7 @@ kexQuat &kexQuat::Normalize(void)
|
|||
// kexQuat::Inverse
|
||||
//
|
||||
|
||||
kexQuat kexQuat::Inverse(void) const
|
||||
kexQuat kexQuat::Inverse() const
|
||||
{
|
||||
kexQuat out;
|
||||
out.Set(-x, -y, -z, -w);
|
||||
|
@ -431,7 +431,7 @@ kexQuat &kexQuat::operator=(const float *vecs)
|
|||
// kexQuat::ToVec3
|
||||
//
|
||||
|
||||
kexVec3 const &kexQuat::ToVec3(void) const
|
||||
kexVec3 const &kexQuat::ToVec3() const
|
||||
{
|
||||
return *reinterpret_cast<const kexVec3*>(this);
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ kexVec3 const &kexQuat::ToVec3(void) const
|
|||
// kexQuat::ToVec3
|
||||
//
|
||||
|
||||
kexVec3 &kexQuat::ToVec3(void)
|
||||
kexVec3 &kexQuat::ToVec3()
|
||||
{
|
||||
return *reinterpret_cast<kexVec3*>(this);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ void kexRand::SetSeed(const int randSeed)
|
|||
// kexRand::SysRand
|
||||
//
|
||||
|
||||
int kexRand::SysRand(void)
|
||||
int kexRand::SysRand()
|
||||
{
|
||||
return rand();
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ int kexRand::SysRand(void)
|
|||
// kexRand::Int
|
||||
//
|
||||
|
||||
int kexRand::Int(void)
|
||||
int kexRand::Int()
|
||||
{
|
||||
seed = 1479838765 - 1471521965 * seed;
|
||||
return seed & RANDOM_MAX;
|
||||
|
@ -83,7 +83,7 @@ int kexRand::Max(const int max)
|
|||
// kexRand::Float
|
||||
//
|
||||
|
||||
float kexRand::Float(void)
|
||||
float kexRand::Float()
|
||||
{
|
||||
return (float)Max(RANDOM_MAX+1) / ((float)RANDOM_MAX+1);
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ float kexRand::Float(void)
|
|||
// kexRand::CFloat
|
||||
//
|
||||
|
||||
float kexRand::CFloat(void)
|
||||
float kexRand::CFloat()
|
||||
{
|
||||
return (float)(Max(20000) - 10000) * 0.0001f;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ kexVec2 kexVec2::vecZero(0, 0);
|
|||
// kexVec2::kexVec2
|
||||
//
|
||||
|
||||
kexVec2::kexVec2(void)
|
||||
kexVec2::kexVec2()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ void kexVec2::Set(const float x, const float y)
|
|||
// kexVec2::Clear
|
||||
//
|
||||
|
||||
void kexVec2::Clear(void)
|
||||
void kexVec2::Clear()
|
||||
{
|
||||
x = y = 0.0f;
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ kexVec2 &kexVec2::Cross(const kexVec3 &vec1, const kexVec3 &vec2)
|
|||
// kexVec2::UnitSq
|
||||
//
|
||||
|
||||
float kexVec2::UnitSq(void) const
|
||||
float kexVec2::UnitSq() const
|
||||
{
|
||||
return x * x + y * y;
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ float kexVec2::UnitSq(void) const
|
|||
// kexVec2::Unit
|
||||
//
|
||||
|
||||
float kexVec2::Unit(void) const
|
||||
float kexVec2::Unit() const
|
||||
{
|
||||
return kexMath::Sqrt(UnitSq());
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ float kexVec2::Distance(const kexVec2 &vec) const
|
|||
// kexVec2::Normalize
|
||||
//
|
||||
|
||||
kexVec2 &kexVec2::Normalize(void)
|
||||
kexVec2 &kexVec2::Normalize()
|
||||
{
|
||||
*this *= kexMath::InvSqrt(UnitSq());
|
||||
return *this;
|
||||
|
@ -253,7 +253,7 @@ kexVec2 &kexVec2::Lerp(const kexVec2 &start, const kexVec2 &next, float movement
|
|||
// kexVec2::ToYaw
|
||||
//
|
||||
|
||||
float kexVec2::ToYaw(void) const
|
||||
float kexVec2::ToYaw() const
|
||||
{
|
||||
float d = x * x + y * y;
|
||||
|
||||
|
@ -269,7 +269,7 @@ float kexVec2::ToYaw(void) const
|
|||
// kexVec2::ToString
|
||||
//
|
||||
|
||||
kexStr kexVec2::ToString(void) const
|
||||
kexStr kexVec2::ToString() const
|
||||
{
|
||||
kexStr str;
|
||||
str = str + x + " " + y;
|
||||
|
@ -280,7 +280,7 @@ kexStr kexVec2::ToString(void) const
|
|||
// kexVec2::ToFloatPtr
|
||||
//
|
||||
|
||||
float *kexVec2::ToFloatPtr(void)
|
||||
float *kexVec2::ToFloatPtr()
|
||||
{
|
||||
return reinterpret_cast<float*>(&x);
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ float *kexVec2::ToFloatPtr(void)
|
|||
// kexVec2::ToVec3
|
||||
//
|
||||
|
||||
kexVec3 kexVec2::ToVec3(void)
|
||||
kexVec3 kexVec2::ToVec3()
|
||||
{
|
||||
return kexVec3(x, y, 0);
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ kexVec2 kexVec2::operator-(const kexVec2 &vec) const
|
|||
// kexVec2::operator-
|
||||
//
|
||||
|
||||
kexVec2 kexVec2::operator-(void) const
|
||||
kexVec2 kexVec2::operator-() const
|
||||
{
|
||||
return kexVec2(-x, -y);
|
||||
}
|
||||
|
@ -562,7 +562,7 @@ bool kexVec2::operator==(const kexVec2 &vec)
|
|||
// kexVec3::kexVec3
|
||||
//
|
||||
|
||||
kexVec3::kexVec3(void)
|
||||
kexVec3::kexVec3()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
@ -591,7 +591,7 @@ void kexVec3::Set(const float x, const float y, const float z)
|
|||
// kexVec3::Clear
|
||||
//
|
||||
|
||||
void kexVec3::Clear(void)
|
||||
void kexVec3::Clear()
|
||||
{
|
||||
x = y = z = 0.0f;
|
||||
}
|
||||
|
@ -644,7 +644,7 @@ kexVec3 &kexVec3::Cross(const kexVec3 &vec1, const kexVec3 &vec2)
|
|||
// kexVec3::UnitSq
|
||||
//
|
||||
|
||||
float kexVec3::UnitSq(void) const
|
||||
float kexVec3::UnitSq() const
|
||||
{
|
||||
return x * x + y * y + z * z;
|
||||
}
|
||||
|
@ -653,7 +653,7 @@ float kexVec3::UnitSq(void) const
|
|||
// kexVec3::Unit
|
||||
//
|
||||
|
||||
float kexVec3::Unit(void) const
|
||||
float kexVec3::Unit() const
|
||||
{
|
||||
return kexMath::Sqrt(UnitSq());
|
||||
}
|
||||
|
@ -684,7 +684,7 @@ float kexVec3::Distance(const kexVec3 &vec) const
|
|||
// kexVec3::Normalize
|
||||
//
|
||||
|
||||
kexVec3 &kexVec3::Normalize(void)
|
||||
kexVec3 &kexVec3::Normalize()
|
||||
{
|
||||
*this *= kexMath::InvSqrt(UnitSq());
|
||||
return *this;
|
||||
|
@ -724,7 +724,7 @@ kexVec3 &kexVec3::Lerp(const kexVec3 &start, const kexVec3 &next, float movement
|
|||
// kexVec3::ToQuat
|
||||
//
|
||||
|
||||
kexQuat kexVec3::ToQuat(void)
|
||||
kexQuat kexVec3::ToQuat()
|
||||
{
|
||||
kexVec3 scv = *this * kexMath::InvSqrt(UnitSq());
|
||||
return kexQuat(kexMath::ACos(scv.z), vecForward.Cross(scv).Normalize());
|
||||
|
@ -734,7 +734,7 @@ kexQuat kexVec3::ToQuat(void)
|
|||
// kexVec3::ToYaw
|
||||
//
|
||||
|
||||
float kexVec3::ToYaw(void) const
|
||||
float kexVec3::ToYaw() const
|
||||
{
|
||||
float d = x * x + z * z;
|
||||
|
||||
|
@ -750,7 +750,7 @@ float kexVec3::ToYaw(void) const
|
|||
// kexVec3::ToPitch
|
||||
//
|
||||
|
||||
float kexVec3::ToPitch(void) const
|
||||
float kexVec3::ToPitch() const
|
||||
{
|
||||
float d = x * x + z * z;
|
||||
|
||||
|
@ -773,7 +773,7 @@ float kexVec3::ToPitch(void) const
|
|||
// kexVec3::ToString
|
||||
//
|
||||
|
||||
kexStr kexVec3::ToString(void) const
|
||||
kexStr kexVec3::ToString() const
|
||||
{
|
||||
kexStr str;
|
||||
str = str + x + " " + y + " " + z;
|
||||
|
@ -784,7 +784,7 @@ kexStr kexVec3::ToString(void) const
|
|||
// kexVec3::ToFloatPtr
|
||||
//
|
||||
|
||||
float *kexVec3::ToFloatPtr(void)
|
||||
float *kexVec3::ToFloatPtr()
|
||||
{
|
||||
return reinterpret_cast<float*>(&x);
|
||||
}
|
||||
|
@ -793,7 +793,7 @@ float *kexVec3::ToFloatPtr(void)
|
|||
// kexVec3::ToVec2
|
||||
//
|
||||
|
||||
kexVec2 kexVec3::ToVec2(void)
|
||||
kexVec2 kexVec3::ToVec2()
|
||||
{
|
||||
return kexVec2(x, y);
|
||||
}
|
||||
|
@ -802,7 +802,7 @@ kexVec2 kexVec3::ToVec2(void)
|
|||
// kexVec3::ToVec2
|
||||
//
|
||||
|
||||
kexVec2 kexVec3::ToVec2(void) const
|
||||
kexVec2 kexVec3::ToVec2() const
|
||||
{
|
||||
return kexVec2(x, y);
|
||||
}
|
||||
|
@ -894,7 +894,7 @@ kexVec3 kexVec3::operator-(const kexVec3 &vec) const
|
|||
// kexVec3::operator-
|
||||
//
|
||||
|
||||
kexVec3 kexVec3::operator-(void) const
|
||||
kexVec3 kexVec3::operator-() const
|
||||
{
|
||||
return kexVec3(-x, -y, -z);
|
||||
}
|
||||
|
@ -1154,7 +1154,7 @@ float &kexVec3::operator[](int index)
|
|||
// kexVec4::kexVec4
|
||||
//
|
||||
|
||||
kexVec4::kexVec4(void)
|
||||
kexVec4::kexVec4()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
@ -1184,7 +1184,7 @@ void kexVec4::Set(const float x, const float y, const float z, const float w)
|
|||
// kexVec4::Clear
|
||||
//
|
||||
|
||||
void kexVec4::Clear(void)
|
||||
void kexVec4::Clear()
|
||||
{
|
||||
x = y = z = w = 0.0f;
|
||||
}
|
||||
|
@ -1193,7 +1193,7 @@ void kexVec4::Clear(void)
|
|||
// kexVec4::ToVec3
|
||||
//
|
||||
|
||||
kexVec3 const &kexVec4::ToVec3(void) const
|
||||
kexVec3 const &kexVec4::ToVec3() const
|
||||
{
|
||||
return *reinterpret_cast<const kexVec3*>(this);
|
||||
}
|
||||
|
@ -1202,7 +1202,7 @@ kexVec3 const &kexVec4::ToVec3(void) const
|
|||
// kexVec4::ToVec3
|
||||
//
|
||||
|
||||
kexVec3 &kexVec4::ToVec3(void)
|
||||
kexVec3 &kexVec4::ToVec3()
|
||||
{
|
||||
return *reinterpret_cast<kexVec3*>(this);
|
||||
}
|
||||
|
@ -1211,7 +1211,7 @@ kexVec3 &kexVec4::ToVec3(void)
|
|||
// kexVec4::ToFloatPtr
|
||||
//
|
||||
|
||||
float *kexVec4::ToFloatPtr(void)
|
||||
float *kexVec4::ToFloatPtr()
|
||||
{
|
||||
return reinterpret_cast<float*>(&x);
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ kexHeapBlock::kexHeapBlock(const char *name, bool bGarbageCollect,
|
|||
// kexHeapBlock::~kexHeapBlock
|
||||
//
|
||||
|
||||
kexHeapBlock::~kexHeapBlock(void)
|
||||
kexHeapBlock::~kexHeapBlock()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ kexHeapBlock *kexHeapBlock::operator[](int index)
|
|||
// kexHeap::AddBlock
|
||||
//
|
||||
|
||||
void kexHeap::AddBlock(memBlock_t *block, kexHeapBlock *heapBlock)
|
||||
void kexHeap::AddBlock(memBlock *block, kexHeapBlock *heapBlock)
|
||||
{
|
||||
block->prev = NULL;
|
||||
block->next = heapBlock->blocks;
|
||||
|
@ -147,7 +147,7 @@ void kexHeap::AddBlock(memBlock_t *block, kexHeapBlock *heapBlock)
|
|||
// kexHeap::RemoveBlock
|
||||
//
|
||||
|
||||
void kexHeap::RemoveBlock(memBlock_t *block)
|
||||
void kexHeap::RemoveBlock(memBlock *block)
|
||||
{
|
||||
if(block->prev == NULL)
|
||||
{
|
||||
|
@ -170,11 +170,11 @@ void kexHeap::RemoveBlock(memBlock_t *block)
|
|||
// kexHeap::GetBlock
|
||||
//
|
||||
|
||||
memBlock_t *kexHeap::GetBlock(void *ptr, const char *file, int line)
|
||||
memBlock *kexHeap::GetBlock(void *ptr, const char *file, int line)
|
||||
{
|
||||
memBlock_t* block;
|
||||
memBlock* block;
|
||||
|
||||
block = (memBlock_t*)((byte*)ptr - sizeof(memBlock_t));
|
||||
block = (memBlock*)((byte*)ptr - sizeof(memBlock));
|
||||
|
||||
if(block->heapTag != kexHeap::HeapTag)
|
||||
{
|
||||
|
@ -190,13 +190,13 @@ memBlock_t *kexHeap::GetBlock(void *ptr, const char *file, int line)
|
|||
|
||||
void *kexHeap::Malloc(int size, kexHeapBlock &heapBlock, const char *file, int line)
|
||||
{
|
||||
memBlock_t *newblock;
|
||||
memBlock *newblock;
|
||||
|
||||
assert(size > 0);
|
||||
|
||||
newblock = NULL;
|
||||
|
||||
if(!(newblock = (memBlock_t*)malloc(sizeof(memBlock_t) + size)))
|
||||
if(!(newblock = (memBlock*)malloc(sizeof(memBlock) + size)))
|
||||
{
|
||||
Error("kexHeap::Malloc: failed on allocation of %u bytes (%s:%d)", size, file, line);
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ void *kexHeap::Malloc(int size, kexHeapBlock &heapBlock, const char *file, int l
|
|||
|
||||
kexHeap::AddBlock(newblock, &heapBlock);
|
||||
|
||||
return ((byte*)newblock) + sizeof(memBlock_t);
|
||||
return ((byte*)newblock) + sizeof(memBlock);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -226,8 +226,8 @@ void *kexHeap::Calloc(int size, kexHeapBlock &heapBlock, const char *file, int l
|
|||
|
||||
void *kexHeap::Realloc(void *ptr, int size, kexHeapBlock &heapBlock, const char *file, int line)
|
||||
{
|
||||
memBlock_t *block;
|
||||
memBlock_t *newblock;
|
||||
memBlock *block;
|
||||
memBlock *newblock;
|
||||
|
||||
if(!ptr)
|
||||
{
|
||||
|
@ -255,7 +255,7 @@ void *kexHeap::Realloc(void *ptr, int size, kexHeapBlock &heapBlock, const char
|
|||
*block->ptrRef = NULL;
|
||||
}
|
||||
|
||||
if(!(newblock = (memBlock_t*)realloc(block, sizeof(memBlock_t) + size)))
|
||||
if(!(newblock = (memBlock*)realloc(block, sizeof(memBlock) + size)))
|
||||
{
|
||||
Error("kexHeap::Realloc: failed on allocation of %u bytes (%s:%d)", size, file, line);
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ void *kexHeap::Realloc(void *ptr, int size, kexHeapBlock &heapBlock, const char
|
|||
|
||||
kexHeap::AddBlock(newblock, &heapBlock);
|
||||
|
||||
return ((byte*)newblock) + sizeof(memBlock_t);
|
||||
return ((byte*)newblock) + sizeof(memBlock);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -285,7 +285,7 @@ void *kexHeap::Alloca(int size, const char *file, int line)
|
|||
|
||||
void kexHeap::Free(void *ptr, const char *file, int line)
|
||||
{
|
||||
memBlock_t* block;
|
||||
memBlock* block;
|
||||
|
||||
block = kexHeap::GetBlock(ptr, file, line);
|
||||
if(block->ptrRef)
|
||||
|
@ -305,8 +305,8 @@ void kexHeap::Free(void *ptr, const char *file, int line)
|
|||
|
||||
void kexHeap::Purge(kexHeapBlock &heapBlock, const char *file, int line)
|
||||
{
|
||||
memBlock_t *block;
|
||||
memBlock_t *next;
|
||||
memBlock *block;
|
||||
memBlock *next;
|
||||
|
||||
for(block = heapBlock.blocks; block != NULL;)
|
||||
{
|
||||
|
@ -353,8 +353,8 @@ void kexHeap::GarbageCollect(const char *file, int line)
|
|||
|
||||
void kexHeap::CheckBlocks(const char *file, int line)
|
||||
{
|
||||
memBlock_t *block;
|
||||
memBlock_t *prev;
|
||||
memBlock *block;
|
||||
memBlock *prev;
|
||||
kexHeapBlock *heapBlock;
|
||||
|
||||
for(heapBlock = kexHeap::blockList; heapBlock; heapBlock = heapBlock->next)
|
||||
|
@ -392,7 +392,7 @@ void kexHeap::Touch(void *ptr, const char *file, int line)
|
|||
int kexHeap::Usage(const kexHeapBlock &heapBlock)
|
||||
{
|
||||
int bytes = 0;
|
||||
memBlock_t *block;
|
||||
memBlock *block;
|
||||
|
||||
for(block = heapBlock.blocks; block != NULL; block = block->next)
|
||||
{
|
||||
|
|
|
@ -25,35 +25,34 @@
|
|||
// distribution.
|
||||
//
|
||||
|
||||
#ifndef __MEM_HEAP_H__
|
||||
#define __MEM_HEAP_H__
|
||||
#pragma once
|
||||
|
||||
typedef void (*blockFunc_t)(void*);
|
||||
|
||||
class kexHeapBlock;
|
||||
|
||||
typedef struct memBlock_s
|
||||
struct memBlock
|
||||
{
|
||||
int heapTag;
|
||||
int purgeID;
|
||||
int size;
|
||||
kexHeapBlock *heapBlock;
|
||||
void **ptrRef;
|
||||
struct memBlock_s *prev;
|
||||
struct memBlock_s *next;
|
||||
} memBlock_t;
|
||||
memBlock *prev;
|
||||
memBlock *next;
|
||||
};
|
||||
|
||||
class kexHeapBlock
|
||||
{
|
||||
public:
|
||||
kexHeapBlock(const char *name, bool bGarbageCollect,
|
||||
blockFunc_t funcFree, blockFunc_t funcGC);
|
||||
~kexHeapBlock(void);
|
||||
~kexHeapBlock();
|
||||
|
||||
kexHeapBlock *operator[](int index);
|
||||
|
||||
char *name;
|
||||
memBlock_t *blocks;
|
||||
memBlock *blocks;
|
||||
bool bGC;
|
||||
blockFunc_t freeFunc;
|
||||
blockFunc_t gcFunc;
|
||||
|
@ -83,9 +82,9 @@ public:
|
|||
static kexHeapBlock *blockList;
|
||||
|
||||
private:
|
||||
static void AddBlock(memBlock_t *block, kexHeapBlock *heapBlock);
|
||||
static void RemoveBlock(memBlock_t *block);
|
||||
static memBlock_t *GetBlock(void *ptr, const char *file, int line);
|
||||
static void AddBlock(memBlock *block, kexHeapBlock *heapBlock);
|
||||
static void RemoveBlock(memBlock *block);
|
||||
static memBlock *GetBlock(void *ptr, const char *file, int line);
|
||||
|
||||
static const int HeapTag = 0x03151983;
|
||||
};
|
||||
|
@ -110,5 +109,3 @@ extern kexHeapBlock hb_object;
|
|||
|
||||
#define Mem_Strdup(s, hb) (strcpy((char*)Mem_Malloc(strlen(s)+1, hb), s))
|
||||
#define Mem_Strdupa(s) (strcpy((char*)Mem_Alloca(strlen(s)+1), s))
|
||||
|
||||
#endif
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#define COMMENT_SINGLELINE 1
|
||||
#define COMMENT_MULTILINE 2
|
||||
|
||||
typedef enum
|
||||
enum chartype_t
|
||||
{
|
||||
CHAR_NUMBER,
|
||||
CHAR_LETTER,
|
||||
|
@ -47,7 +47,7 @@ typedef enum
|
|||
CHAR_QUOTE,
|
||||
CHAR_SPECIAL,
|
||||
CHAR_EOF
|
||||
} chartype_t;
|
||||
};
|
||||
|
||||
#ifdef SC_DEBUG
|
||||
|
||||
|
@ -97,7 +97,7 @@ kexLexer::kexLexer(const char *filename, char *buf, int bufSize)
|
|||
// kexLexer::~kexLexer
|
||||
//
|
||||
|
||||
kexLexer::~kexLexer(void)
|
||||
kexLexer::~kexLexer()
|
||||
{
|
||||
if(buffer)
|
||||
{
|
||||
|
@ -116,7 +116,7 @@ kexLexer::~kexLexer(void)
|
|||
// kexLexer::CheckState
|
||||
//
|
||||
|
||||
bool kexLexer::CheckState(void)
|
||||
bool kexLexer::CheckState()
|
||||
{
|
||||
#ifdef SC_DEBUG
|
||||
SC_DebugPrintf("(%s): checking script state: %i : %i\n",
|
||||
|
@ -135,7 +135,7 @@ bool kexLexer::CheckState(void)
|
|||
// kexLexer::CheckKeywords
|
||||
//
|
||||
|
||||
void kexLexer::CheckKeywords(void)
|
||||
void kexLexer::CheckKeywords()
|
||||
{
|
||||
if(!kexStr::Compare(token, "define"))
|
||||
{
|
||||
|
@ -159,7 +159,7 @@ void kexLexer::CheckKeywords(void)
|
|||
// kexLexer::ClearToken
|
||||
//
|
||||
|
||||
void kexLexer::ClearToken(void)
|
||||
void kexLexer::ClearToken()
|
||||
{
|
||||
tokentype = TK_NONE;
|
||||
memset(token, 0, SC_TOKEN_LEN);
|
||||
|
@ -169,7 +169,7 @@ void kexLexer::ClearToken(void)
|
|||
// kexLexer::GetNumber
|
||||
//
|
||||
|
||||
int kexLexer::GetNumber(void)
|
||||
int kexLexer::GetNumber()
|
||||
{
|
||||
#ifdef SC_DEBUG
|
||||
SC_DebugPrintf("get number (%s)\n", token);
|
||||
|
@ -189,7 +189,7 @@ int kexLexer::GetNumber(void)
|
|||
// kexLexer::GetFloat
|
||||
//
|
||||
|
||||
double kexLexer::GetFloat(void)
|
||||
double kexLexer::GetFloat()
|
||||
{
|
||||
#ifdef SC_DEBUG
|
||||
SC_DebugPrintf("get float (%s)\n", token);
|
||||
|
@ -209,7 +209,7 @@ double kexLexer::GetFloat(void)
|
|||
// kexLexer::GetVector3
|
||||
//
|
||||
|
||||
kexVec3 kexLexer::GetVector3(void)
|
||||
kexVec3 kexLexer::GetVector3()
|
||||
{
|
||||
#ifdef SC_DEBUG
|
||||
SC_DebugPrintf("get vector3 (%s)\n", token);
|
||||
|
@ -230,7 +230,7 @@ kexVec3 kexLexer::GetVector3(void)
|
|||
// kexLexer::GetVector4
|
||||
//
|
||||
|
||||
kexVec4 kexLexer::GetVector4(void)
|
||||
kexVec4 kexLexer::GetVector4()
|
||||
{
|
||||
#ifdef SC_DEBUG
|
||||
SC_DebugPrintf("get vector4 (%s)\n", token);
|
||||
|
@ -252,7 +252,7 @@ kexVec4 kexLexer::GetVector4(void)
|
|||
// kexLexer::GetVectorString3
|
||||
//
|
||||
|
||||
kexVec3 kexLexer::GetVectorString3(void)
|
||||
kexVec3 kexLexer::GetVectorString3()
|
||||
{
|
||||
kexVec3 vec;
|
||||
|
||||
|
@ -266,7 +266,7 @@ kexVec3 kexLexer::GetVectorString3(void)
|
|||
// kexLexer::GetVectorString4
|
||||
//
|
||||
|
||||
kexVec4 kexLexer::GetVectorString4(void)
|
||||
kexVec4 kexLexer::GetVectorString4()
|
||||
{
|
||||
kexVec4 vec;
|
||||
|
||||
|
@ -280,7 +280,7 @@ kexVec4 kexLexer::GetVectorString4(void)
|
|||
// kexLexer::GetString
|
||||
//
|
||||
|
||||
void kexLexer::GetString(void)
|
||||
void kexLexer::GetString()
|
||||
{
|
||||
ExpectNextToken(TK_STRING);
|
||||
strcpy(stringToken, token);
|
||||
|
@ -493,7 +493,7 @@ void kexLexer::GetSymbolToken(char c)
|
|||
// kexLexer::GetStringToken
|
||||
//
|
||||
|
||||
void kexLexer::GetStringToken(void)
|
||||
void kexLexer::GetStringToken()
|
||||
{
|
||||
int i = 0;
|
||||
char c = GetChar();
|
||||
|
@ -515,7 +515,7 @@ void kexLexer::GetStringToken(void)
|
|||
// kexLexer::Find
|
||||
//
|
||||
|
||||
bool kexLexer::Find(void)
|
||||
bool kexLexer::Find()
|
||||
{
|
||||
char c = 0;
|
||||
int comment = COMMENT_NONE;
|
||||
|
@ -618,7 +618,7 @@ bool kexLexer::Find(void)
|
|||
// kexLexer::GetChar
|
||||
//
|
||||
|
||||
char kexLexer::GetChar(void)
|
||||
char kexLexer::GetChar()
|
||||
{
|
||||
int c;
|
||||
|
||||
|
@ -654,7 +654,7 @@ bool kexLexer::Matches(const char *string)
|
|||
// kexLexer::Rewind
|
||||
//
|
||||
|
||||
void kexLexer::Rewind(void)
|
||||
void kexLexer::Rewind()
|
||||
{
|
||||
#ifdef SC_DEBUG
|
||||
SC_DebugPrintf("(%s): rewind\n", name);
|
||||
|
@ -668,7 +668,7 @@ void kexLexer::Rewind(void)
|
|||
// kexLexer::SkipLine
|
||||
//
|
||||
|
||||
void kexLexer::SkipLine(void)
|
||||
void kexLexer::SkipLine()
|
||||
{
|
||||
#ifdef SC_DEBUG
|
||||
SC_DebugPrintf("SkipLine\n");
|
||||
|
@ -691,7 +691,7 @@ void kexLexer::SkipLine(void)
|
|||
// kexLexer::GetIDForTokenList
|
||||
//
|
||||
|
||||
int kexLexer::GetIDForTokenList(const sctokens_t *tokenlist, const char *token)
|
||||
int kexLexer::GetIDForTokenList(const sctokens *tokenlist, const char *token)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; tokenlist[i].id != -1; i++)
|
||||
|
@ -714,7 +714,7 @@ int kexLexer::GetIDForTokenList(const sctokens_t *tokenlist, const char *token)
|
|||
// kexLexer::ExpectTokenListID
|
||||
//
|
||||
|
||||
void kexLexer::ExpectTokenListID(const sctokens_t *tokenlist, int id)
|
||||
void kexLexer::ExpectTokenListID(const sctokens *tokenlist, int id)
|
||||
{
|
||||
Find();
|
||||
if(GetIDForTokenList(tokenlist, token) != id)
|
||||
|
@ -728,7 +728,7 @@ void kexLexer::ExpectTokenListID(const sctokens_t *tokenlist, int id)
|
|||
// kexLexer::AssignFromTokenList
|
||||
//
|
||||
|
||||
void kexLexer::AssignFromTokenList(const sctokens_t *tokenlist, char *str, int id, bool expect)
|
||||
void kexLexer::AssignFromTokenList(const sctokens *tokenlist, char *str, int id, bool expect)
|
||||
{
|
||||
if(expect)
|
||||
{
|
||||
|
@ -743,7 +743,7 @@ void kexLexer::AssignFromTokenList(const sctokens_t *tokenlist, char *str, int i
|
|||
// kexLexer::AssignFromTokenList
|
||||
//
|
||||
|
||||
void kexLexer::AssignFromTokenList(const sctokens_t *tokenlist, unsigned int *var, int id, bool expect)
|
||||
void kexLexer::AssignFromTokenList(const sctokens *tokenlist, unsigned int *var, int id, bool expect)
|
||||
{
|
||||
if(expect)
|
||||
{
|
||||
|
@ -757,7 +757,7 @@ void kexLexer::AssignFromTokenList(const sctokens_t *tokenlist, unsigned int *va
|
|||
// kexLexer::AssignFromTokenList
|
||||
//
|
||||
|
||||
void kexLexer::AssignFromTokenList(const sctokens_t *tokenlist, unsigned short *var, int id, bool expect)
|
||||
void kexLexer::AssignFromTokenList(const sctokens *tokenlist, unsigned short *var, int id, bool expect)
|
||||
{
|
||||
if(expect)
|
||||
{
|
||||
|
@ -771,7 +771,7 @@ void kexLexer::AssignFromTokenList(const sctokens_t *tokenlist, unsigned short *
|
|||
// kexLexer::AssignFromTokenList
|
||||
//
|
||||
|
||||
void kexLexer::AssignFromTokenList(const sctokens_t *tokenlist, float *var, int id, bool expect)
|
||||
void kexLexer::AssignFromTokenList(const sctokens *tokenlist, float *var, int id, bool expect)
|
||||
{
|
||||
if(expect)
|
||||
{
|
||||
|
@ -785,7 +785,7 @@ void kexLexer::AssignFromTokenList(const sctokens_t *tokenlist, float *var, int
|
|||
// kexLexer::AssignVectorFromTokenList
|
||||
//
|
||||
|
||||
void kexLexer::AssignVectorFromTokenList(const sctokens_t *tokenlist, float *var, int id, bool expect)
|
||||
void kexLexer::AssignVectorFromTokenList(const sctokens *tokenlist, float *var, int id, bool expect)
|
||||
{
|
||||
if(expect)
|
||||
{
|
||||
|
@ -803,7 +803,7 @@ void kexLexer::AssignVectorFromTokenList(const sctokens_t *tokenlist, float *var
|
|||
// kexLexer::AssignFromTokenList
|
||||
//
|
||||
|
||||
void kexLexer::AssignFromTokenList(const sctokens_t *tokenlist, arraytype_t type,
|
||||
void kexLexer::AssignFromTokenList(const sctokens *tokenlist, arraytype_t type,
|
||||
void **data, int count, int id, bool expect, kexHeapBlock &hb)
|
||||
{
|
||||
void *buf;
|
||||
|
@ -926,7 +926,7 @@ void kexLexer::AssignFromTokenList(const sctokens_t *tokenlist, arraytype_t type
|
|||
// kexParser::kexParser
|
||||
//
|
||||
|
||||
kexParser::kexParser(void)
|
||||
kexParser::kexParser()
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -965,7 +965,7 @@ kexParser::kexParser(void)
|
|||
// kexParser::~kexParser
|
||||
//
|
||||
|
||||
kexParser::~kexParser(void)
|
||||
kexParser::~kexParser()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -973,7 +973,7 @@ kexParser::~kexParser(void)
|
|||
// kexParser::GetNestedFileName
|
||||
//
|
||||
|
||||
const char *kexParser::GetNestedFileName(void) const
|
||||
const char *kexParser::GetNestedFileName() const
|
||||
{
|
||||
if(numNestedFilenames <= 0)
|
||||
{
|
||||
|
@ -999,7 +999,7 @@ void kexParser::PushFileName(const char *name)
|
|||
// kexParser::PopFileName
|
||||
//
|
||||
|
||||
void kexParser::PopFileName(void)
|
||||
void kexParser::PopFileName()
|
||||
{
|
||||
#ifdef SC_DEBUG
|
||||
SC_DebugPrintf("nested file pop\n");
|
||||
|
@ -1028,7 +1028,7 @@ void kexParser::PushLexer(const char *filename, char *buf, int bufSize)
|
|||
// kexParser::PopLexer
|
||||
//
|
||||
|
||||
void kexParser::PopLexer(void)
|
||||
void kexParser::PopLexer()
|
||||
{
|
||||
delete lexers[--numLexers];
|
||||
if(numLexers <= 0)
|
||||
|
@ -1127,7 +1127,7 @@ kexLexer *kexParser::Open(const char* filename)
|
|||
// kexParser::Close
|
||||
//
|
||||
|
||||
void kexParser::Close(void)
|
||||
void kexParser::Close()
|
||||
{
|
||||
PopLexer();
|
||||
PopFileName();
|
||||
|
|
|
@ -25,13 +25,12 @@
|
|||
// distribution.
|
||||
//
|
||||
|
||||
#ifndef __PARSER_H__
|
||||
#define __PARSER_H__
|
||||
#pragma once
|
||||
|
||||
#define MAX_NESTED_PARSERS 128
|
||||
#define MAX_NESTED_FILENAMES 128
|
||||
|
||||
typedef enum
|
||||
enum tokentype_t
|
||||
{
|
||||
TK_NONE,
|
||||
TK_NUMBER,
|
||||
|
@ -56,78 +55,78 @@ typedef enum
|
|||
TK_INCLUDE,
|
||||
TK_SETDIR,
|
||||
TK_EOF
|
||||
} tokentype_t;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum arraytype_t
|
||||
{
|
||||
AT_SHORT,
|
||||
AT_INTEGER,
|
||||
AT_FLOAT,
|
||||
AT_DOUBLE,
|
||||
AT_VECTOR
|
||||
} arraytype_t;
|
||||
};
|
||||
|
||||
#define SC_TOKEN_LEN 512
|
||||
|
||||
typedef struct
|
||||
struct sctokens
|
||||
{
|
||||
int id;
|
||||
const char *token;
|
||||
} sctokens_t;
|
||||
};
|
||||
|
||||
class kexLexer
|
||||
{
|
||||
public:
|
||||
kexLexer(const char *filename, char *buf, int bufSize);
|
||||
~kexLexer(void);
|
||||
~kexLexer();
|
||||
|
||||
bool CheckState(void);
|
||||
void CheckKeywords(void);
|
||||
bool CheckState();
|
||||
void CheckKeywords();
|
||||
void MustMatchToken(int type);
|
||||
void ExpectNextToken(int type);
|
||||
bool Find(void);
|
||||
char GetChar(void);
|
||||
void Rewind(void);
|
||||
void SkipLine(void);
|
||||
bool Find();
|
||||
char GetChar();
|
||||
void Rewind();
|
||||
void SkipLine();
|
||||
bool Matches(const char *string);
|
||||
int GetNumber(void);
|
||||
double GetFloat(void);
|
||||
kexVec3 GetVector3(void);
|
||||
kexVec4 GetVector4(void);
|
||||
kexVec3 GetVectorString3(void);
|
||||
kexVec4 GetVectorString4(void);
|
||||
void GetString(void);
|
||||
int GetIDForTokenList(const sctokens_t *tokenlist, const char *token);
|
||||
void ExpectTokenListID(const sctokens_t *tokenlist, int id);
|
||||
void AssignFromTokenList(const sctokens_t *tokenlist,
|
||||
int GetNumber();
|
||||
double GetFloat();
|
||||
kexVec3 GetVector3();
|
||||
kexVec4 GetVector4();
|
||||
kexVec3 GetVectorString3();
|
||||
kexVec4 GetVectorString4();
|
||||
void GetString();
|
||||
int GetIDForTokenList(const sctokens *tokenlist, const char *token);
|
||||
void ExpectTokenListID(const sctokens *tokenlist, int id);
|
||||
void AssignFromTokenList(const sctokens *tokenlist,
|
||||
char *str, int id, bool expect);
|
||||
void AssignFromTokenList(const sctokens_t *tokenlist,
|
||||
void AssignFromTokenList(const sctokens *tokenlist,
|
||||
unsigned int *var, int id, bool expect);
|
||||
void AssignFromTokenList(const sctokens_t *tokenlist,
|
||||
void AssignFromTokenList(const sctokens *tokenlist,
|
||||
unsigned short *var, int id, bool expect);
|
||||
void AssignFromTokenList(const sctokens_t *tokenlist,
|
||||
void AssignFromTokenList(const sctokens *tokenlist,
|
||||
float *var, int id, bool expect);
|
||||
void AssignVectorFromTokenList(const sctokens_t *tokenlist,
|
||||
void AssignVectorFromTokenList(const sctokens *tokenlist,
|
||||
float *var, int id, bool expect);
|
||||
void AssignFromTokenList(const sctokens_t *tokenlist,
|
||||
void AssignFromTokenList(const sctokens *tokenlist,
|
||||
arraytype_t type, void **data, int count,
|
||||
int id, bool expect, kexHeapBlock &hb);
|
||||
|
||||
int LinePos(void) { return linepos; }
|
||||
int RowPos(void) { return rowpos; }
|
||||
int BufferPos(void) { return buffpos; }
|
||||
int BufferSize(void) { return buffsize; }
|
||||
char *Buffer(void) { return buffer; }
|
||||
char *StringToken(void) { return stringToken; }
|
||||
const char *Token(void) const { return token; }
|
||||
const int TokenType(void) const { return tokentype; }
|
||||
int LinePos() { return linepos; }
|
||||
int RowPos() { return rowpos; }
|
||||
int BufferPos() { return buffpos; }
|
||||
int BufferSize() { return buffsize; }
|
||||
char *Buffer() { return buffer; }
|
||||
char *StringToken() { return stringToken; }
|
||||
const char *Token() const { return token; }
|
||||
const int TokenType() const { return tokentype; }
|
||||
|
||||
private:
|
||||
void ClearToken(void);
|
||||
void ClearToken();
|
||||
void GetNumberToken(char initial);
|
||||
void GetLetterToken(char initial);
|
||||
void GetSymbolToken(char c);
|
||||
void GetStringToken(void);
|
||||
void GetStringToken();
|
||||
|
||||
char token[SC_TOKEN_LEN];
|
||||
char stringToken[MAX_FILEPATH];
|
||||
|
@ -145,22 +144,22 @@ private:
|
|||
class kexParser
|
||||
{
|
||||
public:
|
||||
kexParser(void);
|
||||
~kexParser(void);
|
||||
kexParser();
|
||||
~kexParser();
|
||||
|
||||
kexLexer *Open(const char *filename);
|
||||
void Close(void);
|
||||
void Close();
|
||||
void HandleError(const char *msg, ...);
|
||||
void PushLexer(const char *filename, char *buf, int bufSize);
|
||||
void PopLexer(void);
|
||||
void PopLexer();
|
||||
void PushFileName(const char *name);
|
||||
void PopFileName(void);
|
||||
byte *CharCode(void) { return charcode; }
|
||||
const kexLexer *CurrentLexer(void) const { return currentLexer; }
|
||||
void PopFileName();
|
||||
byte *CharCode() { return charcode; }
|
||||
const kexLexer *CurrentLexer() const { return currentLexer; }
|
||||
|
||||
private:
|
||||
int OpenExternalFile(const char *name, byte **buffer) const;
|
||||
const char *GetNestedFileName(void) const;
|
||||
const char *GetNestedFileName() const;
|
||||
|
||||
kexLexer *currentLexer;
|
||||
kexLexer *lexers[MAX_NESTED_PARSERS];
|
||||
|
@ -171,5 +170,3 @@ private:
|
|||
};
|
||||
|
||||
extern kexParser *parser;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -68,7 +68,7 @@ static void LightGridWorkerFunc(void *data, int id)
|
|||
// kexLightmapBuilder::kexLightmapBuilder
|
||||
//
|
||||
|
||||
kexLightmapBuilder::kexLightmapBuilder(void)
|
||||
kexLightmapBuilder::kexLightmapBuilder()
|
||||
{
|
||||
this->textureWidth = 128;
|
||||
this->textureHeight = 128;
|
||||
|
@ -85,7 +85,7 @@ kexLightmapBuilder::kexLightmapBuilder(void)
|
|||
// kexLightmapBuilder::~kexLightmapBuilder
|
||||
//
|
||||
|
||||
kexLightmapBuilder::~kexLightmapBuilder(void)
|
||||
kexLightmapBuilder::~kexLightmapBuilder()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ kexLightmapBuilder::~kexLightmapBuilder(void)
|
|||
// Allocates a new texture pointer
|
||||
//
|
||||
|
||||
void kexLightmapBuilder::NewTexture(void)
|
||||
void kexLightmapBuilder::NewTexture()
|
||||
{
|
||||
numTextures++;
|
||||
|
||||
|
@ -881,7 +881,7 @@ void kexLightmapBuilder::CreateLightmaps(kexDoomMap &doomMap)
|
|||
// kexLightmapBuilder::CreateLightGrid
|
||||
//
|
||||
|
||||
void kexLightmapBuilder::CreateLightGrid(void)
|
||||
void kexLightmapBuilder::CreateLightGrid()
|
||||
{
|
||||
int count;
|
||||
int numNodes;
|
||||
|
@ -1135,7 +1135,7 @@ void kexLightmapBuilder::AddLightmapLumps(kexWadFile &wadFile)
|
|||
// kexLightmapBuilder::WriteTexturesToTGA
|
||||
//
|
||||
|
||||
void kexLightmapBuilder::WriteTexturesToTGA(void)
|
||||
void kexLightmapBuilder::WriteTexturesToTGA()
|
||||
{
|
||||
kexBinFile file;
|
||||
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
// distribution.
|
||||
//
|
||||
|
||||
#ifndef __LIGHTMAP_H__
|
||||
#define __LIGHTMAP_H__
|
||||
#pragma once
|
||||
|
||||
#include "surfaces.h"
|
||||
|
||||
|
@ -37,16 +36,16 @@ class kexTrace;
|
|||
class kexLightmapBuilder
|
||||
{
|
||||
public:
|
||||
kexLightmapBuilder(void);
|
||||
~kexLightmapBuilder(void);
|
||||
kexLightmapBuilder();
|
||||
~kexLightmapBuilder();
|
||||
|
||||
void BuildSurfaceParams(surface_t *surface);
|
||||
void TraceSurface(surface_t *surface);
|
||||
void CreateLightGrid(void);
|
||||
void CreateLightGrid();
|
||||
void CreateLightmaps(kexDoomMap &doomMap);
|
||||
void LightSurface(const int surfid);
|
||||
void LightGrid(const int gridid);
|
||||
void WriteTexturesToTGA(void);
|
||||
void WriteTexturesToTGA();
|
||||
void AddLightGridLump(kexWadFile &wadFile);
|
||||
void AddLightmapLumps(kexWadFile &wadFile);
|
||||
|
||||
|
@ -58,23 +57,21 @@ public:
|
|||
static const kexVec3 gridSize;
|
||||
|
||||
private:
|
||||
void NewTexture(void);
|
||||
void NewTexture();
|
||||
bool MakeRoomForBlock(const int width, const int height, int *x, int *y, int *num);
|
||||
kexBBox GetBoundsFromSurface(const surface_t *surface);
|
||||
kexVec3 LightTexelSample(kexTrace &trace, const kexVec3 &origin, surface_t *surface);
|
||||
kexVec3 LightCellSample(const int gridid, kexTrace &trace,
|
||||
const kexVec3 &origin, const mapSubSector_t *sub);
|
||||
bool EmitFromCeiling(kexTrace &trace, const surface_t *surface, const kexVec3 &origin,
|
||||
const kexVec3 &normal, float *dist);
|
||||
kexVec3 LightCellSample(const int gridid, kexTrace &trace, const kexVec3 &origin, const mapSubSector_t *sub);
|
||||
bool EmitFromCeiling(kexTrace &trace, const surface_t *surface, const kexVec3 &origin, const kexVec3 &normal, float *dist);
|
||||
void ExportTexelsToObjFile(FILE *f, const kexVec3 &org, int indices);
|
||||
void WriteBlock(FILE *f, const int i, const kexVec3 &org, int indices, kexBBox &box);
|
||||
|
||||
typedef struct
|
||||
struct gridMap_t
|
||||
{
|
||||
byte marked;
|
||||
byte sunShadow;
|
||||
kexVec3 color;
|
||||
} gridMap_t;
|
||||
};
|
||||
|
||||
kexDoomMap *map;
|
||||
kexArray<byte*> textures;
|
||||
|
@ -89,5 +86,3 @@ private:
|
|||
kexBBox gridBound;
|
||||
kexVec3 gridBlock;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
// kexLightSurface::kexLightSurface
|
||||
//
|
||||
|
||||
kexLightSurface::kexLightSurface(void)
|
||||
kexLightSurface::kexLightSurface()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ kexLightSurface::kexLightSurface(void)
|
|||
// kexLightSurface::~kexLightSurface
|
||||
//
|
||||
|
||||
kexLightSurface::~kexLightSurface(void)
|
||||
kexLightSurface::~kexLightSurface()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ kexLightSurface::~kexLightSurface(void)
|
|||
// kexLightSurface::Init
|
||||
//
|
||||
|
||||
void kexLightSurface::Init(const surfaceLightDef_t &lightSurfaceDef,
|
||||
void kexLightSurface::Init(const surfaceLightDef &lightSurfaceDef,
|
||||
surface_t *surface,
|
||||
const bool bWall,
|
||||
const bool bNoCenterPoint)
|
||||
|
@ -80,7 +80,7 @@ void kexLightSurface::Init(const surfaceLightDef_t &lightSurfaceDef,
|
|||
// intending on subdividing this light surface
|
||||
//
|
||||
|
||||
void kexLightSurface::CreateCenterOrigin(void)
|
||||
void kexLightSurface::CreateCenterOrigin()
|
||||
{
|
||||
if(!bWall)
|
||||
{
|
||||
|
|
|
@ -25,12 +25,11 @@
|
|||
// distribution.
|
||||
//
|
||||
|
||||
#ifndef __LIGHT_SURFACE_H__
|
||||
#define __LIGHT_SURFACE_H__
|
||||
#pragma once
|
||||
|
||||
#include "surfaces.h"
|
||||
|
||||
typedef struct
|
||||
struct surfaceLightDef
|
||||
{
|
||||
int tag;
|
||||
float outerCone;
|
||||
|
@ -42,7 +41,7 @@ typedef struct
|
|||
bool bIgnoreCeiling;
|
||||
bool bNoCenterPoint;
|
||||
kexVec3 rgb;
|
||||
} surfaceLightDef_t;
|
||||
};
|
||||
|
||||
class kexDoomMap;
|
||||
class kexTrace;
|
||||
|
@ -50,32 +49,28 @@ class kexTrace;
|
|||
class kexLightSurface
|
||||
{
|
||||
public:
|
||||
kexLightSurface(void);
|
||||
~kexLightSurface(void);
|
||||
kexLightSurface();
|
||||
~kexLightSurface();
|
||||
|
||||
void Init(const surfaceLightDef_t &lightSurfaceDef, surface_t *surface,
|
||||
const bool bWall, const bool bNoCenterPoint);
|
||||
void Init(const surfaceLightDef &lightSurfaceDef, surface_t *surface, const bool bWall, const bool bNoCenterPoint);
|
||||
void Subdivide(const float divide);
|
||||
void CreateCenterOrigin(void);
|
||||
bool TraceSurface(kexDoomMap *doomMap, kexTrace &trace, const surface_t *surface,
|
||||
const kexVec3 &origin, float *dist);
|
||||
void CreateCenterOrigin();
|
||||
bool TraceSurface(kexDoomMap *doomMap, kexTrace &trace, const surface_t *surface, const kexVec3 &origin, float *dist);
|
||||
|
||||
const float OuterCone(void) const { return outerCone; }
|
||||
const float InnerCone(void) const { return innerCone; }
|
||||
const float FallOff(void) const { return falloff; }
|
||||
const float Distance(void) const { return distance; }
|
||||
const float Intensity(void) const { return intensity; }
|
||||
const kexVec3 GetRGB(void) const { return rgb; }
|
||||
const bool IsAWall(void) const { return bWall; }
|
||||
const bool NoCenterPoint(void) const { return bNoCenterPoint; }
|
||||
const surface_t *Surface(void) const { return surface; }
|
||||
const vertexBatch_t Origins(void) const { return origins; }
|
||||
const float OuterCone() const { return outerCone; }
|
||||
const float InnerCone() const { return innerCone; }
|
||||
const float FallOff() const { return falloff; }
|
||||
const float Distance() const { return distance; }
|
||||
const float Intensity() const { return intensity; }
|
||||
const kexVec3 GetRGB() const { return rgb; }
|
||||
const bool IsAWall() const { return bWall; }
|
||||
const bool NoCenterPoint() const { return bNoCenterPoint; }
|
||||
const surface_t *Surface() const { return surface; }
|
||||
const vertexBatch_t Origins() const { return origins; }
|
||||
|
||||
private:
|
||||
bool SubdivideRecursion(vertexBatch_t &surfPoints, float divide,
|
||||
kexArray<vertexBatch_t*> &points);
|
||||
void Clip(vertexBatch_t &points, const kexVec3 &normal, float dist,
|
||||
vertexBatch_t *frontPoints, vertexBatch_t *backPoints);
|
||||
bool SubdivideRecursion(vertexBatch_t &surfPoints, float divide, kexArray<vertexBatch_t*> &points);
|
||||
void Clip(vertexBatch_t &points, const kexVec3 &normal, float dist, vertexBatch_t *frontPoints, vertexBatch_t *backPoints);
|
||||
|
||||
float outerCone;
|
||||
float innerCone;
|
||||
|
@ -88,5 +83,3 @@ private:
|
|||
vertexBatch_t origins;
|
||||
surface_t *surface;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -43,7 +43,7 @@ const kexVec3 kexDoomMap::defaultSunDirection(0.45f, 0.3f, 0.9f);
|
|||
// kexDoomMap::kexDoomMap
|
||||
//
|
||||
|
||||
kexDoomMap::kexDoomMap(void)
|
||||
kexDoomMap::kexDoomMap()
|
||||
{
|
||||
this->mapLines = NULL;
|
||||
this->mapVerts = NULL;
|
||||
|
@ -80,7 +80,7 @@ kexDoomMap::kexDoomMap(void)
|
|||
// kexDoomMap::~kexDoomMap
|
||||
//
|
||||
|
||||
kexDoomMap::~kexDoomMap(void)
|
||||
kexDoomMap::~kexDoomMap()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ void kexDoomMap::BuildMapFromWad(kexWadFile &wadFile)
|
|||
// kexDoomMap::CheckSkySectors
|
||||
//
|
||||
|
||||
void kexDoomMap::CheckSkySectors(void)
|
||||
void kexDoomMap::CheckSkySectors()
|
||||
{
|
||||
char name[9];
|
||||
|
||||
|
@ -191,7 +191,7 @@ void kexDoomMap::CheckSkySectors(void)
|
|||
// kexDoomMap::BuildPVS
|
||||
//
|
||||
|
||||
void kexDoomMap::BuildPVS(void)
|
||||
void kexDoomMap::BuildPVS()
|
||||
{
|
||||
// don't do anything if already loaded
|
||||
if(mapPVS != NULL)
|
||||
|
@ -269,7 +269,7 @@ void kexDoomMap::BuildVertexes(kexWadFile &wadFile)
|
|||
// kexDoomMap::BuildNodeBounds
|
||||
//
|
||||
|
||||
void kexDoomMap::BuildNodeBounds(void)
|
||||
void kexDoomMap::BuildNodeBounds()
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
|
@ -309,7 +309,7 @@ void kexDoomMap::BuildNodeBounds(void)
|
|||
// kexDoomMap::BuildLeafs
|
||||
//
|
||||
|
||||
void kexDoomMap::BuildLeafs(void)
|
||||
void kexDoomMap::BuildLeafs()
|
||||
{
|
||||
mapSubSector_t *ss;
|
||||
leaf_t *lf;
|
||||
|
@ -615,7 +615,7 @@ bool kexDoomMap::LineIntersectSubSector(const kexVec3 &start, const kexVec3 &end
|
|||
// kexDoomMap::GetSunColor
|
||||
//
|
||||
|
||||
const kexVec3 &kexDoomMap::GetSunColor(void) const
|
||||
const kexVec3 &kexDoomMap::GetSunColor() const
|
||||
{
|
||||
if(mapDef != NULL)
|
||||
{
|
||||
|
@ -629,7 +629,7 @@ const kexVec3 &kexDoomMap::GetSunColor(void) const
|
|||
// kexDoomMap::GetSunDirection
|
||||
//
|
||||
|
||||
const kexVec3 &kexDoomMap::GetSunDirection(void) const
|
||||
const kexVec3 &kexDoomMap::GetSunDirection() const
|
||||
{
|
||||
if(mapDef != NULL)
|
||||
{
|
||||
|
@ -748,7 +748,7 @@ void kexDoomMap::ParseConfigFile(const char *file)
|
|||
|
||||
if(lexer->Matches("surfaceLight"))
|
||||
{
|
||||
surfaceLightDef_t surfaceLight;
|
||||
surfaceLightDef surfaceLight;
|
||||
|
||||
surfaceLight.tag = 0;
|
||||
surfaceLight.outerCone = 1.0f;
|
||||
|
@ -822,7 +822,7 @@ void kexDoomMap::ParseConfigFile(const char *file)
|
|||
// kexDoomMap::CreateLights
|
||||
//
|
||||
|
||||
void kexDoomMap::CreateLights(void)
|
||||
void kexDoomMap::CreateLights()
|
||||
{
|
||||
mapThing_t *thing;
|
||||
thingLight_t *thingLight;
|
||||
|
@ -891,7 +891,7 @@ void kexDoomMap::CreateLights(void)
|
|||
|
||||
for(unsigned int k = 0; k < surfaceLightDefs.Length(); ++k)
|
||||
{
|
||||
surfaceLightDef_t *surfaceLightDef = &surfaceLightDefs[k];
|
||||
surfaceLightDef *surfaceLightDef = &surfaceLightDefs[k];
|
||||
|
||||
if(surface->type >= ST_MIDDLESEG && surface->type <= ST_LOWERSEG)
|
||||
{
|
||||
|
@ -948,7 +948,7 @@ void kexDoomMap::CreateLights(void)
|
|||
// kexDoomMap::CleanupThingLights
|
||||
//
|
||||
|
||||
void kexDoomMap::CleanupThingLights(void)
|
||||
void kexDoomMap::CleanupThingLights()
|
||||
{
|
||||
for(unsigned int i = 0; i < thingLights.Length(); i++)
|
||||
{
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
// distribution.
|
||||
//
|
||||
|
||||
#ifndef __MAPDATA_H__
|
||||
#define __MAPDATA_H__
|
||||
#pragma once
|
||||
|
||||
#include "wad.h"
|
||||
#include "surfaces.h"
|
||||
|
@ -44,22 +43,22 @@ enum
|
|||
BOXRIGHT
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum mapFlags_t
|
||||
{
|
||||
ML_BLOCKING = 1, // Solid, is an obstacle.
|
||||
ML_BLOCKMONSTERS = 2, // Blocks monsters only.
|
||||
ML_TWOSIDED = 4, // Backside will not be present at all if not two sided.
|
||||
ML_TRANSPARENT1 = 2048, // 25% or 75% transcluency?
|
||||
ML_TRANSPARENT2 = 4096 // 25% or 75% transcluency?
|
||||
} mapFlags_t;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct mapVertex_t
|
||||
{
|
||||
short x;
|
||||
short y;
|
||||
} mapVertex_t;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct mapSideDef_t
|
||||
{
|
||||
short textureoffset;
|
||||
short rowoffset;
|
||||
|
@ -67,9 +66,9 @@ typedef struct
|
|||
char bottomtexture[8];
|
||||
char midtexture[8];
|
||||
short sector;
|
||||
} mapSideDef_t;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct mapLineDef_t
|
||||
{
|
||||
short v1;
|
||||
short v2;
|
||||
|
@ -77,9 +76,9 @@ typedef struct
|
|||
short special;
|
||||
short tag;
|
||||
short sidenum[2]; // sidenum[1] will be -1 if one sided
|
||||
} mapLineDef_t;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct mapSector_t
|
||||
{
|
||||
short floorheight;
|
||||
short ceilingheight;
|
||||
|
@ -88,9 +87,9 @@ typedef struct
|
|||
short lightlevel;
|
||||
short special;
|
||||
short tag;
|
||||
} mapSector_t;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct mapNode_t
|
||||
{
|
||||
// Partition line from (x,y) to x+dx,y+dy)
|
||||
short x;
|
||||
|
@ -105,9 +104,9 @@ typedef struct
|
|||
// If NF_SUBSECTOR its a subsector,
|
||||
// else it's a node of another subtree.
|
||||
word children[2];
|
||||
} mapNode_t;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct mapSeg_t
|
||||
{
|
||||
word v1;
|
||||
word v2;
|
||||
|
@ -115,51 +114,51 @@ typedef struct
|
|||
word linedef;
|
||||
short side;
|
||||
short offset;
|
||||
} mapSeg_t;
|
||||
};
|
||||
|
||||
typedef struct mapSubSector_s
|
||||
struct mapSubSector_t
|
||||
{
|
||||
word numsegs;
|
||||
word firstseg;
|
||||
} mapSubSector_t;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct mapThing_t
|
||||
{
|
||||
short x;
|
||||
short y;
|
||||
short angle;
|
||||
short type;
|
||||
short options;
|
||||
} mapThing_t;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct glVert_t
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
} glVert_t;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct glSeg_t
|
||||
{
|
||||
word v1;
|
||||
word v2;
|
||||
word linedef;
|
||||
int16_t side;
|
||||
word partner;
|
||||
} glSeg_t;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct vertex_t
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
} vertex_t;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct leaf_t
|
||||
{
|
||||
vertex_t *vertex;
|
||||
glSeg_t *seg;
|
||||
} leaf_t;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct lightDef_t
|
||||
{
|
||||
int doomednum;
|
||||
float height;
|
||||
|
@ -168,17 +167,17 @@ typedef struct
|
|||
float falloff;
|
||||
bool bCeiling;
|
||||
kexVec3 rgb;
|
||||
} lightDef_t;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct mapDef_t
|
||||
{
|
||||
int map;
|
||||
int sunIgnoreTag;
|
||||
kexVec3 sunDir;
|
||||
kexVec3 sunColor;
|
||||
} mapDef_t;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct thingLight_t
|
||||
{
|
||||
mapThing_t *mapThing;
|
||||
kexVec2 origin;
|
||||
|
@ -190,13 +189,13 @@ typedef struct
|
|||
bool bCeiling;
|
||||
mapSector_t *sector;
|
||||
mapSubSector_t *ssect;
|
||||
} thingLight_t;
|
||||
};
|
||||
|
||||
class kexDoomMap
|
||||
{
|
||||
public:
|
||||
kexDoomMap(void);
|
||||
~kexDoomMap(void);
|
||||
kexDoomMap();
|
||||
~kexDoomMap();
|
||||
|
||||
void BuildMapFromWad(kexWadFile &wadFile);
|
||||
mapSideDef_t *GetSideDef(const glSeg_t *seg);
|
||||
|
@ -205,17 +204,16 @@ public:
|
|||
mapSector_t *GetSectorFromSubSector(const mapSubSector_t *sub);
|
||||
mapSubSector_t *PointInSubSector(const int x, const int y);
|
||||
bool PointInsideSubSector(const float x, const float y, const mapSubSector_t *sub);
|
||||
bool LineIntersectSubSector(const kexVec3 &start, const kexVec3 &end,
|
||||
const mapSubSector_t *sub, kexVec2 &out);
|
||||
bool LineIntersectSubSector(const kexVec3 &start, const kexVec3 &end, const mapSubSector_t *sub, kexVec2 &out);
|
||||
vertex_t *GetSegVertex(int index);
|
||||
bool CheckPVS(mapSubSector_t *s1, mapSubSector_t *s2);
|
||||
|
||||
void ParseConfigFile(const char *file);
|
||||
void CreateLights(void);
|
||||
void CleanupThingLights(void);
|
||||
void CreateLights();
|
||||
void CleanupThingLights();
|
||||
|
||||
const kexVec3 &GetSunColor(void) const;
|
||||
const kexVec3 &GetSunDirection(void) const;
|
||||
const kexVec3 &GetSunColor() const;
|
||||
const kexVec3 &GetSunDirection() const;
|
||||
|
||||
mapThing_t *mapThings;
|
||||
mapLineDef_t *mapLines;
|
||||
|
@ -257,14 +255,14 @@ public:
|
|||
kexArray<kexLightSurface*> lightSurfaces;
|
||||
|
||||
private:
|
||||
void BuildLeafs(void);
|
||||
void BuildNodeBounds(void);
|
||||
void CheckSkySectors(void);
|
||||
void BuildLeafs();
|
||||
void BuildNodeBounds();
|
||||
void CheckSkySectors();
|
||||
void BuildVertexes(kexWadFile &wadFile);
|
||||
void BuildPVS(void);
|
||||
void BuildPVS();
|
||||
|
||||
kexArray<lightDef_t> lightDefs;
|
||||
kexArray<surfaceLightDef_t> surfaceLightDefs;
|
||||
kexArray<surfaceLightDef> surfaceLightDefs;
|
||||
kexArray<mapDef_t> mapDefs;
|
||||
|
||||
mapDef_t *mapDef;
|
||||
|
@ -272,5 +270,3 @@ private:
|
|||
static const kexVec3 defaultSunColor;
|
||||
static const kexVec3 defaultSunDirection;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,10 +25,11 @@
|
|||
// distribution.
|
||||
//
|
||||
|
||||
#ifndef __SURFACES_H__
|
||||
#define __SURFACES_H__
|
||||
#pragma once
|
||||
|
||||
typedef enum
|
||||
struct mapSubSector_t;
|
||||
|
||||
enum surfaceType_t
|
||||
{
|
||||
ST_UNKNOWN = 0,
|
||||
ST_MIDDLESEG,
|
||||
|
@ -36,14 +37,14 @@ typedef enum
|
|||
ST_LOWERSEG,
|
||||
ST_CEILING,
|
||||
ST_FLOOR
|
||||
} surfaceType_t;
|
||||
};
|
||||
|
||||
typedef kexArray<kexVec3> vertexBatch_t;
|
||||
|
||||
// convert from fixed point(FRACUNIT) to floating point
|
||||
#define F(x) (((float)(x))/65536.0f)
|
||||
|
||||
typedef struct
|
||||
struct surface_t
|
||||
{
|
||||
kexPlane plane;
|
||||
int lightmapNum;
|
||||
|
@ -60,8 +61,8 @@ typedef struct
|
|||
int typeIndex;
|
||||
void *data;
|
||||
bool bSky;
|
||||
struct mapSubSector_s *subSector;
|
||||
} surface_t;
|
||||
mapSubSector_t *subSector;
|
||||
};
|
||||
|
||||
extern kexArray<surface_t*> surfaces;
|
||||
|
||||
|
@ -69,5 +70,3 @@ class kexDoomMap;
|
|||
class kexWadFile;
|
||||
|
||||
void Surface_AllocateFromMap(kexDoomMap &doomMap);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
// kexTrace::kexTrace
|
||||
//
|
||||
|
||||
kexTrace::kexTrace(void)
|
||||
kexTrace::kexTrace()
|
||||
{
|
||||
this->map = NULL;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ kexTrace::kexTrace(void)
|
|||
// kexTrace::~kexTrace
|
||||
//
|
||||
|
||||
kexTrace::~kexTrace(void)
|
||||
kexTrace::~kexTrace()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -25,16 +25,15 @@
|
|||
// distribution.
|
||||
//
|
||||
|
||||
#ifndef __TRACE_H__
|
||||
#define __TRACE_H__
|
||||
#pragma once
|
||||
|
||||
class kexDoomMap;
|
||||
|
||||
class kexTrace
|
||||
{
|
||||
public:
|
||||
kexTrace(void);
|
||||
~kexTrace(void);
|
||||
kexTrace();
|
||||
~kexTrace();
|
||||
|
||||
void Init(kexDoomMap &doomMap);
|
||||
void Trace(const kexVec3 &startVec, const kexVec3 &endVec);
|
||||
|
@ -55,5 +54,3 @@ private:
|
|||
kexDoomMap *map;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
// kexWadFile::~kexWadFile
|
||||
//
|
||||
|
||||
kexWadFile::~kexWadFile(void)
|
||||
kexWadFile::~kexWadFile()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ void kexWadFile::Write(const char *fileName)
|
|||
// kexWadFile::Close
|
||||
//
|
||||
|
||||
void kexWadFile::Close(void)
|
||||
void kexWadFile::Close()
|
||||
{
|
||||
if(file.Opened())
|
||||
{
|
||||
|
@ -225,7 +225,7 @@ lump_t *kexWadFile::GetGLMapLump(glMapLumps_t lumpID)
|
|||
// kexWadFile::InitForWrite
|
||||
//
|
||||
|
||||
void kexWadFile::InitForWrite(void)
|
||||
void kexWadFile::InitForWrite()
|
||||
{
|
||||
header.id[0] = 'P';
|
||||
header.id[1] = 'W';
|
||||
|
@ -317,7 +317,7 @@ void kexWadFile::AddLump(const char *name, const int size, byte *data)
|
|||
// kexWadFile::CreateBackup
|
||||
//
|
||||
|
||||
void kexWadFile::CreateBackup(void)
|
||||
void kexWadFile::CreateBackup()
|
||||
{
|
||||
kexStr backupName = wadName;
|
||||
|
||||
|
|
|
@ -25,12 +25,11 @@
|
|||
// distribution.
|
||||
//
|
||||
|
||||
#ifndef __WAD_H__
|
||||
#define __WAD_H__
|
||||
#pragma once
|
||||
|
||||
#include "kexlib/binFile.h"
|
||||
|
||||
typedef enum
|
||||
enum mapLumps_t
|
||||
{
|
||||
ML_HEADER = 0,
|
||||
ML_THINGS,
|
||||
|
@ -45,9 +44,9 @@ typedef enum
|
|||
ML_BLOCKMAP,
|
||||
ML_LIGHTMAP,
|
||||
ML_NUMLUMPS
|
||||
} mapLumps_t;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum glMapLumps_t
|
||||
{
|
||||
ML_GL_LABEL = 0, // A separator name, GL_ExMx or GL_MAPxx
|
||||
ML_GL_VERTS, // Extra Vertices
|
||||
|
@ -55,9 +54,9 @@ typedef enum
|
|||
ML_GL_SSECT, // SubSectors, list of segs
|
||||
ML_GL_NODES, // GL BSP nodes
|
||||
ML_GL_PVS // PVS portals
|
||||
} glMapLumps_t;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum lmMapLumps_t
|
||||
{
|
||||
ML_LM_LABEL = 0,
|
||||
ML_LM_CELLS,
|
||||
|
@ -65,30 +64,30 @@ typedef enum
|
|||
ML_LM_SURFS,
|
||||
ML_LM_TXCRD,
|
||||
ML_LM_LMAPS
|
||||
} lmMapLumps_t;
|
||||
};
|
||||
|
||||
#define gNd2 0x32644E67
|
||||
|
||||
#define GL_VERT_OFFSET 4
|
||||
|
||||
typedef struct
|
||||
struct wadHeader_t
|
||||
{
|
||||
char id[4];
|
||||
int lmpcount;
|
||||
int lmpdirpos;
|
||||
} wadHeader_t;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct lump_t
|
||||
{
|
||||
int filepos;
|
||||
int size;
|
||||
char name[8];
|
||||
} lump_t;
|
||||
};
|
||||
|
||||
class kexWadFile
|
||||
{
|
||||
public:
|
||||
~kexWadFile(void);
|
||||
~kexWadFile();
|
||||
|
||||
wadHeader_t header;
|
||||
lump_t *lumps;
|
||||
|
@ -106,9 +105,9 @@ public:
|
|||
void SetCurrentMap(const int map);
|
||||
bool Open(const char *fileName);
|
||||
void Write(const char *fileName);
|
||||
void Close(void);
|
||||
void CreateBackup(void);
|
||||
void InitForWrite(void);
|
||||
void Close();
|
||||
void CreateBackup();
|
||||
void InitForWrite();
|
||||
void CopyLumpsFromWadFile(kexWadFile &wadFile);
|
||||
void CopyLumpsFromWadFile(kexWadFile &wadFile, kexArray<int> &lumpIgnoreList);
|
||||
void AddLump(const char *name, const int size, byte *data);
|
||||
|
@ -160,5 +159,3 @@ private:
|
|||
kexArray<lump_t> writeLumpList;
|
||||
kexArray<byte*> writeDataList;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -69,7 +69,7 @@ void *WorkThread(void *p)
|
|||
// kexWorker::kexWorker
|
||||
//
|
||||
|
||||
kexWorker::kexWorker(void)
|
||||
kexWorker::kexWorker()
|
||||
{
|
||||
this->numWorkLoad = 0;
|
||||
this->jobsWorked = 0;
|
||||
|
@ -82,7 +82,7 @@ kexWorker::kexWorker(void)
|
|||
// kexWorker::~kexWorker
|
||||
//
|
||||
|
||||
kexWorker::~kexWorker(void)
|
||||
kexWorker::~kexWorker()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ kexWorker::~kexWorker(void)
|
|||
// kexWorker::LockMutex
|
||||
//
|
||||
|
||||
void kexWorker::LockMutex(void)
|
||||
void kexWorker::LockMutex()
|
||||
{
|
||||
mutex.lock();
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ void kexWorker::LockMutex(void)
|
|||
// kexWorker::UnlockMutex
|
||||
//
|
||||
|
||||
void kexWorker::UnlockMutex(void)
|
||||
void kexWorker::UnlockMutex()
|
||||
{
|
||||
mutex.unlock();
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ void kexWorker::UnlockMutex(void)
|
|||
// kexWorker::Destroy
|
||||
//
|
||||
|
||||
void kexWorker::Destroy(void)
|
||||
void kexWorker::Destroy()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ void Delay(int ms)
|
|||
// GetSeconds
|
||||
//
|
||||
|
||||
const int64_t GetSeconds(void)
|
||||
const int64_t GetSeconds()
|
||||
{
|
||||
return time(0);
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ const int64_t GetSeconds(void)
|
|||
// FilePath
|
||||
//
|
||||
|
||||
const kexStr &FilePath(void)
|
||||
const kexStr &FilePath()
|
||||
{
|
||||
return basePath;
|
||||
}
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
// distribution.
|
||||
//
|
||||
|
||||
#ifndef __WORKER_H__
|
||||
#define __WORKER_H__
|
||||
#pragma once
|
||||
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
|
@ -37,30 +36,30 @@ class kexWorker;
|
|||
|
||||
typedef void(*jobFunc_t)(void*, int);
|
||||
|
||||
typedef struct
|
||||
struct jobFuncArgs_t
|
||||
{
|
||||
kexWorker *worker;
|
||||
void *data;
|
||||
int jobID;
|
||||
} jobFuncArgs_t;
|
||||
};
|
||||
|
||||
class kexWorker
|
||||
{
|
||||
public:
|
||||
kexWorker(void);
|
||||
~kexWorker(void);
|
||||
kexWorker();
|
||||
~kexWorker();
|
||||
|
||||
void RunThreads(const int count, void *data, jobFunc_t jobFunc);
|
||||
void LockMutex(void);
|
||||
void UnlockMutex(void);
|
||||
void Destroy(void);
|
||||
void LockMutex();
|
||||
void UnlockMutex();
|
||||
void Destroy();
|
||||
|
||||
bool FinishedAllJobs(void) { return jobsWorked == numWorkLoad; }
|
||||
int DispatchJob(void) { int j = jobsWorked; jobsWorked++; return j; }
|
||||
bool FinishedAllJobs() { return jobsWorked == numWorkLoad; }
|
||||
int DispatchJob() { int j = jobsWorked; jobsWorked++; return j; }
|
||||
void RunJob(void *data, const int jobID) { job(data, jobID); }
|
||||
|
||||
jobFuncArgs_t *Args(const int id) { return &jobArgs[id]; }
|
||||
const int JobsWorked(void) const { return jobsWorked; }
|
||||
const int JobsWorked() const { return jobsWorked; }
|
||||
|
||||
static int maxWorkThreads;
|
||||
|
||||
|
@ -72,5 +71,3 @@ private:
|
|||
int jobsWorked;
|
||||
int numWorkLoad;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -50,8 +50,8 @@
|
|||
|
||||
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
|
||||
|
||||
static void SC_PrepareScript (void);
|
||||
static void CheckOpen (void);
|
||||
static void SC_PrepareScript ();
|
||||
static void CheckOpen ();
|
||||
|
||||
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
|
||||
|
||||
|
@ -107,7 +107,7 @@ void SC_OpenMem (const char *name, char *buffer, int len)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void SC_PrepareScript (void)
|
||||
static void SC_PrepareScript ()
|
||||
{
|
||||
ScriptPtr = ScriptBuffer;
|
||||
ScriptEndPtr = ScriptPtr + ScriptSize;
|
||||
|
@ -126,7 +126,7 @@ static void SC_PrepareScript (void)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void SC_Close (void)
|
||||
void SC_Close ()
|
||||
{
|
||||
if (ScriptOpen)
|
||||
{
|
||||
|
@ -143,7 +143,7 @@ void SC_Close (void)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void SC_SavePos (void)
|
||||
void SC_SavePos ()
|
||||
{
|
||||
CheckOpen ();
|
||||
if (sc_End)
|
||||
|
@ -165,7 +165,7 @@ void SC_SavePos (void)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void SC_RestorePos (void)
|
||||
void SC_RestorePos ()
|
||||
{
|
||||
if (SavedScriptPtr)
|
||||
{
|
||||
|
@ -367,7 +367,7 @@ gottoken:
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void SC_MustGetString (void)
|
||||
void SC_MustGetString ()
|
||||
{
|
||||
if (SC_GetString () == false)
|
||||
{
|
||||
|
@ -417,7 +417,7 @@ bool SC_CheckString (const char *name)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
bool SC_GetNumber (void)
|
||||
bool SC_GetNumber ()
|
||||
{
|
||||
char *stopper;
|
||||
|
||||
|
@ -451,7 +451,7 @@ bool SC_GetNumber (void)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void SC_MustGetNumber (void)
|
||||
void SC_MustGetNumber ()
|
||||
{
|
||||
if (SC_GetNumber() == false)
|
||||
{
|
||||
|
@ -467,7 +467,7 @@ void SC_MustGetNumber (void)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
bool SC_CheckNumber (void)
|
||||
bool SC_CheckNumber ()
|
||||
{
|
||||
char *stopper;
|
||||
|
||||
|
@ -503,7 +503,7 @@ bool SC_CheckNumber (void)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
bool SC_CheckFloat (void)
|
||||
bool SC_CheckFloat ()
|
||||
{
|
||||
char *stopper;
|
||||
|
||||
|
@ -532,7 +532,7 @@ bool SC_CheckFloat (void)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
bool SC_GetFloat (void)
|
||||
bool SC_GetFloat ()
|
||||
{
|
||||
char *stopper;
|
||||
|
||||
|
@ -559,7 +559,7 @@ bool SC_GetFloat (void)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void SC_MustGetFloat (void)
|
||||
void SC_MustGetFloat ()
|
||||
{
|
||||
if (SC_GetFloat() == false)
|
||||
{
|
||||
|
@ -575,7 +575,7 @@ void SC_MustGetFloat (void)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void SC_UnGet (void)
|
||||
void SC_UnGet ()
|
||||
{
|
||||
AlreadyGot = true;
|
||||
}
|
||||
|
@ -589,7 +589,7 @@ void SC_UnGet (void)
|
|||
//==========================================================================
|
||||
|
||||
/*
|
||||
bool SC_Check(void)
|
||||
bool SC_Check()
|
||||
{
|
||||
char *text;
|
||||
|
||||
|
@ -704,7 +704,7 @@ void SC_ScriptError (const char *message, ...)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void CheckOpen(void)
|
||||
static void CheckOpen()
|
||||
{
|
||||
if (ScriptOpen == false)
|
||||
{
|
||||
|
|
|
@ -5,23 +5,23 @@ void SC_Open (const char *name);
|
|||
void SC_OpenFile (const char *name);
|
||||
void SC_OpenMem (const char *name, char *buffer, int size);
|
||||
void SC_OpenLumpNum (int lump, const char *name);
|
||||
void SC_Close (void);
|
||||
void SC_Close ();
|
||||
void SC_SetCMode (bool cmode);
|
||||
void SC_SetEscape (bool esc);
|
||||
void SC_SavePos (void);
|
||||
void SC_RestorePos (void);
|
||||
bool SC_GetString (void);
|
||||
void SC_MustGetString (void);
|
||||
void SC_SavePos ();
|
||||
void SC_RestorePos ();
|
||||
bool SC_GetString ();
|
||||
void SC_MustGetString ();
|
||||
void SC_MustGetStringName (const char *name);
|
||||
bool SC_CheckString (const char *name);
|
||||
bool SC_GetNumber (void);
|
||||
void SC_MustGetNumber (void);
|
||||
bool SC_CheckNumber (void);
|
||||
bool SC_CheckFloat (void);
|
||||
bool SC_GetFloat (void);
|
||||
void SC_MustGetFloat (void);
|
||||
void SC_UnGet (void);
|
||||
//boolean SC_Check(void);
|
||||
bool SC_GetNumber ();
|
||||
void SC_MustGetNumber ();
|
||||
bool SC_CheckNumber ();
|
||||
bool SC_CheckFloat ();
|
||||
bool SC_GetFloat ();
|
||||
void SC_MustGetFloat ();
|
||||
void SC_UnGet ();
|
||||
//boolean SC_Check();
|
||||
bool SC_Compare (const char *text);
|
||||
int SC_MatchString (const char **strings);
|
||||
int SC_MustMatchString (const char **strings);
|
||||
|
|
Loading…
Reference in a new issue