Merge pull request #69060 from rburing/exclude_typedarray

Update remaining physics `exclude` parameters to use `TypedArray`
This commit is contained in:
Rémi Verschelde 2022-11-24 10:40:25 +01:00
commit 92f1058311
No known key found for this signature in database
GPG key ID: C3336907360768E1
12 changed files with 46 additions and 46 deletions

View file

@ -22,7 +22,7 @@
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="RID[]" setter="set_exclude" getter="get_exclude" default="[]">
The list of objects or object [RID]s that will be excluded from collisions.
The list of object [RID]s that will be excluded from collisions. Use [method CollisionObject2D.get_rid] to get the [RID] associated with a [CollisionObject2D]-derived node.
</member>
<member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2(0, 0)">
The position being queried for, in global coordinates.

View file

@ -18,8 +18,8 @@
<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="[]">
The list of objects or object [RID]s that will be excluded from collisions.
<member name="exclude" type="RID[]" setter="set_exclude" getter="get_exclude" default="[]">
The list of object [RID]s that will be excluded from collisions. Use [method CollisionObject3D.get_rid] to get the [RID] associated with a [CollisionObject3D]-derived node.
</member>
<member name="position" type="Vector3" setter="set_position" getter="get_position" default="Vector3(0, 0, 0)">
The position being queried for, in global coordinates.

View file

@ -35,7 +35,7 @@
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="RID[]" setter="set_exclude" getter="get_exclude" default="[]">
The list of objects or object [RID]s that will be excluded from collisions.
The list of object [RID]s that will be excluded from collisions. Use [method CollisionObject2D.get_rid] to get the [RID] associated with a [CollisionObject2D]-derived node.
</member>
<member name="from" type="Vector2" setter="set_from" getter="get_from" default="Vector2(0, 0)">
The starting point of the ray being queried for, in global coordinates.

View file

@ -35,7 +35,7 @@
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="RID[]" setter="set_exclude" getter="get_exclude" default="[]">
The list of objects or object [RID]s that will be excluded from collisions.
The list of object [RID]s that will be excluded from collisions. Use [method CollisionObject3D.get_rid] to get the [RID] associated with a [CollisionObject3D]-derived node.
</member>
<member name="from" type="Vector3" setter="set_from" getter="get_from" default="Vector3(0, 0, 0)">
The starting point of the ray being queried for, in global coordinates.

View file

@ -19,7 +19,7 @@
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="RID[]" setter="set_exclude" getter="get_exclude" default="[]">
The list of objects or object [RID]s that will be excluded from collisions.
The list of object [RID]s that will be excluded from collisions. Use [method CollisionObject2D.get_rid] to get the [RID] associated with a [CollisionObject2D]-derived node.
</member>
<member name="margin" type="float" setter="set_margin" getter="get_margin" default="0.0">
The collision margin for the shape.

View file

@ -18,8 +18,8 @@
<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="[]">
The list of objects or object [RID]s that will be excluded from collisions.
<member name="exclude" type="RID[]" setter="set_exclude" getter="get_exclude" default="[]">
The list of object [RID]s that will be excluded from collisions. Use [method CollisionObject3D.get_rid] to get the [RID] associated with a [CollisionObject3D]-derived node.
</member>
<member name="margin" type="float" setter="set_margin" getter="get_margin" default="0.0">
The collision margin for the shape.

View file

@ -14,9 +14,9 @@
If set to [code]false[/code], shapes of type [constant PhysicsServer2D.SHAPE_SEPARATION_RAY] are only used for separation when overlapping with other bodies. That's the main use for separation ray shapes.
</member>
<member name="exclude_bodies" type="RID[]" setter="set_exclude_bodies" getter="get_exclude_bodies" default="[]">
Optional array of body [RID] to exclude from collision.
Optional array of body [RID] to exclude from collision. Use [method CollisionObject2D.get_rid] to get the [RID] associated with a [CollisionObject2D]-derived node.
</member>
<member name="exclude_objects" type="Array" setter="set_exclude_objects" getter="get_exclude_objects" default="[]">
<member name="exclude_objects" type="int[]" setter="set_exclude_objects" getter="get_exclude_objects" default="[]">
Optional array of object unique instance ID to exclude from collision. See [method Object.get_instance_id].
</member>
<member name="from" type="Transform2D" setter="set_from" getter="get_from" default="Transform2D(1, 0, 0, 1, 0, 0)">

View file

@ -13,10 +13,10 @@
If set to [code]true[/code], shapes of type [constant PhysicsServer3D.SHAPE_SEPARATION_RAY] are used to detect collisions and can stop the motion. Can be useful when snapping to the ground.
If set to [code]false[/code], shapes of type [constant PhysicsServer3D.SHAPE_SEPARATION_RAY] are only used for separation when overlapping with other bodies. That's the main use for separation ray shapes.
</member>
<member name="exclude_bodies" type="Array" setter="set_exclude_bodies" getter="get_exclude_bodies" default="[]">
Optional array of body [RID] to exclude from collision.
<member name="exclude_bodies" type="RID[]" setter="set_exclude_bodies" getter="get_exclude_bodies" default="[]">
Optional array of body [RID] to exclude from collision. Use [method CollisionObject3D.get_rid] to get the [RID] associated with a [CollisionObject3D]-derived node.
</member>
<member name="exclude_objects" type="Array" setter="set_exclude_objects" getter="get_exclude_objects" default="[]">
<member name="exclude_objects" type="int[]" setter="set_exclude_objects" getter="get_exclude_objects" default="[]">
Optional array of object unique instance ID to exclude from collision. See [method Object.get_instance_id].
</member>
<member name="from" type="Transform3D" setter="set_from" getter="get_from" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)">

View file

@ -479,8 +479,8 @@ void PhysicsTestMotionParameters2D::set_exclude_bodies(const TypedArray<RID> &p_
}
}
Array PhysicsTestMotionParameters2D::get_exclude_objects() const {
Array exclude;
TypedArray<uint64_t> PhysicsTestMotionParameters2D::get_exclude_objects() const {
TypedArray<uint64_t> exclude;
exclude.resize(parameters.exclude_objects.size());
int object_index = 0;
@ -491,7 +491,7 @@ Array PhysicsTestMotionParameters2D::get_exclude_objects() const {
return exclude;
}
void PhysicsTestMotionParameters2D::set_exclude_objects(const Array &p_exclude) {
void PhysicsTestMotionParameters2D::set_exclude_objects(const TypedArray<uint64_t> &p_exclude) {
for (int i = 0; i < p_exclude.size(); ++i) {
ObjectID object_id = p_exclude[i];
ERR_CONTINUE(object_id.is_null());

View file

@ -732,8 +732,8 @@ public:
TypedArray<RID> get_exclude_bodies() const;
void set_exclude_bodies(const TypedArray<RID> &p_exclude);
Array get_exclude_objects() const;
void set_exclude_objects(const Array &p_exclude);
TypedArray<uint64_t> get_exclude_objects() const;
void set_exclude_objects(const TypedArray<uint64_t> &p_exclude);
bool is_recovery_as_collision_enabled() const { return parameters.recovery_as_collision; }
void set_recovery_as_collision_enabled(bool p_enabled) { parameters.recovery_as_collision = p_enabled; }

View file

@ -187,7 +187,7 @@ TypedArray<RID> PhysicsRayQueryParameters3D::get_exclude() const {
}
void PhysicsRayQueryParameters3D::_bind_methods() {
ClassDB::bind_static_method("PhysicsRayQueryParameters3D", D_METHOD("create", "from", "to", "collision_mask", "exclude"), &PhysicsRayQueryParameters3D::create, DEFVAL(UINT32_MAX), DEFVAL(Vector<RID>()));
ClassDB::bind_static_method("PhysicsRayQueryParameters3D", D_METHOD("create", "from", "to", "collision_mask", "exclude"), &PhysicsRayQueryParameters3D::create, DEFVAL(UINT32_MAX), DEFVAL(TypedArray<RID>()));
ClassDB::bind_method(D_METHOD("set_from", "from"), &PhysicsRayQueryParameters3D::set_from);
ClassDB::bind_method(D_METHOD("get_from"), &PhysicsRayQueryParameters3D::get_from);
@ -235,19 +235,19 @@ Ref<PhysicsRayQueryParameters3D> PhysicsRayQueryParameters3D::create(Vector3 p_f
return params;
}
void PhysicsPointQueryParameters3D::set_exclude(const Vector<RID> &p_exclude) {
void PhysicsPointQueryParameters3D::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> PhysicsPointQueryParameters3D::get_exclude() const {
Vector<RID> ret;
TypedArray<RID> PhysicsPointQueryParameters3D::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;
}
@ -290,19 +290,19 @@ void PhysicsShapeQueryParameters3D::set_shape_rid(const RID &p_shape) {
}
}
void PhysicsShapeQueryParameters3D::set_exclude(const Vector<RID> &p_exclude) {
void PhysicsShapeQueryParameters3D::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> PhysicsShapeQueryParameters3D::get_exclude() const {
Vector<RID> ret;
TypedArray<RID> PhysicsShapeQueryParameters3D::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;
}
@ -482,37 +482,37 @@ void PhysicsDirectSpaceState3D::_bind_methods() {
///////////////////////////////
Vector<RID> PhysicsTestMotionParameters3D::get_exclude_bodies() const {
Vector<RID> exclude;
TypedArray<RID> PhysicsTestMotionParameters3D::get_exclude_bodies() const {
TypedArray<RID> exclude;
exclude.resize(parameters.exclude_bodies.size());
int body_index = 0;
for (RID body : parameters.exclude_bodies) {
exclude.write[body_index++] = body;
for (const RID &body : parameters.exclude_bodies) {
exclude[body_index++] = body;
}
return exclude;
}
void PhysicsTestMotionParameters3D::set_exclude_bodies(const Vector<RID> &p_exclude) {
for (RID body : p_exclude) {
parameters.exclude_bodies.insert(body);
void PhysicsTestMotionParameters3D::set_exclude_bodies(const TypedArray<RID> &p_exclude) {
for (int i = 0; i < p_exclude.size(); i++) {
parameters.exclude_bodies.insert(p_exclude[i]);
}
}
Array PhysicsTestMotionParameters3D::get_exclude_objects() const {
Array exclude;
TypedArray<uint64_t> PhysicsTestMotionParameters3D::get_exclude_objects() const {
TypedArray<uint64_t> exclude;
exclude.resize(parameters.exclude_objects.size());
int object_index = 0;
for (ObjectID object_id : parameters.exclude_objects) {
for (const ObjectID &object_id : parameters.exclude_objects) {
exclude[object_index++] = object_id;
}
return exclude;
}
void PhysicsTestMotionParameters3D::set_exclude_objects(const Array &p_exclude) {
void PhysicsTestMotionParameters3D::set_exclude_objects(const TypedArray<uint64_t> &p_exclude) {
for (int i = 0; i < p_exclude.size(); ++i) {
ObjectID object_id = p_exclude[i];
ERR_CONTINUE(object_id.is_null());

View file

@ -873,8 +873,8 @@ public:
void set_collide_with_areas(bool p_enable) { parameters.collide_with_areas = p_enable; }
bool is_collide_with_areas_enabled() const { return parameters.collide_with_areas; }
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 PhysicsShapeQueryParameters3D : public RefCounted {
@ -914,8 +914,8 @@ public:
void set_collide_with_areas(bool p_enable) { parameters.collide_with_areas = p_enable; }
bool is_collide_with_areas_enabled() const { return parameters.collide_with_areas; }
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 PhysicsTestMotionParameters3D : public RefCounted {
@ -944,11 +944,11 @@ public:
bool is_collide_separation_ray_enabled() const { return parameters.collide_separation_ray; }
void set_collide_separation_ray_enabled(bool p_enabled) { parameters.collide_separation_ray = p_enabled; }
Vector<RID> get_exclude_bodies() const;
void set_exclude_bodies(const Vector<RID> &p_exclude);
TypedArray<RID> get_exclude_bodies() const;
void set_exclude_bodies(const TypedArray<RID> &p_exclude);
Array get_exclude_objects() const;
void set_exclude_objects(const Array &p_exclude);
TypedArray<uint64_t> get_exclude_objects() const;
void set_exclude_objects(const TypedArray<uint64_t> &p_exclude);
bool is_recovery_as_collision_enabled() const { return parameters.recovery_as_collision; }
void set_recovery_as_collision_enabled(bool p_enabled) { parameters.recovery_as_collision = p_enabled; }