mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03: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:
@@ -141,7 +141,7 @@ void Node2D::_update_transform() {
|
||||
_notify_transform();
|
||||
}
|
||||
|
||||
void Node2D::reparent(Node *p_parent, bool p_keep_global_transform) {
|
||||
void Node2D::reparent(RequiredParam<Node> p_parent, bool p_keep_global_transform) {
|
||||
ERR_THREAD_GUARD;
|
||||
if (p_keep_global_transform) {
|
||||
Transform2D temp = get_global_transform();
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
|
||||
virtual void _edit_set_rect(const Rect2 &p_edit_rect) override;
|
||||
#endif
|
||||
virtual void reparent(Node *p_parent, bool p_keep_global_transform = true) override;
|
||||
virtual void reparent(RequiredParam<Node> p_parent, bool p_keep_global_transform = true) override;
|
||||
|
||||
void set_position(const Point2 &p_pos);
|
||||
void set_rotation(real_t p_radians);
|
||||
|
||||
@@ -501,8 +501,8 @@ bool Area2D::has_overlapping_areas() const {
|
||||
return !area_map.is_empty();
|
||||
}
|
||||
|
||||
bool Area2D::overlaps_area(Node *p_area) const {
|
||||
ERR_FAIL_NULL_V(p_area, false);
|
||||
bool Area2D::overlaps_area(RequiredParam<Node> rp_area) const {
|
||||
EXTRACT_PARAM_OR_FAIL_V(p_area, rp_area, false);
|
||||
HashMap<ObjectID, AreaState>::ConstIterator E = area_map.find(p_area->get_instance_id());
|
||||
if (!E) {
|
||||
return false;
|
||||
@@ -510,8 +510,8 @@ bool Area2D::overlaps_area(Node *p_area) const {
|
||||
return E->value.in_tree;
|
||||
}
|
||||
|
||||
bool Area2D::overlaps_body(Node *p_body) const {
|
||||
ERR_FAIL_NULL_V(p_body, false);
|
||||
bool Area2D::overlaps_body(RequiredParam<Node> rp_body) const {
|
||||
EXTRACT_PARAM_OR_FAIL_V(p_body, rp_body, false);
|
||||
HashMap<ObjectID, BodyState>::ConstIterator E = body_map.find(p_body->get_instance_id());
|
||||
if (!E) {
|
||||
return false;
|
||||
|
||||
@@ -185,8 +185,8 @@ public:
|
||||
bool has_overlapping_bodies() const;
|
||||
bool has_overlapping_areas() const;
|
||||
|
||||
bool overlaps_area(Node *p_area) const;
|
||||
bool overlaps_body(Node *p_body) const;
|
||||
bool overlaps_area(RequiredParam<Node> p_area) const;
|
||||
bool overlaps_body(RequiredParam<Node> p_body) const;
|
||||
|
||||
void set_audio_bus_override(bool p_override);
|
||||
bool is_overriding_audio_bus() const;
|
||||
|
||||
@@ -418,9 +418,9 @@ Object *CollisionObject2D::shape_owner_get_owner(uint32_t p_owner) const {
|
||||
return ObjectDB::get_instance(shapes[p_owner].owner_id);
|
||||
}
|
||||
|
||||
void CollisionObject2D::shape_owner_add_shape(uint32_t p_owner, const Ref<Shape2D> &p_shape) {
|
||||
void CollisionObject2D::shape_owner_add_shape(uint32_t p_owner, RequiredParam<Shape2D> rp_shape) {
|
||||
ERR_FAIL_COND(!shapes.has(p_owner));
|
||||
ERR_FAIL_COND(p_shape.is_null());
|
||||
EXTRACT_PARAM_OR_FAIL(p_shape, rp_shape);
|
||||
|
||||
ShapeData &sd = shapes[p_owner];
|
||||
ShapeData::Shape s;
|
||||
|
||||
@@ -112,7 +112,7 @@ protected:
|
||||
|
||||
virtual void _space_changed(const RID &p_new_space);
|
||||
|
||||
GDVIRTUAL3(_input_event, Viewport *, Ref<InputEvent>, int)
|
||||
GDVIRTUAL3(_input_event, RequiredParam<Viewport>, RequiredParam<InputEvent>, int)
|
||||
GDVIRTUAL0(_mouse_enter)
|
||||
GDVIRTUAL0(_mouse_exit)
|
||||
GDVIRTUAL1(_mouse_shape_enter, int)
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
void shape_owner_set_one_way_collision_margin(uint32_t p_owner, real_t p_margin);
|
||||
real_t get_shape_owner_one_way_collision_margin(uint32_t p_owner) const;
|
||||
|
||||
void shape_owner_add_shape(uint32_t p_owner, const Ref<Shape2D> &p_shape);
|
||||
void shape_owner_add_shape(uint32_t p_owner, RequiredParam<Shape2D> p_shape);
|
||||
int shape_owner_get_shape_count(uint32_t p_owner) const;
|
||||
Ref<Shape2D> shape_owner_get_shape(uint32_t p_owner, int p_shape) const;
|
||||
int shape_owner_get_shape_index(uint32_t p_owner, int p_shape) const;
|
||||
|
||||
@@ -156,15 +156,15 @@ TypedArray<PhysicsBody2D> PhysicsBody2D::get_collision_exceptions() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void PhysicsBody2D::add_collision_exception_with(Node *p_node) {
|
||||
ERR_FAIL_NULL(p_node);
|
||||
void PhysicsBody2D::add_collision_exception_with(RequiredParam<Node> rp_node) {
|
||||
EXTRACT_PARAM_OR_FAIL(p_node, rp_node);
|
||||
PhysicsBody2D *physics_body = Object::cast_to<PhysicsBody2D>(p_node);
|
||||
ERR_FAIL_NULL_MSG(physics_body, "Collision exception only works between two nodes that inherit from PhysicsBody2D.");
|
||||
PhysicsServer2D::get_singleton()->body_add_collision_exception(get_rid(), physics_body->get_rid());
|
||||
}
|
||||
|
||||
void PhysicsBody2D::remove_collision_exception_with(Node *p_node) {
|
||||
ERR_FAIL_NULL(p_node);
|
||||
void PhysicsBody2D::remove_collision_exception_with(RequiredParam<Node> rp_node) {
|
||||
EXTRACT_PARAM_OR_FAIL(p_node, rp_node);
|
||||
PhysicsBody2D *physics_body = Object::cast_to<PhysicsBody2D>(p_node);
|
||||
ERR_FAIL_NULL_MSG(physics_body, "Collision exception only works between two nodes that inherit from PhysicsBody2D.");
|
||||
PhysicsServer2D::get_singleton()->body_remove_collision_exception(get_rid(), physics_body->get_rid());
|
||||
|
||||
@@ -54,6 +54,6 @@ public:
|
||||
Vector2 get_gravity() 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);
|
||||
void add_collision_exception_with(RequiredParam<Node> p_node); //must be physicsbody
|
||||
void remove_collision_exception_with(RequiredParam<Node> p_node);
|
||||
};
|
||||
|
||||
@@ -267,8 +267,8 @@ void RayCast2D::add_exception_rid(const RID &p_rid) {
|
||||
exclude.insert(p_rid);
|
||||
}
|
||||
|
||||
void RayCast2D::add_exception(const CollisionObject2D *p_node) {
|
||||
ERR_FAIL_NULL_MSG(p_node, "The passed Node must be an instance of CollisionObject2D.");
|
||||
void RayCast2D::add_exception(RequiredParam<const CollisionObject2D> rp_node) {
|
||||
EXTRACT_PARAM_OR_FAIL_MSG(p_node, rp_node, "The passed Node must be an instance of CollisionObject2D.");
|
||||
add_exception_rid(p_node->get_rid());
|
||||
}
|
||||
|
||||
@@ -276,8 +276,8 @@ void RayCast2D::remove_exception_rid(const RID &p_rid) {
|
||||
exclude.erase(p_rid);
|
||||
}
|
||||
|
||||
void RayCast2D::remove_exception(const CollisionObject2D *p_node) {
|
||||
ERR_FAIL_NULL_MSG(p_node, "The passed Node must be an instance of CollisionObject2D.");
|
||||
void RayCast2D::remove_exception(RequiredParam<const CollisionObject2D> rp_node) {
|
||||
EXTRACT_PARAM_OR_FAIL_MSG(p_node, rp_node, "The passed Node must be an instance of CollisionObject2D.");
|
||||
remove_exception_rid(p_node->get_rid());
|
||||
}
|
||||
|
||||
|
||||
@@ -97,9 +97,9 @@ public:
|
||||
Vector2 get_collision_normal() const;
|
||||
|
||||
void add_exception_rid(const RID &p_rid);
|
||||
void add_exception(const CollisionObject2D *p_node);
|
||||
void add_exception(RequiredParam<const CollisionObject2D> p_node);
|
||||
void remove_exception_rid(const RID &p_rid);
|
||||
void remove_exception(const CollisionObject2D *p_node);
|
||||
void remove_exception(RequiredParam<const CollisionObject2D> p_node);
|
||||
void clear_exceptions();
|
||||
|
||||
RayCast2D();
|
||||
|
||||
@@ -141,7 +141,7 @@ protected:
|
||||
|
||||
void _validate_property(PropertyInfo &p_property) const;
|
||||
|
||||
GDVIRTUAL1(_integrate_forces, PhysicsDirectBodyState2D *)
|
||||
GDVIRTUAL1(_integrate_forces, RequiredParam<PhysicsDirectBodyState2D>)
|
||||
|
||||
void _apply_body_mode();
|
||||
|
||||
|
||||
@@ -347,8 +347,8 @@ void ShapeCast2D::add_exception_rid(const RID &p_rid) {
|
||||
exclude.insert(p_rid);
|
||||
}
|
||||
|
||||
void ShapeCast2D::add_exception(const CollisionObject2D *p_node) {
|
||||
ERR_FAIL_NULL_MSG(p_node, "The passed Node must be an instance of CollisionObject2D.");
|
||||
void ShapeCast2D::add_exception(RequiredParam<const CollisionObject2D> rp_node) {
|
||||
EXTRACT_PARAM_OR_FAIL_MSG(p_node, rp_node, "The passed Node must be an instance of CollisionObject2D.");
|
||||
add_exception_rid(p_node->get_rid());
|
||||
}
|
||||
|
||||
@@ -356,8 +356,8 @@ void ShapeCast2D::remove_exception_rid(const RID &p_rid) {
|
||||
exclude.erase(p_rid);
|
||||
}
|
||||
|
||||
void ShapeCast2D::remove_exception(const CollisionObject2D *p_node) {
|
||||
ERR_FAIL_NULL_MSG(p_node, "The passed Node must be an instance of CollisionObject2D.");
|
||||
void ShapeCast2D::remove_exception(RequiredParam<const CollisionObject2D> rp_node) {
|
||||
EXTRACT_PARAM_OR_FAIL_MSG(p_node, rp_node, "The passed Node must be an instance of CollisionObject2D.");
|
||||
remove_exception_rid(p_node->get_rid());
|
||||
}
|
||||
|
||||
|
||||
@@ -112,9 +112,9 @@ public:
|
||||
real_t get_closest_collision_unsafe_fraction() const;
|
||||
|
||||
void add_exception_rid(const RID &p_rid);
|
||||
void add_exception(const CollisionObject2D *p_node);
|
||||
void add_exception(RequiredParam<const CollisionObject2D> p_node);
|
||||
void remove_exception_rid(const RID &p_rid);
|
||||
void remove_exception(const CollisionObject2D *p_node);
|
||||
void remove_exception(RequiredParam<const CollisionObject2D> p_node);
|
||||
void clear_exceptions();
|
||||
|
||||
PackedStringArray get_configuration_warnings() const override;
|
||||
|
||||
Reference in New Issue
Block a user