Expose `ShapeCast{2D,3D}::get_collision_result`
This commit is contained in:
parent
ee363af0ed
commit
e47ff98451
|
@ -139,7 +139,7 @@
|
||||||
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
|
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
|
||||||
The shape's collision mask. Only objects in at least one collision layer enabled in the mask will be detected.
|
The shape's collision mask. Only objects in at least one collision layer enabled in the mask will be detected.
|
||||||
</member>
|
</member>
|
||||||
<member name="collision_result" type="Array" setter="" getter="_get_collision_result" default="[]">
|
<member name="collision_result" type="Array" setter="" getter="get_collision_result" default="[]">
|
||||||
Returns the complete collision information from the collision sweep. The data returned is the same as in the [method PhysicsDirectSpaceState2D.get_rest_info] method.
|
Returns the complete collision information from the collision sweep. The data returned is the same as in the [method PhysicsDirectSpaceState2D.get_rest_info] method.
|
||||||
</member>
|
</member>
|
||||||
<member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" default="true">
|
<member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" default="true">
|
||||||
|
|
|
@ -146,7 +146,7 @@
|
||||||
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
|
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
|
||||||
The shape's collision mask. Only objects in at least one collision layer enabled in the mask will be 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.
|
The shape's collision mask. Only objects in at least one collision layer enabled in the mask will be 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>
|
||||||
<member name="collision_result" type="Array" setter="" getter="_get_collision_result" default="[]">
|
<member name="collision_result" type="Array" setter="" getter="get_collision_result" default="[]">
|
||||||
Returns the complete collision information from the collision sweep. The data returned is the same as in the [method PhysicsDirectSpaceState3D.get_rest_info] method.
|
Returns the complete collision information from the collision sweep. The data returned is the same as in the [method PhysicsDirectSpaceState3D.get_rest_info] method.
|
||||||
</member>
|
</member>
|
||||||
<member name="debug_shape_custom_color" type="Color" setter="set_debug_shape_custom_color" getter="get_debug_shape_custom_color" default="Color(0, 0, 0, 1)">
|
<member name="debug_shape_custom_color" type="Color" setter="set_debug_shape_custom_color" getter="get_debug_shape_custom_color" default="Color(0, 0, 0, 1)">
|
||||||
|
|
|
@ -7,3 +7,10 @@ should instead be used to justify these changes and describe how users should wo
|
||||||
Add new entries at the end of the file.
|
Add new entries at the end of the file.
|
||||||
|
|
||||||
## Changes between 4.3-stable and 4.4-stable
|
## Changes between 4.3-stable and 4.4-stable
|
||||||
|
|
||||||
|
GH-95374
|
||||||
|
--------
|
||||||
|
Validate extension JSON: Error: Field 'classes/ShapeCast2D/properties/collision_result': getter changed value in new API, from "_get_collision_result" to &"get_collision_result".
|
||||||
|
Validate extension JSON: Error: Field 'classes/ShapeCast3D/properties/collision_result': getter changed value in new API, from "_get_collision_result" to &"get_collision_result".
|
||||||
|
|
||||||
|
These getters have been renamed to expose them. GDExtension language bindings couldn't have exposed these properties before.
|
||||||
|
|
|
@ -382,7 +382,7 @@ bool ShapeCast2D::is_collide_with_bodies_enabled() const {
|
||||||
return collide_with_bodies;
|
return collide_with_bodies;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array ShapeCast2D::_get_collision_result() const {
|
Array ShapeCast2D::get_collision_result() const {
|
||||||
Array ret;
|
Array ret;
|
||||||
|
|
||||||
for (int i = 0; i < result.size(); ++i) {
|
for (int i = 0; i < result.size(); ++i) {
|
||||||
|
@ -464,7 +464,7 @@ void ShapeCast2D::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &ShapeCast2D::set_collide_with_bodies);
|
ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &ShapeCast2D::set_collide_with_bodies);
|
||||||
ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &ShapeCast2D::is_collide_with_bodies_enabled);
|
ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &ShapeCast2D::is_collide_with_bodies_enabled);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_get_collision_result"), &ShapeCast2D::_get_collision_result);
|
ClassDB::bind_method(D_METHOD("get_collision_result"), &ShapeCast2D::get_collision_result);
|
||||||
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape2D"), "set_shape", "get_shape");
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape2D"), "set_shape", "get_shape");
|
||||||
|
@ -473,7 +473,7 @@ void ShapeCast2D::_bind_methods() {
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "margin", PROPERTY_HINT_RANGE, "0,100,0.01,suffix:px"), "set_margin", "get_margin");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "margin", PROPERTY_HINT_RANGE, "0,100,0.01,suffix:px"), "set_margin", "get_margin");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_results"), "set_max_results", "get_max_results");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_results"), "set_max_results", "get_max_results");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_collision_mask", "get_collision_mask");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_collision_mask", "get_collision_mask");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "collision_result", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "", "_get_collision_result");
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "collision_result", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "", "get_collision_result");
|
||||||
ADD_GROUP("Collide With", "collide_with");
|
ADD_GROUP("Collide With", "collide_with");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collide_with_areas", "is_collide_with_areas_enabled");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collide_with_areas", "is_collide_with_areas_enabled");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_bodies", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collide_with_bodies", "is_collide_with_bodies_enabled");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_bodies", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collide_with_bodies", "is_collide_with_bodies_enabled");
|
||||||
|
|
|
@ -60,7 +60,6 @@ class ShapeCast2D : public Node2D {
|
||||||
real_t collision_safe_fraction = 1.0;
|
real_t collision_safe_fraction = 1.0;
|
||||||
real_t collision_unsafe_fraction = 1.0;
|
real_t collision_unsafe_fraction = 1.0;
|
||||||
|
|
||||||
Array _get_collision_result() const;
|
|
||||||
void _shape_changed();
|
void _shape_changed();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -102,6 +101,7 @@ public:
|
||||||
void force_shapecast_update();
|
void force_shapecast_update();
|
||||||
bool is_colliding() const;
|
bool is_colliding() const;
|
||||||
|
|
||||||
|
Array get_collision_result() const;
|
||||||
int get_collision_count() const;
|
int get_collision_count() const;
|
||||||
Object *get_collider(int p_idx) const;
|
Object *get_collider(int p_idx) const;
|
||||||
RID get_collider_rid(int p_idx) const;
|
RID get_collider_rid(int p_idx) const;
|
||||||
|
|
|
@ -157,7 +157,7 @@ void ShapeCast3D::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &ShapeCast3D::set_collide_with_bodies);
|
ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &ShapeCast3D::set_collide_with_bodies);
|
||||||
ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &ShapeCast3D::is_collide_with_bodies_enabled);
|
ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &ShapeCast3D::is_collide_with_bodies_enabled);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_get_collision_result"), &ShapeCast3D::_get_collision_result);
|
ClassDB::bind_method(D_METHOD("get_collision_result"), &ShapeCast3D::get_collision_result);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_debug_shape_custom_color", "debug_shape_custom_color"), &ShapeCast3D::set_debug_shape_custom_color);
|
ClassDB::bind_method(D_METHOD("set_debug_shape_custom_color", "debug_shape_custom_color"), &ShapeCast3D::set_debug_shape_custom_color);
|
||||||
ClassDB::bind_method(D_METHOD("get_debug_shape_custom_color"), &ShapeCast3D::get_debug_shape_custom_color);
|
ClassDB::bind_method(D_METHOD("get_debug_shape_custom_color"), &ShapeCast3D::get_debug_shape_custom_color);
|
||||||
|
@ -169,7 +169,7 @@ void ShapeCast3D::_bind_methods() {
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "margin", PROPERTY_HINT_RANGE, "0,100,0.01,suffix:m"), "set_margin", "get_margin");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "margin", PROPERTY_HINT_RANGE, "0,100,0.01,suffix:m"), "set_margin", "get_margin");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_results"), "set_max_results", "get_max_results");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_results"), "set_max_results", "get_max_results");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "collision_result", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "", "_get_collision_result");
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "collision_result", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "", "get_collision_result");
|
||||||
|
|
||||||
ADD_GROUP("Collide With", "collide_with");
|
ADD_GROUP("Collide With", "collide_with");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collide_with_areas", "is_collide_with_areas_enabled");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collide_with_areas", "is_collide_with_areas_enabled");
|
||||||
|
@ -475,7 +475,7 @@ bool ShapeCast3D::is_collide_with_bodies_enabled() const {
|
||||||
return collide_with_bodies;
|
return collide_with_bodies;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array ShapeCast3D::_get_collision_result() const {
|
Array ShapeCast3D::get_collision_result() const {
|
||||||
Array ret;
|
Array ret;
|
||||||
|
|
||||||
for (int i = 0; i < result.size(); ++i) {
|
for (int i = 0; i < result.size(); ++i) {
|
||||||
|
|
|
@ -73,8 +73,6 @@ class ShapeCast3D : public Node3D {
|
||||||
real_t collision_safe_fraction = 1.0;
|
real_t collision_safe_fraction = 1.0;
|
||||||
real_t collision_unsafe_fraction = 1.0;
|
real_t collision_unsafe_fraction = 1.0;
|
||||||
|
|
||||||
Array _get_collision_result() const;
|
|
||||||
|
|
||||||
RID debug_instance;
|
RID debug_instance;
|
||||||
Ref<ArrayMesh> debug_mesh;
|
Ref<ArrayMesh> debug_mesh;
|
||||||
|
|
||||||
|
@ -123,6 +121,7 @@ public:
|
||||||
|
|
||||||
Ref<StandardMaterial3D> get_debug_material();
|
Ref<StandardMaterial3D> get_debug_material();
|
||||||
|
|
||||||
|
Array get_collision_result() const;
|
||||||
int get_collision_count() const;
|
int get_collision_count() const;
|
||||||
Object *get_collider(int p_idx) const;
|
Object *get_collider(int p_idx) const;
|
||||||
RID get_collider_rid(int p_idx) const;
|
RID get_collider_rid(int p_idx) const;
|
||||||
|
|
Loading…
Reference in New Issue