Utility.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _UTILITY_H_
  23. #define _UTILITY_H_
  24. #ifndef _SIMBASE_H_
  25. #include "sim/simBase.h"
  26. #endif
  27. #ifndef _PLATFORM_H_
  28. #include "platform/platform.h"
  29. #endif
  30. #ifndef _PLATFORMGL_H_
  31. #include "platform/platformGL.h"
  32. #endif
  33. #ifndef _MMATH_H_
  34. #include "math/mMath.h"
  35. #endif
  36. //-----------------------------------------------------------------------------
  37. // Miscellaneous Defines.
  38. //-----------------------------------------------------------------------------
  39. #define MASK_ALL (U32_MAX)
  40. #define MASK_BITCOUNT (32)
  41. #define DEBUG_MODE_COUNT (8)
  42. #define MAX_LAYERS_SUPPORTED (32)
  43. #define CANNOT_RENDER_PROXY_NAME "CannotRenderProxy"
  44. #define b2_pi2 (b2_pi * 2.0f)
  45. //-----------------------------------------------------------------------------
  46. class SceneObject;
  47. struct Vector2;
  48. typedef Vector<SceneObject*> typeSceneObjectVector;
  49. typedef const Vector<SceneObject*>& typeSceneObjectVectorConstRef;
  50. ///-----------------------------------------------------------------------------
  51. DefineConsoleType( Typeb2AABB )
  52. //-----------------------------------------------------------------------------
  53. namespace Utility
  54. {
  55. //-----------------------------------------------------------------------------
  56. #define STATIC_VOID_CAST_TO( pointerType, castToType, obj ) static_cast<castToType*>( reinterpret_cast<pointerType*>(obj) )
  57. #define DYNAMIC_VOID_CAST_TO( pointerType, castToType, obj ) dynamic_cast<castToType*>( reinterpret_cast<pointerType*>(obj) )
  58. //-----------------------------------------------------------------------------
  59. /// String helpers.
  60. const char* mGetFirstNonWhitespace( const char* inString );
  61. Vector2 mGetStringElementVector( const char* inString, const U32 index = 0 );
  62. VectorF mGetStringElementVector3D( const char* inString, const U32 index = 0 );
  63. const char* mGetStringElement( const char* inString, const U32 index, const bool copyBuffer = true );
  64. U32 mGetStringElementCount( const char *string );
  65. U32 mConvertStringToMask( const char* string );
  66. const char* mConvertMaskToString( const U32 mask );
  67. } // Namespace Utility.
  68. #endif // _UTILITY_H_