diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-08-21 16:17:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-21 16:17:11 +0200 |
commit | 912131fe03d7f82126463fc62cc0a166ed5434f4 (patch) | |
tree | 16f65eff26c02b1d2ea687f3b2724a3c6cb26484 /scene/resources | |
parent | 238b70e2db7e376ce8b627bbba5770535270da30 (diff) | |
parent | e5bfa98d0fa6a1acb1d385534c51b8006ef64142 (diff) |
Merge pull request #20101 from panzergame/shape_margin
Expose bullet shape margin to UI.
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/shape.cpp | 23 | ||||
-rw-r--r-- | scene/resources/shape.h | 6 |
2 files changed, 27 insertions, 2 deletions
diff --git a/scene/resources/shape.cpp b/scene/resources/shape.cpp index 418d8ce819..a48ce0564b 100644 --- a/scene/resources/shape.cpp +++ b/scene/resources/shape.cpp @@ -50,6 +50,15 @@ void Shape::add_vertices_to_array(PoolVector<Vector3> &array, const Transform &p } } +real_t Shape::get_margin() const { + return margin; +} + +void Shape::set_margin(real_t p_margin) { + margin = p_margin; + PhysicsServer::get_singleton()->shape_set_margin(shape, margin); +} + Ref<ArrayMesh> Shape::get_debug_mesh() { if (debug_mesh_cache.is_valid()) @@ -87,12 +96,22 @@ Ref<ArrayMesh> Shape::get_debug_mesh() { return debug_mesh_cache; } -Shape::Shape() { +void Shape::_bind_methods() { + + ClassDB::bind_method(D_METHOD("set_margin", "margin"), &Shape::set_margin); + ClassDB::bind_method(D_METHOD("get_margin"), &Shape::get_margin); + + ADD_PROPERTY(PropertyInfo(Variant::REAL, "margin", PROPERTY_HINT_RANGE, "0.04,10,0.01"), "set_margin", "get_margin"); +} + +Shape::Shape() : + margin(0.04) { ERR_PRINT("Constructor must not be called!"); } -Shape::Shape(RID p_shape) { +Shape::Shape(RID p_shape) : + margin(0.04) { shape = p_shape; } diff --git a/scene/resources/shape.h b/scene/resources/shape.h index ad87a69679..0c44b86e92 100644 --- a/scene/resources/shape.h +++ b/scene/resources/shape.h @@ -40,10 +40,13 @@ class Shape : public Resource { OBJ_SAVE_TYPE(Shape); RES_BASE_EXTENSION("shape"); RID shape; + real_t margin; Ref<ArrayMesh> debug_mesh_cache; protected: + static void _bind_methods(); + _FORCE_INLINE_ RID get_shape() const { return shape; } Shape(RID p_shape); @@ -55,6 +58,9 @@ public: void add_vertices_to_array(PoolVector<Vector3> &array, const Transform &p_xform); + real_t get_margin() const; + void set_margin(real_t p_margin); + Shape(); ~Shape(); }; |