Browse Source

Exposed IsPowerOfTwo(), NextPowerOfTwo() and SDBMHash() to script.

Lasse Öörni 11 years ago
parent
commit
4080f024c5

+ 3 - 0
Source/Engine/LuaScript/pkgs/Math/MathDefs.pkg

@@ -31,6 +31,9 @@ float Clamp(float value, float min, float max);
 float SmoothStep(float lhs, float rhs, float t);
 float SmoothStep(float lhs, float rhs, float t);
 bool Equals(float lhs, float rhs);
 bool Equals(float lhs, float rhs);
 bool IsNaN(float value);
 bool IsNaN(float value);
+bool IsPowerOfTwo(unsigned value);
+unsigned NextPowerOfTwo(unsigned value);
+unsigned SDBMHash(unsigned hash, unsigned char c);
 
 
 float Random();
 float Random();
 float Random(float range);
 float Random(float range);

+ 3 - 0
Source/Engine/Script/MathAPI.cpp

@@ -77,6 +77,9 @@ static void RegisterMathFunctions(asIScriptEngine* engine)
     engine->RegisterGlobalFunction("float Mod(float, float)", asFUNCTION(fmodf), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Mod(float, float)", asFUNCTION(fmodf), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Floor(float)", asFUNCTION(floorf), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Floor(float)", asFUNCTION(floorf), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Ceil(float)", asFUNCTION(ceilf), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Ceil(float)", asFUNCTION(ceilf), asCALL_CDECL);
+    engine->RegisterGlobalFunction("bool IsPowerOfTwo(uint)", asFUNCTION(IsPowerOfTwo), asCALL_CDECL);
+    engine->RegisterGlobalFunction("uint NextPowerOfTwo(uint)", asFUNCTION(NextPowerOfTwo), asCALL_CDECL);
+    engine->RegisterGlobalFunction("uint SDBMHash(uint, uint8)", asFUNCTION(SDBMHash), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Random()", asFUNCTIONPR(Random, (), float), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Random()", asFUNCTIONPR(Random, (), float), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Random(float)", asFUNCTIONPR(Random, (float), float), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Random(float)", asFUNCTIONPR(Random, (float), float), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Random(float, float)", asFUNCTIONPR(Random, (float, float), float), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Random(float, float)", asFUNCTIONPR(Random, (float, float), float), asCALL_CDECL);