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