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
+99 -59
View File
@@ -1,20 +1,20 @@
/**
@file Box.h
\file G3D/Box.h
Box class
@maintainer Morgan McGuire, http://graphics.cs.williams.edu
\maintainer Morgan McGuire, http://graphics.cs.williams.edu
@cite Portions based on Dave Eberly's Magic Software Library at <A HREF="http://www.magic-software.com">http://www.magic-software.com</A>
@created 2001-06-02
@edited 2007-06-05
\cite Portions based on Dave Eberly's Magic Software Library at <A HREF="http://www.magic-software.com">http://www.magic-software.com</A>
\created 2001-06-02
\edited 2013-04-13
Copyright 2000-2006, Morgan McGuire.
Copyright 2000-2013, Morgan McGuire.
All rights reserved.
*/
#ifndef G3D_BOX_H
#define G3D_BOX_H
#ifndef G3D_Box_h
#define G3D_Box_h
#include "G3D/platform.h"
#include "G3D/Vector3.h"
@@ -24,13 +24,12 @@
namespace G3D {
class CoordinateFrame;
class Any;
/**
An arbitrary 3D box, useful as a bounding box.
To construct a box from a coordinate frame, center and extent, use the idiom:
\brief An arbitrary (oriented) 3D box, useful as a bounding box.
To construct a box from a coordinate frame, center and extent, use the idiom:
<CODE>Box box = cframe.toObjectSpace(Box(center - extent/2, center + extent/2));</CODE>
*/
class Box {
@@ -41,29 +40,14 @@ private:
friend class CoordinateFrame;
/**
<PRE>
3 2 7 6
0 1 4 5
front back (seen through front)
</PRE>
Axes with length equal to the 4 edges that run along each of them
*/
Vector3 _corner[8];
/**
Unit axes.
*/
Vector3 _axis[3];
Vector3 _edgeVector[3];
Vector3 _center;
/**
Extent along each axis.
*/
Vector3 _extent;
Point3 _center;
float _area;
float _volume;
void init(
@@ -72,38 +56,47 @@ private:
public:
/**
Does not initialize the fields.
*/
Box();
explicit Box(const Any& a);
/**
Constructs a box from two opposite corners.
*/
Box(
const Vector3& min,
Box(const Vector3& min,
const Vector3& max);
static Box inf();
Box(const Vector3& osMin,
const Vector3& osMax,
const CoordinateFrame& frame);
Box(class BinaryInput& b);
Box(class BinaryInput& b);
Box(const class AABox& b);
void serialize(class BinaryOutput& b) const;
void deserialize(class BinaryInput& b);
explicit Box(const Point3& p);
static Box inf();
Any toAny() const;
void serialize(class BinaryOutput& b) const;
void deserialize(class BinaryInput& b);
/**
Returns the object to world transformation for
this box. localFrame().worldToObject(...) takes
this box, where the origin is the center of the box. localFrame().worldToObject(...) takes
objects into the space where the box axes are
(1,0,0), (0,1,0), (0,0,1). Note that there
is no scaling in this transformation.
*/
CoordinateFrame localFrame() const;
/** \sa localFrame */
void getLocalFrame(CoordinateFrame& frame) const;
Box operator*(float f) const;
/**
Returns the centroid of the box.
*/
@@ -111,18 +104,39 @@ public:
return _center;
}
/**
\htmlonly
<PRE>
inline Vector3 corner(int i) const {
debugAssert(i < 8);
return _corner[i];
}
2--------3
/ : /|
/ : / |
6--------7 |
| : | |
| 0....|..1
| / | /
|/ |/
4--------5
y
^
|
|-->x
z/
</PRE>
\endhtmlonly
*/
Vector3 corner(int i) const;
/**
Unit length.
*/
inline Vector3 axis(int a) const {
debugAssert(a < 3);
return _axis[a];
return _edgeVector[a].direction();
}
/**
@@ -131,17 +145,43 @@ public:
*/
inline float extent(int a) const {
debugAssert(a < 3);
return (float)_extent[a];
return _edgeVector[a].length();
}
inline Vector3 extent() const {
return _extent;
return Vector3(_edgeVector[0].length(), _edgeVector[1].length(), _edgeVector[2].length());
}
/**
Returns the four corners of a face (0 <= f < 6).
The corners are returned to form a counter clockwise quad facing outwards.
*/
The corners are returned to form a clockwise quad facing outwards.
+--------+
/ : /|
/ : / |
+--------+ |
| : | |
| +....|..+
| / | /
|/ |/
+--------+
y
^
|
|-->x
z/
Faces are in the following order:
0: -Z
1: X
2: Z
3: Y
4: -X
5: -Y
*/
void getFaceCorners(
int f,
Vector3& v0,
@@ -150,24 +190,24 @@ public:
Vector3& v3) const;
/**
/**
See AABox::culledBy
*/
*/
bool culledBy
(
const Array<Plane>& plane,
int32& cullingPlaneIndex,
const uint32 testMask,
uint32& childMask) const;
const Array<Plane>& plane,
int32& cullingPlaneIndex,
const uint32 testMask,
uint32& childMask) const;
/**
Conservative culling test that does not produce a mask for children.
*/
bool culledBy
(
const Array<Plane>& plane,
int32& cullingPlaneIndex = dummy,
const uint32 testMask = -1) const;
const Array<Plane>& plane,
int32& cullingPlaneIndex = dummy,
const uint32 testMask = -1) const;
bool contains(
const Vector3& point) const;