summaryrefslogtreecommitdiff
path: root/modules/bullet/area_bullet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/bullet/area_bullet.cpp')
-rw-r--r--modules/bullet/area_bullet.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/modules/bullet/area_bullet.cpp b/modules/bullet/area_bullet.cpp
index b35019bea3..c3bd84c329 100644
--- a/modules/bullet/area_bullet.cpp
+++ b/modules/bullet/area_bullet.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -65,11 +65,14 @@ AreaBullet::~AreaBullet() {
}
void AreaBullet::dispatch_callbacks() {
- RigidCollisionObjectBullet::dispatch_callbacks();
+ if (!isScratched) {
+ return;
+ }
+ isScratched = false;
// Reverse order because I've to remove EXIT objects
for (int i = overlappingObjects.size() - 1; 0 <= i; --i) {
- OverlappingObjectData &otherObj = overlappingObjects[i];
+ OverlappingObjectData &otherObj = overlappingObjects.write[i];
switch (otherObj.state) {
case OVERLAP_STATE_ENTER:
@@ -109,9 +112,10 @@ void AreaBullet::call_event(CollisionObjectBullet *p_otherObject, PhysicsServer3
}
void AreaBullet::scratch() {
- if (space != nullptr) {
- space->add_to_pre_flush_queue(this);
+ if (isScratched) {
+ return;
}
+ isScratched = true;
}
void AreaBullet::clear_overlaps(bool p_notify) {
@@ -160,7 +164,7 @@ void AreaBullet::main_shape_changed() {
btGhost->setCollisionShape(get_main_shape());
}
-void AreaBullet::do_reload_body() {
+void AreaBullet::reload_body() {
if (space) {
space->remove_area(this);
space->add_area(this);
@@ -169,25 +173,22 @@ void AreaBullet::do_reload_body() {
void AreaBullet::set_space(SpaceBullet *p_space) {
// Clear the old space if there is one
-
if (space) {
clear_overlaps(false);
+ isScratched = false;
// Remove this object form the physics world
- space->unregister_collision_object(this);
space->remove_area(this);
}
space = p_space;
if (space) {
- space->register_collision_object(this);
- reload_body();
- scratch();
+ space->add_area(this);
}
}
-void AreaBullet::do_reload_collision_filters() {
+void AreaBullet::on_collision_filters_change() {
if (space) {
space->reload_collision_filters(this);
}
@@ -201,13 +202,13 @@ void AreaBullet::add_overlap(CollisionObjectBullet *p_otherObject) {
void AreaBullet::put_overlap_as_exit(int p_index) {
scratch();
- overlappingObjects[p_index].state = OVERLAP_STATE_EXIT;
+ overlappingObjects.write[p_index].state = OVERLAP_STATE_EXIT;
}
void AreaBullet::put_overlap_as_inside(int p_index) {
// This check is required to be sure this body was inside
if (OVERLAP_STATE_DIRTY == overlappingObjects[p_index].state) {
- overlappingObjects[p_index].state = OVERLAP_STATE_INSIDE;
+ overlappingObjects.write[p_index].state = OVERLAP_STATE_INSIDE;
}
}