mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-27 22:42:29 +00:00
- fixed: TVector::Resized needs to consider that the input vector has a length of 0. In this case just performing the normal calculations results in an invalid vector.
This commit is contained in:
parent
201ae3c60f
commit
41ab08ee47
1 changed files with 18 additions and 6 deletions
|
@ -556,18 +556,30 @@ 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();
|
||||||
|
if (vlen != 0.)
|
||||||
|
{
|
||||||
|
double scale = len / vlen;
|
||||||
X = vec_t(X * scale);
|
X = vec_t(X * scale);
|
||||||
Y = vec_t(Y * scale);
|
Y = vec_t(Y * scale);
|
||||||
Z = vec_t(Z * 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();
|
||||||
|
if (vlen != 0.)
|
||||||
|
{
|
||||||
|
double scale = len / vlen;
|
||||||
return{ vec_t(X * scale), vec_t(Y * scale), vec_t(Z * scale) };
|
return{ vec_t(X * scale), vec_t(Y * scale), vec_t(Z * scale) };
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Dot product
|
// Dot product
|
||||||
double operator | (const TVector3 &other) const
|
double operator | (const TVector3 &other) const
|
||||||
|
|
Loading…
Reference in a new issue