diff options
Diffstat (limited to 'scene')
134 files changed, 1463 insertions, 1357 deletions
diff --git a/scene/2d/animated_sprite_2d.cpp b/scene/2d/animated_sprite_2d.cpp index 4cedfc0c20..fc34f967ce 100644 --- a/scene/2d/animated_sprite_2d.cpp +++ b/scene/2d/animated_sprite_2d.cpp @@ -652,7 +652,7 @@ void AnimatedSprite2D::_reset_timeout() { void AnimatedSprite2D::set_animation(const StringName &p_animation) { - ERR_FAIL_COND_MSG(frames == NULL, vformat("There is no animation with name '%s'.", p_animation)); + ERR_FAIL_COND_MSG(frames == nullptr, vformat("There is no animation with name '%s'.", p_animation)); ERR_FAIL_COND_MSG(frames->get_animation_names().find(p_animation) == -1, vformat("There is no animation with name '%s'.", p_animation)); if (animation == p_animation) diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index 4ccff07416..c46b6eeb5c 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -407,8 +407,8 @@ void Area2D::set_monitoring(bool p_enable) { PhysicsServer2D::get_singleton()->area_set_area_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_area_inout); } else { - PhysicsServer2D::get_singleton()->area_set_monitor_callback(get_rid(), NULL, StringName()); - PhysicsServer2D::get_singleton()->area_set_area_monitor_callback(get_rid(), NULL, StringName()); + PhysicsServer2D::get_singleton()->area_set_monitor_callback(get_rid(), nullptr, StringName()); + PhysicsServer2D::get_singleton()->area_set_area_monitor_callback(get_rid(), nullptr, StringName()); _clear_monitoring(); } } diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index 6d8d981974..d8af14a3fb 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -264,7 +264,7 @@ void Camera2D::_notification(int p_what) { } remove_from_group(group_name); remove_from_group(canvas_group_name); - viewport = NULL; + viewport = nullptr; } break; case NOTIFICATION_DRAW: { @@ -433,7 +433,7 @@ void Camera2D::clear_current() { current = false; if (is_inside_tree()) { - get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, group_name, "_make_current", (Object *)(NULL)); + get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, group_name, "_make_current", (Object *)nullptr); } } @@ -794,7 +794,7 @@ Camera2D::Camera2D() { first = true; smoothing_enabled = false; limit_smoothing_enabled = false; - custom_viewport = NULL; + custom_viewport = nullptr; process_mode = CAMERA2D_PROCESS_IDLE; diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index 5535043432..d82f4a2f2b 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -233,7 +233,7 @@ Transform2D CollisionObject2D::shape_owner_get_transform(uint32_t p_owner) const Object *CollisionObject2D::shape_owner_get_owner(uint32_t p_owner) const { - ERR_FAIL_COND_V(!shapes.has(p_owner), NULL); + ERR_FAIL_COND_V(!shapes.has(p_owner), nullptr); return shapes[p_owner].owner; } diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h index 8874f61bb7..e931f20f40 100644 --- a/scene/2d/collision_object_2d.h +++ b/scene/2d/collision_object_2d.h @@ -60,7 +60,7 @@ class CollisionObject2D : public Node2D { disabled = false; one_way_collision = false; one_way_collision_margin = 0; - owner = NULL; + owner = nullptr; } }; diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index 5880045e90..1e48b2d67f 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -129,7 +129,7 @@ void CollisionPolygon2D::_notification(int p_what) { parent->remove_shape_owner(owner_id); } owner_id = 0; - parent = NULL; + parent = nullptr; } break; case NOTIFICATION_DRAW: { @@ -319,7 +319,7 @@ CollisionPolygon2D::CollisionPolygon2D() { aabb = Rect2(-10, -10, 20, 20); build_mode = BUILD_SOLIDS; set_notify_local_transform(true); - parent = NULL; + parent = nullptr; owner_id = 0; disabled = false; one_way_collision = false; diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp index cb2953cc15..b1dbc57c94 100644 --- a/scene/2d/collision_shape_2d.cpp +++ b/scene/2d/collision_shape_2d.cpp @@ -96,7 +96,7 @@ void CollisionShape2D::_notification(int p_what) { parent->remove_shape_owner(owner_id); } owner_id = 0; - parent = NULL; + parent = nullptr; } break; case NOTIFICATION_DRAW: { @@ -249,7 +249,7 @@ CollisionShape2D::CollisionShape2D() { rect = Rect2(-Point2(10, 10), Point2(20, 20)); set_notify_local_transform(true); owner_id = 0; - parent = NULL; + parent = nullptr; disabled = false; one_way_collision = false; one_way_collision_margin = 1.0; diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index 47465f727e..0a6b091a51 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -976,7 +976,7 @@ void CPUParticles2D::_update_particle_data_buffer() { int pc = particles.size(); int *ow; - int *order = NULL; + int *order = nullptr; float *w = particle_data.ptrw(); const Particle *r = particles.ptr(); diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp index 6cbb0d2a39..4d49f4762f 100644 --- a/scene/2d/joints_2d.cpp +++ b/scene/2d/joints_2d.cpp @@ -49,8 +49,8 @@ void Joint2D::_update_joint(bool p_only_free) { if (p_only_free || !is_inside_tree()) return; - Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)NULL; - Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)NULL; + Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)nullptr; + Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)nullptr; if (!node_a || !node_b) return; diff --git a/scene/2d/line_builder.cpp b/scene/2d/line_builder.cpp index 3385f2fbe0..6b06f2227a 100644 --- a/scene/2d/line_builder.cpp +++ b/scene/2d/line_builder.cpp @@ -95,9 +95,9 @@ static inline Vector2 interpolate(const Rect2 &r, const Vector2 &v) { LineBuilder::LineBuilder() { joint_mode = Line2D::LINE_JOINT_SHARP; width = 10; - curve = NULL; + curve = nullptr; default_color = Color(0.4, 0.5, 1); - gradient = NULL; + gradient = nullptr; sharp_limit = 2.f; round_precision = 8; begin_cap_mode = Line2D::LINE_CAP_NONE; @@ -147,8 +147,8 @@ void LineBuilder::build() { float current_distance1 = 0.f; float total_distance = 0.f; float width_factor = 1.f; - _interpolate_color = gradient != NULL; - bool retrieve_curve = curve != NULL; + _interpolate_color = gradient != nullptr; + bool retrieve_curve = curve != nullptr; bool distance_required = _interpolate_color || retrieve_curve || texture_mode == Line2D::LINE_TEXTURE_TILE || diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp index c70d5ab1fe..32da46e8a8 100644 --- a/scene/2d/navigation_agent_2d.cpp +++ b/scene/2d/navigation_agent_2d.cpp @@ -98,12 +98,12 @@ void NavigationAgent2D::_notification(int p_what) { // Search the navigation node and set it { - Navigation2D *nav = NULL; + Navigation2D *nav = nullptr; Node *p = get_parent(); - while (p != NULL) { + while (p != nullptr) { nav = Object::cast_to<Navigation2D>(p); - if (nav != NULL) - p = NULL; + if (nav != nullptr) + p = nullptr; else p = p->get_parent(); } @@ -114,8 +114,8 @@ void NavigationAgent2D::_notification(int p_what) { set_physics_process_internal(true); } break; case NOTIFICATION_EXIT_TREE: { - agent_parent = NULL; - set_navigation(NULL); + agent_parent = nullptr; + set_navigation(nullptr); set_physics_process_internal(false); } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { @@ -134,8 +134,8 @@ void NavigationAgent2D::_notification(int p_what) { } NavigationAgent2D::NavigationAgent2D() : - agent_parent(NULL), - navigation(NULL), + agent_parent(nullptr), + navigation(nullptr), agent(RID()), target_desired_distance(1.0), path_max_distance(3.0), @@ -160,12 +160,12 @@ void NavigationAgent2D::set_navigation(Navigation2D *p_nav) { return; // Pointless navigation = p_nav; - NavigationServer2D::get_singleton()->agent_set_map(agent, navigation == NULL ? RID() : navigation->get_rid()); + NavigationServer2D::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid()); } void NavigationAgent2D::set_navigation_node(Node *p_nav) { Navigation2D *nav = Object::cast_to<Navigation2D>(p_nav); - ERR_FAIL_COND(nav == NULL); + ERR_FAIL_COND(nav == nullptr); set_navigation(nav); } @@ -225,7 +225,7 @@ Vector2 NavigationAgent2D::get_target_location() const { Vector2 NavigationAgent2D::get_next_location() { update_navigation(); if (navigation_path.size() == 0) { - ERR_FAIL_COND_V(agent_parent == NULL, Vector2()); + ERR_FAIL_COND_V(agent_parent == nullptr, Vector2()); return agent_parent->get_global_transform().get_origin(); } else { return navigation_path[nav_path_index]; @@ -233,7 +233,7 @@ Vector2 NavigationAgent2D::get_next_location() { } real_t NavigationAgent2D::distance_to_target() const { - ERR_FAIL_COND_V(agent_parent == NULL, 0.0); + ERR_FAIL_COND_V(agent_parent == nullptr, 0.0); return agent_parent->get_global_transform().get_origin().distance_to(target_location); } @@ -288,8 +288,8 @@ String NavigationAgent2D::get_configuration_warning() const { void NavigationAgent2D::update_navigation() { - if (agent_parent == NULL) return; - if (navigation == NULL) return; + if (agent_parent == nullptr) return; + if (navigation == nullptr) return; if (update_frame_id == Engine::get_singleton()->get_physics_frames()) return; update_frame_id = Engine::get_singleton()->get_physics_frames(); diff --git a/scene/2d/navigation_obstacle_2d.cpp b/scene/2d/navigation_obstacle_2d.cpp index 4c6e777e73..50d02ca507 100644 --- a/scene/2d/navigation_obstacle_2d.cpp +++ b/scene/2d/navigation_obstacle_2d.cpp @@ -49,12 +49,12 @@ void NavigationObstacle2D::_notification(int p_what) { // Search the navigation node and set it { - Navigation2D *nav = NULL; + Navigation2D *nav = nullptr; Node *p = get_parent(); - while (p != NULL) { + while (p != nullptr) { nav = Object::cast_to<Navigation2D>(p); - if (nav != NULL) - p = NULL; + if (nav != nullptr) + p = nullptr; else p = p->get_parent(); } @@ -65,7 +65,7 @@ void NavigationObstacle2D::_notification(int p_what) { set_physics_process_internal(true); } break; case NOTIFICATION_EXIT_TREE: { - set_navigation(NULL); + set_navigation(nullptr); set_physics_process_internal(false); } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { @@ -79,7 +79,7 @@ void NavigationObstacle2D::_notification(int p_what) { } NavigationObstacle2D::NavigationObstacle2D() : - navigation(NULL), + navigation(nullptr), agent(RID()) { agent = NavigationServer2D::get_singleton()->agent_create(); } @@ -94,12 +94,12 @@ void NavigationObstacle2D::set_navigation(Navigation2D *p_nav) { return; // Pointless navigation = p_nav; - NavigationServer2D::get_singleton()->agent_set_map(agent, navigation == NULL ? RID() : navigation->get_rid()); + NavigationServer2D::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid()); } void NavigationObstacle2D::set_navigation_node(Node *p_nav) { Navigation2D *nav = Object::cast_to<Navigation2D>(p_nav); - ERR_FAIL_COND(nav == NULL); + ERR_FAIL_COND(nav == nullptr); set_navigation(nav); } diff --git a/scene/2d/navigation_region_2d.cpp b/scene/2d/navigation_region_2d.cpp index f0839b4597..d77fd5b097 100644 --- a/scene/2d/navigation_region_2d.cpp +++ b/scene/2d/navigation_region_2d.cpp @@ -281,7 +281,7 @@ void NavigationPolygon::make_polygons_from_outlines() { for (int l = 0; l < olsize2; l++) { - if (Geometry::segment_intersects_segment_2d(r[0], outside_point, r2[l], r2[(l + 1) % olsize2], NULL)) { + if (Geometry::segment_intersects_segment_2d(r[0], outside_point, r2[l], r2[(l + 1) % olsize2], nullptr)) { interscount++; } } @@ -449,7 +449,7 @@ void NavigationRegion2D::_notification(int p_what) { NavigationServer2D::get_singleton()->region_set_map(region, RID()); } - navigation = NULL; + navigation = nullptr; } break; case NOTIFICATION_DRAW: { @@ -574,7 +574,7 @@ NavigationRegion2D::NavigationRegion2D() { set_notify_transform(true); region = NavigationServer2D::get_singleton()->region_create(); - navigation = NULL; + navigation = nullptr; } NavigationRegion2D::~NavigationRegion2D() { diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp index 3e807f12dc..d55b21bc24 100644 --- a/scene/2d/path_2d.cpp +++ b/scene/2d/path_2d.cpp @@ -242,7 +242,7 @@ void PathFollow2D::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { - path = NULL; + path = nullptr; } break; } } @@ -421,7 +421,7 @@ PathFollow2D::PathFollow2D() { offset = 0; h_offset = 0; v_offset = 0; - path = NULL; + path = nullptr; rotate = true; cubic = true; loop = true; diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index d866906ca5..21dc9537ec 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -362,7 +362,7 @@ struct _RigidBody2DInOut { bool RigidBody2D::_test_motion(const Vector2 &p_motion, bool p_infinite_inertia, float p_margin, const Ref<PhysicsTestMotionResult2D> &p_result) { - PhysicsServer2D::MotionResult *r = NULL; + PhysicsServer2D::MotionResult *r = nullptr; if (p_result.is_valid()) r = p_result->get_result_ptr(); return PhysicsServer2D::get_singleton()->body_test_motion(get_rid(), get_global_transform(), p_motion, p_infinite_inertia, p_margin, r); @@ -474,7 +474,7 @@ void RigidBody2D::_direct_state_changed(Object *p_state) { contact_monitor->locked = false; } - state = NULL; + state = nullptr; } void RigidBody2D::set_mode(Mode p_mode) { @@ -780,7 +780,7 @@ void RigidBody2D::set_contact_monitor(bool p_enabled) { } memdelete(contact_monitor); - contact_monitor = NULL; + contact_monitor = nullptr; } else { contact_monitor = memnew(ContactMonitor); @@ -790,7 +790,7 @@ void RigidBody2D::set_contact_monitor(bool p_enabled) { bool RigidBody2D::is_contact_monitor_enabled() const { - return contact_monitor != NULL; + return contact_monitor != nullptr; } void RigidBody2D::_notification(int p_what) { @@ -950,14 +950,14 @@ RigidBody2D::RigidBody2D() : angular_damp = -1; max_contacts_reported = 0; - state = NULL; + state = nullptr; angular_velocity = 0; sleeping = false; ccd_mode = CCD_MODE_DISABLED; custom_integrator = false; - contact_monitor = NULL; + contact_monitor = nullptr; can_sleep = true; PhysicsServer2D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); @@ -1281,7 +1281,7 @@ void KinematicBody2D::set_sync_to_physics(bool p_enable) { set_only_update_transform_changes(true); set_notify_local_transform(true); } else { - PhysicsServer2D::get_singleton()->body_set_force_integration_callback(get_rid(), NULL, ""); + PhysicsServer2D::get_singleton()->body_set_force_integration_callback(get_rid(), nullptr, ""); set_only_update_transform_changes(false); set_notify_local_transform(false); } @@ -1368,12 +1368,12 @@ KinematicBody2D::KinematicBody2D() : } KinematicBody2D::~KinematicBody2D() { if (motion_cache.is_valid()) { - motion_cache->owner = NULL; + motion_cache->owner = nullptr; } for (int i = 0; i < slide_colliders.size(); i++) { if (slide_colliders[i].is_valid()) { - slide_colliders.write[i]->owner = NULL; + slide_colliders.write[i]->owner = nullptr; } } } @@ -1394,7 +1394,7 @@ Vector2 KinematicCollision2D::get_remainder() const { return collision.remainder; } Object *KinematicCollision2D::get_local_shape() const { - if (!owner) return NULL; + if (!owner) return nullptr; uint32_t ownerid = owner->shape_find_owner(collision.local_shape); return owner->shape_owner_get_owner(ownerid); } @@ -1405,7 +1405,7 @@ Object *KinematicCollision2D::get_collider() const { return ObjectDB::get_instance(collision.collider); } - return NULL; + return nullptr; } ObjectID KinematicCollision2D::get_collider_id() const { @@ -1422,7 +1422,7 @@ Object *KinematicCollision2D::get_collider_shape() const { } } - return NULL; + return nullptr; } int KinematicCollision2D::get_collider_shape_index() const { @@ -1468,5 +1468,5 @@ KinematicCollision2D::KinematicCollision2D() { collision.collider_shape = 0; collision.local_shape = 0; - owner = NULL; + owner = nullptr; } diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index 8d20053c6e..84c1828b47 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -103,7 +103,7 @@ void Polygon2D::_notification(int p_what) { if (polygon.size() < 3) return; - Skeleton2D *skeleton_node = NULL; + Skeleton2D *skeleton_node = nullptr; if (has_node(skeleton)) { skeleton_node = Object::cast_to<Skeleton2D>(get_node(skeleton)); } diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp index ed971b1c3a..9d6c7304ce 100644 --- a/scene/2d/ray_cast_2d.cpp +++ b/scene/2d/ray_cast_2d.cpp @@ -79,7 +79,7 @@ bool RayCast2D::is_colliding() const { Object *RayCast2D::get_collider() const { if (against.is_null()) - return NULL; + return nullptr; return ObjectDB::get_instance(against); } diff --git a/scene/2d/skeleton_2d.cpp b/scene/2d/skeleton_2d.cpp index 2be6b6a75c..86c9ff6076 100644 --- a/scene/2d/skeleton_2d.cpp +++ b/scene/2d/skeleton_2d.cpp @@ -35,7 +35,7 @@ void Bone2D::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { Node *parent = get_parent(); parent_bone = Object::cast_to<Bone2D>(parent); - skeleton = NULL; + skeleton = nullptr; while (parent) { skeleton = Object::cast_to<Skeleton2D>(parent); if (skeleton) @@ -73,9 +73,9 @@ void Bone2D::_notification(int p_what) { } } skeleton->_make_bone_setup_dirty(); - skeleton = NULL; + skeleton = nullptr; } - parent_bone = NULL; + parent_bone = nullptr; } } void Bone2D::_bind_methods() { @@ -157,8 +157,8 @@ String Bone2D::get_configuration_warning() const { } Bone2D::Bone2D() { - skeleton = NULL; - parent_bone = NULL; + skeleton = nullptr; + parent_bone = nullptr; skeleton_index = -1; default_length = 16; set_notify_local_transform(true); @@ -257,8 +257,8 @@ int Skeleton2D::get_bone_count() const { Bone2D *Skeleton2D::get_bone(int p_idx) { - ERR_FAIL_COND_V(!is_inside_tree(), NULL); - ERR_FAIL_INDEX_V(p_idx, bones.size(), NULL); + ERR_FAIL_COND_V(!is_inside_tree(), nullptr); + ERR_FAIL_INDEX_V(p_idx, bones.size(), nullptr); return bones[p_idx].bone; } diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index c468389040..1cf12e4421 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -103,8 +103,8 @@ void TileMap::_notification(int p_what) { q.occluder_instances.clear(); } - collision_parent = NULL; - navigation = NULL; + collision_parent = nullptr; + navigation = nullptr; } break; @@ -314,7 +314,7 @@ void TileMap::_add_shape(int &shape_idx, const Quadrant &p_q, const Ref<Shape2D> int real_index = collision_parent->shape_owner_get_shape_index(p_q.shape_owner_id, shape_idx); RID rid = collision_parent->get_rid(); - if (Object::cast_to<Area2D>(collision_parent) != NULL) { + if (Object::cast_to<Area2D>(collision_parent) != nullptr) { ps->area_set_shape_transform(rid, real_index, get_transform() * xform); } else { ps->body_set_shape_transform(rid, real_index, get_transform() * xform); @@ -921,7 +921,7 @@ void TileMap::make_bitmask_area_dirty(const Vector2 &p_pos) { for (int x = p_pos.x - 1; x <= p_pos.x + 1; x++) { for (int y = p_pos.y - 1; y <= p_pos.y + 1; y++) { PosKey p(x, y); - if (dirty_bitmask.find(p) == NULL) { + if (dirty_bitmask.find(p) == nullptr) { dirty_bitmask.push_back(p); } } @@ -962,7 +962,7 @@ void TileMap::update_cell_bitmask(int p_x, int p_y) { ERR_FAIL_COND_MSG(tile_set.is_null(), "Cannot update cell bitmask if Tileset is not open."); PosKey p(p_x, p_y); Map<PosKey, Cell>::Element *E = tile_map.find(p); - if (E != NULL) { + if (E != nullptr) { int id = get_cell(p_x, p_y); if (tile_set->tile_get_tile_mode(id) == TileSet::AUTO_TILE) { uint16_t mask = 0; @@ -1368,7 +1368,7 @@ void TileMap::set_collision_use_parent(bool p_use_parent) { if (use_parent && is_inside_tree()) { collision_parent = Object::cast_to<CollisionObject2D>(get_parent()); } else { - collision_parent = NULL; + collision_parent = nullptr; } _recreate_quadrants(); @@ -1959,9 +1959,9 @@ TileMap::TileMap() { mode = MODE_SQUARE; half_offset = HALF_OFFSET_DISABLED; use_parent = false; - collision_parent = NULL; + collision_parent = nullptr; use_kinematic = false; - navigation = NULL; + navigation = nullptr; y_sort_mode = false; compatibility_mode = false; centered_textures = false; diff --git a/scene/3d/area_3d.cpp b/scene/3d/area_3d.cpp index 5b02a91793..17ae553e5e 100644 --- a/scene/3d/area_3d.cpp +++ b/scene/3d/area_3d.cpp @@ -301,8 +301,8 @@ void Area3D::set_monitoring(bool p_enable) { PhysicsServer3D::get_singleton()->area_set_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_body_inout); PhysicsServer3D::get_singleton()->area_set_area_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_area_inout); } else { - PhysicsServer3D::get_singleton()->area_set_monitor_callback(get_rid(), NULL, StringName()); - PhysicsServer3D::get_singleton()->area_set_area_monitor_callback(get_rid(), NULL, StringName()); + PhysicsServer3D::get_singleton()->area_set_monitor_callback(get_rid(), nullptr, StringName()); + PhysicsServer3D::get_singleton()->area_set_area_monitor_callback(get_rid(), nullptr, StringName()); _clear_monitoring(); } } diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index 9f5170fa98..097368853e 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -401,7 +401,7 @@ void AudioStreamPlayer3D::_notification(int p_what) { PhysicsDirectSpaceState3D::ShapeResult sr[MAX_INTERSECT_AREAS]; int areas = space_state->intersect_point(global_pos, sr, MAX_INTERSECT_AREAS, Set<RID>(), area_mask, false, true); - Area3D *area = NULL; + Area3D *area = nullptr; for (int i = 0; i < areas; i++) { if (!sr[i].collider) diff --git a/scene/3d/audio_stream_player_3d.h b/scene/3d/audio_stream_player_3d.h index 1cce0c77d5..13e08339e2 100644 --- a/scene/3d/audio_stream_player_3d.h +++ b/scene/3d/audio_stream_player_3d.h @@ -82,7 +82,7 @@ private: Output() { filter_gain = 0; - viewport = NULL; + viewport = nullptr; reverb_bus_index = -1; bus_index = -1; } diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp index 05e3f3fefa..6bde56104e 100644 --- a/scene/3d/baked_lightmap.cpp +++ b/scene/3d/baked_lightmap.cpp @@ -193,9 +193,9 @@ BakedLightmapData::~BakedLightmapData() { /////////////////////////// -BakedLightmap::BakeBeginFunc BakedLightmap::bake_begin_function = NULL; -BakedLightmap::BakeStepFunc BakedLightmap::bake_step_function = NULL; -BakedLightmap::BakeEndFunc BakedLightmap::bake_end_function = NULL; +BakedLightmap::BakeBeginFunc BakedLightmap::bake_begin_function = nullptr; +BakedLightmap::BakeStepFunc BakedLightmap::bake_step_function = nullptr; +BakedLightmap::BakeEndFunc BakedLightmap::bake_end_function = nullptr; void BakedLightmap::set_bake_cell_size(float p_cell_size) { bake_cell_size = p_cell_size; diff --git a/scene/3d/camera_3d.cpp b/scene/3d/camera_3d.cpp index 7980c15f89..706c49b43b 100644 --- a/scene/3d/camera_3d.cpp +++ b/scene/3d/camera_3d.cpp @@ -138,7 +138,7 @@ void Camera3D::_notification(int p_what) { if (viewport) { viewport->_camera_remove(this); - viewport = NULL; + viewport = nullptr; } } break; @@ -241,7 +241,7 @@ void Camera3D::clear_current(bool p_enable_next) { return; if (get_viewport()->get_camera() == this) { - get_viewport()->_camera_set(NULL); + get_viewport()->_camera_set(nullptr); if (p_enable_next) { get_viewport()->_camera_make_next_current(this); @@ -413,23 +413,6 @@ Vector3 Camera3D::project_position(const Point2 &p_point, float p_z_depth) const return get_camera_transform().xform(p); } -/* -void Camera::_camera_make_current(Node *p_camera) { - - - if (p_camera==this) { - RenderingServer::get_singleton()->viewport_attach_camera(viewport_id,camera); - active=true; - } else { - if (active && p_camera==NULL) { - //detech camera because no one else will claim it - RenderingServer::get_singleton()->viewport_attach_camera(viewport_id,RID()); - } - active=false; - } -} -*/ - void Camera3D::set_environment(const Ref<Environment> &p_environment) { environment = p_environment; @@ -703,7 +686,7 @@ Camera3D::Camera3D() { near = 0; far = 0; current = false; - viewport = NULL; + viewport = nullptr; force_change = false; mode = PROJECTION_PERSPECTIVE; set_perspective(70.0, 0.05, 100.0); diff --git a/scene/3d/collision_object_3d.cpp b/scene/3d/collision_object_3d.cpp index 6ee0512546..e6cd7bfe7e 100644 --- a/scene/3d/collision_object_3d.cpp +++ b/scene/3d/collision_object_3d.cpp @@ -245,7 +245,7 @@ Transform CollisionObject3D::shape_owner_get_transform(uint32_t p_owner) const { Object *CollisionObject3D::shape_owner_get_owner(uint32_t p_owner) const { - ERR_FAIL_COND_V(!shapes.has(p_owner), NULL); + ERR_FAIL_COND_V(!shapes.has(p_owner), nullptr); return shapes[p_owner].owner; } diff --git a/scene/3d/collision_object_3d.h b/scene/3d/collision_object_3d.h index 6a70f56caa..67d3aed3c8 100644 --- a/scene/3d/collision_object_3d.h +++ b/scene/3d/collision_object_3d.h @@ -56,7 +56,7 @@ class CollisionObject3D : public Node3D { ShapeData() { disabled = false; - owner = NULL; + owner = nullptr; } }; diff --git a/scene/3d/collision_polygon_3d.cpp b/scene/3d/collision_polygon_3d.cpp index 982205137b..66bd903eeb 100644 --- a/scene/3d/collision_polygon_3d.cpp +++ b/scene/3d/collision_polygon_3d.cpp @@ -112,7 +112,7 @@ void CollisionPolygon3D::_notification(int p_what) { parent->remove_shape_owner(owner_id); } owner_id = 0; - parent = NULL; + parent = nullptr; } break; } } @@ -201,7 +201,7 @@ CollisionPolygon3D::CollisionPolygon3D() { aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2)); depth = 1.0; set_notify_local_transform(true); - parent = NULL; + parent = nullptr; owner_id = 0; disabled = false; } diff --git a/scene/3d/collision_shape_3d.cpp b/scene/3d/collision_shape_3d.cpp index 6aecfd08cc..a66e84ac3c 100644 --- a/scene/3d/collision_shape_3d.cpp +++ b/scene/3d/collision_shape_3d.cpp @@ -105,7 +105,7 @@ void CollisionShape3D::_notification(int p_what) { parent->remove_shape_owner(owner_id); } owner_id = 0; - parent = NULL; + parent = nullptr; } break; } } @@ -200,8 +200,8 @@ CollisionShape3D::CollisionShape3D() { //indicator = RenderingServer::get_singleton()->mesh_create(); disabled = false; - debug_shape = NULL; - parent = NULL; + debug_shape = nullptr; + parent = nullptr; owner_id = 0; set_notify_local_transform(true); } @@ -217,7 +217,7 @@ void CollisionShape3D::_update_debug_shape() { if (debug_shape) { debug_shape->queue_delete(); - debug_shape = NULL; + debug_shape = nullptr; } Ref<Shape3D> s = get_shape(); diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp index 2226b0ed83..12c105b0f4 100644 --- a/scene/3d/cpu_particles_3d.cpp +++ b/scene/3d/cpu_particles_3d.cpp @@ -208,13 +208,13 @@ String CPUParticles3D::get_configuration_warning() const { if (get_mesh().is_valid()) { mesh_found = true; for (int j = 0; j < get_mesh()->get_surface_count(); j++) { - anim_material_found = Object::cast_to<ShaderMaterial>(get_mesh()->surface_get_material(j).ptr()) != NULL; + anim_material_found = Object::cast_to<ShaderMaterial>(get_mesh()->surface_get_material(j).ptr()) != nullptr; StandardMaterial3D *spat = Object::cast_to<StandardMaterial3D>(get_mesh()->surface_get_material(j).ptr()); anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == StandardMaterial3D::BILLBOARD_PARTICLES); } } - anim_material_found = anim_material_found || Object::cast_to<ShaderMaterial>(get_material_override().ptr()) != NULL; + anim_material_found = anim_material_found || Object::cast_to<ShaderMaterial>(get_material_override().ptr()) != nullptr; StandardMaterial3D *spat = Object::cast_to<StandardMaterial3D>(get_material_override().ptr()); anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == StandardMaterial3D::BILLBOARD_PARTICLES); @@ -1022,7 +1022,7 @@ void CPUParticles3D::_update_particle_data_buffer() { int pc = particles.size(); int *ow; - int *order = NULL; + int *order = nullptr; float *w = particle_data.ptrw(); const Particle *r = particles.ptr(); diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index a46cd90612..6d571ee4f2 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -293,6 +293,7 @@ GIProbeData::GIProbeData() { propagation = 0.7; anisotropy_strength = 0.5; interior = false; + use_two_bounces = false; probe = RS::get_singleton()->gi_probe_create(); } @@ -402,9 +403,9 @@ void GIProbe::_find_meshes(Node *p_at_node, List<PlotMesh> &plot_meshes) { } } -GIProbe::BakeBeginFunc GIProbe::bake_begin_function = NULL; -GIProbe::BakeStepFunc GIProbe::bake_step_function = NULL; -GIProbe::BakeEndFunc GIProbe::bake_end_function = NULL; +GIProbe::BakeBeginFunc GIProbe::bake_begin_function = nullptr; +GIProbe::BakeStepFunc GIProbe::bake_step_function = nullptr; +GIProbe::BakeEndFunc GIProbe::bake_end_function = nullptr; Vector3i GIProbe::get_estimated_cell_size() const { static const int subdiv_value[SUBDIV_MAX] = { 6, 7, 8, 9 }; @@ -511,7 +512,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) { void GIProbe::_debug_bake() { - bake(NULL, true); + bake(nullptr, true); } AABB GIProbe::get_aabb() const { diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h index c00ee2cb73..28b533e82d 100644 --- a/scene/3d/gi_probe.h +++ b/scene/3d/gi_probe.h @@ -161,7 +161,7 @@ public: Vector3 get_extents() const; Vector3i get_estimated_cell_size() const; - void bake(Node *p_from_node = NULL, bool p_create_visual_debug = false); + void bake(Node *p_from_node = nullptr, bool p_create_visual_debug = false); virtual AABB get_aabb() const; virtual Vector<Face3> get_faces(uint32_t p_usage_flags) const; diff --git a/scene/3d/gpu_particles_3d.cpp b/scene/3d/gpu_particles_3d.cpp index 8646d4f290..7744c477cb 100644 --- a/scene/3d/gpu_particles_3d.cpp +++ b/scene/3d/gpu_particles_3d.cpp @@ -253,7 +253,7 @@ String GPUParticles3D::get_configuration_warning() const { if (draw_passes[i].is_valid()) { meshes_found = true; for (int j = 0; j < draw_passes[i]->get_surface_count(); j++) { - anim_material_found = Object::cast_to<ShaderMaterial>(draw_passes[i]->surface_get_material(j).ptr()) != NULL; + anim_material_found = Object::cast_to<ShaderMaterial>(draw_passes[i]->surface_get_material(j).ptr()) != nullptr; StandardMaterial3D *spat = Object::cast_to<StandardMaterial3D>(draw_passes[i]->surface_get_material(j).ptr()); anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == StandardMaterial3D::BILLBOARD_PARTICLES); } @@ -261,7 +261,7 @@ String GPUParticles3D::get_configuration_warning() const { } } - anim_material_found = anim_material_found || Object::cast_to<ShaderMaterial>(get_material_override().ptr()) != NULL; + anim_material_found = anim_material_found || Object::cast_to<ShaderMaterial>(get_material_override().ptr()) != nullptr; StandardMaterial3D *spat = Object::cast_to<StandardMaterial3D>(get_material_override().ptr()); anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == StandardMaterial3D::BILLBOARD_PARTICLES); diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp index be3b369724..c822b70a4b 100644 --- a/scene/3d/light_3d.cpp +++ b/scene/3d/light_3d.cpp @@ -216,10 +216,6 @@ bool Light3D::is_editor_only() const { } void Light3D::_validate_property(PropertyInfo &property) const { - - if (RenderingServer::get_singleton()->is_low_end() && property.name == "shadow_contact") { - property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL; - } } void Light3D::_bind_methods() { @@ -262,9 +258,10 @@ void Light3D::_bind_methods() { ADD_GROUP("Shadow", "shadow_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shadow_enabled"), "set_shadow", "has_shadow"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "shadow_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_shadow_color", "get_shadow_color"); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "shadow_bias", PROPERTY_HINT_RANGE, "-16,16,0.01"), "set_param", "get_param", PARAM_SHADOW_BIAS); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "shadow_contact", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_param", "get_param", PARAM_CONTACT_SHADOW_SIZE); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "shadow_bias", PROPERTY_HINT_RANGE, "0,10,0.001"), "set_param", "get_param", PARAM_SHADOW_BIAS); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "shadow_normal_bias", PROPERTY_HINT_RANGE, "0,10,0.001"), "set_param", "get_param", PARAM_SHADOW_NORMAL_BIAS); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shadow_reverse_cull_face"), "set_shadow_reverse_cull_face", "get_shadow_reverse_cull_face"); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "shadow_transmittance_bias", PROPERTY_HINT_RANGE, "-16,16,0.01"), "set_param", "get_param", PARAM_TRANSMITTANCE_BIAS); ADD_GROUP("Editor", ""); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_only"), "set_editor_only", "is_editor_only"); ADD_GROUP("", ""); @@ -276,7 +273,6 @@ void Light3D::_bind_methods() { BIND_ENUM_CONSTANT(PARAM_ATTENUATION); BIND_ENUM_CONSTANT(PARAM_SPOT_ANGLE); BIND_ENUM_CONSTANT(PARAM_SPOT_ATTENUATION); - BIND_ENUM_CONSTANT(PARAM_CONTACT_SHADOW_SIZE); BIND_ENUM_CONSTANT(PARAM_SHADOW_MAX_DISTANCE); BIND_ENUM_CONSTANT(PARAM_SHADOW_SPLIT_1_OFFSET); BIND_ENUM_CONSTANT(PARAM_SHADOW_SPLIT_2_OFFSET); @@ -284,7 +280,8 @@ void Light3D::_bind_methods() { BIND_ENUM_CONSTANT(PARAM_SHADOW_FADE_START); BIND_ENUM_CONSTANT(PARAM_SHADOW_NORMAL_BIAS); BIND_ENUM_CONSTANT(PARAM_SHADOW_BIAS); - BIND_ENUM_CONSTANT(PARAM_SHADOW_BIAS_SPLIT_SCALE); + BIND_ENUM_CONSTANT(PARAM_SHADOW_PANCAKE_SIZE); + BIND_ENUM_CONSTANT(PARAM_TRANSMITTANCE_BIAS); BIND_ENUM_CONSTANT(PARAM_MAX); BIND_ENUM_CONSTANT(BAKE_DISABLED); @@ -321,14 +318,15 @@ Light3D::Light3D(RenderingServer::LightType p_type) { set_param(PARAM_ATTENUATION, 1); set_param(PARAM_SPOT_ANGLE, 45); set_param(PARAM_SPOT_ATTENUATION, 1); - set_param(PARAM_CONTACT_SHADOW_SIZE, 0); set_param(PARAM_SHADOW_MAX_DISTANCE, 0); set_param(PARAM_SHADOW_SPLIT_1_OFFSET, 0.1); set_param(PARAM_SHADOW_SPLIT_2_OFFSET, 0.2); set_param(PARAM_SHADOW_SPLIT_3_OFFSET, 0.5); set_param(PARAM_SHADOW_FADE_START, 0.8); - set_param(PARAM_SHADOW_NORMAL_BIAS, 0.0); - set_param(PARAM_SHADOW_BIAS, 0.15); + set_param(PARAM_SHADOW_PANCAKE_SIZE, 20.0); + set_param(PARAM_SHADOW_BIAS, 0.02); + set_param(PARAM_SHADOW_NORMAL_BIAS, 1.0); + set_param(PARAM_TRANSMITTANCE_BIAS, 0.05); set_param(PARAM_SHADOW_FADE_START, 1); set_disable_scale(true); } @@ -398,10 +396,9 @@ void DirectionalLight3D::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_shadow_split_3", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_param", "get_param", PARAM_SHADOW_SPLIT_3_OFFSET); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_shadow_fade_start", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param", "get_param", PARAM_SHADOW_FADE_START); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "directional_shadow_blend_splits"), "set_blend_splits", "is_blend_splits_enabled"); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_shadow_normal_bias", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_param", "get_param", PARAM_SHADOW_NORMAL_BIAS); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_shadow_bias_split_scale", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param", "get_param", PARAM_SHADOW_BIAS_SPLIT_SCALE); ADD_PROPERTY(PropertyInfo(Variant::INT, "directional_shadow_depth_range", PROPERTY_HINT_ENUM, "Stable,Optimized"), "set_shadow_depth_range", "get_shadow_depth_range"); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_shadow_max_distance", PROPERTY_HINT_EXP_RANGE, "0,8192,0.1,or_greater"), "set_param", "get_param", PARAM_SHADOW_MAX_DISTANCE); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_shadow_pancake_size", PROPERTY_HINT_EXP_RANGE, "0,1024,0.1,or_greater"), "set_param", "get_param", PARAM_SHADOW_PANCAKE_SIZE); BIND_ENUM_CONSTANT(SHADOW_ORTHOGONAL); BIND_ENUM_CONSTANT(SHADOW_PARALLEL_2_SPLITS); @@ -414,11 +411,8 @@ void DirectionalLight3D::_bind_methods() { DirectionalLight3D::DirectionalLight3D() : Light3D(RenderingServer::LIGHT_DIRECTIONAL) { - set_param(PARAM_SHADOW_NORMAL_BIAS, 0.8); - set_param(PARAM_SHADOW_BIAS, 0.1); set_param(PARAM_SHADOW_MAX_DISTANCE, 100); set_param(PARAM_SHADOW_FADE_START, 0.8); - set_param(PARAM_SHADOW_BIAS_SPLIT_SCALE, 0.25); set_shadow_mode(SHADOW_PARALLEL_4_SPLITS); set_shadow_depth_range(SHADOW_DEPTH_RANGE_STABLE); diff --git a/scene/3d/light_3d.h b/scene/3d/light_3d.h index 197e5854ec..ad2a1d5a84 100644 --- a/scene/3d/light_3d.h +++ b/scene/3d/light_3d.h @@ -49,7 +49,6 @@ public: PARAM_ATTENUATION = RS::LIGHT_PARAM_ATTENUATION, PARAM_SPOT_ANGLE = RS::LIGHT_PARAM_SPOT_ANGLE, PARAM_SPOT_ATTENUATION = RS::LIGHT_PARAM_SPOT_ATTENUATION, - PARAM_CONTACT_SHADOW_SIZE = RS::LIGHT_PARAM_CONTACT_SHADOW_SIZE, PARAM_SHADOW_MAX_DISTANCE = RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE, PARAM_SHADOW_SPLIT_1_OFFSET = RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET, PARAM_SHADOW_SPLIT_2_OFFSET = RS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET, @@ -57,7 +56,8 @@ public: PARAM_SHADOW_FADE_START = RS::LIGHT_PARAM_SHADOW_FADE_START, PARAM_SHADOW_NORMAL_BIAS = RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS, PARAM_SHADOW_BIAS = RS::LIGHT_PARAM_SHADOW_BIAS, - PARAM_SHADOW_BIAS_SPLIT_SCALE = RS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE, + PARAM_SHADOW_PANCAKE_SIZE = RS::LIGHT_PARAM_SHADOW_PANCAKE_SIZE, + PARAM_TRANSMITTANCE_BIAS = RS::LIGHT_PARAM_TRANSMITTANCE_BIAS, PARAM_MAX = RS::LIGHT_PARAM_MAX }; diff --git a/scene/3d/listener_3d.cpp b/scene/3d/listener_3d.cpp index f352eb24b1..426e34ea80 100644 --- a/scene/3d/listener_3d.cpp +++ b/scene/3d/listener_3d.cpp @@ -131,7 +131,7 @@ void Listener3D::clear_current() { return; if (get_viewport()->get_listener() == this) { - get_viewport()->_listener_set(NULL); + get_viewport()->_listener_set(nullptr); get_viewport()->_listener_make_next_current(this); } } diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp index 284bbd7091..d56a095a5b 100644 --- a/scene/3d/mesh_instance_3d.cpp +++ b/scene/3d/mesh_instance_3d.cpp @@ -217,11 +217,11 @@ Vector<Face3> MeshInstance3D::get_faces(uint32_t p_usage_flags) const { Node *MeshInstance3D::create_trimesh_collision_node() { if (mesh.is_null()) - return NULL; + return nullptr; Ref<Shape3D> shape = mesh->create_trimesh_shape(); if (shape.is_null()) - return NULL; + return nullptr; StaticBody3D *static_body = memnew(StaticBody3D); CollisionShape3D *cshape = memnew(CollisionShape3D); @@ -247,11 +247,11 @@ void MeshInstance3D::create_trimesh_collision() { Node *MeshInstance3D::create_convex_collision_node() { if (mesh.is_null()) - return NULL; + return nullptr; Ref<Shape3D> shape = mesh->create_convex_shape(); if (shape.is_null()) - return NULL; + return nullptr; StaticBody3D *static_body = memnew(StaticBody3D); CollisionShape3D *cshape = memnew(CollisionShape3D); @@ -305,6 +305,23 @@ Ref<Material> MeshInstance3D::get_surface_material(int p_surface) const { return materials[p_surface]; } +Ref<Material> MeshInstance3D::get_active_material(int p_surface) const { + + if (get_material_override() != Ref<Material>()) { + return get_material_override(); + } else if (p_surface < materials.size()) { + return materials[p_surface]; + } else { + Ref<Mesh> mesh = get_mesh(); + + if (mesh.is_null() || p_surface >= mesh->get_surface_count()) { + return Ref<Material>(); + } + + return mesh->surface_get_material(p_surface); + } +} + void MeshInstance3D::_mesh_changed() { materials.resize(mesh->get_surface_count()); @@ -397,6 +414,7 @@ void MeshInstance3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_surface_material_count"), &MeshInstance3D::get_surface_material_count); ClassDB::bind_method(D_METHOD("set_surface_material", "surface", "material"), &MeshInstance3D::set_surface_material); ClassDB::bind_method(D_METHOD("get_surface_material", "surface"), &MeshInstance3D::get_surface_material); + ClassDB::bind_method(D_METHOD("get_active_material", "surface"), &MeshInstance3D::get_active_material); ClassDB::bind_method(D_METHOD("create_trimesh_collision"), &MeshInstance3D::create_trimesh_collision); ClassDB::set_method_flags("MeshInstance3D", "create_trimesh_collision", METHOD_FLAGS_DEFAULT); diff --git a/scene/3d/mesh_instance_3d.h b/scene/3d/mesh_instance_3d.h index e45f68e295..914148f427 100644 --- a/scene/3d/mesh_instance_3d.h +++ b/scene/3d/mesh_instance_3d.h @@ -84,6 +84,7 @@ public: int get_surface_material_count() const; void set_surface_material(int p_surface, const Ref<Material> &p_material); Ref<Material> get_surface_material(int p_surface) const; + Ref<Material> get_active_material(int p_surface) const; Node *create_trimesh_collision_node(); void create_trimesh_collision(); diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp index a131684a8a..0449ab15b7 100644 --- a/scene/3d/navigation_agent_3d.cpp +++ b/scene/3d/navigation_agent_3d.cpp @@ -106,12 +106,12 @@ void NavigationAgent3D::_notification(int p_what) { // Search the navigation node and set it { - Navigation3D *nav = NULL; + Navigation3D *nav = nullptr; Node *p = get_parent(); - while (p != NULL) { + while (p != nullptr) { nav = Object::cast_to<Navigation3D>(p); - if (nav != NULL) - p = NULL; + if (nav != nullptr) + p = nullptr; else p = p->get_parent(); } @@ -122,8 +122,8 @@ void NavigationAgent3D::_notification(int p_what) { set_physics_process_internal(true); } break; case NOTIFICATION_EXIT_TREE: { - agent_parent = NULL; - set_navigation(NULL); + agent_parent = nullptr; + set_navigation(nullptr); set_physics_process_internal(false); } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { @@ -142,8 +142,8 @@ void NavigationAgent3D::_notification(int p_what) { } NavigationAgent3D::NavigationAgent3D() : - agent_parent(NULL), - navigation(NULL), + agent_parent(nullptr), + navigation(nullptr), agent(RID()), target_desired_distance(1.0), navigation_height_offset(0.0), @@ -170,12 +170,12 @@ void NavigationAgent3D::set_navigation(Navigation3D *p_nav) { return; // Pointless navigation = p_nav; - NavigationServer3D::get_singleton()->agent_set_map(agent, navigation == NULL ? RID() : navigation->get_rid()); + NavigationServer3D::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid()); } void NavigationAgent3D::set_navigation_node(Node *p_nav) { Navigation3D *nav = Object::cast_to<Navigation3D>(p_nav); - ERR_FAIL_COND(nav == NULL); + ERR_FAIL_COND(nav == nullptr); set_navigation(nav); } @@ -244,7 +244,7 @@ Vector3 NavigationAgent3D::get_target_location() const { Vector3 NavigationAgent3D::get_next_location() { update_navigation(); if (navigation_path.size() == 0) { - ERR_FAIL_COND_V(agent_parent == NULL, Vector3()); + ERR_FAIL_COND_V(agent_parent == nullptr, Vector3()); return agent_parent->get_global_transform().origin; } else { return navigation_path[nav_path_index] - Vector3(0, navigation_height_offset, 0); @@ -252,7 +252,7 @@ Vector3 NavigationAgent3D::get_next_location() { } real_t NavigationAgent3D::distance_to_target() const { - ERR_FAIL_COND_V(agent_parent == NULL, 0.0); + ERR_FAIL_COND_V(agent_parent == nullptr, 0.0); return agent_parent->get_global_transform().origin.distance_to(target_location); } @@ -306,8 +306,8 @@ String NavigationAgent3D::get_configuration_warning() const { void NavigationAgent3D::update_navigation() { - if (agent_parent == NULL) return; - if (navigation == NULL) return; + if (agent_parent == nullptr) return; + if (navigation == nullptr) return; if (update_frame_id == Engine::get_singleton()->get_physics_frames()) return; update_frame_id = Engine::get_singleton()->get_physics_frames(); diff --git a/scene/3d/navigation_obstacle_3d.cpp b/scene/3d/navigation_obstacle_3d.cpp index fa976e5d18..2ee2008799 100644 --- a/scene/3d/navigation_obstacle_3d.cpp +++ b/scene/3d/navigation_obstacle_3d.cpp @@ -49,12 +49,12 @@ void NavigationObstacle3D::_notification(int p_what) { // Search the navigation node and set it { - Navigation3D *nav = NULL; + Navigation3D *nav = nullptr; Node *p = get_parent(); - while (p != NULL) { + while (p != nullptr) { nav = Object::cast_to<Navigation3D>(p); - if (nav != NULL) - p = NULL; + if (nav != nullptr) + p = nullptr; else p = p->get_parent(); } @@ -65,7 +65,7 @@ void NavigationObstacle3D::_notification(int p_what) { set_physics_process_internal(true); } break; case NOTIFICATION_EXIT_TREE: { - set_navigation(NULL); + set_navigation(nullptr); set_physics_process_internal(false); } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { @@ -87,7 +87,7 @@ void NavigationObstacle3D::_notification(int p_what) { } NavigationObstacle3D::NavigationObstacle3D() : - navigation(NULL), + navigation(nullptr), agent(RID()) { agent = NavigationServer3D::get_singleton()->agent_create(); } @@ -102,12 +102,12 @@ void NavigationObstacle3D::set_navigation(Navigation3D *p_nav) { return; // Pointless navigation = p_nav; - NavigationServer3D::get_singleton()->agent_set_map(agent, navigation == NULL ? RID() : navigation->get_rid()); + NavigationServer3D::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid()); } void NavigationObstacle3D::set_navigation_node(Node *p_nav) { Navigation3D *nav = Object::cast_to<Navigation3D>(p_nav); - ERR_FAIL_COND(nav == NULL); + ERR_FAIL_COND(nav == nullptr); set_navigation(nav); } diff --git a/scene/3d/navigation_region_3d.cpp b/scene/3d/navigation_region_3d.cpp index 08c0fbf4d1..043b816033 100644 --- a/scene/3d/navigation_region_3d.cpp +++ b/scene/3d/navigation_region_3d.cpp @@ -123,9 +123,9 @@ void NavigationRegion3D::_notification(int p_what) { if (debug_view) { debug_view->queue_delete(); - debug_view = NULL; + debug_view = nullptr; } - navigation = NULL; + navigation = nullptr; } break; } } @@ -184,18 +184,18 @@ void _bake_navigation_mesh(void *p_user_data) { } void NavigationRegion3D::bake_navigation_mesh() { - ERR_FAIL_COND(bake_thread != NULL); + ERR_FAIL_COND(bake_thread != nullptr); BakeThreadsArgs *args = memnew(BakeThreadsArgs); args->nav_region = this; bake_thread = Thread::create(_bake_navigation_mesh, args); - ERR_FAIL_COND(bake_thread == NULL); + ERR_FAIL_COND(bake_thread == nullptr); } void NavigationRegion3D::_bake_finished(Ref<NavigationMesh> p_nav_mesh) { set_navigation_mesh(p_nav_mesh); - bake_thread = NULL; + bake_thread = nullptr; } String NavigationRegion3D::get_configuration_warning() const { @@ -247,9 +247,9 @@ NavigationRegion3D::NavigationRegion3D() { set_notify_transform(true); region = NavigationServer3D::get_singleton()->region_create(); - navigation = NULL; - debug_view = NULL; - bake_thread = NULL; + navigation = nullptr; + debug_view = nullptr; + bake_thread = nullptr; } NavigationRegion3D::~NavigationRegion3D() { diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp index 7f444d59bf..0b7407e049 100644 --- a/scene/3d/node_3d.cpp +++ b/scene/3d/node_3d.cpp @@ -134,7 +134,7 @@ void Node3D::_notification(int p_what) { if (data.parent) data.C = data.parent->data.children.push_back(this); else - data.C = NULL; + data.C = nullptr; if (data.toplevel && !Engine::get_singleton()->is_editor_hint()) { @@ -158,14 +158,14 @@ void Node3D::_notification(int p_what) { get_tree()->xform_change_list.remove(&xform_change); if (data.C) data.parent->data.children.erase(data.C); - data.parent = NULL; - data.C = NULL; + data.parent = nullptr; + data.C = nullptr; data.toplevel_active = false; } break; case NOTIFICATION_ENTER_WORLD: { data.inside_world = true; - data.viewport = NULL; + data.viewport = nullptr; Node *parent = get_parent(); while (parent && !data.viewport) { data.viewport = Object::cast_to<Viewport>(parent); @@ -176,7 +176,7 @@ void Node3D::_notification(int p_what) { if (get_script_instance()) { - get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_enter_world, NULL, 0); + get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_enter_world, nullptr, 0); } #ifdef TOOLS_ENABLED if (Engine::get_singleton()->is_editor_hint() && get_tree()->is_node_being_edited(this)) { @@ -208,10 +208,10 @@ void Node3D::_notification(int p_what) { if (get_script_instance()) { - get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_world, NULL, 0); + get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_world, nullptr, 0); } - data.viewport = NULL; + data.viewport = nullptr; data.inside_world = false; } break; @@ -829,7 +829,7 @@ Node3D::Node3D() : data.toplevel = false; data.toplevel_active = false; data.scale = Vector3(1, 1, 1); - data.viewport = NULL; + data.viewport = nullptr; data.inside_world = false; data.visible = true; data.disable_scale = false; @@ -840,8 +840,8 @@ Node3D::Node3D() : #endif data.notify_local_transform = false; data.notify_transform = false; - data.parent = NULL; - data.C = NULL; + data.parent = nullptr; + data.C = nullptr; } Node3D::~Node3D() { diff --git a/scene/3d/path_3d.cpp b/scene/3d/path_3d.cpp index 0f1f9bb8a7..f06135f53d 100644 --- a/scene/3d/path_3d.cpp +++ b/scene/3d/path_3d.cpp @@ -229,7 +229,7 @@ void PathFollow3D::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { - path = NULL; + path = nullptr; } break; } } @@ -409,7 +409,7 @@ PathFollow3D::PathFollow3D() { delta_offset = 0; h_offset = 0; v_offset = 0; - path = NULL; + path = nullptr; rotation_mode = ROTATION_XYZ; cubic = true; loop = true; diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index 37981f914c..2b6eb8ac8a 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -474,7 +474,7 @@ void RigidBody3D::_direct_state_changed(Object *p_state) { contact_monitor->locked = false; } - state = NULL; + state = nullptr; } void RigidBody3D::_notification(int p_what) { @@ -744,7 +744,7 @@ void RigidBody3D::set_contact_monitor(bool p_enabled) { } memdelete(contact_monitor); - contact_monitor = NULL; + contact_monitor = nullptr; } else { contact_monitor = memnew(ContactMonitor); @@ -754,7 +754,7 @@ void RigidBody3D::set_contact_monitor(bool p_enabled) { bool RigidBody3D::is_contact_monitor_enabled() const { - return contact_monitor != NULL; + return contact_monitor != nullptr; } void RigidBody3D::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool p_lock) { @@ -910,7 +910,7 @@ RigidBody3D::RigidBody3D() : mass = 1; max_contacts_reported = 0; - state = NULL; + state = nullptr; gravity_scale = 1; linear_damp = -1; @@ -921,7 +921,7 @@ RigidBody3D::RigidBody3D() : ccd = false; custom_integrator = false; - contact_monitor = NULL; + contact_monitor = nullptr; can_sleep = true; PhysicsServer3D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); @@ -1321,12 +1321,12 @@ KinematicBody3D::KinematicBody3D() : KinematicBody3D::~KinematicBody3D() { if (motion_cache.is_valid()) { - motion_cache->owner = NULL; + motion_cache->owner = nullptr; } for (int i = 0; i < slide_colliders.size(); i++) { if (slide_colliders[i].is_valid()) { - slide_colliders.write[i]->owner = NULL; + slide_colliders.write[i]->owner = nullptr; } } } @@ -1346,7 +1346,7 @@ Vector3 KinematicCollision3D::get_remainder() const { return collision.remainder; } Object *KinematicCollision3D::get_local_shape() const { - if (!owner) return NULL; + if (!owner) return nullptr; uint32_t ownerid = owner->shape_find_owner(collision.local_shape); return owner->shape_owner_get_owner(ownerid); } @@ -1357,7 +1357,7 @@ Object *KinematicCollision3D::get_collider() const { return ObjectDB::get_instance(collision.collider); } - return NULL; + return nullptr; } ObjectID KinematicCollision3D::get_collider_id() const { @@ -1374,7 +1374,7 @@ Object *KinematicCollision3D::get_collider_shape() const { } } - return NULL; + return nullptr; } int KinematicCollision3D::get_collider_shape_index() const { @@ -1420,7 +1420,7 @@ KinematicCollision3D::KinematicCollision3D() { collision.collider_shape = 0; collision.local_shape = 0; - owner = NULL; + owner = nullptr; } /////////////////////////////////////// @@ -2078,7 +2078,7 @@ void PhysicalBone3D::_notification(int p_what) { parent_skeleton->unbind_physical_bone_from_bone(bone_id); } } - parent_skeleton = NULL; + parent_skeleton = nullptr; if (joint.is_valid()) { PhysicsServer3D::get_singleton()->free(joint); joint = RID(); @@ -2181,7 +2181,7 @@ void PhysicalBone3D::_bind_methods() { Skeleton3D *PhysicalBone3D::find_skeleton_parent(Node *p_parent) { if (!p_parent) { - return NULL; + return nullptr; } Skeleton3D *s = Object::cast_to<Skeleton3D>(p_parent); return s ? s : find_skeleton_parent(p_parent->get_parent()); @@ -2333,7 +2333,7 @@ void PhysicalBone3D::set_joint_type(JointType p_joint_type) { if (joint_data) memdelete(joint_data); - joint_data = NULL; + joint_data = nullptr; switch (p_joint_type) { case JOINT_TYPE_PIN: joint_data = memnew(PinJointData); @@ -2501,8 +2501,8 @@ PhysicalBone3D::PhysicalBone3D() : #ifdef TOOLS_ENABLED gizmo_move_joint(false), #endif - joint_data(NULL), - parent_skeleton(NULL), + joint_data(nullptr), + parent_skeleton(nullptr), simulate_physics(false), _internal_simulate_physics(false), bone_id(-1), @@ -2588,7 +2588,7 @@ void PhysicalBone3D::_stop_physics_simulation() { PhysicsServer3D::get_singleton()->body_set_collision_mask(get_rid(), 0); } if (_internal_simulate_physics) { - PhysicsServer3D::get_singleton()->body_set_force_integration_callback(get_rid(), NULL, ""); + PhysicsServer3D::get_singleton()->body_set_force_integration_callback(get_rid(), nullptr, ""); parent_skeleton->set_bone_global_pose_override(bone_id, Transform(), 0.0, false); set_as_toplevel(false); _internal_simulate_physics = false; diff --git a/scene/3d/physics_joint_3d.cpp b/scene/3d/physics_joint_3d.cpp index f6b3e79300..591c17a91e 100644 --- a/scene/3d/physics_joint_3d.cpp +++ b/scene/3d/physics_joint_3d.cpp @@ -45,8 +45,8 @@ void Joint3D::_update_joint(bool p_only_free) { if (p_only_free || !is_inside_tree()) return; - Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)NULL; - Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)NULL; + Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)nullptr; + Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)nullptr; PhysicsBody3D *body_a = Object::cast_to<PhysicsBody3D>(node_a); PhysicsBody3D *body_b = Object::cast_to<PhysicsBody3D>(node_b); diff --git a/scene/3d/ray_cast_3d.cpp b/scene/3d/ray_cast_3d.cpp index d00af3b128..a18da61656 100644 --- a/scene/3d/ray_cast_3d.cpp +++ b/scene/3d/ray_cast_3d.cpp @@ -81,7 +81,7 @@ bool RayCast3D::is_colliding() const { Object *RayCast3D::get_collider() const { if (against.is_null()) - return NULL; + return nullptr; return ObjectDB::get_instance(against); } @@ -387,7 +387,7 @@ void RayCast3D::_clear_debug_shape() { else memdelete(mi); - debug_shape = NULL; + debug_shape = nullptr; } RayCast3D::RayCast3D() { @@ -398,7 +398,7 @@ RayCast3D::RayCast3D() { against_shape = 0; collision_mask = 1; cast_to = Vector3(0, -1, 0); - debug_shape = NULL; + debug_shape = nullptr; exclude_parent_body = true; collide_with_areas = false; collide_with_bodies = true; diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp index 1b05641c9d..59a6e23005 100644 --- a/scene/3d/skeleton_3d.cpp +++ b/scene/3d/skeleton_3d.cpp @@ -685,19 +685,19 @@ void Skeleton3D::bind_physical_bone_to_bone(int p_bone, PhysicalBone3D *p_physic void Skeleton3D::unbind_physical_bone_from_bone(int p_bone) { ERR_FAIL_INDEX(p_bone, bones.size()); - bones.write[p_bone].physical_bone = NULL; + bones.write[p_bone].physical_bone = nullptr; _rebuild_physical_bones_cache(); } PhysicalBone3D *Skeleton3D::get_physical_bone(int p_bone) { - ERR_FAIL_INDEX_V(p_bone, bones.size(), NULL); + ERR_FAIL_INDEX_V(p_bone, bones.size(), nullptr); return bones[p_bone].physical_bone; } PhysicalBone3D *Skeleton3D::get_physical_bone_parent(int p_bone) { - ERR_FAIL_INDEX_V(p_bone, bones.size(), NULL); + ERR_FAIL_INDEX_V(p_bone, bones.size(), nullptr); if (bones[p_bone].cache_parent_physical_bone) { return bones[p_bone].cache_parent_physical_bone; @@ -707,11 +707,11 @@ PhysicalBone3D *Skeleton3D::get_physical_bone_parent(int p_bone) { } PhysicalBone3D *Skeleton3D::_get_physical_bone_parent(int p_bone) { - ERR_FAIL_INDEX_V(p_bone, bones.size(), NULL); + ERR_FAIL_INDEX_V(p_bone, bones.size(), nullptr); const int parent_bone = bones[p_bone].parent; if (0 > parent_bone) { - return NULL; + return nullptr; } PhysicalBone3D *pb = bones[parent_bone].physical_bone; diff --git a/scene/3d/skeleton_3d.h b/scene/3d/skeleton_3d.h index 2ae04aa575..08b8691658 100644 --- a/scene/3d/skeleton_3d.h +++ b/scene/3d/skeleton_3d.h @@ -112,8 +112,8 @@ private: global_pose_override_amount = 0; global_pose_override_reset = false; #ifndef _3D_DISABLED - physical_bone = NULL; - cache_parent_physical_bone = NULL; + physical_bone = nullptr; + cache_parent_physical_bone = nullptr; #endif // _3D_DISABLED } }; diff --git a/scene/3d/skeleton_ik_3d.cpp b/scene/3d/skeleton_ik_3d.cpp index a6c3e25399..7366290ed3 100644 --- a/scene/3d/skeleton_ik_3d.cpp +++ b/scene/3d/skeleton_ik_3d.cpp @@ -42,7 +42,7 @@ FabrikInverseKinematic::ChainItem *FabrikInverseKinematic::ChainItem::find_child return &children.write[i]; } } - return NULL; + return nullptr; } FabrikInverseKinematic::ChainItem *FabrikInverseKinematic::ChainItem::add_child(const BoneId p_bone_id) { @@ -65,7 +65,7 @@ bool FabrikInverseKinematic::build_chain(Task *p_task, bool p_force_simple_chain chain.chain_root.initial_transform = p_task->skeleton->get_bone_global_pose(chain.chain_root.bone); chain.chain_root.current_pos = chain.chain_root.initial_transform.origin; chain.chain_root.pb = p_task->skeleton->get_physical_bone(chain.chain_root.bone); - chain.middle_chain_item = NULL; + chain.middle_chain_item = nullptr; // Holds all IDs that are composing a single chain in reverse order Vector<BoneId> chain_ids; @@ -119,7 +119,7 @@ bool FabrikInverseKinematic::build_chain(Task *p_task, bool p_force_simple_chain } if (!middle_chain_item_id) - chain.middle_chain_item = NULL; + chain.middle_chain_item = nullptr; // Initialize current tip chain.tips.write[x].chain_item = sub_chain; @@ -226,14 +226,14 @@ void FabrikInverseKinematic::solve_simple_forwards(Chain &r_chain, bool p_solve_ if (p_solve_magnet && sub_chain_root == r_chain.middle_chain_item) { // In case of magnet solving this is the tip - sub_chain_root = NULL; + sub_chain_root = nullptr; } else { sub_chain_root = &child; } } else { // Is tip - sub_chain_root = NULL; + sub_chain_root = nullptr; } } } @@ -251,7 +251,7 @@ FabrikInverseKinematic::Task *FabrikInverseKinematic::create_simple_task(Skeleto if (!build_chain(task)) { free_task(task); - return NULL; + return nullptr; } return task; @@ -328,7 +328,7 @@ void FabrikInverseKinematic::solve(Task *p_task, real_t blending_delta, bool ove if (!ci->children.empty()) ci = &ci->children.write[0]; else - ci = NULL; + ci = nullptr; } } @@ -432,14 +432,14 @@ SkeletonIK3D::SkeletonIK3D() : use_magnet(false), min_distance(0.01), max_iterations(10), - skeleton(NULL), - target_node_override(NULL), - task(NULL) { + skeleton(nullptr), + target_node_override(nullptr), + task(nullptr) { } SkeletonIK3D::~SkeletonIK3D() { FabrikInverseKinematic::free_task(task); - task = NULL; + task = nullptr; } void SkeletonIK3D::set_root_bone(const StringName &p_root_bone) { @@ -479,7 +479,7 @@ const Transform &SkeletonIK3D::get_target_transform() const { void SkeletonIK3D::set_target_node(const NodePath &p_node) { target_node_path_override = p_node; - target_node_override = NULL; + target_node_override = nullptr; reload_goal(); } @@ -550,7 +550,7 @@ Transform SkeletonIK3D::_get_target_transform() { void SkeletonIK3D::reload_chain() { FabrikInverseKinematic::free_task(task); - task = NULL; + task = nullptr; if (!skeleton) return; diff --git a/scene/3d/skeleton_ik_3d.h b/scene/3d/skeleton_ik_3d.h index ebfebd1e66..5fbbe6e9e7 100644 --- a/scene/3d/skeleton_ik_3d.h +++ b/scene/3d/skeleton_ik_3d.h @@ -64,9 +64,9 @@ class FabrikInverseKinematic { Vector3 current_ori; ChainItem() : - parent_item(NULL), + parent_item(nullptr), bone(-1), - pb(NULL), + pb(nullptr), length(0) {} ChainItem *find_child(const BoneId p_bone_id); @@ -78,8 +78,8 @@ class FabrikInverseKinematic { const EndEffector *end_effector; ChainTip() : - chain_item(NULL), - end_effector(NULL) {} + chain_item(nullptr), + end_effector(nullptr) {} ChainTip(ChainItem *p_chain_item, const EndEffector *p_end_effector) : chain_item(p_chain_item), @@ -115,7 +115,7 @@ public: Transform goal_global_transform; Task() : - skeleton(NULL), + skeleton(nullptr), min_distance(0.01), max_iterations(10), root_bone(-1) {} diff --git a/scene/3d/soft_body_3d.cpp b/scene/3d/soft_body_3d.cpp index 6d2808cfce..6092818252 100644 --- a/scene/3d/soft_body_3d.cpp +++ b/scene/3d/soft_body_3d.cpp @@ -99,7 +99,7 @@ void SoftBodyRenderingServerHandler::set_aabb(const AABB &p_aabb) { SoftBody3D::PinnedPoint::PinnedPoint() : point_index(-1), - spatial_attachment(NULL) { + spatial_attachment(nullptr) { } SoftBody3D::PinnedPoint::PinnedPoint(const PinnedPoint &obj_tocopy) { @@ -454,7 +454,7 @@ void SoftBody3D::prepare_physics_server() { if (get_mesh().is_valid()) PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, get_mesh()); else - PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, NULL); + PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, nullptr); return; } @@ -466,7 +466,7 @@ void SoftBody3D::prepare_physics_server() { RS::get_singleton()->connect("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh)); } else { - PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, NULL); + PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, nullptr); if (RS::get_singleton()->is_connected("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh))) { RS::get_singleton()->disconnect("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh)); } @@ -808,7 +808,7 @@ void SoftBody3D::_remove_pinned_point(int p_point_index) { int SoftBody3D::_get_pinned_point(int p_point_index, SoftBody3D::PinnedPoint *&r_point) const { const int id = _has_pinned_point(p_point_index); if (-1 == id) { - r_point = NULL; + r_point = nullptr; return -1; } else { r_point = const_cast<SoftBody3D::PinnedPoint *>(&pinned_points.ptr()[id]); diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 360e95e76a..85e5ebc475 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -83,8 +83,8 @@ void SpriteBase3D::_notification(int p_what) { if (parent_sprite) { parent_sprite->children.erase(pI); - pI = NULL; - parent_sprite = NULL; + pI = nullptr; + parent_sprite = nullptr; } } } @@ -364,8 +364,8 @@ SpriteBase3D::SpriteBase3D() { centered = true; hflip = false; vflip = false; - parent_sprite = NULL; - pI = NULL; + parent_sprite = nullptr; + pI = nullptr; for (int i = 0; i < FLAG_MAX; i++) flags[i] = i == FLAG_TRANSPARENT || i == FLAG_DOUBLE_SIDED; @@ -441,7 +441,7 @@ void Sprite3D::_draw() { // Properly setup UVs for impostor textures (AtlasTexture). Ref<AtlasTexture> atlas_tex = texture; - if (atlas_tex != NULL) { + if (atlas_tex != nullptr) { src_tsize[0] = atlas_tex->get_atlas()->get_width(); src_tsize[1] = atlas_tex->get_atlas()->get_height(); } @@ -775,7 +775,7 @@ void AnimatedSprite3D::_draw() { // Properly setup UVs for impostor textures (AtlasTexture). Ref<AtlasTexture> atlas_tex = texture; - if (atlas_tex != NULL) { + if (atlas_tex != nullptr) { src_tsize[0] = atlas_tex->get_atlas()->get_width(); src_tsize[1] = atlas_tex->get_atlas()->get_height(); } diff --git a/scene/3d/vehicle_body_3d.cpp b/scene/3d/vehicle_body_3d.cpp index ac7608a3d5..5c2fa59a21 100644 --- a/scene/3d/vehicle_body_3d.cpp +++ b/scene/3d/vehicle_body_3d.cpp @@ -99,7 +99,7 @@ void VehicleWheel3D::_notification(int p_what) { if (!cb) return; cb->wheels.erase(this); - body = NULL; + body = nullptr; } } @@ -385,7 +385,7 @@ VehicleWheel3D::VehicleWheel3D() { m_clippedInvContactDotSuspension = 1.0; m_raycastInfo.m_isInContact = false; - body = NULL; + body = nullptr; } void VehicleBody3D::_update_wheel_transform(VehicleWheel3D &wheel, PhysicsDirectBodyState3D *s) { @@ -454,7 +454,7 @@ real_t VehicleBody3D::_ray_cast(int p_idx, PhysicsDirectBodyState3D *s) { bool col = ss->intersect_ray(source, target, rr, exclude); - wheel.m_raycastInfo.m_groundObject = 0; + wheel.m_raycastInfo.m_groundObject = nullptr; if (col) { param = source.distance_to(rr.position) / source.distance_to(target); @@ -917,7 +917,7 @@ void VehicleBody3D::_direct_state_changed(Object *p_state) { wheel.m_deltaRotation *= real_t(0.99); //damping of rotation when not in contact } - state = NULL; + state = nullptr; } void VehicleBody3D::set_engine_force(float p_engine_force) { @@ -988,7 +988,7 @@ VehicleBody3D::VehicleBody3D() { engine_force = 0; brake = 0; - state = NULL; + state = nullptr; ccd = false; exclude.insert(get_rid()); diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/xr_nodes.cpp index ce7c885a40..0373114e7d 100644 --- a/scene/3d/arvr_nodes.cpp +++ b/scene/3d/xr_nodes.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* arvr_nodes.cpp */ +/* xr_nodes.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,52 +28,52 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "arvr_nodes.h" +#include "xr_nodes.h" #include "core/input/input_filter.h" -#include "servers/arvr/arvr_interface.h" -#include "servers/arvr_server.h" +#include "servers/xr/xr_interface.h" +#include "servers/xr_server.h" //////////////////////////////////////////////////////////////////////////////////////////////////// -void ARVRCamera::_notification(int p_what) { +void XRCamera3D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - // need to find our ARVROrigin parent and let it know we're its camera! - ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent()); - if (origin != NULL) { + // need to find our XROrigin3D parent and let it know we're its camera! + XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent()); + if (origin != nullptr) { origin->set_tracked_camera(this); } }; break; case NOTIFICATION_EXIT_TREE: { - // need to find our ARVROrigin parent and let it know we're no longer its camera! - ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent()); - if (origin != NULL) { + // need to find our XROrigin3D parent and let it know we're no longer its camera! + XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent()); + if (origin != nullptr) { origin->clear_tracked_camera_if(this); } }; break; }; }; -String ARVRCamera::get_configuration_warning() const { +String XRCamera3D::get_configuration_warning() const { if (!is_visible() || !is_inside_tree()) return String(); - // must be child node of ARVROrigin! - ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent()); - if (origin == NULL) { - return TTR("ARVRCamera must have an ARVROrigin node as its parent."); + // must be child node of XROrigin3D! + XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent()); + if (origin == nullptr) { + return TTR("XRCamera3D must have an XROrigin3D node as its parent."); }; return String(); }; -Vector3 ARVRCamera::project_local_ray_normal(const Point2 &p_pos) const { - // get our ARVRServer - ARVRServer *arvr_server = ARVRServer::get_singleton(); - ERR_FAIL_NULL_V(arvr_server, Vector3()); +Vector3 XRCamera3D::project_local_ray_normal(const Point2 &p_pos) const { + // get our XRServer + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL_V(xr_server, Vector3()); - Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface(); - if (arvr_interface.is_null()) { + Ref<XRInterface> xr_interface = xr_server->get_primary_interface(); + if (xr_interface.is_null()) { // we might be in the editor or have VR turned off, just call superclass return Camera3D::project_local_ray_normal(p_pos); } @@ -84,20 +84,20 @@ Vector3 ARVRCamera::project_local_ray_normal(const Point2 &p_pos) const { Vector2 cpos = get_viewport()->get_camera_coords(p_pos); Vector3 ray; - CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar()); + CameraMatrix cm = xr_interface->get_projection_for_eye(XRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar()); Vector2 screen_he = cm.get_viewport_half_extents(); ray = Vector3(((cpos.x / viewport_size.width) * 2.0 - 1.0) * screen_he.x, ((1.0 - (cpos.y / viewport_size.height)) * 2.0 - 1.0) * screen_he.y, -get_znear()).normalized(); return ray; }; -Point2 ARVRCamera::unproject_position(const Vector3 &p_pos) const { - // get our ARVRServer - ARVRServer *arvr_server = ARVRServer::get_singleton(); - ERR_FAIL_NULL_V(arvr_server, Vector2()); +Point2 XRCamera3D::unproject_position(const Vector3 &p_pos) const { + // get our XRServer + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL_V(xr_server, Vector2()); - Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface(); - if (arvr_interface.is_null()) { + Ref<XRInterface> xr_interface = xr_server->get_primary_interface(); + if (xr_interface.is_null()) { // we might be in the editor or have VR turned off, just call superclass return Camera3D::unproject_position(p_pos); } @@ -106,7 +106,7 @@ Point2 ARVRCamera::unproject_position(const Vector3 &p_pos) const { Size2 viewport_size = get_viewport()->get_visible_rect().size; - CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar()); + CameraMatrix cm = xr_interface->get_projection_for_eye(XRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar()); Plane p(get_camera_transform().xform_inv(p_pos), 1.0); @@ -120,13 +120,13 @@ Point2 ARVRCamera::unproject_position(const Vector3 &p_pos) const { return res; }; -Vector3 ARVRCamera::project_position(const Point2 &p_point, float p_z_depth) const { - // get our ARVRServer - ARVRServer *arvr_server = ARVRServer::get_singleton(); - ERR_FAIL_NULL_V(arvr_server, Vector3()); +Vector3 XRCamera3D::project_position(const Point2 &p_point, float p_z_depth) const { + // get our XRServer + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL_V(xr_server, Vector3()); - Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface(); - if (arvr_interface.is_null()) { + Ref<XRInterface> xr_interface = xr_server->get_primary_interface(); + if (xr_interface.is_null()) { // we might be in the editor or have VR turned off, just call superclass return Camera3D::project_position(p_point, p_z_depth); } @@ -135,7 +135,7 @@ Vector3 ARVRCamera::project_position(const Point2 &p_point, float p_z_depth) con Size2 viewport_size = get_viewport()->get_visible_rect().size; - CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar()); + CameraMatrix cm = xr_interface->get_projection_for_eye(XRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar()); Vector2 vp_he = cm.get_viewport_half_extents(); @@ -149,13 +149,13 @@ Vector3 ARVRCamera::project_position(const Point2 &p_point, float p_z_depth) con return get_camera_transform().xform(p); }; -Vector<Plane> ARVRCamera::get_frustum() const { - // get our ARVRServer - ARVRServer *arvr_server = ARVRServer::get_singleton(); - ERR_FAIL_NULL_V(arvr_server, Vector<Plane>()); +Vector<Plane> XRCamera3D::get_frustum() const { + // get our XRServer + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL_V(xr_server, Vector<Plane>()); - Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface(); - if (arvr_interface.is_null()) { + Ref<XRInterface> xr_interface = xr_server->get_primary_interface(); + if (xr_interface.is_null()) { // we might be in the editor or have VR turned off, just call superclass return Camera3D::get_frustum(); } @@ -163,21 +163,21 @@ Vector<Plane> ARVRCamera::get_frustum() const { ERR_FAIL_COND_V(!is_inside_world(), Vector<Plane>()); Size2 viewport_size = get_viewport()->get_visible_rect().size; - CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar()); + CameraMatrix cm = xr_interface->get_projection_for_eye(XRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar()); return cm.get_projection_planes(get_camera_transform()); }; -ARVRCamera::ARVRCamera(){ +XRCamera3D::XRCamera3D(){ // nothing to do here yet for now.. }; -ARVRCamera::~ARVRCamera(){ +XRCamera3D::~XRCamera3D(){ // nothing to do here yet for now.. }; //////////////////////////////////////////////////////////////////////////////////////////////////// -void ARVRController::_notification(int p_what) { +void XRController3D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { set_process_internal(true); @@ -186,13 +186,13 @@ void ARVRController::_notification(int p_what) { set_process_internal(false); }; break; case NOTIFICATION_INTERNAL_PROCESS: { - // get our ARVRServer - ARVRServer *arvr_server = ARVRServer::get_singleton(); - ERR_FAIL_NULL(arvr_server); + // get our XRServer + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL(xr_server); // find the tracker for our controller - ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id); - if (tracker == NULL) { + XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, controller_id); + if (tracker == nullptr) { // this controller is currently turned off is_active = false; button_states = 0; @@ -236,63 +236,63 @@ void ARVRController::_notification(int p_what) { }; }; -void ARVRController::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_controller_id", "controller_id"), &ARVRController::set_controller_id); - ClassDB::bind_method(D_METHOD("get_controller_id"), &ARVRController::get_controller_id); +void XRController3D::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_controller_id", "controller_id"), &XRController3D::set_controller_id); + ClassDB::bind_method(D_METHOD("get_controller_id"), &XRController3D::get_controller_id); ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_id", PROPERTY_HINT_RANGE, "0,32,1"), "set_controller_id", "get_controller_id"); - ClassDB::bind_method(D_METHOD("get_controller_name"), &ARVRController::get_controller_name); + ClassDB::bind_method(D_METHOD("get_controller_name"), &XRController3D::get_controller_name); // passthroughs to information about our related joystick - ClassDB::bind_method(D_METHOD("get_joystick_id"), &ARVRController::get_joystick_id); - ClassDB::bind_method(D_METHOD("is_button_pressed", "button"), &ARVRController::is_button_pressed); - ClassDB::bind_method(D_METHOD("get_joystick_axis", "axis"), &ARVRController::get_joystick_axis); + ClassDB::bind_method(D_METHOD("get_joystick_id"), &XRController3D::get_joystick_id); + ClassDB::bind_method(D_METHOD("is_button_pressed", "button"), &XRController3D::is_button_pressed); + ClassDB::bind_method(D_METHOD("get_joystick_axis", "axis"), &XRController3D::get_joystick_axis); - ClassDB::bind_method(D_METHOD("get_is_active"), &ARVRController::get_is_active); - ClassDB::bind_method(D_METHOD("get_hand"), &ARVRController::get_hand); + ClassDB::bind_method(D_METHOD("get_is_active"), &XRController3D::get_is_active); + ClassDB::bind_method(D_METHOD("get_hand"), &XRController3D::get_hand); - ClassDB::bind_method(D_METHOD("get_rumble"), &ARVRController::get_rumble); - ClassDB::bind_method(D_METHOD("set_rumble", "rumble"), &ARVRController::set_rumble); + ClassDB::bind_method(D_METHOD("get_rumble"), &XRController3D::get_rumble); + ClassDB::bind_method(D_METHOD("set_rumble", "rumble"), &XRController3D::set_rumble); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rumble", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_rumble", "get_rumble"); ADD_PROPERTY_DEFAULT("rumble", 0.0); - ClassDB::bind_method(D_METHOD("get_mesh"), &ARVRController::get_mesh); + ClassDB::bind_method(D_METHOD("get_mesh"), &XRController3D::get_mesh); ADD_SIGNAL(MethodInfo("button_pressed", PropertyInfo(Variant::INT, "button"))); ADD_SIGNAL(MethodInfo("button_release", PropertyInfo(Variant::INT, "button"))); ADD_SIGNAL(MethodInfo("mesh_updated", PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"))); }; -void ARVRController::set_controller_id(int p_controller_id) { +void XRController3D::set_controller_id(int p_controller_id) { // We don't check any bounds here, this controller may not yet be active and just be a place holder until it is. // Note that setting this to 0 means this node is not bound to a controller yet. controller_id = p_controller_id; update_configuration_warning(); }; -int ARVRController::get_controller_id(void) const { +int XRController3D::get_controller_id(void) const { return controller_id; }; -String ARVRController::get_controller_name(void) const { - // get our ARVRServer - ARVRServer *arvr_server = ARVRServer::get_singleton(); - ERR_FAIL_NULL_V(arvr_server, String()); +String XRController3D::get_controller_name(void) const { + // get our XRServer + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL_V(xr_server, String()); - ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id); - if (tracker == NULL) { + XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, controller_id); + if (tracker == nullptr) { return String("Not connected"); }; return tracker->get_name(); }; -int ARVRController::get_joystick_id() const { - // get our ARVRServer - ARVRServer *arvr_server = ARVRServer::get_singleton(); - ERR_FAIL_NULL_V(arvr_server, 0); +int XRController3D::get_joystick_id() const { + // get our XRServer + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL_V(xr_server, 0); - ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id); - if (tracker == NULL) { + XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, controller_id); + if (tracker == nullptr) { // No tracker? no joystick id... (0 is our first joystick) return -1; }; @@ -300,7 +300,7 @@ int ARVRController::get_joystick_id() const { return tracker->get_joy_id(); }; -bool ARVRController::is_button_pressed(int p_button) const { +bool XRController3D::is_button_pressed(int p_button) const { int joy_id = get_joystick_id(); if (joy_id == -1) { return false; @@ -309,7 +309,7 @@ bool ARVRController::is_button_pressed(int p_button) const { return InputFilter::get_singleton()->is_joy_button_pressed(joy_id, p_button); }; -float ARVRController::get_joystick_axis(int p_axis) const { +float XRController3D::get_joystick_axis(int p_axis) const { int joy_id = get_joystick_id(); if (joy_id == -1) { return 0.0; @@ -318,59 +318,59 @@ float ARVRController::get_joystick_axis(int p_axis) const { return InputFilter::get_singleton()->get_joy_axis(joy_id, p_axis); }; -real_t ARVRController::get_rumble() const { - // get our ARVRServer - ARVRServer *arvr_server = ARVRServer::get_singleton(); - ERR_FAIL_NULL_V(arvr_server, 0.0); +real_t XRController3D::get_rumble() const { + // get our XRServer + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL_V(xr_server, 0.0); - ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id); - if (tracker == NULL) { + XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, controller_id); + if (tracker == nullptr) { return 0.0; }; return tracker->get_rumble(); }; -void ARVRController::set_rumble(real_t p_rumble) { - // get our ARVRServer - ARVRServer *arvr_server = ARVRServer::get_singleton(); - ERR_FAIL_NULL(arvr_server); +void XRController3D::set_rumble(real_t p_rumble) { + // get our XRServer + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL(xr_server); - ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id); - if (tracker != NULL) { + XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, controller_id); + if (tracker != nullptr) { tracker->set_rumble(p_rumble); }; }; -Ref<Mesh> ARVRController::get_mesh() const { +Ref<Mesh> XRController3D::get_mesh() const { return mesh; } -bool ARVRController::get_is_active() const { +bool XRController3D::get_is_active() const { return is_active; }; -ARVRPositionalTracker::TrackerHand ARVRController::get_hand() const { - // get our ARVRServer - ARVRServer *arvr_server = ARVRServer::get_singleton(); - ERR_FAIL_NULL_V(arvr_server, ARVRPositionalTracker::TRACKER_HAND_UNKNOWN); +XRPositionalTracker::TrackerHand XRController3D::get_hand() const { + // get our XRServer + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL_V(xr_server, XRPositionalTracker::TRACKER_HAND_UNKNOWN); - ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id); - if (tracker == NULL) { - return ARVRPositionalTracker::TRACKER_HAND_UNKNOWN; + XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, controller_id); + if (tracker == nullptr) { + return XRPositionalTracker::TRACKER_HAND_UNKNOWN; }; return tracker->get_hand(); }; -String ARVRController::get_configuration_warning() const { +String XRController3D::get_configuration_warning() const { if (!is_visible() || !is_inside_tree()) return String(); - // must be child node of ARVROrigin! - ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent()); - if (origin == NULL) { - return TTR("ARVRController must have an ARVROrigin node as its parent."); + // must be child node of XROrigin! + XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent()); + if (origin == nullptr) { + return TTR("XRController3D must have an XROrigin3D node as its parent."); }; if (controller_id == 0) { @@ -380,19 +380,19 @@ String ARVRController::get_configuration_warning() const { return String(); }; -ARVRController::ARVRController() { +XRController3D::XRController3D() { controller_id = 1; is_active = true; button_states = 0; }; -ARVRController::~ARVRController(){ +XRController3D::~XRController3D(){ // nothing to do here yet for now.. }; //////////////////////////////////////////////////////////////////////////////////////////////////// -void ARVRAnchor::_notification(int p_what) { +void XRAnchor3D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { set_process_internal(true); @@ -401,13 +401,13 @@ void ARVRAnchor::_notification(int p_what) { set_process_internal(false); }; break; case NOTIFICATION_INTERNAL_PROCESS: { - // get our ARVRServer - ARVRServer *arvr_server = ARVRServer::get_singleton(); - ERR_FAIL_NULL(arvr_server); + // get our XRServer + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL(xr_server); // find the tracker for our anchor - ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_ANCHOR, anchor_id); - if (tracker == NULL) { + XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_ANCHOR, anchor_id); + if (tracker == nullptr) { // this anchor is currently not available is_active = false; } else { @@ -415,7 +415,7 @@ void ARVRAnchor::_notification(int p_what) { Transform transform; // we'll need our world_scale - real_t world_scale = arvr_server->get_world_scale(); + real_t world_scale = xr_server->get_world_scale(); // get our info from our tracker transform.basis = tracker->get_orientation(); @@ -427,7 +427,7 @@ void ARVRAnchor::_notification(int p_what) { transform.basis.orthonormalize(); // apply our reference frame and set our transform - set_transform(arvr_server->get_reference_frame() * transform); + set_transform(xr_server->get_reference_frame() * transform); // check for an updated mesh Ref<Mesh> trackerMesh = tracker->get_mesh(); @@ -442,62 +442,62 @@ void ARVRAnchor::_notification(int p_what) { }; }; -void ARVRAnchor::_bind_methods() { +void XRAnchor3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_anchor_id", "anchor_id"), &ARVRAnchor::set_anchor_id); - ClassDB::bind_method(D_METHOD("get_anchor_id"), &ARVRAnchor::get_anchor_id); + ClassDB::bind_method(D_METHOD("set_anchor_id", "anchor_id"), &XRAnchor3D::set_anchor_id); + ClassDB::bind_method(D_METHOD("get_anchor_id"), &XRAnchor3D::get_anchor_id); ADD_PROPERTY(PropertyInfo(Variant::INT, "anchor_id", PROPERTY_HINT_RANGE, "0,32,1"), "set_anchor_id", "get_anchor_id"); - ClassDB::bind_method(D_METHOD("get_anchor_name"), &ARVRAnchor::get_anchor_name); + ClassDB::bind_method(D_METHOD("get_anchor_name"), &XRAnchor3D::get_anchor_name); - ClassDB::bind_method(D_METHOD("get_is_active"), &ARVRAnchor::get_is_active); - ClassDB::bind_method(D_METHOD("get_size"), &ARVRAnchor::get_size); + ClassDB::bind_method(D_METHOD("get_is_active"), &XRAnchor3D::get_is_active); + ClassDB::bind_method(D_METHOD("get_size"), &XRAnchor3D::get_size); - ClassDB::bind_method(D_METHOD("get_plane"), &ARVRAnchor::get_plane); + ClassDB::bind_method(D_METHOD("get_plane"), &XRAnchor3D::get_plane); - ClassDB::bind_method(D_METHOD("get_mesh"), &ARVRAnchor::get_mesh); + ClassDB::bind_method(D_METHOD("get_mesh"), &XRAnchor3D::get_mesh); ADD_SIGNAL(MethodInfo("mesh_updated", PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"))); }; -void ARVRAnchor::set_anchor_id(int p_anchor_id) { +void XRAnchor3D::set_anchor_id(int p_anchor_id) { // We don't check any bounds here, this anchor may not yet be active and just be a place holder until it is. // Note that setting this to 0 means this node is not bound to an anchor yet. anchor_id = p_anchor_id; update_configuration_warning(); }; -int ARVRAnchor::get_anchor_id(void) const { +int XRAnchor3D::get_anchor_id(void) const { return anchor_id; }; -Vector3 ARVRAnchor::get_size() const { +Vector3 XRAnchor3D::get_size() const { return size; }; -String ARVRAnchor::get_anchor_name(void) const { - // get our ARVRServer - ARVRServer *arvr_server = ARVRServer::get_singleton(); - ERR_FAIL_NULL_V(arvr_server, String()); +String XRAnchor3D::get_anchor_name(void) const { + // get our XRServer + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL_V(xr_server, String()); - ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_ANCHOR, anchor_id); - if (tracker == NULL) { + XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_ANCHOR, anchor_id); + if (tracker == nullptr) { return String("Not connected"); }; return tracker->get_name(); }; -bool ARVRAnchor::get_is_active() const { +bool XRAnchor3D::get_is_active() const { return is_active; }; -String ARVRAnchor::get_configuration_warning() const { +String XRAnchor3D::get_configuration_warning() const { if (!is_visible() || !is_inside_tree()) return String(); - // must be child node of ARVROrigin! - ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent()); - if (origin == NULL) { - return TTR("ARVRAnchor must have an ARVROrigin node as its parent."); + // must be child node of XROrigin3D! + XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent()); + if (origin == nullptr) { + return TTR("XRAnchor3D must have an XROrigin3D node as its parent."); }; if (anchor_id == 0) { @@ -507,7 +507,7 @@ String ARVRAnchor::get_configuration_warning() const { return String(); }; -Plane ARVRAnchor::get_plane() const { +Plane XRAnchor3D::get_plane() const { Vector3 location = get_translation(); Basis orientation = get_transform().basis; @@ -516,67 +516,67 @@ Plane ARVRAnchor::get_plane() const { return plane; }; -Ref<Mesh> ARVRAnchor::get_mesh() const { +Ref<Mesh> XRAnchor3D::get_mesh() const { return mesh; } -ARVRAnchor::ARVRAnchor() { +XRAnchor3D::XRAnchor3D() { anchor_id = 1; is_active = true; }; -ARVRAnchor::~ARVRAnchor(){ +XRAnchor3D::~XRAnchor3D(){ // nothing to do here yet for now.. }; //////////////////////////////////////////////////////////////////////////////////////////////////// -String ARVROrigin::get_configuration_warning() const { +String XROrigin3D::get_configuration_warning() const { if (!is_visible() || !is_inside_tree()) return String(); - if (tracked_camera == NULL) - return TTR("ARVROrigin requires an ARVRCamera child node."); + if (tracked_camera == nullptr) + return TTR("XROrigin3D requires an XRCamera3D child node."); return String(); }; -void ARVROrigin::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_world_scale", "world_scale"), &ARVROrigin::set_world_scale); - ClassDB::bind_method(D_METHOD("get_world_scale"), &ARVROrigin::get_world_scale); +void XROrigin3D::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_world_scale", "world_scale"), &XROrigin3D::set_world_scale); + ClassDB::bind_method(D_METHOD("get_world_scale"), &XROrigin3D::get_world_scale); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "world_scale"), "set_world_scale", "get_world_scale"); }; -void ARVROrigin::set_tracked_camera(ARVRCamera *p_tracked_camera) { +void XROrigin3D::set_tracked_camera(XRCamera3D *p_tracked_camera) { tracked_camera = p_tracked_camera; }; -void ARVROrigin::clear_tracked_camera_if(ARVRCamera *p_tracked_camera) { +void XROrigin3D::clear_tracked_camera_if(XRCamera3D *p_tracked_camera) { if (tracked_camera == p_tracked_camera) { - tracked_camera = NULL; + tracked_camera = nullptr; }; }; -float ARVROrigin::get_world_scale() const { - // get our ARVRServer - ARVRServer *arvr_server = ARVRServer::get_singleton(); - ERR_FAIL_NULL_V(arvr_server, 1.0); +float XROrigin3D::get_world_scale() const { + // get our XRServer + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL_V(xr_server, 1.0); - return arvr_server->get_world_scale(); + return xr_server->get_world_scale(); }; -void ARVROrigin::set_world_scale(float p_world_scale) { - // get our ARVRServer - ARVRServer *arvr_server = ARVRServer::get_singleton(); - ERR_FAIL_NULL(arvr_server); +void XROrigin3D::set_world_scale(float p_world_scale) { + // get our XRServer + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL(xr_server); - arvr_server->set_world_scale(p_world_scale); + xr_server->set_world_scale(p_world_scale); }; -void ARVROrigin::_notification(int p_what) { - // get our ARVRServer - ARVRServer *arvr_server = ARVRServer::get_singleton(); - ERR_FAIL_NULL(arvr_server); +void XROrigin3D::_notification(int p_what) { + // get our XRServer + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL(xr_server); switch (p_what) { case NOTIFICATION_ENTER_TREE: { @@ -587,13 +587,13 @@ void ARVROrigin::_notification(int p_what) { }; break; case NOTIFICATION_INTERNAL_PROCESS: { // set our world origin to our node transform - arvr_server->set_world_origin(get_global_transform()); + xr_server->set_world_origin(get_global_transform()); // check if we have a primary interface - Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface(); - if (arvr_interface.is_valid() && tracked_camera != NULL) { + Ref<XRInterface> xr_interface = xr_server->get_primary_interface(); + if (xr_interface.is_valid() && tracked_camera != nullptr) { // get our positioning transform for our headset - Transform t = arvr_interface->get_transform_for_eye(ARVRInterface::EYE_MONO, Transform()); + Transform t = xr_interface->get_transform_for_eye(XRInterface::EYE_MONO, Transform()); // now apply this to our camera tracked_camera->set_transform(t); @@ -603,19 +603,19 @@ void ARVROrigin::_notification(int p_what) { break; }; - // send our notification to all active ARVR interfaces, they may need to react to it also - for (int i = 0; i < arvr_server->get_interface_count(); i++) { - Ref<ARVRInterface> interface = arvr_server->get_interface(i); + // send our notification to all active XE interfaces, they may need to react to it also + for (int i = 0; i < xr_server->get_interface_count(); i++) { + Ref<XRInterface> interface = xr_server->get_interface(i); if (interface.is_valid() && interface->is_initialized()) { interface->notification(p_what); } } }; -ARVROrigin::ARVROrigin() { - tracked_camera = NULL; +XROrigin3D::XROrigin3D() { + tracked_camera = nullptr; }; -ARVROrigin::~ARVROrigin(){ +XROrigin3D::~XROrigin3D(){ // nothing to do here yet for now.. }; diff --git a/scene/3d/arvr_nodes.h b/scene/3d/xr_nodes.h index bc5df2e174..a2f16545d1 100644 --- a/scene/3d/arvr_nodes.h +++ b/scene/3d/xr_nodes.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* arvr_nodes.h */ +/* xr_nodes.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,24 +28,24 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef ARVR_NODES_H -#define ARVR_NODES_H +#ifndef XR_NODES_H +#define XR_NODES_H #include "scene/3d/camera_3d.h" #include "scene/3d/node_3d.h" #include "scene/resources/mesh.h" -#include "servers/arvr/arvr_positional_tracker.h" +#include "servers/xr/xr_positional_tracker.h" /** @author Bastiaan Olij <mux213@gmail.com> **/ /* - ARVRCamera is a subclass of camera which will register itself with its parent ARVROrigin and as a result is automatically positioned + XRCamera is a subclass of camera which will register itself with its parent XROrigin and as a result is automatically positioned */ -class ARVRCamera : public Camera3D { +class XRCamera3D : public Camera3D { - GDCLASS(ARVRCamera, Camera3D); + GDCLASS(XRCamera3D, Camera3D); protected: void _notification(int p_what); @@ -58,19 +58,19 @@ public: virtual Vector3 project_position(const Point2 &p_point, float p_z_depth) const; virtual Vector<Plane> get_frustum() const; - ARVRCamera(); - ~ARVRCamera(); + XRCamera3D(); + ~XRCamera3D(); }; /* - ARVRController is a helper node that automatically updates its position based on tracker data. + XRController3D is a helper node that automatically updates its position based on tracker data. - It must be a child node of our ARVROrigin node + It must be a child node of our XROrigin node */ -class ARVRController : public Node3D { +class XRController3D : public Node3D { - GDCLASS(ARVRController, Node3D); + GDCLASS(XRController3D, Node3D); private: int controller_id; @@ -95,23 +95,23 @@ public: void set_rumble(real_t p_rumble); bool get_is_active() const; - ARVRPositionalTracker::TrackerHand get_hand() const; + XRPositionalTracker::TrackerHand get_hand() const; Ref<Mesh> get_mesh(void) const; String get_configuration_warning() const; - ARVRController(); - ~ARVRController(); + XRController3D(); + ~XRController3D(); }; /* - ARVRAnchor is a helper node that automatically updates its position based on anchor data, it represents a real world location. - It must be a child node of our ARVROrigin node + XRAnchor3D is a helper node that automatically updates its position based on anchor data, it represents a real world location. + It must be a child node of our XROrigin3D node */ -class ARVRAnchor : public Node3D { - GDCLASS(ARVRAnchor, Node3D); +class XRAnchor3D : public Node3D { + GDCLASS(XRAnchor3D, Node3D); private: int anchor_id; @@ -137,24 +137,24 @@ public: String get_configuration_warning() const; - ARVRAnchor(); - ~ARVRAnchor(); + XRAnchor3D(); + ~XRAnchor3D(); }; /* - ARVROrigin is special spatial node that acts as our origin point mapping our real world center of our tracking volume into our virtual world. + XROrigin3D is special spatial node that acts as our origin point mapping our real world center of our tracking volume into our virtual world. It is this point that you will move around the world as the player 'moves while standing still', i.e. the player moves through teleporting or controller inputs as opposed to physically moving. Our camera and controllers will always be child nodes and thus place relative to this origin point. - This node will automatically locate any camera child nodes and update its position while our ARVRController node will handle tracked controllers. + This node will automatically locate any camera child nodes and update its position while our XRController3D node will handle tracked controllers. */ -class ARVROrigin : public Node3D { +class XROrigin3D : public Node3D { - GDCLASS(ARVROrigin, Node3D); + GDCLASS(XROrigin3D, Node3D); private: - ARVRCamera *tracked_camera; + XRCamera3D *tracked_camera; protected: void _notification(int p_what); @@ -163,14 +163,14 @@ protected: public: String get_configuration_warning() const; - void set_tracked_camera(ARVRCamera *p_tracked_camera); - void clear_tracked_camera_if(ARVRCamera *p_tracked_camera); + void set_tracked_camera(XRCamera3D *p_tracked_camera); + void clear_tracked_camera_if(XRCamera3D *p_tracked_camera); float get_world_scale() const; void set_world_scale(float p_world_scale); - ARVROrigin(); - ~ARVROrigin(); + XROrigin3D(); + ~XROrigin3D(); }; -#endif /* ARVR_NODES_H */ +#endif /* XR_NODES_H */ diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index 8ba7a38628..570735ad87 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -41,7 +41,7 @@ StringName AnimationNodeAnimation::get_animation() const { return animation; } -Vector<String> (*AnimationNodeAnimation::get_editable_animation_list)() = NULL; +Vector<String> (*AnimationNodeAnimation::get_editable_animation_list)() = nullptr; void AnimationNodeAnimation::get_parameter_list(List<PropertyInfo> *r_list) const { r_list->push_back(PropertyInfo(Variant::FLOAT, time, PROPERTY_HINT_NONE, "", 0)); diff --git a/scene/animation/animation_cache.cpp b/scene/animation/animation_cache.cpp index 79a7c36e7f..ab8be47b4d 100644 --- a/scene/animation/animation_cache.cpp +++ b/scene/animation/animation_cache.cpp @@ -287,7 +287,7 @@ void AnimationCache::set_all(float p_time, float p_delta) { if (!args.size()) { - call_track(i, name, NULL, 0, err); + call_track(i, name, nullptr, 0, err); } else { Vector<const Variant *> argptrs; @@ -332,7 +332,7 @@ void AnimationCache::set_root(Node *p_root) { AnimationCache::AnimationCache() { - root = NULL; + root = nullptr; cache_dirty = true; cache_valid = false; } diff --git a/scene/animation/animation_cache.h b/scene/animation/animation_cache.h index 20147f060b..23312ca7ec 100644 --- a/scene/animation/animation_cache.h +++ b/scene/animation/animation_cache.h @@ -50,12 +50,12 @@ class AnimationCache : public Object { Vector<StringName> subpath; bool valid; Path() { - object = NULL; - skeleton = NULL; - node = NULL; + object = nullptr; + skeleton = nullptr; + node = nullptr; bone_idx = -1; valid = false; - spatial = NULL; + spatial = nullptr; } }; diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index ce1e75a61d..9f5e06c43d 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -225,7 +225,7 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_sta } //find the last cost transition - List<int>::Element *least_cost_transition = NULL; + List<int>::Element *least_cost_transition = nullptr; float least_cost = 1e20; for (List<int>::Element *E = open_list.front(); E; E = E->next()) { @@ -516,6 +516,11 @@ AnimationNodeStateMachinePlayback::AnimationNodeStateMachinePlayback() { len_current = 0; fading_time = 0; stop_request = false; + len_total = 0.0; + pos_current = 0.0; + loops_current = 0; + fading_pos = 0.0; + start_request_travel = false; } /////////////////////////////////////////////////////// @@ -525,7 +530,7 @@ void AnimationNodeStateMachine::get_parameter_list(List<PropertyInfo> *r_list) c List<StringName> advance_conditions; for (int i = 0; i < transitions.size(); i++) { StringName ac = transitions[i].transition->get_advance_condition_name(); - if (ac != StringName() && advance_conditions.find(ac) == NULL) { + if (ac != StringName() && advance_conditions.find(ac) == nullptr) { advance_conditions.push_back(ac); } } diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 6c870682a6..b657833a3b 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -244,7 +244,7 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) { for (int i = 0; i < a->get_track_count(); i++) { - p_anim->node_cache.write[i] = NULL; + p_anim->node_cache.write[i] = nullptr; RES resource; Vector<StringName> leftover_path; Node *child = parent->get_node_and_resource(a->track_get_path(i), resource, leftover_path); @@ -293,13 +293,13 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) { p_anim->node_cache[i]->bone_idx = p_anim->node_cache[i]->skeleton->find_bone(bone_name); if (p_anim->node_cache[i]->bone_idx < 0) { // broken track (nonexistent bone) - p_anim->node_cache[i]->skeleton = NULL; - p_anim->node_cache[i]->spatial = NULL; + p_anim->node_cache[i]->skeleton = nullptr; + p_anim->node_cache[i]->spatial = nullptr; ERR_CONTINUE(p_anim->node_cache[i]->bone_idx < 0); } } else { // no property, just use spatialnode - p_anim->node_cache[i]->skeleton = NULL; + p_anim->node_cache[i]->skeleton = nullptr; } } } @@ -830,7 +830,7 @@ void AnimationPlayer::_animation_process2(float p_delta, bool p_started) { c.seeked = false; } - List<Blend>::Element *prev = NULL; + List<Blend>::Element *prev = nullptr; for (List<Blend>::Element *E = c.blend.back(); E; E = prev) { Blend &b = E->get(); @@ -1242,19 +1242,6 @@ void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float bool AnimationPlayer::is_playing() const { return playing; - /* - if (playback.current.from==NULL) - return false; - - float len=playback.current.from->animation->get_length(); - float pos = playback.current.pos; - bool loop=playback.current.from->animation->has_loop(); - if (!loop && pos >= len) { - return false; - }; - - return true; - */ } void AnimationPlayer::set_current_animation(const String &p_anim) { @@ -1296,7 +1283,7 @@ void AnimationPlayer::stop(bool p_reset) { Playback &c = playback; c.blend.clear(); if (p_reset) { - c.current.from = NULL; + c.current.from = nullptr; c.current.speed_scale = 1; c.current.pos = 0; } diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h index 32bed6f4d6..c134aff707 100644 --- a/scene/animation/animation_player.h +++ b/scene/animation/animation_player.h @@ -118,9 +118,9 @@ private: Variant capture; PropertyAnim() : - owner(NULL), + owner(nullptr), special(SP_NONE), - object(NULL), + object(nullptr), accum_pass(0) {} }; @@ -135,9 +135,9 @@ private: uint64_t accum_pass; BezierAnim() : - owner(NULL), + owner(nullptr), bezier_accum(0.0), - object(NULL), + object(nullptr), accum_pass(0) {} }; @@ -145,10 +145,10 @@ private: TrackNodeCache() : id(0), - node(NULL), - spatial(NULL), - node_2d(NULL), - skeleton(NULL), + node(nullptr), + spatial(nullptr), + node_2d(nullptr), + skeleton(nullptr), bone_idx(-1), accum_pass(0), audio_playing(false), @@ -212,7 +212,7 @@ private: pos = 0; speed_scale = 1.0; - from = NULL; + from = nullptr; } }; diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index 0e1089cc6a..f8b3ca291b 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -128,8 +128,8 @@ float AnimationNode::_pre_process(const StringName &p_base_path, AnimationNode * float t = process(p_time, p_seek); - state = NULL; - parent = NULL; + state = nullptr; + parent = nullptr; base_path = StringName(); connections.clear(); @@ -164,7 +164,7 @@ float AnimationNode::blend_input(int p_input, float p_time, bool p_seek, float p //inputs.write[p_input].last_pass = state->last_pass; float activity = 0; - float ret = _blend_node(node_name, blend_tree->get_node_connection_array(node_name), NULL, node, p_time, p_seek, p_blend, p_filter, p_optimize, &activity); + float ret = _blend_node(node_name, blend_tree->get_node_connection_array(node_name), nullptr, node, p_time, p_seek, p_blend, p_filter, p_optimize, &activity); Vector<AnimationTree::Activity> *activity_ptr = state->tree->input_activity_map.getptr(base_path); @@ -202,7 +202,7 @@ float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Strin blendw[i] = 0.0; //all to zero by default } - const NodePath *K = NULL; + const NodePath *K = nullptr; while ((K = filter.next(K))) { if (!state->track_map.has(*K)) { continue; @@ -316,7 +316,7 @@ String AnimationNode::get_caption() const { void AnimationNode::add_input(const String &p_name) { //root nodes can't add inputs - ERR_FAIL_COND(Object::cast_to<AnimationRootNode>(this) != NULL); + ERR_FAIL_COND(Object::cast_to<AnimationRootNode>(this) != nullptr); Input input; ERR_FAIL_COND(p_name.find(".") != -1 || p_name.find("/") != -1); input.name = p_name; @@ -374,7 +374,7 @@ Array AnimationNode::_get_filters() const { Array paths; - const NodePath *K = NULL; + const NodePath *K = nullptr; while ((K = filter.next(K))) { paths.push_back(String(*K)); //use strings, so sorting is possible } @@ -453,8 +453,8 @@ void AnimationNode::_bind_methods() { AnimationNode::AnimationNode() { - state = NULL; - parent = NULL; + state = nullptr; + parent = nullptr; filter_enabled = false; } @@ -558,17 +558,17 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { NodePath path = anim->track_get_path(i); Animation::TrackType track_type = anim->track_get_type(i); - TrackCache *track = NULL; + TrackCache *track = nullptr; if (track_cache.has(path)) { track = track_cache.get(path); } //if not valid, delete track - if (track && (track->type != track_type || ObjectDB::get_instance(track->object_id) == NULL)) { + if (track && (track->type != track_type || ObjectDB::get_instance(track->object_id) == nullptr)) { playing_caches.erase(track); memdelete(track); track_cache.erase(path); - track = NULL; + track = nullptr; } if (!track) { @@ -615,7 +615,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { TrackCacheTransform *track_xform = memnew(TrackCacheTransform); track_xform->spatial = spatial; - track_xform->skeleton = NULL; + track_xform->skeleton = nullptr; track_xform->bone_idx = -1; if (path.get_subname_count() == 1 && Object::cast_to<Skeleton3D>(spatial)) { @@ -700,7 +700,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { List<NodePath> to_delete; - const NodePath *K = NULL; + const NodePath *K = nullptr; while ((K = track_cache.next(K))) { TrackCache *tc = track_cache[*K]; if (tc->setup_pass != setup_pass) { @@ -717,7 +717,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { state.track_map.clear(); - K = NULL; + K = nullptr; int idx = 0; while ((K = track_cache.next(K))) { state.track_map[*K] = idx; @@ -733,7 +733,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { void AnimationTree::_clear_caches() { - const NodePath *K = NULL; + const NodePath *K = nullptr; while ((K = track_cache.next(K))) { memdelete(track_cache[*K]); } @@ -829,11 +829,11 @@ void AnimationTree::_process_graph(float p_delta) { if (started) { //if started, seek - root->_pre_process(SceneStringNames::get_singleton()->parameters_base_path, NULL, &state, 0, true, Vector<StringName>()); + root->_pre_process(SceneStringNames::get_singleton()->parameters_base_path, nullptr, &state, 0, true, Vector<StringName>()); started = false; } - root->_pre_process(SceneStringNames::get_singleton()->parameters_base_path, NULL, &state, p_delta, false, Vector<StringName>()); + root->_pre_process(SceneStringNames::get_singleton()->parameters_base_path, nullptr, &state, p_delta, false, Vector<StringName>()); } if (!state.valid) { @@ -1224,7 +1224,7 @@ void AnimationTree::_process_graph(float p_delta) { { // finally, set the tracks - const NodePath *K = NULL; + const NodePath *K = nullptr; while ((K = track_cache.next(K))) { TrackCache *track = track_cache[*K]; if (track->process_pass != process_pass) diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h index faf4333f1d..d558170f23 100644 --- a/scene/animation/animation_tree.h +++ b/scene/animation/animation_tree.h @@ -101,7 +101,7 @@ public: Array _get_filters() const; void _set_filters(const Array &p_filters); friend class AnimationNodeBlendTree; - float _blend_node(const StringName &p_subpath, const Vector<StringName> &p_connections, AnimationNode *p_new_parent, Ref<AnimationNode> p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true, float *r_max = NULL); + float _blend_node(const StringName &p_subpath, const Vector<StringName> &p_connections, AnimationNode *p_new_parent, Ref<AnimationNode> p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true, float *r_max = nullptr); protected: void blend_animation(const StringName &p_animation, float p_time, float p_delta, bool p_seeked, float p_blend); @@ -186,7 +186,7 @@ private: root_motion = false; setup_pass = 0; process_pass = 0; - object = NULL; + object = nullptr; } virtual ~TrackCache() {} }; @@ -202,9 +202,9 @@ private: TrackCacheTransform() { type = Animation::TYPE_TRANSFORM; - spatial = NULL; + spatial = nullptr; bone_idx = -1; - skeleton = NULL; + skeleton = nullptr; } }; diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 628568afbb..bc28c38e2c 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -297,7 +297,7 @@ Variant Tween::_get_initial_val(const InterpolateData &p_data) const { case TARGETING_METHOD: { // Get the object that is being targeted Object *object = ObjectDB::get_instance(p_data.target_id); - ERR_FAIL_COND_V(object == NULL, p_data.initial_val); + ERR_FAIL_COND_V(object == nullptr, p_data.initial_val); // Are we targeting a property or a method? Variant initial_val; @@ -309,7 +309,7 @@ Variant Tween::_get_initial_val(const InterpolateData &p_data) const { } else { // Call the method and get the initial value from it Callable::CallError error; - initial_val = object->call(p_data.target_key[0], NULL, 0, error); + initial_val = object->call(p_data.target_key[0], nullptr, 0, error); ERR_FAIL_COND_V(error.error != Callable::CallError::CALL_OK, p_data.initial_val); } return initial_val; @@ -329,7 +329,7 @@ Variant Tween::_get_final_val(const InterpolateData &p_data) const { case FOLLOW_METHOD: { // Get the object that is being followed Object *target = ObjectDB::get_instance(p_data.target_id); - ERR_FAIL_COND_V(target == NULL, p_data.initial_val); + ERR_FAIL_COND_V(target == nullptr, p_data.initial_val); // We want to figure out the final value Variant final_val; @@ -341,7 +341,7 @@ Variant Tween::_get_final_val(const InterpolateData &p_data) const { } else { // We're looking at a method. Call the method on the target object Callable::CallError error; - final_val = target->call(p_data.target_key[0], NULL, 0, error); + final_val = target->call(p_data.target_key[0], nullptr, 0, error); ERR_FAIL_COND_V(error.error != Callable::CallError::CALL_OK, p_data.initial_val); } @@ -371,7 +371,7 @@ Variant &Tween::_get_delta_val(InterpolateData &p_data) { case FOLLOW_METHOD: { // We're following an object, so grab that instance Object *target = ObjectDB::get_instance(p_data.target_id); - ERR_FAIL_COND_V(target == NULL, p_data.initial_val); + ERR_FAIL_COND_V(target == nullptr, p_data.initial_val); // We want to figure out the final value Variant final_val; @@ -383,7 +383,7 @@ Variant &Tween::_get_delta_val(InterpolateData &p_data) { } else { // We're looking at a method. Call the method on the target object Callable::CallError error; - final_val = target->call(p_data.target_key[0], NULL, 0, error); + final_val = target->call(p_data.target_key[0], nullptr, 0, error); ERR_FAIL_COND_V(error.error != Callable::CallError::CALL_OK, p_data.initial_val); } @@ -607,7 +607,7 @@ bool Tween::_apply_tween_value(InterpolateData &p_data, Variant &value) { // Get the object we want to apply the new value to Object *object = ObjectDB::get_instance(p_data.id); - ERR_FAIL_COND_V(object == NULL, false); + ERR_FAIL_COND_V(object == nullptr, false); // What kind of data are we mutating? switch (p_data.type) { @@ -634,7 +634,7 @@ bool Tween::_apply_tween_value(InterpolateData &p_data, Variant &value) { object->call(p_data.key[0], (const Variant **)arg, 1, error); } else { // Don't pass any argument - object->call(p_data.key[0], NULL, 0, error); + object->call(p_data.key[0], nullptr, 0, error); } // Did we get an error from the function call? @@ -700,7 +700,7 @@ void Tween::_tween_process(float p_delta) { // Get the target object for this interpolation Object *object = ObjectDB::get_instance(data.id); - if (object == NULL) + if (object == nullptr) continue; // Are we still delaying this tween? @@ -860,7 +860,7 @@ void Tween::reset(Object *p_object, StringName p_key) { // Get the target object InterpolateData &data = E->get(); Object *object = ObjectDB::get_instance(data.id); - if (object == NULL) + if (object == nullptr) continue; // Do we have the correct object and key? @@ -901,7 +901,7 @@ void Tween::stop(Object *p_object, StringName p_key) { // Get the object the tween is targeting InterpolateData &data = E->get(); Object *object = ObjectDB::get_instance(data.id); - if (object == NULL) + if (object == nullptr) continue; // Is this the correct object and does it have the given key? @@ -937,7 +937,7 @@ void Tween::resume(Object *p_object, StringName p_key) { // Grab the object InterpolateData &data = E->get(); Object *object = ObjectDB::get_instance(data.id); - if (object == NULL) + if (object == nullptr) continue; // If the object and string key match, activate it @@ -975,7 +975,7 @@ void Tween::remove(Object *p_object, StringName p_key) { // Get the target object InterpolateData &data = E->get(); Object *object = ObjectDB::get_instance(data.id); - if (object == NULL) + if (object == nullptr) continue; // If the target object and string key match, queue it for removal @@ -1264,7 +1264,7 @@ void Tween::_build_interpolation(InterpolateType p_interpolation_type, Object *p // Validate and apply interpolation data // Give it the object - ERR_FAIL_COND_MSG(p_object == NULL, "Invalid object provided to Tween."); + ERR_FAIL_COND_MSG(p_object == nullptr, "Invalid object provided to Tween."); data.id = p_object->get_instance_id(); // Validate the initial and final values @@ -1335,7 +1335,7 @@ void Tween::interpolate_property(Object *p_object, NodePath p_property, Variant if (p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); // Build the interpolation data - _build_interpolation(INTER_PROPERTY, p_object, &p_property, NULL, p_initial_val, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay); + _build_interpolation(INTER_PROPERTY, p_object, &p_property, nullptr, p_initial_val, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay); } void Tween::interpolate_method(Object *p_object, StringName p_method, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) { @@ -1350,7 +1350,7 @@ void Tween::interpolate_method(Object *p_object, StringName p_method, Variant p_ if (p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); // Build the interpolation data - _build_interpolation(INTER_METHOD, p_object, NULL, &p_method, p_initial_val, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay); + _build_interpolation(INTER_METHOD, p_object, nullptr, &p_method, p_initial_val, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay); } void Tween::interpolate_callback(Object *p_object, real_t p_duration, String p_callback, VARIANT_ARG_DECLARE) { @@ -1361,7 +1361,7 @@ void Tween::interpolate_callback(Object *p_object, real_t p_duration, String p_c } // Check that the target object is valid - ERR_FAIL_COND(p_object == NULL); + ERR_FAIL_COND(p_object == nullptr); // Duration cannot be negative ERR_FAIL_COND(p_duration < 0); @@ -1418,7 +1418,7 @@ void Tween::interpolate_deferred_callback(Object *p_object, real_t p_duration, S } // Check that the target object is valid - ERR_FAIL_COND(p_object == NULL); + ERR_FAIL_COND(p_object == nullptr); // No negative durations allowed ERR_FAIL_COND(p_duration < 0); @@ -1486,8 +1486,8 @@ void Tween::follow_property(Object *p_object, NodePath p_property, Variant p_ini if (p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t(); // Confirm the source and target objects are valid - ERR_FAIL_COND(p_object == NULL); - ERR_FAIL_COND(p_target == NULL); + ERR_FAIL_COND(p_object == nullptr); + ERR_FAIL_COND(p_target == nullptr); // No negative durations ERR_FAIL_COND(p_duration < 0); @@ -1547,8 +1547,8 @@ void Tween::follow_method(Object *p_object, StringName p_method, Variant p_initi if (p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t(); // Verify the source and target objects are valid - ERR_FAIL_COND(p_object == NULL); - ERR_FAIL_COND(p_target == NULL); + ERR_FAIL_COND(p_object == nullptr); + ERR_FAIL_COND(p_target == nullptr); // No negative durations ERR_FAIL_COND(p_duration < 0); @@ -1566,7 +1566,7 @@ void Tween::follow_method(Object *p_object, StringName p_method, Variant p_initi // Call the method to get the target value Callable::CallError error; - Variant target_val = p_target->call(p_target_method, NULL, 0, error); + Variant target_val = p_target->call(p_target_method, nullptr, 0, error); ERR_FAIL_COND(error.error != Callable::CallError::CALL_OK); // Convert target INT values to FLOAT as they are better for interpolation @@ -1610,8 +1610,8 @@ void Tween::targeting_property(Object *p_object, NodePath p_property, Object *p_ if (p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); // Verify both objects are valid - ERR_FAIL_COND(p_object == NULL); - ERR_FAIL_COND(p_initial == NULL); + ERR_FAIL_COND(p_object == nullptr); + ERR_FAIL_COND(p_initial == nullptr); // No negative durations ERR_FAIL_COND(p_duration < 0); @@ -1676,8 +1676,8 @@ void Tween::targeting_method(Object *p_object, StringName p_method, Object *p_in if (p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); // Make sure the given objects are valid - ERR_FAIL_COND(p_object == NULL); - ERR_FAIL_COND(p_initial == NULL); + ERR_FAIL_COND(p_object == nullptr); + ERR_FAIL_COND(p_initial == nullptr); // No negative durations ERR_FAIL_COND(p_duration < 0); @@ -1695,7 +1695,7 @@ void Tween::targeting_method(Object *p_object, StringName p_method, Object *p_in // Call the method to get the initial value Callable::CallError error; - Variant initial_val = p_initial->call(p_initial_method, NULL, 0, error); + Variant initial_val = p_initial->call(p_initial_method, nullptr, 0, error); ERR_FAIL_COND(error.error != Callable::CallError::CALL_OK); // Convert initial INT values to FLOAT as they aer better for interpolation diff --git a/scene/audio/audio_stream_player.cpp b/scene/audio/audio_stream_player.cpp index 2582bab200..f612944a62 100644 --- a/scene/audio/audio_stream_player.cpp +++ b/scene/audio/audio_stream_player.cpp @@ -36,7 +36,7 @@ void AudioStreamPlayer::_mix_to_bus(const AudioFrame *p_frames, int p_amount) { int bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus); - AudioFrame *targets[4] = { NULL, NULL, NULL, NULL }; + AudioFrame *targets[4] = { nullptr, nullptr, nullptr, nullptr }; if (AudioServer::get_singleton()->get_speaker_mode() == AudioServer::SPEAKER_MODE_STEREO) { targets[0] = AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index, 0); diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp index 359f936793..8cb63c4ab5 100644 --- a/scene/debugger/scene_debugger.cpp +++ b/scene/debugger/scene_debugger.cpp @@ -40,7 +40,7 @@ void SceneDebugger::initialize() { #ifdef DEBUG_ENABLED LiveEditor::singleton = memnew(LiveEditor); - EngineDebugger::register_message_capture("scene", EngineDebugger::Capture(NULL, SceneDebugger::parse_message)); + EngineDebugger::register_message_capture("scene", EngineDebugger::Capture(nullptr, SceneDebugger::parse_message)); #endif } @@ -51,7 +51,7 @@ void SceneDebugger::deinitialize() { if (EngineDebugger::has_capture("scene")) EngineDebugger::unregister_message_capture("scene"); memdelete(LiveEditor::singleton); - LiveEditor::singleton = NULL; + LiveEditor::singleton = nullptr; } #endif } @@ -279,7 +279,7 @@ SceneDebuggerObject::SceneDebuggerObject(ObjectID p_id) { } } else if (Script *s = Object::cast_to<Script>(obj)) { // Add script constants (no instance). - _parse_script_properties(s, NULL); + _parse_script_properties(s, nullptr); } // Add base object properties. @@ -373,7 +373,7 @@ void SceneDebuggerObject::serialize(Array &r_arr, int p_max_size) { var = res->get_path(); } else { //only send information that can be sent.. int len = 0; //test how big is this to encode - encode_variant(var, NULL, len); + encode_variant(var, nullptr, len); if (len > p_max_size) { //limit to max size hint = PROPERTY_HINT_OBJECT_TOO_BIG; hint_string = ""; @@ -478,7 +478,7 @@ void SceneDebuggerTree::deserialize(const Array &p_arr) { } /// LiveEditor -LiveEditor *LiveEditor::singleton = NULL; +LiveEditor *LiveEditor::singleton = nullptr; LiveEditor *LiveEditor::get_singleton() { return singleton; } @@ -515,7 +515,7 @@ void LiveEditor::_node_set_func(int p_id, const StringName &p_prop, const Varian return; NodePath np = live_edit_node_path_cache[p_id]; - Node *base = NULL; + Node *base = nullptr; if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); @@ -553,7 +553,7 @@ void LiveEditor::_node_call_func(int p_id, const StringName &p_method, VARIANT_A return; NodePath np = live_edit_node_path_cache[p_id]; - Node *base = NULL; + Node *base = nullptr; if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); @@ -626,7 +626,7 @@ void LiveEditor::_create_node_func(const NodePath &p_parent, const String &p_typ if (!scene_tree) return; - Node *base = NULL; + Node *base = nullptr; if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); @@ -664,7 +664,7 @@ void LiveEditor::_instance_node_func(const NodePath &p_parent, const String &p_p if (!ps.is_valid()) return; - Node *base = NULL; + Node *base = nullptr; if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); @@ -697,7 +697,7 @@ void LiveEditor::_remove_node_func(const NodePath &p_at) { if (!scene_tree) return; - Node *base = NULL; + Node *base = nullptr; if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); @@ -728,7 +728,7 @@ void LiveEditor::_remove_and_keep_node_func(const NodePath &p_at, ObjectID p_kee if (!scene_tree) return; - Node *base = NULL; + Node *base = nullptr; if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); @@ -762,7 +762,7 @@ void LiveEditor::_restore_node_func(ObjectID p_id, const NodePath &p_at, int p_a if (!scene_tree) return; - Node *base = NULL; + Node *base = nullptr; if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); @@ -808,7 +808,7 @@ void LiveEditor::_duplicate_node_func(const NodePath &p_at, const String &p_new_ if (!scene_tree) return; - Node *base = NULL; + Node *base = nullptr; if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); @@ -841,7 +841,7 @@ void LiveEditor::_reparent_node_func(const NodePath &p_at, const NodePath &p_new if (!scene_tree) return; - Node *base = NULL; + Node *base = nullptr; if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index a05ac08e9d..1cdc6f8057 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -498,7 +498,7 @@ BaseButton *ButtonGroup::get_pressed_button() { return E->get(); } - return NULL; + return nullptr; } void ButtonGroup::_bind_methods() { diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 2ec9bb2292..5e0f4c91e8 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -80,7 +80,7 @@ void ColorPicker::_notification(int p_what) { } break; case NOTIFICATION_WM_CLOSE_REQUEST: { - if (screen != NULL && screen->is_visible()) + if (screen != nullptr && screen->is_visible()) screen->hide(); } break; } @@ -275,7 +275,7 @@ void ColorPicker::_text_type_toggled() { c_text->set_editable(false); } else { text_type->set_text("#"); - text_type->set_icon(NULL); + text_type->set_icon(nullptr); c_text->set_editable(true); } @@ -732,7 +732,7 @@ ColorPicker::ColorPicker() : changing_color = false; presets_enabled = true; presets_visible = true; - screen = NULL; + screen = nullptr; HBoxContainer *hb_edit = memnew(HBoxContainer); add_child(hb_edit); @@ -1024,8 +1024,8 @@ ColorPickerButton::ColorPickerButton() { // Initialization is now done deferred, // this improves performance in the inspector as the color picker // can be expensive to initialize. - picker = NULL; - popup = NULL; + picker = nullptr; + popup = nullptr; edit_alpha = true; set_toggle_mode(true); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 0d982dbc02..b4dc37c74f 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -455,13 +455,13 @@ void Control::remove_child_notify(Node *p_child) { Control *child_c = Object::cast_to<Control>(p_child); if (child_c && (child_c->data.theme_owner || child_c->data.theme_owner_window) && child_c->data.theme.is_null()) { - _propagate_theme_changed(child_c, NULL, NULL); + _propagate_theme_changed(child_c, nullptr, nullptr); } Window *child_w = Object::cast_to<Window>(p_child); if (child_w && (child_w->theme_owner || child_w->theme_owner_window) && child_w->theme.is_null()) { - _propagate_theme_changed(child_w, NULL, NULL); + _propagate_theme_changed(child_w, nullptr, nullptr); } } @@ -495,7 +495,7 @@ void Control::_notification(int p_notification) { data.parent = Object::cast_to<Control>(get_parent()); Node *parent = this; //meh - Control *parent_control = NULL; + Control *parent_control = nullptr; bool subwindow = false; while (parent) { @@ -548,7 +548,7 @@ void Control::_notification(int p_notification) { if (data.parent_canvas_item) { data.parent_canvas_item->disconnect("item_rect_changed", callable_mp(this, &Control::_size_changed)); - data.parent_canvas_item = NULL; + data.parent_canvas_item = nullptr; } else if (!is_set_as_toplevel()) { //disconnect viewport get_viewport()->disconnect("size_changed", callable_mp(this, &Control::_size_changed)); @@ -556,17 +556,11 @@ void Control::_notification(int p_notification) { if (data.RI) { get_viewport()->_gui_remove_root_control(data.RI); - data.RI = NULL; + data.RI = nullptr; } - data.parent = NULL; - data.parent_canvas_item = NULL; - /* - if (data.theme_owner && data.theme.is_null()) { - data.theme_owner=NULL; - notification(NOTIFICATION_THEME_CHANGED); - } - */ + data.parent = nullptr; + data.parent_canvas_item = nullptr; } break; case NOTIFICATION_MOVED_IN_PARENT: { @@ -621,7 +615,7 @@ void Control::_notification(int p_notification) { if (!is_visible_in_tree()) { - if (get_viewport() != NULL) + if (get_viewport() != nullptr) get_viewport()->_gui_hid_control(this); //remove key focus @@ -753,7 +747,7 @@ Size2 Control::get_minimum_size() const { if (si) { Callable::CallError ce; - Variant s = si->call(SceneStringNames::get_singleton()->_get_minimum_size, NULL, 0, ce); + Variant s = si->call(SceneStringNames::get_singleton()->_get_minimum_size, nullptr, 0, ce); if (ce.error == Callable::CallError::CALL_OK) return s; } @@ -799,8 +793,8 @@ bool Control::_find_theme_item(Control *p_theme_owner, Window *p_theme_owner_win theme_owner_window = parent_w->theme_owner_window; } else { - theme_owner = NULL; - theme_owner_window = NULL; + theme_owner = nullptr; + theme_owner_window = nullptr; } } } @@ -843,8 +837,8 @@ bool Control::_has_theme_item(Control *p_theme_owner, Window *p_theme_owner_wind theme_owner_window = parent_w->theme_owner_window; } else { - theme_owner = NULL; - theme_owner_window = NULL; + theme_owner = nullptr; + theme_owner_window = nullptr; } } } @@ -1034,37 +1028,37 @@ int Control::get_constants(Control *p_theme_owner, Window *p_theme_owner_window, bool Control::has_theme_icon_override(const StringName &p_name) const { const Ref<Texture2D> *tex = data.icon_override.getptr(p_name); - return tex != NULL; + return tex != nullptr; } bool Control::has_theme_shader_override(const StringName &p_name) const { const Ref<Shader> *sdr = data.shader_override.getptr(p_name); - return sdr != NULL; + return sdr != nullptr; } bool Control::has_theme_stylebox_override(const StringName &p_name) const { const Ref<StyleBox> *style = data.style_override.getptr(p_name); - return style != NULL; + return style != nullptr; } bool Control::has_theme_font_override(const StringName &p_name) const { const Ref<Font> *font = data.font_override.getptr(p_name); - return font != NULL; + return font != nullptr; } bool Control::has_theme_color_override(const StringName &p_name) const { const Color *color = data.color_override.getptr(p_name); - return color != NULL; + return color != nullptr; } bool Control::has_theme_constant_override(const StringName &p_name) const { const int *constant = data.constant_override.getptr(p_name); - return constant != NULL; + return constant != nullptr; } bool Control::has_theme_icon(const StringName &p_name, const StringName &p_type) const { @@ -1890,17 +1884,17 @@ void Control::set_focus_mode(FocusMode p_focus_mode) { static Control *_next_control(Control *p_from) { if (p_from->is_set_as_toplevel()) - return NULL; // can't go above + return nullptr; // can't go above Control *parent = Object::cast_to<Control>(p_from->get_parent()); if (!parent) { - return NULL; + return nullptr; } - int next = p_from->get_position_in_parent(); - ERR_FAIL_INDEX_V(next, parent->get_child_count(), NULL); + int next = p_from->get_index(); + ERR_FAIL_INDEX_V(next, parent->get_child_count(), nullptr); for (int i = (next + 1); i < parent->get_child_count(); i++) { Control *c = Object::cast_to<Control>(parent->get_child(i)); @@ -1927,9 +1921,9 @@ Control *Control::find_next_valid_focus() const { Control *c; if (n) { c = Object::cast_to<Control>(n); - ERR_FAIL_COND_V_MSG(!c, NULL, "Next focus node is not a control: " + n->get_name() + "."); + ERR_FAIL_COND_V_MSG(!c, nullptr, "Next focus node is not a control: " + n->get_name() + "."); } else { - return NULL; + return nullptr; } if (c->is_visible() && c->get_focus_mode() != FOCUS_NONE) return c; @@ -1937,7 +1931,7 @@ Control *Control::find_next_valid_focus() const { // find next child - Control *next_child = NULL; + Control *next_child = nullptr; for (int i = 0; i < from->get_child_count(); i++) { @@ -1974,7 +1968,7 @@ Control *Control::find_next_valid_focus() const { } if (next_child == this) // no next control-> - return (get_focus_mode() == FOCUS_ALL) ? next_child : NULL; + return (get_focus_mode() == FOCUS_ALL) ? next_child : nullptr; if (next_child) { if (next_child->get_focus_mode() == FOCUS_ALL) return next_child; @@ -1983,12 +1977,12 @@ Control *Control::find_next_valid_focus() const { break; } - return NULL; + return nullptr; } static Control *_prev_control(Control *p_from) { - Control *child = NULL; + Control *child = nullptr; for (int i = p_from->get_child_count() - 1; i >= 0; i--) { Control *c = Object::cast_to<Control>(p_from->get_child(i)); @@ -2018,9 +2012,9 @@ Control *Control::find_prev_valid_focus() const { Control *c; if (n) { c = Object::cast_to<Control>(n); - ERR_FAIL_COND_V_MSG(!c, NULL, "Previous focus node is not a control: " + n->get_name() + "."); + ERR_FAIL_COND_V_MSG(!c, nullptr, "Previous focus node is not a control: " + n->get_name() + "."); } else { - return NULL; + return nullptr; } if (c->is_visible() && c->get_focus_mode() != FOCUS_NONE) return c; @@ -2028,7 +2022,7 @@ Control *Control::find_prev_valid_focus() const { // find prev child - Control *prev_child = NULL; + Control *prev_child = nullptr; if (from->is_set_as_toplevel() || !Object::cast_to<Control>(from->get_parent())) { @@ -2038,7 +2032,7 @@ Control *Control::find_prev_valid_focus() const { } else { - for (int i = (from->get_position_in_parent() - 1); i >= 0; i--) { + for (int i = (from->get_index() - 1); i >= 0; i--) { Control *c = Object::cast_to<Control>(from->get_parent()->get_child(i)); @@ -2060,7 +2054,7 @@ Control *Control::find_prev_valid_focus() const { } if (prev_child == this) // no prev control-> - return (get_focus_mode() == FOCUS_ALL) ? prev_child : NULL; + return (get_focus_mode() == FOCUS_ALL) ? prev_child : nullptr; if (prev_child->get_focus_mode() == FOCUS_ALL) return prev_child; @@ -2068,7 +2062,7 @@ Control *Control::find_prev_valid_focus() const { from = prev_child; } - return NULL; + return nullptr; } Control::FocusMode Control::get_focus_mode() const { @@ -2221,7 +2215,7 @@ Control *Control::make_custom_tooltip(const String &p_text) const { if (get_script_instance()) { return const_cast<Control *>(this)->call("_make_custom_tooltip", p_text); } - return NULL; + return nullptr; } void Control::set_default_cursor_shape(CursorShape p_shape) { @@ -2288,19 +2282,19 @@ NodePath Control::get_focus_previous() const { Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) { - ERR_FAIL_INDEX_V((int)p_margin, 4, NULL); + ERR_FAIL_INDEX_V((int)p_margin, 4, nullptr); if (p_count >= MAX_NEIGHBOUR_SEARCH_COUNT) - return NULL; + return nullptr; if (!data.focus_neighbour[p_margin].is_empty()) { - Control *c = NULL; + Control *c = nullptr; Node *n = get_node(data.focus_neighbour[p_margin]); if (n) { c = Object::cast_to<Control>(n); - ERR_FAIL_COND_V_MSG(!c, NULL, "Neighbor focus node is not a control: " + n->get_name() + "."); + ERR_FAIL_COND_V_MSG(!c, nullptr, "Neighbor focus node is not a control: " + n->get_name() + "."); } else { - return NULL; + return nullptr; } bool valid = true; if (!c->is_visible()) @@ -2315,7 +2309,7 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) { } float dist = 1e7; - Control *result = NULL; + Control *result = nullptr; Point2 points[4]; @@ -2357,7 +2351,7 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) { } if (!base) - return NULL; + return nullptr; _window_find_focus_neighbour(vdir, base, points, maxd, dist, &result); @@ -2515,7 +2509,7 @@ Control::MouseFilter Control::get_mouse_filter() const { Control *Control::get_focus_owner() const { - ERR_FAIL_COND_V(!is_inside_tree(), NULL); + ERR_FAIL_COND_V(!is_inside_tree(), nullptr); return get_viewport()->_gui_get_focus_owner(); } @@ -2991,19 +2985,19 @@ void Control::_bind_methods() { } Control::Control() { - data.parent = NULL; + data.parent = nullptr; data.mouse_filter = MOUSE_FILTER_STOP; - data.RI = NULL; - data.theme_owner = NULL; - data.theme_owner_window = NULL; + data.RI = nullptr; + data.theme_owner = nullptr; + data.theme_owner_window = nullptr; data.default_cursor = CURSOR_ARROW; data.h_size_flags = SIZE_FILL; data.v_size_flags = SIZE_FILL; data.expand = 1; data.rotation = 0; - data.parent_canvas_item = NULL; + data.parent_canvas_item = nullptr; data.scale = Vector2(1, 1); data.block_minimum_size_adjust = false; diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 2e87a92969..5654219a3e 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -322,7 +322,6 @@ AcceptDialog::AcceptDialog() { label->set_end(Point2(-margin, -button_margin - 10)); add_child(label); - hbc = memnew(HBoxContainer); add_child(hbc); hbc->add_spacer(); diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index a4f0338f00..89d13ecd7f 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -34,11 +34,11 @@ #include "core/print_string.h" #include "scene/gui/label.h" -FileDialog::GetIconFunc FileDialog::get_icon_func = NULL; -FileDialog::GetIconFunc FileDialog::get_large_icon_func = NULL; +FileDialog::GetIconFunc FileDialog::get_icon_func = nullptr; +FileDialog::GetIconFunc FileDialog::get_large_icon_func = nullptr; -FileDialog::RegisterFunc FileDialog::register_func = NULL; -FileDialog::RegisterFunc FileDialog::unregister_func = NULL; +FileDialog::RegisterFunc FileDialog::register_func = nullptr; +FileDialog::RegisterFunc FileDialog::unregister_func = nullptr; VBoxContainer *FileDialog::get_vbox() { return vbox; @@ -46,9 +46,9 @@ VBoxContainer *FileDialog::get_vbox() { void FileDialog::_theme_changed() { - Color font_color = vbc->get_theme_color("font_color", "ToolButton"); - Color font_color_hover = vbc->get_theme_color("font_color_hover", "ToolButton"); - Color font_color_pressed = vbc->get_theme_color("font_color_pressed", "ToolButton"); + Color font_color = vbox->get_theme_color("font_color", "ToolButton"); + Color font_color_hover = vbox->get_theme_color("font_color_hover", "ToolButton"); + Color font_color_pressed = vbox->get_theme_color("font_color_pressed", "ToolButton"); dir_up->add_theme_color_override("icon_color_normal", font_color); dir_up->add_theme_color_override("icon_color_hover", font_color_hover); @@ -73,9 +73,9 @@ void FileDialog::_notification(int p_what) { } if (p_what == NOTIFICATION_ENTER_TREE) { - dir_up->set_icon(vbc->get_theme_icon("parent_folder")); - refresh->set_icon(vbc->get_theme_icon("reload")); - show_hidden->set_icon(vbc->get_theme_icon("toggle_hidden")); + dir_up->set_icon(vbox->get_theme_icon("parent_folder", "FileDialog")); + refresh->set_icon(vbox->get_theme_icon("reload", "FileDialog")); + show_hidden->set_icon(vbox->get_theme_icon("toggle_hidden", "FileDialog")); _theme_changed(); } } @@ -195,7 +195,7 @@ void FileDialog::_action_pressed() { if (mode == FILE_MODE_OPEN_FILES) { - TreeItem *ti = tree->get_next_selected(NULL); + TreeItem *ti = tree->get_next_selected(nullptr); String fbase = dir_access->get_current_dir(); Vector<String> files; @@ -429,8 +429,8 @@ void FileDialog::update_file_list() { dir_access->list_dir_begin(); TreeItem *root = tree->create_item(); - Ref<Texture2D> folder = vbc->get_theme_icon("folder"); - const Color folder_color = vbc->get_theme_color("folder_icon_modulate"); + Ref<Texture2D> folder = vbox->get_theme_icon("folder", "FileDialog"); + const Color folder_color = vbox->get_theme_color("folder_icon_modulate", "FileDialog"); List<String> files; List<String> dirs; @@ -528,7 +528,7 @@ void FileDialog::update_file_list() { } if (mode == FILE_MODE_OPEN_DIR) { - ti->set_custom_color(0, vbc->get_theme_color("files_disabled")); + ti->set_custom_color(0, vbox->get_theme_color("files_disabled", "FileDialog")); ti->set_selectable(0, false); } Dictionary d; @@ -543,7 +543,7 @@ void FileDialog::update_file_list() { files.pop_front(); } - if (tree->get_root() && tree->get_root()->get_children() && tree->get_selected() == NULL) + if (tree->get_root() && tree->get_root()->get_children() && tree->get_selected() == nullptr) tree->get_root()->get_children()->select(0); } @@ -888,9 +888,9 @@ FileDialog::FileDialog() { mode_overrides_title = true; - vbc = memnew(VBoxContainer); - add_child(vbc); - vbc->connect("theme_changed", callable_mp(this, &FileDialog::_theme_changed)); + vbox = memnew(VBoxContainer); + add_child(vbox); + vbox->connect("theme_changed", callable_mp(this, &FileDialog::_theme_changed)); mode = FILE_MODE_SAVE_FILE; set_title(RTR("Save a File")); @@ -909,6 +909,7 @@ FileDialog::FileDialog() { drives = memnew(OptionButton); drives->connect("item_selected", callable_mp(this, &FileDialog::_select_drive)); + hbc->add_child(drives); dir = memnew(LineEdit); hbc->add_child(dir); @@ -933,11 +934,11 @@ FileDialog::FileDialog() { makedir->set_text(RTR("Create Folder")); makedir->connect("pressed", callable_mp(this, &FileDialog::_make_dir)); hbc->add_child(makedir); - vbc->add_child(hbc); + vbox->add_child(hbc); tree = memnew(Tree); tree->set_hide_root(true); - vbc->add_margin_child(RTR("Directories & Files:"), tree, true); + vbox->add_margin_child(RTR("Directories & Files:"), tree, true); file_box = memnew(HBoxContainer); file_box->add_child(memnew(Label(RTR("File:")))); @@ -950,7 +951,7 @@ FileDialog::FileDialog() { filter->set_h_size_flags(Control::SIZE_EXPAND_FILL); filter->set_clip_text(true); // too many extensions overflows it file_box->add_child(filter); - vbc->add_child(file_box); + vbox->add_child(file_box); dir_access = DirAccess::create(DirAccess::ACCESS_RESOURCES); access = ACCESS_RESOURCES; @@ -993,7 +994,6 @@ FileDialog::FileDialog() { update_dir(); set_hide_on_ok(false); - vbox = vbc; invalidated = true; if (register_func) @@ -1006,37 +1006,3 @@ FileDialog::~FileDialog() { unregister_func(this); memdelete(dir_access); } - -void LineEditFileChooser::_bind_methods() { - - ClassDB::bind_method(D_METHOD("get_button"), &LineEditFileChooser::get_button); - ClassDB::bind_method(D_METHOD("get_line_edit"), &LineEditFileChooser::get_line_edit); - ClassDB::bind_method(D_METHOD("get_file_dialog"), &LineEditFileChooser::get_file_dialog); -} - -void LineEditFileChooser::_chosen(const String &p_text) { - - line_edit->set_text(p_text); - line_edit->emit_signal("text_entered", p_text); -} - -void LineEditFileChooser::_browse() { - - dialog->popup_centered_ratio(); -} - -LineEditFileChooser::LineEditFileChooser() { - - line_edit = memnew(LineEdit); - add_child(line_edit); - line_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL); - button = memnew(Button); - button->set_text(" .. "); - add_child(button); - button->connect("pressed", callable_mp(this, &LineEditFileChooser::_browse)); - dialog = memnew(FileDialog); - add_child(dialog); - dialog->connect("file_selected", callable_mp(this, &LineEditFileChooser::_chosen)); - dialog->connect("dir_selected", callable_mp(this, &LineEditFileChooser::_chosen)); - dialog->connect("files_selected", callable_mp(this, &LineEditFileChooser::_chosen)); -} diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h index 295ae023d1..ac0e733abc 100644 --- a/scene/gui/file_dialog.h +++ b/scene/gui/file_dialog.h @@ -70,7 +70,6 @@ private: ConfirmationDialog *makedialog; LineEdit *makedirname; - VBoxContainer *vbc; Button *makedir; Access access; //Button *action; @@ -178,27 +177,6 @@ public: ~FileDialog(); }; -class LineEditFileChooser : public HBoxContainer { - - GDCLASS(LineEditFileChooser, HBoxContainer); - Button *button; - LineEdit *line_edit; - FileDialog *dialog; - - void _chosen(const String &p_text); - void _browse(); - -protected: - static void _bind_methods(); - -public: - Button *get_button() { return button; } - LineEdit *get_line_edit() { return line_edit; } - FileDialog *get_file_dialog() { return dialog; } - - LineEditFileChooser(); -}; - VARIANT_ENUM_CAST(FileDialog::FileMode); VARIANT_ENUM_CAST(FileDialog::Access); diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index fd7935b376..e37e93e2a9 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -854,7 +854,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { if (in_box) gn->set_selected(box_selection_mode_aditive); else - gn->set_selected(previus_selected.find(gn) != NULL); + gn->set_selected(previus_selected.find(gn) != nullptr); } top_layer->update(); @@ -872,7 +872,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { if (!gn) continue; - gn->set_selected(previus_selected.find(gn) != NULL); + gn->set_selected(previus_selected.find(gn) != nullptr); } top_layer->update(); } else { @@ -922,7 +922,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { if (b->get_button_index() == BUTTON_LEFT && b->is_pressed()) { - GraphNode *gn = NULL; + GraphNode *gn = nullptr; for (int i = get_child_count() - 1; i >= 0; i--) { @@ -1323,7 +1323,7 @@ GraphEdit::GraphEdit() { set_focus_mode(FOCUS_ALL); awaiting_scroll_offset_update = false; - top_layer = NULL; + top_layer = nullptr; top_layer = memnew(GraphEditFilter(this)); add_child(top_layer); top_layer->set_mouse_filter(MOUSE_FILTER_PASS); diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index c28a60ff87..5dbc5bc50d 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -593,7 +593,7 @@ void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) { Ref<InputEventMouseButton> mb = p_ev; if (mb.is_valid()) { - ERR_FAIL_COND_MSG(get_parent_control() == NULL, "GraphNode must be the child of a GraphEdit node."); + ERR_FAIL_COND_MSG(get_parent_control() == nullptr, "GraphNode must be the child of a GraphEdit node."); if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 1ffc9712cc..bedcef2df2 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -282,7 +282,7 @@ void Label::_notification(int p_what) { from = from->next; } - wc = to ? to->next : 0; + wc = to ? to->next : nullptr; line++; } } @@ -404,7 +404,7 @@ void Label::regenerate_word_cache() { line_count = 1; total_char_cache = 0; - WordCache *last = NULL; + WordCache *last = nullptr; for (int i = 0; i <= xl_text.length(); i++) { @@ -447,7 +447,7 @@ void Label::regenerate_word_cache() { } if (i < xl_text.length() && xl_text[i] == ' ') { - if (line_width > 0 || last == NULL || last->char_pos != WordCache::CHAR_WRAPLINE) { + if (line_width > 0 || last == nullptr || last->char_pos != WordCache::CHAR_WRAPLINE) { space_count++; line_width += space_width; } else { @@ -697,7 +697,7 @@ Label::Label(const String &p_text) { align = ALIGN_LEFT; valign = VALIGN_TOP; xl_text = ""; - word_cache = NULL; + word_cache = nullptr; word_cache_dirty = true; autowrap = false; line_count = 0; diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 6c5f77f874..b9b7560f2e 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -630,7 +630,7 @@ void LineEdit::drop_data(const Point2 &p_point, const Variant &p_data) { int selected = selection.end - selection.begin; Ref<Font> font = get_theme_font("font"); - if (font != NULL) { + if (font != nullptr) { for (int i = selection.begin; i < selection.end; i++) cached_width -= font->get_char_size(pass ? secret_character[0] : text[i]).width; } @@ -1001,7 +1001,7 @@ void LineEdit::paste_text() { } void LineEdit::undo() { - if (undo_stack_pos == NULL) { + if (undo_stack_pos == nullptr) { if (undo_stack.size() <= 1) { return; } @@ -1023,7 +1023,7 @@ void LineEdit::undo() { } void LineEdit::redo() { - if (undo_stack_pos == NULL) { + if (undo_stack_pos == nullptr) { return; } if (undo_stack_pos == undo_stack.back()) { @@ -1096,7 +1096,7 @@ void LineEdit::set_cursor_at_pixel_pos(int p_x) { while (ofs < text.length()) { int char_w = 0; - if (font != NULL) { + if (font != nullptr) { char_w = font->get_char_size(pass ? secret_character[0] : text[ofs]).width; } pixel_ofs += char_w; @@ -1148,7 +1148,7 @@ int LineEdit::get_cursor_pixel_pos() { } while (ofs < cursor_pos) { - if (font != NULL) { + if (font != nullptr) { pixel_ofs += font->get_char_size(pass ? secret_character[0] : text[ofs]).width; } ofs++; @@ -1207,7 +1207,7 @@ void LineEdit::delete_char() { if ((text.length() <= 0) || (cursor_pos == 0)) return; Ref<Font> font = get_theme_font("font"); - if (font != NULL) { + if (font != nullptr) { cached_width -= font->get_char_size(pass ? secret_character[0] : text[cursor_pos - 1]).width; } @@ -1226,7 +1226,7 @@ void LineEdit::delete_text(int p_from_column, int p_to_column) { if (text.size() > 0) { Ref<Font> font = get_theme_font("font"); - if (font != NULL) { + if (font != nullptr) { for (int i = p_from_column; i < p_to_column; i++) cached_width -= font->get_char_size(pass ? secret_character[0] : text[i]).width; } @@ -1709,7 +1709,7 @@ void LineEdit::_emit_text_change() { void LineEdit::update_cached_width() { Ref<Font> font = get_theme_font("font"); cached_width = 0; - if (font != NULL) { + if (font != nullptr) { String text = get_text(); for (int i = 0; i < text.length(); i++) { cached_width += font->get_char_size(pass ? secret_character[0] : text[i]).width; @@ -1720,7 +1720,7 @@ void LineEdit::update_cached_width() { void LineEdit::update_placeholder_width() { Ref<Font> font = get_theme_font("font"); cached_placeholder_width = 0; - if (font != NULL) { + if (font != nullptr) { for (int i = 0; i < placeholder_translated.length(); i++) { cached_placeholder_width += font->get_char_size(placeholder_translated[i]).width; } @@ -1729,7 +1729,7 @@ void LineEdit::update_placeholder_width() { void LineEdit::_clear_redo() { _create_undo_state(); - if (undo_stack_pos == NULL) { + if (undo_stack_pos == nullptr) { return; } @@ -1744,7 +1744,7 @@ void LineEdit::_clear_redo() { void LineEdit::_clear_undo_stack() { undo_stack.clear(); - undo_stack_pos = NULL; + undo_stack_pos = nullptr; _create_undo_state(); } @@ -1865,7 +1865,7 @@ void LineEdit::_bind_methods() { LineEdit::LineEdit() { - undo_stack_pos = NULL; + undo_stack_pos = nullptr; _create_undo_state(); align = ALIGN_LEFT; cached_width = 0; diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index c096dc94cb..1e933c9aa1 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -394,7 +394,7 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventKey> k = p_event; - if (allow_search && k.is_valid() && k->get_unicode()) { + if (allow_search && k.is_valid() && k->get_unicode() && k->is_pressed()) { uint64_t now = OS::get_singleton()->get_ticks_msec(); uint64_t diff = now - search_time_msec; @@ -1514,6 +1514,7 @@ PopupMenu::PopupMenu() { submenu_over = -1; initial_button_mask = 0; during_grabbed_click = false; + invalidated_click = false; allow_search = false; search_time_msec = 0; diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp index adc5f81465..ab2f64e1b4 100644 --- a/scene/gui/range.cpp +++ b/scene/gui/range.cpp @@ -236,7 +236,7 @@ void Range::_unref_shared() { shared->owners.erase(this); if (shared->owners.size() == 0) { memdelete(shared); - shared = NULL; + shared = nullptr; } } } diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index d17eec4050..0b314d57c5 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -53,7 +53,7 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) { return p_item->subitems.front()->get(); } else if (!p_item->parent) { - return NULL; + return nullptr; } else if (p_item->E->next()) { return p_item->E->next()->get(); @@ -66,7 +66,7 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) { if (p_item->parent) return p_item->E->next()->get(); else - return NULL; + return nullptr; } } else { @@ -74,7 +74,7 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) { return p_item->subitems.front()->get(); } else if (p_item->type == ITEM_FRAME) { - return NULL; + return nullptr; } else if (p_item->E->next()) { return p_item->E->next()->get(); @@ -87,11 +87,11 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) { if (p_item->type != ITEM_FRAME) return p_item->E->next()->get(); else - return NULL; + return nullptr; } } - return NULL; + return nullptr; } RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) { @@ -101,7 +101,7 @@ RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) { return p_item->subitems.back()->get(); } else if (!p_item->parent) { - return NULL; + return nullptr; } else if (p_item->E->prev()) { return p_item->E->prev()->get(); @@ -114,7 +114,7 @@ RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) { if (p_item->parent) return p_item->E->prev()->get(); else - return NULL; + return nullptr; } } else { @@ -122,7 +122,7 @@ RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) { return p_item->subitems.back()->get(); } else if (p_item->type == ITEM_FRAME) { - return NULL; + return nullptr; } else if (p_item->E->prev()) { return p_item->E->prev()->get(); @@ -135,11 +135,11 @@ RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) { if (p_item->type != ITEM_FRAME) return p_item->E->prev()->get(); else - return NULL; + return nullptr; } } - return NULL; + return nullptr; } Rect2 RichTextLabel::_get_text_rect() { @@ -158,7 +158,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & ci = get_canvas_item(); if (r_click_item) - *r_click_item = NULL; + *r_click_item = nullptr; } Line &l = p_frame->lines.write[p_line]; Item *it = l.from; @@ -356,7 +356,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & Color font_color_shadow; bool underline = false; bool strikethrough = false; - ItemFade *fade = NULL; + ItemFade *fade = nullptr; int it_char_start = p_char_count; Vector<ItemFX *> fx_stack = Vector<ItemFX *>(); @@ -411,7 +411,6 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & break; //don't allow lines longer than assigned width } - w += cw; fw += cw; end++; @@ -552,8 +551,10 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & } } - if (visible) + if (visible) { line_is_blank = false; + w += font->get_char_size(c[i], c[i + 1]).x; + } if (c[i] == '\t') visible = false; @@ -582,13 +583,14 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & } else { cw = drawer.draw_char(ci, p_ofs + Point2(align_ofs + pofs, y + lh - line_descent) + fx_offset, fx_char, c[i + 1], fx_color); } - } else if (previously_visible) { + } else if (previously_visible && c[i] != '\t') { backtrack += font->get_char_size(fx_char, c[i + 1]).x; } p_char_count++; if (c[i] == '\t') { cw = tab_size * font->get_char_size(' ').width; + backtrack = MAX(0, backtrack - cw); } ofs += cw; @@ -607,7 +609,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & } else if (strikethrough) { Color uc = color; uc.a *= 0.5; - int uy = y + lh / 2 - line_descent + 2; + int uy = y + lh - (line_ascent + line_descent) / 2; float strikethrough_width = 1.0; #ifdef TOOLS_ENABLED strikethrough_width *= EDSCALE; @@ -915,7 +917,7 @@ void RichTextLabel::_update_scroll() { void RichTextLabel::_update_fx(RichTextLabel::ItemFrame *p_frame, float p_delta_time) { Item *it = p_frame; while (it) { - ItemFX *ifx = NULL; + ItemFX *ifx = nullptr; if (it->type == ITEM_CUSTOMFX || it->type == ITEM_SHAKE || it->type == ITEM_WAVE || it->type == ITEM_TORNADO || it->type == ITEM_RAINBOW) { ifx = static_cast<ItemFX *>(it); @@ -928,7 +930,7 @@ void RichTextLabel::_update_fx(RichTextLabel::ItemFrame *p_frame, float p_delta_ ifx->elapsed_time += p_delta_time; - ItemShake *shake = NULL; + ItemShake *shake = nullptr; if (it->type == ITEM_SHAKE) { shake = static_cast<ItemShake *>(it); @@ -952,7 +954,7 @@ void RichTextLabel::_notification(int p_what) { case NOTIFICATION_MOUSE_EXIT: { if (meta_hovering) { - meta_hovering = NULL; + meta_hovering = nullptr; emit_signal("meta_hover_ended", current_meta); current_meta = false; update(); @@ -1022,7 +1024,7 @@ void RichTextLabel::_notification(int p_what) { visible_line_count = 0; while (y < size.height && from_line < main->lines.size()) { - visible_line_count += _process_line(main, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, from_line, PROCESS_DRAW, base_font, base_color, font_color_shadow, use_outline, shadow_ofs, Point2i(), NULL, NULL, NULL, total_chars); + visible_line_count += _process_line(main, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, from_line, PROCESS_DRAW, base_font, base_color, font_color_shadow, use_outline, shadow_ofs, Point2i(), nullptr, nullptr, nullptr, total_chars); total_chars += main->lines[from_line].char_count; from_line++; @@ -1040,7 +1042,7 @@ void RichTextLabel::_notification(int p_what) { void RichTextLabel::_find_click(ItemFrame *p_frame, const Point2i &p_click, Item **r_click_item, int *r_click_char, bool *r_outside) { if (r_click_item) - *r_click_item = NULL; + *r_click_item = nullptr; Rect2 text_rect = _get_text_rect(); int ofs = vscroll->get_value(); @@ -1086,11 +1088,11 @@ Control::CursorShape RichTextLabel::get_cursor_shape(const Point2 &p_pos) const return CURSOR_ARROW; //invalid int line = 0; - Item *item = NULL; + Item *item = nullptr; bool outside; ((RichTextLabel *)(this))->_find_click(main, p_pos, &item, &line, &outside); - if (item && !outside && ((RichTextLabel *)(this))->_find_meta(item, NULL)) + if (item && !outside && ((RichTextLabel *)(this))->_find_meta(item, nullptr)) return CURSOR_POINTING_HAND; return CURSOR_ARROW; @@ -1108,7 +1110,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { if (b->is_pressed() && !b->is_doubleclick()) { scroll_updated = false; int line = 0; - Item *item = NULL; + Item *item = nullptr; bool outside; _find_click(main, b->get_position(), &item, &line, &outside); @@ -1122,9 +1124,9 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { // Erase previous selection. if (selection.active) { - selection.from = NULL; + selection.from = nullptr; selection.from_char = '\0'; - selection.to = NULL; + selection.to = nullptr; selection.to_char = '\0'; selection.active = false; @@ -1136,7 +1138,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { //doubleclick: select word int line = 0; - Item *item = NULL; + Item *item = nullptr; bool outside; _find_click(main, b->get_position(), &item, &line, &outside); @@ -1163,11 +1165,11 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { } } else if (!b->is_pressed()) { - selection.click = NULL; + selection.click = nullptr; if (!b->is_doubleclick() && !scroll_updated) { int line = 0; - Item *item = NULL; + Item *item = nullptr; bool outside; _find_click(main, b->get_position(), &item, &line, &outside); @@ -1276,7 +1278,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { return; int line = 0; - Item *item = NULL; + Item *item = nullptr; bool outside; _find_click(main, m->get_position(), &item, &line, &outside); @@ -1325,7 +1327,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { emit_signal("meta_hover_started", meta); } } else if (meta_hovering) { - meta_hovering = NULL; + meta_hovering = nullptr; emit_signal("meta_hover_ended", current_meta); current_meta = false; } @@ -1641,7 +1643,7 @@ void RichTextLabel::_add_item(Item *p_item, bool p_enter, bool p_ensure_newline) } } - if (current_frame->lines[current_frame->lines.size() - 1].from == NULL) { + if (current_frame->lines[current_frame->lines.size() - 1].from == nullptr) { current_frame->lines.write[current_frame->lines.size() - 1].from = p_item; } p_item->line = current_frame->lines.size() - 1; @@ -1938,7 +1940,7 @@ void RichTextLabel::push_cell() { item->cell = true; item->parent_line = item->parent_frame->lines.size() - 1; item->lines.resize(1); - item->lines.write[0].from = NULL; + item->lines.write[0].from = nullptr; item->first_invalid_line = 0; } @@ -1969,7 +1971,7 @@ void RichTextLabel::clear() { main->lines.resize(1); main->first_invalid_line = 0; update(); - selection.click = NULL; + selection.click = nullptr; selection.active = false; current_idx = 1; @@ -2953,7 +2955,7 @@ RichTextLabel::RichTextLabel() { tab_size = 4; default_align = ALIGN_LEFT; underline_meta = true; - meta_hovering = NULL; + meta_hovering = nullptr; override_selected_font_color = false; scroll_visible = false; @@ -2977,7 +2979,7 @@ RichTextLabel::RichTextLabel() { current_idx = 1; use_bbcode = false; - selection.click = NULL; + selection.click = nullptr; selection.active = false; selection.enabled = false; diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index dd439208af..7f2b5facb9 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -98,7 +98,7 @@ private: int maximum_width; Line() { - from = NULL; + from = nullptr; char_count = 0; } }; @@ -119,9 +119,11 @@ private: } Item() { - parent = NULL; - E = NULL; + parent = nullptr; + E = nullptr; line = 0; + index = 0; + type = ITEM_FRAME; } virtual ~Item() { _clear_children(); } }; @@ -135,7 +137,7 @@ private: ItemFrame() { type = ITEM_FRAME; - parent_frame = NULL; + parent_frame = nullptr; cell = false; parent_line = 0; } @@ -368,8 +370,8 @@ private: int visible_characters; float percent_visible; - int _process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &y, int p_width, int p_line, ProcessMode p_mode, const Ref<Font> &p_base_font, const Color &p_base_color, const Color &p_font_color_shadow, bool p_shadow_as_outline, const Point2 &shadow_ofs, const Point2i &p_click_pos = Point2i(), Item **r_click_item = NULL, int *r_click_char = NULL, bool *r_outside = NULL, int p_char_count = 0); - void _find_click(ItemFrame *p_frame, const Point2i &p_click, Item **r_click_item = NULL, int *r_click_char = NULL, bool *r_outside = NULL); + int _process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &y, int p_width, int p_line, ProcessMode p_mode, const Ref<Font> &p_base_font, const Color &p_base_color, const Color &p_font_color_shadow, bool p_shadow_as_outline, const Point2 &shadow_ofs, const Point2i &p_click_pos = Point2i(), Item **r_click_item = nullptr, int *r_click_char = nullptr, bool *r_outside = nullptr, int p_char_count = 0); + void _find_click(ItemFrame *p_frame, const Point2i &p_click, Item **r_click_item = nullptr, int *r_click_char = nullptr, bool *r_outside = nullptr); Ref<Font> _find_font(Item *p_item); int _find_margin(Item *p_item, const Ref<Font> &p_base_font); @@ -377,7 +379,7 @@ private: Color _find_color(Item *p_item, const Color &p_default_color); bool _find_underline(Item *p_item); bool _find_strikethrough(Item *p_item); - bool _find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item = NULL); + bool _find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item = nullptr); bool _find_layout_subitem(Item *from, Item *to); bool _find_by_type(Item *p_item, ItemType p_type); void _fetch_item_fx_stack(Item *p_item, Vector<ItemFX *> &r_stack); diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 5e9541730e..1c63c25e28 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -308,7 +308,7 @@ void ScrollBar::_notification(int p_what) { drag_node->disconnect("tree_exiting", callable_mp(this, &ScrollBar::_drag_node_exit)); } - drag_node = NULL; + drag_node = nullptr; } if (p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) { @@ -542,7 +542,7 @@ void ScrollBar::_drag_node_exit() { if (drag_node) { drag_node->disconnect("gui_input", callable_mp(this, &ScrollBar::_drag_node_input)); } - drag_node = NULL; + drag_node = nullptr; } void ScrollBar::_drag_node_input(const Ref<InputEvent> &p_input) { @@ -616,7 +616,7 @@ void ScrollBar::set_drag_node(const NodePath &p_path) { } } - drag_node = NULL; + drag_node = nullptr; drag_node_path = p_path; if (is_inside_tree()) { @@ -662,7 +662,7 @@ ScrollBar::ScrollBar(Orientation p_orientation) { orientation = p_orientation; highlight = HIGHLIGHT_NONE; custom_step = -1; - drag_node = NULL; + drag_node = nullptr; drag.active = false; diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index ccfa8ebf63..8572d570fb 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -60,7 +60,7 @@ void SpinBox::_text_entered(const String &p_string) { return; } - Variant value = expr->execute(Array(), NULL, false); + Variant value = expr->execute(Array(), nullptr, false); if (value.get_type() != Variant::NIL) { set_value(value); _value_changed(0); diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp index 4eb614a9ac..de892a4fb9 100644 --- a/scene/gui/split_container.cpp +++ b/scene/gui/split_container.cpp @@ -50,7 +50,7 @@ Control *SplitContainer::_getch(int p_idx) const { idx++; } - return NULL; + return nullptr; } void SplitContainer::_resort() { diff --git a/scene/gui/viewport_container.cpp b/scene/gui/subviewport_container.cpp index 7ce1d9e551..50f468741d 100644 --- a/scene/gui/viewport_container.cpp +++ b/scene/gui/subviewport_container.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* viewport_container.cpp */ +/* subviewport_container.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,12 +28,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "viewport_container.h" +#include "subviewport_container.h" #include "core/engine.h" #include "scene/main/viewport.h" -Size2 ViewportContainer::get_minimum_size() const { +Size2 SubViewportContainer::get_minimum_size() const { if (stretch) return Size2(); @@ -52,19 +52,19 @@ Size2 ViewportContainer::get_minimum_size() const { return ms; } -void ViewportContainer::set_stretch(bool p_enable) { +void SubViewportContainer::set_stretch(bool p_enable) { stretch = p_enable; queue_sort(); update(); } -bool ViewportContainer::is_stretch_enabled() const { +bool SubViewportContainer::is_stretch_enabled() const { return stretch; } -void ViewportContainer::set_stretch_shrink(int p_shrink) { +void SubViewportContainer::set_stretch_shrink(int p_shrink) { ERR_FAIL_COND(p_shrink < 1); if (shrink == p_shrink) @@ -87,12 +87,12 @@ void ViewportContainer::set_stretch_shrink(int p_shrink) { update(); } -int ViewportContainer::get_stretch_shrink() const { +int SubViewportContainer::get_stretch_shrink() const { return shrink; } -void ViewportContainer::_notification(int p_what) { +void SubViewportContainer::_notification(int p_what) { if (p_what == NOTIFICATION_RESIZED) { @@ -142,7 +142,7 @@ void ViewportContainer::_notification(int p_what) { } } -void ViewportContainer::_input(const Ref<InputEvent> &p_event) { +void SubViewportContainer::_input(const Ref<InputEvent> &p_event) { if (Engine::get_singleton()->is_editor_hint()) return; @@ -167,7 +167,7 @@ void ViewportContainer::_input(const Ref<InputEvent> &p_event) { } } -void ViewportContainer::_unhandled_input(const Ref<InputEvent> &p_event) { +void SubViewportContainer::_unhandled_input(const Ref<InputEvent> &p_event) { if (Engine::get_singleton()->is_editor_hint()) return; @@ -192,21 +192,21 @@ void ViewportContainer::_unhandled_input(const Ref<InputEvent> &p_event) { } } -void ViewportContainer::_bind_methods() { +void SubViewportContainer::_bind_methods() { - ClassDB::bind_method(D_METHOD("_unhandled_input", "event"), &ViewportContainer::_unhandled_input); - ClassDB::bind_method(D_METHOD("_input", "event"), &ViewportContainer::_input); - ClassDB::bind_method(D_METHOD("set_stretch", "enable"), &ViewportContainer::set_stretch); - ClassDB::bind_method(D_METHOD("is_stretch_enabled"), &ViewportContainer::is_stretch_enabled); + ClassDB::bind_method(D_METHOD("_unhandled_input", "event"), &SubViewportContainer::_unhandled_input); + ClassDB::bind_method(D_METHOD("_input", "event"), &SubViewportContainer::_input); + ClassDB::bind_method(D_METHOD("set_stretch", "enable"), &SubViewportContainer::set_stretch); + ClassDB::bind_method(D_METHOD("is_stretch_enabled"), &SubViewportContainer::is_stretch_enabled); - ClassDB::bind_method(D_METHOD("set_stretch_shrink", "amount"), &ViewportContainer::set_stretch_shrink); - ClassDB::bind_method(D_METHOD("get_stretch_shrink"), &ViewportContainer::get_stretch_shrink); + ClassDB::bind_method(D_METHOD("set_stretch_shrink", "amount"), &SubViewportContainer::set_stretch_shrink); + ClassDB::bind_method(D_METHOD("get_stretch_shrink"), &SubViewportContainer::get_stretch_shrink); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stretch"), "set_stretch", "is_stretch_enabled"); ADD_PROPERTY(PropertyInfo(Variant::INT, "stretch_shrink"), "set_stretch_shrink", "get_stretch_shrink"); } -ViewportContainer::ViewportContainer() { +SubViewportContainer::SubViewportContainer() { stretch = false; shrink = 1; diff --git a/scene/gui/viewport_container.h b/scene/gui/subviewport_container.h index 8597444426..6ff3d188e2 100644 --- a/scene/gui/viewport_container.h +++ b/scene/gui/subviewport_container.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* viewport_container.h */ +/* subviewport_container.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -33,9 +33,9 @@ #include "scene/gui/container.h" -class ViewportContainer : public Container { +class SubViewportContainer : public Container { - GDCLASS(ViewportContainer, Container); + GDCLASS(SubViewportContainer, Container); bool stretch; int shrink; @@ -55,7 +55,7 @@ public: virtual Size2 get_minimum_size() const; - ViewportContainer(); + SubViewportContainer(); }; #endif // VIEWPORTCONTAINER_H diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 7cecbf7fa2..de80049862 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -602,7 +602,7 @@ Control *TabContainer::get_tab_control(int p_idx) const { if (p_idx >= 0 && p_idx < tabs.size()) return tabs[p_idx]; else - return NULL; + return nullptr; } Control *TabContainer::get_current_tab_control() const { @@ -611,7 +611,7 @@ Control *TabContainer::get_current_tab_control() const { if (current >= 0 && current < tabs.size()) return tabs[current]; else - return NULL; + return nullptr; } void TabContainer::remove_child_notify(Node *p_child) { @@ -1041,7 +1041,7 @@ TabContainer::TabContainer() { previous = 0; align = ALIGN_CENTER; tabs_visible = true; - popup = NULL; + popup = nullptr; drag_to_rearrange_enabled = false; tabs_rearrange_group = -1; use_hidden_tabs_for_min_size = false; diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index ea6d44e3a7..1a3b53f489 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -184,10 +184,7 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) { } int found = -1; - for (int i = 0; i < tabs.size(); i++) { - - if (i < offset) - continue; + for (int i = offset; i < tabs.size(); i++) { if (tabs[i].rb_rect.has_point(pos)) { rb_pressing = true; @@ -276,10 +273,7 @@ void Tabs::_notification(int p_what) { missing_right = false; - for (int i = 0; i < tabs.size(); i++) { - - if (i < offset) - continue; + for (int i = offset; i < tabs.size(); i++) { tabs.write[i].ofs_cache = w; @@ -499,10 +493,7 @@ void Tabs::_update_hover() { // test hovering to display right or close button int hover_now = -1; int hover_buttons = -1; - for (int i = 0; i < tabs.size(); i++) { - - if (i < offset) - continue; + for (int i = offset; i < tabs.size(); i++) { Rect2 rect = get_tab_rect(i); if (rect.has_point(pos)) { @@ -559,9 +550,8 @@ void Tabs::_update_cache() { if (count_resize > 0) { m_width = MAX((limit - size_fixed) / count_resize, min_width); } - for (int i = 0; i < tabs.size(); i++) { - if (i < offset) - continue; + for (int i = offset; i < tabs.size(); i++) { + Ref<StyleBox> sb; if (tabs[i].disabled) { sb = tab_disabled; @@ -753,10 +743,7 @@ void Tabs::drop_data(const Point2 &p_point, const Variant &p_data) { int Tabs::get_tab_idx_at_point(const Point2 &p_point) const { int hover_now = -1; - for (int i = 0; i < tabs.size(); i++) { - - if (i < offset) - continue; + for (int i = offset; i < tabs.size(); i++) { Rect2 rect = get_tab_rect(i); if (rect.has_point(p_point)) { @@ -850,10 +837,7 @@ void Tabs::_ensure_no_over_offset() { while (offset > 0) { int total_w = 0; - for (int i = 0; i < tabs.size(); i++) { - - if (i < offset - 1) - continue; + for (int i = offset - 1; i < tabs.size(); i++) { total_w += tabs[i].size_cache; } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 7071652f2a..36e35897d1 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2186,7 +2186,7 @@ Vector2i TextEdit::_get_cursor_pixel_pos() { int x = cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width + cache.info_gutter_width - cursor.x_ofs; int ix = 0; while (ix < rows2[0].size() && ix < cursor.column) { - if (cache.font != NULL) { + if (cache.font != nullptr) { x += cache.font->get_char_size(rows2[0].get(ix)).width; } ix++; @@ -3990,7 +3990,7 @@ void TextEdit::_base_insert_text(int p_line, int p_char, const String &p_text, i text.set_breakpoint(p_line, false); text.set_hidden(p_line, false); - text.set_info_icon(p_line, NULL, ""); + text.set_info_icon(p_line, nullptr, ""); } text.set_line_wrap_amount(p_line, -1); @@ -6087,7 +6087,7 @@ void TextEdit::_do_text_op(const TextOperation &p_op, bool p_reverse) { void TextEdit::_clear_redo() { - if (undo_stack_pos == NULL) + if (undo_stack_pos == nullptr) return; // Nothing to clear. _push_current_op(); @@ -6103,7 +6103,7 @@ void TextEdit::undo() { _push_current_op(); - if (undo_stack_pos == NULL) { + if (undo_stack_pos == nullptr) { if (!undo_stack.size()) return; // Nothing to undo. @@ -6152,7 +6152,7 @@ void TextEdit::redo() { _push_current_op(); - if (undo_stack_pos == NULL) + if (undo_stack_pos == nullptr) return; // Nothing to do. deselect(); @@ -6184,7 +6184,7 @@ void TextEdit::clear_undo_history() { saved_version = 0; current_op.type = TextOperation::TYPE_NONE; - undo_stack_pos = NULL; + undo_stack_pos = nullptr; undo_stack.clear(); } @@ -6633,8 +6633,8 @@ void TextEdit::_update_completion_candidates() { const CharType *tgt = &option.display[0]; const CharType *tgt_lower = &display_lower[0]; - const CharType *ssq_last_tgt = NULL; - const CharType *ssq_lower_last_tgt = NULL; + const CharType *ssq_last_tgt = nullptr; + const CharType *ssq_lower_last_tgt = nullptr; for (; *tgt; tgt++, tgt_lower++) { if (*ssq == *tgt) { @@ -6701,7 +6701,7 @@ void TextEdit::query_code_comple() { bool ignored = completion_active && !completion_options.empty(); if (ignored) { ScriptCodeCompletionOption::Kind kind = ScriptCodeCompletionOption::KIND_PLAIN_TEXT; - const ScriptCodeCompletionOption *previous_option = NULL; + const ScriptCodeCompletionOption *previous_option = nullptr; for (int i = 0; i < completion_options.size(); i++) { const ScriptCodeCompletionOption ¤t_option = completion_options[i]; if (!previous_option) { @@ -7259,7 +7259,7 @@ TextEdit::TextEdit() { wrap_at = 0; wrap_right_offset = 10; set_focus_mode(FOCUS_ALL); - syntax_highlighter = NULL; + syntax_highlighter = nullptr; _update_caches(); cache.row_height = 1; cache.line_spacing = 1; @@ -7323,7 +7323,7 @@ TextEdit::TextEdit() { current_op.type = TextOperation::TYPE_NONE; undo_enabled = true; - undo_stack_pos = NULL; + undo_stack_pos = nullptr; setting_text = false; last_dblclk = 0; current_op.version = 0; @@ -7333,7 +7333,7 @@ TextEdit::TextEdit() { completion_enabled = false; completion_active = false; completion_line_ofs = 0; - tooltip_obj = NULL; + tooltip_obj = nullptr; line_numbers = false; line_numbers_zero_padded = false; line_length_guidelines = false; @@ -7394,7 +7394,7 @@ Map<int, TextEdit::HighlighterInfo> TextEdit::_get_line_syntax_highlighting(int return syntax_highlighting_cache[p_line]; } - if (syntax_highlighter != NULL) { + if (syntax_highlighter != nullptr) { Map<int, HighlighterInfo> color_map = syntax_highlighter->_get_line_syntax_highlighting(p_line); syntax_highlighting_cache[p_line] = color_map; return color_map; @@ -7508,7 +7508,7 @@ Map<int, TextEdit::HighlighterInfo> TextEdit::_get_line_syntax_highlighting(int if (col) { for (int k = j - 1; k >= 0; k--) { if (str[k] == '.') { - col = NULL; // Member indexing not allowed. + col = nullptr; // Member indexing not allowed. break; } else if (str[k] > 32) { break; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 7d096f7897..ef8c39d32f 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -530,7 +530,7 @@ private: protected: virtual String get_tooltip(const Point2 &p_pos) const; - void _insert_text(int p_line, int p_char, const String &p_text, int *r_end_line = NULL, int *r_end_char = NULL); + void _insert_text(int p_line, int p_char, const String &p_text, int *r_end_line = nullptr, int *r_end_char = nullptr); void _remove_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column); void _insert_text_at_cursor(const String &p_text); void _gui_input(const Ref<InputEvent> &p_gui_input); diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp index baa138847f..92f3c5b5d9 100644 --- a/scene/gui/texture_rect.cpp +++ b/scene/gui/texture_rect.cpp @@ -95,6 +95,15 @@ void TextureRect::_notification(int p_what) { } break; } + Ref<AtlasTexture> p_atlas = texture; + + if (p_atlas.is_valid() && region.has_no_area()) { + Size2 scale_size(size.width / texture->get_width(), size.height / texture->get_height()); + + offset.width += hflip ? p_atlas->get_margin().get_position().width * scale_size.width * 2 : 0; + offset.height += vflip ? p_atlas->get_margin().get_position().height * scale_size.height * 2 : 0; + } + size.width *= hflip ? -1.0f : 1.0f; size.height *= vflip ? -1.0f : 1.0f; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 87425b49cd..a7acaae8df 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -71,7 +71,7 @@ void TreeItem::move_to_bottom() { parent->children = next; } last->next = this; - next = NULL; + next = nullptr; } Size2 TreeItem::Cell::get_icon_size() const { @@ -371,7 +371,7 @@ TreeItem *TreeItem::get_next() { TreeItem *TreeItem::get_prev() { if (!parent || parent->children == this) - return NULL; + return nullptr; TreeItem *prev = parent->children; while (prev && prev->next != this) @@ -400,7 +400,7 @@ TreeItem *TreeItem::get_prev_visible(bool p_wrap) { current = current->parent; if (current == tree->root && tree->hide_root) { - return NULL; + return nullptr; } else if (!current) { if (p_wrap) { current = this; @@ -410,7 +410,7 @@ TreeItem *TreeItem::get_prev_visible(bool p_wrap) { temp = temp->get_next_visible(); } } else { - return NULL; + return nullptr; } } } else { @@ -450,7 +450,7 @@ TreeItem *TreeItem::get_next_visible(bool p_wrap) { if (p_wrap) return tree->root; else - return NULL; + return nullptr; } else { current = current->next; } @@ -472,7 +472,7 @@ void TreeItem::remove_child(TreeItem *p_item) { *c = (*c)->next; - aux->parent = NULL; + aux->parent = nullptr; return; } @@ -890,11 +890,11 @@ void TreeItem::clear_children() { TreeItem *aux = c; c = c->get_next(); - aux->parent = 0; // so it won't try to recursively autoremove from me in here + aux->parent = nullptr; // so it won't try to recursively autoremove from me in here memdelete(aux); } - children = 0; + children = nullptr; }; TreeItem::TreeItem(Tree *p_tree) { @@ -904,9 +904,9 @@ TreeItem::TreeItem(Tree *p_tree) { disable_folding = false; custom_min_height = 0; - parent = 0; // parent item - next = 0; // next in list - children = 0; //child items + parent = nullptr; // parent item + next = nullptr; // next in list + children = nullptr; //child items } TreeItem::~TreeItem() { @@ -918,29 +918,29 @@ TreeItem::~TreeItem() { if (tree && tree->root == this) { - tree->root = 0; + tree->root = nullptr; } if (tree && tree->popup_edited_item == this) { - tree->popup_edited_item = NULL; + tree->popup_edited_item = nullptr; tree->pressing_for_editor = false; } if (tree && tree->cache.hover_item == this) { - tree->cache.hover_item = NULL; + tree->cache.hover_item = nullptr; } if (tree && tree->selected_item == this) - tree->selected_item = NULL; + tree->selected_item = nullptr; if (tree && tree->drop_mode_over == this) - tree->drop_mode_over = NULL; + tree->drop_mode_over = nullptr; if (tree && tree->single_select_defer == this) - tree->single_select_defer = NULL; + tree->single_select_defer = nullptr; if (tree && tree->edited_item == this) { - tree->edited_item = NULL; + tree->edited_item = nullptr; tree->pressing_for_editor = false; } } @@ -1498,7 +1498,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 int parent_ofs = p_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin); Point2i root_pos = Point2i(root_ofs, children_pos.y + label_h / 2) - cache.offset + p_draw_ofs; - if (c->get_children() != NULL) + if (c->get_children() != nullptr) root_pos -= Point2i(cache.arrow->get_width(), 0); float line_width = 1.0; @@ -2131,7 +2131,7 @@ void Tree::popup_select(int p_option) { void Tree::_go_left() { if (selected_col == 0) { - if (selected_item->get_children() != NULL && !selected_item->is_collapsed()) { + if (selected_item->get_children() != nullptr && !selected_item->is_collapsed()) { selected_item->set_collapsed(true); } else { if (columns.size() == 1) { // goto parent with one column @@ -2160,7 +2160,7 @@ void Tree::_go_left() { void Tree::_go_right() { if (selected_col == (columns.size() - 1)) { - if (selected_item->get_children() != NULL && selected_item->is_collapsed()) { + if (selected_item->get_children() != nullptr && selected_item->is_collapsed()) { selected_item->set_collapsed(false); } else if (selected_item->get_next_visible()) { selected_col = 0; @@ -2181,7 +2181,7 @@ void Tree::_go_right() { } void Tree::_go_up() { - TreeItem *prev = NULL; + TreeItem *prev = nullptr; if (!selected_item) { prev = get_last_item(); selected_col = 0; @@ -2221,7 +2221,7 @@ void Tree::_go_up() { } void Tree::_go_down() { - TreeItem *next = NULL; + TreeItem *next = nullptr; if (!selected_item) { if (root) { @@ -2324,7 +2324,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { if (!cursor_can_exit_tree) accept_event(); - TreeItem *next = NULL; + TreeItem *next = nullptr; if (!selected_item) return; next = selected_item; @@ -2362,7 +2362,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { if (!cursor_can_exit_tree) accept_event(); - TreeItem *prev = NULL; + TreeItem *prev = nullptr; if (!selected_item) return; prev = selected_item; @@ -2584,7 +2584,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { if (single_select_defer) { select_single_item(single_select_defer, root, single_select_defer_column); - single_select_defer = NULL; + single_select_defer = nullptr; } range_click_timer->stop(); @@ -2609,7 +2609,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { pressing_for_editor = false; } - if (cache.click_type == Cache::CLICK_BUTTON && cache.click_item != NULL) { + if (cache.click_type == Cache::CLICK_BUTTON && cache.click_item != nullptr) { // make sure in case of wrong reference after reconstructing whole TreeItems cache.click_item = get_item_at_position(cache.click_pos); emit_signal("button_pressed", cache.click_item, cache.click_column, cache.click_id); @@ -2617,7 +2617,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { cache.click_type = Cache::CLICK_NONE; cache.click_index = -1; cache.click_id = -1; - cache.click_item = NULL; + cache.click_item = nullptr; cache.click_column = 0; if (drag_touching) { @@ -2711,7 +2711,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { } if (b->get_button_index() == BUTTON_LEFT) { - if (get_item_at_position(b->get_position()) == NULL && !b->get_shift() && !b->get_control() && !b->get_command()) + if (get_item_at_position(b->get_position()) == nullptr && !b->get_shift() && !b->get_control() && !b->get_command()) emit_signal("nothing_selected"); } } @@ -2946,7 +2946,7 @@ void Tree::_notification(int p_what) { } if (p_what == NOTIFICATION_DRAG_BEGIN) { - single_select_defer = NULL; + single_select_defer = nullptr; if (cache.scroll_speed > 0) { scrolling = true; set_physics_process_internal(true); @@ -3076,7 +3076,7 @@ void Tree::_notification(int p_what) { if (p_what == NOTIFICATION_RESIZED || p_what == NOTIFICATION_TRANSFORM_CHANGED) { - if (popup_edited_item != NULL) { + if (popup_edited_item != nullptr) { Rect2 rect = popup_edited_item->get_meta("__focus_rect"); Vector2 ofs(0, (text_editor->get_size().height - rect.size.height) / 2); Point2i textedpos = get_global_position() + rect.position - ofs; @@ -3097,18 +3097,18 @@ Size2 Tree::get_minimum_size() const { TreeItem *Tree::create_item(TreeItem *p_parent, int p_idx) { - ERR_FAIL_COND_V(blocked > 0, NULL); + ERR_FAIL_COND_V(blocked > 0, nullptr); - TreeItem *ti = NULL; + TreeItem *ti = nullptr; if (p_parent) { // Append or insert a new item to the given parent. ti = memnew(TreeItem(this)); - ERR_FAIL_COND_V(!ti, NULL); + ERR_FAIL_COND_V(!ti, nullptr); ti->cells.resize(columns.size()); - TreeItem *prev = NULL; + TreeItem *prev = nullptr; TreeItem *c = p_parent->children; int idx = 0; @@ -3132,7 +3132,7 @@ TreeItem *Tree::create_item(TreeItem *p_parent, int p_idx) { if (!root) { // No root exists, make the given item the new root. ti = memnew(TreeItem(this)); - ERR_FAIL_COND_V(!ti, NULL); + ERR_FAIL_COND_V(!ti, nullptr); ti->cells.resize(columns.size()); root = ti; @@ -3227,7 +3227,7 @@ void Tree::deselect_all() { ERR_FAIL_COND(item == prev_item); } - selected_item = NULL; + selected_item = nullptr; selected_col = -1; update(); @@ -3235,7 +3235,7 @@ void Tree::deselect_all() { bool Tree::is_anything_selected() { - return (selected_item != NULL); + return (selected_item != nullptr); } void Tree::clear() { @@ -3253,12 +3253,12 @@ void Tree::clear() { if (root) { memdelete(root); - root = NULL; + root = nullptr; }; - selected_item = NULL; - edited_item = NULL; - popup_edited_item = NULL; + selected_item = nullptr; + edited_item = nullptr; + popup_edited_item = nullptr; update(); }; @@ -3315,10 +3315,10 @@ TreeItem *Tree::get_next_selected(TreeItem *p_item) { /* if (!p_item) - return NULL; + return nullptr; */ if (!root) - return NULL; + return nullptr; while (true) { @@ -3338,8 +3338,8 @@ TreeItem *Tree::get_next_selected(TreeItem *p_item) { while (!p_item->next) { p_item = p_item->parent; - if (p_item == NULL) - return NULL; + if (p_item == nullptr) + return nullptr; } p_item = p_item->next; @@ -3351,7 +3351,7 @@ TreeItem *Tree::get_next_selected(TreeItem *p_item) { return p_item; } - return NULL; + return nullptr; } int Tree::get_column_width(int p_column) const { @@ -3458,7 +3458,7 @@ int Tree::get_item_offset(TreeItem *p_item) const { while (!it->next) { it = it->parent; - if (it == NULL) + if (it == nullptr) return 0; } @@ -3626,7 +3626,7 @@ TreeItem *Tree::_search_item_text(TreeItem *p_at, const String &p_find, int *r_c break; } - return NULL; + return nullptr; } TreeItem *Tree::search_item_text(const String &p_find, int *r_col, bool p_selectable) { @@ -3636,7 +3636,7 @@ TreeItem *Tree::search_item_text(const String &p_find, int *r_col, bool p_select if (!from) from = root; if (!from) - return NULL; + return nullptr; return _search_item_text(from->get_next_visible(true), p_find, r_col, p_selectable); } @@ -3649,7 +3649,7 @@ TreeItem *Tree::get_item_with_text(const String &p_find) const { } } } - return NULL; + return nullptr; } void Tree::_do_incr_search(const String &p_add) { @@ -3703,7 +3703,7 @@ TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_ pos.x -= w; } - return NULL; + return nullptr; } else { pos.y -= h; @@ -3714,7 +3714,7 @@ TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_ } if (p_item->is_collapsed()) - return NULL; // do not try children, it's collapsed + return nullptr; // do not try children, it's collapsed TreeItem *n = p_item->get_children(); while (n) { @@ -3728,7 +3728,7 @@ TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_ n = n->get_next(); } - return NULL; + return nullptr; } int Tree::get_column_at_position(const Point2 &p_pos) const { @@ -3790,7 +3790,7 @@ TreeItem *Tree::get_item_at_position(const Point2 &p_pos) const { pos -= cache.bg->get_offset(); pos.y -= _get_title_button_height(); if (pos.y < 0) - return NULL; + return nullptr; if (h_scroll->is_visible_in_tree()) pos.x += h_scroll->get_value(); @@ -3806,7 +3806,7 @@ TreeItem *Tree::get_item_at_position(const Point2 &p_pos) const { } } - return NULL; + return nullptr; } String Tree::get_tooltip(const Point2 &p_pos) const { @@ -3883,7 +3883,7 @@ void Tree::set_drop_mode_flags(int p_flags) { return; drop_mode_flags = p_flags; if (drop_mode_flags == 0) { - drop_mode_over = NULL; + drop_mode_over = nullptr; } update(); @@ -4015,17 +4015,17 @@ Tree::Tree() { selected_col = 0; columns.resize(1); - selected_item = NULL; - edited_item = NULL; + selected_item = nullptr; + edited_item = nullptr; selected_col = -1; edited_col = -1; hide_root = false; select_mode = SELECT_SINGLE; - root = 0; - popup_menu = NULL; - popup_edited_item = NULL; - text_editor = NULL; + root = nullptr; + popup_menu = nullptr; + popup_edited_item = nullptr; + text_editor = nullptr; set_focus_mode(FOCUS_ALL); popup_menu = memnew(PopupMenu); @@ -4078,7 +4078,7 @@ Tree::Tree() { cache.hover_index = -1; cache.click_index = -1; cache.click_id = -1; - cache.click_item = NULL; + cache.click_item = nullptr; cache.click_column = 0; cache.hover_cell = -1; last_keypress = 0; @@ -4098,9 +4098,9 @@ Tree::Tree() { hide_folding = false; drop_mode_flags = 0; - drop_mode_over = NULL; + drop_mode_over = nullptr; drop_mode_section = 0; - single_select_defer = NULL; + single_select_defer = nullptr; scrolling = false; allow_rmb_select = false; @@ -4108,7 +4108,7 @@ Tree::Tree() { set_clip_contents(true); - cache.hover_item = NULL; + cache.hover_item = nullptr; cache.hover_cell = -1; allow_reselect = false; diff --git a/scene/gui/tree.h b/scene/gui/tree.h index becbe76598..87c2588a12 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -383,7 +383,7 @@ private: //void draw_item_text(String p_text,const Ref<Texture2D>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color); void draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color, const Color &p_icon_color); int draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item); - void select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev = NULL, bool *r_in_range = NULL, bool p_force_deselect = false); + void select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev = nullptr, bool *r_in_range = nullptr, bool p_force_deselect = false); int propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool p_doubleclick, TreeItem *p_item, int p_button, const Ref<InputEventWithModifiers> &p_mod); void _text_editor_enter(String p_text); void _text_editor_modal_close(); @@ -584,7 +584,7 @@ public: bool edit_selected(); // First item that starts with the text, from the current focused item down and wraps around. - TreeItem *search_item_text(const String &p_find, int *r_col = NULL, bool p_selectable = false); + TreeItem *search_item_text(const String &p_find, int *r_col = nullptr, bool p_selectable = false); // First item that matches the whole text, from the first item down. TreeItem *get_item_with_text(const String &p_find) const; diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp index 4a415415f1..2eacad68c3 100644 --- a/scene/main/canvas_item.cpp +++ b/scene/main/canvas_item.cpp @@ -43,9 +43,9 @@ #include "servers/rendering_server.h" Mutex CanvasItemMaterial::material_mutex; -SelfList<CanvasItemMaterial>::List *CanvasItemMaterial::dirty_materials = NULL; +SelfList<CanvasItemMaterial>::List *CanvasItemMaterial::dirty_materials = nullptr; Map<CanvasItemMaterial::MaterialKey, CanvasItemMaterial::ShaderData> CanvasItemMaterial::shader_map; -CanvasItemMaterial::ShaderNames *CanvasItemMaterial::shader_names = NULL; +CanvasItemMaterial::ShaderNames *CanvasItemMaterial::shader_names = nullptr; void CanvasItemMaterial::init_shaders() { @@ -62,7 +62,7 @@ void CanvasItemMaterial::finish_shaders() { memdelete(dirty_materials); memdelete(shader_names); - dirty_materials = NULL; + dirty_materials = nullptr; } void CanvasItemMaterial::_update_shader() { @@ -411,7 +411,7 @@ void CanvasItem::hide() { _change_notify("visible"); } -CanvasItem *CanvasItem::current_item_drawn = NULL; +CanvasItem *CanvasItem::current_item_drawn = nullptr; CanvasItem *CanvasItem::get_current_item_drawn() { return current_item_drawn; } @@ -435,9 +435,9 @@ void CanvasItem::_update_callback() { notification(NOTIFICATION_DRAW); emit_signal(SceneStringNames::get_singleton()->draw); if (get_script_instance()) { - get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_draw, NULL, 0); + get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_draw, nullptr, 0); } - current_item_drawn = NULL; + current_item_drawn = nullptr; drawing = false; } //todo updating = false @@ -504,7 +504,7 @@ void CanvasItem::_enter_canvas() { Node *n = this; - canvas_layer = NULL; + canvas_layer = nullptr; while (n) { @@ -554,7 +554,7 @@ void CanvasItem::_exit_canvas() { notification(NOTIFICATION_EXIT_CANVAS, true); //reverse the notification RenderingServer::get_singleton()->canvas_item_set_parent(canvas_item, RID()); - canvas_layer = NULL; + canvas_layer = nullptr; group = ""; } @@ -617,7 +617,7 @@ void CanvasItem::_notification(int p_what) { _exit_canvas(); if (C) { Object::cast_to<CanvasItem>(get_parent())->children_items.erase(C); - C = NULL; + C = nullptr; } if (window) { window->disconnect(SceneStringNames::get_singleton()->visibility_changed, callable_mp(this, &CanvasItem::_window_visibility_changed)); @@ -703,7 +703,7 @@ bool CanvasItem::is_set_as_toplevel() const { CanvasItem *CanvasItem::get_parent_item() const { if (toplevel) - return NULL; + return nullptr; return Object::cast_to<CanvasItem>(get_parent()); } @@ -1469,8 +1469,7 @@ CanvasItem::CanvasItem() : drawing = false; behind = false; block_transform_notify = false; - //viewport=NULL; - canvas_layer = NULL; + canvas_layer = nullptr; use_parent_material = false; global_invalid = true; notify_local_transform = false; @@ -1481,7 +1480,7 @@ CanvasItem::CanvasItem() : texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR; texture_repeat_cache = RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED; - C = NULL; + C = nullptr; } CanvasItem::~CanvasItem() { diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp index e6a665d035..c1caa943e3 100644 --- a/scene/main/canvas_layer.cpp +++ b/scene/main/canvas_layer.cpp @@ -35,7 +35,7 @@ void CanvasLayer::set_layer(int p_xform) { layer = p_xform; if (viewport.is_valid()) - RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent()); + RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_index()); } int CanvasLayer::get_layer() const { @@ -151,7 +151,7 @@ void CanvasLayer::_notification(int p_what) { viewport = vp->get_viewport_rid(); RenderingServer::get_singleton()->viewport_attach_canvas(viewport, canvas); - RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent()); + RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_index()); RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform); _update_follow_viewport(); @@ -167,7 +167,7 @@ void CanvasLayer::_notification(int p_what) { case NOTIFICATION_MOVED_IN_PARENT: { if (is_inside_tree()) - RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent()); + RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_index()); } break; } @@ -214,7 +214,7 @@ void CanvasLayer::set_custom_viewport(Node *p_viewport) { viewport = vp->get_viewport_rid(); RenderingServer::get_singleton()->viewport_attach_canvas(viewport, canvas); - RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent()); + RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_index()); RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform); } } @@ -320,13 +320,13 @@ void CanvasLayer::_bind_methods() { CanvasLayer::CanvasLayer() { - vp = NULL; + vp = nullptr; scale = Vector2(1, 1); rot = 0; locrotscale_dirty = false; layer = 1; canvas = RS::get_singleton()->canvas_create(); - custom_viewport = NULL; + custom_viewport = nullptr; sort_index = 0; follow_viewport = false; diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp index fee2ada76d..dc0da015ac 100644 --- a/scene/main/http_request.cpp +++ b/scene/main/http_request.cpp @@ -162,12 +162,12 @@ void HTTPRequest::cancel_request() { thread_request_quit = true; Thread::wait_to_finish(thread); memdelete(thread); - thread = NULL; + thread = nullptr; } if (file) { memdelete(file); - file = NULL; + file = nullptr; } client->close(); body.resize(0); @@ -566,7 +566,7 @@ void HTTPRequest::_bind_methods() { HTTPRequest::HTTPRequest() { - thread = NULL; + thread = nullptr; port = 80; redirections = 0; @@ -583,7 +583,7 @@ HTTPRequest::HTTPRequest() { thread_done = false; downloaded = 0; body_size_limit = -1; - file = NULL; + file = nullptr; timer = memnew(Timer); timer->set_one_shot(true); diff --git a/scene/main/instance_placeholder.cpp b/scene/main/instance_placeholder.cpp index fe238af1c4..062b221c84 100644 --- a/scene/main/instance_placeholder.cpp +++ b/scene/main/instance_placeholder.cpp @@ -77,11 +77,11 @@ String InstancePlaceholder::get_instance_path() const { Node *InstancePlaceholder::create_instance(bool p_replace, const Ref<PackedScene> &p_custom_scene) { - ERR_FAIL_COND_V(!is_inside_tree(), NULL); + ERR_FAIL_COND_V(!is_inside_tree(), nullptr); Node *base = get_parent(); if (!base) - return NULL; + return nullptr; Ref<PackedScene> ps; if (p_custom_scene.is_valid()) @@ -90,12 +90,12 @@ Node *InstancePlaceholder::create_instance(bool p_replace, const Ref<PackedScene ps = ResourceLoader::load(path, "PackedScene"); if (!ps.is_valid()) - return NULL; + return nullptr; Node *scene = ps->instance(); if (!scene) - return NULL; + return nullptr; scene->set_name(get_name()); - int pos = get_position_in_parent(); + int pos = get_index(); for (List<PropSet>::Element *E = stored_values.front(); E; E = E->next()) { scene->set(E->get().name, E->get().value); diff --git a/scene/main/node.cpp b/scene/main/node.cpp index b882b9ead6..50f3bf834f 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -82,7 +82,7 @@ void Node::_notification(int p_notification) { if (data.parent) data.pause_owner = data.parent->data.pause_owner; else - data.pause_owner = NULL; + data.pause_owner = nullptr; } else { data.pause_owner = this; } @@ -112,17 +112,17 @@ void Node::_notification(int p_notification) { if (data.unhandled_key_input) remove_from_group("_vp_unhandled_key_input" + itos(get_viewport()->get_instance_id())); - data.pause_owner = NULL; + data.pause_owner = nullptr; if (data.path_cache) { memdelete(data.path_cache); - data.path_cache = NULL; + data.path_cache = nullptr; } } break; case NOTIFICATION_PATH_CHANGED: { if (data.path_cache) { memdelete(data.path_cache); - data.path_cache = NULL; + data.path_cache = nullptr; } } break; case NOTIFICATION_READY: { @@ -149,7 +149,7 @@ void Node::_notification(int p_notification) { set_physics_process(true); } - get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_ready, NULL, 0); + get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_ready, nullptr, 0); } } break; @@ -158,11 +158,11 @@ void Node::_notification(int p_notification) { } break; case NOTIFICATION_PREDELETE: { - set_owner(NULL); + set_owner(nullptr); while (data.owned.size()) { - data.owned.front()->get()->set_owner(NULL); + data.owned.front()->get()->set_owner(nullptr); } if (data.parent) { @@ -226,7 +226,7 @@ void Node::_propagate_enter_tree() { if (get_script_instance()) { - get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_enter_tree, NULL, 0); + get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_enter_tree, nullptr, 0); } emit_signal(SceneStringNames::get_singleton()->tree_entered); @@ -278,7 +278,7 @@ void Node::_propagate_exit_tree() { if (get_script_instance()) { - get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_tree, NULL, 0); + get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_tree, nullptr, 0); } emit_signal(SceneStringNames::get_singleton()->tree_exiting); @@ -290,17 +290,17 @@ void Node::_propagate_exit_tree() { for (Map<StringName, GroupData>::Element *E = data.grouped.front(); E; E = E->next()) { data.tree->remove_from_group(E->key(), this); - E->get().group = NULL; + E->get().group = nullptr; } - data.viewport = NULL; + data.viewport = nullptr; if (data.tree) data.tree->tree_changed(); data.inside_tree = false; data.ready_notified = false; - data.tree = NULL; + data.tree = nullptr; data.depth = -1; } @@ -423,7 +423,7 @@ void Node::set_pause_mode(PauseMode p_mode) { if ((data.pause_mode == PAUSE_MODE_INHERIT) == prev_inherits) return; ///nothing changed - Node *owner = NULL; + Node *owner = nullptr; if (data.pause_mode == PAUSE_MODE_INHERIT) { @@ -914,7 +914,7 @@ void Node::set_process_priority(int p_priority) { data.process_priority = p_priority; // Make sure we are in SceneTree. - if (data.tree == NULL) { + if (data.tree == nullptr) { return; } @@ -1268,7 +1268,7 @@ void Node::add_child_below_node(Node *p_node, Node *p_child, bool p_legible_uniq add_child(p_child, p_legible_unique_name); if (is_a_parent_of(p_node)) { - move_child(p_child, p_node->get_position_in_parent() + 1); + move_child(p_child, p_node->get_index() + 1); } else { WARN_PRINT("Cannot move under node " + p_node->get_name() + " as " + p_child->get_name() + " does not share a parent."); } @@ -1295,7 +1295,7 @@ void Node::_propagate_validate_owner() { if (!found) { data.owner->data.owned.erase(data.OW); - data.owner = NULL; + data.owner = nullptr; } } @@ -1336,7 +1336,7 @@ void Node::remove_child(Node *p_child) { //if (data.scene) { does not matter - p_child->_set_tree(NULL); + p_child->_set_tree(nullptr); //} remove_child_notify(p_child); @@ -1354,7 +1354,7 @@ void Node::remove_child(Node *p_child) { children[i]->notification(NOTIFICATION_MOVED_IN_PARENT); } - p_child->data.parent = NULL; + p_child->data.parent = nullptr; p_child->data.pos = -1; // validate owner @@ -1371,7 +1371,7 @@ int Node::get_child_count() const { } Node *Node::get_child(int p_index) const { - ERR_FAIL_INDEX_V(p_index, data.children.size(), NULL); + ERR_FAIL_INDEX_V(p_index, data.children.size(), nullptr); return data.children[p_index]; } @@ -1386,19 +1386,19 @@ Node *Node::_get_child_by_name(const StringName &p_name) const { return cd[i]; } - return NULL; + return nullptr; } Node *Node::get_node_or_null(const NodePath &p_path) const { if (p_path.is_empty()) { - return NULL; + return nullptr; } - ERR_FAIL_COND_V_MSG(!data.inside_tree && p_path.is_absolute(), NULL, "Can't use get_node() with absolute paths from outside the active scene tree."); + ERR_FAIL_COND_V_MSG(!data.inside_tree && p_path.is_absolute(), nullptr, "Can't use get_node() with absolute paths from outside the active scene tree."); - Node *current = NULL; - Node *root = NULL; + Node *current = nullptr; + Node *root = nullptr; if (!p_path.is_absolute()) { current = const_cast<Node *>(this); //start from this @@ -1412,7 +1412,7 @@ Node *Node::get_node_or_null(const NodePath &p_path) const { for (int i = 0; i < p_path.get_name_count(); i++) { StringName name = p_path.get_name(i); - Node *next = NULL; + Node *next = nullptr; if (name == SceneStringNames::get_singleton()->dot) { // . @@ -1420,18 +1420,18 @@ Node *Node::get_node_or_null(const NodePath &p_path) const { } else if (name == SceneStringNames::get_singleton()->doubledot) { // .. - if (current == NULL || !current->data.parent) - return NULL; + if (current == nullptr || !current->data.parent) + return nullptr; next = current->data.parent; - } else if (current == NULL) { + } else if (current == nullptr) { if (name == root->get_name()) next = root; } else { - next = NULL; + next = nullptr; for (int j = 0; j < current->data.children.size(); j++) { @@ -1443,8 +1443,8 @@ Node *Node::get_node_or_null(const NodePath &p_path) const { break; } } - if (next == NULL) { - return NULL; + if (next == nullptr) { + return nullptr; }; } current = next; @@ -1456,13 +1456,13 @@ Node *Node::get_node_or_null(const NodePath &p_path) const { Node *Node::get_node(const NodePath &p_path) const { Node *node = get_node_or_null(p_path); - ERR_FAIL_COND_V_MSG(!node, NULL, "Node not found: " + p_path + "."); + ERR_FAIL_COND_V_MSG(!node, nullptr, "Node not found: " + p_path + "."); return node; } bool Node::has_node(const NodePath &p_path) const { - return get_node_or_null(p_path) != NULL; + return get_node_or_null(p_path) != nullptr; } Node *Node::find_node(const String &p_mask, bool p_recursive, bool p_owned) const { @@ -1482,7 +1482,7 @@ Node *Node::find_node(const String &p_mask, bool p_recursive, bool p_owned) cons if (ret) return ret; } - return NULL; + return nullptr; } Node *Node::get_parent() const { @@ -1500,7 +1500,7 @@ Node *Node::find_parent(const String &p_mask) const { p = p->data.parent; } - return NULL; + return nullptr; } bool Node::is_a_parent_of(const Node *p_node) const { @@ -1607,8 +1607,8 @@ void Node::set_owner(Node *p_owner) { if (data.owner) { data.owner->data.owned.erase(data.OW); - data.OW = NULL; - data.owner = NULL; + data.OW = nullptr; + data.owner = nullptr; } ERR_FAIL_COND(p_owner == this); @@ -1663,7 +1663,7 @@ Node *Node::find_common_parent_with(const Node *p_node) const { } if (!common_parent) - return NULL; + return nullptr; return const_cast<Node *>(common_parent); } @@ -1762,7 +1762,7 @@ void Node::add_to_group(const StringName &p_identifier, bool p_persistent) { if (data.tree) { gd.group = data.tree->add_to_group(p_identifier, this); } else { - gd.group = NULL; + gd.group = nullptr; } gd.persistent = p_persistent; @@ -1918,6 +1918,7 @@ int Node::get_index() const { return data.pos; } + void Node::remove_and_skip() { ERR_FAIL_COND(!data.parent); @@ -1935,7 +1936,7 @@ void Node::remove_and_skip() { continue; remove_child(c_node); - c_node->_propagate_replace_owner(this, NULL); + c_node->_propagate_replace_owner(this, nullptr); children.push_back(c_node); clear = false; break; @@ -1949,7 +1950,7 @@ void Node::remove_and_skip() { Node *c_node = children.front()->get(); data.parent->add_child(c_node); - c_node->_propagate_replace_owner(NULL, new_owner); + c_node->_propagate_replace_owner(nullptr, new_owner); children.pop_front(); } @@ -2042,14 +2043,9 @@ bool Node::get_scene_instance_load_placeholder() const { return data.use_placeholder; } -int Node::get_position_in_parent() const { - - return data.pos; -} - Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const { - Node *node = NULL; + Node *node = nullptr; bool instanced = false; @@ -2063,25 +2059,25 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const } else if ((p_flags & DUPLICATE_USE_INSTANCING) && get_filename() != String()) { Ref<PackedScene> res = ResourceLoader::load(get_filename()); - ERR_FAIL_COND_V(res.is_null(), NULL); + ERR_FAIL_COND_V(res.is_null(), nullptr); PackedScene::GenEditState ges = PackedScene::GEN_EDIT_STATE_DISABLED; #ifdef TOOLS_ENABLED if (p_flags & DUPLICATE_FROM_EDITOR) ges = PackedScene::GEN_EDIT_STATE_INSTANCE; #endif node = res->instance(ges); - ERR_FAIL_COND_V(!node, NULL); + ERR_FAIL_COND_V(!node, nullptr); instanced = true; } else { Object *obj = ClassDB::instance(get_class()); - ERR_FAIL_COND_V(!obj, NULL); + ERR_FAIL_COND_V(!obj, nullptr); node = Object::cast_to<Node>(obj); if (!node) memdelete(obj); - ERR_FAIL_COND_V(!node, NULL); + ERR_FAIL_COND_V(!node, nullptr); } if (get_filename() != "") { //an instance @@ -2189,7 +2185,7 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const if (!dup) { memdelete(node); - return NULL; + return nullptr; } node->add_child(dup); @@ -2204,18 +2200,18 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const if (!parent) { memdelete(node); - return NULL; + return nullptr; } Node *dup = E->get()->_duplicate(p_flags, r_duplimap); if (!dup) { memdelete(node); - return NULL; + return nullptr; } parent->add_child(dup); - int pos = E->get()->get_position_in_parent(); + int pos = E->get()->get_index(); if (pos < parent->get_child_count() - 1) { @@ -2256,7 +2252,7 @@ void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p if (get_owner() != get_parent()->get_owner()) return; - Node *node = NULL; + Node *node = nullptr; if (get_filename() != "") { @@ -2369,15 +2365,15 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const { Node *Node::duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const { - ERR_FAIL_COND_V(get_filename() != "", NULL); + ERR_FAIL_COND_V(get_filename() != "", nullptr); Object *obj = ClassDB::instance(get_class()); - ERR_FAIL_COND_V_MSG(!obj, NULL, "Node: Could not duplicate: " + String(get_class()) + "."); + ERR_FAIL_COND_V_MSG(!obj, nullptr, "Node: Could not duplicate: " + String(get_class()) + "."); Node *node = Object::cast_to<Node>(obj); if (!node) { memdelete(obj); - ERR_FAIL_V_MSG(NULL, "Node: Could not duplicate: " + String(get_class()) + "."); + ERR_FAIL_V_MSG(nullptr, "Node: Could not duplicate: " + String(get_class()) + "."); } node->set_name(get_name()); @@ -2591,7 +2587,7 @@ Node *Node::get_node_and_resource(const NodePath &p_path, RES &r_res, Vector<Str r_res = RES(); r_leftover_subpath = Vector<StringName>(); if (!node) - return NULL; + return nullptr; if (p_path.get_subname_count()) { @@ -2601,7 +2597,7 @@ Node *Node::get_node_and_resource(const NodePath &p_path, RES &r_res, Vector<Str Variant new_res_v = j == 0 ? node->get(p_path.get_subname(j)) : r_res->get(p_path.get_subname(j)); if (new_res_v.get_type() == Variant::NIL) { // Found nothing on that path - return NULL; + return nullptr; } RES new_res = new_res_v; @@ -2623,8 +2619,8 @@ Node *Node::get_node_and_resource(const NodePath &p_path, RES &r_res, Vector<Str void Node::_set_tree(SceneTree *p_tree) { - SceneTree *tree_changed_a = NULL; - SceneTree *tree_changed_b = NULL; + SceneTree *tree_changed_a = nullptr; + SceneTree *tree_changed_b = nullptr; //ERR_FAIL_COND(p_scene && data.parent && !data.parent->data.scene); //nobug if both are null @@ -2860,7 +2856,6 @@ void Node::_bind_methods() { ClassDB::bind_method(D_METHOD("get_pause_mode"), &Node::get_pause_mode); ClassDB::bind_method(D_METHOD("can_process"), &Node::can_process); ClassDB::bind_method(D_METHOD("print_stray_nodes"), &Node::_print_stray_nodes); - ClassDB::bind_method(D_METHOD("get_position_in_parent"), &Node::get_position_in_parent); ClassDB::bind_method(D_METHOD("set_display_folded", "fold"), &Node::set_display_folded); ClassDB::bind_method(D_METHOD("is_displayed_folded"), &Node::is_displayed_folded); @@ -3012,8 +3007,8 @@ Node::Node() { data.pos = -1; data.depth = -1; data.blocked = 0; - data.parent = NULL; - data.tree = NULL; + data.parent = nullptr; + data.tree = nullptr; data.physics_process = false; data.idle_process = false; data.process_priority = 0; @@ -3022,18 +3017,18 @@ Node::Node() { data.inside_tree = false; data.ready_notified = false; - data.owner = NULL; - data.OW = NULL; + data.owner = nullptr; + data.OW = nullptr; data.input = false; data.unhandled_input = false; data.unhandled_key_input = false; data.pause_mode = PAUSE_MODE_INHERIT; - data.pause_owner = NULL; + data.pause_owner = nullptr; data.network_master = 1; //server by default - data.path_cache = NULL; + data.path_cache = nullptr; data.parent_owned = false; data.in_constructor = true; - data.viewport = NULL; + data.viewport = nullptr; data.use_placeholder = false; data.display_folded = false; data.ready_first = true; diff --git a/scene/main/node.h b/scene/main/node.h index cf25a92be6..5de07d506e 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -180,7 +180,7 @@ private: void _duplicate_signals(const Node *p_original, Node *p_copy) const; void _duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p_reown_map) const; - Node *_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap = NULL) const; + Node *_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap = nullptr) const; Array _get_children() const; Array _get_groups() const; @@ -286,7 +286,7 @@ public: Node *find_parent(const String &p_mask) const; _FORCE_INLINE_ SceneTree *get_tree() const { - ERR_FAIL_COND_V(!data.tree, NULL); + ERR_FAIL_COND_V(!data.tree, nullptr); return data.tree; } @@ -369,8 +369,6 @@ public: void set_process_unhandled_key_input(bool p_enable); bool is_processing_unhandled_key_input() const; - int get_position_in_parent() const; - Node *duplicate(int p_flags = DUPLICATE_GROUPS | DUPLICATE_SIGNALS | DUPLICATE_SCRIPTS) const; Node *duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const; #ifdef TOOLS_ENABLED diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 15c0a7666e..41f31617d2 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -112,7 +112,7 @@ void SceneTree::node_added(Node *p_node) { void SceneTree::node_removed(Node *p_node) { if (current_scene == p_node) { - current_scene = NULL; + current_scene = nullptr; } emit_signal(node_removed_name, p_node); if (call_lock > 0) @@ -539,10 +539,10 @@ void SceneTree::finish() { MainLoop::finish(); if (root) { - root->_set_tree(NULL); + root->_set_tree(nullptr); root->_propagate_after_exit_tree(); memdelete(root); //delete root - root = NULL; + root = nullptr; } // cleanup timers @@ -1037,7 +1037,7 @@ Node *SceneTree::get_edited_scene_root() const { #ifdef TOOLS_ENABLED return edited_scene_root; #else - return NULL; + return nullptr; #endif } @@ -1056,7 +1056,7 @@ void SceneTree::_change_scene(Node *p_to) { if (current_scene) { memdelete(current_scene); - current_scene = NULL; + current_scene = nullptr; } // If we're quitting, abort. @@ -1082,7 +1082,7 @@ Error SceneTree::change_scene(const String &p_path) { } Error SceneTree::change_scene_to(const Ref<PackedScene> &p_scene) { - Node *new_scene = NULL; + Node *new_scene = nullptr; if (p_scene.is_valid()) { new_scene = p_scene->instance(); ERR_FAIL_COND_V(!new_scene, ERR_CANT_CREATE); @@ -1321,7 +1321,7 @@ void SceneTree::_bind_methods() { BIND_ENUM_CONSTANT(GROUP_CALL_UNIQUE); } -SceneTree *SceneTree::singleton = NULL; +SceneTree *SceneTree::singleton = nullptr; SceneTree::IdleCallback SceneTree::idle_callbacks[SceneTree::MAX_IDLE_CALLBACKS]; int SceneTree::idle_callback_count = 0; @@ -1372,7 +1372,7 @@ void SceneTree::get_argument_options(const StringName &p_function, int p_idx, Li SceneTree::SceneTree() { - if (singleton == NULL) singleton = this; + if (singleton == nullptr) singleton = this; _quit = false; accept_quit = true; quit_on_go_back = true; @@ -1392,7 +1392,7 @@ SceneTree::SceneTree() { physics_process_time = 1; idle_process_time = 1; - root = NULL; + root = nullptr; pause = false; current_frame = 0; current_event = 0; @@ -1419,7 +1419,7 @@ SceneTree::SceneTree() { //root->set_world_2d( Ref<World2D>( memnew( World2D ))); root->set_as_audio_listener(true); root->set_as_audio_listener_2d(true); - current_scene = NULL; + current_scene = nullptr; int msaa_mode = GLOBAL_DEF("rendering/quality/filters/msaa", 0); ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/filters/msaa", PropertyInfo(Variant::INT, "rendering/quality/filters/msaa", PROPERTY_HINT_ENUM, "Disabled,2x,4x,8x,16x,AndroidVR 2x,AndroidVR 4x")); @@ -1463,16 +1463,16 @@ SceneTree::SceneTree() { root->connect("focus_entered", callable_mp(this, &SceneTree::_main_window_focus_in)); #ifdef TOOLS_ENABLED - edited_scene_root = NULL; + edited_scene_root = nullptr; #endif } SceneTree::~SceneTree() { if (root) { - root->_set_tree(NULL); + root->_set_tree(nullptr); root->_propagate_after_exit_tree(); memdelete(root); } - if (singleton == this) singleton = NULL; + if (singleton == this) singleton = nullptr; } diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index b95e81a702..1cfc3b0260 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -61,7 +61,7 @@ void ViewportTexture::setup_local_to_scene() { vp->viewport_textures.erase(this); } - vp = NULL; + vp = nullptr; Node *local_scene = get_local_scene(); if (!local_scene) { @@ -148,7 +148,7 @@ void ViewportTexture::_bind_methods() { ViewportTexture::ViewportTexture() { - vp = NULL; + vp = nullptr; set_local_to_scene(true); } @@ -190,17 +190,17 @@ Viewport::GUI::GUI() { embedding_subwindows = false; dragging = false; - mouse_focus = NULL; + mouse_focus = nullptr; forced_mouse_focus = false; - mouse_click_grabber = NULL; + mouse_click_grabber = nullptr; mouse_focus_mask = 0; - key_focus = NULL; - mouse_over = NULL; - drag_mouse_over = NULL; + key_focus = nullptr; + mouse_over = nullptr; + drag_mouse_over = nullptr; - tooltip = NULL; - tooltip_popup = NULL; - tooltip_label = NULL; + tooltip = nullptr; + tooltip_popup = nullptr; + tooltip_label = nullptr; } ///////////////////////////////////// @@ -455,7 +455,7 @@ void Viewport::_notification(int p_what) { parent = get_parent()->get_viewport(); RenderingServer::get_singleton()->viewport_set_parent_viewport(viewport, parent->get_viewport_rid()); } else { - parent = NULL; + parent = nullptr; } current_canvas = find_world_2d()->get_canvas(); @@ -489,10 +489,10 @@ void Viewport::_notification(int p_what) { case NOTIFICATION_READY: { #ifndef _3D_DISABLED if (listeners.size() && !listener) { - Listener3D *first = NULL; + Listener3D *first = nullptr; for (Set<Listener3D *>::Element *E = listeners.front(); E; E = E->next()) { - if (first == NULL || first->is_greater_than(E->get())) { + if (first == nullptr || first->is_greater_than(E->get())) { first = E->get(); } } @@ -503,10 +503,10 @@ void Viewport::_notification(int p_what) { if (cameras.size() && !camera) { //there are cameras but no current camera, pick first in tree and make it current - Camera3D *first = NULL; + Camera3D *first = nullptr; for (Set<Camera3D *>::Element *E = cameras.front(); E; E = E->next()) { - if (first == NULL || first->is_greater_than(E->get())) { + if (first == nullptr || first->is_greater_than(E->get())) { first = E->get(); } } @@ -586,7 +586,7 @@ void Viewport::_notification(int p_what) { #ifndef _3D_DISABLED Vector2 last_pos(1e20, 1e20); - CollisionObject3D *last_object = NULL; + CollisionObject3D *last_object = nullptr; ObjectID last_id; #endif PhysicsDirectSpaceState3D::RayResult result; @@ -879,13 +879,14 @@ void Viewport::update_canvas_items() { _update_canvas_items(this); } -void Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_override, const Rect2i &p_to_screen_rect, const Transform2D &p_stretch_transform, bool p_allocated) { +void Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_2d_override, const Rect2i &p_to_screen_rect, const Transform2D &p_stretch_transform, bool p_allocated) { - if (size == p_size && size_allocated == p_allocated && stretch_transform == p_stretch_transform && p_size_override == size_override && to_screen_rect != p_to_screen_rect) + if (size == p_size && size_allocated == p_allocated && stretch_transform == p_stretch_transform && p_size_2d_override == size_2d_override && to_screen_rect != p_to_screen_rect) return; + size = p_size; size_allocated = p_allocated; - size_override = p_size_override; + size_2d_override = p_size_2d_override; stretch_transform = p_stretch_transform; to_screen_rect = p_to_screen_rect; @@ -904,6 +905,9 @@ void Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_override, co Size2i Viewport::_get_size() const { return size; } +Size2i Viewport::_get_size_2d_override() const { + return size_2d_override; +} bool Viewport::_is_size_allocated() const { return size_allocated; } @@ -918,8 +922,8 @@ Rect2 Viewport::get_visible_rect() const { r = Rect2(Point2(), size); } - if (size_override != Size2i()) { - r.size = size_override; + if (size_2d_override != Size2i()) { + r.size = size_2d_override; } return r; @@ -1059,7 +1063,7 @@ void Viewport::_listener_remove(Listener3D *p_listener) { listeners.erase(p_listener); if (listener == p_listener) { - listener = NULL; + listener = nullptr; } } @@ -1073,14 +1077,14 @@ void Viewport::_listener_make_next_current(Listener3D *p_exclude) { continue; if (!E->get()->is_inside_tree()) continue; - if (listener != NULL) + if (listener != nullptr) return; E->get()->make_current(); } } else { // Attempt to reset listener to the camera position - if (camera != NULL) { + if (camera != nullptr) { _update_listener(); _camera_transform_changed_notify(); } @@ -1134,7 +1138,7 @@ void Viewport::_camera_remove(Camera3D *p_camera) { cameras.erase(p_camera); if (camera == p_camera) { camera->notification(Camera3D::NOTIFICATION_LOST_CURRENT); - camera = NULL; + camera = nullptr; } } @@ -1147,7 +1151,7 @@ void Viewport::_camera_make_next_current(Camera3D *p_exclude) { continue; if (!E->get()->is_inside_tree()) continue; - if (camera != NULL) + if (camera != nullptr) return; E->get()->make_current(); @@ -1528,12 +1532,12 @@ void Viewport::_gui_sort_roots() { void Viewport::_gui_cancel_tooltip() { - gui.tooltip = NULL; + gui.tooltip = nullptr; gui.tooltip_timer = -1; if (gui.tooltip_popup) { gui.tooltip_popup->queue_delete(); - gui.tooltip_popup = NULL; - gui.tooltip_label = NULL; + gui.tooltip_popup = nullptr; + gui.tooltip_label = nullptr; } } @@ -1571,7 +1575,7 @@ void Viewport::_gui_show_tooltip() { return; } - Control *which = NULL; + Control *which = nullptr; String tooltip = _gui_get_tooltip(gui.tooltip, gui.tooltip->get_global_transform().xform_inv(gui.tooltip_pos), &which); tooltip = tooltip.strip_edges(); if (tooltip.length() == 0) @@ -1579,8 +1583,8 @@ void Viewport::_gui_show_tooltip() { if (gui.tooltip_popup) { memdelete(gui.tooltip_popup); - gui.tooltip_popup = NULL; - gui.tooltip_label = NULL; + gui.tooltip_popup = nullptr; + gui.tooltip_label = nullptr; } if (!which) { @@ -1651,7 +1655,7 @@ void Viewport::_gui_call_input(Control *p_control, const Ref<InputEvent> &p_inpu Ref<InputEventPanGesture> pn = p_input; cant_stop_me_now = pn.is_valid() || cant_stop_me_now; - bool ismouse = ev.is_valid() || Object::cast_to<InputEventMouseMotion>(*p_input) != NULL; + bool ismouse = ev.is_valid() || Object::cast_to<InputEventMouseMotion>(*p_input) != nullptr; CanvasItem *ci = p_control; while (ci) { @@ -1741,23 +1745,23 @@ Control *Viewport::_gui_find_control(const Point2 &p_global) { return ret; } - return NULL; + return nullptr; } Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_global, const Transform2D &p_xform, Transform2D &r_inv_xform) { if (Object::cast_to<Viewport>(p_node)) - return NULL; + return nullptr; if (!p_node->is_visible()) { //return _find_next_visible_control_at_pos(p_node,p_global,r_inv_xform); - return NULL; //canvas item hidden, discard + return nullptr; //canvas item hidden, discard } Transform2D matrix = p_xform * p_node->get_transform(); // matrix.basis_determinant() == 0.0f implies that node does not exist on scene if (matrix.basis_determinant() == 0.0f) - return NULL; + return nullptr; Control *c = Object::cast_to<Control>(p_node); @@ -1776,7 +1780,7 @@ Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_ } if (!c) - return NULL; + return nullptr; matrix.affine_invert(); @@ -1785,7 +1789,7 @@ Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_ r_inv_xform = matrix; return c; } else - return NULL; + return nullptr; } bool Viewport::_gui_drop(Control *p_at_control, Point2 p_at_pos, bool p_just_check) { @@ -1938,7 +1942,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { if (gui.drag_preview) { memdelete(gui.drag_preview); - gui.drag_preview = NULL; + gui.drag_preview = nullptr; } _propagate_viewport_notification(this, NOTIFICATION_DRAG_END); //change mouse accordingly @@ -1957,7 +1961,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { if (gui.drag_preview && mb->get_button_index() == BUTTON_LEFT) { memdelete(gui.drag_preview); - gui.drag_preview = NULL; + gui.drag_preview = nullptr; } gui.drag_data = Variant(); @@ -1985,7 +1989,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { //disable mouse focus if needed before calling input, this makes popups on mouse press event work better, as the release will never be received otherwise if (gui.mouse_focus_mask == 0) { - gui.mouse_focus = NULL; + gui.mouse_focus = nullptr; gui.forced_mouse_focus = false; } @@ -2011,7 +2015,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { gui.last_mouse_pos = mpos; - Control *over = NULL; + Control *over = nullptr; // D&D if (!gui.drag_attempted && gui.mouse_focus && mm->get_button_mask() & BUTTON_MASK_LEFT) { @@ -2031,15 +2035,15 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { gui.drag_data = control->get_drag_data(control->get_global_transform_with_canvas().affine_inverse().xform(mpos) - gui.drag_accum); if (gui.drag_data.get_type() != Variant::NIL) { - gui.mouse_focus = NULL; + gui.mouse_focus = nullptr; gui.forced_mouse_focus = false; gui.mouse_focus_mask = 0; break; } else { - if (gui.drag_preview != NULL) { + if (gui.drag_preview != nullptr) { ERR_PRINT("Don't set a drag preview and return null data. Preview was deleted and drag request ignored."); memdelete(gui.drag_preview); - gui.drag_preview = NULL; + gui.drag_preview = nullptr; } gui.dragging = false; } @@ -2395,7 +2399,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { } } - Control *from = gui.key_focus ? gui.key_focus : NULL; //hmm + Control *from = gui.key_focus ? gui.key_focus : nullptr; //hmm //keyboard focus //if (from && p_event->is_pressed() && !p_event->get_alt() && !p_event->get_metakey() && !p_event->key->get_command()) { @@ -2405,7 +2409,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { bool mods = k.is_valid() && (k->get_control() || k->get_alt() || k->get_shift() || k->get_metakey()); if (from && p_event->is_pressed()) { - Control *next = NULL; + Control *next = nullptr; InputFilter *input = InputFilter::get_singleton(); @@ -2463,7 +2467,7 @@ void Viewport::_gui_force_drag(Control *p_base, const Variant &p_data, Control * gui.dragging = true; gui.drag_data = p_data; - gui.mouse_focus = NULL; + gui.mouse_focus = nullptr; if (p_control) { _gui_set_drag_preview(p_base, p_control); @@ -2475,7 +2479,7 @@ 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() != NULL); + ERR_FAIL_COND(p_control->get_parent() != nullptr); if (gui.drag_preview) { memdelete(gui.drag_preview); @@ -2506,22 +2510,12 @@ void Viewport::_gui_hid_control(Control *p_control) { _drop_mouse_focus(); } - /* ??? - if (data.window==p_control) { - window->drag_data=Variant(); - if (window->drag_preview) { - memdelete( window->drag_preview); - window->drag_preview=NULL; - } - } - */ - if (gui.key_focus == p_control) _gui_remove_focus(); if (gui.mouse_over == p_control) - gui.mouse_over = NULL; + gui.mouse_over = nullptr; if (gui.drag_mouse_over == p_control) - gui.drag_mouse_over = NULL; + gui.drag_mouse_over = nullptr; if (gui.tooltip == p_control) _gui_cancel_tooltip(); } @@ -2529,28 +2523,28 @@ void Viewport::_gui_hid_control(Control *p_control) { void Viewport::_gui_remove_control(Control *p_control) { if (gui.mouse_focus == p_control) { - gui.mouse_focus = NULL; + gui.mouse_focus = nullptr; gui.forced_mouse_focus = false; gui.mouse_focus_mask = 0; } if (gui.last_mouse_focus == p_control) { - gui.last_mouse_focus = NULL; + gui.last_mouse_focus = nullptr; } if (gui.key_focus == p_control) - gui.key_focus = NULL; + gui.key_focus = nullptr; if (gui.mouse_over == p_control) - gui.mouse_over = NULL; + gui.mouse_over = nullptr; if (gui.drag_mouse_over == p_control) - gui.drag_mouse_over = NULL; + gui.drag_mouse_over = nullptr; if (gui.tooltip == p_control) - gui.tooltip = NULL; + gui.tooltip = nullptr; } void Viewport::_gui_remove_focus() { if (gui.key_focus) { Node *f = gui.key_focus; - gui.key_focus = NULL; + gui.key_focus = nullptr; f->notification(Control::NOTIFICATION_FOCUS_EXIT, true); } } @@ -2583,7 +2577,7 @@ void Viewport::_drop_mouse_focus() { Control *c = gui.mouse_focus; int mask = gui.mouse_focus_mask; - gui.mouse_focus = NULL; + gui.mouse_focus = nullptr; gui.forced_mouse_focus = false; gui.mouse_focus_mask = 0; @@ -2645,7 +2639,7 @@ void Viewport::_post_gui_grab_click_focus() { // Redundant grab requests were made return; } - gui.mouse_click_grabber = NULL; + gui.mouse_click_grabber = nullptr; if (gui.mouse_focus) { @@ -3063,7 +3057,7 @@ void Viewport::unhandled_input(const Ref<InputEvent> &p_event, bool p_local_coor get_tree()->_call_input_pause(unhandled_input_group, "_unhandled_input", ev, this); //call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"unhandled_input","_unhandled_input",ev); - if (!is_input_handled() && Object::cast_to<InputEventKey>(*ev) != NULL) { + if (!is_input_handled() && Object::cast_to<InputEventKey>(*ev) != nullptr) { get_tree()->_call_input_pause(unhandled_key_input_group, "_unhandled_key_input", ev, this); //call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"unhandled_key_input","_unhandled_key_input",ev); } @@ -3504,6 +3498,8 @@ void Viewport::_bind_methods() { BIND_ENUM_CONSTANT(DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS); BIND_ENUM_CONSTANT(DEBUG_DRAW_SCENE_LUMINANCE); BIND_ENUM_CONSTANT(DEBUG_DRAW_SSAO); + BIND_ENUM_CONSTANT(DEBUG_DRAW_ROUGHNESS_LIMITER); + BIND_ENUM_CONSTANT(DEBUG_DRAW_PSSM_SPLITS); BIND_ENUM_CONSTANT(MSAA_DISABLED); BIND_ENUM_CONSTANT(MSAA_2X); @@ -3539,11 +3535,11 @@ Viewport::Viewport() { //internal_listener_2d = SpatialSound2DServer::get_singleton()->listener_create(); audio_listener_2d = false; transparent_bg = false; - parent = NULL; - listener = NULL; - camera = NULL; + parent = nullptr; + listener = nullptr; + camera = nullptr; override_canvas_transform = false; - canvas_layers.insert(NULL); // This eases picking code (interpreted as the canvas of the Viewport) + canvas_layers.insert(nullptr); // This eases picking code (interpreted as the canvas of the Viewport) gen_mipmaps = false; @@ -3577,15 +3573,15 @@ Viewport::Viewport() { gui.tooltip_delay = GLOBAL_DEF("gui/timers/tooltip_delay_sec", 0.5); ProjectSettings::get_singleton()->set_custom_property_info("gui/timers/tooltip_delay_sec", PropertyInfo(Variant::FLOAT, "gui/timers/tooltip_delay_sec", PROPERTY_HINT_RANGE, "0,5,0.01,or_greater")); // No negative numbers - gui.tooltip = NULL; - gui.tooltip_label = NULL; - gui.drag_preview = NULL; + gui.tooltip = nullptr; + gui.tooltip_label = nullptr; + gui.drag_preview = nullptr; gui.drag_attempted = false; gui.canvas_sort_index = 0; gui.roots_order_dirty = false; - gui.mouse_focus = NULL; + gui.mouse_focus = nullptr; gui.forced_mouse_focus = false; - gui.last_mouse_focus = NULL; + gui.last_mouse_focus = nullptr; gui.subwindow_focused = nullptr; gui.subwindow_drag = SUB_WINDOW_DRAG_DISABLED; @@ -3612,30 +3608,53 @@ Viewport::~Viewport() { //erase itself from viewport textures for (Set<ViewportTexture *>::Element *E = viewport_textures.front(); E; E = E->next()) { - E->get()->vp = NULL; + E->get()->vp = nullptr; } RenderingServer::get_singleton()->free(viewport); } ///////////////////////////////// -void SubViewport::set_use_arvr(bool p_use_arvr) { - arvr = p_use_arvr; +void SubViewport::set_use_xr(bool p_use_xr) { + xr = p_use_xr; - RS::get_singleton()->viewport_set_use_arvr(get_viewport_rid(), arvr); + RS::get_singleton()->viewport_set_use_xr(get_viewport_rid(), xr); } -bool SubViewport::is_using_arvr() { - return arvr; +bool SubViewport::is_using_xr() { + return xr; } void SubViewport::set_size(const Size2i &p_size) { - _set_size(p_size, Size2i(), Rect2i(), Transform2D(), true); + _set_size(p_size, _get_size_2d_override(), Rect2i(), _stretch_transform(), true); } Size2i SubViewport::get_size() const { return _get_size(); } +void SubViewport::set_size_2d_override(const Size2i &p_size) { + + _set_size(_get_size(), p_size, Rect2i(), _stretch_transform(), true); +} +Size2i SubViewport::get_size_2d_override() const { + + return _get_size_2d_override(); +} + +void SubViewport::set_size_2d_override_stretch(bool p_enable) { + + if (p_enable == size_2d_override_stretch) { + return; + } + + size_2d_override_stretch = p_enable; + _set_size(_get_size(), _get_size_2d_override(), Rect2i(), _stretch_transform(), true); +} +bool SubViewport::is_size_2d_override_stretch_enabled() const { + + return size_2d_override_stretch; +} + void SubViewport::set_update_mode(UpdateMode p_mode) { update_mode = p_mode; @@ -3651,7 +3670,6 @@ void SubViewport::set_clear_mode(ClearMode p_mode) { clear_mode = p_mode; RS::get_singleton()->viewport_set_clear_mode(get_viewport_rid(), RS::ViewportClearMode(p_mode)); } - SubViewport::ClearMode SubViewport::get_clear_mode() const { return clear_mode; @@ -3661,6 +3679,18 @@ DisplayServer::WindowID SubViewport::get_window_id() const { return DisplayServer::INVALID_WINDOW_ID; } +Transform2D SubViewport::_stretch_transform() { + + Transform2D transform = Transform2D(); + Size2i view_size_2d_override = _get_size_2d_override(); + if (size_2d_override_stretch && view_size_2d_override.width > 0 && view_size_2d_override.height > 0) { + Size2 scale = _get_size() / view_size_2d_override; + transform.scale(scale); + } + + return transform; +} + void SubViewport::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { @@ -3672,19 +3702,28 @@ void SubViewport::_notification(int p_what) { } void SubViewport::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_use_arvr", "use"), &SubViewport::set_use_arvr); - ClassDB::bind_method(D_METHOD("is_using_arvr"), &SubViewport::is_using_arvr); + ClassDB::bind_method(D_METHOD("set_use_xr", "use"), &SubViewport::set_use_xr); + ClassDB::bind_method(D_METHOD("is_using_xr"), &SubViewport::is_using_xr); ClassDB::bind_method(D_METHOD("set_size", "size"), &SubViewport::set_size); ClassDB::bind_method(D_METHOD("get_size"), &SubViewport::get_size); + ClassDB::bind_method(D_METHOD("set_size_2d_override", "size"), &SubViewport::set_size_2d_override); + ClassDB::bind_method(D_METHOD("get_size_2d_override"), &SubViewport::get_size_2d_override); + + ClassDB::bind_method(D_METHOD("set_size_2d_override_stretch", "enable"), &SubViewport::set_size_2d_override_stretch); + ClassDB::bind_method(D_METHOD("is_size_2d_override_stretch_enabled"), &SubViewport::is_size_2d_override_stretch_enabled); + ClassDB::bind_method(D_METHOD("set_update_mode", "mode"), &SubViewport::set_update_mode); ClassDB::bind_method(D_METHOD("get_update_mode"), &SubViewport::get_update_mode); ClassDB::bind_method(D_METHOD("set_clear_mode", "mode"), &SubViewport::set_clear_mode); ClassDB::bind_method(D_METHOD("get_clear_mode"), &SubViewport::get_clear_mode); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "arvr"), "set_use_arvr", "is_using_arvr"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "xr"), "set_use_xr", "is_using_xr"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size_2d_override"), "set_size_2d_override", "get_size_2d_override"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "size_2d_override_stretch"), "set_size_2d_override_stretch", "is_size_2d_override_stretch_enabled"); ADD_GROUP("Render Target", "render_target_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "render_target_clear_mode", PROPERTY_HINT_ENUM, "Always,Never,Next Frame"), "set_clear_mode", "get_clear_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "render_target_update_mode", PROPERTY_HINT_ENUM, "Disabled,Once,When Visible,Always"), "set_update_mode", "get_update_mode"); @@ -3701,7 +3740,8 @@ void SubViewport::_bind_methods() { } SubViewport::SubViewport() { - arvr = false; + xr = false; + size_2d_override_stretch = false; update_mode = UPDATE_WHEN_VISIBLE; clear_mode = CLEAR_MODE_ALWAYS; } diff --git a/scene/main/viewport.h b/scene/main/viewport.h index d0b22b5553..ab3987d16d 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -133,7 +133,8 @@ public: DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS, DEBUG_DRAW_SCENE_LUMINANCE, DEBUG_DRAW_SSAO, - DEBUG_DRAW_ROUGHNESS_LIMITER + DEBUG_DRAW_ROUGHNESS_LIMITER, + DEBUG_DRAW_PSSM_SPLITS }; enum DefaultCanvasItemTextureFilter { @@ -203,7 +204,7 @@ private: Transform2D stretch_transform; Size2i size; - Size2i size_override; + Size2i size_2d_override; bool size_allocated; RID contact_2d_debug; @@ -374,7 +375,7 @@ private: void _gui_remove_root_control(List<Control *>::Element *RI); - String _gui_get_tooltip(Control *p_control, const Vector2 &p_pos, Control **r_which = NULL); + String _gui_get_tooltip(Control *p_control, const Vector2 &p_pos, Control **r_which = nullptr); void _gui_cancel_tooltip(); void _gui_show_tooltip(); @@ -434,9 +435,10 @@ private: SubWindowResize _sub_window_get_resize_margin(Window *p_subwindow, const Point2 &p_point); protected: - void _set_size(const Size2i &p_size, const Size2i &p_size_override, const Rect2i &p_to_screen_rect, const Transform2D &p_stretch_transform, bool p_allocated); + void _set_size(const Size2i &p_size, const Size2i &p_size_2d_override, const Rect2i &p_to_screen_rect, const Transform2D &p_stretch_transform, bool p_allocated); Size2i _get_size() const; + Size2i _get_size_2d_override() const; bool _is_size_allocated() const; void _notification(int p_what); @@ -588,19 +590,27 @@ public: private: UpdateMode update_mode; ClearMode clear_mode; - bool arvr; + bool xr; + bool size_2d_override_stretch; protected: static void _bind_methods(); virtual DisplayServer::WindowID get_window_id() const; + Transform2D _stretch_transform(); void _notification(int p_what); public: void set_size(const Size2i &p_size); Size2i get_size() const; - void set_use_arvr(bool p_use_arvr); - bool is_using_arvr(); + void set_size_2d_override(const Size2i &p_size); + Size2i get_size_2d_override() const; + + void set_use_xr(bool p_use_xr); + bool is_using_xr(); + + void set_size_2d_override_stretch(bool p_enable); + bool is_size_2d_override_stretch_enabled() const; void set_update_mode(UpdateMode p_mode); UpdateMode get_update_mode() const; diff --git a/scene/main/window.cpp b/scene/main/window.cpp index 3a8f7ebb60..19954299de 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -909,7 +909,7 @@ void Window::_window_input_text(const String &p_text) { input_text(p_text); } void Window::_window_drop_files(const Vector<String> &p_files) { - emit_signal("files_dropped", p_files); + emit_signal("files_dropped", p_files, current_screen); } Viewport *Window::get_parent_viewport() const { @@ -1108,13 +1108,13 @@ void Window::remove_child_notify(Node *p_child) { Control *child_c = Object::cast_to<Control>(p_child); if (child_c && (child_c->data.theme_owner || child_c->data.theme_owner_window) && child_c->data.theme.is_null()) { - Control::_propagate_theme_changed(child_c, NULL, NULL); + Control::_propagate_theme_changed(child_c, nullptr, nullptr); } Window *child_w = Object::cast_to<Window>(p_child); if (child_w && (child_w->theme_owner || child_w->theme_owner_window) && child_w->theme.is_null()) { - Control::_propagate_theme_changed(child_w, NULL, NULL); + Control::_propagate_theme_changed(child_w, nullptr, nullptr); } if (is_inside_tree() && wrap_controls) { @@ -1285,7 +1285,7 @@ void Window::_bind_methods() { ClassDB::bind_method(D_METHOD("set_exclusive", "exclusive"), &Window::set_exclusive); ClassDB::bind_method(D_METHOD("is_exclusive"), &Window::is_exclusive); - ClassDB::bind_method(D_METHOD("can_draw"), &Window::is_transient); + ClassDB::bind_method(D_METHOD("can_draw"), &Window::can_draw); ClassDB::bind_method(D_METHOD("has_focus"), &Window::has_focus); ClassDB::bind_method(D_METHOD("grab_focus"), &Window::grab_focus); diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 22c000fae7..035d26b3e4 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -110,6 +110,7 @@ #include "scene/gui/slider.h" #include "scene/gui/spin_box.h" #include "scene/gui/split_container.h" +#include "scene/gui/subviewport_container.h" #include "scene/gui/tab_container.h" #include "scene/gui/tabs.h" #include "scene/gui/text_edit.h" @@ -119,7 +120,6 @@ #include "scene/gui/tool_button.h" #include "scene/gui/tree.h" #include "scene/gui/video_player.h" -#include "scene/gui/viewport_container.h" #include "scene/main/canvas_item.h" #include "scene/main/canvas_layer.h" #include "scene/main/http_request.h" @@ -179,7 +179,6 @@ #ifndef _3D_DISABLED #include "scene/3d/area_3d.h" -#include "scene/3d/arvr_nodes.h" #include "scene/3d/audio_stream_player_3d.h" #include "scene/3d/baked_lightmap.h" #include "scene/3d/bone_attachment_3d.h" @@ -213,6 +212,7 @@ #include "scene/3d/vehicle_body_3d.h" #include "scene/3d/visibility_notifier_3d.h" #include "scene/3d/world_environment.h" +#include "scene/3d/xr_nodes.h" #include "scene/resources/environment.h" #include "scene/resources/mesh_library.h" #endif @@ -357,7 +357,7 @@ void register_scene_types() { ClassDB::register_class<ConfirmationDialog>(); ClassDB::register_class<MarginContainer>(); - ClassDB::register_class<ViewportContainer>(); + ClassDB::register_class<SubViewportContainer>(); ClassDB::register_virtual_class<SplitContainer>(); ClassDB::register_class<HSplitContainer>(); ClassDB::register_class<VSplitContainer>(); @@ -410,10 +410,10 @@ void register_scene_types() { ClassDB::register_class<Camera3D>(); ClassDB::register_class<ClippedCamera3D>(); ClassDB::register_class<Listener3D>(); - ClassDB::register_class<ARVRCamera>(); - ClassDB::register_class<ARVRController>(); - ClassDB::register_class<ARVRAnchor>(); - ClassDB::register_class<ARVROrigin>(); + ClassDB::register_class<XRCamera3D>(); + ClassDB::register_class<XRController3D>(); + ClassDB::register_class<XRAnchor3D>(); + ClassDB::register_class<XROrigin3D>(); ClassDB::register_class<MeshInstance3D>(); ClassDB::register_class<ImmediateGeometry3D>(); ClassDB::register_virtual_class<SpriteBase3D>(); @@ -842,6 +842,7 @@ void register_scene_types() { ClassDB::add_compatibility_class("StaticBody", "StaticBody3D"); ClassDB::add_compatibility_class("VehicleBody", "VehicleBody3D"); ClassDB::add_compatibility_class("VehicleWheel", "VehicleWheel3D"); + ClassDB::add_compatibility_class("ViewportContainer", "SubViewportContainer"); ClassDB::add_compatibility_class("VisibilityEnabler", "VisibilityEnabler3D"); ClassDB::add_compatibility_class("VisibilityNotifier", "VisibilityNotifier3D"); ClassDB::add_compatibility_class("VisualServer", "RenderingServer"); @@ -850,6 +851,13 @@ void register_scene_types() { ClassDB::add_compatibility_class("VisualShaderNodeScalarOp", "VisualShaderNodeFloatOp"); ClassDB::add_compatibility_class("VisualShaderNodeScalarUniform", "VisualShaderNodeFloatUniform"); ClassDB::add_compatibility_class("World", "World3D"); + ClassDB::add_compatibility_class("ProceduralSky", "Sky"); + ClassDB::add_compatibility_class("PanoramaSky", "Sky"); + ClassDB::add_compatibility_class("ARVRCamera", "XRCamera3D"); + ClassDB::add_compatibility_class("ARVROrigin", "XROrigin3D"); + ClassDB::add_compatibility_class("ARVRController", "XRController3D"); + ClassDB::add_compatibility_class("ARVRAnchor", "XRAnchor3D"); + #endif OS::get_singleton()->yield(); //may take time to init diff --git a/scene/resources/animation.h b/scene/resources/animation.h index 36d5df52df..e4e5177a8c 100644 --- a/scene/resources/animation.h +++ b/scene/resources/animation.h @@ -84,7 +84,10 @@ private: float transition; float time; // time in secs - Key() { transition = 1; } + Key() { + transition = 1; + time = 0; + } }; // transform key holds either Vector3 or Quaternion diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp index 06b65e4b4a..d630a1f3ee 100644 --- a/scene/resources/audio_stream_sample.cpp +++ b/scene/resources/audio_stream_sample.cpp @@ -482,7 +482,7 @@ void AudioStreamSample::set_data(const Vector<uint8_t> &p_data) { AudioServer::get_singleton()->lock(); if (data) { memfree(data); - data = NULL; + data = nullptr; data_bytes = 0; } @@ -654,14 +654,14 @@ AudioStreamSample::AudioStreamSample() { loop_begin = 0; loop_end = 0; mix_rate = 44100; - data = NULL; + data = nullptr; data_bytes = 0; } AudioStreamSample::~AudioStreamSample() { if (data) { memfree(data); - data = NULL; + data = nullptr; data_bytes = 0; } } diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 0c45779307..e6f09eb034 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -890,9 +890,9 @@ void make_default_theme(bool p_hidpi, Ref<Font> p_font) { void clear_default_theme() { - Theme::set_project_default(NULL); - Theme::set_default(NULL); - Theme::set_default_icon(NULL); - Theme::set_default_style(NULL); - Theme::set_default_font(NULL); + Theme::set_project_default(nullptr); + Theme::set_default(nullptr); + Theme::set_default_icon(nullptr); + Theme::set_default_style(nullptr); + Theme::set_default_font(nullptr); } diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index 107f07ec7d..a613b01376 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -107,7 +107,7 @@ DynamicFontData::DynamicFontData() { antialiased = true; force_autohinter = false; hinting = DynamicFontData::HINTING_NORMAL; - font_mem = NULL; + font_mem = nullptr; font_mem_size = 0; } @@ -124,7 +124,7 @@ Error DynamicFontAtSize::_load() { ERR_FAIL_COND_V_MSG(error != 0, ERR_CANT_CREATE, "Error initializing FreeType."); // FT_OPEN_STREAM is extremely slow only on Android. - if (OS::get_singleton()->get_name() == "Android" && font->font_mem == NULL && font->font_path != String()) { + if (OS::get_singleton()->get_name() == "Android" && font->font_mem == nullptr && font->font_path != String()) { // cache font only once for each font->font_path if (_fontdata.has(font->font_path)) { @@ -148,7 +148,7 @@ Error DynamicFontAtSize::_load() { } } - if (font->font_mem == NULL && font->font_path != String()) { + if (font->font_mem == nullptr && font->font_path != String()) { FileAccess *f = FileAccess::open(font->font_path, FileAccess::READ); if (!f) { @@ -157,7 +157,7 @@ Error DynamicFontAtSize::_load() { } memset(&stream, 0, sizeof(FT_StreamRec)); - stream.base = NULL; + stream.base = nullptr; stream.size = f->get_len(); stream.pos = 0; stream.descriptor.pointer = f; @@ -245,7 +245,7 @@ float DynamicFontAtSize::get_descent() const { const Pair<const DynamicFontAtSize::Character *, DynamicFontAtSize *> DynamicFontAtSize::_find_char_with_font(CharType p_char, const Vector<Ref<DynamicFontAtSize>> &p_fallbacks) const { const Character *chr = char_map.getptr(p_char); - ERR_FAIL_COND_V(!chr, (Pair<const Character *, DynamicFontAtSize *>(NULL, NULL))); + ERR_FAIL_COND_V(!chr, (Pair<const Character *, DynamicFontAtSize *>(nullptr, nullptr))); if (!chr->found) { @@ -269,7 +269,7 @@ const Pair<const DynamicFontAtSize::Character *, DynamicFontAtSize *> DynamicFon //not found, try 0xFFFD to display 'not found'. const_cast<DynamicFontAtSize *>(this)->_update_char(0xFFFD); chr = char_map.getptr(0xFFFD); - ERR_FAIL_COND_V(!chr, (Pair<const Character *, DynamicFontAtSize *>(NULL, NULL))); + ERR_FAIL_COND_V(!chr, (Pair<const Character *, DynamicFontAtSize *>(nullptr, nullptr))); } return Pair<const Character *, DynamicFontAtSize *>(chr, const_cast<DynamicFontAtSize *>(this)); @@ -565,7 +565,7 @@ DynamicFontAtSize::Character DynamicFontAtSize::_make_outline_char(CharType p_ch goto cleanup_stroker; if (FT_Glyph_Stroke(&glyph, stroker, 1) != 0) goto cleanup_glyph; - if (FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 1) != 0) + if (FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, nullptr, 1) != 0) goto cleanup_glyph; glyph_bitmap = (FT_BitmapGlyph)glyph; @@ -992,11 +992,12 @@ void DynamicFont::_bind_methods() { Mutex DynamicFont::dynamic_font_mutex; -SelfList<DynamicFont>::List *DynamicFont::dynamic_fonts = NULL; +SelfList<DynamicFont>::List *DynamicFont::dynamic_fonts = nullptr; DynamicFont::DynamicFont() : font_list(this) { + valid = false; cache_id.size = 16; outline_cache_id.size = 16; spacing_top = 0; @@ -1020,7 +1021,7 @@ void DynamicFont::initialize_dynamic_fonts() { void DynamicFont::finish_dynamic_fonts() { memdelete(dynamic_fonts); - dynamic_fonts = NULL; + dynamic_fonts = nullptr; } void DynamicFont::update_oversampling() { diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h index 88b1df039e..9e628fc35a 100644 --- a/scene/resources/dynamic_font.h +++ b/scene/resources/dynamic_font.h @@ -302,7 +302,7 @@ VARIANT_ENUM_CAST(DynamicFont::SpacingType); class ResourceFormatLoaderDynamicFont : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index 6fa52e6f05..835fef81e1 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -345,7 +345,7 @@ void Environment::_validate_property(PropertyInfo &property) const { "ssao_", "glow_", "adjustment_", - NULL + nullptr }; @@ -354,7 +354,7 @@ void Environment::_validate_property(PropertyInfo &property) const { "tonemap_", "ss_reflections_", "ssao_", - NULL + nullptr }; @@ -389,7 +389,7 @@ void Environment::_validate_property(PropertyInfo &property) const { void Environment::set_ssr_enabled(bool p_enable) { ssr_enabled = p_enable; - RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness); + RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance); _change_notify(); } @@ -401,7 +401,7 @@ bool Environment::is_ssr_enabled() const { void Environment::set_ssr_max_steps(int p_steps) { ssr_max_steps = p_steps; - RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness); + RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance); } int Environment::get_ssr_max_steps() const { @@ -411,7 +411,7 @@ int Environment::get_ssr_max_steps() const { void Environment::set_ssr_fade_in(float p_fade_in) { ssr_fade_in = p_fade_in; - RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness); + RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance); } float Environment::get_ssr_fade_in() const { @@ -421,7 +421,7 @@ float Environment::get_ssr_fade_in() const { void Environment::set_ssr_fade_out(float p_fade_out) { ssr_fade_out = p_fade_out; - RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness); + RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance); } float Environment::get_ssr_fade_out() const { @@ -431,23 +431,13 @@ float Environment::get_ssr_fade_out() const { void Environment::set_ssr_depth_tolerance(float p_depth_tolerance) { ssr_depth_tolerance = p_depth_tolerance; - RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness); + RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance); } float Environment::get_ssr_depth_tolerance() const { return ssr_depth_tolerance; } -void Environment::set_ssr_rough(bool p_enable) { - - ssr_roughness = p_enable; - RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness); -} -bool Environment::is_ssr_rough() const { - - return ssr_roughness; -} - void Environment::set_ssao_enabled(bool p_enable) { ssao_enabled = p_enable; @@ -981,16 +971,12 @@ void Environment::_bind_methods() { ClassDB::bind_method(D_METHOD("set_ssr_depth_tolerance", "depth_tolerance"), &Environment::set_ssr_depth_tolerance); ClassDB::bind_method(D_METHOD("get_ssr_depth_tolerance"), &Environment::get_ssr_depth_tolerance); - ClassDB::bind_method(D_METHOD("set_ssr_rough", "rough"), &Environment::set_ssr_rough); - ClassDB::bind_method(D_METHOD("is_ssr_rough"), &Environment::is_ssr_rough); - ADD_GROUP("SS Reflections", "ss_reflections_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ss_reflections_enabled"), "set_ssr_enabled", "is_ssr_enabled"); ADD_PROPERTY(PropertyInfo(Variant::INT, "ss_reflections_max_steps", PROPERTY_HINT_RANGE, "1,512,1"), "set_ssr_max_steps", "get_ssr_max_steps"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ss_reflections_fade_in", PROPERTY_HINT_EXP_EASING), "set_ssr_fade_in", "get_ssr_fade_in"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ss_reflections_fade_out", PROPERTY_HINT_EXP_EASING), "set_ssr_fade_out", "get_ssr_fade_out"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ss_reflections_depth_tolerance", PROPERTY_HINT_RANGE, "0.1,128,0.1"), "set_ssr_depth_tolerance", "get_ssr_depth_tolerance"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ss_reflections_roughness"), "set_ssr_rough", "is_ssr_rough"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ss_reflections_depth_tolerance", PROPERTY_HINT_RANGE, "0.01,128,0.1"), "set_ssr_depth_tolerance", "get_ssr_depth_tolerance"); ClassDB::bind_method(D_METHOD("set_ssao_enabled", "enabled"), &Environment::set_ssao_enabled); ClassDB::bind_method(D_METHOD("is_ssao_enabled"), &Environment::is_ssao_enabled); @@ -1173,7 +1159,6 @@ Environment::Environment() : ssr_fade_in = 0.15; ssr_fade_out = 2.0; ssr_depth_tolerance = 0.2; - ssr_roughness = true; ssao_enabled = false; ssao_radius = 1; diff --git a/scene/resources/environment.h b/scene/resources/environment.h index 83f9a3f509..02434bc592 100644 --- a/scene/resources/environment.h +++ b/scene/resources/environment.h @@ -125,7 +125,6 @@ private: float ssr_fade_in; float ssr_fade_out; float ssr_depth_tolerance; - bool ssr_roughness; bool ssao_enabled; float ssao_radius; @@ -257,9 +256,6 @@ public: void set_ssr_depth_tolerance(float p_depth_tolerance); float get_ssr_depth_tolerance() const; - void set_ssr_rough(bool p_enable); - bool is_ssr_rough() const; - void set_ssao_enabled(bool p_enable); bool is_ssao_enabled() const; diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 8914cf8097..192eefbf6a 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -128,7 +128,7 @@ Vector<int> BitmapFont::_get_chars() const { Vector<int> chars; - const CharType *key = NULL; + const CharType *key = nullptr; while ((key = char_map.next(key))) { @@ -382,7 +382,7 @@ Vector<CharType> BitmapFont::get_char_keys() const { Vector<CharType> chars; chars.resize(char_map.size()); - const CharType *ct = NULL; + const CharType *ct = nullptr; int count = 0; while ((ct = char_map.next(ct))) { @@ -528,7 +528,7 @@ Size2 Font::get_wordwrap_string_size(const String &p_string, float p_width) cons void BitmapFont::set_fallback(const Ref<BitmapFont> &p_fallback) { - for (Ref<BitmapFont> fallback_child = p_fallback; fallback_child != NULL; fallback_child = fallback_child->get_fallback()) { + for (Ref<BitmapFont> fallback_child = p_fallback; fallback_child != nullptr; fallback_child = fallback_child->get_fallback()) { ERR_FAIL_COND_MSG(fallback_child == this, "Can't set as fallback one of its parents to prevent crashes due to recursive loop."); } diff --git a/scene/resources/font.h b/scene/resources/font.h index 076532f390..ce75f27e2a 100644 --- a/scene/resources/font.h +++ b/scene/resources/font.h @@ -200,7 +200,7 @@ public: class ResourceFormatLoaderBMFont : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index f52b755ed3..fd8cff7cd0 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -40,7 +40,7 @@ void Material::set_next_pass(const Ref<Material> &p_pass) { - for (Ref<Material> pass_child = p_pass; pass_child != NULL; pass_child = pass_child->get_next_pass()) { + for (Ref<Material> pass_child = p_pass; pass_child != nullptr; pass_child = pass_child->get_next_pass()) { ERR_FAIL_COND_MSG(pass_child == this, "Can't set as next_pass one of its parents to prevent crashes due to recursive loop."); } @@ -290,9 +290,9 @@ ShaderMaterial::~ShaderMaterial() { ///////////////////////////////// Mutex BaseMaterial3D::material_mutex; -SelfList<BaseMaterial3D>::List *BaseMaterial3D::dirty_materials = NULL; +SelfList<BaseMaterial3D>::List *BaseMaterial3D::dirty_materials = nullptr; Map<BaseMaterial3D::MaterialKey, BaseMaterial3D::ShaderData> BaseMaterial3D::shader_map; -BaseMaterial3D::ShaderNames *BaseMaterial3D::shader_names = NULL; +BaseMaterial3D::ShaderNames *BaseMaterial3D::shader_names = nullptr; void BaseMaterial3D::init_shaders() { @@ -314,7 +314,7 @@ void BaseMaterial3D::init_shaders() { shader_names->anisotropy = "anisotropy_ratio"; shader_names->heightmap_scale = "heightmap_scale"; shader_names->subsurface_scattering_strength = "subsurface_scattering_strength"; - shader_names->transmission = "transmission"; + shader_names->backlight = "backlight"; shader_names->refraction = "refraction"; shader_names->point_size = "point_size"; shader_names->uv1_scale = "uv1_scale"; @@ -347,6 +347,11 @@ void BaseMaterial3D::init_shaders() { shader_names->refraction_texture_channel = "refraction_texture_channel"; shader_names->alpha_scissor_threshold = "alpha_scissor_threshold"; + shader_names->transmittance_color = "transmittance_color"; + shader_names->transmittance_curve = "transmittance_curve"; + shader_names->transmittance_depth = "transmittance_depth"; + shader_names->transmittance_boost = "transmittance_boost"; + shader_names->texture_names[TEXTURE_ALBEDO] = "texture_albedo"; shader_names->texture_names[TEXTURE_METALLIC] = "texture_metallic"; shader_names->texture_names[TEXTURE_ROUGHNESS] = "texture_roughness"; @@ -358,7 +363,8 @@ void BaseMaterial3D::init_shaders() { shader_names->texture_names[TEXTURE_AMBIENT_OCCLUSION] = "texture_ambient_occlusion"; shader_names->texture_names[TEXTURE_HEIGHTMAP] = "texture_heightmap"; shader_names->texture_names[TEXTURE_SUBSURFACE_SCATTERING] = "texture_subsurface_scattering"; - shader_names->texture_names[TEXTURE_TRANSMISSION] = "texture_transmission"; + shader_names->texture_names[TEXTURE_SUBSURFACE_TRANSMITTANCE] = "texture_subsurface_transmittance"; + shader_names->texture_names[TEXTURE_BACKLIGHT] = "texture_backlight"; shader_names->texture_names[TEXTURE_REFRACTION] = "texture_refraction"; shader_names->texture_names[TEXTURE_DETAIL_MASK] = "texture_detail_mask"; shader_names->texture_names[TEXTURE_DETAIL_ALBEDO] = "texture_detail_albedo"; @@ -375,7 +381,7 @@ void BaseMaterial3D::finish_shaders() { } memdelete(dirty_materials); - dirty_materials = NULL; + dirty_materials = nullptr; memdelete(shader_names); } @@ -385,7 +391,7 @@ void BaseMaterial3D::_update_shader() { dirty_materials->remove(&element); MaterialKey mk = _compute_key(); - if (mk.key == current_key.key) + if (mk == current_key) return; //no update required in the end if (shader_map.has(current_key)) { @@ -467,6 +473,9 @@ void BaseMaterial3D::_update_shader() { case SPECULAR_TOON: code += ",specular_toon"; break; case SPECULAR_DISABLED: code += ",specular_disabled"; break; } + if (features[FEATURE_SUBSURFACE_SCATTERING] && flags[FLAG_SUBSURFACE_MODE_SKIN]) { + code += ",sss_mode_skin"; + } if (shading_mode == SHADING_MODE_UNSHADED) { code += ",unshaded"; @@ -586,16 +595,25 @@ void BaseMaterial3D::_update_shader() { code += "uniform sampler2D texture_detail_mask : hint_white," + texfilter_str + ";\n"; } - if (features[FEATURE_SUBSURACE_SCATTERING]) { + if (features[FEATURE_SUBSURFACE_SCATTERING]) { code += "uniform float subsurface_scattering_strength : hint_range(0,1);\n"; code += "uniform sampler2D texture_subsurface_scattering : hint_white," + texfilter_str + ";\n"; } - if (features[FEATURE_TRANSMISSION]) { + if (features[FEATURE_SUBSURFACE_TRANSMITTANCE]) { + + code += "uniform vec4 transmittance_color : hint_color;\n"; + code += "uniform float transmittance_depth;\n"; + code += "uniform sampler2D texture_subsurface_transmittance : hint_white," + texfilter_str + ";\n"; + code += "uniform float transmittance_curve;\n"; + code += "uniform float transmittance_boost;\n"; + } + + if (features[FEATURE_BACKLIGHT]) { - code += "uniform vec4 transmission : hint_color;\n"; - code += "uniform sampler2D texture_transmission : hint_black," + texfilter_str + ";\n"; + code += "uniform vec4 backlight : hint_color;\n"; + code += "uniform sampler2D texture_backlight : hint_black," + texfilter_str + ";\n"; } if (features[FEATURE_HEIGHT_MAPPING]) { @@ -1048,7 +1066,7 @@ void BaseMaterial3D::_update_shader() { code += "\tAO_LIGHT_AFFECT = ao_light_affect;\n"; } - if (features[FEATURE_SUBSURACE_SCATTERING]) { + if (features[FEATURE_SUBSURFACE_SCATTERING]) { if (flags[FLAG_UV1_USE_TRIPLANAR]) { code += "\tfloat sss_tex = triplanar_texture(texture_subsurface_scattering,uv1_power_normal,uv1_triplanar_pos).r;\n"; @@ -1058,13 +1076,27 @@ void BaseMaterial3D::_update_shader() { code += "\tSSS_STRENGTH=subsurface_scattering_strength*sss_tex;\n"; } - if (features[FEATURE_TRANSMISSION]) { + if (features[FEATURE_SUBSURFACE_TRANSMITTANCE]) { + + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "\tvec4 trans_color_tex = triplanar_texture(texture_subsurface_transmittance,uv1_power_normal,uv1_triplanar_pos);\n"; + } else { + code += "\tvec4 trans_color_tex = texture(texture_subsurface_transmittance,base_uv);\n"; + } + code += "\tSSS_TRANSMITTANCE_COLOR=transmittance_color*trans_color_tex;\n"; + + code += "\tSSS_TRANSMITTANCE_DEPTH=transmittance_depth;\n"; + code += "\tSSS_TRANSMITTANCE_CURVE=transmittance_curve;\n"; + code += "\tSSS_TRANSMITTANCE_BOOST=transmittance_boost;\n"; + } + + if (features[FEATURE_BACKLIGHT]) { if (flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tvec3 transmission_tex = triplanar_texture(texture_transmission,uv1_power_normal,uv1_triplanar_pos).rgb;\n"; + code += "\tvec3 backlight_tex = triplanar_texture(texture_backlight,uv1_power_normal,uv1_triplanar_pos).rgb;\n"; } else { - code += "\tvec3 transmission_tex = texture(texture_transmission,base_uv).rgb;\n"; + code += "\tvec3 backlight_tex = texture(texture_backlight,base_uv).rgb;\n"; } - code += "\tTRANSMISSION = (transmission.rgb+transmission_tex);\n"; + code += "\tBACKLIGHT = (backlight.rgb+backlight_tex);\n"; } if (features[FEATURE_DETAIL]) { @@ -1306,15 +1338,48 @@ float BaseMaterial3D::get_subsurface_scattering_strength() const { return subsurface_scattering_strength; } -void BaseMaterial3D::set_transmission(const Color &p_transmission) { +void BaseMaterial3D::set_transmittance_color(const Color &p_color) { + transmittance_color = p_color; + RS::get_singleton()->material_set_param(_get_material(), shader_names->transmittance_color, p_color); +} + +Color BaseMaterial3D::get_transmittance_color() const { + return transmittance_color; +} + +void BaseMaterial3D::set_transmittance_depth(float p_depth) { + transmittance_depth = p_depth; + RS::get_singleton()->material_set_param(_get_material(), shader_names->transmittance_depth, p_depth); +} +float BaseMaterial3D::get_transmittance_depth() const { + return transmittance_depth; +} + +void BaseMaterial3D::set_transmittance_curve(float p_curve) { + transmittance_curve = p_curve; + RS::get_singleton()->material_set_param(_get_material(), shader_names->transmittance_curve, p_curve); +} +float BaseMaterial3D::get_transmittance_curve() const { + return transmittance_curve; +} - transmission = p_transmission; - RS::get_singleton()->material_set_param(_get_material(), shader_names->transmission, transmission); +void BaseMaterial3D::set_transmittance_boost(float p_boost) { + transmittance_boost = p_boost; + RS::get_singleton()->material_set_param(_get_material(), shader_names->transmittance_boost, p_boost); +} +float BaseMaterial3D::get_transmittance_boost() const { + return transmittance_boost; } -Color BaseMaterial3D::get_transmission() const { +void BaseMaterial3D::set_backlight(const Color &p_backlight) { - return transmission; + backlight = p_backlight; + RS::get_singleton()->material_set_param(_get_material(), shader_names->backlight, backlight); +} + +Color BaseMaterial3D::get_backlight() const { + + return backlight; } void BaseMaterial3D::set_refraction(float p_refraction) { @@ -1454,7 +1519,7 @@ void BaseMaterial3D::set_flag(Flags p_flag, bool p_enabled) { return; flags[p_flag] = p_enabled; - if ((p_flag == FLAG_USE_SHADOW_TO_OPACITY) || (p_flag == FLAG_USE_TEXTURE_REPEAT)) { + if (p_flag == FLAG_USE_SHADOW_TO_OPACITY || p_flag == FLAG_USE_TEXTURE_REPEAT || p_flag == FLAG_SUBSURFACE_MODE_SKIN) { _change_notify(); } _queue_shader_change(); @@ -1537,8 +1602,8 @@ void BaseMaterial3D::_validate_property(PropertyInfo &property) const { _validate_feature("anisotropy", FEATURE_ANISOTROPY, property); _validate_feature("ao", FEATURE_AMBIENT_OCCLUSION, property); _validate_feature("heightmap", FEATURE_HEIGHT_MAPPING, property); - _validate_feature("subsurf_scatter", FEATURE_SUBSURACE_SCATTERING, property); - _validate_feature("transmission", FEATURE_TRANSMISSION, property); + _validate_feature("subsurf_scatter", FEATURE_SUBSURFACE_SCATTERING, property); + _validate_feature("backlight", FEATURE_BACKLIGHT, property); _validate_feature("refraction", FEATURE_REFRACTION, property); _validate_feature("detail", FEATURE_DETAIL, property); @@ -1572,6 +1637,10 @@ void BaseMaterial3D::_validate_property(PropertyInfo &property) const { property.usage = 0; } + if (flags[FLAG_SUBSURFACE_MODE_SKIN] && (property.name == "subsurf_scatter_transmittance_color" || property.name == "subsurf_scatter_transmittance_texture" || property.name == "subsurf_scatter_transmittance_curve")) { + property.usage = 0; + } + if (orm) { if (property.name == "shading_mode") { @@ -1628,7 +1697,11 @@ void BaseMaterial3D::_validate_property(PropertyInfo &property) const { property.usage = 0; } - if (property.name.begins_with("transmission")) { + if (property.name.begins_with("backlight")) { + property.usage = 0; + } + + if (property.name.begins_with("transmittance")) { property.usage = 0; } } @@ -2067,8 +2140,20 @@ void BaseMaterial3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_subsurface_scattering_strength", "strength"), &BaseMaterial3D::set_subsurface_scattering_strength); ClassDB::bind_method(D_METHOD("get_subsurface_scattering_strength"), &BaseMaterial3D::get_subsurface_scattering_strength); - ClassDB::bind_method(D_METHOD("set_transmission", "transmission"), &BaseMaterial3D::set_transmission); - ClassDB::bind_method(D_METHOD("get_transmission"), &BaseMaterial3D::get_transmission); + ClassDB::bind_method(D_METHOD("set_transmittance_color", "color"), &BaseMaterial3D::set_transmittance_color); + ClassDB::bind_method(D_METHOD("get_transmittance_color"), &BaseMaterial3D::get_transmittance_color); + + ClassDB::bind_method(D_METHOD("set_transmittance_depth", "depth"), &BaseMaterial3D::set_transmittance_depth); + ClassDB::bind_method(D_METHOD("get_transmittance_depth"), &BaseMaterial3D::get_transmittance_depth); + + ClassDB::bind_method(D_METHOD("set_transmittance_curve", "curve"), &BaseMaterial3D::set_transmittance_curve); + ClassDB::bind_method(D_METHOD("get_transmittance_curve"), &BaseMaterial3D::get_transmittance_curve); + + ClassDB::bind_method(D_METHOD("set_transmittance_boost", "boost"), &BaseMaterial3D::set_transmittance_boost); + ClassDB::bind_method(D_METHOD("get_transmittance_boost"), &BaseMaterial3D::get_transmittance_boost); + + ClassDB::bind_method(D_METHOD("set_backlight", "backlight"), &BaseMaterial3D::set_backlight); + ClassDB::bind_method(D_METHOD("get_backlight"), &BaseMaterial3D::get_backlight); ClassDB::bind_method(D_METHOD("set_refraction", "refraction"), &BaseMaterial3D::set_refraction); ClassDB::bind_method(D_METHOD("get_refraction"), &BaseMaterial3D::get_refraction); @@ -2282,14 +2367,23 @@ void BaseMaterial3D::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "heightmap_flip_texture"), "set_flag", "get_flag", FLAG_INVERT_HEIGHTMAP); ADD_GROUP("Subsurf Scatter", "subsurf_scatter_"); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "subsurf_scatter_enabled"), "set_feature", "get_feature", FEATURE_SUBSURACE_SCATTERING); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "subsurf_scatter_enabled"), "set_feature", "get_feature", FEATURE_SUBSURFACE_SCATTERING); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "subsurf_scatter_strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_subsurface_scattering_strength", "get_subsurface_scattering_strength"); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "subsurf_scatter_skin_mode"), "set_flag", "get_flag", FLAG_SUBSURFACE_MODE_SKIN); ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "subsurf_scatter_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_SUBSURFACE_SCATTERING); - ADD_GROUP("Transmission", "transmission_"); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "transmission_enabled"), "set_feature", "get_feature", FEATURE_TRANSMISSION); - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "transmission", PROPERTY_HINT_COLOR_NO_ALPHA), "set_transmission", "get_transmission"); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "transmission_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_TRANSMISSION); + ADD_SUBGROUP("Transmittance", "subsurf_scatter_transmittance_"); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "subsurf_scatter_transmittance_enabled"), "set_feature", "get_feature", FEATURE_SUBSURFACE_TRANSMITTANCE); + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "subsurf_scatter_transmittance_color"), "set_transmittance_color", "get_transmittance_color"); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "subsurf_scatter_transmittance_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_SUBSURFACE_TRANSMITTANCE); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "subsurf_scatter_transmittance_depth", PROPERTY_HINT_RANGE, "0.001,8,0.001,or_greater"), "set_transmittance_depth", "get_transmittance_depth"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "subsurf_scatter_transmittance_curve", PROPERTY_HINT_EXP_EASING, "0.01,16,0.01"), "set_transmittance_curve", "get_transmittance_curve"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "subsurf_scatter_transmittance_boost", PROPERTY_HINT_RANGE, "0.00,1.0,0.01"), "set_transmittance_boost", "get_transmittance_boost"); + + ADD_GROUP("Back Lighting", "backlight_"); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "backlight_enabled"), "set_feature", "get_feature", FEATURE_BACKLIGHT); + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "backlight", PROPERTY_HINT_COLOR_NO_ALPHA), "set_backlight", "get_backlight"); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "backlight_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_BACKLIGHT); ADD_GROUP("Refraction", "refraction_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "refraction_enabled"), "set_feature", "get_feature", FEATURE_REFRACTION); @@ -2362,7 +2456,8 @@ void BaseMaterial3D::_bind_methods() { BIND_ENUM_CONSTANT(TEXTURE_AMBIENT_OCCLUSION); BIND_ENUM_CONSTANT(TEXTURE_HEIGHTMAP); BIND_ENUM_CONSTANT(TEXTURE_SUBSURFACE_SCATTERING); - BIND_ENUM_CONSTANT(TEXTURE_TRANSMISSION); + BIND_ENUM_CONSTANT(TEXTURE_SUBSURFACE_TRANSMITTANCE); + BIND_ENUM_CONSTANT(TEXTURE_BACKLIGHT); BIND_ENUM_CONSTANT(TEXTURE_REFRACTION); BIND_ENUM_CONSTANT(TEXTURE_DETAIL_MASK); BIND_ENUM_CONSTANT(TEXTURE_DETAIL_ALBEDO); @@ -2399,8 +2494,9 @@ void BaseMaterial3D::_bind_methods() { BIND_ENUM_CONSTANT(FEATURE_ANISOTROPY); BIND_ENUM_CONSTANT(FEATURE_AMBIENT_OCCLUSION); BIND_ENUM_CONSTANT(FEATURE_HEIGHT_MAPPING); - BIND_ENUM_CONSTANT(FEATURE_SUBSURACE_SCATTERING); - BIND_ENUM_CONSTANT(FEATURE_TRANSMISSION); + BIND_ENUM_CONSTANT(FEATURE_SUBSURFACE_SCATTERING); + BIND_ENUM_CONSTANT(FEATURE_SUBSURFACE_TRANSMITTANCE); + BIND_ENUM_CONSTANT(FEATURE_BACKLIGHT); BIND_ENUM_CONSTANT(FEATURE_REFRACTION); BIND_ENUM_CONSTANT(FEATURE_DETAIL); BIND_ENUM_CONSTANT(FEATURE_MAX); @@ -2436,6 +2532,7 @@ void BaseMaterial3D::_bind_methods() { BIND_ENUM_CONSTANT(FLAG_USE_SHADOW_TO_OPACITY); BIND_ENUM_CONSTANT(FLAG_USE_TEXTURE_REPEAT); BIND_ENUM_CONSTANT(FLAG_INVERT_HEIGHTMAP); + BIND_ENUM_CONSTANT(FLAG_SUBSURFACE_MODE_SKIN); BIND_ENUM_CONSTANT(FLAG_MAX); BIND_ENUM_CONSTANT(DIFFUSE_BURLEY); @@ -2491,7 +2588,11 @@ BaseMaterial3D::BaseMaterial3D(bool p_orm) : set_anisotropy(0); set_heightmap_scale(0.05); set_subsurface_scattering_strength(0); - set_transmission(Color(0, 0, 0)); + set_backlight(Color(0, 0, 0)); + set_transmittance_color(Color(1, 1, 1, 1)); + set_transmittance_depth(0.1); + set_transmittance_curve(1.0); + set_transmittance_boost(0.0); set_refraction(0.05); set_point_size(1); set_uv1_offset(Vector3(0, 0, 0)); @@ -2547,7 +2648,8 @@ BaseMaterial3D::BaseMaterial3D(bool p_orm) : features[i] = false; } - current_key.key = 0; + current_key.key0 = 0; + current_key.key1 = 0; current_key.invalid_key = 1; texture_filter = TEXTURE_FILTER_LINEAR_WITH_MIPMAPS; _queue_shader_change(); @@ -2641,7 +2743,7 @@ bool StandardMaterial3D::_set(const StringName &p_name, const Variant &p_value) { "depth_flip_binormal", "heightmap_flip_binormal" }, { "depth_texture", "heightmap_texture" }, - { NULL, NULL }, + { nullptr, nullptr }, }; int idx = 0; diff --git a/scene/resources/material.h b/scene/resources/material.h index 0c9352baf4..241357ba9b 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -125,7 +125,8 @@ public: TEXTURE_AMBIENT_OCCLUSION, TEXTURE_HEIGHTMAP, TEXTURE_SUBSURFACE_SCATTERING, - TEXTURE_TRANSMISSION, + TEXTURE_SUBSURFACE_TRANSMITTANCE, + TEXTURE_BACKLIGHT, TEXTURE_REFRACTION, TEXTURE_DETAIL_MASK, TEXTURE_DETAIL_ALBEDO, @@ -173,8 +174,9 @@ public: FEATURE_ANISOTROPY, FEATURE_AMBIENT_OCCLUSION, FEATURE_HEIGHT_MAPPING, - FEATURE_SUBSURACE_SCATTERING, - FEATURE_TRANSMISSION, + FEATURE_SUBSURFACE_SCATTERING, + FEATURE_SUBSURFACE_TRANSMITTANCE, + FEATURE_BACKLIGHT, FEATURE_REFRACTION, FEATURE_DETAIL, FEATURE_MAX @@ -218,6 +220,7 @@ public: FLAG_USE_SHADOW_TO_OPACITY, FLAG_USE_TEXTURE_REPEAT, FLAG_INVERT_HEIGHTMAP, + FLAG_SUBSURFACE_MODE_SKIN, FLAG_MAX }; @@ -290,10 +293,16 @@ private: uint64_t roughness_channel : 3; }; - uint64_t key; + struct { + uint64_t key0; + uint64_t key1; + }; + bool operator==(const MaterialKey &p_key) const { + return (key0 == p_key.key0) && (key1 == p_key.key1); + } bool operator<(const MaterialKey &p_key) const { - return key < p_key.key; + return (key0 == p_key.key0) ? (key1 < p_key.key1) : (key0 < p_key.key0); } }; @@ -309,7 +318,8 @@ private: _FORCE_INLINE_ MaterialKey _compute_key() const { MaterialKey mk; - mk.key = 0; + mk.key0 = 0; + mk.key1 = 0; for (int i = 0; i < FEATURE_MAX; i++) { if (features[i]) { mk.feature_mask |= ((uint64_t)1 << i); @@ -356,7 +366,11 @@ private: StringName anisotropy; StringName heightmap_scale; StringName subsurface_scattering_strength; - StringName transmission; + StringName transmittance_color; + StringName transmittance_curve; + StringName transmittance_depth; + StringName transmittance_boost; + StringName backlight; StringName refraction; StringName point_size; StringName uv1_scale; @@ -414,7 +428,13 @@ private: float anisotropy; float heightmap_scale; float subsurface_scattering_strength; - Color transmission; + float transmittance_amount; + Color transmittance_color; + float transmittance_depth; + float transmittance_curve; + float transmittance_boost; + + Color backlight; float refraction; float point_size; float alpha_scissor_threshold; @@ -545,8 +565,20 @@ public: void set_subsurface_scattering_strength(float p_subsurface_scattering_strength); float get_subsurface_scattering_strength() const; - void set_transmission(const Color &p_transmission); - Color get_transmission() const; + void set_transmittance_color(const Color &p_color); + Color get_transmittance_color() const; + + void set_transmittance_depth(float p_depth); + float get_transmittance_depth() const; + + void set_transmittance_curve(float p_curve); + float get_transmittance_curve() const; + + void set_transmittance_boost(float p_boost); + float get_transmittance_boost() const; + + void set_backlight(const Color &p_backlight); + Color get_backlight() const; void set_refraction(float p_refraction); float get_refraction() const; diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index b37b7f9751..6bb5be15f3 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -37,7 +37,7 @@ #include <stdlib.h> -Mesh::ConvexDecompositionFunc Mesh::convex_composition_function = NULL; +Mesh::ConvexDecompositionFunc Mesh::convex_composition_function = nullptr; Ref<TriangleMesh> Mesh::generate_triangle_mesh() const { @@ -372,7 +372,7 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const { ERR_FAIL_COND_V(arrays.size() != ARRAY_MAX, Ref<ArrayMesh>()); { - int *ir = NULL; + int *ir = nullptr; Vector<int> indices = arrays[ARRAY_INDEX]; bool has_indices = false; Vector<Vector3> vertices = arrays[ARRAY_VERTEX]; @@ -1359,7 +1359,7 @@ void ArrayMesh::regen_normalmaps() { } //dirty hack -bool (*array_mesh_lightmap_unwrap_callback)(float p_texel_size, const float *p_vertices, const float *p_normals, int p_vertex_count, const int *p_indices, const int *p_face_materials, int p_index_count, float **r_uv, int **r_vertex, int *r_vertex_count, int **r_index, int *r_index_count, int *r_size_hint_x, int *r_size_hint_y) = NULL; +bool (*array_mesh_lightmap_unwrap_callback)(float p_texel_size, const float *p_vertices, const float *p_normals, int p_vertex_count, const int *p_indices, const int *p_face_materials, int p_index_count, float **r_uv, int **r_vertex, int *r_vertex_count, int **r_index, int *r_index_count, int *r_size_hint_x, int *r_size_hint_y) = nullptr; struct ArrayMeshLightmapSurface { diff --git a/scene/resources/mesh_data_tool.cpp b/scene/resources/mesh_data_tool.cpp index 8b7f8288b8..76d96786bc 100644 --- a/scene/resources/mesh_data_tool.cpp +++ b/scene/resources/mesh_data_tool.cpp @@ -58,30 +58,30 @@ Error MeshDataTool::create_from_surface(const Ref<ArrayMesh> &p_mesh, int p_surf const Vector3 *vr = varray.ptr(); - const Vector3 *nr = NULL; + const Vector3 *nr = nullptr; if (arrays[Mesh::ARRAY_NORMAL].get_type() != Variant::NIL) nr = arrays[Mesh::ARRAY_NORMAL].operator Vector<Vector3>().ptr(); - const real_t *ta = NULL; + const real_t *ta = nullptr; if (arrays[Mesh::ARRAY_TANGENT].get_type() != Variant::NIL) ta = arrays[Mesh::ARRAY_TANGENT].operator Vector<real_t>().ptr(); - const Vector2 *uv = NULL; + const Vector2 *uv = nullptr; if (arrays[Mesh::ARRAY_TEX_UV].get_type() != Variant::NIL) uv = arrays[Mesh::ARRAY_TEX_UV].operator Vector<Vector2>().ptr(); - const Vector2 *uv2 = NULL; + const Vector2 *uv2 = nullptr; if (arrays[Mesh::ARRAY_TEX_UV2].get_type() != Variant::NIL) uv2 = arrays[Mesh::ARRAY_TEX_UV2].operator Vector<Vector2>().ptr(); - const Color *col = NULL; + const Color *col = nullptr; if (arrays[Mesh::ARRAY_COLOR].get_type() != Variant::NIL) col = arrays[Mesh::ARRAY_COLOR].operator Vector<Color>().ptr(); - const int *bo = NULL; + const int *bo = nullptr; if (arrays[Mesh::ARRAY_BONES].get_type() != Variant::NIL) bo = arrays[Mesh::ARRAY_BONES].operator Vector<int>().ptr(); - const real_t *we = NULL; + const real_t *we = nullptr; if (arrays[Mesh::ARRAY_WEIGHTS].get_type() != Variant::NIL) we = arrays[Mesh::ARRAY_WEIGHTS].operator Vector<real_t>().ptr(); @@ -202,43 +202,43 @@ Error MeshDataTool::commit_to_surface(const Ref<ArrayMesh> &p_mesh) { v.resize(vcount); Vector3 *vr = v.ptrw(); - Vector3 *nr = NULL; + Vector3 *nr = nullptr; if (format & Mesh::ARRAY_FORMAT_NORMAL) { n.resize(vcount); nr = n.ptrw(); } - real_t *ta = NULL; + real_t *ta = nullptr; if (format & Mesh::ARRAY_FORMAT_TANGENT) { t.resize(vcount * 4); ta = t.ptrw(); } - Vector2 *uv = NULL; + Vector2 *uv = nullptr; if (format & Mesh::ARRAY_FORMAT_TEX_UV) { u.resize(vcount); uv = u.ptrw(); } - Vector2 *uv2 = NULL; + Vector2 *uv2 = nullptr; if (format & Mesh::ARRAY_FORMAT_TEX_UV2) { u2.resize(vcount); uv2 = u2.ptrw(); } - Color *col = NULL; + Color *col = nullptr; if (format & Mesh::ARRAY_FORMAT_COLOR) { c.resize(vcount); col = c.ptrw(); } - int *bo = NULL; + int *bo = nullptr; if (format & Mesh::ARRAY_FORMAT_BONES) { b.resize(vcount * 4); bo = b.ptrw(); } - real_t *we = NULL; + real_t *we = nullptr; if (format & Mesh::ARRAY_FORMAT_WEIGHTS) { w.resize(vcount * 4); we = w.ptrw(); diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 549c29a7f3..633771506e 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -51,25 +51,25 @@ Node *SceneState::instance(GenEditState p_edit_state) const { // nodes where instancing failed (because something is missing) List<Node *> stray_instances; -#define NODE_FROM_ID(p_name, p_id) \ - Node *p_name; \ - if (p_id & FLAG_ID_IS_PATH) { \ - NodePath np = node_paths[p_id & FLAG_MASK]; \ - p_name = ret_nodes[0]->get_node_or_null(np); \ - } else { \ - ERR_FAIL_INDEX_V(p_id &FLAG_MASK, nc, NULL); \ - p_name = ret_nodes[p_id & FLAG_MASK]; \ +#define NODE_FROM_ID(p_name, p_id) \ + Node *p_name; \ + if (p_id & FLAG_ID_IS_PATH) { \ + NodePath np = node_paths[p_id & FLAG_MASK]; \ + p_name = ret_nodes[0]->get_node_or_null(np); \ + } else { \ + ERR_FAIL_INDEX_V(p_id &FLAG_MASK, nc, nullptr); \ + p_name = ret_nodes[p_id & FLAG_MASK]; \ } int nc = nodes.size(); - ERR_FAIL_COND_V(nc == 0, NULL); + ERR_FAIL_COND_V(nc == 0, nullptr); - const StringName *snames = NULL; + const StringName *snames = nullptr; int sname_count = names.size(); if (sname_count) snames = &names[0]; - const Variant *props = NULL; + const Variant *props = nullptr; int prop_count = variants.size(); if (prop_count) props = &variants[0]; @@ -88,11 +88,11 @@ Node *SceneState::instance(GenEditState p_edit_state) const { const NodeData &n = nd[i]; - Node *parent = NULL; + Node *parent = nullptr; if (i > 0) { - ERR_FAIL_COND_V_MSG(n.parent == -1, NULL, vformat("Invalid scene: node %s does not specify its parent node.", snames[n.name])); + ERR_FAIL_COND_V_MSG(n.parent == -1, nullptr, vformat("Invalid scene: node %s does not specify its parent node.", snames[n.name])); NODE_FROM_ID(nparent, n.parent); #ifdef DEBUG_ENABLED if (!nparent && (n.parent & FLAG_ID_IS_PATH)) { @@ -103,14 +103,14 @@ Node *SceneState::instance(GenEditState p_edit_state) const { parent = nparent; } - Node *node = NULL; + Node *node = nullptr; if (i == 0 && base_scene_idx >= 0) { //scene inheritance on root node Ref<PackedScene> sdata = props[base_scene_idx]; - ERR_FAIL_COND_V(!sdata.is_valid(), NULL); + ERR_FAIL_COND_V(!sdata.is_valid(), nullptr); node = sdata->instance(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, NULL); + ERR_FAIL_COND_V(!node, nullptr); if (p_edit_state != GEN_EDIT_STATE_DISABLED) { node->set_scene_inherited_state(sdata->get_state()); } @@ -123,9 +123,9 @@ Node *SceneState::instance(GenEditState p_edit_state) const { if (disable_placeholders) { Ref<PackedScene> sdata = ResourceLoader::load(path, "PackedScene"); - ERR_FAIL_COND_V(!sdata.is_valid(), NULL); + ERR_FAIL_COND_V(!sdata.is_valid(), nullptr); node = sdata->instance(p_edit_state == GEN_EDIT_STATE_DISABLED ? PackedScene::GEN_EDIT_STATE_DISABLED : PackedScene::GEN_EDIT_STATE_INSTANCE); - ERR_FAIL_COND_V(!node, NULL); + ERR_FAIL_COND_V(!node, nullptr); } else { InstancePlaceholder *ip = memnew(InstancePlaceholder); ip->set_instance_path(path); @@ -134,9 +134,9 @@ Node *SceneState::instance(GenEditState p_edit_state) const { node->set_scene_instance_load_placeholder(true); } else { Ref<PackedScene> sdata = props[n.instance & FLAG_MASK]; - ERR_FAIL_COND_V(!sdata.is_valid(), NULL); + ERR_FAIL_COND_V(!sdata.is_valid(), nullptr); node = sdata->instance(p_edit_state == GEN_EDIT_STATE_DISABLED ? PackedScene::GEN_EDIT_STATE_DISABLED : PackedScene::GEN_EDIT_STATE_INSTANCE); - ERR_FAIL_COND_V(!node, NULL); + ERR_FAIL_COND_V(!node, nullptr); } } else if (n.type == TYPE_INSTANCED) { @@ -155,7 +155,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const { if (!Object::cast_to<Node>(obj)) { if (obj) { memdelete(obj); - obj = NULL; + obj = nullptr; } WARN_PRINT(String("Warning node of type " + snames[n.type].operator String() + " does not exist.").ascii().get_data()); if (n.parent >= 0 && n.parent < nc && ret_nodes[n.parent]) { @@ -193,8 +193,8 @@ Node *SceneState::instance(GenEditState p_edit_state) const { for (int j = 0; j < nprop_count; j++) { bool valid; - ERR_FAIL_INDEX_V(nprops[j].name, sname_count, NULL); - ERR_FAIL_INDEX_V(nprops[j].value, prop_count, NULL); + ERR_FAIL_INDEX_V(nprops[j].name, sname_count, nullptr); + ERR_FAIL_INDEX_V(nprops[j].value, prop_count, nullptr); if (snames[nprops[j].name] == CoreStringNames::get_singleton()->_script) { //work around to avoid old script variables from disappearing, should be the proper fix to: @@ -260,7 +260,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const { //groups for (int j = 0; j < n.groups.size(); j++) { - ERR_FAIL_INDEX_V(n.groups[j], sname_count, NULL); + ERR_FAIL_INDEX_V(n.groups[j], sname_count, nullptr); node->add_to_group(snames[n.groups[j]], true); } @@ -315,8 +315,8 @@ Node *SceneState::instance(GenEditState p_edit_state) const { for (int i = 0; i < cc; i++) { const ConnectionData &c = cdata[i]; - //ERR_FAIL_INDEX_V( c.from, nc, NULL ); - //ERR_FAIL_INDEX_V( c.to, nc, NULL ); + //ERR_FAIL_INDEX_V( c.from, nc, nullptr ); + //ERR_FAIL_INDEX_V( c.to, nc, nullptr ); NODE_FROM_ID(cfrom, c.from); NODE_FROM_ID(cto, c.to); @@ -450,7 +450,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map nd.instance = _vm_get_variant(instance, variant_map); } } - n = NULL; + n = nullptr; } else { if (n->get_filename() != String()) { //is an instance @@ -773,7 +773,7 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName } } - nl = NULL; + nl = nullptr; } else { if (nl->get_filename() != String()) { //is an instance @@ -896,7 +896,7 @@ Error SceneState::pack(Node *p_scene) { } variants.resize(variant_map.size()); - const Variant *K = NULL; + const Variant *K = nullptr; while ((K = variant_map.next(K))) { int idx = variant_map[*K]; @@ -1689,12 +1689,12 @@ bool PackedScene::can_instance() const { Node *PackedScene::instance(GenEditState p_edit_state) const { #ifndef TOOLS_ENABLED - ERR_FAIL_COND_V_MSG(p_edit_state != GEN_EDIT_STATE_DISABLED, NULL, "Edit state is only for editors, does not work without tools compiled."); + ERR_FAIL_COND_V_MSG(p_edit_state != GEN_EDIT_STATE_DISABLED, nullptr, "Edit state is only for editors, does not work without tools compiled."); #endif Node *s = state->instance((SceneState::GenEditState)p_edit_state); if (!s) - return NULL; + return nullptr; if (p_edit_state != GEN_EDIT_STATE_DISABLED) { s->set_scene_instance_state(state); diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp index 63766c1756..83430aef9e 100644 --- a/scene/resources/particles_material.cpp +++ b/scene/resources/particles_material.cpp @@ -31,9 +31,9 @@ #include "particles_material.h" Mutex ParticlesMaterial::material_mutex; -SelfList<ParticlesMaterial>::List *ParticlesMaterial::dirty_materials = NULL; +SelfList<ParticlesMaterial>::List *ParticlesMaterial::dirty_materials = nullptr; Map<ParticlesMaterial::MaterialKey, ParticlesMaterial::ShaderData> ParticlesMaterial::shader_map; -ParticlesMaterial::ShaderNames *ParticlesMaterial::shader_names = NULL; +ParticlesMaterial::ShaderNames *ParticlesMaterial::shader_names = nullptr; void ParticlesMaterial::init_shaders() { @@ -104,7 +104,7 @@ void ParticlesMaterial::init_shaders() { void ParticlesMaterial::finish_shaders() { memdelete(dirty_materials); - dirty_materials = NULL; + dirty_materials = nullptr; memdelete(shader_names); } diff --git a/scene/resources/polygon_path_finder.cpp b/scene/resources/polygon_path_finder.cpp index eff0721cef..c3daedf918 100644 --- a/scene/resources/polygon_path_finder.cpp +++ b/scene/resources/polygon_path_finder.cpp @@ -42,7 +42,7 @@ bool PolygonPathFinder::_is_point_inside(const Vector2 &p_point) const { Vector2 a = points[e.points[0]].pos; Vector2 b = points[e.points[1]].pos; - if (Geometry::segment_intersects_segment_2d(a, b, p_point, outside_point, NULL)) { + if (Geometry::segment_intersects_segment_2d(a, b, p_point, outside_point, nullptr)) { crosses++; } } @@ -119,7 +119,7 @@ void PolygonPathFinder::setup(const Vector<Vector2> &p_points, const Vector<int> Vector2 a = points[e.points[0]].pos; Vector2 b = points[e.points[1]].pos; - if (Geometry::segment_intersects_segment_2d(a, b, from, to, NULL)) { + if (Geometry::segment_intersects_segment_2d(a, b, from, to, nullptr)) { valid = false; break; } @@ -209,7 +209,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector Vector2 a = points[e.points[0]].pos; Vector2 b = points[e.points[1]].pos; - if (Geometry::segment_intersects_segment_2d(a, b, from, to, NULL)) { + if (Geometry::segment_intersects_segment_2d(a, b, from, to, nullptr)) { can_see_eachother = false; break; } @@ -268,7 +268,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector e.points[0] != ignore_from_edge.points[0] && e.points[1] != ignore_from_edge.points[0]) { - if (Geometry::segment_intersects_segment_2d(a, b, from, points[i].pos, NULL)) { + if (Geometry::segment_intersects_segment_2d(a, b, from, points[i].pos, nullptr)) { valid_a = false; } } @@ -281,7 +281,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector e.points[0] != ignore_to_edge.points[0] && e.points[1] != ignore_to_edge.points[0]) { - if (Geometry::segment_intersects_segment_2d(a, b, to, points[i].pos, NULL)) { + if (Geometry::segment_intersects_segment_2d(a, b, to, points[i].pos, nullptr)) { valid_b = false; } } diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index 0792af2143..46e8575018 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -164,7 +164,7 @@ void PrimitiveMesh::surface_set_material(int p_idx, const Ref<Material> &p_mater } Ref<Material> PrimitiveMesh::surface_get_material(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, 1, NULL); + ERR_FAIL_INDEX_V(p_idx, 1, nullptr); return material; } diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 238bdf05ef..5068bb548f 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -795,7 +795,7 @@ Error ResourceLoaderText::rename_dependencies(FileAccess *p_f, const String &p_p ignore_resource_parsing = true; //FileAccess - FileAccess *fw = NULL; + FileAccess *fw = nullptr; String base_path = local_path.get_base_dir(); @@ -961,7 +961,7 @@ void ResourceLoaderText::open(FileAccess *p_f, bool p_skip_first_tag) { rp.ext_func = _parse_ext_resources; rp.sub_func = _parse_sub_resources; - rp.func = NULL; + rp.func = nullptr; rp.userdata = this; } @@ -1392,7 +1392,7 @@ Error ResourceFormatLoaderText::rename_dependencies(const String &p_path, const return loader.rename_dependencies(f, p_path, p_map); } -ResourceFormatLoaderText *ResourceFormatLoaderText::singleton = NULL; +ResourceFormatLoaderText *ResourceFormatLoaderText::singleton = nullptr; Error ResourceFormatLoaderText::convert_file_to_binary(const String &p_src_path, const String &p_dst_path) { @@ -1674,7 +1674,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r RES res = E->get(); ERR_CONTINUE(!resource_set.has(res)); - bool main = (E->next() == NULL); + bool main = (E->next() == nullptr); if (main && packed_scene.is_valid()) break; //save as a scene @@ -1880,7 +1880,7 @@ void ResourceFormatSaverText::get_recognized_extensions(const RES &p_resource, L p_extensions->push_back("tres"); //text resource } -ResourceFormatSaverText *ResourceFormatSaverText::singleton = NULL; +ResourceFormatSaverText *ResourceFormatSaverText::singleton = nullptr; ResourceFormatSaverText::ResourceFormatSaverText() { singleton = this; } diff --git a/scene/resources/resource_format_text.h b/scene/resources/resource_format_text.h index 2425ac7f6c..fbbd2e3346 100644 --- a/scene/resources/resource_format_text.h +++ b/scene/resources/resource_format_text.h @@ -134,7 +134,7 @@ public: class ResourceFormatLoaderText : public ResourceFormatLoader { public: static ResourceFormatLoaderText *singleton; - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const; virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; diff --git a/scene/resources/shader.h b/scene/resources/shader.h index e65457ed76..cf0cec362c 100644 --- a/scene/resources/shader.h +++ b/scene/resources/shader.h @@ -84,7 +84,7 @@ public: _FORCE_INLINE_ StringName remap_param(const StringName &p_param) const { if (params_cache_dirty) - get_param_list(NULL); + get_param_list(nullptr); const Map<StringName, StringName>::Element *E = params_cache.find(p_param); if (E) @@ -102,7 +102,7 @@ VARIANT_ENUM_CAST(Shader::Mode); class ResourceFormatLoaderShader : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/scene/resources/shape_2d.cpp b/scene/resources/shape_2d.cpp index 7984dadbc5..4fe585053a 100644 --- a/scene/resources/shape_2d.cpp +++ b/scene/resources/shape_2d.cpp @@ -50,13 +50,13 @@ bool Shape2D::collide_with_motion(const Transform2D &p_local_xform, const Vector ERR_FAIL_COND_V(p_shape.is_null(), false); int r; - return PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, p_local_motion, p_shape->get_rid(), p_shape_xform, p_shape_motion, NULL, 0, r); + return PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, p_local_motion, p_shape->get_rid(), p_shape_xform, p_shape_motion, nullptr, 0, r); } bool Shape2D::collide(const Transform2D &p_local_xform, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform) { ERR_FAIL_COND_V(p_shape.is_null(), false); int r; - return PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, Vector2(), p_shape->get_rid(), p_shape_xform, Vector2(), NULL, 0, r); + return PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, Vector2(), p_shape->get_rid(), p_shape_xform, Vector2(), nullptr, 0, r); } Array Shape2D::collide_with_motion_and_get_contacts(const Transform2D &p_local_xform, const Vector2 &p_local_motion, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform, const Vector2 &p_shape_motion) { diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index fee6bd1b54..4b392e23b7 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -854,7 +854,7 @@ void SurfaceTool::mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, cons const tbool bIsOrientationPreserving, const int iFace, const int iVert) { TangentGenerationContextUserData &triangle_data = *reinterpret_cast<TangentGenerationContextUserData *>(pContext->m_pUserData); - Vertex *vtx = NULL; + Vertex *vtx = nullptr; if (triangle_data.indices.size() > 0) { int index = triangle_data.indices[iFace * 3 + iVert]->get(); if (index < triangle_data.vertices.size()) { @@ -864,7 +864,7 @@ void SurfaceTool::mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, cons vtx = &triangle_data.vertices[iFace * 3 + iVert]->get(); } - if (vtx != NULL) { + if (vtx != nullptr) { vtx->tangent = Vector3(fvTangent[0], fvTangent[1], fvTangent[2]); vtx->binormal = Vector3(-fvBiTangent[0], -fvBiTangent[1], -fvBiTangent[2]); // for some reason these are reversed, something with the coordinate system in Godot } @@ -882,7 +882,7 @@ void SurfaceTool::generate_tangents() { mkif.m_getPosition = mikktGetPosition; mkif.m_getTexCoord = mikktGetTexCoord; mkif.m_setTSpace = mikktSetTSpaceDefault; - mkif.m_setTSpaceBasic = NULL; + mkif.m_setTSpaceBasic = nullptr; SMikkTSpaceContext msc; msc.m_pInterface = &mkif; diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 74b6a16d41..749dff24f2 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -525,9 +525,9 @@ void StreamTexture::_requested_normal(void *p_ud) { request_normal_callback(stex); } -StreamTexture::TextureFormatRequestCallback StreamTexture::request_3d_callback = NULL; -StreamTexture::TextureFormatRoughnessRequestCallback StreamTexture::request_roughness_callback = NULL; -StreamTexture::TextureFormatRequestCallback StreamTexture::request_normal_callback = NULL; +StreamTexture::TextureFormatRequestCallback StreamTexture::request_3d_callback = nullptr; +StreamTexture::TextureFormatRoughnessRequestCallback StreamTexture::request_roughness_callback = nullptr; +StreamTexture::TextureFormatRequestCallback StreamTexture::request_normal_callback = nullptr; Image::Format StreamTexture::get_format() const { @@ -637,7 +637,7 @@ Error StreamTexture::load(const String &p_path) { RS::get_singleton()->texture_set_detect_3d_callback(texture, _requested_3d, this); } else { //print_line("not requesting detect 3D at " + p_path); - RS::get_singleton()->texture_set_detect_3d_callback(texture, NULL, NULL); + RS::get_singleton()->texture_set_detect_3d_callback(texture, nullptr, nullptr); } if (request_roughness) { @@ -645,7 +645,7 @@ Error StreamTexture::load(const String &p_path) { RS::get_singleton()->texture_set_detect_roughness_callback(texture, _requested_roughness, this); } else { //print_line("not requesting detect srgb at " + p_path); - RS::get_singleton()->texture_set_detect_roughness_callback(texture, NULL, NULL); + RS::get_singleton()->texture_set_detect_roughness_callback(texture, nullptr, nullptr); } if (request_normal) { @@ -653,7 +653,7 @@ Error StreamTexture::load(const String &p_path) { RS::get_singleton()->texture_set_detect_normal_callback(texture, _requested_normal, this); } else { //print_line("not requesting detect normal at " + p_path); - RS::get_singleton()->texture_set_detect_normal_callback(texture, NULL, NULL); + RS::get_singleton()->texture_set_detect_normal_callback(texture, nullptr, nullptr); } #endif @@ -1869,7 +1869,7 @@ AnimatedTexture::AnimatedTexture() { #ifndef NO_THREADS rw_lock = RWLock::create(); #else - rw_lock = NULL; + rw_lock = nullptr; #endif } diff --git a/scene/resources/texture.h b/scene/resources/texture.h index c3bbbd5ee6..18f70baa07 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -213,7 +213,7 @@ public: class ResourceFormatLoaderStreamTexture : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; @@ -421,7 +421,7 @@ public: COMPRESSION_UNCOMPRESSED }; - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index d67f5f9ff2..98ebf048dc 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -230,11 +230,11 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const { List<PropertyInfo> list; - const StringName *key = NULL; + const StringName *key = nullptr; while ((key = icon_map.next(key))) { - const StringName *key2 = NULL; + const StringName *key2 = nullptr; while ((key2 = icon_map[*key].next(key2))) { @@ -242,11 +242,11 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const { } } - key = NULL; + key = nullptr; while ((key = style_map.next(key))) { - const StringName *key2 = NULL; + const StringName *key2 = nullptr; while ((key2 = style_map[*key].next(key2))) { @@ -254,11 +254,11 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const { } } - key = NULL; + key = nullptr; while ((key = font_map.next(key))) { - const StringName *key2 = NULL; + const StringName *key2 = nullptr; while ((key2 = font_map[*key].next(key2))) { @@ -266,11 +266,11 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const { } } - key = NULL; + key = nullptr; while ((key = color_map.next(key))) { - const StringName *key2 = NULL; + const StringName *key2 = nullptr; while ((key2 = color_map[*key].next(key2))) { @@ -278,11 +278,11 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const { } } - key = NULL; + key = nullptr; while ((key = constant_map.next(key))) { - const StringName *key2 = NULL; + const StringName *key2 = nullptr; while ((key2 = constant_map[*key].next(key2))) { @@ -417,7 +417,7 @@ void Theme::get_icon_list(StringName p_type, List<StringName> *p_list) const { if (!icon_map.has(p_type)) return; - const StringName *key = NULL; + const StringName *key = nullptr; while ((key = icon_map[p_type].next(key))) { @@ -440,7 +440,7 @@ Ref<Shader> Theme::get_shader(const StringName &p_name, const StringName &p_type if (shader_map.has(p_type) && shader_map[p_type].has(p_name) && shader_map[p_type][p_name].is_valid()) { return shader_map[p_type][p_name]; } else { - return NULL; + return nullptr; } } @@ -464,7 +464,7 @@ void Theme::get_shader_list(const StringName &p_type, List<StringName> *p_list) if (!shader_map.has(p_type)) return; - const StringName *key = NULL; + const StringName *key = nullptr; while ((key = shader_map[p_type].next(key))) { @@ -530,7 +530,7 @@ void Theme::get_stylebox_list(StringName p_type, List<StringName> *p_list) const if (!style_map.has(p_type)) return; - const StringName *key = NULL; + const StringName *key = nullptr; while ((key = style_map[p_type].next(key))) { @@ -541,7 +541,7 @@ void Theme::get_stylebox_list(StringName p_type, List<StringName> *p_list) const void Theme::get_stylebox_types(List<StringName> *p_list) const { ERR_FAIL_NULL(p_list); - const StringName *key = NULL; + const StringName *key = nullptr; while ((key = style_map.next(key))) { p_list->push_back(*key); } @@ -604,7 +604,7 @@ void Theme::get_font_list(StringName p_type, List<StringName> *p_list) const { if (!font_map.has(p_type)) return; - const StringName *key = NULL; + const StringName *key = nullptr; while ((key = font_map[p_type].next(key))) { @@ -654,7 +654,7 @@ void Theme::get_color_list(StringName p_type, List<StringName> *p_list) const { if (!color_map.has(p_type)) return; - const StringName *key = NULL; + const StringName *key = nullptr; while ((key = color_map[p_type].next(key))) { @@ -704,7 +704,7 @@ void Theme::get_constant_list(StringName p_type, List<StringName> *p_list) const if (!constant_map.has(p_type)) return; - const StringName *key = NULL; + const StringName *key = nullptr; while ((key = constant_map[p_type].next(key))) { @@ -716,9 +716,9 @@ void Theme::clear() { //these need disconnecting { - const StringName *K = NULL; + const StringName *K = nullptr; while ((K = icon_map.next(K))) { - const StringName *L = NULL; + const StringName *L = nullptr; while ((L = icon_map[*K].next(L))) { Ref<Texture2D> icon = icon_map[*K][*L]; if (icon.is_valid()) { @@ -729,9 +729,9 @@ void Theme::clear() { } { - const StringName *K = NULL; + const StringName *K = nullptr; while ((K = style_map.next(K))) { - const StringName *L = NULL; + const StringName *L = nullptr; while ((L = style_map[*K].next(L))) { Ref<StyleBox> style = style_map[*K][*L]; if (style.is_valid()) { @@ -742,9 +742,9 @@ void Theme::clear() { } { - const StringName *K = NULL; + const StringName *K = nullptr; while ((K = font_map.next(K))) { - const StringName *L = NULL; + const StringName *L = nullptr; while ((L = font_map[*K].next(L))) { Ref<Font> font = font_map[*K][*L]; if (font.is_valid()) { @@ -781,9 +781,9 @@ void Theme::copy_theme(const Ref<Theme> &p_other) { //these need reconnecting, so add normally { - const StringName *K = NULL; + const StringName *K = nullptr; while ((K = p_other->icon_map.next(K))) { - const StringName *L = NULL; + const StringName *L = nullptr; while ((L = p_other->icon_map[*K].next(L))) { set_icon(*L, *K, p_other->icon_map[*K][*L]); } @@ -791,9 +791,9 @@ void Theme::copy_theme(const Ref<Theme> &p_other) { } { - const StringName *K = NULL; + const StringName *K = nullptr; while ((K = p_other->style_map.next(K))) { - const StringName *L = NULL; + const StringName *L = nullptr; while ((L = p_other->style_map[*K].next(L))) { set_stylebox(*L, *K, p_other->style_map[*K][*L]); } @@ -801,9 +801,9 @@ void Theme::copy_theme(const Ref<Theme> &p_other) { } { - const StringName *K = NULL; + const StringName *K = nullptr; while ((K = p_other->font_map.next(K))) { - const StringName *L = NULL; + const StringName *L = nullptr; while ((L = p_other->font_map[*K].next(L))) { set_font(*L, *K, p_other->font_map[*K][*L]); } @@ -825,35 +825,35 @@ void Theme::get_type_list(List<StringName> *p_list) const { ERR_FAIL_NULL(p_list); Set<StringName> types; - const StringName *key = NULL; + const StringName *key = nullptr; while ((key = icon_map.next(key))) { types.insert(*key); } - key = NULL; + key = nullptr; while ((key = style_map.next(key))) { types.insert(*key); } - key = NULL; + key = nullptr; while ((key = font_map.next(key))) { types.insert(*key); } - key = NULL; + key = nullptr; while ((key = color_map.next(key))) { types.insert(*key); } - key = NULL; + key = nullptr; while ((key = constant_map.next(key))) { diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index 27305cfff1..6f8a53be1a 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -620,7 +620,7 @@ Vector2 TileSet::autotile_get_subtile_for_bitmask(int p_id, uint16_t p_bitmask, ERR_FAIL_COND_V(!tile_map.has(p_id), Vector2()); //First try to forward selection to script if (p_tilemap_node->get_class_name() == "TileMap") { - if (get_script_instance() != NULL) { + if (get_script_instance() != nullptr) { if (get_script_instance()->has_method("_forward_subtile_selection")) { Variant ret = get_script_instance()->call("_forward_subtile_selection", p_id, p_bitmask, p_tilemap_node, p_tile_location); if (ret.get_type() == Variant::VECTOR2) { @@ -681,7 +681,7 @@ Vector2 TileSet::atlastile_get_subtile_by_priority(int p_id, const Node *p_tilem ERR_FAIL_COND_V(!tile_map.has(p_id), Vector2()); //First try to forward selection to script - if (get_script_instance() != NULL) { + if (get_script_instance() != nullptr) { if (get_script_instance()->has_method("_forward_atlas_subtile_selection")) { Variant ret = get_script_instance()->call("_forward_atlas_subtile_selection", p_id, p_tilemap_node, p_tile_location); if (ret.get_type() == Variant::VECTOR2) { @@ -1108,7 +1108,7 @@ bool TileSet::is_tile_bound(int p_drawn_id, int p_neighbor_id) { if (p_drawn_id == p_neighbor_id) { return true; - } else if (get_script_instance() != NULL) { + } else if (get_script_instance() != nullptr) { if (get_script_instance()->has_method("_is_tile_bound")) { Variant ret = get_script_instance()->call("_is_tile_bound", p_drawn_id, p_neighbor_id); if (ret.get_type() == Variant::BOOL) { diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h index 5252c560a4..05b43dfb89 100644 --- a/scene/resources/tile_set.h +++ b/scene/resources/tile_set.h @@ -194,8 +194,8 @@ public: void autotile_set_bitmask(int p_id, Vector2 p_coord, uint32_t p_flag); uint32_t autotile_get_bitmask(int p_id, Vector2 p_coord); const Map<Vector2, uint32_t> &autotile_get_bitmask_map(int p_id); - Vector2 autotile_get_subtile_for_bitmask(int p_id, uint16_t p_bitmask, const Node *p_tilemap_node = NULL, const Vector2 &p_tile_location = Vector2()); - Vector2 atlastile_get_subtile_by_priority(int p_id, const Node *p_tilemap_node = NULL, const Vector2 &p_tile_location = Vector2()); + Vector2 autotile_get_subtile_for_bitmask(int p_id, uint16_t p_bitmask, const Node *p_tilemap_node = nullptr, const Vector2 &p_tile_location = Vector2()); + Vector2 atlastile_get_subtile_by_priority(int p_id, const Node *p_tilemap_node = nullptr, const Vector2 &p_tile_location = Vector2()); void tile_set_shape(int p_id, int p_shape_id, const Ref<Shape2D> &p_shape); Ref<Shape2D> tile_get_shape(int p_id, int p_shape_id) const; diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index c47e80c807..310a7ef4e4 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -881,7 +881,7 @@ VisualShader::RenderModeEnums VisualShader::render_mode_enums[] = { { Shader::MODE_SPATIAL, "diffuse" }, { Shader::MODE_SPATIAL, "specular" }, { Shader::MODE_CANVAS_ITEM, "blend" }, - { Shader::MODE_CANVAS_ITEM, NULL } + { Shader::MODE_CANVAS_ITEM, nullptr } }; static const char *type_string[VisualShader::TYPE_MAX] = { @@ -1085,12 +1085,12 @@ void VisualShader::_get_property_list(List<PropertyInfo> *p_list) const { } p_list->push_back(PropertyInfo(Variant::VECTOR2, prop_name + "/position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); - if (Object::cast_to<VisualShaderNodeGroupBase>(E->get().node.ptr()) != NULL) { + if (Object::cast_to<VisualShaderNodeGroupBase>(E->get().node.ptr()) != nullptr) { p_list->push_back(PropertyInfo(Variant::VECTOR2, prop_name + "/size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); p_list->push_back(PropertyInfo(Variant::STRING, prop_name + "/input_ports", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); p_list->push_back(PropertyInfo(Variant::STRING, prop_name + "/output_ports", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); } - if (Object::cast_to<VisualShaderNodeExpression>(E->get().node.ptr()) != NULL) { + if (Object::cast_to<VisualShaderNodeExpression>(E->get().node.ptr()) != nullptr) { p_list->push_back(PropertyInfo(Variant::STRING, prop_name + "/expression", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); } } @@ -1478,7 +1478,7 @@ void VisualShader::_bind_methods() { ClassDB::bind_method(D_METHOD("remove_node", "type", "id"), &VisualShader::remove_node); ClassDB::bind_method(D_METHOD("is_node_connection", "type", "from_node", "from_port", "to_node", "to_port"), &VisualShader::is_node_connection); - ClassDB::bind_method(D_METHOD("can_connect_nodes", "type", "from_node", "from_port", "to_node", "to_port"), &VisualShader::is_node_connection); + ClassDB::bind_method(D_METHOD("can_connect_nodes", "type", "from_node", "from_port", "to_node", "to_port"), &VisualShader::can_connect_nodes); ClassDB::bind_method(D_METHOD("connect_nodes", "type", "from_node", "from_port", "to_node", "to_port"), &VisualShader::connect_nodes); ClassDB::bind_method(D_METHOD("disconnect_nodes", "type", "from_node", "from_port", "to_node", "to_port"), &VisualShader::disconnect_nodes); @@ -1687,7 +1687,7 @@ const VisualShaderNodeInput::Port VisualShaderNodeInput::ports[] = { { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "sky_coords", "vec3(SKY_COORDS, 0.0)" }, { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" }, - { Shader::MODE_MAX, VisualShader::TYPE_MAX, VisualShaderNode::PORT_TYPE_TRANSFORM, NULL, NULL }, + { Shader::MODE_MAX, VisualShader::TYPE_MAX, VisualShaderNode::PORT_TYPE_TRANSFORM, nullptr, nullptr }, }; const VisualShaderNodeInput::Port VisualShaderNodeInput::preview_ports[] = { @@ -1736,7 +1736,7 @@ const VisualShaderNodeInput::Port VisualShaderNodeInput::preview_ports[] = { { Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "1.0" }, { Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "velocity", "vec3(0.0, 0.0, 1.0)" }, { Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" }, - { Shader::MODE_MAX, VisualShader::TYPE_MAX, VisualShaderNode::PORT_TYPE_TRANSFORM, NULL, NULL }, + { Shader::MODE_MAX, VisualShader::TYPE_MAX, VisualShaderNode::PORT_TYPE_TRANSFORM, nullptr, nullptr }, }; int VisualShaderNodeInput::get_input_port_count() const { @@ -2034,7 +2034,7 @@ const VisualShaderNodeOutput::Port VisualShaderNodeOutput::ports[] = { { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "color", "COLOR" }, { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "ALPHA" }, - { Shader::MODE_MAX, VisualShader::TYPE_MAX, VisualShaderNode::PORT_TYPE_TRANSFORM, NULL, NULL }, + { Shader::MODE_MAX, VisualShader::TYPE_MAX, VisualShaderNode::PORT_TYPE_TRANSFORM, nullptr, nullptr }, }; int VisualShaderNodeOutput::get_input_port_count() const { @@ -2164,6 +2164,17 @@ void VisualShaderNodeUniform::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "uniform_name"), "set_uniform_name", "get_uniform_name"); } +String VisualShaderNodeUniform::get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const { + + List<String> keyword_list; + ShaderLanguage::get_keyword_list(&keyword_list); + if (keyword_list.find(uniform_name)) { + return TTR("Uniform name cannot be equal to a shader keyword. Choose another name."); + } + + return String(); +} + VisualShaderNodeUniform::VisualShaderNodeUniform() { } @@ -2565,7 +2576,7 @@ void VisualShaderNodeGroupBase::set_control(Control *p_control, int p_index) { } Control *VisualShaderNodeGroupBase::get_control(int p_index) { - ERR_FAIL_COND_V(!controls.has(p_index), NULL); + ERR_FAIL_COND_V(!controls.has(p_index), nullptr); return controls[p_index]; } diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h index 450dcfa081..ecf3f93fbb 100644 --- a/scene/resources/visual_shader.h +++ b/scene/resources/visual_shader.h @@ -379,6 +379,8 @@ public: void set_uniform_name(const String &p_name); String get_uniform_name() const; + virtual String get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const; + VisualShaderNodeUniform(); }; diff --git a/scene/resources/world_3d.cpp b/scene/resources/world_3d.cpp index a33f850755..dee00dd82a 100644 --- a/scene/resources/world_3d.cpp +++ b/scene/resources/world_3d.cpp @@ -365,7 +365,7 @@ World3D::World3D() { ProjectSettings::get_singleton()->set_custom_property_info("physics/3d/default_angular_damp", PropertyInfo(Variant::FLOAT, "physics/3d/default_angular_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater")); #ifdef _3D_DISABLED - indexer = NULL; + indexer = nullptr; #else indexer = memnew(SpatialIndexer); #endif diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp index 1f0365dab9..ad996e7d50 100644 --- a/scene/scene_string_names.cpp +++ b/scene/scene_string_names.cpp @@ -30,7 +30,7 @@ #include "scene_string_names.h" -SceneStringNames *SceneStringNames::singleton = NULL; +SceneStringNames *SceneStringNames::singleton = nullptr; SceneStringNames::SceneStringNames() { diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h index e255ebb3cb..58e8c28454 100644 --- a/scene/scene_string_names.h +++ b/scene/scene_string_names.h @@ -44,7 +44,7 @@ class SceneStringNames { static void create() { singleton = memnew(SceneStringNames); } static void free() { memdelete(singleton); - singleton = NULL; + singleton = nullptr; } SceneStringNames(); |