Fix compilation warnings in Shape2DSW/Shape3DSW

This commit is contained in:
PouleyKetchoupp 2021-08-19 16:19:49 -07:00
parent 4f640762f7
commit dafb6edacf
2 changed files with 178 additions and 192 deletions

View file

@ -34,18 +34,6 @@
#include "servers/physics_server_2d.h" #include "servers/physics_server_2d.h"
#define _SEGMENT_IS_VALID_SUPPORT_THRESHOLD 0.99998 #define _SEGMENT_IS_VALID_SUPPORT_THRESHOLD 0.99998
/*
SHAPE_WORLD_MARGIN, ///< plane:"plane"
SHAPE_SEGMENT, ///< real_t:"length"
SHAPE_CIRCLE, ///< real_t:"radius"
SHAPE_RECTANGLE, ///< vec3:"extents"
SHAPE_CONVEX_POLYGON, ///< array of planes:"planes"
SHAPE_CONCAVE_POLYGON, ///< Vector2 array:"triangles" , or Dictionary with "indices" (int array) and "triangles" (Vector2 array)
SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_create() with this value will result in an error
*/
class Shape2DSW; class Shape2DSW;
class ShapeOwner2DSW { class ShapeOwner2DSW {
@ -138,7 +126,7 @@ public:
//let the optimizer do the magic //let the optimizer do the magic
#define DEFAULT_PROJECT_RANGE_CAST \ #define DEFAULT_PROJECT_RANGE_CAST \
virtual void project_range_castv(const Vector2 &p_cast, const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { \ virtual void project_range_castv(const Vector2 &p_cast, const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const override { \
project_range_cast(p_cast, p_normal, p_transform, r_min, r_max); \ project_range_cast(p_cast, p_normal, p_transform, r_min, r_max); \
} \ } \
_FORCE_INLINE_ void project_range_cast(const Vector2 &p_cast, const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { \ _FORCE_INLINE_ void project_range_cast(const Vector2 &p_cast, const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { \
@ -160,17 +148,17 @@ public:
_FORCE_INLINE_ Vector2 get_normal() const { return normal; } _FORCE_INLINE_ Vector2 get_normal() const { return normal; }
_FORCE_INLINE_ real_t get_d() const { return d; } _FORCE_INLINE_ real_t get_d() const { return d; }
virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_WORLD_MARGIN; } virtual PhysicsServer2D::ShapeType get_type() const override { return PhysicsServer2D::SHAPE_WORLD_MARGIN; }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); } virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const override { project_range(p_normal, p_transform, r_min, r_max); }
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const; virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const override;
virtual bool contains_point(const Vector2 &p_point) const; virtual bool contains_point(const Vector2 &p_point) const override;
virtual bool intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const; virtual bool intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const override;
virtual real_t get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const; virtual real_t get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const override;
virtual void set_data(const Variant &p_data); virtual void set_data(const Variant &p_data) override;
virtual Variant get_data() const; virtual Variant get_data() const override;
_FORCE_INLINE_ void project_range(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { _FORCE_INLINE_ void project_range(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const {
//real large //real large
@ -178,7 +166,7 @@ public:
r_max = 1e10; r_max = 1e10;
} }
virtual void project_range_castv(const Vector2 &p_cast, const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { virtual void project_range_castv(const Vector2 &p_cast, const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const override {
project_range_cast(p_cast, p_normal, p_transform, r_min, r_max); project_range_cast(p_cast, p_normal, p_transform, r_min, r_max);
} }
@ -199,20 +187,20 @@ public:
_FORCE_INLINE_ const Vector2 &get_b() const { return b; } _FORCE_INLINE_ const Vector2 &get_b() const { return b; }
_FORCE_INLINE_ const Vector2 &get_normal() const { return n; } _FORCE_INLINE_ const Vector2 &get_normal() const { return n; }
virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_SEGMENT; } virtual PhysicsServer2D::ShapeType get_type() const override { return PhysicsServer2D::SHAPE_SEGMENT; }
_FORCE_INLINE_ Vector2 get_xformed_normal(const Transform2D &p_xform) const { _FORCE_INLINE_ Vector2 get_xformed_normal(const Transform2D &p_xform) const {
return (p_xform.xform(b) - p_xform.xform(a)).normalized().orthogonal(); return (p_xform.xform(b) - p_xform.xform(a)).normalized().orthogonal();
} }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); } virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const override { project_range(p_normal, p_transform, r_min, r_max); }
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const; virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const override;
virtual bool contains_point(const Vector2 &p_point) const; virtual bool contains_point(const Vector2 &p_point) const override;
virtual bool intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const; virtual bool intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const override;
virtual real_t get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const; virtual real_t get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const override;
virtual void set_data(const Variant &p_data); virtual void set_data(const Variant &p_data) override;
virtual Variant get_data() const; virtual Variant get_data() const override;
_FORCE_INLINE_ void project_range(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { _FORCE_INLINE_ void project_range(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const {
//real large //real large
@ -239,17 +227,17 @@ class CircleShape2DSW : public Shape2DSW {
public: public:
_FORCE_INLINE_ const real_t &get_radius() const { return radius; } _FORCE_INLINE_ const real_t &get_radius() const { return radius; }
virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_CIRCLE; } virtual PhysicsServer2D::ShapeType get_type() const override { return PhysicsServer2D::SHAPE_CIRCLE; }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); } virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const override { project_range(p_normal, p_transform, r_min, r_max); }
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const; virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const override;
virtual bool contains_point(const Vector2 &p_point) const; virtual bool contains_point(const Vector2 &p_point) const override;
virtual bool intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const; virtual bool intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const override;
virtual real_t get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const; virtual real_t get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const override;
virtual void set_data(const Variant &p_data); virtual void set_data(const Variant &p_data) override;
virtual Variant get_data() const; virtual Variant get_data() const override;
_FORCE_INLINE_ void project_range(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { _FORCE_INLINE_ void project_range(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const {
//real large //real large
@ -272,17 +260,17 @@ class RectangleShape2DSW : public Shape2DSW {
public: public:
_FORCE_INLINE_ const Vector2 &get_half_extents() const { return half_extents; } _FORCE_INLINE_ const Vector2 &get_half_extents() const { return half_extents; }
virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_RECTANGLE; } virtual PhysicsServer2D::ShapeType get_type() const override { return PhysicsServer2D::SHAPE_RECTANGLE; }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); } virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const override { project_range(p_normal, p_transform, r_min, r_max); }
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const; virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const override;
virtual bool contains_point(const Vector2 &p_point) const; virtual bool contains_point(const Vector2 &p_point) const override;
virtual bool intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const; virtual bool intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const override;
virtual real_t get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const; virtual real_t get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const override;
virtual void set_data(const Variant &p_data); virtual void set_data(const Variant &p_data) override;
virtual Variant get_data() const; virtual Variant get_data() const override;
_FORCE_INLINE_ void project_range(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { _FORCE_INLINE_ void project_range(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const {
// no matter the angle, the box is mirrored anyway // no matter the angle, the box is mirrored anyway
@ -346,17 +334,17 @@ public:
_FORCE_INLINE_ const real_t &get_radius() const { return radius; } _FORCE_INLINE_ const real_t &get_radius() const { return radius; }
_FORCE_INLINE_ const real_t &get_height() const { return height; } _FORCE_INLINE_ const real_t &get_height() const { return height; }
virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_CAPSULE; } virtual PhysicsServer2D::ShapeType get_type() const override { return PhysicsServer2D::SHAPE_CAPSULE; }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); } virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const override { project_range(p_normal, p_transform, r_min, r_max); }
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const; virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const override;
virtual bool contains_point(const Vector2 &p_point) const; virtual bool contains_point(const Vector2 &p_point) const override;
virtual bool intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const; virtual bool intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const override;
virtual real_t get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const; virtual real_t get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const override;
virtual void set_data(const Variant &p_data); virtual void set_data(const Variant &p_data) override;
virtual Variant get_data() const; virtual Variant get_data() const override;
_FORCE_INLINE_ void project_range(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { _FORCE_INLINE_ void project_range(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const {
// no matter the angle, the box is mirrored anyway // no matter the angle, the box is mirrored anyway
@ -399,17 +387,17 @@ public:
return (p_xform.xform(b) - p_xform.xform(a)).normalized().orthogonal(); return (p_xform.xform(b) - p_xform.xform(a)).normalized().orthogonal();
} }
virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_CONVEX_POLYGON; } virtual PhysicsServer2D::ShapeType get_type() const override { return PhysicsServer2D::SHAPE_CONVEX_POLYGON; }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); } virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const override { project_range(p_normal, p_transform, r_min, r_max); }
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const; virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const override;
virtual bool contains_point(const Vector2 &p_point) const; virtual bool contains_point(const Vector2 &p_point) const override;
virtual bool intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const; virtual bool intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const override;
virtual real_t get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const; virtual real_t get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const override;
virtual void set_data(const Variant &p_data); virtual void set_data(const Variant &p_data) override;
virtual Variant get_data() const; virtual Variant get_data() const override;
_FORCE_INLINE_ void project_range(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { _FORCE_INLINE_ void project_range(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const {
if (!points || point_count <= 0) { if (!points || point_count <= 0) {
@ -437,7 +425,7 @@ public:
class ConcaveShape2DSW : public Shape2DSW { class ConcaveShape2DSW : public Shape2DSW {
public: public:
virtual bool is_concave() const { return true; } virtual bool is_concave() const override { return true; }
typedef void (*Callback)(void *p_userdata, Shape2DSW *p_convex); typedef void (*Callback)(void *p_userdata, Shape2DSW *p_convex);
virtual void cull(const Rect2 &p_local_aabb, Callback p_callback, void *p_userdata) const = 0; virtual void cull(const Rect2 &p_local_aabb, Callback p_callback, void *p_userdata) const = 0;
@ -474,23 +462,31 @@ class ConcavePolygonShape2DSW : public ConcaveShape2DSW {
int _generate_bvh(BVH *p_bvh, int p_len, int p_depth); int _generate_bvh(BVH *p_bvh, int p_len, int p_depth);
public: public:
virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_CONCAVE_POLYGON; } virtual PhysicsServer2D::ShapeType get_type() const override { return PhysicsServer2D::SHAPE_CONCAVE_POLYGON; }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { /*project_range(p_normal,p_transform,r_min,r_max);*/ virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const override {
r_min = 0;
r_max = 0;
ERR_FAIL_MSG("Unsupported call to project_rangev in ConcavePolygonShape2DSW");
} }
virtual void project_range(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { /*project_range(p_normal,p_transform,r_min,r_max);*/
void project_range(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const {
r_min = 0;
r_max = 0;
ERR_FAIL_MSG("Unsupported call to project_range in ConcavePolygonShape2DSW");
} }
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const;
virtual bool contains_point(const Vector2 &p_point) const; virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const override;
virtual bool intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const;
virtual real_t get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const { return 0; } virtual bool contains_point(const Vector2 &p_point) const override;
virtual bool intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const override;
virtual void set_data(const Variant &p_data); virtual real_t get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const override { return 0; }
virtual Variant get_data() const;
virtual void cull(const Rect2 &p_local_aabb, Callback p_callback, void *p_userdata) const; virtual void set_data(const Variant &p_data) override;
virtual Variant get_data() const override;
virtual void cull(const Rect2 &p_local_aabb, Callback p_callback, void *p_userdata) const override;
DEFAULT_PROJECT_RANGE_CAST DEFAULT_PROJECT_RANGE_CAST
}; };

View file

@ -33,17 +33,6 @@
#include "core/math/geometry_3d.h" #include "core/math/geometry_3d.h"
#include "servers/physics_server_3d.h" #include "servers/physics_server_3d.h"
/*
SHAPE_LINE, ///< plane:"plane"
SHAPE_SEGMENT, ///< real_t:"length"
SHAPE_CIRCLE, ///< real_t:"radius"
SHAPE_RECTANGLE, ///< vec3:"extents"
SHAPE_CONVEX_POLYGON, ///< array of planes:"planes"
SHAPE_CONCAVE_POLYGON, ///< Vector3 array:"triangles" , or Dictionary with "indices" (int array) and "triangles" (Vector3 array)
SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_create() with this value will result in an error
*/
class Shape3DSW; class Shape3DSW;
@ -111,9 +100,9 @@ public:
class ConcaveShape3DSW : public Shape3DSW { class ConcaveShape3DSW : public Shape3DSW {
public: public:
virtual bool is_concave() const { return true; } virtual bool is_concave() const override { return true; }
typedef void (*Callback)(void *p_userdata, Shape3DSW *p_convex); typedef void (*Callback)(void *p_userdata, Shape3DSW *p_convex);
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const { r_amount = 0; } virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const override { r_amount = 0; }
virtual void cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const = 0; virtual void cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const = 0;
@ -153,21 +142,21 @@ class SphereShape3DSW : public Shape3DSW {
public: public:
real_t get_radius() const; real_t get_radius() const;
virtual real_t get_area() const { return 4.0 / 3.0 * Math_PI * radius * radius * radius; } virtual real_t get_area() const override { return 4.0 / 3.0 * Math_PI * radius * radius * radius; }
virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_SPHERE; } virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_SPHERE; }
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const; virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
virtual Vector3 get_support(const Vector3 &p_normal) const; virtual Vector3 get_support(const Vector3 &p_normal) const override;
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const; virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const override;
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const; virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const override;
virtual bool intersect_point(const Vector3 &p_point) const; virtual bool intersect_point(const Vector3 &p_point) const override;
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const; virtual Vector3 get_closest_point_to(const Vector3 &p_point) const override;
virtual Vector3 get_moment_of_inertia(real_t p_mass) const; virtual Vector3 get_moment_of_inertia(real_t p_mass) const override;
virtual void set_data(const Variant &p_data); virtual void set_data(const Variant &p_data) override;
virtual Variant get_data() const; virtual Variant get_data() const override;
SphereShape3DSW(); SphereShape3DSW();
}; };
@ -178,21 +167,21 @@ class BoxShape3DSW : public Shape3DSW {
public: public:
_FORCE_INLINE_ Vector3 get_half_extents() const { return half_extents; } _FORCE_INLINE_ Vector3 get_half_extents() const { return half_extents; }
virtual real_t get_area() const { return 8 * half_extents.x * half_extents.y * half_extents.z; } virtual real_t get_area() const override { return 8 * half_extents.x * half_extents.y * half_extents.z; }
virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_BOX; } virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_BOX; }
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const; virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
virtual Vector3 get_support(const Vector3 &p_normal) const; virtual Vector3 get_support(const Vector3 &p_normal) const override;
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const; virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const override;
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const; virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const override;
virtual bool intersect_point(const Vector3 &p_point) const; virtual bool intersect_point(const Vector3 &p_point) const override;
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const; virtual Vector3 get_closest_point_to(const Vector3 &p_point) const override;
virtual Vector3 get_moment_of_inertia(real_t p_mass) const; virtual Vector3 get_moment_of_inertia(real_t p_mass) const override;
virtual void set_data(const Variant &p_data); virtual void set_data(const Variant &p_data) override;
virtual Variant get_data() const; virtual Variant get_data() const override;
BoxShape3DSW(); BoxShape3DSW();
}; };
@ -207,21 +196,21 @@ public:
_FORCE_INLINE_ real_t get_height() const { return height; } _FORCE_INLINE_ real_t get_height() const { return height; }
_FORCE_INLINE_ real_t get_radius() const { return radius; } _FORCE_INLINE_ real_t get_radius() const { return radius; }
virtual real_t get_area() const { return 4.0 / 3.0 * Math_PI * radius * radius * radius + (height - radius * 2.0) * Math_PI * radius * radius; } virtual real_t get_area() const override { return 4.0 / 3.0 * Math_PI * radius * radius * radius + (height - radius * 2.0) * Math_PI * radius * radius; }
virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_CAPSULE; } virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_CAPSULE; }
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const; virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
virtual Vector3 get_support(const Vector3 &p_normal) const; virtual Vector3 get_support(const Vector3 &p_normal) const override;
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const; virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const override;
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const; virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const override;
virtual bool intersect_point(const Vector3 &p_point) const; virtual bool intersect_point(const Vector3 &p_point) const override;
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const; virtual Vector3 get_closest_point_to(const Vector3 &p_point) const override;
virtual Vector3 get_moment_of_inertia(real_t p_mass) const; virtual Vector3 get_moment_of_inertia(real_t p_mass) const override;
virtual void set_data(const Variant &p_data); virtual void set_data(const Variant &p_data) override;
virtual Variant get_data() const; virtual Variant get_data() const override;
CapsuleShape3DSW(); CapsuleShape3DSW();
}; };
@ -236,21 +225,21 @@ public:
_FORCE_INLINE_ real_t get_height() const { return height; } _FORCE_INLINE_ real_t get_height() const { return height; }
_FORCE_INLINE_ real_t get_radius() const { return radius; } _FORCE_INLINE_ real_t get_radius() const { return radius; }
virtual real_t get_area() const { return 4.0 / 3.0 * Math_PI * radius * radius * radius + height * Math_PI * radius * radius; } virtual real_t get_area() const override { return 4.0 / 3.0 * Math_PI * radius * radius * radius + height * Math_PI * radius * radius; }
virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_CYLINDER; } virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_CYLINDER; }
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const; virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
virtual Vector3 get_support(const Vector3 &p_normal) const; virtual Vector3 get_support(const Vector3 &p_normal) const override;
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const; virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const override;
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const; virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const override;
virtual bool intersect_point(const Vector3 &p_point) const; virtual bool intersect_point(const Vector3 &p_point) const override;
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const; virtual Vector3 get_closest_point_to(const Vector3 &p_point) const override;
virtual Vector3 get_moment_of_inertia(real_t p_mass) const; virtual Vector3 get_moment_of_inertia(real_t p_mass) const override;
virtual void set_data(const Variant &p_data); virtual void set_data(const Variant &p_data) override;
virtual Variant get_data() const; virtual Variant get_data() const override;
CylinderShape3DSW(); CylinderShape3DSW();
}; };
@ -263,19 +252,19 @@ struct ConvexPolygonShape3DSW : public Shape3DSW {
public: public:
const Geometry3D::MeshData &get_mesh() const { return mesh; } const Geometry3D::MeshData &get_mesh() const { return mesh; }
virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_CONVEX_POLYGON; } virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_CONVEX_POLYGON; }
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const; virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
virtual Vector3 get_support(const Vector3 &p_normal) const; virtual Vector3 get_support(const Vector3 &p_normal) const override;
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const; virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const override;
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const; virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const override;
virtual bool intersect_point(const Vector3 &p_point) const; virtual bool intersect_point(const Vector3 &p_point) const override;
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const; virtual Vector3 get_closest_point_to(const Vector3 &p_point) const override;
virtual Vector3 get_moment_of_inertia(real_t p_mass) const; virtual Vector3 get_moment_of_inertia(real_t p_mass) const override;
virtual void set_data(const Variant &p_data); virtual void set_data(const Variant &p_data) override;
virtual Variant get_data() const; virtual Variant get_data() const override;
ConvexPolygonShape3DSW(); ConvexPolygonShape3DSW();
}; };
@ -341,21 +330,21 @@ struct ConcavePolygonShape3DSW : public ConcaveShape3DSW {
public: public:
Vector<Vector3> get_faces() const; Vector<Vector3> get_faces() const;
virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_CONCAVE_POLYGON; } virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_CONCAVE_POLYGON; }
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const; virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
virtual Vector3 get_support(const Vector3 &p_normal) const; virtual Vector3 get_support(const Vector3 &p_normal) const override;
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const; virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const override;
virtual bool intersect_point(const Vector3 &p_point) const; virtual bool intersect_point(const Vector3 &p_point) const override;
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const; virtual Vector3 get_closest_point_to(const Vector3 &p_point) const override;
virtual void cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const; virtual void cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const override;
virtual Vector3 get_moment_of_inertia(real_t p_mass) const; virtual Vector3 get_moment_of_inertia(real_t p_mass) const override;
virtual void set_data(const Variant &p_data); virtual void set_data(const Variant &p_data) override;
virtual Variant get_data() const; virtual Variant get_data() const override;
ConcavePolygonShape3DSW(); ConcavePolygonShape3DSW();
}; };
@ -385,20 +374,20 @@ public:
int get_width() const; int get_width() const;
int get_depth() const; int get_depth() const;
virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_HEIGHTMAP; } virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_HEIGHTMAP; }
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const; virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
virtual Vector3 get_support(const Vector3 &p_normal) const; virtual Vector3 get_support(const Vector3 &p_normal) const override;
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_point, Vector3 &r_normal) const; virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_point, Vector3 &r_normal) const override;
virtual bool intersect_point(const Vector3 &p_point) const; virtual bool intersect_point(const Vector3 &p_point) const override;
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const; virtual Vector3 get_closest_point_to(const Vector3 &p_point) const override;
virtual void cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const; virtual void cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const override;
virtual Vector3 get_moment_of_inertia(real_t p_mass) const; virtual Vector3 get_moment_of_inertia(real_t p_mass) const override;
virtual void set_data(const Variant &p_data); virtual void set_data(const Variant &p_data) override;
virtual Variant get_data() const; virtual Variant get_data() const override;
HeightMapShape3DSW(); HeightMapShape3DSW();
}; };
@ -409,21 +398,21 @@ struct FaceShape3DSW : public Shape3DSW {
Vector3 vertex[3]; Vector3 vertex[3];
bool backface_collision = false; bool backface_collision = false;
virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_CONCAVE_POLYGON; } virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_CONCAVE_POLYGON; }
const Vector3 &get_vertex(int p_idx) const { return vertex[p_idx]; } const Vector3 &get_vertex(int p_idx) const { return vertex[p_idx]; }
void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const; virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
Vector3 get_support(const Vector3 &p_normal) const; virtual Vector3 get_support(const Vector3 &p_normal) const override;
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const; virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const override;
bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const; virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const override;
virtual bool intersect_point(const Vector3 &p_point) const; virtual bool intersect_point(const Vector3 &p_point) const override;
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const; virtual Vector3 get_closest_point_to(const Vector3 &p_point) const override;
Vector3 get_moment_of_inertia(real_t p_mass) const; virtual Vector3 get_moment_of_inertia(real_t p_mass) const override;
virtual void set_data(const Variant &p_data) {} virtual void set_data(const Variant &p_data) override {}
virtual Variant get_data() const { return Variant(); } virtual Variant get_data() const override { return Variant(); }
FaceShape3DSW(); FaceShape3DSW();
}; };
@ -432,9 +421,9 @@ struct MotionShape3DSW : public Shape3DSW {
Shape3DSW *shape; Shape3DSW *shape;
Vector3 motion; Vector3 motion;
virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_CONVEX_POLYGON; } virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_CONVEX_POLYGON; }
void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const { virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override {
Vector3 cast = p_transform.basis.xform(motion); Vector3 cast = p_transform.basis.xform(motion);
real_t mina, maxa; real_t mina, maxa;
real_t minb, maxb; real_t minb, maxb;
@ -446,22 +435,23 @@ struct MotionShape3DSW : public Shape3DSW {
r_max = MAX(maxa, maxb); r_max = MAX(maxa, maxb);
} }
Vector3 get_support(const Vector3 &p_normal) const { virtual Vector3 get_support(const Vector3 &p_normal) const override {
Vector3 support = shape->get_support(p_normal); Vector3 support = shape->get_support(p_normal);
if (p_normal.dot(motion) > 0) { if (p_normal.dot(motion) > 0) {
support += motion; support += motion;
} }
return support; return support;
} }
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const { r_amount = 0; }
bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { return false; }
virtual bool intersect_point(const Vector3 &p_point) const { return false; }
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const { return p_point; }
Vector3 get_moment_of_inertia(real_t p_mass) const { return Vector3(); } virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const override { r_amount = 0; }
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const override { return false; }
virtual bool intersect_point(const Vector3 &p_point) const override { return false; }
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const override { return p_point; }
virtual void set_data(const Variant &p_data) {} virtual Vector3 get_moment_of_inertia(real_t p_mass) const override { return Vector3(); }
virtual Variant get_data() const { return Variant(); }
virtual void set_data(const Variant &p_data) override {}
virtual Variant get_data() const override { return Variant(); }
MotionShape3DSW() { configure(AABB()); } MotionShape3DSW() { configure(AABB()); }
}; };