Return RID instead of Object id in area-body_shape_entered-exited signals.
This commit is contained in:
parent
a133d4577c
commit
09456c2a01
12 changed files with 84 additions and 62 deletions
|
@ -117,7 +117,7 @@
|
||||||
</description>
|
</description>
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="area_shape_entered">
|
<signal name="area_shape_entered">
|
||||||
<argument index="0" name="area_id" type="int">
|
<argument index="0" name="area_rid" type="RID">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="area" type="Area">
|
<argument index="1" name="area" type="Area">
|
||||||
</argument>
|
</argument>
|
||||||
|
@ -134,7 +134,7 @@
|
||||||
</description>
|
</description>
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="area_shape_exited">
|
<signal name="area_shape_exited">
|
||||||
<argument index="0" name="area_id" type="int">
|
<argument index="0" name="area_rid" type="RID">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="area" type="Area">
|
<argument index="1" name="area" type="Area">
|
||||||
</argument>
|
</argument>
|
||||||
|
@ -167,7 +167,7 @@
|
||||||
</description>
|
</description>
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="body_shape_entered">
|
<signal name="body_shape_entered">
|
||||||
<argument index="0" name="body_id" type="int">
|
<argument index="0" name="body_rid" type="RID">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="body" type="Node">
|
<argument index="1" name="body" type="Node">
|
||||||
</argument>
|
</argument>
|
||||||
|
@ -184,7 +184,7 @@
|
||||||
</description>
|
</description>
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="body_shape_exited">
|
<signal name="body_shape_exited">
|
||||||
<argument index="0" name="body_id" type="int">
|
<argument index="0" name="body_rid" type="RID">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="body" type="Node">
|
<argument index="1" name="body" type="Node">
|
||||||
</argument>
|
</argument>
|
||||||
|
|
|
@ -107,7 +107,7 @@
|
||||||
</description>
|
</description>
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="area_shape_entered">
|
<signal name="area_shape_entered">
|
||||||
<argument index="0" name="area_id" type="int">
|
<argument index="0" name="area_rid" type="RID">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="area" type="Area2D">
|
<argument index="1" name="area" type="Area2D">
|
||||||
</argument>
|
</argument>
|
||||||
|
@ -124,7 +124,7 @@
|
||||||
</description>
|
</description>
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="area_shape_exited">
|
<signal name="area_shape_exited">
|
||||||
<argument index="0" name="area_id" type="int">
|
<argument index="0" name="area_rid" type="RID">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="area" type="Area2D">
|
<argument index="1" name="area" type="Area2D">
|
||||||
</argument>
|
</argument>
|
||||||
|
@ -157,7 +157,7 @@
|
||||||
</description>
|
</description>
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="body_shape_entered">
|
<signal name="body_shape_entered">
|
||||||
<argument index="0" name="body_id" type="int">
|
<argument index="0" name="body_rid" type="RID">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="body" type="Node">
|
<argument index="1" name="body" type="Node">
|
||||||
</argument>
|
</argument>
|
||||||
|
@ -174,7 +174,7 @@
|
||||||
</description>
|
</description>
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="body_shape_exited">
|
<signal name="body_shape_exited">
|
||||||
<argument index="0" name="body_id" type="int">
|
<argument index="0" name="body_rid" type="RID">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="body" type="Node">
|
<argument index="1" name="body" type="Node">
|
||||||
</argument>
|
</argument>
|
||||||
|
|
|
@ -228,7 +228,7 @@
|
||||||
</description>
|
</description>
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="body_shape_entered">
|
<signal name="body_shape_entered">
|
||||||
<argument index="0" name="body_id" type="int">
|
<argument index="0" name="body_rid" type="RID">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="body" type="Node">
|
<argument index="1" name="body" type="Node">
|
||||||
</argument>
|
</argument>
|
||||||
|
@ -246,7 +246,7 @@
|
||||||
</description>
|
</description>
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="body_shape_exited">
|
<signal name="body_shape_exited">
|
||||||
<argument index="0" name="body_id" type="int">
|
<argument index="0" name="body_rid" type="RID">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="body" type="Node">
|
<argument index="1" name="body" type="Node">
|
||||||
</argument>
|
</argument>
|
||||||
|
|
|
@ -204,7 +204,7 @@
|
||||||
</description>
|
</description>
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="body_shape_entered">
|
<signal name="body_shape_entered">
|
||||||
<argument index="0" name="body_id" type="int">
|
<argument index="0" name="body_rid" type="RID">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="body" type="Node">
|
<argument index="1" name="body" type="Node">
|
||||||
</argument>
|
</argument>
|
||||||
|
@ -221,7 +221,7 @@
|
||||||
</description>
|
</description>
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="body_shape_exited">
|
<signal name="body_shape_exited">
|
||||||
<argument index="0" name="body_id" type="int">
|
<argument index="0" name="body_rid" type="RID">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="body" type="Node">
|
<argument index="1" name="body" type="Node">
|
||||||
</argument>
|
</argument>
|
||||||
|
|
|
@ -111,7 +111,7 @@ void Area2D::_body_enter_tree(ObjectID p_id) {
|
||||||
E->get().in_tree = true;
|
E->get().in_tree = true;
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
|
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
|
||||||
for (int i = 0; i < E->get().shapes.size(); i++) {
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
|
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, E->get().rid, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ void Area2D::_body_exit_tree(ObjectID p_id) {
|
||||||
E->get().in_tree = false;
|
E->get().in_tree = false;
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
|
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
|
||||||
for (int i = 0; i < E->get().shapes.size(); i++) {
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
|
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, E->get().rid, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,6 +147,7 @@ void Area2D::_body_inout(int p_status, const RID &p_body, int p_instance, int p_
|
||||||
if (body_in) {
|
if (body_in) {
|
||||||
if (!E) {
|
if (!E) {
|
||||||
E = body_map.insert(objid, BodyState());
|
E = body_map.insert(objid, BodyState());
|
||||||
|
E->get().rid = p_body;
|
||||||
E->get().rc = 0;
|
E->get().rc = 0;
|
||||||
E->get().in_tree = node && node->is_inside_tree();
|
E->get().in_tree = node && node->is_inside_tree();
|
||||||
if (node) {
|
if (node) {
|
||||||
|
@ -163,7 +164,7 @@ void Area2D::_body_inout(int p_status, const RID &p_body, int p_instance, int p_
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!node || E->get().in_tree) {
|
if (!node || E->get().in_tree) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, objid, node, p_body_shape, p_area_shape);
|
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, p_body, node, p_body_shape, p_area_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -185,7 +186,7 @@ void Area2D::_body_inout(int p_status, const RID &p_body, int p_instance, int p_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!node || in_tree) {
|
if (!node || in_tree) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, objid, obj, p_body_shape, p_area_shape);
|
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, p_body, obj, p_body_shape, p_area_shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +205,7 @@ void Area2D::_area_enter_tree(ObjectID p_id) {
|
||||||
E->get().in_tree = true;
|
E->get().in_tree = true;
|
||||||
emit_signal(SceneStringNames::get_singleton()->area_entered, node);
|
emit_signal(SceneStringNames::get_singleton()->area_entered, node);
|
||||||
for (int i = 0; i < E->get().shapes.size(); i++) {
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->area_shape_entered, p_id, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
|
emit_signal(SceneStringNames::get_singleton()->area_shape_entered, E->get().rid, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +219,7 @@ void Area2D::_area_exit_tree(ObjectID p_id) {
|
||||||
E->get().in_tree = false;
|
E->get().in_tree = false;
|
||||||
emit_signal(SceneStringNames::get_singleton()->area_exited, node);
|
emit_signal(SceneStringNames::get_singleton()->area_exited, node);
|
||||||
for (int i = 0; i < E->get().shapes.size(); i++) {
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, p_id, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
|
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, E->get().rid, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,6 +240,7 @@ void Area2D::_area_inout(int p_status, const RID &p_area, int p_instance, int p_
|
||||||
if (area_in) {
|
if (area_in) {
|
||||||
if (!E) {
|
if (!E) {
|
||||||
E = area_map.insert(objid, AreaState());
|
E = area_map.insert(objid, AreaState());
|
||||||
|
E->get().rid = p_area;
|
||||||
E->get().rc = 0;
|
E->get().rc = 0;
|
||||||
E->get().in_tree = node && node->is_inside_tree();
|
E->get().in_tree = node && node->is_inside_tree();
|
||||||
if (node) {
|
if (node) {
|
||||||
|
@ -255,7 +257,7 @@ void Area2D::_area_inout(int p_status, const RID &p_area, int p_instance, int p_
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!node || E->get().in_tree) {
|
if (!node || E->get().in_tree) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->area_shape_entered, objid, node, p_area_shape, p_self_shape);
|
emit_signal(SceneStringNames::get_singleton()->area_shape_entered, p_area, node, p_area_shape, p_self_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -277,7 +279,7 @@ void Area2D::_area_inout(int p_status, const RID &p_area, int p_instance, int p_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!node || in_tree) {
|
if (!node || in_tree) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, objid, obj, p_area_shape, p_self_shape);
|
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, p_area, obj, p_area_shape, p_self_shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +311,7 @@ void Area2D::_clear_monitoring() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < E->get().shapes.size(); i++) {
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, E->key(), node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
|
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, E->get().rid, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_exited, obj);
|
emit_signal(SceneStringNames::get_singleton()->body_exited, obj);
|
||||||
|
@ -338,7 +340,7 @@ void Area2D::_clear_monitoring() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < E->get().shapes.size(); i++) {
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, E->key(), node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
|
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, E->get().rid, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit_signal(SceneStringNames::get_singleton()->area_exited, obj);
|
emit_signal(SceneStringNames::get_singleton()->area_exited, obj);
|
||||||
|
@ -533,13 +535,13 @@ void Area2D::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("_body_inout"), &Area2D::_body_inout);
|
ClassDB::bind_method(D_METHOD("_body_inout"), &Area2D::_body_inout);
|
||||||
ClassDB::bind_method(D_METHOD("_area_inout"), &Area2D::_area_inout);
|
ClassDB::bind_method(D_METHOD("_area_inout"), &Area2D::_area_inout);
|
||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::_RID, "body_rid"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
||||||
ADD_SIGNAL(MethodInfo("body_shape_exited", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
ADD_SIGNAL(MethodInfo("body_shape_exited", PropertyInfo(Variant::_RID, "body_rid"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
||||||
ADD_SIGNAL(MethodInfo("body_entered", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
|
ADD_SIGNAL(MethodInfo("body_entered", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
|
||||||
ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
|
ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
|
||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("area_shape_entered", PropertyInfo(Variant::INT, "area_id"), PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area2D"), PropertyInfo(Variant::INT, "area_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
ADD_SIGNAL(MethodInfo("area_shape_entered", PropertyInfo(Variant::_RID, "area_rid"), PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area2D"), PropertyInfo(Variant::INT, "area_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
||||||
ADD_SIGNAL(MethodInfo("area_shape_exited", PropertyInfo(Variant::INT, "area_id"), PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area2D"), PropertyInfo(Variant::INT, "area_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
ADD_SIGNAL(MethodInfo("area_shape_exited", PropertyInfo(Variant::_RID, "area_rid"), PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area2D"), PropertyInfo(Variant::INT, "area_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
||||||
ADD_SIGNAL(MethodInfo("area_entered", PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area2D")));
|
ADD_SIGNAL(MethodInfo("area_entered", PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area2D")));
|
||||||
ADD_SIGNAL(MethodInfo("area_exited", PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area2D")));
|
ADD_SIGNAL(MethodInfo("area_exited", PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area2D")));
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BodyState {
|
struct BodyState {
|
||||||
|
RID rid;
|
||||||
int rc;
|
int rc;
|
||||||
bool in_tree;
|
bool in_tree;
|
||||||
VSet<ShapePair> shapes;
|
VSet<ShapePair> shapes;
|
||||||
|
@ -114,6 +115,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AreaState {
|
struct AreaState {
|
||||||
|
RID rid;
|
||||||
int rc;
|
int rc;
|
||||||
bool in_tree;
|
bool in_tree;
|
||||||
VSet<AreaShapePair> shapes;
|
VSet<AreaShapePair> shapes;
|
||||||
|
|
|
@ -246,7 +246,7 @@ void RigidBody2D::_body_enter_tree(ObjectID p_id) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
|
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
|
||||||
|
|
||||||
for (int i = 0; i < E->get().shapes.size(); i++) {
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].local_shape);
|
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, E->get().rid, node, E->get().shapes[i].body_shape, E->get().shapes[i].local_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
contact_monitor->locked = false;
|
contact_monitor->locked = false;
|
||||||
|
@ -267,13 +267,13 @@ void RigidBody2D::_body_exit_tree(ObjectID p_id) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
|
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
|
||||||
|
|
||||||
for (int i = 0; i < E->get().shapes.size(); i++) {
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].local_shape);
|
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, E->get().rid, node, E->get().shapes[i].body_shape, E->get().shapes[i].local_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
contact_monitor->locked = false;
|
contact_monitor->locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape) {
|
void RigidBody2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_local_shape) {
|
||||||
bool body_in = p_status == 1;
|
bool body_in = p_status == 1;
|
||||||
ObjectID objid = p_instance;
|
ObjectID objid = p_instance;
|
||||||
|
|
||||||
|
@ -288,6 +288,7 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
|
||||||
if (body_in) {
|
if (body_in) {
|
||||||
if (!E) {
|
if (!E) {
|
||||||
E = contact_monitor->body_map.insert(objid, BodyState());
|
E = contact_monitor->body_map.insert(objid, BodyState());
|
||||||
|
E->get().rid = p_body;
|
||||||
//E->get().rc=0;
|
//E->get().rc=0;
|
||||||
E->get().in_scene = node && node->is_inside_tree();
|
E->get().in_scene = node && node->is_inside_tree();
|
||||||
if (node) {
|
if (node) {
|
||||||
|
@ -306,7 +307,7 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
|
||||||
}
|
}
|
||||||
|
|
||||||
if (E->get().in_scene) {
|
if (E->get().in_scene) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, objid, node, p_body_shape, p_local_shape);
|
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, p_body, node, p_body_shape, p_local_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -330,12 +331,13 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
|
||||||
contact_monitor->body_map.erase(E);
|
contact_monitor->body_map.erase(E);
|
||||||
}
|
}
|
||||||
if (node && in_scene) {
|
if (node && in_scene) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, objid, node, p_body_shape, p_local_shape);
|
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, p_body, node, p_body_shape, p_local_shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct _RigidBody2DInOut {
|
struct _RigidBody2DInOut {
|
||||||
|
RID rid;
|
||||||
ObjectID id;
|
ObjectID id;
|
||||||
int shape;
|
int shape;
|
||||||
int local_shape;
|
int local_shape;
|
||||||
|
@ -388,6 +390,7 @@ void RigidBody2D::_direct_state_changed(Object *p_state) {
|
||||||
//put the ones to add
|
//put the ones to add
|
||||||
|
|
||||||
for (int i = 0; i < state->get_contact_count(); i++) {
|
for (int i = 0; i < state->get_contact_count(); i++) {
|
||||||
|
RID rid = state->get_contact_collider(i);
|
||||||
ObjectID obj = state->get_contact_collider_id(i);
|
ObjectID obj = state->get_contact_collider_id(i);
|
||||||
int local_shape = state->get_contact_local_shape(i);
|
int local_shape = state->get_contact_local_shape(i);
|
||||||
int shape = state->get_contact_collider_shape(i);
|
int shape = state->get_contact_collider_shape(i);
|
||||||
|
@ -396,6 +399,7 @@ void RigidBody2D::_direct_state_changed(Object *p_state) {
|
||||||
|
|
||||||
Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(obj);
|
Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(obj);
|
||||||
if (!E) {
|
if (!E) {
|
||||||
|
toadd[toadd_count].rid = rid;
|
||||||
toadd[toadd_count].local_shape = local_shape;
|
toadd[toadd_count].local_shape = local_shape;
|
||||||
toadd[toadd_count].id = obj;
|
toadd[toadd_count].id = obj;
|
||||||
toadd[toadd_count].shape = shape;
|
toadd[toadd_count].shape = shape;
|
||||||
|
@ -406,6 +410,7 @@ void RigidBody2D::_direct_state_changed(Object *p_state) {
|
||||||
ShapePair sp(shape, local_shape);
|
ShapePair sp(shape, local_shape);
|
||||||
int idx = E->get().shapes.find(sp);
|
int idx = E->get().shapes.find(sp);
|
||||||
if (idx == -1) {
|
if (idx == -1) {
|
||||||
|
toadd[toadd_count].rid = rid;
|
||||||
toadd[toadd_count].local_shape = local_shape;
|
toadd[toadd_count].local_shape = local_shape;
|
||||||
toadd[toadd_count].id = obj;
|
toadd[toadd_count].id = obj;
|
||||||
toadd[toadd_count].shape = shape;
|
toadd[toadd_count].shape = shape;
|
||||||
|
@ -421,6 +426,7 @@ void RigidBody2D::_direct_state_changed(Object *p_state) {
|
||||||
for (Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) {
|
for (Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) {
|
||||||
for (int i = 0; i < E->get().shapes.size(); i++) {
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
||||||
if (!E->get().shapes[i].tagged) {
|
if (!E->get().shapes[i].tagged) {
|
||||||
|
toremove[toremove_count].rid = E->get().rid;
|
||||||
toremove[toremove_count].body_id = E->key();
|
toremove[toremove_count].body_id = E->key();
|
||||||
toremove[toremove_count].pair = E->get().shapes[i];
|
toremove[toremove_count].pair = E->get().shapes[i];
|
||||||
toremove_count++;
|
toremove_count++;
|
||||||
|
@ -431,13 +437,13 @@ void RigidBody2D::_direct_state_changed(Object *p_state) {
|
||||||
//process remotions
|
//process remotions
|
||||||
|
|
||||||
for (int i = 0; i < toremove_count; i++) {
|
for (int i = 0; i < toremove_count; i++) {
|
||||||
_body_inout(0, toremove[i].body_id, toremove[i].pair.body_shape, toremove[i].pair.local_shape);
|
_body_inout(0, toremove[i].rid, toremove[i].body_id, toremove[i].pair.body_shape, toremove[i].pair.local_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
//process aditions
|
//process aditions
|
||||||
|
|
||||||
for (int i = 0; i < toadd_count; i++) {
|
for (int i = 0; i < toadd_count; i++) {
|
||||||
_body_inout(1, toadd[i].id, toadd[i].shape, toadd[i].local_shape);
|
_body_inout(1, toadd[i].rid, toadd[i].id, toadd[i].shape, toadd[i].local_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
contact_monitor->locked = false;
|
contact_monitor->locked = false;
|
||||||
|
@ -913,8 +919,8 @@ void RigidBody2D::_bind_methods() {
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "applied_force"), "set_applied_force", "get_applied_force");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "applied_force"), "set_applied_force", "get_applied_force");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "applied_torque"), "set_applied_torque", "get_applied_torque");
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "applied_torque"), "set_applied_torque", "get_applied_torque");
|
||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::_RID, "body_rid"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
||||||
ADD_SIGNAL(MethodInfo("body_shape_exited", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
ADD_SIGNAL(MethodInfo("body_shape_exited", PropertyInfo(Variant::_RID, "body_rid"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
||||||
ADD_SIGNAL(MethodInfo("body_entered", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
|
ADD_SIGNAL(MethodInfo("body_entered", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
|
||||||
ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
|
ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
|
||||||
ADD_SIGNAL(MethodInfo("sleeping_state_changed"));
|
ADD_SIGNAL(MethodInfo("sleeping_state_changed"));
|
||||||
|
|
|
@ -150,11 +150,12 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct RigidBody2D_RemoveAction {
|
struct RigidBody2D_RemoveAction {
|
||||||
|
RID rid;
|
||||||
ObjectID body_id;
|
ObjectID body_id;
|
||||||
ShapePair pair;
|
ShapePair pair;
|
||||||
};
|
};
|
||||||
struct BodyState {
|
struct BodyState {
|
||||||
//int rc;
|
RID rid;
|
||||||
bool in_scene;
|
bool in_scene;
|
||||||
VSet<ShapePair> shapes;
|
VSet<ShapePair> shapes;
|
||||||
};
|
};
|
||||||
|
@ -168,7 +169,7 @@ private:
|
||||||
void _body_enter_tree(ObjectID p_id);
|
void _body_enter_tree(ObjectID p_id);
|
||||||
void _body_exit_tree(ObjectID p_id);
|
void _body_exit_tree(ObjectID p_id);
|
||||||
|
|
||||||
void _body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape);
|
void _body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_local_shape);
|
||||||
void _direct_state_changed(Object *p_state);
|
void _direct_state_changed(Object *p_state);
|
||||||
|
|
||||||
bool _test_motion(const Vector2 &p_motion, bool p_infinite_inertia = true, float p_margin = 0.08, const Ref<Physics2DTestMotionResult> &p_result = Ref<Physics2DTestMotionResult>());
|
bool _test_motion(const Vector2 &p_motion, bool p_infinite_inertia = true, float p_margin = 0.08, const Ref<Physics2DTestMotionResult> &p_result = Ref<Physics2DTestMotionResult>());
|
||||||
|
|
|
@ -110,7 +110,7 @@ void Area::_body_enter_tree(ObjectID p_id) {
|
||||||
E->get().in_tree = true;
|
E->get().in_tree = true;
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
|
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
|
||||||
for (int i = 0; i < E->get().shapes.size(); i++) {
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
|
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, E->get().rid, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ void Area::_body_exit_tree(ObjectID p_id) {
|
||||||
E->get().in_tree = false;
|
E->get().in_tree = false;
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
|
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
|
||||||
for (int i = 0; i < E->get().shapes.size(); i++) {
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
|
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, E->get().rid, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +146,7 @@ void Area::_body_inout(int p_status, const RID &p_body, int p_instance, int p_bo
|
||||||
if (body_in) {
|
if (body_in) {
|
||||||
if (!E) {
|
if (!E) {
|
||||||
E = body_map.insert(objid, BodyState());
|
E = body_map.insert(objid, BodyState());
|
||||||
|
E->get().rid = p_body;
|
||||||
E->get().rc = 0;
|
E->get().rc = 0;
|
||||||
E->get().in_tree = node && node->is_inside_tree();
|
E->get().in_tree = node && node->is_inside_tree();
|
||||||
if (node) {
|
if (node) {
|
||||||
|
@ -162,7 +163,7 @@ void Area::_body_inout(int p_status, const RID &p_body, int p_instance, int p_bo
|
||||||
}
|
}
|
||||||
|
|
||||||
if (E->get().in_tree) {
|
if (E->get().in_tree) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, objid, node, p_body_shape, p_area_shape);
|
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, p_body, node, p_body_shape, p_area_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -184,7 +185,7 @@ void Area::_body_inout(int p_status, const RID &p_body, int p_instance, int p_bo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (node && in_tree) {
|
if (node && in_tree) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, objid, obj, p_body_shape, p_area_shape);
|
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, p_body, obj, p_body_shape, p_area_shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +214,7 @@ void Area::_clear_monitoring() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < E->get().shapes.size(); i++) {
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, E->key(), node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
|
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, E->get().rid, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
|
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
|
||||||
|
@ -242,7 +243,7 @@ void Area::_clear_monitoring() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < E->get().shapes.size(); i++) {
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, E->key(), node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
|
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, E->get().rid, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit_signal(SceneStringNames::get_singleton()->area_exited, obj);
|
emit_signal(SceneStringNames::get_singleton()->area_exited, obj);
|
||||||
|
@ -289,7 +290,7 @@ void Area::_area_enter_tree(ObjectID p_id) {
|
||||||
E->get().in_tree = true;
|
E->get().in_tree = true;
|
||||||
emit_signal(SceneStringNames::get_singleton()->area_entered, node);
|
emit_signal(SceneStringNames::get_singleton()->area_entered, node);
|
||||||
for (int i = 0; i < E->get().shapes.size(); i++) {
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->area_shape_entered, p_id, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
|
emit_signal(SceneStringNames::get_singleton()->area_shape_entered, E->get().rid, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,7 +304,7 @@ void Area::_area_exit_tree(ObjectID p_id) {
|
||||||
E->get().in_tree = false;
|
E->get().in_tree = false;
|
||||||
emit_signal(SceneStringNames::get_singleton()->area_exited, node);
|
emit_signal(SceneStringNames::get_singleton()->area_exited, node);
|
||||||
for (int i = 0; i < E->get().shapes.size(); i++) {
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, p_id, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
|
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, E->get().rid, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,6 +326,7 @@ void Area::_area_inout(int p_status, const RID &p_area, int p_instance, int p_ar
|
||||||
if (area_in) {
|
if (area_in) {
|
||||||
if (!E) {
|
if (!E) {
|
||||||
E = area_map.insert(objid, AreaState());
|
E = area_map.insert(objid, AreaState());
|
||||||
|
E->get().rid = p_area;
|
||||||
E->get().rc = 0;
|
E->get().rc = 0;
|
||||||
E->get().in_tree = node && node->is_inside_tree();
|
E->get().in_tree = node && node->is_inside_tree();
|
||||||
if (node) {
|
if (node) {
|
||||||
|
@ -341,7 +343,7 @@ void Area::_area_inout(int p_status, const RID &p_area, int p_instance, int p_ar
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!node || E->get().in_tree) {
|
if (!node || E->get().in_tree) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->area_shape_entered, objid, node, p_area_shape, p_self_shape);
|
emit_signal(SceneStringNames::get_singleton()->area_shape_entered, p_area, node, p_area_shape, p_self_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -363,7 +365,7 @@ void Area::_area_inout(int p_status, const RID &p_area, int p_instance, int p_ar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!node || in_tree) {
|
if (!node || in_tree) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, objid, obj, p_area_shape, p_self_shape);
|
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, p_area, obj, p_area_shape, p_self_shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -574,13 +576,13 @@ void Area::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_reverb_uniformity", "amount"), &Area::set_reverb_uniformity);
|
ClassDB::bind_method(D_METHOD("set_reverb_uniformity", "amount"), &Area::set_reverb_uniformity);
|
||||||
ClassDB::bind_method(D_METHOD("get_reverb_uniformity"), &Area::get_reverb_uniformity);
|
ClassDB::bind_method(D_METHOD("get_reverb_uniformity"), &Area::get_reverb_uniformity);
|
||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::_RID, "body_rid"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
||||||
ADD_SIGNAL(MethodInfo("body_shape_exited", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
ADD_SIGNAL(MethodInfo("body_shape_exited", PropertyInfo(Variant::_RID, "body_rid"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
||||||
ADD_SIGNAL(MethodInfo("body_entered", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
|
ADD_SIGNAL(MethodInfo("body_entered", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
|
||||||
ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
|
ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
|
||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("area_shape_entered", PropertyInfo(Variant::INT, "area_id"), PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area"), PropertyInfo(Variant::INT, "area_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
ADD_SIGNAL(MethodInfo("area_shape_entered", PropertyInfo(Variant::_RID, "area_rid"), PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area"), PropertyInfo(Variant::INT, "area_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
||||||
ADD_SIGNAL(MethodInfo("area_shape_exited", PropertyInfo(Variant::INT, "area_id"), PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area"), PropertyInfo(Variant::INT, "area_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
ADD_SIGNAL(MethodInfo("area_shape_exited", PropertyInfo(Variant::_RID, "area_rid"), PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area"), PropertyInfo(Variant::INT, "area_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
||||||
ADD_SIGNAL(MethodInfo("area_entered", PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area")));
|
ADD_SIGNAL(MethodInfo("area_entered", PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area")));
|
||||||
ADD_SIGNAL(MethodInfo("area_exited", PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area")));
|
ADD_SIGNAL(MethodInfo("area_exited", PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area")));
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BodyState {
|
struct BodyState {
|
||||||
|
RID rid;
|
||||||
int rc;
|
int rc;
|
||||||
bool in_tree;
|
bool in_tree;
|
||||||
VSet<ShapePair> shapes;
|
VSet<ShapePair> shapes;
|
||||||
|
@ -114,6 +115,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AreaState {
|
struct AreaState {
|
||||||
|
RID rid;
|
||||||
int rc;
|
int rc;
|
||||||
bool in_tree;
|
bool in_tree;
|
||||||
VSet<AreaShapePair> shapes;
|
VSet<AreaShapePair> shapes;
|
||||||
|
|
|
@ -257,7 +257,7 @@ void RigidBody::_body_enter_tree(ObjectID p_id) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
|
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
|
||||||
|
|
||||||
for (int i = 0; i < E->get().shapes.size(); i++) {
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].local_shape);
|
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, E->get().rid, node, E->get().shapes[i].body_shape, E->get().shapes[i].local_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
contact_monitor->locked = false;
|
contact_monitor->locked = false;
|
||||||
|
@ -278,13 +278,13 @@ void RigidBody::_body_exit_tree(ObjectID p_id) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
|
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
|
||||||
|
|
||||||
for (int i = 0; i < E->get().shapes.size(); i++) {
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].local_shape);
|
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, E->get().rid, node, E->get().shapes[i].body_shape, E->get().shapes[i].local_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
contact_monitor->locked = false;
|
contact_monitor->locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape) {
|
void RigidBody::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_local_shape) {
|
||||||
bool body_in = p_status == 1;
|
bool body_in = p_status == 1;
|
||||||
ObjectID objid = p_instance;
|
ObjectID objid = p_instance;
|
||||||
|
|
||||||
|
@ -299,6 +299,7 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape,
|
||||||
if (body_in) {
|
if (body_in) {
|
||||||
if (!E) {
|
if (!E) {
|
||||||
E = contact_monitor->body_map.insert(objid, BodyState());
|
E = contact_monitor->body_map.insert(objid, BodyState());
|
||||||
|
E->get().rid = p_body;
|
||||||
//E->get().rc=0;
|
//E->get().rc=0;
|
||||||
E->get().in_tree = node && node->is_inside_tree();
|
E->get().in_tree = node && node->is_inside_tree();
|
||||||
if (node) {
|
if (node) {
|
||||||
|
@ -315,7 +316,7 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (E->get().in_tree) {
|
if (E->get().in_tree) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, objid, node, p_body_shape, p_local_shape);
|
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, p_body, node, p_body_shape, p_local_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -339,12 +340,13 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape,
|
||||||
contact_monitor->body_map.erase(E);
|
contact_monitor->body_map.erase(E);
|
||||||
}
|
}
|
||||||
if (node && in_tree) {
|
if (node && in_tree) {
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, objid, obj, p_body_shape, p_local_shape);
|
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, p_body, obj, p_body_shape, p_local_shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct _RigidBodyInOut {
|
struct _RigidBodyInOut {
|
||||||
|
RID rid;
|
||||||
ObjectID id;
|
ObjectID id;
|
||||||
int shape;
|
int shape;
|
||||||
int local_shape;
|
int local_shape;
|
||||||
|
@ -389,6 +391,7 @@ void RigidBody::_direct_state_changed(Object *p_state) {
|
||||||
//put the ones to add
|
//put the ones to add
|
||||||
|
|
||||||
for (int i = 0; i < state->get_contact_count(); i++) {
|
for (int i = 0; i < state->get_contact_count(); i++) {
|
||||||
|
RID rid = state->get_contact_collider(i);
|
||||||
ObjectID obj = state->get_contact_collider_id(i);
|
ObjectID obj = state->get_contact_collider_id(i);
|
||||||
int local_shape = state->get_contact_local_shape(i);
|
int local_shape = state->get_contact_local_shape(i);
|
||||||
int shape = state->get_contact_collider_shape(i);
|
int shape = state->get_contact_collider_shape(i);
|
||||||
|
@ -397,6 +400,7 @@ void RigidBody::_direct_state_changed(Object *p_state) {
|
||||||
|
|
||||||
Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(obj);
|
Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(obj);
|
||||||
if (!E) {
|
if (!E) {
|
||||||
|
toadd[toadd_count].rid = rid;
|
||||||
toadd[toadd_count].local_shape = local_shape;
|
toadd[toadd_count].local_shape = local_shape;
|
||||||
toadd[toadd_count].id = obj;
|
toadd[toadd_count].id = obj;
|
||||||
toadd[toadd_count].shape = shape;
|
toadd[toadd_count].shape = shape;
|
||||||
|
@ -407,6 +411,7 @@ void RigidBody::_direct_state_changed(Object *p_state) {
|
||||||
ShapePair sp(shape, local_shape);
|
ShapePair sp(shape, local_shape);
|
||||||
int idx = E->get().shapes.find(sp);
|
int idx = E->get().shapes.find(sp);
|
||||||
if (idx == -1) {
|
if (idx == -1) {
|
||||||
|
toadd[toadd_count].rid = rid;
|
||||||
toadd[toadd_count].local_shape = local_shape;
|
toadd[toadd_count].local_shape = local_shape;
|
||||||
toadd[toadd_count].id = obj;
|
toadd[toadd_count].id = obj;
|
||||||
toadd[toadd_count].shape = shape;
|
toadd[toadd_count].shape = shape;
|
||||||
|
@ -422,6 +427,7 @@ void RigidBody::_direct_state_changed(Object *p_state) {
|
||||||
for (Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) {
|
for (Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) {
|
||||||
for (int i = 0; i < E->get().shapes.size(); i++) {
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
||||||
if (!E->get().shapes[i].tagged) {
|
if (!E->get().shapes[i].tagged) {
|
||||||
|
toremove[toremove_count].rid = E->get().rid;
|
||||||
toremove[toremove_count].body_id = E->key();
|
toremove[toremove_count].body_id = E->key();
|
||||||
toremove[toremove_count].pair = E->get().shapes[i];
|
toremove[toremove_count].pair = E->get().shapes[i];
|
||||||
toremove_count++;
|
toremove_count++;
|
||||||
|
@ -432,13 +438,13 @@ void RigidBody::_direct_state_changed(Object *p_state) {
|
||||||
//process remotions
|
//process remotions
|
||||||
|
|
||||||
for (int i = 0; i < toremove_count; i++) {
|
for (int i = 0; i < toremove_count; i++) {
|
||||||
_body_inout(0, toremove[i].body_id, toremove[i].pair.body_shape, toremove[i].pair.local_shape);
|
_body_inout(0, toremove[i].rid, toremove[i].body_id, toremove[i].pair.body_shape, toremove[i].pair.local_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
//process aditions
|
//process aditions
|
||||||
|
|
||||||
for (int i = 0; i < toadd_count; i++) {
|
for (int i = 0; i < toadd_count; i++) {
|
||||||
_body_inout(1, toadd[i].id, toadd[i].shape, toadd[i].local_shape);
|
_body_inout(1, toadd[i].rid, toadd[i].id, toadd[i].shape, toadd[i].local_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
contact_monitor->locked = false;
|
contact_monitor->locked = false;
|
||||||
|
@ -897,8 +903,8 @@ void RigidBody::_bind_methods() {
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "angular_velocity"), "set_angular_velocity", "get_angular_velocity");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "angular_velocity"), "set_angular_velocity", "get_angular_velocity");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater"), "set_angular_damp", "get_angular_damp");
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater"), "set_angular_damp", "get_angular_damp");
|
||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::_RID, "body_rid"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
||||||
ADD_SIGNAL(MethodInfo("body_shape_exited", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
ADD_SIGNAL(MethodInfo("body_shape_exited", PropertyInfo(Variant::_RID, "body_rid"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
|
||||||
ADD_SIGNAL(MethodInfo("body_entered", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
|
ADD_SIGNAL(MethodInfo("body_entered", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
|
||||||
ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
|
ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
|
||||||
ADD_SIGNAL(MethodInfo("sleeping_state_changed"));
|
ADD_SIGNAL(MethodInfo("sleeping_state_changed"));
|
||||||
|
|
|
@ -149,11 +149,12 @@ protected:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct RigidBody_RemoveAction {
|
struct RigidBody_RemoveAction {
|
||||||
|
RID rid;
|
||||||
ObjectID body_id;
|
ObjectID body_id;
|
||||||
ShapePair pair;
|
ShapePair pair;
|
||||||
};
|
};
|
||||||
struct BodyState {
|
struct BodyState {
|
||||||
//int rc;
|
RID rid;
|
||||||
bool in_tree;
|
bool in_tree;
|
||||||
VSet<ShapePair> shapes;
|
VSet<ShapePair> shapes;
|
||||||
};
|
};
|
||||||
|
@ -167,7 +168,7 @@ protected:
|
||||||
void _body_enter_tree(ObjectID p_id);
|
void _body_enter_tree(ObjectID p_id);
|
||||||
void _body_exit_tree(ObjectID p_id);
|
void _body_exit_tree(ObjectID p_id);
|
||||||
|
|
||||||
void _body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape);
|
void _body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_local_shape);
|
||||||
virtual void _direct_state_changed(Object *p_state);
|
virtual void _direct_state_changed(Object *p_state);
|
||||||
|
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
|
Loading…
Reference in a new issue