Use NULL instead of COND checks when appropriate
Restricted to scene
This commit is contained in:
parent
9723077f4f
commit
dcd2b883eb
|
@ -135,7 +135,7 @@ int Area2D::get_priority() const {
|
|||
void Area2D::_body_enter_tree(ObjectID p_id) {
|
||||
Object *obj = ObjectDB::get_instance(p_id);
|
||||
Node *node = Object::cast_to<Node>(obj);
|
||||
ERR_FAIL_COND(!node);
|
||||
ERR_FAIL_NULL(node);
|
||||
|
||||
HashMap<ObjectID, BodyState>::Iterator E = body_map.find(p_id);
|
||||
ERR_FAIL_COND(!E);
|
||||
|
@ -151,7 +151,7 @@ void Area2D::_body_enter_tree(ObjectID p_id) {
|
|||
void Area2D::_body_exit_tree(ObjectID p_id) {
|
||||
Object *obj = ObjectDB::get_instance(p_id);
|
||||
Node *node = Object::cast_to<Node>(obj);
|
||||
ERR_FAIL_COND(!node);
|
||||
ERR_FAIL_NULL(node);
|
||||
HashMap<ObjectID, BodyState>::Iterator E = body_map.find(p_id);
|
||||
ERR_FAIL_COND(!E);
|
||||
ERR_FAIL_COND(!E->value.in_tree);
|
||||
|
@ -231,7 +231,7 @@ void Area2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i
|
|||
void Area2D::_area_enter_tree(ObjectID p_id) {
|
||||
Object *obj = ObjectDB::get_instance(p_id);
|
||||
Node *node = Object::cast_to<Node>(obj);
|
||||
ERR_FAIL_COND(!node);
|
||||
ERR_FAIL_NULL(node);
|
||||
|
||||
HashMap<ObjectID, AreaState>::Iterator E = area_map.find(p_id);
|
||||
ERR_FAIL_COND(!E);
|
||||
|
@ -247,7 +247,7 @@ void Area2D::_area_enter_tree(ObjectID p_id) {
|
|||
void Area2D::_area_exit_tree(ObjectID p_id) {
|
||||
Object *obj = ObjectDB::get_instance(p_id);
|
||||
Node *node = Object::cast_to<Node>(obj);
|
||||
ERR_FAIL_COND(!node);
|
||||
ERR_FAIL_NULL(node);
|
||||
HashMap<ObjectID, AreaState>::Iterator E = area_map.find(p_id);
|
||||
ERR_FAIL_COND(!E);
|
||||
ERR_FAIL_COND(!E->value.in_tree);
|
||||
|
|
|
@ -1163,7 +1163,7 @@ void CPUParticles2D::_notification(int p_what) {
|
|||
|
||||
void CPUParticles2D::convert_from_particles(Node *p_particles) {
|
||||
GPUParticles2D *gpu_particles = Object::cast_to<GPUParticles2D>(p_particles);
|
||||
ERR_FAIL_COND_MSG(!gpu_particles, "Only GPUParticles2D nodes can be converted to CPUParticles2D.");
|
||||
ERR_FAIL_NULL_MSG(gpu_particles, "Only GPUParticles2D nodes can be converted to CPUParticles2D.");
|
||||
|
||||
set_emitting(gpu_particles->is_emitting());
|
||||
set_amount(gpu_particles->get_amount());
|
||||
|
|
|
@ -403,7 +403,7 @@ Transform2D Node2D::get_relative_transform_to_parent(const Node *p_parent) const
|
|||
|
||||
Node2D *parent_2d = Object::cast_to<Node2D>(get_parent());
|
||||
|
||||
ERR_FAIL_COND_V(!parent_2d, Transform2D());
|
||||
ERR_FAIL_NULL_V(parent_2d, Transform2D());
|
||||
if (p_parent == parent_2d) {
|
||||
return get_transform();
|
||||
} else {
|
||||
|
|
|
@ -162,14 +162,14 @@ TypedArray<PhysicsBody2D> PhysicsBody2D::get_collision_exceptions() {
|
|||
void PhysicsBody2D::add_collision_exception_with(Node *p_node) {
|
||||
ERR_FAIL_NULL(p_node);
|
||||
PhysicsBody2D *physics_body = Object::cast_to<PhysicsBody2D>(p_node);
|
||||
ERR_FAIL_COND_MSG(!physics_body, "Collision exception only works between two nodes that inherit from PhysicsBody2D.");
|
||||
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);
|
||||
PhysicsBody2D *physics_body = Object::cast_to<PhysicsBody2D>(p_node);
|
||||
ERR_FAIL_COND_MSG(!physics_body, "Collision exception only works between two nodes that inherit from PhysicsBody2D.");
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -323,9 +323,8 @@ AnimatableBody2D::AnimatableBody2D() :
|
|||
void RigidBody2D::_body_enter_tree(ObjectID p_id) {
|
||||
Object *obj = ObjectDB::get_instance(p_id);
|
||||
Node *node = Object::cast_to<Node>(obj);
|
||||
ERR_FAIL_COND(!node);
|
||||
|
||||
ERR_FAIL_COND(!contact_monitor);
|
||||
ERR_FAIL_NULL(node);
|
||||
ERR_FAIL_NULL(contact_monitor);
|
||||
HashMap<ObjectID, BodyState>::Iterator E = contact_monitor->body_map.find(p_id);
|
||||
ERR_FAIL_COND(!E);
|
||||
ERR_FAIL_COND(E->value.in_scene);
|
||||
|
@ -345,8 +344,8 @@ void RigidBody2D::_body_enter_tree(ObjectID p_id) {
|
|||
void RigidBody2D::_body_exit_tree(ObjectID p_id) {
|
||||
Object *obj = ObjectDB::get_instance(p_id);
|
||||
Node *node = Object::cast_to<Node>(obj);
|
||||
ERR_FAIL_COND(!node);
|
||||
ERR_FAIL_COND(!contact_monitor);
|
||||
ERR_FAIL_NULL(node);
|
||||
ERR_FAIL_NULL(contact_monitor);
|
||||
HashMap<ObjectID, BodyState>::Iterator E = contact_monitor->body_map.find(p_id);
|
||||
ERR_FAIL_COND(!E);
|
||||
ERR_FAIL_COND(!E->value.in_scene);
|
||||
|
@ -370,7 +369,7 @@ void RigidBody2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instan
|
|||
Object *obj = ObjectDB::get_instance(objid);
|
||||
Node *node = Object::cast_to<Node>(obj);
|
||||
|
||||
ERR_FAIL_COND(!contact_monitor);
|
||||
ERR_FAIL_NULL(contact_monitor);
|
||||
HashMap<ObjectID, BodyState>::Iterator E = contact_monitor->body_map.find(objid);
|
||||
|
||||
ERR_FAIL_COND(!body_in && !E);
|
||||
|
@ -849,7 +848,7 @@ RigidBody2D::CCDMode RigidBody2D::get_continuous_collision_detection_mode() cons
|
|||
}
|
||||
|
||||
TypedArray<Node2D> RigidBody2D::get_colliding_bodies() const {
|
||||
ERR_FAIL_COND_V(!contact_monitor, TypedArray<Node2D>());
|
||||
ERR_FAIL_NULL_V(contact_monitor, TypedArray<Node2D>());
|
||||
|
||||
TypedArray<Node2D> ret;
|
||||
ret.resize(contact_monitor->body_map.size());
|
||||
|
|
|
@ -183,7 +183,7 @@ void RayCast2D::_update_raycast_state() {
|
|||
ERR_FAIL_COND(w2d.is_null());
|
||||
|
||||
PhysicsDirectSpaceState2D *dss = PhysicsServer2D::get_singleton()->space_get_direct_state(w2d->get_space());
|
||||
ERR_FAIL_COND(!dss);
|
||||
ERR_FAIL_NULL(dss);
|
||||
|
||||
Transform2D gt = get_global_transform();
|
||||
|
||||
|
|
|
@ -293,7 +293,7 @@ void ShapeCast2D::_update_shapecast_state() {
|
|||
ERR_FAIL_COND(w2d.is_null());
|
||||
|
||||
PhysicsDirectSpaceState2D *dss = PhysicsServer2D::get_singleton()->space_get_direct_state(w2d->get_space());
|
||||
ERR_FAIL_COND(!dss);
|
||||
ERR_FAIL_NULL(dss);
|
||||
|
||||
Transform2D gt = get_global_transform();
|
||||
|
||||
|
|
|
@ -406,7 +406,7 @@ void Bone2D::apply_rest() {
|
|||
}
|
||||
|
||||
int Bone2D::get_index_in_skeleton() const {
|
||||
ERR_FAIL_COND_V(!skeleton, -1);
|
||||
ERR_FAIL_NULL_V(skeleton, -1);
|
||||
skeleton->_update_bone_setup();
|
||||
return skeleton_index;
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ void Area3D::_initialize_wind() {
|
|||
void Area3D::_body_enter_tree(ObjectID p_id) {
|
||||
Object *obj = ObjectDB::get_instance(p_id);
|
||||
Node *node = Object::cast_to<Node>(obj);
|
||||
ERR_FAIL_COND(!node);
|
||||
ERR_FAIL_NULL(node);
|
||||
|
||||
HashMap<ObjectID, BodyState>::Iterator E = body_map.find(p_id);
|
||||
ERR_FAIL_COND(!E);
|
||||
|
@ -206,7 +206,7 @@ void Area3D::_body_enter_tree(ObjectID p_id) {
|
|||
void Area3D::_body_exit_tree(ObjectID p_id) {
|
||||
Object *obj = ObjectDB::get_instance(p_id);
|
||||
Node *node = Object::cast_to<Node>(obj);
|
||||
ERR_FAIL_COND(!node);
|
||||
ERR_FAIL_NULL(node);
|
||||
HashMap<ObjectID, BodyState>::Iterator E = body_map.find(p_id);
|
||||
ERR_FAIL_COND(!E);
|
||||
ERR_FAIL_COND(!E->value.in_tree);
|
||||
|
@ -379,7 +379,7 @@ void Area3D::set_monitoring(bool p_enable) {
|
|||
void Area3D::_area_enter_tree(ObjectID p_id) {
|
||||
Object *obj = ObjectDB::get_instance(p_id);
|
||||
Node *node = Object::cast_to<Node>(obj);
|
||||
ERR_FAIL_COND(!node);
|
||||
ERR_FAIL_NULL(node);
|
||||
|
||||
HashMap<ObjectID, AreaState>::Iterator E = area_map.find(p_id);
|
||||
ERR_FAIL_COND(!E);
|
||||
|
@ -395,7 +395,7 @@ void Area3D::_area_enter_tree(ObjectID p_id) {
|
|||
void Area3D::_area_exit_tree(ObjectID p_id) {
|
||||
Object *obj = ObjectDB::get_instance(p_id);
|
||||
Node *node = Object::cast_to<Node>(obj);
|
||||
ERR_FAIL_COND(!node);
|
||||
ERR_FAIL_NULL(node);
|
||||
HashMap<ObjectID, AreaState>::Iterator E = area_map.find(p_id);
|
||||
ERR_FAIL_COND(!E);
|
||||
ERR_FAIL_COND(!E->value.in_tree);
|
||||
|
|
|
@ -112,11 +112,11 @@ void BoneAttachment3D::_update_external_skeleton_cache() {
|
|||
external_skeleton_node_cache = ObjectID();
|
||||
if (has_node(external_skeleton_node)) {
|
||||
Node *node = get_node(external_skeleton_node);
|
||||
ERR_FAIL_COND_MSG(!node, "Cannot update external skeleton cache: Node cannot be found!");
|
||||
ERR_FAIL_NULL_MSG(node, "Cannot update external skeleton cache: Node cannot be found!");
|
||||
|
||||
// Make sure it's a skeleton3D
|
||||
Skeleton3D *sk = Object::cast_to<Skeleton3D>(node);
|
||||
ERR_FAIL_COND_MSG(!sk, "Cannot update external skeleton cache: Skeleton3D Nodepath does not point to a Skeleton3D node!");
|
||||
ERR_FAIL_NULL_MSG(sk, "Cannot update external skeleton cache: Skeleton3D Nodepath does not point to a Skeleton3D node!");
|
||||
|
||||
external_skeleton_node_cache = node->get_instance_id();
|
||||
} else {
|
||||
|
@ -126,11 +126,11 @@ void BoneAttachment3D::_update_external_skeleton_cache() {
|
|||
parent_attachment->_update_external_skeleton_cache();
|
||||
if (parent_attachment->has_node(parent_attachment->external_skeleton_node)) {
|
||||
Node *node = parent_attachment->get_node(parent_attachment->external_skeleton_node);
|
||||
ERR_FAIL_COND_MSG(!node, "Cannot update external skeleton cache: Parent's Skeleton3D node cannot be found!");
|
||||
ERR_FAIL_NULL_MSG(node, "Cannot update external skeleton cache: Parent's Skeleton3D node cannot be found!");
|
||||
|
||||
// Make sure it's a skeleton3D
|
||||
Skeleton3D *sk = Object::cast_to<Skeleton3D>(node);
|
||||
ERR_FAIL_COND_MSG(!sk, "Cannot update external skeleton cache: Parent Skeleton3D Nodepath does not point to a Skeleton3D node!");
|
||||
ERR_FAIL_NULL_MSG(sk, "Cannot update external skeleton cache: Parent Skeleton3D Nodepath does not point to a Skeleton3D node!");
|
||||
|
||||
external_skeleton_node_cache = node->get_instance_id();
|
||||
external_skeleton_node = get_path_to(node);
|
||||
|
@ -190,7 +190,7 @@ void BoneAttachment3D::_transform_changed() {
|
|||
if (override_pose) {
|
||||
Skeleton3D *sk = _get_skeleton3d();
|
||||
|
||||
ERR_FAIL_COND_MSG(!sk, "Cannot override pose: Skeleton not found!");
|
||||
ERR_FAIL_NULL_MSG(sk, "Cannot override pose: Skeleton not found!");
|
||||
ERR_FAIL_INDEX_MSG(bone_idx, sk->get_bone_count(), "Cannot override pose: Bone index is out of range!");
|
||||
|
||||
Transform3D our_trans = get_transform();
|
||||
|
|
|
@ -106,7 +106,7 @@ void Camera3D::_notification(int p_what) {
|
|||
// and Spatial will handle it first, including clearing its reference to the Viewport,
|
||||
// therefore making it impossible to subclasses to access it
|
||||
viewport = get_viewport();
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
bool first_camera = viewport->_camera_3d_add(this);
|
||||
if (current || first_camera) {
|
||||
|
@ -454,7 +454,7 @@ Ref<CameraAttributes> Camera3D::get_attributes() const {
|
|||
|
||||
void Camera3D::_attributes_changed() {
|
||||
CameraAttributesPhysical *physical_attributes = Object::cast_to<CameraAttributesPhysical>(attributes.ptr());
|
||||
ERR_FAIL_COND(!physical_attributes);
|
||||
ERR_FAIL_NULL(physical_attributes);
|
||||
|
||||
fov = physical_attributes->get_fov();
|
||||
near = physical_attributes->get_near();
|
||||
|
|
|
@ -1327,7 +1327,7 @@ void CPUParticles3D::_notification(int p_what) {
|
|||
|
||||
void CPUParticles3D::convert_from_particles(Node *p_particles) {
|
||||
GPUParticles3D *gpu_particles = Object::cast_to<GPUParticles3D>(p_particles);
|
||||
ERR_FAIL_COND_MSG(!gpu_particles, "Only GPUParticles3D nodes can be converted to CPUParticles3D.");
|
||||
ERR_FAIL_NULL_MSG(gpu_particles, "Only GPUParticles3D nodes can be converted to CPUParticles3D.");
|
||||
|
||||
set_emitting(gpu_particles->is_emitting());
|
||||
set_amount(gpu_particles->get_amount());
|
||||
|
|
|
@ -204,12 +204,12 @@ void Label3D::_notification(int p_what) {
|
|||
_im_update();
|
||||
}
|
||||
Viewport *viewport = get_viewport();
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
viewport->connect("size_changed", callable_mp(this, &Label3D::_font_changed));
|
||||
} break;
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
Viewport *viewport = get_viewport();
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
viewport->disconnect("size_changed", callable_mp(this, &Label3D::_font_changed));
|
||||
} break;
|
||||
case NOTIFICATION_TRANSLATION_CHANGED: {
|
||||
|
|
|
@ -243,7 +243,7 @@ Node *MeshInstance3D::create_trimesh_collision_node() {
|
|||
|
||||
void MeshInstance3D::create_trimesh_collision() {
|
||||
StaticBody3D *static_body = Object::cast_to<StaticBody3D>(create_trimesh_collision_node());
|
||||
ERR_FAIL_COND(!static_body);
|
||||
ERR_FAIL_NULL(static_body);
|
||||
static_body->set_name(String(get_name()) + "_col");
|
||||
|
||||
add_child(static_body, true);
|
||||
|
@ -273,7 +273,7 @@ Node *MeshInstance3D::create_convex_collision_node(bool p_clean, bool p_simplify
|
|||
|
||||
void MeshInstance3D::create_convex_collision(bool p_clean, bool p_simplify) {
|
||||
StaticBody3D *static_body = Object::cast_to<StaticBody3D>(create_convex_collision_node(p_clean, p_simplify));
|
||||
ERR_FAIL_COND(!static_body);
|
||||
ERR_FAIL_NULL(static_body);
|
||||
static_body->set_name(String(get_name()) + "_col");
|
||||
|
||||
add_child(static_body, true);
|
||||
|
@ -312,7 +312,7 @@ Node *MeshInstance3D::create_multiple_convex_collisions_node(const Ref<MeshConve
|
|||
|
||||
void MeshInstance3D::create_multiple_convex_collisions(const Ref<MeshConvexDecompositionSettings> &p_settings) {
|
||||
StaticBody3D *static_body = Object::cast_to<StaticBody3D>(create_multiple_convex_collisions_node(p_settings));
|
||||
ERR_FAIL_COND(!static_body);
|
||||
ERR_FAIL_NULL(static_body);
|
||||
static_body->set_name(String(get_name()) + "_col");
|
||||
|
||||
add_child(static_body, true);
|
||||
|
|
|
@ -135,7 +135,7 @@ void Node3D::_notification(int p_what) {
|
|||
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
ERR_FAIL_COND(!get_tree());
|
||||
ERR_FAIL_NULL(get_tree());
|
||||
|
||||
Node *p = get_parent();
|
||||
if (p) {
|
||||
|
@ -186,7 +186,7 @@ void Node3D::_notification(int p_what) {
|
|||
parent = parent->get_parent();
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!data.viewport);
|
||||
ERR_FAIL_NULL(data.viewport);
|
||||
|
||||
if (get_script_instance()) {
|
||||
get_script_instance()->call(SceneStringNames::get_singleton()->_enter_world);
|
||||
|
@ -379,7 +379,7 @@ Transform3D Node3D::get_relative_transform(const Node *p_parent) const {
|
|||
return Transform3D();
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(!data.parent, Transform3D());
|
||||
ERR_FAIL_NULL_V(data.parent, Transform3D());
|
||||
|
||||
if (p_parent == data.parent) {
|
||||
return get_transform();
|
||||
|
@ -743,7 +743,7 @@ bool Node3D::is_set_as_top_level() const {
|
|||
Ref<World3D> Node3D::get_world_3d() const {
|
||||
ERR_READ_THREAD_GUARD_V(Ref<World3D>()); // World3D can only be set from main thread, so it's safe to obtain on threads.
|
||||
ERR_FAIL_COND_V(!is_inside_world(), Ref<World3D>());
|
||||
ERR_FAIL_COND_V(!data.viewport, Ref<World3D>());
|
||||
ERR_FAIL_NULL_V(data.viewport, Ref<World3D>());
|
||||
|
||||
return data.viewport->find_world_3d();
|
||||
}
|
||||
|
@ -977,10 +977,10 @@ void Node3D::_update_visibility_parent(bool p_update_root) {
|
|||
return;
|
||||
}
|
||||
Node *parent = get_node_or_null(visibility_parent_path);
|
||||
ERR_FAIL_COND_MSG(!parent, "Can't find visibility parent node at path: " + visibility_parent_path);
|
||||
ERR_FAIL_NULL_MSG(parent, "Can't find visibility parent node at path: " + visibility_parent_path);
|
||||
ERR_FAIL_COND_MSG(parent == this, "The visibility parent can't be the same node.");
|
||||
GeometryInstance3D *gi = Object::cast_to<GeometryInstance3D>(parent);
|
||||
ERR_FAIL_COND_MSG(!gi, "The visibility parent node must be a GeometryInstance3D, at path: " + visibility_parent_path);
|
||||
ERR_FAIL_NULL_MSG(gi, "The visibility parent node must be a GeometryInstance3D, at path: " + visibility_parent_path);
|
||||
new_parent = gi ? gi->get_instance() : RID();
|
||||
} else if (data.parent) {
|
||||
new_parent = data.parent->data.visibility_parent;
|
||||
|
|
|
@ -605,7 +605,7 @@ void OccluderInstance3D::_bake_node(Node *p_node, PackedVector3Array &r_vertices
|
|||
}
|
||||
|
||||
void OccluderInstance3D::bake_single_node(const Node3D *p_node, float p_simplification_distance, PackedVector3Array &r_vertices, PackedInt32Array &r_indices) {
|
||||
ERR_FAIL_COND(!p_node);
|
||||
ERR_FAIL_NULL(p_node);
|
||||
|
||||
Transform3D xform = p_node->is_inside_tree() ? p_node->get_global_transform() : p_node->get_transform();
|
||||
|
||||
|
|
|
@ -80,14 +80,14 @@ TypedArray<PhysicsBody3D> PhysicsBody3D::get_collision_exceptions() {
|
|||
void PhysicsBody3D::add_collision_exception_with(Node *p_node) {
|
||||
ERR_FAIL_NULL(p_node);
|
||||
CollisionObject3D *collision_object = Object::cast_to<CollisionObject3D>(p_node);
|
||||
ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two nodes that inherit from CollisionObject3D (such as Area3D or PhysicsBody3D).");
|
||||
ERR_FAIL_NULL_MSG(collision_object, "Collision exception only works between two nodes that inherit from CollisionObject3D (such as Area3D or PhysicsBody3D).");
|
||||
PhysicsServer3D::get_singleton()->body_add_collision_exception(get_rid(), collision_object->get_rid());
|
||||
}
|
||||
|
||||
void PhysicsBody3D::remove_collision_exception_with(Node *p_node) {
|
||||
ERR_FAIL_NULL(p_node);
|
||||
CollisionObject3D *collision_object = Object::cast_to<CollisionObject3D>(p_node);
|
||||
ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two nodes that inherit from CollisionObject3D (such as Area3D or PhysicsBody3D).");
|
||||
ERR_FAIL_NULL_MSG(collision_object, "Collision exception only works between two nodes that inherit from CollisionObject3D (such as Area3D or PhysicsBody3D).");
|
||||
PhysicsServer3D::get_singleton()->body_remove_collision_exception(get_rid(), collision_object->get_rid());
|
||||
}
|
||||
|
||||
|
@ -379,9 +379,8 @@ AnimatableBody3D::AnimatableBody3D() :
|
|||
void RigidBody3D::_body_enter_tree(ObjectID p_id) {
|
||||
Object *obj = ObjectDB::get_instance(p_id);
|
||||
Node *node = Object::cast_to<Node>(obj);
|
||||
ERR_FAIL_COND(!node);
|
||||
|
||||
ERR_FAIL_COND(!contact_monitor);
|
||||
ERR_FAIL_NULL(node);
|
||||
ERR_FAIL_NULL(contact_monitor);
|
||||
HashMap<ObjectID, BodyState>::Iterator E = contact_monitor->body_map.find(p_id);
|
||||
ERR_FAIL_COND(!E);
|
||||
ERR_FAIL_COND(E->value.in_tree);
|
||||
|
@ -402,8 +401,8 @@ void RigidBody3D::_body_enter_tree(ObjectID p_id) {
|
|||
void RigidBody3D::_body_exit_tree(ObjectID p_id) {
|
||||
Object *obj = ObjectDB::get_instance(p_id);
|
||||
Node *node = Object::cast_to<Node>(obj);
|
||||
ERR_FAIL_COND(!node);
|
||||
ERR_FAIL_COND(!contact_monitor);
|
||||
ERR_FAIL_NULL(node);
|
||||
ERR_FAIL_NULL(contact_monitor);
|
||||
HashMap<ObjectID, BodyState>::Iterator E = contact_monitor->body_map.find(p_id);
|
||||
ERR_FAIL_COND(!E);
|
||||
ERR_FAIL_COND(!E->value.in_tree);
|
||||
|
@ -427,7 +426,7 @@ void RigidBody3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instan
|
|||
Object *obj = ObjectDB::get_instance(objid);
|
||||
Node *node = Object::cast_to<Node>(obj);
|
||||
|
||||
ERR_FAIL_COND(!contact_monitor);
|
||||
ERR_FAIL_NULL(contact_monitor);
|
||||
HashMap<ObjectID, BodyState>::Iterator E = contact_monitor->body_map.find(objid);
|
||||
|
||||
ERR_FAIL_COND(!body_in && !E);
|
||||
|
@ -962,7 +961,7 @@ bool RigidBody3D::is_contact_monitor_enabled() const {
|
|||
}
|
||||
|
||||
TypedArray<Node3D> RigidBody3D::get_colliding_bodies() const {
|
||||
ERR_FAIL_COND_V(!contact_monitor, TypedArray<Node3D>());
|
||||
ERR_FAIL_NULL_V(contact_monitor, TypedArray<Node3D>());
|
||||
|
||||
TypedArray<Node3D> ret;
|
||||
ret.resize(contact_monitor->body_map.size());
|
||||
|
|
|
@ -206,7 +206,7 @@ void RayCast3D::_update_raycast_state() {
|
|||
ERR_FAIL_COND(w3d.is_null());
|
||||
|
||||
PhysicsDirectSpaceState3D *dss = PhysicsServer3D::get_singleton()->space_get_direct_state(w3d->get_space());
|
||||
ERR_FAIL_COND(!dss);
|
||||
ERR_FAIL_NULL(dss);
|
||||
|
||||
Transform3D gt = get_global_transform();
|
||||
|
||||
|
|
|
@ -385,7 +385,7 @@ void ShapeCast3D::_update_shapecast_state() {
|
|||
ERR_FAIL_COND(w3d.is_null());
|
||||
|
||||
PhysicsDirectSpaceState3D *dss = PhysicsServer3D::get_singleton()->space_get_direct_state(w3d->get_space());
|
||||
ERR_FAIL_COND(!dss);
|
||||
ERR_FAIL_NULL(dss);
|
||||
|
||||
Transform3D gt = get_global_transform();
|
||||
|
||||
|
|
|
@ -680,7 +680,7 @@ void Skeleton3D::bind_physical_bone_to_bone(int p_bone, PhysicalBone3D *p_physic
|
|||
const int bone_size = bones.size();
|
||||
ERR_FAIL_INDEX(p_bone, bone_size);
|
||||
ERR_FAIL_COND(bones[p_bone].physical_bone);
|
||||
ERR_FAIL_COND(!p_physical_bone);
|
||||
ERR_FAIL_NULL(p_physical_bone);
|
||||
bones.write[p_bone].physical_bone = p_physical_bone;
|
||||
|
||||
_rebuild_physical_bones_cache();
|
||||
|
|
|
@ -593,14 +593,14 @@ TypedArray<PhysicsBody3D> SoftBody3D::get_collision_exceptions() {
|
|||
void SoftBody3D::add_collision_exception_with(Node *p_node) {
|
||||
ERR_FAIL_NULL(p_node);
|
||||
CollisionObject3D *collision_object = Object::cast_to<CollisionObject3D>(p_node);
|
||||
ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two nodes that inherit from CollisionObject3D (such as Area3D or PhysicsBody3D).");
|
||||
ERR_FAIL_NULL_MSG(collision_object, "Collision exception only works between two nodes that inherit from CollisionObject3D (such as Area3D or PhysicsBody3D).");
|
||||
PhysicsServer3D::get_singleton()->soft_body_add_collision_exception(physics_rid, collision_object->get_rid());
|
||||
}
|
||||
|
||||
void SoftBody3D::remove_collision_exception_with(Node *p_node) {
|
||||
ERR_FAIL_NULL(p_node);
|
||||
CollisionObject3D *collision_object = Object::cast_to<CollisionObject3D>(p_node);
|
||||
ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two nodes that inherit from CollisionObject3D (such as Area3D or PhysicsBody3D).");
|
||||
ERR_FAIL_NULL_MSG(collision_object, "Collision exception only works between two nodes that inherit from CollisionObject3D (such as Area3D or PhysicsBody3D).");
|
||||
PhysicsServer3D::get_singleton()->soft_body_remove_collision_exception(physics_rid, collision_object->get_rid());
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ void AnimationNodeAnimation::_validate_property(PropertyInfo &p_property) const
|
|||
|
||||
double AnimationNodeAnimation::_process(double p_time, bool p_seek, bool p_is_external_seeking, bool p_test_only) {
|
||||
AnimationPlayer *ap = state->player;
|
||||
ERR_FAIL_COND_V(!ap, 0);
|
||||
ERR_FAIL_NULL_V(ap, 0);
|
||||
|
||||
double cur_time = get_parameter(time);
|
||||
|
||||
|
|
|
@ -273,7 +273,7 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim, Node *p_root_ov
|
|||
|
||||
Node *parent = p_root_override ? p_root_override : get_node(root);
|
||||
|
||||
ERR_FAIL_COND(!parent);
|
||||
ERR_FAIL_NULL(parent);
|
||||
|
||||
Animation *a = p_anim->animation.operator->();
|
||||
|
||||
|
@ -2169,7 +2169,7 @@ Ref<AnimatedValuesBackup> AnimationPlayer::apply_reset(bool p_user_initiated) {
|
|||
ERR_FAIL_COND_V(reset_anim.is_null(), Ref<AnimatedValuesBackup>());
|
||||
|
||||
Node *root_node = get_node_or_null(root);
|
||||
ERR_FAIL_COND_V(!root_node, Ref<AnimatedValuesBackup>());
|
||||
ERR_FAIL_NULL_V(root_node, Ref<AnimatedValuesBackup>());
|
||||
|
||||
AnimationPlayer *aux_player = memnew(AnimationPlayer);
|
||||
EditorNode::get_singleton()->add_child(aux_player);
|
||||
|
|
|
@ -64,7 +64,7 @@ void AnimationNode::set_parameter(const StringName &p_name, const Variant &p_val
|
|||
if (is_testing) {
|
||||
return;
|
||||
}
|
||||
ERR_FAIL_COND(!state);
|
||||
ERR_FAIL_NULL(state);
|
||||
ERR_FAIL_COND(!state->tree->property_parent_map.has(base_path));
|
||||
ERR_FAIL_COND(!state->tree->property_parent_map[base_path].has(p_name));
|
||||
StringName path = state->tree->property_parent_map[base_path][p_name];
|
||||
|
@ -73,7 +73,7 @@ void AnimationNode::set_parameter(const StringName &p_name, const Variant &p_val
|
|||
}
|
||||
|
||||
Variant AnimationNode::get_parameter(const StringName &p_name) const {
|
||||
ERR_FAIL_COND_V(!state, Variant());
|
||||
ERR_FAIL_NULL_V(state, Variant());
|
||||
ERR_FAIL_COND_V(!state->tree->property_parent_map.has(base_path), Variant());
|
||||
ERR_FAIL_COND_V(!state->tree->property_parent_map[base_path].has(p_name), Variant());
|
||||
|
||||
|
@ -96,7 +96,7 @@ void AnimationNode::get_child_nodes(List<ChildNode> *r_child_nodes) {
|
|||
}
|
||||
|
||||
void AnimationNode::blend_animation(const StringName &p_animation, double p_time, double p_delta, bool p_seeked, bool p_is_external_seeking, real_t p_blend, Animation::LoopedFlag p_looped_flag) {
|
||||
ERR_FAIL_COND(!state);
|
||||
ERR_FAIL_NULL(state);
|
||||
ERR_FAIL_COND(!state->player->has_animation(p_animation));
|
||||
|
||||
Ref<Animation> animation = state->player->get_animation(p_animation);
|
||||
|
@ -144,12 +144,12 @@ double AnimationNode::_pre_process(const StringName &p_base_path, AnimationNode
|
|||
}
|
||||
|
||||
AnimationTree *AnimationNode::get_animation_tree() const {
|
||||
ERR_FAIL_COND_V(!state, nullptr);
|
||||
ERR_FAIL_NULL_V(state, nullptr);
|
||||
return state->tree;
|
||||
}
|
||||
|
||||
void AnimationNode::make_invalid(const String &p_reason) {
|
||||
ERR_FAIL_COND(!state);
|
||||
ERR_FAIL_NULL(state);
|
||||
state->valid = false;
|
||||
if (!state->invalid_reasons.is_empty()) {
|
||||
state->invalid_reasons += "\n";
|
||||
|
@ -159,10 +159,10 @@ void AnimationNode::make_invalid(const String &p_reason) {
|
|||
|
||||
double AnimationNode::blend_input(int p_input, double p_time, bool p_seek, bool p_is_external_seeking, real_t p_blend, FilterAction p_filter, bool p_sync, bool p_test_only) {
|
||||
ERR_FAIL_INDEX_V(p_input, inputs.size(), 0);
|
||||
ERR_FAIL_COND_V(!state, 0);
|
||||
ERR_FAIL_NULL_V(state, 0);
|
||||
|
||||
AnimationNodeBlendTree *blend_tree = Object::cast_to<AnimationNodeBlendTree>(parent);
|
||||
ERR_FAIL_COND_V(!blend_tree, 0);
|
||||
ERR_FAIL_NULL_V(blend_tree, 0);
|
||||
|
||||
StringName node_name = connections[p_input];
|
||||
|
||||
|
@ -193,7 +193,7 @@ double AnimationNode::blend_node(const StringName &p_sub_path, Ref<AnimationNode
|
|||
|
||||
double AnimationNode::_blend_node(const StringName &p_subpath, const Vector<StringName> &p_connections, AnimationNode *p_new_parent, Ref<AnimationNode> p_node, double p_time, bool p_seek, bool p_is_external_seeking, real_t p_blend, FilterAction p_filter, bool p_sync, real_t *r_max, bool p_test_only) {
|
||||
ERR_FAIL_COND_V(!p_node.is_valid(), 0);
|
||||
ERR_FAIL_COND_V(!state, 0);
|
||||
ERR_FAIL_NULL_V(state, 0);
|
||||
|
||||
int blend_count = blends.size();
|
||||
|
||||
|
@ -293,7 +293,7 @@ double AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Stri
|
|||
new_parent = p_new_parent;
|
||||
new_path = String(base_path) + String(p_subpath) + "/";
|
||||
} else {
|
||||
ERR_FAIL_COND_V(!parent, 0);
|
||||
ERR_FAIL_NULL_V(parent, 0);
|
||||
new_parent = parent;
|
||||
new_path = String(parent->base_path) + String(p_subpath) + "/";
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ Error SceneDebugger::parse_message(void *p_user, const String &p_msg, const Arra
|
|||
|
||||
void SceneDebugger::_save_node(ObjectID id, const String &p_path) {
|
||||
Node *node = Object::cast_to<Node>(ObjectDB::get_instance(id));
|
||||
ERR_FAIL_COND(!node);
|
||||
ERR_FAIL_NULL(node);
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
HashMap<const Node *, Node *> duplimap;
|
||||
|
|
|
@ -97,7 +97,7 @@ void Container::_sort_children() {
|
|||
}
|
||||
|
||||
void Container::fit_child_in_rect(Control *p_child, const Rect2 &p_rect) {
|
||||
ERR_FAIL_COND(!p_child);
|
||||
ERR_FAIL_NULL(p_child);
|
||||
ERR_FAIL_COND(p_child->get_parent() != this);
|
||||
|
||||
bool rtl = is_layout_rtl();
|
||||
|
|
|
@ -3180,7 +3180,7 @@ void Control::_notification(int p_notification) {
|
|||
} else {
|
||||
// Is a regular root control or top_level.
|
||||
Viewport *viewport = get_viewport();
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
data.RI = viewport->_gui_add_root_control(this);
|
||||
|
||||
get_parent()->connect(SNAME("child_order_changed"), callable_mp(get_viewport(), &Viewport::gui_set_root_order_dirty), CONNECT_REFERENCE_COUNTED);
|
||||
|
@ -3193,7 +3193,7 @@ void Control::_notification(int p_notification) {
|
|||
} else {
|
||||
// Connect viewport.
|
||||
Viewport *viewport = get_viewport();
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
viewport->connect("size_changed", callable_mp(this, &Control::_size_changed));
|
||||
}
|
||||
} break;
|
||||
|
@ -3205,7 +3205,7 @@ void Control::_notification(int p_notification) {
|
|||
} else {
|
||||
// Disconnect viewport.
|
||||
Viewport *viewport = get_viewport();
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
viewport->disconnect("size_changed", callable_mp(this, &Control::_size_changed));
|
||||
}
|
||||
|
||||
|
|
|
@ -372,7 +372,7 @@ void GraphEdit::_update_scroll() {
|
|||
|
||||
void GraphEdit::_graph_node_raised(Node *p_gn) {
|
||||
GraphNode *gn = Object::cast_to<GraphNode>(p_gn);
|
||||
ERR_FAIL_COND(!gn);
|
||||
ERR_FAIL_NULL(gn);
|
||||
if (gn->is_comment()) {
|
||||
move_child(gn, 0);
|
||||
} else {
|
||||
|
@ -382,21 +382,21 @@ void GraphEdit::_graph_node_raised(Node *p_gn) {
|
|||
|
||||
void GraphEdit::_graph_node_selected(Node *p_gn) {
|
||||
GraphNode *gn = Object::cast_to<GraphNode>(p_gn);
|
||||
ERR_FAIL_COND(!gn);
|
||||
ERR_FAIL_NULL(gn);
|
||||
|
||||
emit_signal(SNAME("node_selected"), gn);
|
||||
}
|
||||
|
||||
void GraphEdit::_graph_node_deselected(Node *p_gn) {
|
||||
GraphNode *gn = Object::cast_to<GraphNode>(p_gn);
|
||||
ERR_FAIL_COND(!gn);
|
||||
ERR_FAIL_NULL(gn);
|
||||
|
||||
emit_signal(SNAME("node_deselected"), gn);
|
||||
}
|
||||
|
||||
void GraphEdit::_graph_node_moved(Node *p_gn) {
|
||||
GraphNode *gn = Object::cast_to<GraphNode>(p_gn);
|
||||
ERR_FAIL_COND(!gn);
|
||||
ERR_FAIL_NULL(gn);
|
||||
top_layer->queue_redraw();
|
||||
minimap->queue_redraw();
|
||||
queue_redraw();
|
||||
|
@ -405,7 +405,7 @@ void GraphEdit::_graph_node_moved(Node *p_gn) {
|
|||
|
||||
void GraphEdit::_graph_node_slot_updated(int p_index, Node *p_gn) {
|
||||
GraphNode *gn = Object::cast_to<GraphNode>(p_gn);
|
||||
ERR_FAIL_COND(!gn);
|
||||
ERR_FAIL_NULL(gn);
|
||||
top_layer->queue_redraw();
|
||||
minimap->queue_redraw();
|
||||
queue_redraw();
|
||||
|
@ -990,9 +990,9 @@ void GraphEdit::_top_layer_draw() {
|
|||
|
||||
if (connecting) {
|
||||
Node *fromn = get_node(NodePath(connecting_from));
|
||||
ERR_FAIL_COND(!fromn);
|
||||
ERR_FAIL_NULL(fromn);
|
||||
GraphNode *from = Object::cast_to<GraphNode>(fromn);
|
||||
ERR_FAIL_COND(!from);
|
||||
ERR_FAIL_NULL(from);
|
||||
Vector2 pos;
|
||||
if (connecting_out) {
|
||||
pos = from->get_connection_output_position(connecting_index);
|
||||
|
|
|
@ -236,7 +236,7 @@ double Range::get_as_ratio() const {
|
|||
|
||||
void Range::_share(Node *p_range) {
|
||||
Range *r = Object::cast_to<Range>(p_range);
|
||||
ERR_FAIL_COND(!r);
|
||||
ERR_FAIL_NULL(r);
|
||||
share(r);
|
||||
}
|
||||
|
||||
|
|
|
@ -3599,7 +3599,7 @@ void RichTextLabel::pop() {
|
|||
_stop_thread();
|
||||
MutexLock data_lock(data_mutex);
|
||||
|
||||
ERR_FAIL_COND(!current->parent);
|
||||
ERR_FAIL_NULL(current->parent);
|
||||
|
||||
if (current->type == ITEM_FRAME) {
|
||||
current_frame = static_cast<ItemFrame *>(current)->parent_frame;
|
||||
|
|
|
@ -731,7 +731,7 @@ bool TabContainer::is_all_tabs_in_front() const {
|
|||
|
||||
void TabContainer::set_tab_title(int p_tab, const String &p_title) {
|
||||
Control *child = get_tab_control(p_tab);
|
||||
ERR_FAIL_COND(!child);
|
||||
ERR_FAIL_NULL(child);
|
||||
|
||||
if (tab_bar->get_tab_title(p_tab) == p_title) {
|
||||
return;
|
||||
|
@ -789,7 +789,7 @@ bool TabContainer::is_tab_disabled(int p_tab) const {
|
|||
|
||||
void TabContainer::set_tab_hidden(int p_tab, bool p_hidden) {
|
||||
Control *child = get_tab_control(p_tab);
|
||||
ERR_FAIL_COND(!child);
|
||||
ERR_FAIL_NULL(child);
|
||||
|
||||
if (tab_bar->is_tab_hidden(p_tab) == p_hidden) {
|
||||
return;
|
||||
|
|
|
@ -992,7 +992,7 @@ void TreeItem::validate_cache() const {
|
|||
void TreeItem::move_before(TreeItem *p_item) {
|
||||
ERR_FAIL_NULL(p_item);
|
||||
ERR_FAIL_COND(is_root);
|
||||
ERR_FAIL_COND(!p_item->parent);
|
||||
ERR_FAIL_NULL(p_item->parent);
|
||||
|
||||
if (p_item == this) {
|
||||
return;
|
||||
|
@ -1037,7 +1037,7 @@ void TreeItem::move_before(TreeItem *p_item) {
|
|||
void TreeItem::move_after(TreeItem *p_item) {
|
||||
ERR_FAIL_NULL(p_item);
|
||||
ERR_FAIL_COND(is_root);
|
||||
ERR_FAIL_COND(!p_item->parent);
|
||||
ERR_FAIL_NULL(p_item->parent);
|
||||
|
||||
if (p_item == this) {
|
||||
return;
|
||||
|
@ -1400,7 +1400,7 @@ bool TreeItem::is_folding_disabled() const {
|
|||
Size2 TreeItem::get_minimum_size(int p_column) {
|
||||
ERR_FAIL_INDEX_V(p_column, cells.size(), Size2());
|
||||
Tree *parent_tree = get_tree();
|
||||
ERR_FAIL_COND_V(!parent_tree, Size2());
|
||||
ERR_FAIL_NULL_V(parent_tree, Size2());
|
||||
|
||||
const TreeItem::Cell &cell = cells[p_column];
|
||||
|
||||
|
@ -3916,7 +3916,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
|
|||
|
||||
bool Tree::edit_selected(bool p_force_edit) {
|
||||
TreeItem *s = get_selected();
|
||||
ERR_FAIL_COND_V_MSG(!s, false, "No item selected.");
|
||||
ERR_FAIL_NULL_V_MSG(s, false, "No item selected.");
|
||||
ensure_cursor_is_visible();
|
||||
int col = get_selected_column();
|
||||
ERR_FAIL_INDEX_V_MSG(col, columns.size(), false, "No item column selected.");
|
||||
|
@ -4338,7 +4338,7 @@ TreeItem *Tree::create_item(TreeItem *p_parent, int p_index) {
|
|||
if (!root) {
|
||||
// No root exists, make the given item the new root.
|
||||
ti = memnew(TreeItem(this));
|
||||
ERR_FAIL_COND_V(!ti, nullptr);
|
||||
ERR_FAIL_NULL_V(ti, nullptr);
|
||||
ti->cells.resize(columns.size());
|
||||
ti->is_root = true;
|
||||
root = ti;
|
||||
|
@ -4572,7 +4572,7 @@ TreeItem *Tree::get_selected() const {
|
|||
|
||||
void Tree::set_selected(TreeItem *p_item, int p_column) {
|
||||
ERR_FAIL_INDEX(p_column, columns.size());
|
||||
ERR_FAIL_COND(!p_item);
|
||||
ERR_FAIL_NULL(p_item);
|
||||
select_single_item(p_item, get_root(), p_column);
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ void VideoStreamPlayer::_mix_audio() {
|
|||
|
||||
if (cc == 1) {
|
||||
AudioFrame *target = AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index, 0);
|
||||
ERR_FAIL_COND(!target);
|
||||
ERR_FAIL_NULL(target);
|
||||
|
||||
for (int j = 0; j < buffer_size; j++) {
|
||||
target[j] += buffer[j] * vol;
|
||||
|
@ -114,7 +114,7 @@ void VideoStreamPlayer::_mix_audio() {
|
|||
|
||||
for (int k = 0; k < cc; k++) {
|
||||
targets[k] = AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index, k);
|
||||
ERR_FAIL_COND(!targets[k]);
|
||||
ERR_FAIL_NULL(targets[k]);
|
||||
}
|
||||
|
||||
for (int j = 0; j < buffer_size; j++) {
|
||||
|
|
|
@ -381,7 +381,7 @@ void CanvasItem::update_draw_order() {
|
|||
if (canvas_group != StringName()) {
|
||||
get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE | SceneTree::GROUP_CALL_DEFERRED, canvas_group, "_top_level_raise_self");
|
||||
} else {
|
||||
ERR_FAIL_COND_MSG(!get_parent_item(), "Moved child is in incorrect state (no canvas group, no canvas item parent).");
|
||||
ERR_FAIL_NULL_MSG(get_parent_item(), "Moved child is in incorrect state (no canvas group, no canvas item parent).");
|
||||
RenderingServer::get_singleton()->canvas_item_set_draw_index(canvas_item, get_index());
|
||||
}
|
||||
}
|
||||
|
@ -1033,13 +1033,13 @@ Ref<InputEvent> CanvasItem::make_input_local(const Ref<InputEvent> &p_event) con
|
|||
|
||||
Vector2 CanvasItem::get_global_mouse_position() const {
|
||||
ERR_READ_THREAD_GUARD_V(Vector2());
|
||||
ERR_FAIL_COND_V(!get_viewport(), Vector2());
|
||||
ERR_FAIL_NULL_V(get_viewport(), Vector2());
|
||||
return get_canvas_transform().affine_inverse().xform(get_viewport()->get_mouse_position());
|
||||
}
|
||||
|
||||
Vector2 CanvasItem::get_local_mouse_position() const {
|
||||
ERR_READ_THREAD_GUARD_V(Vector2());
|
||||
ERR_FAIL_COND_V(!get_viewport(), Vector2());
|
||||
ERR_FAIL_NULL_V(get_viewport(), Vector2());
|
||||
|
||||
return get_global_transform().affine_inverse().xform(get_global_mouse_position());
|
||||
}
|
||||
|
|
|
@ -66,8 +66,8 @@ void Node::_notification(int p_notification) {
|
|||
} break;
|
||||
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
ERR_FAIL_COND(!get_viewport());
|
||||
ERR_FAIL_COND(!get_tree());
|
||||
ERR_FAIL_NULL(get_viewport());
|
||||
ERR_FAIL_NULL(get_tree());
|
||||
|
||||
// Update process mode.
|
||||
if (data.process_mode == PROCESS_MODE_INHERIT) {
|
||||
|
@ -121,8 +121,8 @@ void Node::_notification(int p_notification) {
|
|||
} break;
|
||||
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
ERR_FAIL_COND(!get_viewport());
|
||||
ERR_FAIL_COND(!get_tree());
|
||||
ERR_FAIL_NULL(get_viewport());
|
||||
ERR_FAIL_NULL(get_tree());
|
||||
|
||||
get_tree()->nodes_in_tree_count--;
|
||||
orphan_node_count++;
|
||||
|
@ -1989,7 +1989,7 @@ NodePath Node::get_path_to(const Node *p_node, bool p_use_unique_path) const {
|
|||
common_parent = common_parent->data.parent;
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(!common_parent, NodePath()); //nodes not in the same tree
|
||||
ERR_FAIL_NULL_V(common_parent, NodePath()); //nodes not in the same tree
|
||||
|
||||
visited.clear();
|
||||
|
||||
|
@ -2252,7 +2252,7 @@ void Node::_propagate_replace_owner(Node *p_owner, Node *p_by_owner) {
|
|||
|
||||
Ref<Tween> Node::create_tween() {
|
||||
ERR_THREAD_GUARD_V(Ref<Tween>());
|
||||
ERR_FAIL_COND_V_MSG(!data.tree, nullptr, "Can't create Tween when not inside scene tree.");
|
||||
ERR_FAIL_NULL_V_MSG(data.tree, nullptr, "Can't create Tween when not inside scene tree.");
|
||||
Ref<Tween> tween = get_tree()->create_tween();
|
||||
tween->bind_node(this);
|
||||
return tween;
|
||||
|
@ -2437,19 +2437,19 @@ Node *Node::_duplicate(int p_flags, HashMap<const Node *, Node *> *r_duplimap) c
|
|||
}
|
||||
#endif
|
||||
node = res->instantiate(edit_state);
|
||||
ERR_FAIL_COND_V(!node, nullptr);
|
||||
ERR_FAIL_NULL_V(node, nullptr);
|
||||
node->set_scene_instance_load_placeholder(get_scene_instance_load_placeholder());
|
||||
|
||||
instantiated = true;
|
||||
|
||||
} else {
|
||||
Object *obj = ClassDB::instantiate(get_class());
|
||||
ERR_FAIL_COND_V(!obj, nullptr);
|
||||
ERR_FAIL_NULL_V(obj, nullptr);
|
||||
node = Object::cast_to<Node>(obj);
|
||||
if (!node) {
|
||||
memdelete(obj);
|
||||
}
|
||||
ERR_FAIL_COND_V(!node, nullptr);
|
||||
ERR_FAIL_NULL_V(node, nullptr);
|
||||
}
|
||||
|
||||
if (!get_scene_file_path().is_empty()) { //an instance
|
||||
|
|
|
@ -443,7 +443,7 @@ void SceneTree::set_group(const StringName &p_group, const String &p_name, const
|
|||
}
|
||||
|
||||
void SceneTree::initialize() {
|
||||
ERR_FAIL_COND(!root);
|
||||
ERR_FAIL_NULL(root);
|
||||
initialized = true;
|
||||
root->_set_tree(this);
|
||||
MainLoop::initialize();
|
||||
|
@ -1095,7 +1095,7 @@ bool SceneTree::ProcessGroupSort::operator()(const ProcessGroup *p_left, const P
|
|||
void SceneTree::_remove_process_group(Node *p_node) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
ProcessGroup *pg = (ProcessGroup *)p_node->data.process_group;
|
||||
ERR_FAIL_COND(!pg);
|
||||
ERR_FAIL_NULL(pg);
|
||||
ERR_FAIL_COND(pg->removed);
|
||||
pg->removed = true;
|
||||
pg->owner = nullptr;
|
||||
|
@ -1105,7 +1105,7 @@ void SceneTree::_remove_process_group(Node *p_node) {
|
|||
|
||||
void SceneTree::_add_process_group(Node *p_node) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
ERR_FAIL_COND(!p_node);
|
||||
ERR_FAIL_NULL(p_node);
|
||||
|
||||
ProcessGroup *pg = memnew(ProcessGroup);
|
||||
|
||||
|
@ -1419,7 +1419,7 @@ Error SceneTree::change_scene_to_packed(const Ref<PackedScene> &p_scene) {
|
|||
ERR_FAIL_COND_V_MSG(p_scene.is_null(), ERR_INVALID_PARAMETER, "Can't change to a null scene. Use unload_current_scene() if you wish to unload it.");
|
||||
|
||||
Node *new_scene = p_scene->instantiate();
|
||||
ERR_FAIL_COND_V(!new_scene, ERR_CANT_CREATE);
|
||||
ERR_FAIL_NULL_V(new_scene, ERR_CANT_CREATE);
|
||||
|
||||
call_deferred(SNAME("_change_scene"), new_scene);
|
||||
return OK;
|
||||
|
@ -1427,7 +1427,7 @@ Error SceneTree::change_scene_to_packed(const Ref<PackedScene> &p_scene) {
|
|||
|
||||
Error SceneTree::reload_current_scene() {
|
||||
ERR_FAIL_COND_V_MSG(!Thread::is_main_thread(), ERR_INVALID_PARAMETER, "Reloading scene can only be done from the main thread.");
|
||||
ERR_FAIL_COND_V(!current_scene, ERR_UNCONFIGURED);
|
||||
ERR_FAIL_NULL_V(current_scene, ERR_UNCONFIGURED);
|
||||
String fname = current_scene->get_scene_file_path();
|
||||
return change_scene_to_file(fname);
|
||||
}
|
||||
|
|
|
@ -2317,7 +2317,6 @@ void Viewport::_gui_force_drag(Control *p_base, const Variant &p_data, Control *
|
|||
|
||||
void Viewport::_gui_set_drag_preview(Control *p_base, Control *p_control) {
|
||||
ERR_FAIL_NULL(p_control);
|
||||
ERR_FAIL_COND(!Object::cast_to<Control>((Object *)p_control));
|
||||
ERR_FAIL_COND(p_control->is_inside_tree());
|
||||
ERR_FAIL_COND(p_control->get_parent() != nullptr);
|
||||
|
||||
|
|
|
@ -1774,7 +1774,7 @@ Rect2i Window::get_usable_parent_rect() const {
|
|||
} else {
|
||||
const Window *w = is_visible() ? this : get_parent_visible_window();
|
||||
//find a parent that can contain us
|
||||
ERR_FAIL_COND_V(!w, Rect2());
|
||||
ERR_FAIL_NULL_V(w, Rect2());
|
||||
|
||||
parent_rect = DisplayServer::get_singleton()->screen_get_usable_rect(DisplayServer::get_singleton()->window_get_current_screen(w->get_window_id()));
|
||||
}
|
||||
|
@ -2335,9 +2335,9 @@ Rect2i Window::get_parent_rect() const {
|
|||
if (is_embedded()) {
|
||||
//viewport
|
||||
Node *n = get_parent();
|
||||
ERR_FAIL_COND_V(!n, Rect2i());
|
||||
ERR_FAIL_NULL_V(n, Rect2i());
|
||||
Viewport *p = n->get_viewport();
|
||||
ERR_FAIL_COND_V(!p, Rect2i());
|
||||
ERR_FAIL_NULL_V(p, Rect2i());
|
||||
|
||||
return p->get_visible_rect();
|
||||
} else {
|
||||
|
|
|
@ -939,7 +939,7 @@ Vector<Face3> ImporterMesh::get_faces() const {
|
|||
}
|
||||
|
||||
Vector<Ref<Shape3D>> ImporterMesh::convex_decompose(const Ref<MeshConvexDecompositionSettings> &p_settings) const {
|
||||
ERR_FAIL_COND_V(!Mesh::convex_decomposition_function, Vector<Ref<Shape3D>>());
|
||||
ERR_FAIL_NULL_V(Mesh::convex_decomposition_function, Vector<Ref<Shape3D>>());
|
||||
|
||||
const Vector<Face3> faces = get_faces();
|
||||
int face_count = faces.size();
|
||||
|
@ -1102,7 +1102,7 @@ struct EditorSceneFormatImporterMeshLightmapSurface {
|
|||
static const uint32_t custom_shift[RS::ARRAY_CUSTOM_COUNT] = { Mesh::ARRAY_FORMAT_CUSTOM0_SHIFT, Mesh::ARRAY_FORMAT_CUSTOM1_SHIFT, Mesh::ARRAY_FORMAT_CUSTOM2_SHIFT, Mesh::ARRAY_FORMAT_CUSTOM3_SHIFT };
|
||||
|
||||
Error ImporterMesh::lightmap_unwrap_cached(const Transform3D &p_base_transform, float p_texel_size, const Vector<uint8_t> &p_src_cache, Vector<uint8_t> &r_dst_cache) {
|
||||
ERR_FAIL_COND_V(!array_mesh_lightmap_unwrap_callback, ERR_UNCONFIGURED);
|
||||
ERR_FAIL_NULL_V(array_mesh_lightmap_unwrap_callback, ERR_UNCONFIGURED);
|
||||
ERR_FAIL_COND_V_MSG(blend_shapes.size() != 0, ERR_UNAVAILABLE, "Can't unwrap mesh with blend shapes.");
|
||||
|
||||
LocalVector<float> vertices;
|
||||
|
|
|
@ -895,7 +895,7 @@ void Mesh::clear_cache() const {
|
|||
}
|
||||
|
||||
Vector<Ref<Shape3D>> Mesh::convex_decompose(const Ref<MeshConvexDecompositionSettings> &p_settings) const {
|
||||
ERR_FAIL_COND_V(!convex_decomposition_function, Vector<Ref<Shape3D>>());
|
||||
ERR_FAIL_NULL_V(convex_decomposition_function, Vector<Ref<Shape3D>>());
|
||||
|
||||
Ref<TriangleMesh> tm = generate_triangle_mesh();
|
||||
ERR_FAIL_COND_V(!tm.is_valid(), Vector<Ref<Shape3D>>());
|
||||
|
@ -2014,7 +2014,7 @@ Error ArrayMesh::lightmap_unwrap(const Transform3D &p_base_transform, float p_te
|
|||
}
|
||||
|
||||
Error ArrayMesh::lightmap_unwrap_cached(const Transform3D &p_base_transform, float p_texel_size, const Vector<uint8_t> &p_src_cache, Vector<uint8_t> &r_dst_cache, bool p_generate_cache) {
|
||||
ERR_FAIL_COND_V(!array_mesh_lightmap_unwrap_callback, ERR_UNCONFIGURED);
|
||||
ERR_FAIL_NULL_V(array_mesh_lightmap_unwrap_callback, ERR_UNCONFIGURED);
|
||||
ERR_FAIL_COND_V_MSG(blend_shapes.size() != 0, ERR_UNAVAILABLE, "Can't unwrap mesh with blend shapes.");
|
||||
ERR_FAIL_COND_V_MSG(p_texel_size <= 0.0f, ERR_PARAMETER_RANGE_ERROR, "Texel size must be greater than 0.");
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
|
|||
Ref<PackedScene> sdata = props[base_scene_idx];
|
||||
ERR_FAIL_COND_V(!sdata.is_valid(), nullptr);
|
||||
node = sdata->instantiate(p_edit_state == GEN_EDIT_STATE_DISABLED ? PackedScene::GEN_EDIT_STATE_DISABLED : PackedScene::GEN_EDIT_STATE_INSTANCE); //only main gets main edit state
|
||||
ERR_FAIL_COND_V(!node, nullptr);
|
||||
ERR_FAIL_NULL_V(node, nullptr);
|
||||
if (p_edit_state != GEN_EDIT_STATE_DISABLED) {
|
||||
node->set_scene_inherited_state(sdata->get_state());
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
|
|||
Ref<PackedScene> sdata = ResourceLoader::load(scene_path, "PackedScene");
|
||||
ERR_FAIL_COND_V(!sdata.is_valid(), nullptr);
|
||||
node = sdata->instantiate(p_edit_state == GEN_EDIT_STATE_DISABLED ? PackedScene::GEN_EDIT_STATE_DISABLED : PackedScene::GEN_EDIT_STATE_INSTANCE);
|
||||
ERR_FAIL_COND_V(!node, nullptr);
|
||||
ERR_FAIL_NULL_V(node, nullptr);
|
||||
} else {
|
||||
InstancePlaceholder *ip = memnew(InstancePlaceholder);
|
||||
ip->set_instance_path(scene_path);
|
||||
|
@ -166,7 +166,7 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
|
|||
Ref<PackedScene> sdata = props[n.instance & FLAG_MASK];
|
||||
ERR_FAIL_COND_V(!sdata.is_valid(), nullptr);
|
||||
node = sdata->instantiate(p_edit_state == GEN_EDIT_STATE_DISABLED ? PackedScene::GEN_EDIT_STATE_DISABLED : PackedScene::GEN_EDIT_STATE_INSTANCE);
|
||||
ERR_FAIL_COND_V(!node, nullptr);
|
||||
ERR_FAIL_NULL_V(node, nullptr);
|
||||
}
|
||||
|
||||
} else if (n.type == TYPE_INSTANTIATED) {
|
||||
|
|
|
@ -185,7 +185,7 @@ void SkeletonModification2DPhysicalBones::set_physical_bone_chain_length(int p_l
|
|||
}
|
||||
|
||||
void SkeletonModification2DPhysicalBones::fetch_physical_bones() {
|
||||
ERR_FAIL_COND_MSG(!stack, "No modification stack found! Cannot fetch physical bones!");
|
||||
ERR_FAIL_NULL_MSG(stack, "No modification stack found! Cannot fetch physical bones!");
|
||||
ERR_FAIL_COND_MSG(!stack->skeleton, "No skeleton found! Cannot fetch physical bones!");
|
||||
|
||||
physical_bone_chain.clear();
|
||||
|
|
|
@ -386,7 +386,7 @@ void PortableCompressedTexture2D::_set_data(const Vector<uint8_t> &p_data) {
|
|||
|
||||
} break;
|
||||
case COMPRESSION_MODE_BASIS_UNIVERSAL: {
|
||||
ERR_FAIL_COND(!Image::basis_universal_unpacker_ptr);
|
||||
ERR_FAIL_NULL(Image::basis_universal_unpacker_ptr);
|
||||
image = Image::basis_universal_unpacker_ptr(data, data_size);
|
||||
|
||||
} break;
|
||||
|
@ -812,21 +812,21 @@ void CompressedTexture2D::set_path(const String &p_path, bool p_take_over) {
|
|||
void CompressedTexture2D::_requested_3d(void *p_ud) {
|
||||
CompressedTexture2D *ct = (CompressedTexture2D *)p_ud;
|
||||
Ref<CompressedTexture2D> ctex(ct);
|
||||
ERR_FAIL_COND(!request_3d_callback);
|
||||
ERR_FAIL_NULL(request_3d_callback);
|
||||
request_3d_callback(ctex);
|
||||
}
|
||||
|
||||
void CompressedTexture2D::_requested_roughness(void *p_ud, const String &p_normal_path, RS::TextureDetectRoughnessChannel p_roughness_channel) {
|
||||
CompressedTexture2D *ct = (CompressedTexture2D *)p_ud;
|
||||
Ref<CompressedTexture2D> ctex(ct);
|
||||
ERR_FAIL_COND(!request_roughness_callback);
|
||||
ERR_FAIL_NULL(request_roughness_callback);
|
||||
request_roughness_callback(ctex, p_normal_path, p_roughness_channel);
|
||||
}
|
||||
|
||||
void CompressedTexture2D::_requested_normal(void *p_ud) {
|
||||
CompressedTexture2D *ct = (CompressedTexture2D *)p_ud;
|
||||
Ref<CompressedTexture2D> ctex(ct);
|
||||
ERR_FAIL_COND(!request_normal_callback);
|
||||
ERR_FAIL_NULL(request_normal_callback);
|
||||
request_normal_callback(ctex);
|
||||
}
|
||||
|
||||
|
|
|
@ -1610,7 +1610,7 @@ Vector<Point2> TileSet::get_terrain_peering_bit_polygon(int p_terrain_set, TileS
|
|||
#define TERRAIN_ALPHA 0.6
|
||||
|
||||
void TileSet::draw_terrains(CanvasItem *p_canvas_item, Transform2D p_transform, const TileData *p_tile_data) {
|
||||
ERR_FAIL_COND(!p_tile_data);
|
||||
ERR_FAIL_NULL(p_tile_data);
|
||||
|
||||
if (terrain_bits_meshes_dirty) {
|
||||
// Recompute the meshes.
|
||||
|
|
Loading…
Reference in New Issue