diff options
author | ShyRed <ShyRed@users.noreply.github.com> | 2019-03-24 10:38:31 +0100 |
---|---|---|
committer | ShyRed <ShyRed@users.noreply.github.com> | 2019-04-23 18:06:48 +0200 |
commit | a9d4cde0f5abc399332dde0c7415b99a5796eb34 (patch) | |
tree | 1063803662cb51ad51ac81063a8e532fb3d30cc6 /servers/physics_2d | |
parent | 6098a7f1914f64c77d689f54d5432095911b744f (diff) |
Allow adding disabled shapes
Adds the ability to directly add disabled shapes to a collision object. Before this commit a shape has always been assumed to be enabled and had to be disabled in an extra step.
Diffstat (limited to 'servers/physics_2d')
-rw-r--r-- | servers/physics_2d/collision_object_2d_sw.cpp | 4 | ||||
-rw-r--r-- | servers/physics_2d/collision_object_2d_sw.h | 2 | ||||
-rw-r--r-- | servers/physics_2d/physics_2d_server_sw.cpp | 8 | ||||
-rw-r--r-- | servers/physics_2d/physics_2d_server_sw.h | 4 | ||||
-rw-r--r-- | servers/physics_2d/physics_2d_server_wrap_mt.h | 4 |
5 files changed, 11 insertions, 11 deletions
diff --git a/servers/physics_2d/collision_object_2d_sw.cpp b/servers/physics_2d/collision_object_2d_sw.cpp index 4ec92497e7..445a2e0613 100644 --- a/servers/physics_2d/collision_object_2d_sw.cpp +++ b/servers/physics_2d/collision_object_2d_sw.cpp @@ -31,14 +31,14 @@ #include "collision_object_2d_sw.h" #include "space_2d_sw.h" -void CollisionObject2DSW::add_shape(Shape2DSW *p_shape, const Transform2D &p_transform) { +void CollisionObject2DSW::add_shape(Shape2DSW *p_shape, const Transform2D &p_transform, bool p_disabled) { Shape s; s.shape = p_shape; s.xform = p_transform; s.xform_inv = s.xform.affine_inverse(); s.bpid = 0; //needs update - s.disabled = false; + s.disabled = p_disabled; s.one_way_collision = false; s.one_way_collision_margin = 0; shapes.push_back(s); diff --git a/servers/physics_2d/collision_object_2d_sw.h b/servers/physics_2d/collision_object_2d_sw.h index d5e815ff45..fa18e61262 100644 --- a/servers/physics_2d/collision_object_2d_sw.h +++ b/servers/physics_2d/collision_object_2d_sw.h @@ -111,7 +111,7 @@ public: void _shape_changed(); _FORCE_INLINE_ Type get_type() const { return type; } - void add_shape(Shape2DSW *p_shape, const Transform2D &p_transform = Transform2D()); + void add_shape(Shape2DSW *p_shape, const Transform2D &p_transform = Transform2D(), bool p_disabled = false); void set_shape(int p_index, Shape2DSW *p_shape); void set_shape_transform(int p_index, const Transform2D &p_transform); void set_shape_metadata(int p_index, const Variant &p_metadata); diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp index 283d20876d..1d02227052 100644 --- a/servers/physics_2d/physics_2d_server_sw.cpp +++ b/servers/physics_2d/physics_2d_server_sw.cpp @@ -378,7 +378,7 @@ Physics2DServer::AreaSpaceOverrideMode Physics2DServerSW::area_get_space_overrid return area->get_space_override_mode(); } -void Physics2DServerSW::area_add_shape(RID p_area, RID p_shape, const Transform2D &p_transform) { +void Physics2DServerSW::area_add_shape(RID p_area, RID p_shape, const Transform2D &p_transform, bool p_disabled) { Area2DSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); @@ -386,7 +386,7 @@ void Physics2DServerSW::area_add_shape(RID p_area, RID p_shape, const Transform2 Shape2DSW *shape = shape_owner.get(p_shape); ERR_FAIL_COND(!shape); - area->add_shape(shape, p_transform); + area->add_shape(shape, p_transform, p_disabled); } void Physics2DServerSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) { @@ -643,7 +643,7 @@ Physics2DServer::BodyMode Physics2DServerSW::body_get_mode(RID p_body) const { return body->get_mode(); }; -void Physics2DServerSW::body_add_shape(RID p_body, RID p_shape, const Transform2D &p_transform) { +void Physics2DServerSW::body_add_shape(RID p_body, RID p_shape, const Transform2D &p_transform, bool p_disabled) { Body2DSW *body = body_owner.get(p_body); ERR_FAIL_COND(!body); @@ -651,7 +651,7 @@ void Physics2DServerSW::body_add_shape(RID p_body, RID p_shape, const Transform2 Shape2DSW *shape = shape_owner.get(p_shape); ERR_FAIL_COND(!shape); - body->add_shape(shape, p_transform); + body->add_shape(shape, p_transform, p_disabled); } void Physics2DServerSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) { diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h index 4beec41442..6fda74b877 100644 --- a/servers/physics_2d/physics_2d_server_sw.h +++ b/servers/physics_2d/physics_2d_server_sw.h @@ -131,7 +131,7 @@ public: virtual void area_set_space(RID p_area, RID p_space); virtual RID area_get_space(RID p_area) const; - virtual void area_add_shape(RID p_area, RID p_shape, const Transform2D &p_transform = Transform2D()); + virtual void area_add_shape(RID p_area, RID p_shape, const Transform2D &p_transform = Transform2D(), bool p_disabled = false); virtual void area_set_shape(RID p_area, int p_shape_idx, RID p_shape); virtual void area_set_shape_transform(RID p_area, int p_shape_idx, const Transform2D &p_transform); @@ -175,7 +175,7 @@ public: virtual void body_set_mode(RID p_body, BodyMode p_mode); virtual BodyMode body_get_mode(RID p_body) const; - virtual void body_add_shape(RID p_body, RID p_shape, const Transform2D &p_transform = Transform2D()); + virtual void body_add_shape(RID p_body, RID p_shape, const Transform2D &p_transform = Transform2D(), bool p_disabled = false); virtual void body_set_shape(RID p_body, int p_shape_idx, RID p_shape); virtual void body_set_shape_transform(RID p_body, int p_shape_idx, const Transform2D &p_transform); virtual void body_set_shape_metadata(RID p_body, int p_shape_idx, const Variant &p_metadata); diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_2d_server_wrap_mt.h index 5b9a102a1b..b61e1faad2 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.h +++ b/servers/physics_2d/physics_2d_server_wrap_mt.h @@ -140,7 +140,7 @@ public: FUNC2(area_set_space_override_mode, RID, AreaSpaceOverrideMode); FUNC1RC(AreaSpaceOverrideMode, area_get_space_override_mode, RID); - FUNC3(area_add_shape, RID, RID, const Transform2D &); + FUNC4(area_add_shape, RID, RID, const Transform2D &, bool); FUNC3(area_set_shape, RID, int, RID); FUNC3(area_set_shape_transform, RID, int, const Transform2D &); FUNC3(area_set_shape_disabled, RID, int, bool); @@ -183,7 +183,7 @@ public: FUNC2(body_set_mode, RID, BodyMode); FUNC1RC(BodyMode, body_get_mode, RID); - FUNC3(body_add_shape, RID, RID, const Transform2D &); + FUNC4(body_add_shape, RID, RID, const Transform2D &, bool); FUNC3(body_set_shape, RID, int, RID); FUNC3(body_set_shape_transform, RID, int, const Transform2D &); FUNC3(body_set_shape_metadata, RID, int, const Variant &); |