diff options
author | m4nu3lf <m4nu3lf@gmail.com> | 2016-12-31 14:39:25 +0000 |
---|---|---|
committer | m4nu3lf <m4nu3lf@gmail.com> | 2017-01-09 00:13:54 +0000 |
commit | 2e38b32e0f261445c2d0b095c1822fbe6df16e25 (patch) | |
tree | 7add49833c34260d581424469818573abd44104a /servers/physics/shape_sw.h | |
parent | f2e99826c0b1e8227644bfab0795d858c504d279 (diff) |
Fixed inertia tensor computation and center of mass
Diffstat (limited to 'servers/physics/shape_sw.h')
-rw-r--r-- | servers/physics/shape_sw.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/servers/physics/shape_sw.h b/servers/physics/shape_sw.h index d031a9fb9b..e76237017d 100644 --- a/servers/physics/shape_sw.h +++ b/servers/physics/shape_sw.h @@ -73,6 +73,8 @@ public: MAX_SUPPORTS=8 }; + virtual real_t get_area() const { return aabb.get_area();} + _FORCE_INLINE_ void set_self(const RID& p_self) { self=p_self; } _FORCE_INLINE_ RID get_self() const {return self; } @@ -128,6 +130,7 @@ public: Plane get_plane() const; + virtual real_t get_area() const { return INFINITY; } virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_PLANE; } virtual void project_range(const Vector3& p_normal, const Transform& p_transform, real_t &r_min, real_t &r_max) const; virtual Vector3 get_support(const Vector3& p_normal) const; @@ -152,6 +155,7 @@ public: float get_length() const; + virtual real_t get_area() const { return 0.0; } virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_RAY; } virtual void project_range(const Vector3& p_normal, const Transform& p_transform, real_t &r_min, real_t &r_max) const; virtual Vector3 get_support(const Vector3& p_normal) const; @@ -176,6 +180,8 @@ public: real_t get_radius() const; + virtual real_t get_area() const { return 4.0/3.0 * Math_PI * radius * radius * radius; } + virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_SPHERE; } virtual void project_range(const Vector3& p_normal, const Transform& p_transform, real_t &r_min, real_t &r_max) const; @@ -198,6 +204,7 @@ class BoxShapeSW : public ShapeSW { public: _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 PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_BOX; } @@ -226,6 +233,8 @@ public: _FORCE_INLINE_ real_t get_height() const { return height; } _FORCE_INLINE_ real_t get_radius() const { return radius; } + virtual real_t get_area() { return 4.0/3.0 * Math_PI * radius * radius * radius + height * Math_PI * radius * radius; } + virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CAPSULE; } virtual void project_range(const Vector3& p_normal, const Transform& p_transform, real_t &r_min, real_t &r_max) const; |