mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 17:01:28 +00:00
- added 'Resized()' to TVector2 and fixed its const state for all vectors.
This commit is contained in:
parent
a4ec938526
commit
2fe5655394
1 changed files with 15 additions and 2 deletions
|
@ -271,6 +271,19 @@ struct TVector2
|
|||
return *this;
|
||||
}
|
||||
|
||||
TVector2 Resized(double len) const
|
||||
{
|
||||
double vlen = Length();
|
||||
if (vlen != 0.)
|
||||
{
|
||||
double scale = len / vlen;
|
||||
return{ vec_t(X * scale), vec_t(Y * scale) };
|
||||
}
|
||||
else
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
// Dot product
|
||||
vec_t operator | (const TVector2 &other) const
|
||||
|
@ -644,7 +657,7 @@ struct TVector3
|
|||
return *this;
|
||||
}
|
||||
|
||||
TVector3 Resized(double len)
|
||||
TVector3 Resized(double len) const
|
||||
{
|
||||
double vlen = Length();
|
||||
if (vlen != 0.)
|
||||
|
@ -955,7 +968,7 @@ struct TVector4
|
|||
return *this;
|
||||
}
|
||||
|
||||
TVector4 Resized(double len)
|
||||
TVector4 Resized(double len) const
|
||||
{
|
||||
double vlen = Length();
|
||||
if (vlen != 0.)
|
||||
|
|
Loading…
Reference in a new issue