Fix body leaving area gravity influence

(cherry picked from commit 492f1c2406)
This commit is contained in:
Occalepsus 2023-10-05 13:46:10 +02:00 committed by Yuri Sizov
parent 837aeeac89
commit c12a46d3f4
4 changed files with 15 additions and 3 deletions

View File

@ -66,6 +66,7 @@ bool GodotAreaPair2D::pre_solve(real_t p_step) {
if (colliding) {
if (has_space_override) {
body_has_attached_area = true;
body->add_area(area);
}
@ -74,6 +75,7 @@ bool GodotAreaPair2D::pre_solve(real_t p_step) {
}
} else {
if (has_space_override) {
body_has_attached_area = false;
body->remove_area(area);
}
@ -103,7 +105,8 @@ GodotAreaPair2D::GodotAreaPair2D(GodotBody2D *p_body, int p_body_shape, GodotAre
GodotAreaPair2D::~GodotAreaPair2D() {
if (colliding) {
if (has_space_override) {
if (body_has_attached_area) {
body_has_attached_area = false;
body->remove_area(area);
}
if (area->has_monitor_callback()) {

View File

@ -43,6 +43,7 @@ class GodotAreaPair2D : public GodotConstraint2D {
bool colliding = false;
bool has_space_override = false;
bool process_collision = false;
bool body_has_attached_area = false;
public:
virtual bool setup(real_t p_step) override;

View File

@ -67,6 +67,7 @@ bool GodotAreaPair3D::pre_solve(real_t p_step) {
if (colliding) {
if (has_space_override) {
body_has_attached_area = true;
body->add_area(area);
}
@ -75,6 +76,7 @@ bool GodotAreaPair3D::pre_solve(real_t p_step) {
}
} else {
if (has_space_override) {
body_has_attached_area = false;
body->remove_area(area);
}
@ -104,7 +106,8 @@ GodotAreaPair3D::GodotAreaPair3D(GodotBody3D *p_body, int p_body_shape, GodotAre
GodotAreaPair3D::~GodotAreaPair3D() {
if (colliding) {
if (has_space_override) {
if (body_has_attached_area) {
body_has_attached_area = false;
body->remove_area(area);
}
if (area->has_monitor_callback()) {
@ -242,6 +245,7 @@ bool GodotAreaSoftBodyPair3D::pre_solve(real_t p_step) {
if (colliding) {
if (has_space_override) {
body_has_attached_area = true;
soft_body->add_area(area);
}
@ -250,6 +254,7 @@ bool GodotAreaSoftBodyPair3D::pre_solve(real_t p_step) {
}
} else {
if (has_space_override) {
body_has_attached_area = false;
soft_body->remove_area(area);
}
@ -276,7 +281,8 @@ GodotAreaSoftBodyPair3D::GodotAreaSoftBodyPair3D(GodotSoftBody3D *p_soft_body, i
GodotAreaSoftBodyPair3D::~GodotAreaSoftBodyPair3D() {
if (colliding) {
if (has_space_override) {
if (body_has_attached_area) {
body_has_attached_area = false;
soft_body->remove_area(area);
}
if (area->has_monitor_callback()) {

View File

@ -44,6 +44,7 @@ class GodotAreaPair3D : public GodotConstraint3D {
bool colliding = false;
bool process_collision = false;
bool has_space_override = false;
bool body_has_attached_area = false;
public:
virtual bool setup(real_t p_step) override;
@ -83,6 +84,7 @@ class GodotAreaSoftBodyPair3D : public GodotConstraint3D {
bool colliding = false;
bool process_collision = false;
bool has_space_override = false;
bool body_has_attached_area = false;
public:
virtual bool setup(real_t p_step) override;