summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-04-26 17:46:20 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-04-26 17:46:20 -0300
commit79d5b7f2580e5da87d8c962558517d7cc65fdf45 (patch)
tree37408978e6b58b30f7d13250c15cd5f53cf8b46a /scene
parent3bcb930e8ac1c8048de990f41c29cd2dfcc3c2a2 (diff)
-fixed bodyenter/bodyexit callback of physics bodies, fixes #1739
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/physics_body_2d.cpp16
-rw-r--r--scene/3d/physics_body.cpp11
2 files changed, 20 insertions, 7 deletions
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index b55e9f28d1..e7bc199608 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -277,6 +277,13 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.find(objid);
+ /*if (obj) {
+ if (body_in)
+ print_line("in: "+String(obj->call("get_name")));
+ else
+ print_line("out: "+String(obj->call("get_name")));
+ }*/
+
ERR_FAIL_COND(!body_in && !E);
if (body_in) {
@@ -386,14 +393,14 @@ void RigidBody2D::_direct_state_changed(Object *p_state) {
ObjectID obj = state->get_contact_collider_id(i);
int local_shape = state->get_contact_local_shape(i);
int shape = state->get_contact_collider_shape(i);
- toadd[i].local_shape=local_shape;
- toadd[i].id=obj;
- toadd[i].shape=shape;
// bool found=false;
Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.find(obj);
if (!E) {
+ toadd[toadd_count].local_shape=local_shape;
+ toadd[toadd_count].id=obj;
+ toadd[toadd_count].shape=shape;
toadd_count++;
continue;
}
@@ -402,6 +409,9 @@ void RigidBody2D::_direct_state_changed(Object *p_state) {
int idx = E->get().shapes.find(sp);
if (idx==-1) {
+ toadd[toadd_count].local_shape=local_shape;
+ toadd[toadd_count].id=obj;
+ toadd[toadd_count].shape=shape;
toadd_count++;
continue;
}
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 469ea0dd9a..3d5091f667 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -338,14 +338,14 @@ void RigidBody::_direct_state_changed(Object *p_state) {
ObjectID obj = state->get_contact_collider_id(i);
int local_shape = state->get_contact_local_shape(i);
int shape = state->get_contact_collider_shape(i);
- toadd[i].local_shape=local_shape;
- toadd[i].id=obj;
- toadd[i].shape=shape;
- bool found=false;
+// bool found=false;
Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.find(obj);
if (!E) {
+ toadd[toadd_count].local_shape=local_shape;
+ toadd[toadd_count].id=obj;
+ toadd[toadd_count].shape=shape;
toadd_count++;
continue;
}
@@ -354,6 +354,9 @@ void RigidBody::_direct_state_changed(Object *p_state) {
int idx = E->get().shapes.find(sp);
if (idx==-1) {
+ toadd[toadd_count].local_shape=local_shape;
+ toadd[toadd_count].id=obj;
+ toadd[toadd_count].shape=shape;
toadd_count++;
continue;
}