mirror of
https://github.com/DrBeef/Raze.git
synced 2025-02-01 05:20:43 +00:00
- optimized TVector3::XY() to return a writable reference.
This commit is contained in:
parent
48cbdeb697
commit
be2f61bce2
1 changed files with 9 additions and 2 deletions
|
@ -308,6 +308,8 @@ template<class vec_t>
|
||||||
struct TVector3
|
struct TVector3
|
||||||
{
|
{
|
||||||
typedef TVector2<vec_t> Vector2;
|
typedef TVector2<vec_t> Vector2;
|
||||||
|
// this does not compile - should be true on all relevant hardware.
|
||||||
|
//static_assert(myoffsetof(TVector3, X) == myoffsetof(Vector2, X) && myoffsetof(TVector3, Y) == myoffsetof(Vector2, Y), "TVector2 and TVector3 are not aligned");
|
||||||
|
|
||||||
vec_t X, Y, Z;
|
vec_t X, Y, Z;
|
||||||
|
|
||||||
|
@ -492,9 +494,14 @@ struct TVector3
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns the XY fields as a 2D-vector.
|
// returns the XY fields as a 2D-vector.
|
||||||
Vector2 XY() const
|
const Vector2& XY() const
|
||||||
{
|
{
|
||||||
return{ X, Y };
|
return *reinterpret_cast<const Vector2*>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2& XY()
|
||||||
|
{
|
||||||
|
return *reinterpret_cast<Vector2*>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a 3D vector and a 2D vector.
|
// Add a 3D vector and a 2D vector.
|
||||||
|
|
Loading…
Reference in a new issue