Core/Misc: update g3dlite lib (#2904)

* Core/Misc: update g3dlite lib

* update

Co-authored-by: Francesco Borzì <borzifrancesco@gmail.com>
This commit is contained in:
Viste
2020-07-30 13:35:45 +03:00
committed by GitHub
parent 91bbbf08eb
commit fcaf91b8b2
183 changed files with 13258 additions and 8022 deletions

View File

@@ -9,12 +9,13 @@
at http://www.magic-software.com
@created 2001-06-02
@edited 2009-11-16
@edited 2010-11-16
*/
#include "G3D/platform.h"
#include <stdlib.h>
#include "G3D/Vector2.h"
#include "G3D/Vector2int32.h"
#include "G3D/g3dmath.h"
#include "G3D/format.h"
#include "G3D/BinaryInput.h"
@@ -25,9 +26,12 @@
namespace G3D {
Vector2::Vector2(const Vector2int32& other) : x((float)other.x), y((float)other.y) {
}
Vector2::Vector2(const Any& any) {
any.verifyName("Vector2");
any.verifyName("Vector2", "Point2");
any.verifyType(Any::TABLE, Any::ARRAY);
any.verifySize(2);
@@ -42,7 +46,13 @@ Vector2::Vector2(const Any& any) {
}
Vector2::operator Any() const {
Vector2& Vector2::operator=(const Any& a) {
*this = Vector2(a);
return *this;
}
Any Vector2::toAny() const {
Any any(Any::ARRAY, "Vector2");
any.append(x, y);
return any;
@@ -70,26 +80,26 @@ const Vector2& Vector2::unitY() {
}
const Vector2& Vector2::inf() {
static Vector2 v((float)G3D::finf(), (float)G3D::finf());
return v;
static Vector2 v(G3D::finf(), G3D::finf());
return v;
}
const Vector2& Vector2::nan() {
static Vector2 v((float)G3D::fnan(), (float)G3D::fnan());
return v;
static Vector2 v(G3D::fnan(), G3D::fnan());
return v;
}
const Vector2& Vector2::minFinite() {
static Vector2 v(-FLT_MAX, -FLT_MAX);
return v;
static Vector2 v(-FLT_MAX, -FLT_MAX);
return v;
}
const Vector2& Vector2::maxFinite() {
static Vector2 v(FLT_MAX, FLT_MAX);
return v;
static Vector2 v(FLT_MAX, FLT_MAX);
return v;
}
@@ -145,9 +155,7 @@ Vector2 Vector2::random(G3D::Random& r) {
} while (result.squaredLength() >= 1.0f);
result.unitize();
return result;
return result.direction();
}
@@ -161,20 +169,6 @@ Vector2& Vector2::operator/= (float k) {
return *this;
}
//----------------------------------------------------------------------------
float Vector2::unitize (float fTolerance) {
float fLength = length();
if (fLength > fTolerance) {
float fInvLength = 1.0f / fLength;
x *= fInvLength;
y *= fInvLength;
} else {
fLength = 0.0;
}
return fLength;
}
//----------------------------------------------------------------------------
@@ -220,5 +214,12 @@ Vector4 Vector2::xyyy() const { return Vector4 (x, y, y, y); }
Vector4 Vector2::yyyy() const { return Vector4 (y, y, y, y); }
void serialize(const Vector2& v, class BinaryOutput& b) {
v.serialize(b);
}
void deserialize(Vector2& v, class BinaryInput& b) {
v.deserialize(b);
}
} // namespace