You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Replace Array return types with TypedArray 2
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/string/print_string.h"
|
||||
#include "core/variant/typed_array.h"
|
||||
|
||||
void PhysicsServer3DRenderingServerHandler::set_vertex(int p_vertex_id, const void *p_vector3) {
|
||||
GDVIRTUAL_REQUIRED_CALL(_set_vertex, p_vertex_id, p_vector3);
|
||||
@@ -366,8 +367,8 @@ Dictionary PhysicsDirectSpaceState3D::_intersect_ray(const Ref<PhysicsRayQueryPa
|
||||
return d;
|
||||
}
|
||||
|
||||
Array PhysicsDirectSpaceState3D::_intersect_point(const Ref<PhysicsPointQueryParameters3D> &p_point_query, int p_max_results) {
|
||||
ERR_FAIL_COND_V(p_point_query.is_null(), Array());
|
||||
TypedArray<Dictionary> PhysicsDirectSpaceState3D::_intersect_point(const Ref<PhysicsPointQueryParameters3D> &p_point_query, int p_max_results) {
|
||||
ERR_FAIL_COND_V(p_point_query.is_null(), TypedArray<Dictionary>());
|
||||
|
||||
Vector<ShapeResult> ret;
|
||||
ret.resize(p_max_results);
|
||||
@@ -375,10 +376,10 @@ Array PhysicsDirectSpaceState3D::_intersect_point(const Ref<PhysicsPointQueryPar
|
||||
int rc = intersect_point(p_point_query->get_parameters(), ret.ptrw(), ret.size());
|
||||
|
||||
if (rc == 0) {
|
||||
return Array();
|
||||
return TypedArray<Dictionary>();
|
||||
}
|
||||
|
||||
Array r;
|
||||
TypedArray<Dictionary> r;
|
||||
r.resize(rc);
|
||||
for (int i = 0; i < rc; i++) {
|
||||
Dictionary d;
|
||||
@@ -391,13 +392,13 @@ Array PhysicsDirectSpaceState3D::_intersect_point(const Ref<PhysicsPointQueryPar
|
||||
return r;
|
||||
}
|
||||
|
||||
Array PhysicsDirectSpaceState3D::_intersect_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results) {
|
||||
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array());
|
||||
TypedArray<Dictionary> PhysicsDirectSpaceState3D::_intersect_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results) {
|
||||
ERR_FAIL_COND_V(!p_shape_query.is_valid(), TypedArray<Dictionary>());
|
||||
|
||||
Vector<ShapeResult> sr;
|
||||
sr.resize(p_max_results);
|
||||
int rc = intersect_shape(p_shape_query->get_parameters(), sr.ptrw(), sr.size());
|
||||
Array ret;
|
||||
TypedArray<Dictionary> ret;
|
||||
ret.resize(rc);
|
||||
for (int i = 0; i < rc; i++) {
|
||||
Dictionary d;
|
||||
@@ -411,22 +412,22 @@ Array PhysicsDirectSpaceState3D::_intersect_shape(const Ref<PhysicsShapeQueryPar
|
||||
return ret;
|
||||
}
|
||||
|
||||
Array PhysicsDirectSpaceState3D::_cast_motion(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query) {
|
||||
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array());
|
||||
Vector<real_t> PhysicsDirectSpaceState3D::_cast_motion(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query) {
|
||||
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Vector<real_t>());
|
||||
|
||||
real_t closest_safe = 1.0f, closest_unsafe = 1.0f;
|
||||
bool res = cast_motion(p_shape_query->get_parameters(), closest_safe, closest_unsafe);
|
||||
if (!res) {
|
||||
return Array();
|
||||
return Vector<real_t>();
|
||||
}
|
||||
Array ret;
|
||||
Vector<real_t> ret;
|
||||
ret.resize(2);
|
||||
ret[0] = closest_safe;
|
||||
ret[1] = closest_unsafe;
|
||||
ret.write[0] = closest_safe;
|
||||
ret.write[1] = closest_unsafe;
|
||||
return ret;
|
||||
}
|
||||
|
||||
Array PhysicsDirectSpaceState3D::_collide_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results) {
|
||||
TypedArray<PackedVector2Array> PhysicsDirectSpaceState3D::_collide_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results) {
|
||||
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array());
|
||||
|
||||
Vector<Vector3> ret;
|
||||
@@ -434,9 +435,9 @@ Array PhysicsDirectSpaceState3D::_collide_shape(const Ref<PhysicsShapeQueryParam
|
||||
int rc = 0;
|
||||
bool res = collide_shape(p_shape_query->get_parameters(), ret.ptrw(), p_max_results, rc);
|
||||
if (!res) {
|
||||
return Array();
|
||||
return TypedArray<PackedVector2Array>();
|
||||
}
|
||||
Array r;
|
||||
TypedArray<PackedVector2Array> r;
|
||||
r.resize(rc * 2);
|
||||
for (int i = 0; i < rc * 2; i++) {
|
||||
r[i] = ret[i];
|
||||
|
||||
Reference in New Issue
Block a user