aboutsummaryrefslogtreecommitdiff
path: root/servers/physics_2d_server.cpp
diff options
context:
space:
mode:
authorCarl Olsson2015-03-23 08:19:20 +1000
committerCarl Olsson2015-03-23 08:19:20 +1000
commitfb2cdfe7edcc2ccafea7604afd104f582e5b9c17 (patch)
treed9555d9519648f95d7ed3663fbca50978bb12a1f /servers/physics_2d_server.cpp
parent41686d5fdd0d72f167894f976d19b177789f1f63 (diff)
parente9f94ce8d2cc6805e74fffdf733e6dc5b5c530f5 (diff)
downloadgodot-fb2cdfe7edcc2ccafea7604afd104f582e5b9c17.tar.gz
godot-fb2cdfe7edcc2ccafea7604afd104f582e5b9c17.tar.zst
godot-fb2cdfe7edcc2ccafea7604afd104f582e5b9c17.zip
Merge branch 'master' of https://github.com/not-surt/godot into snapping2
Conflicts: tools/editor/plugins/canvas_item_editor_plugin.cpp tools/editor/plugins/canvas_item_editor_plugin.h
Diffstat (limited to 'servers/physics_2d_server.cpp')
-rw-r--r--servers/physics_2d_server.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp
index 07389bc91..098f89022 100644
--- a/servers/physics_2d_server.cpp
+++ b/servers/physics_2d_server.cpp
@@ -289,6 +289,36 @@ Array Physics2DDirectSpaceState::_cast_motion(const Ref<Physics2DShapeQueryParam
return ret;
}
+
+Array Physics2DDirectSpaceState::_intersect_point(const Vector2& p_point,int p_max_results,const Vector<RID>& p_exclude,uint32_t p_layers,uint32_t p_object_type_mask) {
+
+ Set<RID> exclude;
+ for(int i=0;i<p_exclude.size();i++)
+ exclude.insert(p_exclude[i]);
+
+ Vector<ShapeResult> ret;
+ ret.resize(p_max_results);
+
+ int rc = intersect_point(p_point,ret.ptr(),ret.size(),exclude,p_layers,p_object_type_mask);
+ if (rc==0)
+ return Array();
+
+ Array r;
+ r.resize(rc);
+ for(int i=0;i<rc;i++) {
+
+ Dictionary d;
+ d["rid"]=ret[i].rid;
+ d["collider_id"]=ret[i].collider_id;
+ d["collider"]=ret[i].collider;
+ d["shape"]=ret[i].shape;
+ d["metadata"]=ret[i].metadata;
+ r[i]=d;
+ }
+ return r;
+
+}
+
Array Physics2DDirectSpaceState::_collide_shape(const Ref<Physics2DShapeQueryParameters> &psq, int p_max_results){
Vector<Vector2> ret;
@@ -336,6 +366,7 @@ Physics2DDirectSpaceState::Physics2DDirectSpaceState() {
void Physics2DDirectSpaceState::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("intersect_point","point","max_results","exclude","layer_mask","type_mask"),&Physics2DDirectSpaceState::_intersect_point,DEFVAL(32),DEFVAL(Array()),DEFVAL(0x7FFFFFFF),DEFVAL(TYPE_MASK_COLLISION));
ObjectTypeDB::bind_method(_MD("intersect_ray:Dictionary","from","to","exclude","layer_mask","type_mask"),&Physics2DDirectSpaceState::_intersect_ray,DEFVAL(Array()),DEFVAL(0x7FFFFFFF),DEFVAL(TYPE_MASK_COLLISION));
ObjectTypeDB::bind_method(_MD("intersect_shape","shape:Physics2DShapeQueryParameters","max_results"),&Physics2DDirectSpaceState::_intersect_shape,DEFVAL(32));
ObjectTypeDB::bind_method(_MD("cast_motion","shape:Physics2DShapeQueryParameters"),&Physics2DDirectSpaceState::_cast_motion);