mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 12:12:28 +00:00
Core: Make all Variant math types structs
Some were declared as structs (public by default) and others as classes (private by default) but in practice all these math types exposed as Variants are all 100% public.
This commit is contained in:
parent
8495be9cec
commit
5ddb518496
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user