Skip to content

Commit

Permalink
Fix CVector optional arguments - #3738 (#3782)
Browse files Browse the repository at this point in the history
  • Loading branch information
TracerDS authored Dec 21, 2024
1 parent aa90aa5 commit 6a70cf7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
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{};
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

0 comments on commit 6a70cf7

Please sign in to comment.