summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-12-12 16:39:45 +0100
committerGitHub <noreply@github.com>2018-12-12 16:39:45 +0100
commitc7cef29b00430e01faceed396dbd9def1b7cb235 (patch)
treeae580102d211b02dd87e54e960b965012d296723 /servers
parentde264a819901d92501a69e19bb84632e70b1b5a6 (diff)
parent9edf98e8419ce68085a308ba4ae65fe8bf8a9f17 (diff)
Merge pull request #24218 from staddy/master
Disabled CollisionShape2D is not processed now
Diffstat (limited to 'servers')
-rw-r--r--servers/physics/body_sw.cpp4
-rw-r--r--servers/physics/collision_object_sw.h4
-rw-r--r--servers/physics_2d/body_2d_sw.cpp4
-rw-r--r--servers/physics_2d/collision_object_2d_sw.h4
4 files changed, 16 insertions, 0 deletions
diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp
index 36511f78ce..74cb724bb3 100644
--- a/servers/physics/body_sw.cpp
+++ b/servers/physics/body_sw.cpp
@@ -87,6 +87,10 @@ void BodySW::update_inertias() {
for (int i = 0; i < get_shape_count(); i++) {
+ if (is_shape_disabled(i)) {
+ continue;
+ }
+
const ShapeSW *shape = get_shape(i);
real_t area = get_shape_area(i);
diff --git a/servers/physics/collision_object_sw.h b/servers/physics/collision_object_sw.h
index 993799ee10..dc482baccb 100644
--- a/servers/physics/collision_object_sw.h
+++ b/servers/physics/collision_object_sw.h
@@ -122,6 +122,10 @@ public:
void set_shape(int p_index, ShapeSW *p_shape);
void set_shape_transform(int p_index, const Transform &p_transform);
_FORCE_INLINE_ int get_shape_count() const { return shapes.size(); }
+ _FORCE_INLINE_ bool is_shape_disabled(int p_index) const {
+ CRASH_BAD_INDEX(p_index, shapes.size());
+ return shapes[p_index].disabled;
+ }
_FORCE_INLINE_ ShapeSW *get_shape(int p_index) const { return shapes[p_index].shape; }
_FORCE_INLINE_ const Transform &get_shape_transform(int p_index) const { return shapes[p_index].xform; }
_FORCE_INLINE_ const Transform &get_shape_inv_transform(int p_index) const { return shapes[p_index].xform_inv; }
diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp
index 52362386d2..475c9ba977 100644
--- a/servers/physics_2d/body_2d_sw.cpp
+++ b/servers/physics_2d/body_2d_sw.cpp
@@ -61,6 +61,10 @@ void Body2DSW::update_inertias() {
for (int i = 0; i < get_shape_count(); i++) {
+ if (is_shape_disabled(i)) {
+ continue;
+ }
+
const Shape2DSW *shape = get_shape(i);
real_t area = get_shape_aabb(i).get_area();
diff --git a/servers/physics_2d/collision_object_2d_sw.h b/servers/physics_2d/collision_object_2d_sw.h
index f256910f52..2bf8cba572 100644
--- a/servers/physics_2d/collision_object_2d_sw.h
+++ b/servers/physics_2d/collision_object_2d_sw.h
@@ -115,6 +115,10 @@ public:
void set_shape_metadata(int p_index, const Variant &p_metadata);
_FORCE_INLINE_ int get_shape_count() const { return shapes.size(); }
+ _FORCE_INLINE_ bool is_shape_disabled(int p_index) const {
+ CRASH_BAD_INDEX(p_index, shapes.size());
+ return shapes[p_index].disabled;
+ }
_FORCE_INLINE_ Shape2DSW *get_shape(int p_index) const {
CRASH_BAD_INDEX(p_index, shapes.size());
return shapes[p_index].shape;