mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Merge pull request #113282 from dsnopek/required-ptr-get-out-there
Use `RequiredParam`/`RequiredResult` in some high value places
This commit is contained in:
commit
9f76aa3df5
79 changed files with 372 additions and 321 deletions
|
|
@ -336,8 +336,8 @@ void PhysicsShapeQueryParameters2D::_bind_methods() {
|
|||
|
||||
///////////////////////////////////////////////////////
|
||||
|
||||
Dictionary PhysicsDirectSpaceState2D::_intersect_ray(const Ref<PhysicsRayQueryParameters2D> &p_ray_query) {
|
||||
ERR_FAIL_COND_V(p_ray_query.is_null(), Dictionary());
|
||||
Dictionary PhysicsDirectSpaceState2D::_intersect_ray(RequiredParam<PhysicsRayQueryParameters2D> rp_ray_query) {
|
||||
EXTRACT_PARAM_OR_FAIL_V(p_ray_query, rp_ray_query, Dictionary());
|
||||
|
||||
RayResult result;
|
||||
bool res = intersect_ray(p_ray_query->get_parameters(), result);
|
||||
|
|
@ -357,8 +357,8 @@ Dictionary PhysicsDirectSpaceState2D::_intersect_ray(const Ref<PhysicsRayQueryPa
|
|||
return d;
|
||||
}
|
||||
|
||||
TypedArray<Dictionary> PhysicsDirectSpaceState2D::_intersect_point(const Ref<PhysicsPointQueryParameters2D> &p_point_query, int p_max_results) {
|
||||
ERR_FAIL_COND_V(p_point_query.is_null(), Array());
|
||||
TypedArray<Dictionary> PhysicsDirectSpaceState2D::_intersect_point(RequiredParam<PhysicsPointQueryParameters2D> rp_point_query, int p_max_results) {
|
||||
EXTRACT_PARAM_OR_FAIL_V(p_point_query, rp_point_query, TypedArray<Dictionary>());
|
||||
|
||||
Vector<ShapeResult> ret;
|
||||
ret.resize(p_max_results);
|
||||
|
|
@ -382,8 +382,8 @@ TypedArray<Dictionary> PhysicsDirectSpaceState2D::_intersect_point(const Ref<Phy
|
|||
return r;
|
||||
}
|
||||
|
||||
TypedArray<Dictionary> PhysicsDirectSpaceState2D::_intersect_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results) {
|
||||
ERR_FAIL_COND_V(p_shape_query.is_null(), TypedArray<Dictionary>());
|
||||
TypedArray<Dictionary> PhysicsDirectSpaceState2D::_intersect_shape(RequiredParam<PhysicsShapeQueryParameters2D> rp_shape_query, int p_max_results) {
|
||||
EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, TypedArray<Dictionary>());
|
||||
|
||||
Vector<ShapeResult> sr;
|
||||
sr.resize(p_max_results);
|
||||
|
|
@ -402,8 +402,8 @@ TypedArray<Dictionary> PhysicsDirectSpaceState2D::_intersect_shape(const Ref<Phy
|
|||
return ret;
|
||||
}
|
||||
|
||||
Vector<real_t> PhysicsDirectSpaceState2D::_cast_motion(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query) {
|
||||
ERR_FAIL_COND_V(p_shape_query.is_null(), Vector<real_t>());
|
||||
Vector<real_t> PhysicsDirectSpaceState2D::_cast_motion(RequiredParam<PhysicsShapeQueryParameters2D> rp_shape_query) {
|
||||
EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, Vector<real_t>());
|
||||
|
||||
real_t closest_safe, closest_unsafe;
|
||||
bool res = cast_motion(p_shape_query->get_parameters(), closest_safe, closest_unsafe);
|
||||
|
|
@ -417,8 +417,8 @@ Vector<real_t> PhysicsDirectSpaceState2D::_cast_motion(const Ref<PhysicsShapeQue
|
|||
return ret;
|
||||
}
|
||||
|
||||
TypedArray<Vector2> PhysicsDirectSpaceState2D::_collide_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results) {
|
||||
ERR_FAIL_COND_V(p_shape_query.is_null(), TypedArray<Vector2>());
|
||||
TypedArray<Vector2> PhysicsDirectSpaceState2D::_collide_shape(RequiredParam<PhysicsShapeQueryParameters2D> rp_shape_query, int p_max_results) {
|
||||
EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, TypedArray<Vector2>());
|
||||
|
||||
Vector<Vector2> ret;
|
||||
ret.resize(p_max_results * 2);
|
||||
|
|
@ -435,8 +435,8 @@ TypedArray<Vector2> PhysicsDirectSpaceState2D::_collide_shape(const Ref<PhysicsS
|
|||
return r;
|
||||
}
|
||||
|
||||
Dictionary PhysicsDirectSpaceState2D::_get_rest_info(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query) {
|
||||
ERR_FAIL_COND_V(p_shape_query.is_null(), Dictionary());
|
||||
Dictionary PhysicsDirectSpaceState2D::_get_rest_info(RequiredParam<PhysicsShapeQueryParameters2D> rp_shape_query) {
|
||||
EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, Dictionary());
|
||||
|
||||
ShapeRestInfo sri;
|
||||
|
||||
|
|
@ -613,8 +613,8 @@ void PhysicsTestMotionResult2D::_bind_methods() {
|
|||
|
||||
///////////////////////////////////////
|
||||
|
||||
bool PhysicsServer2D::_body_test_motion(RID p_body, const Ref<PhysicsTestMotionParameters2D> &p_parameters, const Ref<PhysicsTestMotionResult2D> &p_result) {
|
||||
ERR_FAIL_COND_V(p_parameters.is_null(), false);
|
||||
bool PhysicsServer2D::_body_test_motion(RID p_body, RequiredParam<PhysicsTestMotionParameters2D> rp_parameters, const Ref<PhysicsTestMotionResult2D> &p_result) {
|
||||
EXTRACT_PARAM_OR_FAIL_V(p_parameters, rp_parameters, false);
|
||||
|
||||
MotionResult *result_ptr = nullptr;
|
||||
if (p_result.is_valid()) {
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ public:
|
|||
virtual real_t get_step() const = 0;
|
||||
virtual void integrate_forces();
|
||||
|
||||
virtual PhysicsDirectSpaceState2D *get_space_state() = 0;
|
||||
virtual RequiredResult<PhysicsDirectSpaceState2D> get_space_state() = 0;
|
||||
|
||||
PhysicsDirectBodyState2D();
|
||||
};
|
||||
|
|
@ -124,12 +124,12 @@ class PhysicsShapeQueryParameters2D;
|
|||
class PhysicsDirectSpaceState2D : public Object {
|
||||
GDCLASS(PhysicsDirectSpaceState2D, Object);
|
||||
|
||||
Dictionary _intersect_ray(const Ref<PhysicsRayQueryParameters2D> &p_ray_query);
|
||||
TypedArray<Dictionary> _intersect_point(const Ref<PhysicsPointQueryParameters2D> &p_point_query, int p_max_results = 32);
|
||||
TypedArray<Dictionary> _intersect_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results = 32);
|
||||
Vector<real_t> _cast_motion(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query);
|
||||
TypedArray<Vector2> _collide_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results = 32);
|
||||
Dictionary _get_rest_info(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query);
|
||||
Dictionary _intersect_ray(RequiredParam<PhysicsRayQueryParameters2D> p_ray_query);
|
||||
TypedArray<Dictionary> _intersect_point(RequiredParam<PhysicsPointQueryParameters2D> p_point_query, int p_max_results = 32);
|
||||
TypedArray<Dictionary> _intersect_shape(RequiredParam<PhysicsShapeQueryParameters2D> p_shape_query, int p_max_results = 32);
|
||||
Vector<real_t> _cast_motion(RequiredParam<PhysicsShapeQueryParameters2D> p_shape_query);
|
||||
TypedArray<Vector2> _collide_shape(RequiredParam<PhysicsShapeQueryParameters2D> p_shape_query, int p_max_results = 32);
|
||||
Dictionary _get_rest_info(RequiredParam<PhysicsShapeQueryParameters2D> p_shape_query);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
|
@ -216,7 +216,7 @@ class PhysicsServer2D : public Object {
|
|||
|
||||
static PhysicsServer2D *singleton;
|
||||
|
||||
virtual bool _body_test_motion(RID p_body, const Ref<PhysicsTestMotionParameters2D> &p_parameters, const Ref<PhysicsTestMotionResult2D> &p_result = Ref<PhysicsTestMotionResult2D>());
|
||||
virtual bool _body_test_motion(RID p_body, RequiredParam<PhysicsTestMotionParameters2D> p_parameters, const Ref<PhysicsTestMotionResult2D> &p_result = Ref<PhysicsTestMotionResult2D>());
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public:
|
|||
virtual real_t get_step() const override { return 0; }
|
||||
virtual void integrate_forces() override {}
|
||||
|
||||
virtual PhysicsDirectSpaceState2D *get_space_state() override { return space_state_dummy; }
|
||||
virtual RequiredResult<PhysicsDirectSpaceState2D> get_space_state() override { return space_state_dummy; }
|
||||
|
||||
PhysicsDirectBodyState2DDummy(PhysicsDirectSpaceState2D *p_space_state_dummy) {
|
||||
space_state_dummy = p_space_state_dummy;
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ public:
|
|||
EXBIND0RC(real_t, get_step)
|
||||
EXBIND0(integrate_forces)
|
||||
|
||||
EXBIND0R(PhysicsDirectSpaceState2D *, get_space_state)
|
||||
EXBIND0R(RequiredResult<PhysicsDirectSpaceState2D>, get_space_state)
|
||||
|
||||
PhysicsDirectBodyState2DExtension();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -360,8 +360,8 @@ void PhysicsShapeQueryParameters3D::_bind_methods() {
|
|||
|
||||
/////////////////////////////////////
|
||||
|
||||
Dictionary PhysicsDirectSpaceState3D::_intersect_ray(const Ref<PhysicsRayQueryParameters3D> &p_ray_query) {
|
||||
ERR_FAIL_COND_V(p_ray_query.is_null(), Dictionary());
|
||||
Dictionary PhysicsDirectSpaceState3D::_intersect_ray(RequiredParam<PhysicsRayQueryParameters3D> rp_ray_query) {
|
||||
EXTRACT_PARAM_OR_FAIL_V(p_ray_query, rp_ray_query, Dictionary());
|
||||
|
||||
RayResult result;
|
||||
bool res = intersect_ray(p_ray_query->get_parameters(), result);
|
||||
|
|
@ -382,8 +382,8 @@ Dictionary PhysicsDirectSpaceState3D::_intersect_ray(const Ref<PhysicsRayQueryPa
|
|||
return d;
|
||||
}
|
||||
|
||||
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>());
|
||||
TypedArray<Dictionary> PhysicsDirectSpaceState3D::_intersect_point(RequiredParam<PhysicsPointQueryParameters3D> rp_point_query, int p_max_results) {
|
||||
EXTRACT_PARAM_OR_FAIL_V(p_point_query, rp_point_query, TypedArray<Dictionary>());
|
||||
|
||||
Vector<ShapeResult> ret;
|
||||
ret.resize(p_max_results);
|
||||
|
|
@ -407,8 +407,8 @@ TypedArray<Dictionary> PhysicsDirectSpaceState3D::_intersect_point(const Ref<Phy
|
|||
return r;
|
||||
}
|
||||
|
||||
TypedArray<Dictionary> PhysicsDirectSpaceState3D::_intersect_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results) {
|
||||
ERR_FAIL_COND_V(p_shape_query.is_null(), TypedArray<Dictionary>());
|
||||
TypedArray<Dictionary> PhysicsDirectSpaceState3D::_intersect_shape(RequiredParam<PhysicsShapeQueryParameters3D> rp_shape_query, int p_max_results) {
|
||||
EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, TypedArray<Dictionary>());
|
||||
|
||||
Vector<ShapeResult> sr;
|
||||
sr.resize(p_max_results);
|
||||
|
|
@ -427,8 +427,8 @@ TypedArray<Dictionary> PhysicsDirectSpaceState3D::_intersect_shape(const Ref<Phy
|
|||
return ret;
|
||||
}
|
||||
|
||||
Vector<real_t> PhysicsDirectSpaceState3D::_cast_motion(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query) {
|
||||
ERR_FAIL_COND_V(p_shape_query.is_null(), Vector<real_t>());
|
||||
Vector<real_t> PhysicsDirectSpaceState3D::_cast_motion(RequiredParam<PhysicsShapeQueryParameters3D> rp_shape_query) {
|
||||
EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, 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);
|
||||
|
|
@ -442,8 +442,8 @@ Vector<real_t> PhysicsDirectSpaceState3D::_cast_motion(const Ref<PhysicsShapeQue
|
|||
return ret;
|
||||
}
|
||||
|
||||
TypedArray<Vector3> PhysicsDirectSpaceState3D::_collide_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results) {
|
||||
ERR_FAIL_COND_V(p_shape_query.is_null(), TypedArray<Vector3>());
|
||||
TypedArray<Vector3> PhysicsDirectSpaceState3D::_collide_shape(RequiredParam<PhysicsShapeQueryParameters3D> rp_shape_query, int p_max_results) {
|
||||
EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, TypedArray<Vector3>());
|
||||
|
||||
Vector<Vector3> ret;
|
||||
ret.resize(p_max_results * 2);
|
||||
|
|
@ -460,8 +460,8 @@ TypedArray<Vector3> PhysicsDirectSpaceState3D::_collide_shape(const Ref<PhysicsS
|
|||
return r;
|
||||
}
|
||||
|
||||
Dictionary PhysicsDirectSpaceState3D::_get_rest_info(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query) {
|
||||
ERR_FAIL_COND_V(p_shape_query.is_null(), Dictionary());
|
||||
Dictionary PhysicsDirectSpaceState3D::_get_rest_info(RequiredParam<PhysicsShapeQueryParameters3D> rp_shape_query) {
|
||||
EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, Dictionary());
|
||||
|
||||
ShapeRestInfo sri;
|
||||
|
||||
|
|
@ -656,8 +656,8 @@ void PhysicsTestMotionResult3D::_bind_methods() {
|
|||
|
||||
///////////////////////////////////////
|
||||
|
||||
bool PhysicsServer3D::_body_test_motion(RID p_body, const Ref<PhysicsTestMotionParameters3D> &p_parameters, const Ref<PhysicsTestMotionResult3D> &p_result) {
|
||||
ERR_FAIL_COND_V(p_parameters.is_null(), false);
|
||||
bool PhysicsServer3D::_body_test_motion(RID p_body, RequiredParam<PhysicsTestMotionParameters3D> rp_parameters, const Ref<PhysicsTestMotionResult3D> &p_result) {
|
||||
EXTRACT_PARAM_OR_FAIL_V(p_parameters, rp_parameters, false);
|
||||
|
||||
MotionResult *result_ptr = nullptr;
|
||||
if (p_result.is_valid()) {
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ public:
|
|||
virtual real_t get_step() const = 0;
|
||||
virtual void integrate_forces();
|
||||
|
||||
virtual PhysicsDirectSpaceState3D *get_space_state() = 0;
|
||||
virtual RequiredResult<PhysicsDirectSpaceState3D> get_space_state() = 0;
|
||||
|
||||
PhysicsDirectBodyState3D();
|
||||
};
|
||||
|
|
@ -126,12 +126,12 @@ class PhysicsDirectSpaceState3D : public Object {
|
|||
GDCLASS(PhysicsDirectSpaceState3D, Object);
|
||||
|
||||
private:
|
||||
Dictionary _intersect_ray(const Ref<PhysicsRayQueryParameters3D> &p_ray_query);
|
||||
TypedArray<Dictionary> _intersect_point(const Ref<PhysicsPointQueryParameters3D> &p_point_query, int p_max_results = 32);
|
||||
TypedArray<Dictionary> _intersect_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results = 32);
|
||||
Vector<real_t> _cast_motion(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query);
|
||||
TypedArray<Vector3> _collide_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results = 32);
|
||||
Dictionary _get_rest_info(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query);
|
||||
Dictionary _intersect_ray(RequiredParam<PhysicsRayQueryParameters3D> p_ray_query);
|
||||
TypedArray<Dictionary> _intersect_point(RequiredParam<PhysicsPointQueryParameters3D> p_point_query, int p_max_results = 32);
|
||||
TypedArray<Dictionary> _intersect_shape(RequiredParam<PhysicsShapeQueryParameters3D> p_shape_query, int p_max_results = 32);
|
||||
Vector<real_t> _cast_motion(RequiredParam<PhysicsShapeQueryParameters3D> p_shape_query);
|
||||
TypedArray<Vector3> _collide_shape(RequiredParam<PhysicsShapeQueryParameters3D> p_shape_query, int p_max_results = 32);
|
||||
Dictionary _get_rest_info(RequiredParam<PhysicsShapeQueryParameters3D> p_shape_query);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
|
@ -238,7 +238,7 @@ class PhysicsServer3D : public Object {
|
|||
|
||||
static PhysicsServer3D *singleton;
|
||||
|
||||
virtual bool _body_test_motion(RID p_body, const Ref<PhysicsTestMotionParameters3D> &p_parameters, const Ref<PhysicsTestMotionResult3D> &p_result = Ref<PhysicsTestMotionResult3D>());
|
||||
virtual bool _body_test_motion(RID p_body, RequiredParam<PhysicsTestMotionParameters3D> p_parameters, const Ref<PhysicsTestMotionResult3D> &p_result = Ref<PhysicsTestMotionResult3D>());
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
|
@ -576,7 +576,7 @@ public:
|
|||
|
||||
virtual RID soft_body_create() = 0;
|
||||
|
||||
virtual void soft_body_update_rendering_server(RID p_body, PhysicsServer3DRenderingServerHandler *p_rendering_server_handler) = 0;
|
||||
virtual void soft_body_update_rendering_server(RID p_body, RequiredParam<PhysicsServer3DRenderingServerHandler> p_rendering_server_handler) = 0;
|
||||
|
||||
virtual void soft_body_set_space(RID p_body, RID p_space) = 0;
|
||||
virtual RID soft_body_get_space(RID p_body) const = 0;
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ public:
|
|||
virtual real_t get_step() const override { return 0; }
|
||||
virtual void integrate_forces() override {}
|
||||
|
||||
virtual PhysicsDirectSpaceState3D *get_space_state() override { return space_state_dummy; }
|
||||
virtual RequiredResult<PhysicsDirectSpaceState3D> get_space_state() override { return space_state_dummy; }
|
||||
|
||||
PhysicsDirectBodyState3DDummy(PhysicsDirectSpaceState3D *p_space_state_dummy) {
|
||||
space_state_dummy = p_space_state_dummy;
|
||||
|
|
@ -312,7 +312,7 @@ public:
|
|||
|
||||
virtual RID soft_body_create() override { return RID(); }
|
||||
|
||||
virtual void soft_body_update_rendering_server(RID p_body, PhysicsServer3DRenderingServerHandler *p_rendering_server_handler) override {}
|
||||
virtual void soft_body_update_rendering_server(RID p_body, RequiredParam<PhysicsServer3DRenderingServerHandler> p_rendering_server_handler) override {}
|
||||
|
||||
virtual void soft_body_set_space(RID p_body, RID p_space) override {}
|
||||
virtual RID soft_body_get_space(RID p_body) const override { return RID(); }
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ public:
|
|||
EXBIND0RC(real_t, get_step)
|
||||
|
||||
EXBIND0(integrate_forces)
|
||||
EXBIND0R(PhysicsDirectSpaceState3D *, get_space_state)
|
||||
EXBIND0R(RequiredResult<PhysicsDirectSpaceState3D>, get_space_state)
|
||||
|
||||
PhysicsDirectBodyState3DExtension();
|
||||
};
|
||||
|
|
@ -411,7 +411,7 @@ public:
|
|||
|
||||
EXBIND0R(RID, soft_body_create)
|
||||
|
||||
EXBIND2(soft_body_update_rendering_server, RID, PhysicsServer3DRenderingServerHandler *)
|
||||
EXBIND2(soft_body_update_rendering_server, RID, RequiredParam<PhysicsServer3DRenderingServerHandler>)
|
||||
|
||||
EXBIND2(soft_body_set_space, RID, RID)
|
||||
EXBIND1RC(RID, soft_body_get_space, RID)
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ public:
|
|||
|
||||
FUNCRID(soft_body)
|
||||
|
||||
FUNC2(soft_body_update_rendering_server, RID, PhysicsServer3DRenderingServerHandler *)
|
||||
FUNC2(soft_body_update_rendering_server, RID, RequiredParam<PhysicsServer3DRenderingServerHandler>)
|
||||
|
||||
FUNC2(soft_body_set_space, RID, RID)
|
||||
FUNC1RC(RID, soft_body_get_space, RID)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue