Polyphase Game Engine
Loading...
Searching...
No Matches
Utilities.h File Reference
#include <vector>
#include <string>
#include <Bullet/btBulletDynamicsCommon.h>
#include "Property.h"
#include "EngineTypes.h"
#include "Maths.h"

Go to the source code of this file.

Macros

#define OCT_ARRAY_SIZE(array)   (int(sizeof(array) / sizeof(array[0])))
 
#define OCT_UNUSED(var)   (void)var
 
#define FORCE_LINK_DEF(x)   int gForceLink_##x = 0;
 
#define FORCE_LINK_CALL(x)   { extern int gForceLink_##x; gForceLink_##x = 1; }
 

Functions

Platform GetPlatform ()
 
bool IsPlatformConsole (Platform platform)
 
std::string StringToLower (const std::string &str)
 
std::string StringToUpper (const std::string &str)
 
std::string GetCurrentDirectoryPath ()
 
void SetWorkingDirectory (const std::string &dirPath)
 
bool DoesDirExist (const char *dirPath)
 
void CreateDir (const char *dirPath)
 
void RemoveDir (const char *dirPath)
 
std::string GetDirShortName (const std::string &dirName)
 
void CreateSymLink (const std::string &original, const std::string &link)
 
btCollisionShape * CloneCollisionShape (const btCollisionShape *srcShape)
 
void DestroyCollisionShape (btCollisionShape *shape)
 
void DebugDrawCollisionShape (btCollisionShape *collisionShape, Node3D *node, const glm::mat4 &parentTransform, std::vector< DebugDraw > *inoutDraws=nullptr)
 
uint32_t OctHashString (const char *key)
 
void GatherAllNodeNames (std::vector< std::string > &outNames)
 
PropertyFindProperty (std::vector< Property > &props, const std::string &name)
 
void CopyPropertyValues (std::vector< Property > &dstProps, const std::vector< Property > &srcProps)
 
uint32_t GetStringSerializationSize (const std::string &str)
 
const char * GetPlatformString (Platform platform)
 
uint8_t ConvertKeyCodeToChar (uint8_t keyCode, bool shiftDown)
 
glm::mat4 MakeTransform (glm::vec3 translation, glm::vec3 rotation, glm::vec3 scale)
 
btTransform MakeBulletTransform (glm::vec3 translation, glm::vec3 rotationDegrees)
 
void GatherNonDefaultProperties (Node *node, std::vector< Property > &props, NodePtr refNode=nullptr)
 
void GatherSubSceneOverrides (Node *node, Node *sceneRoot, std::vector< SubSceneOverride > &overs)
 
void ApplySubSceneOverride (Node *sceneRoot, const SubSceneOverride &over)
 
void RemoveSpacesFromString (std::string &str)
 
void AddDebugDraw (const DebugDraw &draw)
 
void AddDebugDraw (StaticMesh *mesh, glm::vec3 position, glm::quat rotation, glm::vec3 scale, glm::vec4 color={ 0.25f, 0.25f, 1.0f, 1.0f }, float life=0.0f, Material *material=nullptr)
 
void AddDebugDraw (StaticMesh *mesh, glm::vec3 position, glm::vec3 rotation, glm::vec3 scale, glm::vec4 color={ 0.25f, 0.25f, 1.0f, 1.0f }, float life=0.0f, Material *material=nullptr)
 
void CreateTableLua (lua_State *L, const Datum &datum)
 
void CreateTableCpp (lua_State *L, int tableIdx, Datum &datum)
 
void LuaPushDatum (lua_State *L, const Datum &arg)
 
Datum LuaObjectToDatum (lua_State *L, int idx)
 
void LuaObjectToDatum (lua_State *L, int idx, Datum &datum)
 
glm::vec3 EnforceEulerRange (const glm::vec3 &eulerAngles)
 
glm::vec3 BulletToGlm (const btVector3 &vector3)
 
glm::quat BulletToGlm (const btQuaternion &quat)
 
btVector3 GlmToBullet (const glm::vec3 &vector3)
 
btQuaternion GlmToBullet (const glm::quat &quat)
 
uint32_t ColorFloat4ToUint32 (glm::vec4 color)
 
glm::vec4 ColorUint32ToFloat4 (uint32_t color)
 
void ReverseColorUint32 (uint32_t &color)
 
template<typename T >
Bounds ComputeBounds (const std::vector< T > &vertices)
 
template<typename T >
void ShuffleVector (std::vector< T > &vect)
 
bool EndsWith (const std::string &str, const std::string &suffix)
 

Macro Definition Documentation

◆ FORCE_LINK_CALL

#define FORCE_LINK_CALL (   x)    { extern int gForceLink_##x; gForceLink_##x = 1; }

◆ FORCE_LINK_DEF

#define FORCE_LINK_DEF (   x)    int gForceLink_##x = 0;

◆ OCT_ARRAY_SIZE

#define OCT_ARRAY_SIZE (   array)    (int(sizeof(array) / sizeof(array[0])))

◆ OCT_UNUSED

#define OCT_UNUSED (   var)    (void)var

Function Documentation

◆ AddDebugDraw() [1/3]

void AddDebugDraw ( const DebugDraw draw)

◆ AddDebugDraw() [2/3]

void AddDebugDraw ( StaticMesh mesh,
glm::vec3  position,
glm::quat  rotation,
glm::vec3  scale,
glm::vec4  color = { 0.25f, 0.25f, 1.0f, 1.0f },
float  life = 0.0f,
Material material = nullptr 
)

◆ AddDebugDraw() [3/3]

void AddDebugDraw ( StaticMesh mesh,
glm::vec3  position,
glm::vec3  rotation,
glm::vec3  scale,
glm::vec4  color = { 0.25f, 0.25f, 1.0f, 1.0f },
float  life = 0.0f,
Material material = nullptr 
)

◆ ApplySubSceneOverride()

void ApplySubSceneOverride ( Node sceneRoot,
const SubSceneOverride over 
)

◆ BulletToGlm() [1/2]

glm::quat BulletToGlm ( const btQuaternion &  quat)
inline

◆ BulletToGlm() [2/2]

glm::vec3 BulletToGlm ( const btVector3 &  vector3)
inline

◆ CloneCollisionShape()

btCollisionShape * CloneCollisionShape ( const btCollisionShape *  srcShape)

◆ ColorFloat4ToUint32()

uint32_t ColorFloat4ToUint32 ( glm::vec4  color)
inline

◆ ColorUint32ToFloat4()

glm::vec4 ColorUint32ToFloat4 ( uint32_t  color)
inline

◆ ComputeBounds()

template<typename T >
Bounds ComputeBounds ( const std::vector< T > &  vertices)

◆ ConvertKeyCodeToChar()

uint8_t ConvertKeyCodeToChar ( uint8_t  keyCode,
bool  shiftDown 
)

◆ CopyPropertyValues()

void CopyPropertyValues ( std::vector< Property > &  dstProps,
const std::vector< Property > &  srcProps 
)

◆ CreateDir()

void CreateDir ( const char *  dirPath)

◆ CreateSymLink()

void CreateSymLink ( const std::string &  original,
const std::string &  link 
)

◆ CreateTableCpp()

void CreateTableCpp ( lua_State *  L,
int  tableIdx,
Datum datum 
)

◆ CreateTableLua()

void CreateTableLua ( lua_State *  L,
const Datum datum 
)

◆ DebugDrawCollisionShape()

void DebugDrawCollisionShape ( btCollisionShape *  collisionShape,
Node3D node,
const glm::mat4 &  parentTransform,
std::vector< DebugDraw > *  inoutDraws = nullptr 
)

◆ DestroyCollisionShape()

void DestroyCollisionShape ( btCollisionShape *  shape)

◆ DoesDirExist()

bool DoesDirExist ( const char *  dirPath)

◆ EndsWith()

bool EndsWith ( const std::string &  str,
const std::string &  suffix 
)
inline

◆ EnforceEulerRange()

glm::vec3 EnforceEulerRange ( const glm::vec3 &  eulerAngles)

◆ FindProperty()

Property * FindProperty ( std::vector< Property > &  props,
const std::string &  name 
)

◆ GatherAllNodeNames()

void GatherAllNodeNames ( std::vector< std::string > &  outNames)

◆ GatherNonDefaultProperties()

void GatherNonDefaultProperties ( Node node,
std::vector< Property > &  props,
NodePtr  refNode = nullptr 
)

◆ GatherSubSceneOverrides()

void GatherSubSceneOverrides ( Node node,
Node sceneRoot,
std::vector< SubSceneOverride > &  overs 
)

◆ GetCurrentDirectoryPath()

std::string GetCurrentDirectoryPath ( )

◆ GetDirShortName()

std::string GetDirShortName ( const std::string &  dirName)

◆ GetPlatform()

Platform GetPlatform ( )

◆ GetPlatformString()

const char * GetPlatformString ( Platform  platform)

◆ GetStringSerializationSize()

uint32_t GetStringSerializationSize ( const std::string &  str)

◆ GlmToBullet() [1/2]

btQuaternion GlmToBullet ( const glm::quat &  quat)
inline

◆ GlmToBullet() [2/2]

btVector3 GlmToBullet ( const glm::vec3 &  vector3)
inline

◆ IsPlatformConsole()

bool IsPlatformConsole ( Platform  platform)

◆ LuaObjectToDatum() [1/2]

Datum LuaObjectToDatum ( lua_State *  L,
int  idx 
)

◆ LuaObjectToDatum() [2/2]

void LuaObjectToDatum ( lua_State *  L,
int  idx,
Datum datum 
)

◆ LuaPushDatum()

void LuaPushDatum ( lua_State *  L,
const Datum arg 
)

◆ MakeBulletTransform()

btTransform MakeBulletTransform ( glm::vec3  translation,
glm::vec3  rotationDegrees 
)

◆ MakeTransform()

glm::mat4 MakeTransform ( glm::vec3  translation,
glm::vec3  rotation,
glm::vec3  scale 
)

◆ OctHashString()

uint32_t OctHashString ( const char *  key)

◆ RemoveDir()

void RemoveDir ( const char *  dirPath)

◆ RemoveSpacesFromString()

void RemoveSpacesFromString ( std::string &  str)

◆ ReverseColorUint32()

void ReverseColorUint32 ( uint32_t &  color)
inline

◆ SetWorkingDirectory()

void SetWorkingDirectory ( const std::string &  dirPath)

◆ ShuffleVector()

template<typename T >
void ShuffleVector ( std::vector< T > &  vect)

◆ StringToLower()

std::string StringToLower ( const std::string &  str)

◆ StringToUpper()

std::string StringToUpper ( const std::string &  str)