2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* area.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2019-01-01 11:53:14 +00:00
|
|
|
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
2014-02-10 01:10:30 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "area.h"
|
|
|
|
#include "scene/scene_string_names.h"
|
2017-07-15 04:23:10 +00:00
|
|
|
#include "servers/audio_server.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "servers/physics_server.h"
|
2017-07-15 04:23:10 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void Area::set_space_override_mode(SpaceOverride p_mode) {
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
space_override = p_mode;
|
|
|
|
PhysicsServer::get_singleton()->area_set_space_override_mode(get_rid(), PhysicsServer::AreaSpaceOverrideMode(p_mode));
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
Area::SpaceOverride Area::get_space_override_mode() const {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
return space_override;
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void Area::set_gravity_is_point(bool p_enabled) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
gravity_is_point = p_enabled;
|
|
|
|
PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT, p_enabled);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
bool Area::is_gravity_a_point() const {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
return gravity_is_point;
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void Area::set_gravity_distance_scale(real_t p_scale) {
|
2015-03-19 14:10:07 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
gravity_distance_scale = p_scale;
|
|
|
|
PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE, p_scale);
|
2015-03-19 14:10:07 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
real_t Area::get_gravity_distance_scale() const {
|
2015-03-19 14:10:07 +00:00
|
|
|
return gravity_distance_scale;
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void Area::set_gravity_vector(const Vector3 &p_vec) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
gravity_vec = p_vec;
|
|
|
|
PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_GRAVITY_VECTOR, p_vec);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
Vector3 Area::get_gravity_vector() const {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
return gravity_vec;
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void Area::set_gravity(real_t p_gravity) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
gravity = p_gravity;
|
|
|
|
PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_GRAVITY, p_gravity);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
real_t Area::get_gravity() const {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
return gravity;
|
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
void Area::set_linear_damp(real_t p_linear_damp) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
linear_damp = p_linear_damp;
|
|
|
|
PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_LINEAR_DAMP, p_linear_damp);
|
2015-08-30 21:57:17 +00:00
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
real_t Area::get_linear_damp() const {
|
2015-08-30 21:57:17 +00:00
|
|
|
|
|
|
|
return linear_damp;
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void Area::set_angular_damp(real_t p_angular_damp) {
|
2015-08-30 21:57:17 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
angular_damp = p_angular_damp;
|
|
|
|
PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_ANGULAR_DAMP, p_angular_damp);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
real_t Area::get_angular_damp() const {
|
2015-08-30 21:57:17 +00:00
|
|
|
|
|
|
|
return angular_damp;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void Area::set_priority(real_t p_priority) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
priority = p_priority;
|
|
|
|
PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_PRIORITY, p_priority);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
real_t Area::get_priority() const {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
return priority;
|
|
|
|
}
|
|
|
|
|
2014-11-06 00:20:42 +00:00
|
|
|
void Area::_body_enter_tree(ObjectID p_id) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
Object *obj = ObjectDB::get_instance(p_id);
|
2017-08-24 20:58:51 +00:00
|
|
|
Node *node = Object::cast_to<Node>(obj);
|
2014-02-10 01:10:30 +00:00
|
|
|
ERR_FAIL_COND(!node);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Map<ObjectID, BodyState>::Element *E = body_map.find(p_id);
|
2014-02-10 01:10:30 +00:00
|
|
|
ERR_FAIL_COND(!E);
|
2014-11-06 00:20:42 +00:00
|
|
|
ERR_FAIL_COND(E->get().in_tree);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
E->get().in_tree = true;
|
|
|
|
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
|
|
|
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-06 00:20:42 +00:00
|
|
|
void Area::_body_exit_tree(ObjectID p_id) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
Object *obj = ObjectDB::get_instance(p_id);
|
2017-08-24 20:58:51 +00:00
|
|
|
Node *node = Object::cast_to<Node>(obj);
|
2014-02-10 01:10:30 +00:00
|
|
|
ERR_FAIL_COND(!node);
|
2017-03-05 15:44:50 +00:00
|
|
|
Map<ObjectID, BodyState>::Element *E = body_map.find(p_id);
|
2014-02-10 01:10:30 +00:00
|
|
|
ERR_FAIL_COND(!E);
|
2014-11-06 00:20:42 +00:00
|
|
|
ERR_FAIL_COND(!E->get().in_tree);
|
2017-03-05 15:44:50 +00:00
|
|
|
E->get().in_tree = false;
|
|
|
|
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
|
|
|
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void Area::_body_inout(int p_status, const RID &p_body, int p_instance, int p_body_shape, int p_area_shape) {
|
2014-12-07 05:04:20 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
bool body_in = p_status == PhysicsServer::AREA_BODY_ADDED;
|
|
|
|
ObjectID objid = p_instance;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
Object *obj = ObjectDB::get_instance(objid);
|
2017-08-24 20:58:51 +00:00
|
|
|
Node *node = Object::cast_to<Node>(obj);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Map<ObjectID, BodyState>::Element *E = body_map.find(objid);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2018-11-28 21:40:58 +00:00
|
|
|
if (!body_in && !E) {
|
|
|
|
return; //likely removed from the tree
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
locked = true;
|
2014-12-07 05:04:20 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
if (body_in) {
|
|
|
|
if (!E) {
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
E = body_map.insert(objid, BodyState());
|
|
|
|
E->get().rc = 0;
|
|
|
|
E->get().in_tree = node && node->is_inside_tree();
|
2014-02-10 01:10:30 +00:00
|
|
|
if (node) {
|
2017-03-05 15:44:50 +00:00
|
|
|
node->connect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree, make_binds(objid));
|
2018-01-12 11:28:39 +00:00
|
|
|
node->connect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid));
|
2014-11-06 00:20:42 +00:00
|
|
|
if (E->get().in_tree) {
|
2017-03-05 15:44:50 +00:00
|
|
|
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
E->get().rc++;
|
|
|
|
if (node)
|
2017-03-05 15:44:50 +00:00
|
|
|
E->get().shapes.insert(ShapePair(p_body_shape, p_area_shape));
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2014-11-06 00:20:42 +00:00
|
|
|
if (E->get().in_tree) {
|
2017-03-05 15:44:50 +00:00
|
|
|
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, objid, node, p_body_shape, p_area_shape);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
E->get().rc--;
|
|
|
|
|
|
|
|
if (node)
|
2017-03-05 15:44:50 +00:00
|
|
|
E->get().shapes.erase(ShapePair(p_body_shape, p_area_shape));
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
bool eraseit = false;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (E->get().rc == 0) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
if (node) {
|
2017-03-05 15:44:50 +00:00
|
|
|
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree);
|
2018-01-12 11:28:39 +00:00
|
|
|
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree);
|
2014-11-06 00:20:42 +00:00
|
|
|
if (E->get().in_tree)
|
2017-03-05 15:44:50 +00:00
|
|
|
emit_signal(SceneStringNames::get_singleton()->body_exited, obj);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
eraseit = true;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2014-11-06 00:20:42 +00:00
|
|
|
if (node && E->get().in_tree) {
|
2017-03-05 15:44:50 +00:00
|
|
|
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, objid, obj, p_body_shape, p_area_shape);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (eraseit)
|
|
|
|
body_map.erase(E);
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
locked = false;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Area::_clear_monitoring() {
|
|
|
|
|
2014-12-07 05:04:20 +00:00
|
|
|
if (locked) {
|
|
|
|
ERR_EXPLAIN("This function can't be used during the in/out signal.");
|
|
|
|
}
|
|
|
|
ERR_FAIL_COND(locked);
|
|
|
|
|
2015-06-12 18:52:21 +00:00
|
|
|
{
|
2017-03-05 15:44:50 +00:00
|
|
|
Map<ObjectID, BodyState> bmcopy = body_map;
|
2015-06-12 18:52:21 +00:00
|
|
|
body_map.clear();
|
|
|
|
//disconnect all monitored stuff
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (Map<ObjectID, BodyState>::Element *E = bmcopy.front(); E; E = E->next()) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-06-12 18:52:21 +00:00
|
|
|
Object *obj = ObjectDB::get_instance(E->key());
|
2017-08-24 20:58:51 +00:00
|
|
|
Node *node = Object::cast_to<Node>(obj);
|
2017-07-10 14:20:56 +00:00
|
|
|
|
|
|
|
if (!node) //node may have been deleted in previous frame or at other legiminate point
|
|
|
|
continue;
|
|
|
|
//ERR_CONTINUE(!node);
|
|
|
|
|
2015-06-12 18:52:21 +00:00
|
|
|
if (!E->get().in_tree)
|
|
|
|
continue;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, E->key(), node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
|
2015-06-12 18:52:21 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2018-09-01 10:05:51 +00:00
|
|
|
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
|
2015-06-12 18:52:21 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree);
|
2018-01-12 11:28:39 +00:00
|
|
|
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2015-06-12 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Map<ObjectID, AreaState> bmcopy = area_map;
|
2015-06-12 18:52:21 +00:00
|
|
|
area_map.clear();
|
|
|
|
//disconnect all monitored stuff
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (Map<ObjectID, AreaState>::Element *E = bmcopy.front(); E; E = E->next()) {
|
2015-06-12 18:52:21 +00:00
|
|
|
|
|
|
|
Object *obj = ObjectDB::get_instance(E->key());
|
2017-08-24 20:58:51 +00:00
|
|
|
Node *node = Object::cast_to<Node>(obj);
|
2017-07-10 14:20:56 +00:00
|
|
|
|
|
|
|
if (!node) //node may have been deleted in previous frame or at other legiminate point
|
|
|
|
continue;
|
|
|
|
//ERR_CONTINUE(!node);
|
|
|
|
|
2015-06-12 18:52:21 +00:00
|
|
|
if (!E->get().in_tree)
|
|
|
|
continue;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, E->key(), node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
|
2015-06-12 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
emit_signal(SceneStringNames::get_singleton()->area_exited, obj);
|
2015-06-12 18:52:21 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree);
|
2018-01-12 11:28:39 +00:00
|
|
|
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree);
|
2015-06-12 18:52:21 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
void Area::_notification(int p_what) {
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (p_what == NOTIFICATION_EXIT_TREE) {
|
2014-02-10 01:10:30 +00:00
|
|
|
_clear_monitoring();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-13 23:03:51 +00:00
|
|
|
void Area::set_monitoring(bool p_enable) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2014-12-07 05:04:20 +00:00
|
|
|
if (locked) {
|
2018-11-16 11:49:26 +00:00
|
|
|
ERR_EXPLAIN("Function blocked during in/out signal. Use set_deferred(\"monitoring\",true/false)");
|
2014-12-07 05:04:20 +00:00
|
|
|
}
|
|
|
|
ERR_FAIL_COND(locked);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (p_enable == monitoring)
|
2014-02-10 01:10:30 +00:00
|
|
|
return;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
monitoring = p_enable;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
if (monitoring) {
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
PhysicsServer::get_singleton()->area_set_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_body_inout);
|
|
|
|
PhysicsServer::get_singleton()->area_set_area_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_area_inout);
|
2014-02-10 01:10:30 +00:00
|
|
|
} else {
|
2017-03-05 15:44:50 +00:00
|
|
|
PhysicsServer::get_singleton()->area_set_monitor_callback(get_rid(), NULL, StringName());
|
|
|
|
PhysicsServer::get_singleton()->area_set_area_monitor_callback(get_rid(), NULL, StringName());
|
2014-02-10 01:10:30 +00:00
|
|
|
_clear_monitoring();
|
2015-06-12 18:52:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Area::_area_enter_tree(ObjectID p_id) {
|
|
|
|
|
|
|
|
Object *obj = ObjectDB::get_instance(p_id);
|
2017-08-24 20:58:51 +00:00
|
|
|
Node *node = Object::cast_to<Node>(obj);
|
2015-06-12 18:52:21 +00:00
|
|
|
ERR_FAIL_COND(!node);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Map<ObjectID, AreaState>::Element *E = area_map.find(p_id);
|
2015-06-12 18:52:21 +00:00
|
|
|
ERR_FAIL_COND(!E);
|
|
|
|
ERR_FAIL_COND(E->get().in_tree);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
E->get().in_tree = true;
|
|
|
|
emit_signal(SceneStringNames::get_singleton()->area_entered, node);
|
|
|
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
2015-06-12 18:52:21 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
emit_signal(SceneStringNames::get_singleton()->area_shape_entered, p_id, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
|
2015-06-12 18:52:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Area::_area_exit_tree(ObjectID p_id) {
|
|
|
|
|
|
|
|
Object *obj = ObjectDB::get_instance(p_id);
|
2017-08-24 20:58:51 +00:00
|
|
|
Node *node = Object::cast_to<Node>(obj);
|
2015-06-12 18:52:21 +00:00
|
|
|
ERR_FAIL_COND(!node);
|
2017-03-05 15:44:50 +00:00
|
|
|
Map<ObjectID, AreaState>::Element *E = area_map.find(p_id);
|
2015-06-12 18:52:21 +00:00
|
|
|
ERR_FAIL_COND(!E);
|
|
|
|
ERR_FAIL_COND(!E->get().in_tree);
|
2017-03-05 15:44:50 +00:00
|
|
|
E->get().in_tree = false;
|
|
|
|
emit_signal(SceneStringNames::get_singleton()->area_exited, node);
|
|
|
|
for (int i = 0; i < E->get().shapes.size(); i++) {
|
2015-06-12 18:52:21 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, p_id, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2015-06-12 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void Area::_area_inout(int p_status, const RID &p_area, int p_instance, int p_area_shape, int p_self_shape) {
|
2015-06-12 18:52:21 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
bool area_in = p_status == PhysicsServer::AREA_BODY_ADDED;
|
|
|
|
ObjectID objid = p_instance;
|
2015-06-12 18:52:21 +00:00
|
|
|
|
|
|
|
Object *obj = ObjectDB::get_instance(objid);
|
2017-08-24 20:58:51 +00:00
|
|
|
Node *node = Object::cast_to<Node>(obj);
|
2015-06-12 18:52:21 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Map<ObjectID, AreaState>::Element *E = area_map.find(objid);
|
2015-06-12 18:52:21 +00:00
|
|
|
|
2019-04-15 02:31:51 +00:00
|
|
|
if (!area_in && !E) {
|
|
|
|
return; //likely removed from the tree
|
|
|
|
}
|
2015-06-12 18:52:21 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
locked = true;
|
2015-06-12 18:52:21 +00:00
|
|
|
|
|
|
|
if (area_in) {
|
|
|
|
if (!E) {
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
E = area_map.insert(objid, AreaState());
|
|
|
|
E->get().rc = 0;
|
|
|
|
E->get().in_tree = node && node->is_inside_tree();
|
2015-06-12 18:52:21 +00:00
|
|
|
if (node) {
|
2017-03-05 15:44:50 +00:00
|
|
|
node->connect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree, make_binds(objid));
|
2018-01-12 11:28:39 +00:00
|
|
|
node->connect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree, make_binds(objid));
|
2015-06-12 18:52:21 +00:00
|
|
|
if (E->get().in_tree) {
|
2017-03-05 15:44:50 +00:00
|
|
|
emit_signal(SceneStringNames::get_singleton()->area_entered, node);
|
2015-06-12 18:52:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
E->get().rc++;
|
|
|
|
if (node)
|
2017-03-05 15:44:50 +00:00
|
|
|
E->get().shapes.insert(AreaShapePair(p_area_shape, p_self_shape));
|
2015-06-12 18:52:21 +00:00
|
|
|
|
|
|
|
if (!node || E->get().in_tree) {
|
2017-03-05 15:44:50 +00:00
|
|
|
emit_signal(SceneStringNames::get_singleton()->area_shape_entered, objid, node, p_area_shape, p_self_shape);
|
2015-06-12 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
E->get().rc--;
|
|
|
|
|
|
|
|
if (node)
|
2017-03-05 15:44:50 +00:00
|
|
|
E->get().shapes.erase(AreaShapePair(p_area_shape, p_self_shape));
|
2015-06-12 18:52:21 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
bool eraseit = false;
|
2015-06-12 18:52:21 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (E->get().rc == 0) {
|
2015-06-12 18:52:21 +00:00
|
|
|
|
|
|
|
if (node) {
|
2017-03-05 15:44:50 +00:00
|
|
|
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree);
|
2018-01-12 11:28:39 +00:00
|
|
|
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree);
|
2015-06-12 18:52:21 +00:00
|
|
|
if (E->get().in_tree) {
|
2017-03-05 15:44:50 +00:00
|
|
|
emit_signal(SceneStringNames::get_singleton()->area_exited, obj);
|
2015-06-12 18:52:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
eraseit = true;
|
2015-06-12 18:52:21 +00:00
|
|
|
}
|
|
|
|
if (!node || E->get().in_tree) {
|
2017-03-05 15:44:50 +00:00
|
|
|
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, objid, obj, p_area_shape, p_self_shape);
|
2015-06-12 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (eraseit)
|
|
|
|
area_map.erase(E);
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
locked = false;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-01-13 23:03:51 +00:00
|
|
|
bool Area::is_monitoring() const {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
return monitoring;
|
|
|
|
}
|
|
|
|
|
2014-11-13 03:53:12 +00:00
|
|
|
Array Area::get_overlapping_bodies() const {
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_COND_V(!monitoring, Array());
|
2014-11-13 03:53:12 +00:00
|
|
|
Array ret;
|
|
|
|
ret.resize(body_map.size());
|
2017-03-05 15:44:50 +00:00
|
|
|
int idx = 0;
|
|
|
|
for (const Map<ObjectID, BodyState>::Element *E = body_map.front(); E; E = E->next()) {
|
2014-11-13 03:53:12 +00:00
|
|
|
Object *obj = ObjectDB::get_instance(E->key());
|
|
|
|
if (!obj) {
|
2017-03-05 15:44:50 +00:00
|
|
|
ret.resize(ret.size() - 1); //ops
|
2014-11-13 03:53:12 +00:00
|
|
|
} else {
|
2017-03-05 15:44:50 +00:00
|
|
|
ret[idx++] = obj;
|
2014-11-13 03:53:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2015-06-12 18:52:21 +00:00
|
|
|
void Area::set_monitorable(bool p_enable) {
|
|
|
|
|
2019-02-22 12:04:59 +00:00
|
|
|
if (locked || (is_inside_tree() && PhysicsServer::get_singleton()->is_flushing_queries())) {
|
2018-11-16 11:49:26 +00:00
|
|
|
ERR_EXPLAIN("Function blocked during in/out signal. Use set_deferred(\"monitorable\",true/false)");
|
2019-03-02 11:48:13 +00:00
|
|
|
ERR_FAIL();
|
2015-06-12 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (p_enable == monitorable)
|
2015-06-12 18:52:21 +00:00
|
|
|
return;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
monitorable = p_enable;
|
2015-06-12 18:52:21 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
PhysicsServer::get_singleton()->area_set_monitorable(get_rid(), monitorable);
|
2015-06-12 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Area::is_monitorable() const {
|
|
|
|
|
|
|
|
return monitorable;
|
|
|
|
}
|
|
|
|
|
|
|
|
Array Area::get_overlapping_areas() const {
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_COND_V(!monitoring, Array());
|
2015-06-12 18:52:21 +00:00
|
|
|
Array ret;
|
|
|
|
ret.resize(area_map.size());
|
2017-03-05 15:44:50 +00:00
|
|
|
int idx = 0;
|
|
|
|
for (const Map<ObjectID, AreaState>::Element *E = area_map.front(); E; E = E->next()) {
|
2015-06-12 18:52:21 +00:00
|
|
|
Object *obj = ObjectDB::get_instance(E->key());
|
|
|
|
if (!obj) {
|
2017-03-05 15:44:50 +00:00
|
|
|
ret.resize(ret.size() - 1); //ops
|
2015-06-12 18:52:21 +00:00
|
|
|
} else {
|
2017-03-05 15:44:50 +00:00
|
|
|
ret[idx++] = obj;
|
2015-06-12 18:52:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
bool Area::overlaps_area(Node *p_area) const {
|
2015-06-12 18:52:21 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_NULL_V(p_area, false);
|
2017-08-07 10:17:31 +00:00
|
|
|
const Map<ObjectID, AreaState>::Element *E = area_map.find(p_area->get_instance_id());
|
2015-06-12 18:52:21 +00:00
|
|
|
if (!E)
|
|
|
|
return false;
|
|
|
|
return E->get().in_tree;
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
bool Area::overlaps_body(Node *p_body) const {
|
2015-06-12 18:52:21 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_NULL_V(p_body, false);
|
2017-08-07 10:17:31 +00:00
|
|
|
const Map<ObjectID, BodyState>::Element *E = body_map.find(p_body->get_instance_id());
|
2015-06-12 18:52:21 +00:00
|
|
|
if (!E)
|
|
|
|
return false;
|
|
|
|
return E->get().in_tree;
|
|
|
|
}
|
2016-04-09 18:54:09 +00:00
|
|
|
void Area::set_collision_mask(uint32_t p_mask) {
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
collision_mask = p_mask;
|
|
|
|
PhysicsServer::get_singleton()->area_set_collision_mask(get_rid(), p_mask);
|
2016-04-09 18:54:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t Area::get_collision_mask() const {
|
|
|
|
|
|
|
|
return collision_mask;
|
|
|
|
}
|
2017-06-13 15:45:01 +00:00
|
|
|
void Area::set_collision_layer(uint32_t p_layer) {
|
2016-04-09 18:54:09 +00:00
|
|
|
|
2017-06-13 15:45:01 +00:00
|
|
|
collision_layer = p_layer;
|
|
|
|
PhysicsServer::get_singleton()->area_set_collision_layer(get_rid(), p_layer);
|
2016-04-09 18:54:09 +00:00
|
|
|
}
|
|
|
|
|
2017-06-13 15:45:01 +00:00
|
|
|
uint32_t Area::get_collision_layer() const {
|
2016-04-09 18:54:09 +00:00
|
|
|
|
2017-06-13 15:45:01 +00:00
|
|
|
return collision_layer;
|
2016-04-09 18:54:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Area::set_collision_mask_bit(int p_bit, bool p_value) {
|
|
|
|
|
|
|
|
uint32_t mask = get_collision_mask();
|
|
|
|
if (p_value)
|
2017-03-05 15:44:50 +00:00
|
|
|
mask |= 1 << p_bit;
|
2016-04-09 18:54:09 +00:00
|
|
|
else
|
2017-03-05 15:44:50 +00:00
|
|
|
mask &= ~(1 << p_bit);
|
2016-04-09 18:54:09 +00:00
|
|
|
set_collision_mask(mask);
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
bool Area::get_collision_mask_bit(int p_bit) const {
|
2016-04-09 18:54:09 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
return get_collision_mask() & (1 << p_bit);
|
2016-04-09 18:54:09 +00:00
|
|
|
}
|
|
|
|
|
2017-06-13 15:45:01 +00:00
|
|
|
void Area::set_collision_layer_bit(int p_bit, bool p_value) {
|
2016-04-09 18:54:09 +00:00
|
|
|
|
2017-06-13 15:45:01 +00:00
|
|
|
uint32_t layer = get_collision_layer();
|
2016-04-09 18:54:09 +00:00
|
|
|
if (p_value)
|
2017-06-13 15:45:01 +00:00
|
|
|
layer |= 1 << p_bit;
|
2016-04-09 18:54:09 +00:00
|
|
|
else
|
2017-06-13 15:45:01 +00:00
|
|
|
layer &= ~(1 << p_bit);
|
|
|
|
set_collision_layer(layer);
|
2016-04-09 18:54:09 +00:00
|
|
|
}
|
|
|
|
|
2017-06-13 15:45:01 +00:00
|
|
|
bool Area::get_collision_layer_bit(int p_bit) const {
|
2016-04-09 18:54:09 +00:00
|
|
|
|
2017-06-13 15:45:01 +00:00
|
|
|
return get_collision_layer() & (1 << p_bit);
|
2016-04-09 18:54:09 +00:00
|
|
|
}
|
|
|
|
|
2017-07-15 04:23:10 +00:00
|
|
|
void Area::set_audio_bus_override(bool p_override) {
|
|
|
|
|
|
|
|
audio_bus_override = p_override;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Area::is_overriding_audio_bus() const {
|
|
|
|
|
|
|
|
return audio_bus_override;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Area::set_audio_bus(const StringName &p_audio_bus) {
|
|
|
|
|
|
|
|
audio_bus = p_audio_bus;
|
|
|
|
}
|
|
|
|
StringName Area::get_audio_bus() const {
|
|
|
|
|
|
|
|
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
|
|
|
|
if (AudioServer::get_singleton()->get_bus_name(i) == audio_bus) {
|
|
|
|
return audio_bus;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "Master";
|
|
|
|
}
|
|
|
|
|
|
|
|
void Area::set_use_reverb_bus(bool p_enable) {
|
|
|
|
|
|
|
|
use_reverb_bus = p_enable;
|
|
|
|
}
|
|
|
|
bool Area::is_using_reverb_bus() const {
|
|
|
|
|
|
|
|
return use_reverb_bus;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Area::set_reverb_bus(const StringName &p_audio_bus) {
|
|
|
|
|
|
|
|
reverb_bus = p_audio_bus;
|
|
|
|
}
|
|
|
|
StringName Area::get_reverb_bus() const {
|
|
|
|
|
|
|
|
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
|
|
|
|
if (AudioServer::get_singleton()->get_bus_name(i) == reverb_bus) {
|
|
|
|
return reverb_bus;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "Master";
|
|
|
|
}
|
|
|
|
|
|
|
|
void Area::set_reverb_amount(float p_amount) {
|
|
|
|
|
|
|
|
reverb_amount = p_amount;
|
|
|
|
}
|
|
|
|
float Area::get_reverb_amount() const {
|
|
|
|
|
|
|
|
return reverb_amount;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Area::set_reverb_uniformity(float p_uniformity) {
|
|
|
|
|
|
|
|
reverb_uniformity = p_uniformity;
|
|
|
|
}
|
|
|
|
float Area::get_reverb_uniformity() const {
|
|
|
|
|
|
|
|
return reverb_uniformity;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Area::_validate_property(PropertyInfo &property) const {
|
|
|
|
|
|
|
|
if (property.name == "audio_bus_name" || property.name == "reverb_bus_name") {
|
|
|
|
|
|
|
|
String options;
|
|
|
|
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
|
|
|
|
if (i > 0)
|
|
|
|
options += ",";
|
|
|
|
String name = AudioServer::get_singleton()->get_bus_name(i);
|
|
|
|
options += name;
|
|
|
|
}
|
|
|
|
|
|
|
|
property.hint_string = options;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void Area::_bind_methods() {
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_body_enter_tree", "id"), &Area::_body_enter_tree);
|
|
|
|
ClassDB::bind_method(D_METHOD("_body_exit_tree", "id"), &Area::_body_exit_tree);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_area_enter_tree", "id"), &Area::_area_enter_tree);
|
|
|
|
ClassDB::bind_method(D_METHOD("_area_exit_tree", "id"), &Area::_area_exit_tree);
|
2015-06-12 18:52:21 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_space_override_mode", "enable"), &Area::set_space_override_mode);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_space_override_mode"), &Area::get_space_override_mode);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_gravity_is_point", "enable"), &Area::set_gravity_is_point);
|
|
|
|
ClassDB::bind_method(D_METHOD("is_gravity_a_point"), &Area::is_gravity_a_point);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_gravity_distance_scale", "distance_scale"), &Area::set_gravity_distance_scale);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_gravity_distance_scale"), &Area::get_gravity_distance_scale);
|
2015-03-19 14:10:07 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_gravity_vector", "vector"), &Area::set_gravity_vector);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_gravity_vector"), &Area::get_gravity_vector);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_gravity", "gravity"), &Area::set_gravity);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_gravity"), &Area::get_gravity);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_angular_damp", "angular_damp"), &Area::set_angular_damp);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_angular_damp"), &Area::get_angular_damp);
|
2015-08-30 21:57:17 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_linear_damp", "linear_damp"), &Area::set_linear_damp);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_linear_damp"), &Area::get_linear_damp);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_priority", "priority"), &Area::set_priority);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_priority"), &Area::get_priority);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &Area::set_collision_mask);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_collision_mask"), &Area::get_collision_mask);
|
2016-04-09 18:54:09 +00:00
|
|
|
|
2017-06-13 15:45:01 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_collision_layer", "collision_layer"), &Area::set_collision_layer);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_collision_layer"), &Area::get_collision_layer);
|
2016-04-09 18:54:09 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &Area::set_collision_mask_bit);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &Area::get_collision_mask_bit);
|
2016-04-09 18:54:09 +00:00
|
|
|
|
2017-06-13 15:45:01 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &Area::set_collision_layer_bit);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &Area::get_collision_layer_bit);
|
2016-04-09 18:54:09 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_monitorable", "enable"), &Area::set_monitorable);
|
|
|
|
ClassDB::bind_method(D_METHOD("is_monitorable"), &Area::is_monitorable);
|
2015-06-12 18:52:21 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_monitoring", "enable"), &Area::set_monitoring);
|
|
|
|
ClassDB::bind_method(D_METHOD("is_monitoring"), &Area::is_monitoring);
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("get_overlapping_bodies"), &Area::get_overlapping_bodies);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_overlapping_areas"), &Area::get_overlapping_areas);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("overlaps_body", "body"), &Area::overlaps_body);
|
|
|
|
ClassDB::bind_method(D_METHOD("overlaps_area", "area"), &Area::overlaps_area);
|
2015-06-12 18:52:21 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_body_inout"), &Area::_body_inout);
|
|
|
|
ClassDB::bind_method(D_METHOD("_area_inout"), &Area::_area_inout);
|
2014-11-13 03:53:12 +00:00
|
|
|
|
2017-07-15 04:23:10 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_audio_bus_override", "enable"), &Area::set_audio_bus_override);
|
|
|
|
ClassDB::bind_method(D_METHOD("is_overriding_audio_bus"), &Area::is_overriding_audio_bus);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("set_audio_bus", "name"), &Area::set_audio_bus);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_audio_bus"), &Area::get_audio_bus);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("set_use_reverb_bus", "enable"), &Area::set_use_reverb_bus);
|
|
|
|
ClassDB::bind_method(D_METHOD("is_using_reverb_bus"), &Area::is_using_reverb_bus);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("set_reverb_bus", "name"), &Area::set_reverb_bus);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_reverb_bus"), &Area::get_reverb_bus);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("set_reverb_amount", "amount"), &Area::set_reverb_amount);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_reverb_amount"), &Area::get_reverb_amount);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2018-09-01 10:05:51 +00:00
|
|
|
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, "area_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, "area_shape")));
|
|
|
|
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")));
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
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, "self_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, "self_shape")));
|
|
|
|
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")));
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "space_override", PROPERTY_HINT_ENUM, "Disabled,Combine,Combine-Replace,Replace,Replace-Combine"), "set_space_override_mode", "get_space_override_mode");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gravity_point"), "set_gravity_is_point", "is_gravity_a_point");
|
2018-05-16 12:13:41 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "gravity_distance_scale", PROPERTY_HINT_EXP_RANGE, "0,1024,0.001,or_greater"), "set_gravity_distance_scale", "get_gravity_distance_scale");
|
2017-03-05 15:44:50 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "gravity_vec"), "set_gravity_vector", "get_gravity_vector");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "gravity", PROPERTY_HINT_RANGE, "-1024,1024,0.01"), "set_gravity", "get_gravity");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "linear_damp", PROPERTY_HINT_RANGE, "0,1024,0.001"), "set_linear_damp", "get_linear_damp");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_damp", PROPERTY_HINT_RANGE, "0,1024,0.001"), "set_angular_damp", "get_angular_damp");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "priority", PROPERTY_HINT_RANGE, "0,128,1"), "set_priority", "get_priority");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "monitoring"), "set_monitoring", "is_monitoring");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "monitorable"), "set_monitorable", "is_monitorable");
|
|
|
|
ADD_GROUP("Collision", "collision_");
|
2017-06-13 15:45:01 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_layer", "get_collision_layer");
|
2017-03-05 15:44:50 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
|
2017-07-15 04:23:10 +00:00
|
|
|
ADD_GROUP("Audio Bus", "audio_bus_");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "audio_bus_override"), "set_audio_bus_override", "is_overriding_audio_bus");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "audio_bus_name", PROPERTY_HINT_ENUM, ""), "set_audio_bus", "get_audio_bus");
|
|
|
|
ADD_GROUP("Reverb Bus", "reverb_bus_");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "reverb_bus_enable"), "set_use_reverb_bus", "is_using_reverb_bus");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "reverb_bus_name", PROPERTY_HINT_ENUM, ""), "set_reverb_bus", "get_reverb_bus");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "reverb_bus_amount", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_reverb_amount", "get_reverb_amount");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "reverb_bus_uniformity", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_reverb_uniformity", "get_reverb_uniformity");
|
2017-09-12 19:09:06 +00:00
|
|
|
|
|
|
|
BIND_ENUM_CONSTANT(SPACE_OVERRIDE_DISABLED);
|
|
|
|
BIND_ENUM_CONSTANT(SPACE_OVERRIDE_COMBINE);
|
|
|
|
BIND_ENUM_CONSTANT(SPACE_OVERRIDE_COMBINE_REPLACE);
|
|
|
|
BIND_ENUM_CONSTANT(SPACE_OVERRIDE_REPLACE);
|
|
|
|
BIND_ENUM_CONSTANT(SPACE_OVERRIDE_REPLACE_COMBINE);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-12-06 20:36:34 +00:00
|
|
|
Area::Area() :
|
|
|
|
CollisionObject(PhysicsServer::get_singleton()->area_create(), true) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
space_override = SPACE_OVERRIDE_DISABLED;
|
2017-01-14 17:03:38 +00:00
|
|
|
set_gravity(9.8);
|
2017-03-05 15:44:50 +00:00
|
|
|
locked = false;
|
|
|
|
set_gravity_vector(Vector3(0, -1, 0));
|
|
|
|
gravity_is_point = false;
|
|
|
|
gravity_distance_scale = 0;
|
|
|
|
linear_damp = 0.1;
|
|
|
|
angular_damp = 1;
|
|
|
|
priority = 0;
|
|
|
|
monitoring = false;
|
2019-01-17 22:11:43 +00:00
|
|
|
monitorable = false;
|
2017-03-05 15:44:50 +00:00
|
|
|
collision_mask = 1;
|
2017-06-13 15:45:01 +00:00
|
|
|
collision_layer = 1;
|
2017-01-13 23:03:51 +00:00
|
|
|
set_monitoring(true);
|
2015-06-12 18:52:21 +00:00
|
|
|
set_monitorable(true);
|
2017-07-15 04:23:10 +00:00
|
|
|
|
|
|
|
audio_bus_override = false;
|
|
|
|
audio_bus = "Master";
|
|
|
|
|
|
|
|
use_reverb_bus = false;
|
|
|
|
reverb_bus = "Master";
|
|
|
|
reverb_amount = 0.0;
|
|
|
|
reverb_uniformity = 0.0;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Area::~Area() {
|
|
|
|
}
|