mirror of
https://github.com/godotengine/godot.git
synced 2024-11-11 14:43:44 +00:00
Move collision layer and mask into CollisionObject.
This commit is contained in:
parent
aa677865e3
commit
071871b787
@ -13,24 +13,6 @@
|
||||
<link title="2D Platformer Demo">https://godotengine.org/asset-library/asset/120</link>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="get_collision_layer_bit" qualifiers="const">
|
||||
<return type="bool">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
Returns an individual bit on the layer mask. Describes whether other areas will collide with this one on the given layer.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_collision_mask_bit" qualifiers="const">
|
||||
<return type="bool">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
Returns an individual bit on the collision mask. Describes whether this area will collide with others on the given layer.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_overlapping_areas" qualifiers="const">
|
||||
<return type="Area2D[]">
|
||||
</return>
|
||||
@ -66,28 +48,6 @@
|
||||
The [code]body[/code] argument can either be a [PhysicsBody2D] or a [TileMap] instance (while TileMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body).
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_collision_layer_bit">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="value" type="bool">
|
||||
</argument>
|
||||
<description>
|
||||
Set/clear individual bits on the layer mask. This makes getting an area in/out of only one layer easier.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_collision_mask_bit">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="value" type="bool">
|
||||
</argument>
|
||||
<description>
|
||||
Set/clear individual bits on the collision mask. This makes selecting the areas scanned easier.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp" default="1.0">
|
||||
@ -100,12 +60,6 @@
|
||||
<member name="audio_bus_override" type="bool" setter="set_audio_bus_override" getter="is_overriding_audio_bus" default="false">
|
||||
If [code]true[/code], the area's audio bus overrides the default audio bus.
|
||||
</member>
|
||||
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
|
||||
The area's physics layer(s). Collidable objects can exist in any of 32 different layers. A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See also [member collision_mask]. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
|
||||
</member>
|
||||
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
|
||||
The physics layers this area scans to determine collision detection. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
|
||||
</member>
|
||||
<member name="gravity" type="float" setter="set_gravity" getter="get_gravity" default="98.0">
|
||||
The area's gravity intensity (ranges from -1024 to 1024). This value multiplies the gravity vector. This is useful to alter the force of gravity without altering its direction.
|
||||
</member>
|
||||
|
@ -11,24 +11,6 @@
|
||||
<link title="GUI in 3D Demo">https://godotengine.org/asset-library/asset/127</link>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="get_collision_layer_bit" qualifiers="const">
|
||||
<return type="bool">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
Returns an individual bit on the layer mask.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_collision_mask_bit" qualifiers="const">
|
||||
<return type="bool">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
Returns an individual bit on the collision mask.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_overlapping_areas" qualifiers="const">
|
||||
<return type="Area3D[]">
|
||||
</return>
|
||||
@ -64,28 +46,6 @@
|
||||
The [code]body[/code] argument can either be a [PhysicsBody3D] or a [GridMap] instance (while GridMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body).
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_collision_layer_bit">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="value" type="bool">
|
||||
</argument>
|
||||
<description>
|
||||
Set/clear individual bits on the layer mask. This simplifies editing this [Area3D]'s layers.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_collision_mask_bit">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="value" type="bool">
|
||||
</argument>
|
||||
<description>
|
||||
Set/clear individual bits on the collision mask. This simplifies editing which [Area3D] layers this [Area3D] scans.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp" default="0.1">
|
||||
@ -98,12 +58,6 @@
|
||||
<member name="audio_bus_override" type="bool" setter="set_audio_bus_override" getter="is_overriding_audio_bus" default="false">
|
||||
If [code]true[/code], the area's audio bus overrides the default audio bus.
|
||||
</member>
|
||||
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
|
||||
The area's physics layer(s). Collidable objects can exist in any of 32 different layers. A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See also [member collision_mask]. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
|
||||
</member>
|
||||
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
|
||||
The physics layers this area scans to determine collision detection. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
|
||||
</member>
|
||||
<member name="gravity" type="float" setter="set_gravity" getter="get_gravity" default="9.8">
|
||||
The area's gravity intensity (ranges from -1024 to 1024). This value multiplies the gravity vector. This is useful to alter the force of gravity without altering its direction.
|
||||
</member>
|
||||
|
@ -31,6 +31,24 @@
|
||||
Creates a new shape owner for the given object. Returns [code]owner_id[/code] of the new owner for future reference.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_collision_layer_bit" qualifiers="const">
|
||||
<return type="bool">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
Returns whether or not the specified [code]bit[/code] of the [member collision_layer] is set.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_collision_mask_bit" qualifiers="const">
|
||||
<return type="bool">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
Returns whether or not the specified [code]bit[/code] of the [member collision_mask] is set.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_rid" qualifiers="const">
|
||||
<return type="RID">
|
||||
</return>
|
||||
@ -90,6 +108,30 @@
|
||||
Returns the [code]owner_id[/code] of the given shape.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_collision_layer_bit">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="value" type="bool">
|
||||
</argument>
|
||||
<description>
|
||||
If [code]value[/value] is [code]true[/code], sets the specified [code]bit[/code] in the the [member collision_layer].
|
||||
If [code]value[/value] is [code]false[/code], clears the specified [code]bit[/code] in the the [member collision_layer].
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_collision_mask_bit">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="value" type="bool">
|
||||
</argument>
|
||||
<description>
|
||||
If [code]value[/value] is [code]true[/code], sets the specified [code]bit[/code] in the the [member collision_mask].
|
||||
If [code]value[/value] is [code]false[/code], clears the specified [code]bit[/code] in the the [member collision_mask].
|
||||
</description>
|
||||
</method>
|
||||
<method name="shape_owner_add_shape">
|
||||
<return type="void">
|
||||
</return>
|
||||
@ -216,6 +258,14 @@
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
|
||||
The physics layers this CollisionObject2D is in. Collision objects can exist in one or more of 32 different layers. See also [member collision_mask].
|
||||
[b]Note:[/b] A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
|
||||
</member>
|
||||
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
|
||||
The physics layers this CollisionObject2D scans. Collision objects can scan one or more of 32 different layers. See also [member collision_layer].
|
||||
[b]Note:[/b] A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
|
||||
</member>
|
||||
<member name="input_pickable" type="bool" setter="set_pickable" getter="is_pickable" default="true">
|
||||
If [code]true[/code], this object is pickable. A pickable object can detect the mouse pointer entering/leaving, and if the mouse is inside it, report input events. Requires at least one [code]collision_layer[/code] bit to be set.
|
||||
</member>
|
||||
|
@ -35,6 +35,24 @@
|
||||
Creates a new shape owner for the given object. Returns [code]owner_id[/code] of the new owner for future reference.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_collision_layer_bit" qualifiers="const">
|
||||
<return type="bool">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
Returns whether or not the specified [code]bit[/code] of the [member collision_layer] is set.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_collision_mask_bit" qualifiers="const">
|
||||
<return type="bool">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
Returns whether or not the specified [code]bit[/code] of the [member collision_mask] is set.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_rid" qualifiers="const">
|
||||
<return type="RID">
|
||||
</return>
|
||||
@ -67,6 +85,30 @@
|
||||
Removes the given shape owner.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_collision_layer_bit">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="value" type="bool">
|
||||
</argument>
|
||||
<description>
|
||||
If [code]value[/value] is [code]true[/code], sets the specified [code]bit[/code] in the the [member collision_layer].
|
||||
If [code]value[/value] is [code]false[/code], clears the specified [code]bit[/code] in the the [member collision_layer].
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_collision_mask_bit">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="value" type="bool">
|
||||
</argument>
|
||||
<description>
|
||||
If [code]value[/value] is [code]true[/code], sets the specified [code]bit[/code] in the the [member collision_mask].
|
||||
If [code]value[/value] is [code]false[/code], clears the specified [code]bit[/code] in the the [member collision_mask].
|
||||
</description>
|
||||
</method>
|
||||
<method name="shape_find_owner" qualifiers="const">
|
||||
<return type="int">
|
||||
</return>
|
||||
@ -180,6 +222,17 @@
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
|
||||
The physics layers this CollisionObject3D is in. Collision objects can exist in one or more of 32 different layers. See also [member collision_mask].
|
||||
[b]Note:[/b] A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
|
||||
</member>
|
||||
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
|
||||
The physics layers this CollisionObject3D scans. Collision objects can scan one or more of 32 different layers. See also [member collision_layer].
|
||||
[b]Note:[/b] A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
|
||||
</member>
|
||||
<member name="input_pickable" type="bool" setter="set_pickable" getter="is_pickable" default="true">
|
||||
If [code]true[/code], this object is pickable. A pickable object can detect the mouse pointer entering/leaving, and if the mouse is inside it, report input events. Requires at least one [code]collision_layer[/code] bit to be set.
|
||||
</member>
|
||||
<member name="input_capture_on_drag" type="bool" setter="set_capture_input_on_drag" getter="get_capture_input_on_drag" default="false">
|
||||
If [code]true[/code], the [CollisionObject3D] will continue to receive input events as the mouse is dragged across its shapes.
|
||||
</member>
|
||||
|
@ -26,24 +26,6 @@
|
||||
Returns an array of nodes that were added as collision exceptions for this body.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_collision_layer_bit" qualifiers="const">
|
||||
<return type="bool">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
Returns an individual bit on the [member collision_layer].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_collision_mask_bit" qualifiers="const">
|
||||
<return type="bool">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
Returns an individual bit on the [member collision_mask].
|
||||
</description>
|
||||
</method>
|
||||
<method name="remove_collision_exception_with">
|
||||
<return type="void">
|
||||
</return>
|
||||
@ -53,38 +35,8 @@
|
||||
Removes a body from the list of bodies that this body can't collide with.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_collision_layer_bit">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="value" type="bool">
|
||||
</argument>
|
||||
<description>
|
||||
Sets individual bits on the [member collision_layer] bitmask. Use this if you only need to change one layer's value.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_collision_mask_bit">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="value" type="bool">
|
||||
</argument>
|
||||
<description>
|
||||
Sets individual bits on the [member collision_mask] bitmask. Use this if you only need to change one layer's value.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
|
||||
The physics layers this area is in.
|
||||
Collidable objects can exist in any of 32 different layers. These layers work like a tagging system, and are not visual. A collidable can use these layers to select with which objects it can collide, using the [member collision_mask] property.
|
||||
A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
|
||||
</member>
|
||||
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
|
||||
The physics layers this area scans for collisions. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
|
||||
</member>
|
||||
<member name="input_pickable" type="bool" setter="set_pickable" getter="is_pickable" override="true" default="false" />
|
||||
</members>
|
||||
<constants>
|
||||
|
@ -26,24 +26,6 @@
|
||||
Returns an array of nodes that were added as collision exceptions for this body.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_collision_layer_bit" qualifiers="const">
|
||||
<return type="bool">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
Returns an individual bit on the [member collision_layer].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_collision_mask_bit" qualifiers="const">
|
||||
<return type="bool">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
Returns an individual bit on the [member collision_mask].
|
||||
</description>
|
||||
</method>
|
||||
<method name="remove_collision_exception_with">
|
||||
<return type="void">
|
||||
</return>
|
||||
@ -53,38 +35,8 @@
|
||||
Removes a body from the list of bodies that this body can't collide with.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_collision_layer_bit">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="value" type="bool">
|
||||
</argument>
|
||||
<description>
|
||||
Sets individual bits on the [member collision_layer] bitmask. Use this if you only need to change one layer's value.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_collision_mask_bit">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="bit" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="value" type="bool">
|
||||
</argument>
|
||||
<description>
|
||||
Sets individual bits on the [member collision_mask] bitmask. Use this if you only need to change one layer's value.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
|
||||
The physics layers this area is in.
|
||||
Collidable objects can exist in any of 32 different layers. These layers work like a tagging system, and are not visual. A collidable can use these layers to select with which objects it can collide, using the [member collision_mask] property.
|
||||
A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
|
||||
</member>
|
||||
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
|
||||
The physics layers this area scans for collisions. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
|
@ -450,52 +450,6 @@ bool Area2D::overlaps_body(Node *p_body) const {
|
||||
return E->get().in_tree;
|
||||
}
|
||||
|
||||
void Area2D::set_collision_mask(uint32_t p_mask) {
|
||||
collision_mask = p_mask;
|
||||
PhysicsServer2D::get_singleton()->area_set_collision_mask(get_rid(), p_mask);
|
||||
}
|
||||
|
||||
uint32_t Area2D::get_collision_mask() const {
|
||||
return collision_mask;
|
||||
}
|
||||
|
||||
void Area2D::set_collision_layer(uint32_t p_layer) {
|
||||
collision_layer = p_layer;
|
||||
PhysicsServer2D::get_singleton()->area_set_collision_layer(get_rid(), p_layer);
|
||||
}
|
||||
|
||||
uint32_t Area2D::get_collision_layer() const {
|
||||
return collision_layer;
|
||||
}
|
||||
|
||||
void Area2D::set_collision_mask_bit(int p_bit, bool p_value) {
|
||||
uint32_t mask = get_collision_mask();
|
||||
if (p_value) {
|
||||
mask |= 1 << p_bit;
|
||||
} else {
|
||||
mask &= ~(1 << p_bit);
|
||||
}
|
||||
set_collision_mask(mask);
|
||||
}
|
||||
|
||||
bool Area2D::get_collision_mask_bit(int p_bit) const {
|
||||
return get_collision_mask() & (1 << p_bit);
|
||||
}
|
||||
|
||||
void Area2D::set_collision_layer_bit(int p_bit, bool p_value) {
|
||||
uint32_t layer = get_collision_layer();
|
||||
if (p_value) {
|
||||
layer |= 1 << p_bit;
|
||||
} else {
|
||||
layer &= ~(1 << p_bit);
|
||||
}
|
||||
set_collision_layer(layer);
|
||||
}
|
||||
|
||||
bool Area2D::get_collision_layer_bit(int p_bit) const {
|
||||
return get_collision_layer() & (1 << p_bit);
|
||||
}
|
||||
|
||||
void Area2D::set_audio_bus_override(bool p_override) {
|
||||
audio_bus_override = p_override;
|
||||
}
|
||||
@ -557,18 +511,6 @@ void Area2D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_priority", "priority"), &Area2D::set_priority);
|
||||
ClassDB::bind_method(D_METHOD("get_priority"), &Area2D::get_priority);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &Area2D::set_collision_mask);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_mask"), &Area2D::get_collision_mask);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_collision_layer", "collision_layer"), &Area2D::set_collision_layer);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_layer"), &Area2D::get_collision_layer);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &Area2D::set_collision_mask_bit);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &Area2D::get_collision_mask_bit);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &Area2D::set_collision_layer_bit);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &Area2D::get_collision_layer_bit);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_monitoring", "enable"), &Area2D::set_monitoring);
|
||||
ClassDB::bind_method(D_METHOD("is_monitoring"), &Area2D::is_monitoring);
|
||||
|
||||
@ -613,10 +555,6 @@ void Area2D::_bind_methods() {
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "linear_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_linear_damp", "get_linear_damp");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_angular_damp", "get_angular_damp");
|
||||
|
||||
ADD_GROUP("Collision", "collision_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_collision_layer", "get_collision_layer");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_collision_mask", "get_collision_mask");
|
||||
|
||||
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_NAME, "audio_bus_name", PROPERTY_HINT_ENUM, ""), "set_audio_bus_name", "get_audio_bus_name");
|
||||
|
@ -54,8 +54,6 @@ private:
|
||||
real_t gravity_distance_scale = 0.0;
|
||||
real_t linear_damp = 0.1;
|
||||
real_t angular_damp = 1.0;
|
||||
uint32_t collision_mask = 1;
|
||||
uint32_t collision_layer = 1;
|
||||
int priority = 0;
|
||||
bool monitoring = false;
|
||||
bool monitorable = false;
|
||||
@ -163,18 +161,6 @@ public:
|
||||
void set_monitorable(bool p_enable);
|
||||
bool is_monitorable() const;
|
||||
|
||||
void set_collision_mask(uint32_t p_mask);
|
||||
uint32_t get_collision_mask() const;
|
||||
|
||||
void set_collision_layer(uint32_t p_layer);
|
||||
uint32_t get_collision_layer() const;
|
||||
|
||||
void set_collision_mask_bit(int p_bit, bool p_value);
|
||||
bool get_collision_mask_bit(int p_bit) const;
|
||||
|
||||
void set_collision_layer_bit(int p_bit, bool p_value);
|
||||
bool get_collision_layer_bit(int p_bit) const;
|
||||
|
||||
TypedArray<Node2D> get_overlapping_bodies() const; //function for script
|
||||
TypedArray<Area2D> get_overlapping_areas() const; //function for script
|
||||
|
||||
|
@ -100,6 +100,60 @@ void CollisionObject2D::_notification(int p_what) {
|
||||
}
|
||||
}
|
||||
|
||||
void CollisionObject2D::set_collision_layer(uint32_t p_layer) {
|
||||
collision_layer = p_layer;
|
||||
if (area) {
|
||||
PhysicsServer2D::get_singleton()->area_set_collision_layer(get_rid(), p_layer);
|
||||
} else {
|
||||
PhysicsServer2D::get_singleton()->body_set_collision_layer(get_rid(), p_layer);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t CollisionObject2D::get_collision_layer() const {
|
||||
return collision_layer;
|
||||
}
|
||||
|
||||
void CollisionObject2D::set_collision_mask(uint32_t p_mask) {
|
||||
collision_mask = p_mask;
|
||||
if (area) {
|
||||
PhysicsServer2D::get_singleton()->area_set_collision_mask(get_rid(), p_mask);
|
||||
} else {
|
||||
PhysicsServer2D::get_singleton()->body_set_collision_mask(get_rid(), p_mask);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t CollisionObject2D::get_collision_mask() const {
|
||||
return collision_mask;
|
||||
}
|
||||
|
||||
void CollisionObject2D::set_collision_layer_bit(int p_bit, bool p_value) {
|
||||
uint32_t collision_layer = get_collision_layer();
|
||||
if (p_value) {
|
||||
collision_layer |= 1 << p_bit;
|
||||
} else {
|
||||
collision_layer &= ~(1 << p_bit);
|
||||
}
|
||||
set_collision_layer(collision_layer);
|
||||
}
|
||||
|
||||
bool CollisionObject2D::get_collision_layer_bit(int p_bit) const {
|
||||
return get_collision_layer() & (1 << p_bit);
|
||||
}
|
||||
|
||||
void CollisionObject2D::set_collision_mask_bit(int p_bit, bool p_value) {
|
||||
uint32_t mask = get_collision_mask();
|
||||
if (p_value) {
|
||||
mask |= 1 << p_bit;
|
||||
} else {
|
||||
mask &= ~(1 << p_bit);
|
||||
}
|
||||
set_collision_mask(mask);
|
||||
}
|
||||
|
||||
bool CollisionObject2D::get_collision_mask_bit(int p_bit) const {
|
||||
return get_collision_mask() & (1 << p_bit);
|
||||
}
|
||||
|
||||
uint32_t CollisionObject2D::create_shape_owner(Object *p_owner) {
|
||||
ShapeData sd;
|
||||
uint32_t id;
|
||||
@ -375,7 +429,14 @@ TypedArray<String> CollisionObject2D::get_configuration_warnings() const {
|
||||
|
||||
void CollisionObject2D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_rid"), &CollisionObject2D::get_rid);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &CollisionObject2D::set_collision_layer);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_layer"), &CollisionObject2D::get_collision_layer);
|
||||
ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &CollisionObject2D::set_collision_mask);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_mask"), &CollisionObject2D::get_collision_mask);
|
||||
ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &CollisionObject2D::set_collision_layer_bit);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &CollisionObject2D::get_collision_layer_bit);
|
||||
ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &CollisionObject2D::set_collision_mask_bit);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &CollisionObject2D::get_collision_mask_bit);
|
||||
ClassDB::bind_method(D_METHOD("set_pickable", "enabled"), &CollisionObject2D::set_pickable);
|
||||
ClassDB::bind_method(D_METHOD("is_pickable"), &CollisionObject2D::is_pickable);
|
||||
ClassDB::bind_method(D_METHOD("create_shape_owner", "owner"), &CollisionObject2D::create_shape_owner);
|
||||
@ -404,9 +465,12 @@ void CollisionObject2D::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("mouse_entered"));
|
||||
ADD_SIGNAL(MethodInfo("mouse_exited"));
|
||||
|
||||
ADD_GROUP("Pickable", "input_");
|
||||
ADD_GROUP("Collision", "collision_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_collision_layer", "get_collision_layer");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_collision_mask", "get_collision_mask");
|
||||
|
||||
ADD_GROUP("Input", "input_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "input_pickable"), "set_pickable", "is_pickable");
|
||||
ADD_GROUP("", "");
|
||||
}
|
||||
|
||||
CollisionObject2D::CollisionObject2D(RID p_rid, bool p_area) {
|
||||
|
@ -37,6 +37,9 @@
|
||||
class CollisionObject2D : public Node2D {
|
||||
GDCLASS(CollisionObject2D, Node2D);
|
||||
|
||||
uint32_t collision_layer = 1;
|
||||
uint32_t collision_mask = 1;
|
||||
|
||||
bool area = false;
|
||||
RID rid;
|
||||
bool pickable = false;
|
||||
@ -76,6 +79,18 @@ protected:
|
||||
void set_only_update_transform_changes(bool p_enable);
|
||||
|
||||
public:
|
||||
void set_collision_layer(uint32_t p_layer);
|
||||
uint32_t get_collision_layer() const;
|
||||
|
||||
void set_collision_mask(uint32_t p_mask);
|
||||
uint32_t get_collision_mask() const;
|
||||
|
||||
void set_collision_layer_bit(int p_bit, bool p_value);
|
||||
bool get_collision_layer_bit(int p_bit) const;
|
||||
|
||||
void set_collision_mask_bit(int p_bit, bool p_value);
|
||||
bool get_collision_mask_bit(int p_bit) const;
|
||||
|
||||
uint32_t create_shape_owner(Object *p_owner);
|
||||
void remove_shape_owner(uint32_t owner);
|
||||
void get_shape_owners(List<uint32_t> *r_owners);
|
||||
|
@ -42,70 +42,9 @@ void PhysicsBody2D::_notification(int p_what) {
|
||||
}
|
||||
|
||||
void PhysicsBody2D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &PhysicsBody2D::set_collision_layer);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_layer"), &PhysicsBody2D::get_collision_layer);
|
||||
ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &PhysicsBody2D::set_collision_mask);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsBody2D::get_collision_mask);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &PhysicsBody2D::set_collision_mask_bit);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &PhysicsBody2D::get_collision_mask_bit);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &PhysicsBody2D::set_collision_layer_bit);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &PhysicsBody2D::get_collision_layer_bit);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_collision_exceptions"), &PhysicsBody2D::get_collision_exceptions);
|
||||
ClassDB::bind_method(D_METHOD("add_collision_exception_with", "body"), &PhysicsBody2D::add_collision_exception_with);
|
||||
ClassDB::bind_method(D_METHOD("remove_collision_exception_with", "body"), &PhysicsBody2D::remove_collision_exception_with);
|
||||
|
||||
ADD_GROUP("Collision", "collision_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_collision_layer", "get_collision_layer");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_collision_mask", "get_collision_mask");
|
||||
}
|
||||
|
||||
void PhysicsBody2D::set_collision_layer(uint32_t p_layer) {
|
||||
collision_layer = p_layer;
|
||||
PhysicsServer2D::get_singleton()->body_set_collision_layer(get_rid(), p_layer);
|
||||
}
|
||||
|
||||
uint32_t PhysicsBody2D::get_collision_layer() const {
|
||||
return collision_layer;
|
||||
}
|
||||
|
||||
void PhysicsBody2D::set_collision_mask(uint32_t p_mask) {
|
||||
collision_mask = p_mask;
|
||||
PhysicsServer2D::get_singleton()->body_set_collision_mask(get_rid(), p_mask);
|
||||
}
|
||||
|
||||
uint32_t PhysicsBody2D::get_collision_mask() const {
|
||||
return collision_mask;
|
||||
}
|
||||
|
||||
void PhysicsBody2D::set_collision_mask_bit(int p_bit, bool p_value) {
|
||||
uint32_t mask = get_collision_mask();
|
||||
if (p_value) {
|
||||
mask |= 1 << p_bit;
|
||||
} else {
|
||||
mask &= ~(1 << p_bit);
|
||||
}
|
||||
set_collision_mask(mask);
|
||||
}
|
||||
|
||||
bool PhysicsBody2D::get_collision_mask_bit(int p_bit) const {
|
||||
return get_collision_mask() & (1 << p_bit);
|
||||
}
|
||||
|
||||
void PhysicsBody2D::set_collision_layer_bit(int p_bit, bool p_value) {
|
||||
uint32_t collision_layer = get_collision_layer();
|
||||
if (p_value) {
|
||||
collision_layer |= 1 << p_bit;
|
||||
} else {
|
||||
collision_layer &= ~(1 << p_bit);
|
||||
}
|
||||
set_collision_layer(collision_layer);
|
||||
}
|
||||
|
||||
bool PhysicsBody2D::get_collision_layer_bit(int p_bit) const {
|
||||
return get_collision_layer() & (1 << p_bit);
|
||||
}
|
||||
|
||||
PhysicsBody2D::PhysicsBody2D(PhysicsServer2D::BodyMode p_mode) :
|
||||
|
@ -41,9 +41,6 @@ class KinematicCollision2D;
|
||||
class PhysicsBody2D : public CollisionObject2D {
|
||||
GDCLASS(PhysicsBody2D, CollisionObject2D);
|
||||
|
||||
uint32_t collision_layer = 1;
|
||||
uint32_t collision_mask = 1;
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
PhysicsBody2D(PhysicsServer2D::BodyMode p_mode);
|
||||
@ -51,18 +48,6 @@ protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void set_collision_layer(uint32_t p_layer);
|
||||
uint32_t get_collision_layer() const;
|
||||
|
||||
void set_collision_mask(uint32_t p_mask);
|
||||
uint32_t get_collision_mask() const;
|
||||
|
||||
void set_collision_mask_bit(int p_bit, bool p_value);
|
||||
bool get_collision_mask_bit(int p_bit) const;
|
||||
|
||||
void set_collision_layer_bit(int p_bit, bool p_value);
|
||||
bool get_collision_layer_bit(int p_bit) const;
|
||||
|
||||
TypedArray<PhysicsBody2D> get_collision_exceptions();
|
||||
void add_collision_exception_with(Node *p_node); //must be physicsbody
|
||||
void remove_collision_exception_with(Node *p_node);
|
||||
|
@ -451,52 +451,6 @@ bool Area3D::overlaps_body(Node *p_body) const {
|
||||
return E->get().in_tree;
|
||||
}
|
||||
|
||||
void Area3D::set_collision_mask(uint32_t p_mask) {
|
||||
collision_mask = p_mask;
|
||||
PhysicsServer3D::get_singleton()->area_set_collision_mask(get_rid(), p_mask);
|
||||
}
|
||||
|
||||
uint32_t Area3D::get_collision_mask() const {
|
||||
return collision_mask;
|
||||
}
|
||||
|
||||
void Area3D::set_collision_layer(uint32_t p_layer) {
|
||||
collision_layer = p_layer;
|
||||
PhysicsServer3D::get_singleton()->area_set_collision_layer(get_rid(), p_layer);
|
||||
}
|
||||
|
||||
uint32_t Area3D::get_collision_layer() const {
|
||||
return collision_layer;
|
||||
}
|
||||
|
||||
void Area3D::set_collision_mask_bit(int p_bit, bool p_value) {
|
||||
uint32_t mask = get_collision_mask();
|
||||
if (p_value) {
|
||||
mask |= 1 << p_bit;
|
||||
} else {
|
||||
mask &= ~(1 << p_bit);
|
||||
}
|
||||
set_collision_mask(mask);
|
||||
}
|
||||
|
||||
bool Area3D::get_collision_mask_bit(int p_bit) const {
|
||||
return get_collision_mask() & (1 << p_bit);
|
||||
}
|
||||
|
||||
void Area3D::set_collision_layer_bit(int p_bit, bool p_value) {
|
||||
uint32_t layer = get_collision_layer();
|
||||
if (p_value) {
|
||||
layer |= 1 << p_bit;
|
||||
} else {
|
||||
layer &= ~(1 << p_bit);
|
||||
}
|
||||
set_collision_layer(layer);
|
||||
}
|
||||
|
||||
bool Area3D::get_collision_layer_bit(int p_bit) const {
|
||||
return get_collision_layer() & (1 << p_bit);
|
||||
}
|
||||
|
||||
void Area3D::set_audio_bus_override(bool p_override) {
|
||||
audio_bus_override = p_override;
|
||||
}
|
||||
@ -595,18 +549,6 @@ void Area3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_priority", "priority"), &Area3D::set_priority);
|
||||
ClassDB::bind_method(D_METHOD("get_priority"), &Area3D::get_priority);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &Area3D::set_collision_mask);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_mask"), &Area3D::get_collision_mask);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_collision_layer", "collision_layer"), &Area3D::set_collision_layer);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_layer"), &Area3D::get_collision_layer);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &Area3D::set_collision_mask_bit);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &Area3D::get_collision_mask_bit);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &Area3D::set_collision_layer_bit);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &Area3D::get_collision_layer_bit);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_monitorable", "enable"), &Area3D::set_monitorable);
|
||||
ClassDB::bind_method(D_METHOD("is_monitorable"), &Area3D::is_monitorable);
|
||||
|
||||
@ -663,10 +605,6 @@ void Area3D::_bind_methods() {
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "linear_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_linear_damp", "get_linear_damp");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_angular_damp", "get_angular_damp");
|
||||
|
||||
ADD_GROUP("Collision", "collision_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_layer", "get_collision_layer");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
|
||||
|
||||
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_NAME, "audio_bus_name", PROPERTY_HINT_ENUM, ""), "set_audio_bus_name", "get_audio_bus_name");
|
||||
|
@ -54,8 +54,6 @@ private:
|
||||
real_t gravity_distance_scale = 0.0;
|
||||
real_t angular_damp = 0.1;
|
||||
real_t linear_damp = 0.1;
|
||||
uint32_t collision_mask = 1;
|
||||
uint32_t collision_layer = 1;
|
||||
int priority = 0;
|
||||
bool monitoring = false;
|
||||
bool monitorable = false;
|
||||
@ -169,18 +167,6 @@ public:
|
||||
void set_monitorable(bool p_enable);
|
||||
bool is_monitorable() const;
|
||||
|
||||
void set_collision_mask(uint32_t p_mask);
|
||||
uint32_t get_collision_mask() const;
|
||||
|
||||
void set_collision_layer(uint32_t p_layer);
|
||||
uint32_t get_collision_layer() const;
|
||||
|
||||
void set_collision_mask_bit(int p_bit, bool p_value);
|
||||
bool get_collision_mask_bit(int p_bit) const;
|
||||
|
||||
void set_collision_layer_bit(int p_bit, bool p_value);
|
||||
bool get_collision_layer_bit(int p_bit) const;
|
||||
|
||||
TypedArray<Node3D> get_overlapping_bodies() const;
|
||||
TypedArray<Area3D> get_overlapping_areas() const; //function for script
|
||||
|
||||
|
@ -83,6 +83,60 @@ void CollisionObject3D::_notification(int p_what) {
|
||||
}
|
||||
}
|
||||
|
||||
void CollisionObject3D::set_collision_layer(uint32_t p_layer) {
|
||||
collision_layer = p_layer;
|
||||
if (area) {
|
||||
PhysicsServer3D::get_singleton()->area_set_collision_layer(get_rid(), p_layer);
|
||||
} else {
|
||||
PhysicsServer3D::get_singleton()->body_set_collision_layer(get_rid(), p_layer);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t CollisionObject3D::get_collision_layer() const {
|
||||
return collision_layer;
|
||||
}
|
||||
|
||||
void CollisionObject3D::set_collision_mask(uint32_t p_mask) {
|
||||
collision_mask = p_mask;
|
||||
if (area) {
|
||||
PhysicsServer3D::get_singleton()->area_set_collision_mask(get_rid(), p_mask);
|
||||
} else {
|
||||
PhysicsServer3D::get_singleton()->body_set_collision_mask(get_rid(), p_mask);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t CollisionObject3D::get_collision_mask() const {
|
||||
return collision_mask;
|
||||
}
|
||||
|
||||
void CollisionObject3D::set_collision_layer_bit(int p_bit, bool p_value) {
|
||||
uint32_t collision_layer = get_collision_layer();
|
||||
if (p_value) {
|
||||
collision_layer |= 1 << p_bit;
|
||||
} else {
|
||||
collision_layer &= ~(1 << p_bit);
|
||||
}
|
||||
set_collision_layer(collision_layer);
|
||||
}
|
||||
|
||||
bool CollisionObject3D::get_collision_layer_bit(int p_bit) const {
|
||||
return get_collision_layer() & (1 << p_bit);
|
||||
}
|
||||
|
||||
void CollisionObject3D::set_collision_mask_bit(int p_bit, bool p_value) {
|
||||
uint32_t mask = get_collision_mask();
|
||||
if (p_value) {
|
||||
mask |= 1 << p_bit;
|
||||
} else {
|
||||
mask &= ~(1 << p_bit);
|
||||
}
|
||||
set_collision_mask(mask);
|
||||
}
|
||||
|
||||
bool CollisionObject3D::get_collision_mask_bit(int p_bit) const {
|
||||
return get_collision_mask() & (1 << p_bit);
|
||||
}
|
||||
|
||||
void CollisionObject3D::_input_event(Node *p_camera, const Ref<InputEvent> &p_input_event, const Vector3 &p_pos, const Vector3 &p_normal, int p_shape) {
|
||||
if (get_script_instance()) {
|
||||
get_script_instance()->call(SceneStringNames::get_singleton()->_input_event, p_camera, p_input_event, p_pos, p_normal, p_shape);
|
||||
@ -183,6 +237,14 @@ bool CollisionObject3D::is_ray_pickable() const {
|
||||
}
|
||||
|
||||
void CollisionObject3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &CollisionObject3D::set_collision_layer);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_layer"), &CollisionObject3D::get_collision_layer);
|
||||
ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &CollisionObject3D::set_collision_mask);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_mask"), &CollisionObject3D::get_collision_mask);
|
||||
ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &CollisionObject3D::set_collision_layer_bit);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &CollisionObject3D::get_collision_layer_bit);
|
||||
ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &CollisionObject3D::set_collision_mask_bit);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &CollisionObject3D::get_collision_mask_bit);
|
||||
ClassDB::bind_method(D_METHOD("set_ray_pickable", "ray_pickable"), &CollisionObject3D::set_ray_pickable);
|
||||
ClassDB::bind_method(D_METHOD("is_ray_pickable"), &CollisionObject3D::is_ray_pickable);
|
||||
ClassDB::bind_method(D_METHOD("set_capture_input_on_drag", "enable"), &CollisionObject3D::set_capture_input_on_drag);
|
||||
@ -212,6 +274,11 @@ void CollisionObject3D::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("mouse_entered"));
|
||||
ADD_SIGNAL(MethodInfo("mouse_exited"));
|
||||
|
||||
ADD_GROUP("Collision", "collision_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_layer", "get_collision_layer");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
|
||||
|
||||
ADD_GROUP("Input", "input_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "input_ray_pickable"), "set_ray_pickable", "is_ray_pickable");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "input_capture_on_drag"), "set_capture_input_on_drag", "get_capture_input_on_drag");
|
||||
}
|
||||
|
@ -37,6 +37,9 @@
|
||||
class CollisionObject3D : public Node3D {
|
||||
GDCLASS(CollisionObject3D, Node3D);
|
||||
|
||||
uint32_t collision_layer = 1;
|
||||
uint32_t collision_mask = 1;
|
||||
|
||||
bool area = false;
|
||||
|
||||
RID rid;
|
||||
@ -82,6 +85,18 @@ protected:
|
||||
void _clear_debug_shapes();
|
||||
|
||||
public:
|
||||
void set_collision_layer(uint32_t p_layer);
|
||||
uint32_t get_collision_layer() const;
|
||||
|
||||
void set_collision_mask(uint32_t p_mask);
|
||||
uint32_t get_collision_mask() const;
|
||||
|
||||
void set_collision_layer_bit(int p_bit, bool p_value);
|
||||
bool get_collision_layer_bit(int p_bit) const;
|
||||
|
||||
void set_collision_mask_bit(int p_bit, bool p_value);
|
||||
bool get_collision_mask_bit(int p_bit) const;
|
||||
|
||||
uint32_t create_shape_owner(Object *p_owner);
|
||||
void remove_shape_owner(uint32_t owner);
|
||||
void get_shape_owners(List<uint32_t> *r_owners);
|
||||
|
@ -55,52 +55,6 @@ real_t PhysicsBody3D::get_inverse_mass() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PhysicsBody3D::set_collision_layer(uint32_t p_layer) {
|
||||
collision_layer = p_layer;
|
||||
PhysicsServer3D::get_singleton()->body_set_collision_layer(get_rid(), p_layer);
|
||||
}
|
||||
|
||||
uint32_t PhysicsBody3D::get_collision_layer() const {
|
||||
return collision_layer;
|
||||
}
|
||||
|
||||
void PhysicsBody3D::set_collision_mask(uint32_t p_mask) {
|
||||
collision_mask = p_mask;
|
||||
PhysicsServer3D::get_singleton()->body_set_collision_mask(get_rid(), p_mask);
|
||||
}
|
||||
|
||||
uint32_t PhysicsBody3D::get_collision_mask() const {
|
||||
return collision_mask;
|
||||
}
|
||||
|
||||
void PhysicsBody3D::set_collision_mask_bit(int p_bit, bool p_value) {
|
||||
uint32_t mask = get_collision_mask();
|
||||
if (p_value) {
|
||||
mask |= 1 << p_bit;
|
||||
} else {
|
||||
mask &= ~(1 << p_bit);
|
||||
}
|
||||
set_collision_mask(mask);
|
||||
}
|
||||
|
||||
bool PhysicsBody3D::get_collision_mask_bit(int p_bit) const {
|
||||
return get_collision_mask() & (1 << p_bit);
|
||||
}
|
||||
|
||||
void PhysicsBody3D::set_collision_layer_bit(int p_bit, bool p_value) {
|
||||
uint32_t mask = get_collision_layer();
|
||||
if (p_value) {
|
||||
mask |= 1 << p_bit;
|
||||
} else {
|
||||
mask &= ~(1 << p_bit);
|
||||
}
|
||||
set_collision_layer(mask);
|
||||
}
|
||||
|
||||
bool PhysicsBody3D::get_collision_layer_bit(int p_bit) const {
|
||||
return get_collision_layer() & (1 << p_bit);
|
||||
}
|
||||
|
||||
TypedArray<PhysicsBody3D> PhysicsBody3D::get_collision_exceptions() {
|
||||
List<RID> exceptions;
|
||||
PhysicsServer3D::get_singleton()->body_get_collision_exceptions(get_rid(), &exceptions);
|
||||
@ -129,29 +83,11 @@ void PhysicsBody3D::remove_collision_exception_with(Node *p_node) {
|
||||
PhysicsServer3D::get_singleton()->body_remove_collision_exception(get_rid(), collision_object->get_rid());
|
||||
}
|
||||
|
||||
void PhysicsBody3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &PhysicsBody3D::set_collision_layer);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_layer"), &PhysicsBody3D::get_collision_layer);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &PhysicsBody3D::set_collision_mask);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsBody3D::get_collision_mask);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &PhysicsBody3D::set_collision_mask_bit);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &PhysicsBody3D::get_collision_mask_bit);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &PhysicsBody3D::set_collision_layer_bit);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &PhysicsBody3D::get_collision_layer_bit);
|
||||
|
||||
ADD_GROUP("Collision", "collision_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_layer", "get_collision_layer");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
|
||||
}
|
||||
void PhysicsBody3D::_bind_methods() {}
|
||||
|
||||
PhysicsBody3D::PhysicsBody3D(PhysicsServer3D::BodyMode p_mode) :
|
||||
CollisionObject3D(PhysicsServer3D::get_singleton()->body_create(), false) {
|
||||
PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), p_mode);
|
||||
collision_layer = 1;
|
||||
collision_mask = 1;
|
||||
}
|
||||
|
||||
void StaticBody3D::set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override) {
|
||||
|
@ -40,9 +40,6 @@
|
||||
class PhysicsBody3D : public CollisionObject3D {
|
||||
GDCLASS(PhysicsBody3D, CollisionObject3D);
|
||||
|
||||
uint32_t collision_layer;
|
||||
uint32_t collision_mask;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
PhysicsBody3D(PhysicsServer3D::BodyMode p_mode);
|
||||
@ -52,18 +49,6 @@ public:
|
||||
virtual Vector3 get_angular_velocity() const;
|
||||
virtual real_t get_inverse_mass() const;
|
||||
|
||||
void set_collision_layer(uint32_t p_layer);
|
||||
uint32_t get_collision_layer() const;
|
||||
|
||||
void set_collision_mask(uint32_t p_mask);
|
||||
uint32_t get_collision_mask() const;
|
||||
|
||||
void set_collision_layer_bit(int p_bit, bool p_value);
|
||||
bool get_collision_layer_bit(int p_bit) const;
|
||||
|
||||
void set_collision_mask_bit(int p_bit, bool p_value);
|
||||
bool get_collision_mask_bit(int p_bit) const;
|
||||
|
||||
TypedArray<PhysicsBody3D> get_collision_exceptions();
|
||||
void add_collision_exception_with(Node *p_node); //must be physicsbody
|
||||
void remove_collision_exception_with(Node *p_node);
|
||||
|
Loading…
Reference in New Issue
Block a user