mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-28 06:42:09 +00:00
Merge branch 'master' of https://github.com/rheit/zdoom
This commit is contained in:
commit
15af9242d6
1 changed files with 18 additions and 6 deletions
|
@ -556,17 +556,29 @@ struct TVector3
|
||||||
// Resizes this vector to be the specified length (if it is not 0)
|
// Resizes this vector to be the specified length (if it is not 0)
|
||||||
TVector3 &MakeResize(double len)
|
TVector3 &MakeResize(double len)
|
||||||
{
|
{
|
||||||
double scale = len / Length();
|
double vlen = Length();
|
||||||
X = vec_t(X * scale);
|
if (vlen != 0.)
|
||||||
Y = vec_t(Y * scale);
|
{
|
||||||
Z = vec_t(Z * scale);
|
double scale = len / vlen;
|
||||||
|
X = vec_t(X * scale);
|
||||||
|
Y = vec_t(Y * scale);
|
||||||
|
Z = vec_t(Z * scale);
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
TVector3 Resized(double len)
|
TVector3 Resized(double len)
|
||||||
{
|
{
|
||||||
double scale = len / Length();
|
double vlen = Length();
|
||||||
return{ vec_t(X * scale), vec_t(Y * scale), vec_t(Z * scale) };
|
if (vlen != 0.)
|
||||||
|
{
|
||||||
|
double scale = len / vlen;
|
||||||
|
return{ vec_t(X * scale), vec_t(Y * scale), vec_t(Z * scale) };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dot product
|
// Dot product
|
||||||
|
|
Loading…
Reference in a new issue