Skip to content

Commit

Permalink
added vector.Rotate lua binding
Browse files Browse the repository at this point in the history
  • Loading branch information
turanszkij committed Feb 8, 2024
1 parent c774af4 commit efcb078
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions Content/Documentation/ScriptingAPI-Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ A four component floating point vector. Provides efficient calculations with SIM
- Dot(Vector v1,v2) : Vector result
- Cross(Vector v1,v2) : Vector result
- Lerp(Vector v1,v2, float t) : Vector result
- Rotate(Vector v1,quaternion) : Vector result -- rotates the first argument 3D vector with the second argument quaternion
- QuaternionInverse(Vector quaternion) : Vector resultQuaternion
- QuaternionMultiply(Vector quaternion1,quaternion2) : Vector resultQuaternion
- QuaternionFromRollPitchYaw(Vector rotXYZ) : Vector resultQuaternion
Expand Down
17 changes: 17 additions & 0 deletions WickedEngine/wiMath_BindLua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace wi::lua
lunamethod(Vector_BindLua, Dot),
lunamethod(Vector_BindLua, Cross),
lunamethod(Vector_BindLua, Lerp),
lunamethod(Vector_BindLua, Rotate),
lunamethod(Vector_BindLua, QuaternionSlerp),
lunamethod(Vector_BindLua, Slerp),
lunamethod(Vector_BindLua, Clamp),
Expand Down Expand Up @@ -407,6 +408,22 @@ namespace wi::lua
wi::lua::SError(L, "Lerp(Vector v1,v2, float t) not enough arguments!");
return 0;
}
int Vector_BindLua::Rotate(lua_State* L)
{
int argc = wi::lua::SGetArgCount(L);
if (argc > 1)
{
Vector_BindLua* v1 = Luna<Vector_BindLua>::lightcheck(L, 1);
Vector_BindLua* v2 = Luna<Vector_BindLua>::lightcheck(L, 2);
if (v1 && v2)
{
Luna<Vector_BindLua>::push(L, XMVector3Rotate(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data)));
return 1;
}
}
wi::lua::SError(L, "Rotate(Vector v1,quaternion) not enough arguments!");
return 0;
}


int Vector_BindLua::QuaternionInverse(lua_State* L)
Expand Down
1 change: 1 addition & 0 deletions WickedEngine/wiMath_BindLua.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ namespace wi::lua
int Add(lua_State* L);
int Subtract(lua_State* L);
int Lerp(lua_State* L);
int Rotate(lua_State* L);


int QuaternionInverse(lua_State* L);
Expand Down

0 comments on commit efcb078

Please sign in to comment.