RegisterMath.cpp 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. //
  2. // Urho3D Engine
  3. // Copyright (c) 2008-2011 Lasse Öörni
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. #include "Precompiled.h"
  24. #include "Frustum.h"
  25. #include "StringUtils.h"
  26. #include <angelscript.h>
  27. static float Sin(float angle)
  28. {
  29. return sinf(angle * M_DEGTORAD);
  30. }
  31. static float Cos(float angle)
  32. {
  33. return cosf(angle * M_DEGTORAD);
  34. }
  35. static float Tan(float angle)
  36. {
  37. return tanf(angle * M_DEGTORAD);
  38. }
  39. static float ASin(float x)
  40. {
  41. return M_RADTODEG * asinf(clamp(x, -1.0f, 1.0f));
  42. }
  43. static float ACos(float x)
  44. {
  45. return M_RADTODEG * acosf(clamp(x, -1.0f, 1.0f));
  46. }
  47. static float ATan(float x)
  48. {
  49. return M_RADTODEG * atanf(x);
  50. }
  51. static float ATan2(float y, float x)
  52. {
  53. return M_RADTODEG * atan2f(y, x);
  54. }
  55. static void registerMathFunctions(asIScriptEngine* engine)
  56. {
  57. engine->RegisterGlobalFunction("float sin(float)", asFUNCTION(Sin), asCALL_CDECL);
  58. engine->RegisterGlobalFunction("float cos(float)", asFUNCTION(Cos), asCALL_CDECL);
  59. engine->RegisterGlobalFunction("float tan(float)", asFUNCTION(Tan), asCALL_CDECL);
  60. engine->RegisterGlobalFunction("float asin(float)", asFUNCTION(ASin), asCALL_CDECL);
  61. engine->RegisterGlobalFunction("float acos(float)", asFUNCTION(ACos), asCALL_CDECL);
  62. engine->RegisterGlobalFunction("float atan(float)", asFUNCTION(ATan), asCALL_CDECL);
  63. engine->RegisterGlobalFunction("float atan2(float, float)", asFUNCTION(ATan2), asCALL_CDECL);
  64. engine->RegisterGlobalFunction("float abs(float)", asFUNCTION(fabsf), asCALL_CDECL);
  65. engine->RegisterGlobalFunction("float sqrt(float)", asFUNCTION(sqrtf), asCALL_CDECL);
  66. engine->RegisterGlobalFunction("float pow(float)", asFUNCTION(powf), asCALL_CDECL);
  67. engine->RegisterGlobalFunction("float random()", asFUNCTIONPR(random, (), float), asCALL_CDECL);
  68. engine->RegisterGlobalFunction("float random(float)", asFUNCTIONPR(random, (float), float), asCALL_CDECL);
  69. engine->RegisterGlobalFunction("int randomInt()", asFUNCTION(rand), asCALL_CDECL);
  70. engine->RegisterGlobalFunction("int randomInt(int)", asFUNCTIONPR(random, (int), int), asCALL_CDECL);
  71. engine->RegisterGlobalFunction("void setRandomSeed(int)", asFUNCTION(srand), asCALL_CDECL);
  72. engine->RegisterGlobalFunction("float min(float, float)", asFUNCTIONPR(min, (float, float), float), asCALL_CDECL);
  73. engine->RegisterGlobalFunction("float max(float, float)", asFUNCTIONPR(max, (float, float), float), asCALL_CDECL);
  74. engine->RegisterGlobalFunction("float clamp(float, float, float)", asFUNCTIONPR(clamp, (float, float, float), float), asCALL_CDECL);
  75. engine->RegisterGlobalFunction("float lerp(float, float, float)", asFUNCTIONPR(lerp, (float, float, float), float), asCALL_CDECL);
  76. }
  77. static void ConstructIntRect(IntRect* ptr)
  78. {
  79. // Init to zero because performance is not critical
  80. new(ptr) IntRect(IntRect::sZero);
  81. }
  82. static void ConstructIntRectCopy(const IntRect& rect, IntRect* ptr)
  83. {
  84. new(ptr) IntRect(rect);
  85. }
  86. static void ConstructIntRectInit(int left, int top, int right, int bottom, IntRect* ptr)
  87. {
  88. new(ptr) IntRect(left, top, right, bottom);
  89. }
  90. static void registerIntRect(asIScriptEngine* engine)
  91. {
  92. engine->RegisterObjectType("IntRect", sizeof(IntRect), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CA);
  93. engine->RegisterObjectBehaviour("IntRect", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructIntRect), asCALL_CDECL_OBJLAST);
  94. engine->RegisterObjectBehaviour("IntRect", asBEHAVE_CONSTRUCT, "void f(const IntRect& in)", asFUNCTION(ConstructIntRectCopy), asCALL_CDECL_OBJLAST);
  95. engine->RegisterObjectBehaviour("IntRect", asBEHAVE_CONSTRUCT, "void f(int, int, int, int)", asFUNCTION(ConstructIntRectInit), asCALL_CDECL_OBJLAST);
  96. engine->RegisterObjectMethod("IntRect", "IntRect &opAssign(const IntRect& in)", asMETHOD(IntRect, operator =), asCALL_THISCALL);
  97. engine->RegisterObjectMethod("IntRect", "bool &opEquals(const IntRect& in) const", asMETHOD(IntRect, operator ==), asCALL_THISCALL);
  98. engine->RegisterObjectProperty("IntRect", "int left", offsetof(IntRect, mLeft));
  99. engine->RegisterObjectProperty("IntRect", "int top", offsetof(IntRect, mTop));
  100. engine->RegisterObjectProperty("IntRect", "int right", offsetof(IntRect, mRight));
  101. engine->RegisterObjectProperty("IntRect", "int bottom", offsetof(IntRect, mBottom));
  102. }
  103. static void ConstructIntVector2(IntVector2* ptr)
  104. {
  105. // Init to zero because performance is not critical
  106. new(ptr) IntVector2(IntVector2::sZero);
  107. }
  108. static void ConstructIntVector2Copy(const IntVector2& vector, IntVector2* ptr)
  109. {
  110. new(ptr) IntVector2(vector);
  111. }
  112. static void ConstructIntVector2Init(int x, int y, IntVector2* ptr)
  113. {
  114. new(ptr) IntVector2(x, y);
  115. }
  116. static void registerIntVector2(asIScriptEngine* engine)
  117. {
  118. engine->RegisterObjectType("IntVector2", sizeof(IntVector2), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CA);
  119. engine->RegisterObjectBehaviour("IntVector2", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructIntVector2), asCALL_CDECL_OBJLAST);
  120. engine->RegisterObjectBehaviour("IntVector2", asBEHAVE_CONSTRUCT, "void f(const IntVector2& in)", asFUNCTION(ConstructIntVector2Copy), asCALL_CDECL_OBJLAST);
  121. engine->RegisterObjectBehaviour("IntVector2", asBEHAVE_CONSTRUCT, "void f(int, int)", asFUNCTION(ConstructIntVector2Init), asCALL_CDECL_OBJLAST);
  122. engine->RegisterObjectMethod("IntVector2", "IntVector2 &opAssign(const IntVector2& in)", asMETHOD(IntVector2, operator =), asCALL_THISCALL);
  123. engine->RegisterObjectMethod("IntVector2", "IntVector2 &opAddAssign(const IntVector2& in)", asMETHOD(IntVector2, operator +=), asCALL_THISCALL);
  124. engine->RegisterObjectMethod("IntVector2", "IntVector2 &opSubAssign(const IntVector2& in)", asMETHOD(IntVector2, operator -=), asCALL_THISCALL);
  125. engine->RegisterObjectMethod("IntVector2", "IntVector2 &opMulAssign(int)", asMETHODPR(IntVector2, operator *=, (int), IntVector2&), asCALL_THISCALL);
  126. engine->RegisterObjectMethod("IntVector2", "IntVector2 &opDivAssign(int)", asMETHODPR(IntVector2, operator /=, (int), IntVector2&), asCALL_THISCALL);
  127. engine->RegisterObjectMethod("IntVector2", "bool &opEquals(const IntVector2& in) const", asMETHOD(IntVector2, operator ==), asCALL_THISCALL);
  128. engine->RegisterObjectMethod("IntVector2", "IntVector2 opNeg() const", asMETHODPR(IntVector2, operator -, () const, IntVector2), asCALL_THISCALL);
  129. engine->RegisterObjectMethod("IntVector2", "IntVector2 opAdd(const IntVector2& in) const", asMETHOD(IntVector2, operator +), asCALL_THISCALL);
  130. engine->RegisterObjectMethod("IntVector2", "IntVector2 opSub(const IntVector2& in) const", asMETHODPR(IntVector2, operator -, (const IntVector2&) const, IntVector2), asCALL_THISCALL);
  131. engine->RegisterObjectMethod("IntVector2", "IntVector2 opMul(int) const", asMETHODPR(IntVector2, operator *, (int) const, IntVector2), asCALL_THISCALL);
  132. engine->RegisterObjectMethod("IntVector2", "IntVector2 opDiv(int) const", asMETHODPR(IntVector2, operator /, (int) const, IntVector2), asCALL_THISCALL);
  133. engine->RegisterObjectMethod("IntVector2", "string toString() const", asFUNCTIONPR(toString, (const IntVector2&), std::string), asCALL_CDECL_OBJLAST);
  134. engine->RegisterObjectProperty("IntVector2", "int x", offsetof(IntVector2, mX));
  135. engine->RegisterObjectProperty("IntVector2", "int y", offsetof(IntVector2, mY));
  136. }
  137. static void ConstructVector2(Vector2* ptr)
  138. {
  139. // Init to zero because performance is not critical
  140. new(ptr) Vector2(Vector2::sZero);
  141. }
  142. static void ConstructVector2Copy(const Vector2& vector, Vector2* ptr)
  143. {
  144. new(ptr) Vector2(vector);
  145. }
  146. static void ConstructVector2Init(float x, float y, Vector2* ptr)
  147. {
  148. new(ptr) Vector2(x, y);
  149. }
  150. static void registerVector2(asIScriptEngine* engine)
  151. {
  152. engine->RegisterObjectType("Vector2", sizeof(Vector2), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CA);
  153. engine->RegisterObjectBehaviour("Vector2", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructVector2), asCALL_CDECL_OBJLAST);
  154. engine->RegisterObjectBehaviour("Vector2", asBEHAVE_CONSTRUCT, "void f(const Vector2& in)", asFUNCTION(ConstructVector2Copy), asCALL_CDECL_OBJLAST);
  155. engine->RegisterObjectBehaviour("Vector2", asBEHAVE_CONSTRUCT, "void f(float, float)", asFUNCTION(ConstructVector2Init), asCALL_CDECL_OBJLAST);
  156. engine->RegisterObjectMethod("Vector2", "Vector2 &opAssign(const Vector2& in)", asMETHOD(Vector2, operator =), asCALL_THISCALL);
  157. engine->RegisterObjectMethod("Vector2", "Vector2 &opAddAssign(const Vector2& in)", asMETHOD(Vector2, operator +=), asCALL_THISCALL);
  158. engine->RegisterObjectMethod("Vector2", "Vector2 &opSubAssign(const Vector2& in)", asMETHOD(Vector2, operator -=), asCALL_THISCALL);
  159. engine->RegisterObjectMethod("Vector2", "Vector2 &opMulAssign(const Vector2& in)", asMETHODPR(Vector2, operator *=, (const Vector2&), Vector2&), asCALL_THISCALL);
  160. engine->RegisterObjectMethod("Vector2", "Vector2 &opMulAssign(float)", asMETHODPR(Vector2, operator *=, (float), Vector2&), asCALL_THISCALL);
  161. engine->RegisterObjectMethod("Vector2", "Vector2 &opDivAssign(const Vector2& in)", asMETHODPR(Vector2, operator /=, (const Vector2&), Vector2&), asCALL_THISCALL);
  162. engine->RegisterObjectMethod("Vector2", "Vector2 &opDivAssign(float)", asMETHODPR(Vector2, operator /=, (float), Vector2&), asCALL_THISCALL);
  163. engine->RegisterObjectMethod("Vector2", "bool &opEquals(const Vector2& in) const", asMETHOD(Vector2, operator ==), asCALL_THISCALL);
  164. engine->RegisterObjectMethod("Vector2", "Vector2 opNeg() const", asMETHODPR(Vector2, operator -, () const, Vector2), asCALL_THISCALL);
  165. engine->RegisterObjectMethod("Vector2", "Vector2 opAdd(const Vector2& in) const", asMETHOD(Vector2, operator +), asCALL_THISCALL);
  166. engine->RegisterObjectMethod("Vector2", "Vector2 opSub(const Vector2& in) const", asMETHODPR(Vector2, operator -, (const Vector2&) const, Vector2), asCALL_THISCALL);
  167. engine->RegisterObjectMethod("Vector2", "Vector2 opMul(const Vector2& in) const", asMETHODPR(Vector2, operator *, (const Vector2&) const, Vector2), asCALL_THISCALL);
  168. engine->RegisterObjectMethod("Vector2", "Vector2 opMul(float) const", asMETHODPR(Vector2, operator *, (float) const, Vector2), asCALL_THISCALL);
  169. engine->RegisterObjectMethod("Vector2", "Vector2 opDiv(const Vector2& in) const", asMETHODPR(Vector2, operator /, (const Vector2&) const, Vector2), asCALL_THISCALL);
  170. engine->RegisterObjectMethod("Vector2", "Vector2 opDiv(float) const", asMETHODPR(Vector2, operator /, (float) const, Vector2), asCALL_THISCALL);
  171. engine->RegisterObjectMethod("Vector2", "float normalize()", asMETHOD(Vector2, normalize), asCALL_THISCALL);
  172. engine->RegisterObjectMethod("Vector2", "float getLength() const", asMETHOD(Vector2, getLength), asCALL_THISCALL);
  173. engine->RegisterObjectMethod("Vector2", "float getLengthSquared() const", asMETHOD(Vector2, getLengthSquared), asCALL_THISCALL);
  174. engine->RegisterObjectMethod("Vector2", "float dotProduct(const Vector2& in) const", asMETHOD(Vector2, dotProduct), asCALL_THISCALL);
  175. engine->RegisterObjectMethod("Vector2", "float absDotProduct(const Vector2& in) const", asMETHOD(Vector2, absDotProduct), asCALL_THISCALL);
  176. engine->RegisterObjectMethod("Vector2", "Vector2 lerp(const Vector2& in, float) const", asMETHOD(Vector2, lerp), asCALL_THISCALL);
  177. engine->RegisterObjectMethod("Vector2", "Vector2 getNormalized() const", asMETHOD(Vector2, getNormalized), asCALL_THISCALL);
  178. engine->RegisterObjectMethod("Vector2", "string toString() const", asFUNCTIONPR(toString, (const Vector2&), std::string), asCALL_CDECL_OBJLAST);
  179. engine->RegisterObjectProperty("Vector2", "float x", offsetof(Vector2, mX));
  180. engine->RegisterObjectProperty("Vector2", "float y", offsetof(Vector2, mY));
  181. }
  182. static void ConstructVector3(Vector3* ptr)
  183. {
  184. // Init to zero because performance is not critical
  185. new(ptr) Vector3(Vector3::sZero);
  186. }
  187. static void ConstructVector3Copy(const Vector3& vector, Vector3* ptr)
  188. {
  189. new(ptr) Vector3(vector);
  190. }
  191. static void ConstructVector3Init(float x, float y, float z, Vector3* ptr)
  192. {
  193. new(ptr) Vector3(x, y, z);
  194. }
  195. static void registerVector3(asIScriptEngine* engine)
  196. {
  197. engine->RegisterObjectType("Vector3", sizeof(Vector3), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CA);
  198. engine->RegisterObjectBehaviour("Vector3", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructVector3), asCALL_CDECL_OBJLAST);
  199. engine->RegisterObjectBehaviour("Vector3", asBEHAVE_CONSTRUCT, "void f(const Vector3& in)", asFUNCTION(ConstructVector3Copy), asCALL_CDECL_OBJLAST);
  200. engine->RegisterObjectBehaviour("Vector3", asBEHAVE_CONSTRUCT, "void f(float, float, float)", asFUNCTION(ConstructVector3Init), asCALL_CDECL_OBJLAST);
  201. engine->RegisterObjectMethod("Vector3", "Vector3 &opAssign(const Vector3& in)", asMETHOD(Vector3, operator =), asCALL_THISCALL);
  202. engine->RegisterObjectMethod("Vector3", "Vector3 &opAddAssign(const Vector3& in)", asMETHOD(Vector3, operator +=), asCALL_THISCALL);
  203. engine->RegisterObjectMethod("Vector3", "Vector3 &opSubAssign(const Vector3& in)", asMETHOD(Vector3, operator -=), asCALL_THISCALL);
  204. engine->RegisterObjectMethod("Vector3", "Vector3 &opMulAssign(const Vector3& in)", asMETHODPR(Vector3, operator *=, (const Vector3&), Vector3&), asCALL_THISCALL);
  205. engine->RegisterObjectMethod("Vector3", "Vector3 &opMulAssign(float)", asMETHODPR(Vector3, operator *=, (float), Vector3&), asCALL_THISCALL);
  206. engine->RegisterObjectMethod("Vector3", "Vector3 &opDivAssign(const Vector3& in)", asMETHODPR(Vector3, operator /=, (const Vector3&), Vector3&), asCALL_THISCALL);
  207. engine->RegisterObjectMethod("Vector3", "Vector3 &opDivAssign(float)", asMETHODPR(Vector3, operator /=, (float), Vector3&), asCALL_THISCALL);
  208. engine->RegisterObjectMethod("Vector3", "bool &opEquals(const Vector3& in) const", asMETHOD(Vector3, operator ==), asCALL_THISCALL);
  209. engine->RegisterObjectMethod("Vector3", "Vector3 opNeg() const", asMETHODPR(Vector3, operator -, () const, Vector3), asCALL_THISCALL);
  210. engine->RegisterObjectMethod("Vector3", "Vector3 opAdd(const Vector3& in) const", asMETHOD(Vector3, operator +), asCALL_THISCALL);
  211. engine->RegisterObjectMethod("Vector3", "Vector3 opSub(const Vector3& in) const", asMETHODPR(Vector3, operator -, (const Vector3&) const, Vector3), asCALL_THISCALL);
  212. engine->RegisterObjectMethod("Vector3", "Vector3 opMul(const Vector3& in) const", asMETHODPR(Vector3, operator *, (const Vector3&) const, Vector3), asCALL_THISCALL);
  213. engine->RegisterObjectMethod("Vector3", "Vector3 opMul(float) const", asMETHODPR(Vector3, operator *, (float) const, Vector3), asCALL_THISCALL);
  214. engine->RegisterObjectMethod("Vector3", "Vector3 opDiv(const Vector3& in) const", asMETHODPR(Vector3, operator /, (const Vector3&) const, Vector3), asCALL_THISCALL);
  215. engine->RegisterObjectMethod("Vector3", "Vector3 opDiv(float) const", asMETHODPR(Vector3, operator /, (float) const, Vector3), asCALL_THISCALL);
  216. engine->RegisterObjectMethod("Vector3", "float normalize()", asMETHOD(Vector3, normalize), asCALL_THISCALL);
  217. engine->RegisterObjectMethod("Vector3", "float getLength() const", asMETHOD(Vector3, getLength), asCALL_THISCALL);
  218. engine->RegisterObjectMethod("Vector3", "float getLengthSquared() const", asMETHOD(Vector3, getLengthSquared), asCALL_THISCALL);
  219. engine->RegisterObjectMethod("Vector3", "float dotProduct(const Vector3& in) const", asMETHOD(Vector3, dotProduct), asCALL_THISCALL);
  220. engine->RegisterObjectMethod("Vector3", "float absDotProduct(const Vector3& in) const", asMETHOD(Vector3, absDotProduct), asCALL_THISCALL);
  221. engine->RegisterObjectMethod("Vector3", "Vector3 crossProduct(const Vector3& in) const", asMETHOD(Vector3, crossProduct), asCALL_THISCALL);
  222. engine->RegisterObjectMethod("Vector3", "Vector3 lerp(const Vector3& in, float) const", asMETHOD(Vector3, lerp), asCALL_THISCALL);
  223. engine->RegisterObjectMethod("Vector3", "Vector3 getNormalized() const", asMETHOD(Vector3, getNormalized), asCALL_THISCALL);
  224. engine->RegisterObjectMethod("Vector3", "string toString() const", asFUNCTIONPR(toString, (const Vector3&), std::string), asCALL_CDECL_OBJLAST);
  225. engine->RegisterObjectProperty("Vector3", "float x", offsetof(Vector3, mX));
  226. engine->RegisterObjectProperty("Vector3", "float y", offsetof(Vector3, mY));
  227. engine->RegisterObjectProperty("Vector3", "float z", offsetof(Vector3, mZ));
  228. }
  229. static void ConstructVector4(Vector4* ptr)
  230. {
  231. // Init to zero because performance is not critical
  232. new(ptr) Vector4(Vector4::sZero);
  233. }
  234. static void ConstructVector4Copy(const Vector4& vector, Vector4* ptr)
  235. {
  236. new(ptr) Vector4(vector);
  237. }
  238. static void ConstructVector4Init(float x, float y, float z, float w, Vector4* ptr)
  239. {
  240. new(ptr) Vector4(x, y, z, w);
  241. }
  242. static void registerVector4(asIScriptEngine* engine)
  243. {
  244. engine->RegisterObjectType("Vector4", sizeof(Vector4), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CA);
  245. engine->RegisterObjectBehaviour("Vector4", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructVector4), asCALL_CDECL_OBJLAST);
  246. engine->RegisterObjectBehaviour("Vector4", asBEHAVE_CONSTRUCT, "void f(const Vector4& in)", asFUNCTION(ConstructVector4Copy), asCALL_CDECL_OBJLAST);
  247. engine->RegisterObjectBehaviour("Vector4", asBEHAVE_CONSTRUCT, "void f(float, float, float)", asFUNCTION(ConstructVector4Init), asCALL_CDECL_OBJLAST);
  248. engine->RegisterObjectMethod("Vector4", "Vector4 &opAssign(const Vector4& in)", asMETHOD(Vector4, operator =), asCALL_THISCALL);
  249. engine->RegisterObjectMethod("Vector4", "Vector4 &opAddAssign(const Vector4& in)", asMETHOD(Vector4, operator +=), asCALL_THISCALL);
  250. engine->RegisterObjectMethod("Vector4", "Vector4 &opSubAssign(const Vector4& in)", asMETHOD(Vector4, operator -=), asCALL_THISCALL);
  251. engine->RegisterObjectMethod("Vector4", "Vector4 &opMulAssign(const Vector4& in)", asMETHODPR(Vector4, operator *=, (const Vector4&), Vector4&), asCALL_THISCALL);
  252. engine->RegisterObjectMethod("Vector4", "Vector4 &opMulAssign(float)", asMETHODPR(Vector4, operator *=, (float), Vector4&), asCALL_THISCALL);
  253. engine->RegisterObjectMethod("Vector4", "Vector4 &opDivAssign(const Vector4& in)", asMETHODPR(Vector4, operator /=, (const Vector4&), Vector4&), asCALL_THISCALL);
  254. engine->RegisterObjectMethod("Vector4", "Vector4 &opDivAssign(float)", asMETHODPR(Vector4, operator /=, (float), Vector4&), asCALL_THISCALL);
  255. engine->RegisterObjectMethod("Vector4", "bool &opEquals(const Vector4& in) const", asMETHOD(Vector4, operator ==), asCALL_THISCALL);
  256. engine->RegisterObjectMethod("Vector4", "Vector4 opNeg() const", asMETHODPR(Vector4, operator -, () const, Vector4), asCALL_THISCALL);
  257. engine->RegisterObjectMethod("Vector4", "Vector4 opAdd(const Vector4& in) const", asMETHOD(Vector4, operator +), asCALL_THISCALL);
  258. engine->RegisterObjectMethod("Vector4", "Vector4 opSub(const Vector4& in) const", asMETHODPR(Vector4, operator -, (const Vector4&) const, Vector4), asCALL_THISCALL);
  259. engine->RegisterObjectMethod("Vector4", "Vector4 opMul(const Vector4& in) const", asMETHODPR(Vector4, operator *, (const Vector4&) const, Vector4), asCALL_THISCALL);
  260. engine->RegisterObjectMethod("Vector4", "Vector4 opMul(float) const", asMETHODPR(Vector4, operator *, (float) const, Vector4), asCALL_THISCALL);
  261. engine->RegisterObjectMethod("Vector4", "Vector4 opDiv(const Vector4& in) const", asMETHODPR(Vector4, operator /, (const Vector4&) const, Vector4), asCALL_THISCALL);
  262. engine->RegisterObjectMethod("Vector4", "Vector4 opDiv(float) const", asMETHODPR(Vector4, operator /, (float) const, Vector4), asCALL_THISCALL);
  263. engine->RegisterObjectMethod("Vector4", "float dotProduct(const Vector4& in) const", asMETHOD(Vector4, dotProduct), asCALL_THISCALL);
  264. engine->RegisterObjectMethod("Vector4", "float absDotProduct(const Vector4& in) const", asMETHOD(Vector4, absDotProduct), asCALL_THISCALL);
  265. engine->RegisterObjectMethod("Vector4", "Vector4 lerp(const Vector4& in, float) const", asMETHOD(Vector4, lerp), asCALL_THISCALL);
  266. engine->RegisterObjectMethod("Vector4", "string toString() const", asFUNCTIONPR(toString, (const Vector4&), std::string), asCALL_CDECL_OBJLAST);
  267. engine->RegisterObjectProperty("Vector4", "float x", offsetof(Vector4, mX));
  268. engine->RegisterObjectProperty("Vector4", "float y", offsetof(Vector4, mY));
  269. engine->RegisterObjectProperty("Vector4", "float z", offsetof(Vector4, mZ));
  270. engine->RegisterObjectProperty("Vector4", "float w", offsetof(Vector4, mW));
  271. }
  272. static void ConstructQuaternion(Quaternion* ptr)
  273. {
  274. new(ptr) Quaternion();
  275. }
  276. static void ConstructQuaternionCopy(const Quaternion& quat, Quaternion* ptr)
  277. {
  278. new(ptr) Quaternion(quat);
  279. }
  280. static void ConstructQuaternionInit(float w, float x, float y, float z, Quaternion* ptr)
  281. {
  282. new(ptr) Quaternion(w, x, y, z);
  283. }
  284. static void ConstructQuaternionAngleAxis(float angle, const Vector3& axis, Quaternion* ptr)
  285. {
  286. new(ptr) Quaternion(angle, axis);
  287. }
  288. static void ConstructQuaternionEuler(float angleX, float angleY, float angleZ, Quaternion* ptr)
  289. {
  290. new(ptr) Quaternion(angleX, angleY, angleZ);
  291. }
  292. static void ConstructQuaternionRotation(const Vector3& start, const Vector3& end, Quaternion* ptr)
  293. {
  294. new(ptr) Quaternion(start, end);
  295. }
  296. static void registerQuaternion(asIScriptEngine* engine)
  297. {
  298. engine->RegisterObjectType("Quaternion", sizeof(Quaternion), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CA);
  299. engine->RegisterObjectBehaviour("Quaternion", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructQuaternion), asCALL_CDECL_OBJLAST);
  300. engine->RegisterObjectBehaviour("Quaternion", asBEHAVE_CONSTRUCT, "void f(const Quaternion& in)", asFUNCTION(ConstructQuaternionCopy), asCALL_CDECL_OBJLAST);
  301. engine->RegisterObjectBehaviour("Quaternion", asBEHAVE_CONSTRUCT, "void f(float, float, float, float)", asFUNCTION(ConstructQuaternionInit), asCALL_CDECL_OBJLAST);
  302. engine->RegisterObjectBehaviour("Quaternion", asBEHAVE_CONSTRUCT, "void f(float, const Vector3& in)", asFUNCTION(ConstructQuaternionAngleAxis), asCALL_CDECL_OBJLAST);
  303. engine->RegisterObjectBehaviour("Quaternion", asBEHAVE_CONSTRUCT, "void f(float, float, float)", asFUNCTION(ConstructQuaternionEuler), asCALL_CDECL_OBJLAST);
  304. engine->RegisterObjectBehaviour("Quaternion", asBEHAVE_CONSTRUCT, "void f(const Vector3& in, const Vector3& in)", asFUNCTION(ConstructQuaternionRotation), asCALL_CDECL_OBJLAST);
  305. engine->RegisterObjectMethod("Quaternion", "Quaternion &opAssign(const Quaternion& in)", asMETHOD(Quaternion, operator =), asCALL_THISCALL);
  306. engine->RegisterObjectMethod("Quaternion", "Quaternion &opAddAssign(const Quaternion& in)", asMETHOD(Quaternion, operator +=), asCALL_THISCALL);
  307. engine->RegisterObjectMethod("Quaternion", "bool opEquals(const Quaternion& in) const", asMETHOD(Quaternion, operator ==), asCALL_THISCALL);
  308. engine->RegisterObjectMethod("Quaternion", "Quaternion opMul(float) const", asMETHODPR(Quaternion, operator *, (float) const, Quaternion), asCALL_THISCALL);
  309. engine->RegisterObjectMethod("Quaternion", "Vector3 opMul(const Vector3& in) const", asMETHODPR(Quaternion, operator *, (const Vector3&) const, Vector3), asCALL_THISCALL);
  310. engine->RegisterObjectMethod("Quaternion", "Quaternion opNeg() const", asMETHODPR(Quaternion, operator -, () const, Quaternion), asCALL_THISCALL);
  311. engine->RegisterObjectMethod("Quaternion", "Quaternion opAdd(const Quaternion& in) const", asMETHOD(Quaternion, operator +), asCALL_THISCALL);
  312. engine->RegisterObjectMethod("Quaternion", "Quaternion opSub(const Quaternion& in) const", asMETHODPR(Quaternion, operator +, (const Quaternion&) const, Quaternion), asCALL_THISCALL);
  313. engine->RegisterObjectMethod("Quaternion", "Quaternion opMul(const Quaternion& in) const", asMETHODPR(Quaternion, operator *, (const Quaternion&) const, Quaternion), asCALL_THISCALL);
  314. engine->RegisterObjectMethod("Quaternion", "void normalize()", asMETHOD(Quaternion, normalize), asCALL_THISCALL);
  315. engine->RegisterObjectMethod("Quaternion", "void fromAngleAxis(float, const Vector3& in)", asMETHOD(Quaternion, fromAngleAxis), asCALL_THISCALL);
  316. engine->RegisterObjectMethod("Quaternion", "void fromEulerAngles(float, float, float)", asMETHOD(Quaternion, fromEulerAngles), asCALL_THISCALL);
  317. engine->RegisterObjectMethod("Quaternion", "void fromRotation(const Vector3& in, const Vector3& in)", asMETHOD(Quaternion, fromRotationTo), asCALL_THISCALL);
  318. engine->RegisterObjectMethod("Quaternion", "Quaternion getNormalized() const", asMETHOD(Quaternion, getNormalized), asCALL_THISCALL);
  319. engine->RegisterObjectMethod("Quaternion", "Quaternion getInverse() const", asMETHOD(Quaternion, getInverse), asCALL_THISCALL);
  320. engine->RegisterObjectMethod("Quaternion", "float dotProduct(const Quaternion& in) const", asMETHOD(Quaternion, dotProduct), asCALL_THISCALL);
  321. engine->RegisterObjectMethod("Quaternion", "Quaternion nlerp(const Quaternion& in, float) const", asMETHOD(Quaternion, nlerp), asCALL_THISCALL);
  322. engine->RegisterObjectMethod("Quaternion", "void getEulerAngles(float &out, float &out, float &out) const", asMETHOD(Quaternion, getEulerAngles), asCALL_THISCALL);
  323. engine->RegisterObjectMethod("Quaternion", "float getYaw() const", asMETHOD(Quaternion, getYaw), asCALL_THISCALL);
  324. engine->RegisterObjectMethod("Quaternion", "float getPitch() const", asMETHOD(Quaternion, getPitch), asCALL_THISCALL);
  325. engine->RegisterObjectMethod("Quaternion", "float getRoll() const", asMETHOD(Quaternion, getRoll), asCALL_THISCALL);
  326. engine->RegisterObjectMethod("Quaternion", "Quaternion slerp(const Quaternion& in, float) const", asMETHOD(Quaternion, slerp), asCALL_THISCALL);
  327. engine->RegisterObjectMethod("Quaternion", "string toString() const", asFUNCTIONPR(toString, (const Quaternion&), std::string), asCALL_CDECL_OBJLAST);
  328. engine->RegisterObjectProperty("Quaternion", "float w", offsetof(Quaternion, mW));
  329. engine->RegisterObjectProperty("Quaternion", "float x", offsetof(Quaternion, mX));
  330. engine->RegisterObjectProperty("Quaternion", "float y", offsetof(Quaternion, mY));
  331. engine->RegisterObjectProperty("Quaternion", "float z", offsetof(Quaternion, mZ));
  332. }
  333. static void ConstructRay(Ray* ptr)
  334. {
  335. // Initialize to zero because performance is not critical
  336. new(ptr) Ray(Vector3::sZero, Vector3::sZero);
  337. }
  338. static void ConstructRayCopy(const Ray& ray, Ray* ptr)
  339. {
  340. new(ptr) Ray(ray);
  341. }
  342. static void ConstructRayInit(const Vector3& origin, const Vector3& direction, Ray* ptr)
  343. {
  344. // Normalize direction because performance is not critical
  345. new(ptr) Ray(origin, direction.getNormalized());
  346. }
  347. static void registerRay(asIScriptEngine* engine)
  348. {
  349. engine->RegisterObjectType("Ray", sizeof(Ray), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CA);
  350. engine->RegisterObjectBehaviour("Ray", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructRay), asCALL_CDECL_OBJLAST);
  351. engine->RegisterObjectBehaviour("Ray", asBEHAVE_CONSTRUCT, "void f(const Ray& in)", asFUNCTION(ConstructRayCopy), asCALL_CDECL_OBJLAST);
  352. engine->RegisterObjectBehaviour("Ray", asBEHAVE_CONSTRUCT, "void f(const Vector3& in, const Vector3& in)", asFUNCTION(ConstructRayInit), asCALL_CDECL_OBJLAST);
  353. engine->RegisterObjectMethod("Ray", "Ray &opAssign(const Ray& in)", asMETHOD(Ray, operator =), asCALL_THISCALL);
  354. engine->RegisterObjectMethod("Ray", "bool &opEquals(const Ray& in) const", asMETHOD(Ray, operator ==), asCALL_THISCALL);
  355. engine->RegisterObjectMethod("Ray", "void define(const Vector3& in, const Vector3& in)", asMETHOD(Ray, define), asCALL_THISCALL);
  356. engine->RegisterObjectMethod("Ray", "float getDistance(const Vector3& in, const Vector3& in, const Vector3& in) const", asMETHODPR(Ray, getDistance, (const Vector3&, const Vector3&, const Vector3&) const, float), asCALL_THISCALL);
  357. engine->RegisterObjectProperty("Ray", "Vector3 origin", offsetof(Ray, mOrigin));
  358. engine->RegisterObjectProperty("Ray", "Vector3 direction", offsetof(Ray, mDirection));
  359. }
  360. static void ConstructBoundingBox(BoundingBox* ptr)
  361. {
  362. new(ptr) BoundingBox();
  363. }
  364. static void ConstructBoundingBoxCopy(const BoundingBox& box, BoundingBox* ptr)
  365. {
  366. new(ptr) BoundingBox(box);
  367. }
  368. static void ConstructBoundingBoxInit(const Vector3& min, const Vector3& max, BoundingBox* ptr)
  369. {
  370. new(ptr) BoundingBox(min, max);
  371. }
  372. static void ConstructBoundingBoxFloat(float min, float max, BoundingBox* ptr)
  373. {
  374. new(ptr) BoundingBox(min, max);
  375. }
  376. static void ConstructSphere(Sphere* ptr)
  377. {
  378. new(ptr) Sphere();
  379. }
  380. static void ConstructSphereCopy(const Sphere& sphere, Sphere* ptr)
  381. {
  382. new(ptr) Sphere(sphere);
  383. }
  384. static void ConstructSphereInit(const Vector3& center, float radius, Sphere* ptr)
  385. {
  386. new(ptr) Sphere(center, radius);
  387. }
  388. static void ConstructFrustum(Frustum* ptr)
  389. {
  390. new(ptr) Frustum();
  391. }
  392. static void ConstructFrustumCopy(const Frustum& frustum, Frustum* ptr)
  393. {
  394. new(ptr) Frustum(frustum);
  395. }
  396. static void DestructFrustum(Frustum* ptr)
  397. {
  398. ptr->~Frustum();
  399. }
  400. static Vector3 FrustumGetVertex(unsigned index, Frustum* ptr)
  401. {
  402. if (index >= NUM_FRUSTUM_VERTICES)
  403. return Vector3::sZero;
  404. return ptr->mVertices[index];
  405. }
  406. static void registerVolumes(asIScriptEngine* engine)
  407. {
  408. engine->RegisterEnum("Intersection");
  409. engine->RegisterEnumValue("Intersection", "OUTSIDE", OUTSIDE);
  410. engine->RegisterEnumValue("Intersection", "INTERSECTS", INTERSECTS);
  411. engine->RegisterEnumValue("Intersection", "INSIDE", INSIDE);
  412. engine->RegisterObjectType("BoundingBox", sizeof(BoundingBox), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CA);
  413. engine->RegisterObjectType("Sphere", sizeof(Sphere), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CA);
  414. engine->RegisterObjectType("Frustum", sizeof(Frustum), asOBJ_VALUE | asOBJ_APP_CLASS_CDA);
  415. engine->RegisterObjectBehaviour("BoundingBox", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructBoundingBox), asCALL_CDECL_OBJLAST);
  416. engine->RegisterObjectBehaviour("BoundingBox", asBEHAVE_CONSTRUCT, "void f(const BoundingBox& in)", asFUNCTION(ConstructBoundingBoxCopy), asCALL_CDECL_OBJLAST);
  417. engine->RegisterObjectBehaviour("BoundingBox", asBEHAVE_CONSTRUCT, "void f(const Vector3& in, const Vector3& in)", asFUNCTION(ConstructBoundingBoxInit), asCALL_CDECL_OBJLAST);
  418. engine->RegisterObjectBehaviour("BoundingBox", asBEHAVE_CONSTRUCT, "void f(float, float)", asFUNCTION(ConstructBoundingBoxFloat), asCALL_CDECL_OBJLAST);
  419. engine->RegisterObjectMethod("BoundingBox", "BoundingBox &opAssign(const BoundingBox& in)", asMETHODPR(BoundingBox, operator =, (const BoundingBox&), BoundingBox&), asCALL_THISCALL);
  420. engine->RegisterObjectMethod("BoundingBox", "bool &opEquals(const BoundingBox& in) const", asMETHOD(BoundingBox, operator ==), asCALL_THISCALL);
  421. engine->RegisterObjectMethod("BoundingBox", "void define(const Vector3& in, const Vector3& in)", asMETHODPR(BoundingBox, define, (const Vector3&, const Vector3&), void), asCALL_THISCALL);
  422. engine->RegisterObjectMethod("BoundingBox", "void define(float, float)", asMETHODPR(BoundingBox, define, (float, float), void), asCALL_THISCALL);
  423. engine->RegisterObjectMethod("BoundingBox", "void define(const Frustum& in)", asMETHODPR(BoundingBox, define, (const Frustum&), void), asCALL_THISCALL);
  424. engine->RegisterObjectMethod("BoundingBox", "void define(const Sphere& in)", asMETHODPR(BoundingBox, define, (const Sphere&), void), asCALL_THISCALL);
  425. engine->RegisterObjectMethod("BoundingBox", "void merge(const Vector3& in)", asMETHODPR(BoundingBox, merge, (const Vector3&), void), asCALL_THISCALL);
  426. engine->RegisterObjectMethod("BoundingBox", "void merge(const BoundingBox& in)", asMETHODPR(BoundingBox, merge, (const BoundingBox&), void), asCALL_THISCALL);
  427. engine->RegisterObjectMethod("BoundingBox", "void merge(const Frustum& in)", asMETHODPR(BoundingBox, merge, (const Frustum&), void), asCALL_THISCALL);
  428. engine->RegisterObjectMethod("BoundingBox", "void merge(const Sphere& in)", asMETHODPR(BoundingBox, merge, (const Sphere&), void), asCALL_THISCALL);
  429. engine->RegisterObjectMethod("BoundingBox", "void intersect(const BoundingBox& in)", asMETHODPR(BoundingBox, intersect, (const BoundingBox&), void), asCALL_THISCALL);
  430. engine->RegisterObjectMethod("BoundingBox", "Vector3 getCenter() const", asMETHOD(BoundingBox, getCenter), asCALL_THISCALL);
  431. engine->RegisterObjectMethod("BoundingBox", "Vector3 getSize() const", asMETHOD(BoundingBox, getSize), asCALL_THISCALL);
  432. engine->RegisterObjectMethod("BoundingBox", "Vector3 getHalfSize() const", asMETHOD(BoundingBox, getHalfSize), asCALL_THISCALL);
  433. engine->RegisterObjectMethod("BoundingBox", "Intersection isInside(const Vector3& in) const", asMETHODPR(BoundingBox, isInside, (const Vector3&) const, Intersection), asCALL_THISCALL);
  434. engine->RegisterObjectMethod("BoundingBox", "Intersection isInside(const Sphere& in) const", asMETHODPR(BoundingBox, isInside, (const Sphere&) const, Intersection), asCALL_THISCALL);
  435. engine->RegisterObjectMethod("BoundingBox", "Intersection isInside(const BoundingBox& in) const", asMETHODPR(BoundingBox, isInside, (const BoundingBox&) const, Intersection), asCALL_THISCALL);
  436. engine->RegisterObjectMethod("BoundingBox", "float getDistance(const Ray& in) const", asMETHOD(BoundingBox, getDistance), asCALL_THISCALL);
  437. engine->RegisterObjectProperty("BoundingBox", "Vector3 min", offsetof(BoundingBox, mMin));
  438. engine->RegisterObjectProperty("BoundingBox", "Vector3 max", offsetof(BoundingBox, mMax));
  439. engine->RegisterObjectProperty("BoundingBox", "bool defined", offsetof(BoundingBox, mDefined));
  440. engine->RegisterObjectBehaviour("Sphere", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructSphere), asCALL_CDECL_OBJLAST);
  441. engine->RegisterObjectBehaviour("Sphere", asBEHAVE_CONSTRUCT, "void f(const Sphere& in)", asFUNCTION(ConstructSphereCopy), asCALL_CDECL_OBJLAST);
  442. engine->RegisterObjectBehaviour("Sphere", asBEHAVE_CONSTRUCT, "void f(const Vector3& in, float)", asFUNCTION(ConstructSphereInit), asCALL_CDECL_OBJLAST);
  443. engine->RegisterObjectMethod("Sphere", "Sphere &opAssign(const Sphere& in)", asMETHODPR(Sphere, operator =, (const Sphere&), Sphere&), asCALL_THISCALL);
  444. engine->RegisterObjectMethod("Sphere", "bool &opEquals(const Sphere& in) const", asMETHOD(Sphere, operator ==), asCALL_THISCALL);
  445. engine->RegisterObjectMethod("Sphere", "void define(const Vector3& in, float)", asMETHODPR(Sphere, define, (const Vector3&, float), void), asCALL_THISCALL);
  446. engine->RegisterObjectMethod("Sphere", "void define(const BoundingBox& in)", asMETHODPR(Sphere, define, (const BoundingBox&), void), asCALL_THISCALL);
  447. engine->RegisterObjectMethod("Sphere", "void define(const Frustum& in)", asMETHODPR(Sphere, define, (const Frustum&), void), asCALL_THISCALL);
  448. engine->RegisterObjectMethod("Sphere", "void merge(const Vector3& in)", asMETHODPR(Sphere, merge, (const Vector3&), void), asCALL_THISCALL);
  449. engine->RegisterObjectMethod("Sphere", "void merge(const BoundingBox& in)", asMETHODPR(Sphere, merge, (const BoundingBox&), void), asCALL_THISCALL);
  450. engine->RegisterObjectMethod("Sphere", "void merge(const Frustum& in)", asMETHODPR(Sphere, merge, (const Frustum&), void), asCALL_THISCALL);
  451. engine->RegisterObjectMethod("Sphere", "void merge(const Sphere& in)", asMETHODPR(Sphere, merge, (const Sphere&), void), asCALL_THISCALL);
  452. engine->RegisterObjectMethod("Sphere", "Intersection isInside(const Vector3& in) const", asMETHODPR(Sphere, isInside, (const Vector3&) const, Intersection), asCALL_THISCALL);
  453. engine->RegisterObjectMethod("Sphere", "Intersection isInside(const Sphere& in) const", asMETHODPR(Sphere, isInside, (const Sphere&) const, Intersection), asCALL_THISCALL);
  454. engine->RegisterObjectMethod("Sphere", "Intersection isInside(const BoundingBox& in) const", asMETHODPR(Sphere, isInside, (const BoundingBox&) const, Intersection), asCALL_THISCALL);
  455. engine->RegisterObjectMethod("Sphere", "float getDistance(const Ray& in) const", asMETHOD(Sphere, getDistance), asCALL_THISCALL);
  456. engine->RegisterObjectProperty("Sphere", "Vector3 center", offsetof(Sphere, mCenter));
  457. engine->RegisterObjectProperty("Sphere", "float radius", offsetof(Sphere, mRadius));
  458. engine->RegisterObjectProperty("Sphere", "bool defined", offsetof(Sphere, mDefined));
  459. engine->RegisterObjectBehaviour("Frustum", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructFrustum), asCALL_CDECL_OBJLAST);
  460. engine->RegisterObjectBehaviour("Frustum", asBEHAVE_CONSTRUCT, "void f(const Frustum& in)", asFUNCTION(ConstructFrustumCopy), asCALL_CDECL_OBJLAST);
  461. engine->RegisterObjectBehaviour("Frustum", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(DestructFrustum), asCALL_CDECL_OBJLAST);
  462. engine->RegisterObjectMethod("Frustum", "string &opAssign(const Frustum& in)", asMETHODPR(Frustum, operator =, (const Frustum&), Frustum&), asCALL_THISCALL);
  463. engine->RegisterObjectMethod("Frustum", "Intersection isInside(const Vector3& in)", asMETHODPR(Frustum, isInside, (const Vector3&) const, Intersection), asCALL_THISCALL);
  464. engine->RegisterObjectMethod("Frustum", "Intersection isInside(const BoundingBox& in)", asMETHODPR(Frustum, isInside, (const BoundingBox&) const, Intersection), asCALL_THISCALL);
  465. engine->RegisterObjectMethod("Frustum", "Intersection isInside(const Sphere& in)", asMETHODPR(Frustum, isInside, (const Sphere&) const, Intersection), asCALL_THISCALL);
  466. engine->RegisterObjectProperty("Frustum", "bool defined", offsetof(Frustum, mDefined));
  467. engine->RegisterObjectMethod("Frustum", "Vector3 get_vertices(uint) const", asFUNCTION(FrustumGetVertex), asCALL_CDECL_OBJLAST);
  468. }
  469. void registerMathLibrary(asIScriptEngine* engine)
  470. {
  471. registerMathFunctions(engine);
  472. registerIntRect(engine);
  473. registerIntVector2(engine);
  474. registerVector2(engine);
  475. registerVector3(engine);
  476. registerVector4(engine);
  477. registerQuaternion(engine);
  478. registerRay(engine);
  479. registerVolumes(engine);
  480. }