Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CVector optional arguments - #3738 #3782

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion Client/game_sa/CEntitySA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ bool CEntitySA::GetBonePosition(eBone boneId, CVector& position)
return false;

const RwV3d& pos = rwBoneMatrix->pos;
position = {pos.x, pos.y, pos.z};
position = CVector(pos.x, pos.y, pos.z);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion Shared/mods/deathmatch/logic/lua/CLuaFunctionParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ struct CLuaFunctionParserBase
else if constexpr (std::is_same_v<T, CVector>)
{
if (lua_isnumber(L, index))
return {PopUnsafe<float>(L, index), PopUnsafe<float>(L, index), PopUnsafe<float>(L, index)};
return CVector(PopUnsafe<float>(L, index), PopUnsafe<float>(L, index), PopUnsafe<float>(L, index));

int iType = lua_type(L, index);
bool isLightUserData = iType == LUA_TLIGHTUSERDATA;
Expand Down
13 changes: 6 additions & 7 deletions Shared/sdk/CVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ class CVector
float fY;
float fZ;

struct NoInit{};
TracerDS marked this conversation as resolved.
Show resolved Hide resolved
struct NoInit {};
CVector(NoInit) noexcept {}

CVector(NoInit) {}

constexpr CVector() : fX(0.0f), fY(0.0f), fZ(0.0f) {}

constexpr CVector(float x, float y, float z) : fX(x), fY(y), fZ(z) {}
constexpr CVector() noexcept : fX(0.0f), fY(0.0f), fZ(0.0f) {}

constexpr explicit CVector(float x, float y = 0.0f, float z = 0.0f) noexcept : fX(x), fY(y), fZ(z) {}

constexpr CVector(const CVector4D& vec) noexcept : fX(vec.fX), fY(vec.fY), fZ(vec.fZ) {}

Expand Down Expand Up @@ -187,7 +186,7 @@ class CVector
{
*outVec = *this + vecRay * t;
if (outHitBary) { // Calculate all barycentric coords if necessary
*outHitBary = { 1.f - u - v, u, v }; // For vertices A, B, C [I assume?]
*outHitBary = CVector( 1.f - u - v, u, v ); // For vertices A, B, C [I assume?]
}
return true;
}
Expand Down
Loading