Skip to content

Commit

Permalink
Merge pull request #69017 from raulsntos/physics3d-array
Browse files Browse the repository at this point in the history
Change exclude property in `PhysicsRayQueryParameters3D` to TypedArray
  • Loading branch information
akien-mga committed Nov 22, 2022
2 parents dfcb2d4 + 82dac64 commit 7f8ecff
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions doc/classes/PhysicsRayQueryParameters3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<param index="0" name="from" type="Vector3" />
<param index="1" name="to" type="Vector3" />
<param index="2" name="collision_mask" type="int" default="4294967295" />
<param index="3" name="exclude" type="Array" default="[]" />
<param index="3" name="exclude" type="RID[]" default="[]" />
<description>
Returns a new, pre-configured [PhysicsRayQueryParameters3D] object. Use it to quickly create query parameters using the most common options.
[codeblock]
Expand All @@ -34,7 +34,7 @@
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="4294967295">
The physics layers the query will detect (as a bitmask). By default, all collision layers are detected. See [url=$DOCS_URL/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
</member>
<member name="exclude" type="Array" setter="set_exclude" getter="get_exclude" default="[]">
<member name="exclude" type="RID[]" setter="set_exclude" getter="get_exclude" default="[]">
The list of objects or object [RID]s that will be excluded from collisions.
</member>
<member name="from" type="Vector3" setter="set_from" getter="get_from" default="Vector3(0, 0, 0)">
Expand Down
10 changes: 5 additions & 5 deletions servers/physics_server_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,19 @@ PhysicsDirectBodyState3D::PhysicsDirectBodyState3D() {}

///////////////////////////////////////////////////////

void PhysicsRayQueryParameters3D::set_exclude(const Vector<RID> &p_exclude) {
void PhysicsRayQueryParameters3D::set_exclude(const TypedArray<RID> &p_exclude) {
parameters.exclude.clear();
for (int i = 0; i < p_exclude.size(); i++) {
parameters.exclude.insert(p_exclude[i]);
}
}

Vector<RID> PhysicsRayQueryParameters3D::get_exclude() const {
Vector<RID> ret;
TypedArray<RID> PhysicsRayQueryParameters3D::get_exclude() const {
TypedArray<RID> ret;
ret.resize(parameters.exclude.size());
int idx = 0;
for (const RID &E : parameters.exclude) {
ret.write[idx++] = E;
ret[idx++] = E;
}
return ret;
}
Expand Down Expand Up @@ -225,7 +225,7 @@ void PhysicsRayQueryParameters3D::_bind_methods() {

///////////////////////////////////////////////////////

Ref<PhysicsRayQueryParameters3D> PhysicsRayQueryParameters3D::create(Vector3 p_from, Vector3 p_to, uint32_t p_mask, const Vector<RID> &p_exclude) {
Ref<PhysicsRayQueryParameters3D> PhysicsRayQueryParameters3D::create(Vector3 p_from, Vector3 p_to, uint32_t p_mask, const TypedArray<RID> &p_exclude) {
Ref<PhysicsRayQueryParameters3D> params;
params.instantiate();
params->set_from(p_from);
Expand Down
6 changes: 3 additions & 3 deletions servers/physics_server_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ class PhysicsRayQueryParameters3D : public RefCounted {
static void _bind_methods();

public:
static Ref<PhysicsRayQueryParameters3D> create(Vector3 p_from, Vector3 p_to, uint32_t p_mask, const Vector<RID> &p_exclude);
static Ref<PhysicsRayQueryParameters3D> create(Vector3 p_from, Vector3 p_to, uint32_t p_mask, const TypedArray<RID> &p_exclude);
const PhysicsDirectSpaceState3D::RayParameters &get_parameters() const { return parameters; }

void set_from(const Vector3 &p_from) { parameters.from = p_from; }
Expand All @@ -846,8 +846,8 @@ class PhysicsRayQueryParameters3D : public RefCounted {
void set_hit_back_faces(bool p_enable) { parameters.hit_back_faces = p_enable; }
bool is_hit_back_faces_enabled() const { return parameters.hit_back_faces; }

void set_exclude(const Vector<RID> &p_exclude);
Vector<RID> get_exclude() const;
void set_exclude(const TypedArray<RID> &p_exclude);
TypedArray<RID> get_exclude() const;
};

class PhysicsPointQueryParameters3D : public RefCounted {
Expand Down

0 comments on commit 7f8ecff

Please sign in to comment.