diff options
author | Tristan Porteries <tristan@upbge.org> | 2018-07-10 12:50:14 +0000 |
---|---|---|
committer | Porteries Tristan <republicthunderbolt9@gmail.com> | 2018-08-16 16:58:15 +0200 |
commit | e5bfa98d0fa6a1acb1d385534c51b8006ef64142 (patch) | |
tree | 3da6e820e9564b7b8a710f6af74659e4ba880655 /scene/resources/shape.cpp | |
parent | b01f036fb4dedaa3e0d9b36360ef08f706007a32 (diff) | |
download | redot-engine-e5bfa98d0fa6a1acb1d385534c51b8006ef64142.tar.gz |
Expose bullet shape margin to UI.
The margin value is exposed into the UI for shape ressource.
This value can be modified through set_margin and get from get_margin
or by using the property margin. Each time the margin is modified
the associated collision shape is recreated and the margin value is
used in ShapeBullet::prepare.
Diffstat (limited to 'scene/resources/shape.cpp')
-rw-r--r-- | scene/resources/shape.cpp | 23 |
1 files changed, 21 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; } |