Merge pull request #57623 from akien-mga/core-math-struct-em-all

This commit is contained in:
Rémi Verschelde 2022-02-04 19:02:57 +01:00 committed by GitHub
commit 84290fe4b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 26 additions and 31 deletions

View file

@ -36,13 +36,13 @@
#include "core/math/vector3.h"
/**
* AABB / AABB (Axis Aligned Bounding Box)
* This is implemented by a point (position) and the box size
* AABB (Axis Aligned Bounding Box)
* This is implemented by a point (position) and the box size.
*/
class Variant;
class _NO_DISCARD_ AABB {
public:
struct _NO_DISCARD_ AABB {
Vector3 position;
Vector3 size;

View file

@ -34,11 +34,7 @@
#include "core/math/quaternion.h"
#include "core/math/vector3.h"
class _NO_DISCARD_ Basis {
private:
void _set_diagonal(const Vector3 &p_diag);
public:
struct _NO_DISCARD_ Basis {
Vector3 elements[3] = {
Vector3(1, 0, 0),
Vector3(0, 1, 0),
@ -263,6 +259,10 @@ public:
}
_FORCE_INLINE_ Basis() {}
private:
// Helper method.
void _set_diagonal(const Vector3 &p_diag);
};
_FORCE_INLINE_ void Basis::operator*=(const Basis &p_matrix) {
@ -334,4 +334,5 @@ real_t Basis::determinant() const {
elements[1][0] * (elements[0][1] * elements[2][2] - elements[2][1] * elements[0][2]) +
elements[2][0] * (elements[0][1] * elements[1][2] - elements[1][1] * elements[0][2]);
}
#endif // BASIS_H

View file

@ -34,10 +34,10 @@
#include "core/math/math_defs.h"
#include "core/math/vector3.h"
class AABB;
class Plane;
class Transform3D;
struct AABB;
struct Plane;
struct Rect2;
struct Transform3D;
struct Vector2;
struct CameraMatrix {

View file

@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef DYNAMICBVH_H
#define DYNAMICBVH_H
#ifndef DYNAMIC_BVH_H
#define DYNAMIC_BVH_H
#include "core/math/aabb.h"
#include "core/templates/list.h"
@ -474,4 +474,4 @@ void DynamicBVH::ray_query(const Vector3 &p_from, const Vector3 &p_to, QueryResu
} while (depth > 0);
}
#endif // DYNAMICBVH_H
#endif // DYNAMIC_BVH_H

View file

@ -36,8 +36,7 @@
#include "core/math/transform_3d.h"
#include "core/math/vector3.h"
class _NO_DISCARD_ Face3 {
public:
struct _NO_DISCARD_ Face3 {
enum Side {
SIDE_OVER,
SIDE_UNDER,
@ -48,14 +47,11 @@ public:
Vector3 vertex[3];
/**
*
* @param p_plane plane used to split the face
* @param p_res array of at least 3 faces, amount used in function return
* @param p_is_point_over array of at least 3 booleans, determining which face is over the plane, amount used in function return
* @param _epsilon constant used for numerical error rounding, to add "thickness" to the plane (so coplanar points can happen)
* @return amount of faces generated by the split, either 0 (means no split possible), 2 or 3
*/
int split_by_plane(const Plane &p_plane, Face3 *p_res, bool *p_is_point_over) const;
Plane get_plane(ClockDirection p_dir = CLOCKWISE) const;

View file

@ -35,13 +35,12 @@
class Variant;
class _NO_DISCARD_ Plane {
public:
struct _NO_DISCARD_ Plane {
Vector3 normal;
real_t d = 0;
void set_normal(const Vector3 &p_normal);
_FORCE_INLINE_ Vector3 get_normal() const { return normal; }; ///Point is coplanar, CMP_EPSILON for precision
_FORCE_INLINE_ Vector3 get_normal() const { return normal; };
void normalize();
Plane normalized() const;

View file

@ -36,8 +36,7 @@
#include "core/math/vector3.h"
#include "core/string/ustring.h"
class _NO_DISCARD_ Quaternion {
public:
struct _NO_DISCARD_ Quaternion {
union {
struct {
real_t x;

View file

@ -28,15 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef TRANSFORM_H
#define TRANSFORM_H
#ifndef TRANSFORM_3D_H
#define TRANSFORM_3D_H
#include "core/math/aabb.h"
#include "core/math/basis.h"
#include "core/math/plane.h"
class _NO_DISCARD_ Transform3D {
public:
struct _NO_DISCARD_ Transform3D {
Basis basis;
Vector3 origin;
@ -265,4 +264,4 @@ _FORCE_INLINE_ Plane Transform3D::xform_inv_fast(const Plane &p_plane, const Tra
return Plane(normal, d);
}
#endif // TRANSFORM_H
#endif // TRANSFORM_3D_H

View file

@ -35,7 +35,8 @@
#include "core/math/vector2.h"
#include "core/math/vector3i.h"
#include "core/string/ustring.h"
class Basis;
struct Basis;
struct _NO_DISCARD_ Vector3 {
static const int AXIS_COUNT = 3;