Opcode.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. /*
  3. * OPCODE - Optimized Collision Detection
  4. * Copyright (C) 2001 Pierre Terdiman
  5. * Homepage: http://www.codercorner.com/Opcode.htm
  6. */
  7. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. /**
  10. * Main file for Opcode.dll.
  11. * \file Opcode.cpp
  12. * \author Pierre Terdiman
  13. * \date March, 20, 2001
  14. */
  15. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  16. /*
  17. Finding a good name is difficult!
  18. Here's the draft for this lib.... Spooky, uh?
  19. VOID? Very Optimized Interference Detection
  20. ZOID? Zappy's Optimized Interference Detection
  21. CID? Custom/Clever Interference Detection
  22. AID / ACID! Accurate Interference Detection
  23. QUID? Quick Interference Detection
  24. RIDE? Realtime Interference DEtection
  25. WIDE? Wicked Interference DEtection (....)
  26. GUID!
  27. KID ! k-dop interference detection :)
  28. OPCODE! OPtimized COllision DEtection
  29. */
  30. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  31. // Precompiled Header
  32. #include "Stdafx.h"
  33. using namespace Opcode;
  34. struct ThreadLocalDataAsSingleton:
  35. public ThreadLocalData
  36. {
  37. public:
  38. ThreadLocalDataAsSingleton(): ThreadLocalData(false) {}
  39. void Init() { ThreadLocalData::Init(); }
  40. void Finit() { ThreadLocalData::Finit(); }
  41. };
  42. static ThreadLocalDataAsSingleton g_ThreadLocalDataSingleton;
  43. /*extern */ThreadLocalDataProviderProc g_pfnThreadLocalDataProvider = NULL;
  44. static ThreadLocalData *ProvideThreadLocalDataAsSingleton()
  45. {
  46. return &g_ThreadLocalDataSingleton;
  47. }
  48. bool Opcode::InitOpcode(ThreadLocalDataProviderProc pfnThreadLocalDataProvider)
  49. {
  50. //Log("// Initializing OPCODE\n\n");
  51. // LogAPIInfo();
  52. if (pfnThreadLocalDataProvider)
  53. {
  54. g_pfnThreadLocalDataProvider = pfnThreadLocalDataProvider;
  55. }
  56. else
  57. {
  58. g_ThreadLocalDataSingleton.Init();
  59. g_pfnThreadLocalDataProvider = &ProvideThreadLocalDataAsSingleton;
  60. }
  61. return true;
  62. }
  63. bool Opcode::CloseOpcode()
  64. {
  65. //Log("// Closing OPCODE\n\n");
  66. g_pfnThreadLocalDataProvider = NULL;
  67. g_ThreadLocalDataSingleton.Finit(); // Finit can be safely called without init
  68. return true;
  69. }
  70. #ifdef ICE_MAIN
  71. void ModuleAttach(HINSTANCE hinstance)
  72. {
  73. }
  74. void ModuleDetach()
  75. {
  76. }
  77. #endif