diff options
Diffstat (limited to 'servers/rendering')
24 files changed, 258 insertions, 258 deletions
diff --git a/servers/rendering/rasterizer.cpp b/servers/rendering/rasterizer.cpp index a3f93a3f8c..f62e0a43a6 100644 --- a/servers/rendering/rasterizer.cpp +++ b/servers/rendering/rasterizer.cpp @@ -33,7 +33,7 @@ #include "core/os/os.h" #include "core/print_string.h" -Rasterizer *(*Rasterizer::_create_func)() = NULL; +Rasterizer *(*Rasterizer::_create_func)() = nullptr; void RasterizerScene::InstanceDependency::instance_notify_changed(bool p_aabb, bool p_dependencies) { for (Map<InstanceBase *, uint32_t>::Element *E = instances.front(); E; E = E->next()) { @@ -67,9 +67,9 @@ Rasterizer *Rasterizer::create() { return _create_func(); } -RasterizerCanvas *RasterizerCanvas::singleton = NULL; +RasterizerCanvas *RasterizerCanvas::singleton = nullptr; -RasterizerStorage *RasterizerStorage::base_singleton = NULL; +RasterizerStorage *RasterizerStorage::base_singleton = nullptr; RasterizerStorage::RasterizerStorage() { diff --git a/servers/rendering/rasterizer.h b/servers/rendering/rasterizer.h index eb33db04fc..fca1352870 100644 --- a/servers/rendering/rasterizer.h +++ b/servers/rendering/rasterizer.h @@ -219,7 +219,7 @@ public: baked_light = false; dynamic_gi = false; redraw_if_visible = false; - lightmap_capture = NULL; + lightmap_capture = nullptr; } virtual ~InstanceBase() { @@ -751,10 +751,10 @@ public: energy = 1.0; item_shadow_mask = -1; mode = RS::CANVAS_LIGHT_MODE_ADD; - // texture_cache = NULL; - next_ptr = NULL; - mask_next_ptr = NULL; - filter_next_ptr = NULL; + // texture_cache = nullptr; + next_ptr = nullptr; + mask_next_ptr = nullptr; + filter_next_ptr = nullptr; use_shadow = false; shadow_buffer_size = 2048; shadow_filter = RS::CANVAS_LIGHT_FILTER_NONE; @@ -1005,7 +1005,7 @@ public: //must update rect - if (commands == NULL) { + if (commands == nullptr) { rect = Rect2(); rect_dirty = false; @@ -1115,12 +1115,12 @@ public: template <class T> T *alloc_command() { T *command; - if (commands == NULL) { + if (commands == nullptr) { // As the most common use case of canvas items is to // use only one command, the first is done with it's // own allocation. The rest of them use blocks. command = memnew(T); - command->next = NULL; + command->next = nullptr; commands = command; last_command = command; } else { @@ -1147,7 +1147,7 @@ public: //allocate block and add to the linked list void *memory = c->memory + c->usage; command = memnew_placement(memory, T); - command->next = NULL; + command->next = nullptr; last_command->next = command; last_command = command; c->usage += sizeof(T); @@ -1172,7 +1172,7 @@ public: Command *n = c->next; if (c == commands) { memdelete(commands); - commands = NULL; + commands = nullptr; } else { c->~Command(); } @@ -1186,36 +1186,36 @@ public: } } - last_command = NULL; - commands = NULL; + last_command = nullptr; + commands = nullptr; current_block = 0; clip = false; rect_dirty = true; - final_clip_owner = NULL; - material_owner = NULL; + final_clip_owner = nullptr; + material_owner = nullptr; light_masked = false; } Item() { - commands = NULL; - last_command = NULL; + commands = nullptr; + last_command = nullptr; current_block = 0; light_mask = 1; - vp_render = NULL; - next = NULL; - final_clip_owner = NULL; + vp_render = nullptr; + next = nullptr; + final_clip_owner = nullptr; clip = false; final_modulate = Color(1, 1, 1, 1); visible = true; rect_dirty = true; custom_rect = false; behind = false; - material_owner = NULL; - copy_back_buffer = NULL; + material_owner = nullptr; + copy_back_buffer = nullptr; distance_field = false; light_masked = false; update_when_visible = false; z_final = 0; - custom_data = NULL; + custom_data = nullptr; } virtual ~Item() { clear(); @@ -1248,7 +1248,7 @@ public: LightOccluderInstance() { enabled = true; - next = NULL; + next = nullptr; light_mask = 1; cull_cache = RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED; } diff --git a/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.cpp index 8d52ffd7b9..ba4f4c4acb 100644 --- a/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.cpp +++ b/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.cpp @@ -1220,7 +1220,7 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_ glVertexAttribPointer(10, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(sizeof(float) * 4 * 5)); glVertexAttribDivisor(10, 1); glEnableVertexAttribArray(11); //color - glVertexAttribPointer(11, 4, GL_FLOAT, GL_FALSE, stride, NULL); + glVertexAttribPointer(11, 4, GL_FLOAT, GL_FALSE, stride, nullptr); glVertexAttribDivisor(11, 1); glEnableVertexAttribArray(12); //custom glVertexAttribPointer(12, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(sizeof(float) * 4 * 2)); @@ -1262,7 +1262,7 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_ glVertexAttribPointer(10, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(sizeof(float) * 4 * 5)); glVertexAttribDivisor(10, 1); glEnableVertexAttribArray(11); //color - glVertexAttribPointer(11, 4, GL_FLOAT, GL_FALSE, stride, NULL); + glVertexAttribPointer(11, 4, GL_FLOAT, GL_FALSE, stride, nullptr); glVertexAttribDivisor(11, 1); glEnableVertexAttribArray(12); //custom glVertexAttribPointer(12, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(sizeof(float) * 4 * 2)); @@ -1314,13 +1314,13 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_ if (current_clip && reclip) { //will make it re-enable clipping if needed afterwards - current_clip = NULL; + current_clip = nullptr; } } void RasterizerCanvasRD::_render_items(RID p_to_render_target, int p_item_count, const Transform2D &p_canvas_transform_inverse, Light *p_lights, RID p_screen_uniform_set) { - Item *current_clip = NULL; + Item *current_clip = nullptr; Transform2D canvas_transform_inverse = p_canvas_transform_inverse; @@ -1369,7 +1369,7 @@ void RasterizerCanvasRD::_render_items(RID p_to_render_target, int p_item_count, if (ci->material != prev_material) { - MaterialData *material_data = NULL; + MaterialData *material_data = nullptr; if (ci->material.is_valid()) { material_data = (MaterialData *)storage->material_get_data(ci->material, RasterizerStorageRD::SHADER_TYPE_2D); } @@ -2532,7 +2532,7 @@ RasterizerCanvasRD::~RasterizerCanvasRD() { //anything remains? if (bindings.texture_bindings.size()) { ERR_PRINT("Some texture bindings were not properly freed (leaked canvasitems?"); - const TextureBindingID *key = NULL; + const TextureBindingID *key = nullptr; while ((key = bindings.texture_bindings.next(key))) { TextureBinding *tb = bindings.texture_bindings[*key]; tb->reference_count = 1; diff --git a/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.h b/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.h index 0c151975bc..83b431eaf6 100644 --- a/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.h +++ b/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.h @@ -383,7 +383,7 @@ class RasterizerCanvasRD : public RasterizerCanvas { for (int i = 0; i < DEFAULT_MAX_LIGHTS_PER_ITEM; i++) { light_cache[i].light_version = 0; - light_cache[i].light = NULL; + light_cache[i].light = nullptr; } light_cache_count = 0xFFFFFFFF; } diff --git a/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.cpp index bf3cd045f1..10d83b0c26 100644 --- a/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.cpp +++ b/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.cpp @@ -1074,12 +1074,12 @@ void RasterizerSceneHighEndRD::_add_geometry(InstanceBase *p_instance, uint32_t } } - MaterialData *material = NULL; + MaterialData *material = nullptr; if (m_src.is_valid()) { material = (MaterialData *)storage->material_get_data(m_src, RasterizerStorageRD::SHADER_TYPE_3D); if (!material || !material->shader_data->valid) { - material = NULL; + material = nullptr; } } @@ -1203,7 +1203,7 @@ void RasterizerSceneHighEndRD::_fill_render_list(InstanceBase **p_cull_result, i case RS::INSTANCE_MESH: { - const RID *materials = NULL; + const RID *materials = nullptr; uint32_t surface_count; materials = storage->mesh_get_surface_count_and_materials(inst->base, surface_count); @@ -1237,7 +1237,7 @@ void RasterizerSceneHighEndRD::_fill_render_list(InstanceBase **p_cull_result, i continue; } - const RID *materials = NULL; + const RID *materials = nullptr; uint32_t surface_count; materials = storage->mesh_get_surface_count_and_materials(mesh, surface_count); @@ -1258,7 +1258,7 @@ void RasterizerSceneHighEndRD::_fill_render_list(InstanceBase **p_cull_result, i RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.getornull(inst->base); ERR_CONTINUE(!immediate); - _add_geometry(immediate, inst, NULL, -1, p_depth_pass, p_shadow_pass); + _add_geometry(immediate, inst, nullptr, -1, p_depth_pass, p_shadow_pass); } break; case RS::INSTANCE_PARTICLES: { @@ -1637,7 +1637,7 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID *p_gi_probe_cull_result, int p_gi_probe_cull_count, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, const Color &p_default_bg_color) { - RenderBufferDataHighEnd *render_buffer = NULL; + RenderBufferDataHighEnd *render_buffer = nullptr; if (p_render_buffer.is_valid()) { render_buffer = (RenderBufferDataHighEnd *)render_buffers_get_data(p_render_buffer); } @@ -1937,13 +1937,13 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor //_render_list #if 0 if (state.directional_light_count == 0) { - directional_light = NULL; - _render_list(&render_list.elements[render_list.max_elements - render_list.alpha_element_count], render_list.alpha_element_count, p_cam_transform, p_cam_projection, env_radiance_tex, false, true, false, false, shadow_atlas != NULL); + directional_light = nullptr; + _render_list(&render_list.elements[render_list.max_elements - render_list.alpha_element_count], render_list.alpha_element_count, p_cam_transform, p_cam_projection, env_radiance_tex, false, true, false, false, shadow_atlas != nullptr); } else { for (int i = 0; i < state.directional_light_count; i++) { directional_light = directional_lights[i]; - _setup_directional_light(i, p_cam_transform.affine_inverse(), shadow_atlas != NULL && shadow_atlas->size > 0); - _render_list(&render_list.elements[render_list.max_elements - render_list.alpha_element_count], render_list.alpha_element_count, p_cam_transform, p_cam_projection, env_radiance_tex, false, true, false, i > 0, shadow_atlas != NULL); + _setup_directional_light(i, p_cam_transform.affine_inverse(), shadow_atlas != nullptr && shadow_atlas->size > 0); + _render_list(&render_list.elements[render_list.max_elements - render_list.alpha_element_count], render_list.alpha_element_count, p_cam_transform, p_cam_projection, env_radiance_tex, false, true, false, i > 0, shadow_atlas != nullptr); } } #endif @@ -2366,7 +2366,7 @@ void RasterizerSceneHighEndRD::_update_render_buffers_uniform_set(RID p_render_b } } -RasterizerSceneHighEndRD *RasterizerSceneHighEndRD::singleton = NULL; +RasterizerSceneHighEndRD *RasterizerSceneHighEndRD::singleton = nullptr; void RasterizerSceneHighEndRD::set_time(double p_time, double p_step) { time = p_time; diff --git a/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.h b/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.h index 4c3422cedb..683a1fc82d 100644 --- a/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.h +++ b/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.h @@ -489,7 +489,7 @@ class RasterizerSceneHighEndRD : public RasterizerSceneRD { _FORCE_INLINE_ Element *add_element() { if (element_count + alpha_element_count >= max_elements) - return NULL; + return nullptr; elements[element_count] = &base_elements[element_count]; return elements[element_count++]; } @@ -497,7 +497,7 @@ class RasterizerSceneHighEndRD : public RasterizerSceneRD { _FORCE_INLINE_ Element *add_alpha_element() { if (element_count + alpha_element_count >= max_elements) - return NULL; + return nullptr; int idx = max_elements - alpha_element_count - 1; elements[idx] = &base_elements[idx]; alpha_element_count++; diff --git a/servers/rendering/rasterizer_rd/rasterizer_scene_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_scene_rd.cpp index 517eea12f4..7a0869e7c1 100644 --- a/servers/rendering/rasterizer_rd/rasterizer_scene_rd.cpp +++ b/servers/rendering/rasterizer_rd/rasterizer_scene_rd.cpp @@ -465,12 +465,12 @@ void RasterizerSceneRD::_draw_sky(bool p_can_continue, RID p_fb, RID p_environme RID sky_material = sky_get_material(environment_get_sky(p_environment)); - SkyMaterialData *material = NULL; + SkyMaterialData *material = nullptr; if (sky_material.is_valid()) { material = (SkyMaterialData *)storage->material_get_data(sky_material, RasterizerStorageRD::SHADER_TYPE_SKY); if (!material || !material->shader_data->valid) { - material = NULL; + material = nullptr; } } @@ -551,12 +551,12 @@ void RasterizerSceneRD::_setup_sky(RID p_environment, const Vector3 &p_position, RID sky_material = sky_get_material(environment_get_sky(p_environment)); - SkyMaterialData *material = NULL; + SkyMaterialData *material = nullptr; if (sky_material.is_valid()) { material = (SkyMaterialData *)storage->material_get_data(sky_material, RasterizerStorageRD::SHADER_TYPE_SKY); if (!material || !material->shader_data->valid) { - material = NULL; + material = nullptr; } } @@ -688,12 +688,12 @@ void RasterizerSceneRD::_update_sky(RID p_environment, const CameraMatrix &p_pro RID sky_material = sky_get_material(environment_get_sky(p_environment)); - SkyMaterialData *material = NULL; + SkyMaterialData *material = nullptr; if (sky_material.is_valid()) { material = (SkyMaterialData *)storage->material_get_data(sky_material, RasterizerStorageRD::SHADER_TYPE_SKY); if (!material || !material->shader_data->valid) { - material = NULL; + material = nullptr; } } @@ -3469,7 +3469,7 @@ bool RasterizerSceneRD::is_using_radiance_cubemap_array() const { RasterizerSceneRD::RenderBufferData *RasterizerSceneRD::render_buffers_get_data(RID p_render_buffers) { RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); - ERR_FAIL_COND_V(!rb, NULL); + ERR_FAIL_COND_V(!rb, nullptr); return rb->data; } @@ -3798,7 +3798,7 @@ float RasterizerSceneRD::screen_space_roughness_limiter_get_curve() const { return screen_space_roughness_limiter_curve; } -RasterizerSceneRD *RasterizerSceneRD::singleton = NULL; +RasterizerSceneRD *RasterizerSceneRD::singleton = nullptr; RasterizerSceneRD::RasterizerSceneRD(RasterizerStorageRD *p_storage) { storage = p_storage; diff --git a/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp index b6b6b5a040..322e89ef9a 100644 --- a/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp +++ b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp @@ -862,7 +862,7 @@ Size2 RasterizerStorageRD::texture_size_with_proxy(RID p_proxy) { RID RasterizerStorageRD::shader_create() { Shader shader; - shader.data = NULL; + shader.data = nullptr; shader.type = SHADER_TYPE_MAX; return shader_owner.make_rid(shader); @@ -890,7 +890,7 @@ void RasterizerStorageRD::shader_set_code(RID p_shader, const String &p_code) { if (new_type != shader->type) { if (shader->data) { memdelete(shader->data); - shader->data = NULL; + shader->data = nullptr; } for (Set<Material *>::Element *E = shader->owners.front(); E; E = E->next()) { @@ -899,7 +899,7 @@ void RasterizerStorageRD::shader_set_code(RID p_shader, const String &p_code) { material->shader_type = new_type; if (material->data) { memdelete(material->data); - material->data = NULL; + material->data = nullptr; } } @@ -991,10 +991,10 @@ void RasterizerStorageRD::shader_set_data_request_function(ShaderType p_shader_t RID RasterizerStorageRD::material_create() { Material material; - material.data = NULL; - material.shader = NULL; + material.data = nullptr; + material.shader = nullptr; material.shader_type = SHADER_TYPE_MAX; - material.update_next = NULL; + material.update_next = nullptr; material.update_requested = false; material.uniform_dirty = false; material.texture_dirty = false; @@ -1026,12 +1026,12 @@ void RasterizerStorageRD::material_set_shader(RID p_material, RID p_shader) { if (material->data) { memdelete(material->data); - material->data = NULL; + material->data = nullptr; } if (material->shader) { material->shader->owners.erase(material); - material->shader = NULL; + material->shader = nullptr; material->shader_type = SHADER_TYPE_MAX; } @@ -1050,7 +1050,7 @@ void RasterizerStorageRD::material_set_shader(RID p_material, RID p_shader) { return; } - ERR_FAIL_COND(shader->data == NULL); + ERR_FAIL_COND(shader->data == nullptr); material->data = material_data_request_func[shader->type](shader->data); material->data->set_next_pass(material->next_pass); @@ -1770,10 +1770,10 @@ void RasterizerStorageRD::_update_queued_materials() { material->update_requested = false; material->texture_dirty = false; material->uniform_dirty = false; - material->update_next = NULL; + material->update_next = nullptr; material = next; } - material_update_list = NULL; + material_update_list = nullptr; } /* MESH API */ @@ -4453,10 +4453,10 @@ String RasterizerStorageRD::get_captured_timestamp_name(uint32_t p_index) const RasterizerStorageRD::RasterizerStorageRD() { for (int i = 0; i < SHADER_TYPE_MAX; i++) { - shader_data_request_func[i] = NULL; + shader_data_request_func[i] = nullptr; } - material_update_list = NULL; + material_update_list = nullptr; { //create default textures RD::TextureFormat tformat; diff --git a/servers/rendering/rasterizer_rd/rasterizer_storage_rd.h b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.h index ab02ca1331..49f77e49e1 100644 --- a/servers/rendering/rasterizer_rd/rasterizer_storage_rd.h +++ b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.h @@ -604,7 +604,7 @@ public: _FORCE_INLINE_ MaterialData *material_get_data(RID p_material, ShaderType p_shader_type) { Material *material = material_owner.getornull(p_material); if (!material || material->shader_type != p_shader_type) { - return NULL; + return nullptr; } else { return material->data; } @@ -640,10 +640,10 @@ public: _FORCE_INLINE_ const RID *mesh_get_surface_count_and_materials(RID p_mesh, uint32_t &r_surface_count) { Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh, NULL); + ERR_FAIL_COND_V(!mesh, nullptr); r_surface_count = mesh->surface_count; if (r_surface_count == 0) { - return NULL; + return nullptr; } if (mesh->material_cache.empty()) { mesh->material_cache.resize(mesh->surface_count); @@ -1037,7 +1037,7 @@ public: void lightmap_capture_set_energy(RID p_capture, float p_energy) {} float lightmap_capture_get_energy(RID p_capture) const { return 0.0; } const Vector<LightmapCaptureOctree> *lightmap_capture_get_octree_ptr(RID p_capture) const { - return NULL; + return nullptr; } /* PARTICLES */ diff --git a/servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp b/servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp index 4ee020aa69..2bfdb7fffe 100644 --- a/servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp +++ b/servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp @@ -57,7 +57,7 @@ void RenderPipelineVertexFormatCacheRD::_clear() { } version_count = 0; memfree(versions); - versions = NULL; + versions = nullptr; } } @@ -88,7 +88,7 @@ void RenderPipelineVertexFormatCacheRD::clear() { RenderPipelineVertexFormatCacheRD::RenderPipelineVertexFormatCacheRD() { version_count = 0; - versions = NULL; + versions = nullptr; input_mask = 0; } diff --git a/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp b/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp index b3a4b0ede8..4a0b4f02b1 100644 --- a/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp +++ b/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp @@ -303,7 +303,7 @@ void ShaderCompilerRD::_dump_function_deps(const SL::ShaderNode *p_node, const S _dump_function_deps(p_node, E->get(), p_func_code, r_to_add, added); - SL::FunctionNode *fnode = NULL; + SL::FunctionNode *fnode = nullptr; for (int i = 0; i < p_node->functions.size(); i++) { if (p_node->functions[i].name == E->get()) { @@ -572,7 +572,7 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge function = fnode; current_func_name = fnode->name; function_code[fnode->name] = _dump_node_code(fnode->body, p_level + 1, r_gen_code, p_actions, p_default_actions, p_assigning); - function = NULL; + function = nullptr; } //place functions in actual code @@ -605,7 +605,7 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge _dump_function_deps(pnode, fnode->name, function_code, r_gen_code.fragment_global, added_fragment); r_gen_code.light = function_code[light_name]; } - function = NULL; + function = nullptr; } //code+=dump_node_code(pnode->body,p_level); @@ -798,12 +798,12 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge else code = _mkid(anode->name); - if (anode->call_expression != NULL) { + if (anode->call_expression != nullptr) { code += "."; code += _dump_node_code(anode->call_expression, p_level, r_gen_code, p_actions, p_default_actions, p_assigning); } - if (anode->index_expression != NULL) { + if (anode->index_expression != nullptr) { code += "["; code += _dump_node_code(anode->index_expression, p_level, r_gen_code, p_actions, p_default_actions, p_assigning); code += "]"; @@ -1025,7 +1025,7 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge case SL::Node::TYPE_MEMBER: { SL::MemberNode *mnode = (SL::MemberNode *)p_node; code = _dump_node_code(mnode->owner, p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + "." + mnode->name; - if (mnode->index_expression != NULL) { + if (mnode->index_expression != nullptr) { code += "["; code += _dump_node_code(mnode->index_expression, p_level, r_gen_code, p_actions, p_default_actions, p_assigning); code += "]"; @@ -1048,7 +1048,7 @@ Error ShaderCompilerRD::compile(RS::ShaderMode p_mode, const String &p_code, Ide print_line(itos(i + 1) + " " + shader[i]); } - _err_print_error(NULL, p_path.utf8().get_data(), parser.get_error_line(), parser.get_error_text().utf8().get_data(), ERR_HANDLER_SHADER); + _err_print_error(nullptr, p_path.utf8().get_data(), parser.get_error_line(), parser.get_error_text().utf8().get_data(), ERR_HANDLER_SHADER); return err; } @@ -1066,7 +1066,7 @@ Error ShaderCompilerRD::compile(RS::ShaderMode p_mode, const String &p_code, Ide used_flag_pointers.clear(); shader = parser.get_shader(); - function = NULL; + function = nullptr; _dump_node_code(shader, 1, r_gen_code, *p_actions, actions, false); return OK; diff --git a/servers/rendering/rasterizer_rd/shader_rd.cpp b/servers/rendering/rasterizer_rd/shader_rd.cpp index 3dcfd0faf9..d60a58813e 100644 --- a/servers/rendering/rasterizer_rd/shader_rd.cpp +++ b/servers/rendering/rasterizer_rd/shader_rd.cpp @@ -191,7 +191,7 @@ RID ShaderRD::version_create() { version.dirty = true; version.valid = false; version.initialize_needed = true; - version.variants = NULL; + version.variants = nullptr; return version_owner.make_rid(version); } @@ -203,7 +203,7 @@ void ShaderRD::_clear_version(Version *p_version) { } memdelete_arr(p_version->variants); - p_version->variants = NULL; + p_version->variants = nullptr; } } @@ -394,7 +394,7 @@ void ShaderRD::_compile_version(Version *p_version) { } } memdelete_arr(p_version->variants); - p_version->variants = NULL; + p_version->variants = nullptr; return; } diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp index 3c1795161d..a3799b0e4d 100644 --- a/servers/rendering/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -30,14 +30,14 @@ #include "rendering_device.h" -RenderingDevice *RenderingDevice::singleton = NULL; +RenderingDevice *RenderingDevice::singleton = nullptr; RenderingDevice *RenderingDevice::get_singleton() { return singleton; } -RenderingDevice::ShaderCompileFunction RenderingDevice::compile_function = NULL; -RenderingDevice::ShaderCacheFunction RenderingDevice::cache_function = NULL; +RenderingDevice::ShaderCompileFunction RenderingDevice::compile_function = nullptr; +RenderingDevice::ShaderCacheFunction RenderingDevice::cache_function = nullptr; void RenderingDevice::shader_set_compile_function(ShaderCompileFunction p_function) { compile_function = p_function; diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h index 4705bcaa75..a639ff3641 100644 --- a/servers/rendering/rendering_device.h +++ b/servers/rendering/rendering_device.h @@ -563,7 +563,7 @@ public: /**** SHADER ****/ /****************/ - virtual Vector<uint8_t> shader_compile_from_source(ShaderStage p_stage, const String &p_source_code, ShaderLanguage p_language = SHADER_LANGUAGE_GLSL, String *r_error = NULL, bool p_allow_cache = true); + virtual Vector<uint8_t> shader_compile_from_source(ShaderStage p_stage, const String &p_source_code, ShaderLanguage p_language = SHADER_LANGUAGE_GLSL, String *r_error = nullptr, bool p_allow_cache = true); static void shader_set_compile_function(ShaderCompileFunction p_function); static void shader_set_cache_function(ShaderCacheFunction p_function); diff --git a/servers/rendering/rendering_server_canvas.cpp b/servers/rendering/rendering_server_canvas.cpp index 261bd4c275..5d6dcfd2c1 100644 --- a/servers/rendering/rendering_server_canvas.cpp +++ b/servers/rendering/rendering_server_canvas.cpp @@ -43,14 +43,14 @@ void RenderingServerCanvas::_render_canvas_item_tree(RID p_to_render_target, Can memset(z_last_list, 0, z_range * sizeof(RasterizerCanvas::Item *)); for (int i = 0; i < p_child_item_count; i++) { - _cull_canvas_item(p_child_items[i].item, p_transform, p_clip_rect, Color(1, 1, 1, 1), 0, z_list, z_last_list, NULL, NULL); + _cull_canvas_item(p_child_items[i].item, p_transform, p_clip_rect, Color(1, 1, 1, 1), 0, z_list, z_last_list, nullptr, nullptr); } if (p_canvas_item) { - _cull_canvas_item(p_canvas_item, p_transform, p_clip_rect, Color(1, 1, 1, 1), 0, z_list, z_last_list, NULL, NULL); + _cull_canvas_item(p_canvas_item, p_transform, p_clip_rect, Color(1, 1, 1, 1), 0, z_list, z_last_list, nullptr, nullptr); } - RasterizerCanvas::Item *list = NULL; - RasterizerCanvas::Item *list_end = NULL; + RasterizerCanvas::Item *list = nullptr; + RasterizerCanvas::Item *list_end = nullptr; for (int i = 0; i < z_range; i++) { if (!z_list[i]) @@ -78,7 +78,7 @@ void _collect_ysort_children(RenderingServerCanvas::Item *p_canvas_item, Transfo r_items[r_index] = child_items[i]; child_items[i]->ysort_xform = p_transform; child_items[i]->ysort_pos = p_transform.xform(child_items[i]->xform.elements[2]); - child_items[i]->material_owner = child_items[i]->use_parent_material ? p_material_owner : NULL; + child_items[i]->material_owner = child_items[i]->use_parent_material ? p_material_owner : nullptr; } r_index++; @@ -92,7 +92,7 @@ void _collect_ysort_children(RenderingServerCanvas::Item *p_canvas_item, Transfo void _mark_ysort_dirty(RenderingServerCanvas::Item *ysort_owner, RID_PtrOwner<RenderingServerCanvas::Item> &canvas_item_owner) { do { ysort_owner->ysort_children_count = -1; - ysort_owner = canvas_item_owner.owns(ysort_owner->parent) ? canvas_item_owner.getornull(ysort_owner->parent) : NULL; + ysort_owner = canvas_item_owner.owns(ysort_owner->parent) ? canvas_item_owner.getornull(ysort_owner->parent) : nullptr; } while (ysort_owner && ysort_owner->sort_y); } @@ -118,7 +118,7 @@ void RenderingServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transfo ci->material_owner = p_material_owner; else { p_material_owner = ci; - ci->material_owner = NULL; + ci->material_owner = nullptr; } Color modulate(ci->modulate.r * p_modulate.r, ci->modulate.g * p_modulate.g, ci->modulate.b * p_modulate.b, ci->modulate.a * p_modulate.a); @@ -130,7 +130,7 @@ void RenderingServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transfo Item **child_items = ci->child_items.ptrw(); if (ci->clip) { - if (p_canvas_clip != NULL) { + if (p_canvas_clip != nullptr) { ci->final_clip_rect = p_canvas_clip->final_clip_rect.clip(global_rect); } else { ci->final_clip_rect = global_rect; @@ -145,7 +145,7 @@ void RenderingServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transfo if (ci->ysort_children_count == -1) { ci->ysort_children_count = 0; - _collect_ysort_children(ci, Transform2D(), p_material_owner, NULL, ci->ysort_children_count); + _collect_ysort_children(ci, Transform2D(), p_material_owner, nullptr, ci->ysort_children_count); } child_item_count = ci->ysort_children_count; @@ -183,7 +183,7 @@ void RenderingServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transfo RenderingServerRaster::redraw_request(); } - if ((ci->commands != NULL && p_clip_rect.intersects(global_rect, true)) || ci->vp_render || ci->copy_back_buffer) { + if ((ci->commands != nullptr && p_clip_rect.intersects(global_rect, true)) || ci->vp_render || ci->copy_back_buffer) { //something to draw? ci->final_transform = xform; ci->final_modulate = Color(modulate.r * ci->self_modulate.r, modulate.g * ci->self_modulate.g, modulate.b * ci->self_modulate.b, modulate.a * ci->self_modulate.a); @@ -204,7 +204,7 @@ void RenderingServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transfo ci->z_final = p_z; - ci->next = NULL; + ci->next = nullptr; } for (int i = 0; i < child_item_count; i++) { @@ -265,30 +265,30 @@ void RenderingServerCanvas::render_canvas(RID p_render_target, Canvas *p_canvas, if (!has_mirror) { - _render_canvas_item_tree(p_render_target, ci, l, NULL, p_transform, p_clip_rect, p_canvas->modulate, p_lights); + _render_canvas_item_tree(p_render_target, ci, l, nullptr, p_transform, p_clip_rect, p_canvas->modulate, p_lights); } else { //used for parallaxlayer mirroring for (int i = 0; i < l; i++) { const Canvas::ChildItem &ci2 = p_canvas->child_items[i]; - _render_canvas_item_tree(p_render_target, NULL, 0, ci2.item, p_transform, p_clip_rect, p_canvas->modulate, p_lights); + _render_canvas_item_tree(p_render_target, nullptr, 0, ci2.item, p_transform, p_clip_rect, p_canvas->modulate, p_lights); //mirroring (useful for scrolling backgrounds) if (ci2.mirror.x != 0) { Transform2D xform2 = p_transform * Transform2D(0, Vector2(ci2.mirror.x, 0)); - _render_canvas_item_tree(p_render_target, NULL, 0, ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights); + _render_canvas_item_tree(p_render_target, nullptr, 0, ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights); } if (ci2.mirror.y != 0) { Transform2D xform2 = p_transform * Transform2D(0, Vector2(0, ci2.mirror.y)); - _render_canvas_item_tree(p_render_target, NULL, 0, ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights); + _render_canvas_item_tree(p_render_target, nullptr, 0, ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights); } if (ci2.mirror.y != 0 && ci2.mirror.x != 0) { Transform2D xform2 = p_transform * Transform2D(0, ci2.mirror); - _render_canvas_item_tree(p_render_target, NULL, 0, ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights); + _render_canvas_item_tree(p_render_target, nullptr, 0, ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights); } } } @@ -946,12 +946,12 @@ void RenderingServerCanvas::canvas_item_set_copy_to_backbuffer(RID p_item, bool Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); - if (bool(canvas_item->copy_back_buffer != NULL) != p_enable) { + if (bool(canvas_item->copy_back_buffer != nullptr) != p_enable) { if (p_enable) { canvas_item->copy_back_buffer = memnew(RasterizerCanvas::Item::CopyBackBuffer); } else { memdelete(canvas_item->copy_back_buffer); - canvas_item->copy_back_buffer = NULL; + canvas_item->copy_back_buffer = nullptr; } } diff --git a/servers/rendering/rendering_server_canvas.h b/servers/rendering/rendering_server_canvas.h index c79b74f287..9da11462db 100644 --- a/servers/rendering/rendering_server_canvas.h +++ b/servers/rendering/rendering_server_canvas.h @@ -59,7 +59,7 @@ public: Item() { children_order_dirty = true; - E = NULL; + E = nullptr; z_index = 0; modulate = Color(1, 1, 1, 1); self_modulate = Color(1, 1, 1, 1); diff --git a/servers/rendering/rendering_server_globals.cpp b/servers/rendering/rendering_server_globals.cpp index 251cf64184..5a270520a9 100644 --- a/servers/rendering/rendering_server_globals.cpp +++ b/servers/rendering/rendering_server_globals.cpp @@ -30,11 +30,11 @@ #include "rendering_server_globals.h" -RasterizerStorage *RenderingServerGlobals::storage = NULL; -RasterizerCanvas *RenderingServerGlobals::canvas_render = NULL; -RasterizerScene *RenderingServerGlobals::scene_render = NULL; -Rasterizer *RenderingServerGlobals::rasterizer = NULL; +RasterizerStorage *RenderingServerGlobals::storage = nullptr; +RasterizerCanvas *RenderingServerGlobals::canvas_render = nullptr; +RasterizerScene *RenderingServerGlobals::scene_render = nullptr; +Rasterizer *RenderingServerGlobals::rasterizer = nullptr; -RenderingServerCanvas *RenderingServerGlobals::canvas = NULL; -RenderingServerViewport *RenderingServerGlobals::viewport = NULL; -RenderingServerScene *RenderingServerGlobals::scene = NULL; +RenderingServerCanvas *RenderingServerGlobals::canvas = nullptr; +RenderingServerViewport *RenderingServerGlobals::viewport = nullptr; +RenderingServerScene *RenderingServerGlobals::scene = nullptr; diff --git a/servers/rendering/rendering_server_scene.cpp b/servers/rendering/rendering_server_scene.cpp index 04e4b8dace..65823e11aa 100644 --- a/servers/rendering/rendering_server_scene.cpp +++ b/servers/rendering/rendering_server_scene.cpp @@ -194,7 +194,7 @@ void *RenderingServerScene::_instance_pair(void *p_self, OctreeElementID, Instan return gi_probe->lights.insert(A); } - return NULL; + return nullptr; } void RenderingServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int, void *udata) { @@ -375,7 +375,7 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) { #endif if (instance->scenario && light->D) { instance->scenario->directional_lights.erase(light->D); - light->D = NULL; + light->D = nullptr; } RSG::scene_render->free(light->instance); } break; @@ -416,7 +416,7 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) { Instance *capture = (Instance *)instance->lightmap_capture; InstanceLightmapCaptureData *lightmap_capture = static_cast<InstanceLightmapCaptureData *>(capture->base_data); lightmap_capture->users.erase(instance); - instance->lightmap_capture = NULL; + instance->lightmap_capture = nullptr; instance->lightmap = RID(); } @@ -429,7 +429,7 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) { if (instance->base_data) { memdelete(instance->base_data); - instance->base_data = NULL; + instance->base_data = nullptr; } instance->blend_values.clear(); @@ -533,7 +533,7 @@ void RenderingServerScene::instance_set_scenario(RID p_instance, RID p_scenario) #endif if (light->D) { instance->scenario->directional_lights.erase(light->D); - light->D = NULL; + light->D = nullptr; } } break; case RS::INSTANCE_REFLECTION_PROBE: { @@ -564,7 +564,7 @@ void RenderingServerScene::instance_set_scenario(RID p_instance, RID p_scenario) } } - instance->scenario = NULL; + instance->scenario = nullptr; } if (p_scenario.is_valid()) { @@ -720,7 +720,7 @@ void RenderingServerScene::instance_set_use_lightmap(RID p_instance, RID p_light InstanceLightmapCaptureData *lightmap_capture = static_cast<InstanceLightmapCaptureData *>(((Instance *)instance->lightmap_capture)->base_data); lightmap_capture->users.erase(instance); instance->lightmap = RID(); - instance->lightmap_capture = NULL; + instance->lightmap_capture = nullptr; } if (p_lightmap_instance.is_valid()) { @@ -744,16 +744,16 @@ void RenderingServerScene::instance_set_custom_aabb(RID p_instance, AABB p_aabb) if (p_aabb != AABB()) { // Set custom AABB - if (instance->custom_aabb == NULL) + if (instance->custom_aabb == nullptr) instance->custom_aabb = memnew(AABB); *instance->custom_aabb = p_aabb; } else { // Clear custom AABB - if (instance->custom_aabb != NULL) { + if (instance->custom_aabb != nullptr) { memdelete(instance->custom_aabb); - instance->custom_aabb = NULL; + instance->custom_aabb = nullptr; } } @@ -2259,7 +2259,7 @@ void RenderingServerScene::render_empty_scene(RID p_render_buffers, RID p_scenar else environment = scenario->fallback_environment; RENDER_TIMESTAMP("Render Empty Scene "); - RSG::scene_render->render_scene(p_render_buffers, Transform(), CameraMatrix(), true, NULL, 0, NULL, 0, NULL, 0, NULL, 0, environment, RID(), p_shadow_atlas, scenario->reflection_atlas, RID(), 0); + RSG::scene_render->render_scene(p_render_buffers, Transform(), CameraMatrix(), true, nullptr, 0, nullptr, 0, nullptr, 0, nullptr, 0, environment, RID(), p_shadow_atlas, scenario->reflection_atlas, RID(), 0); #endif } @@ -2827,7 +2827,7 @@ bool RenderingServerScene::free(RID p_rid) { return true; } -RenderingServerScene *RenderingServerScene::singleton = NULL; +RenderingServerScene *RenderingServerScene::singleton = nullptr; RenderingServerScene::RenderingServerScene() { diff --git a/servers/rendering/rendering_server_scene.h b/servers/rendering/rendering_server_scene.h index 9e09136216..41641b7c75 100644 --- a/servers/rendering/rendering_server_scene.h +++ b/servers/rendering/rendering_server_scene.h @@ -196,7 +196,7 @@ public: update_item(this) { octree_id = 0; - scenario = NULL; + scenario = nullptr; update_aabb = false; update_dependencies = false; @@ -213,9 +213,9 @@ public: last_render_pass = 0; last_frame_pass = 0; version = 1; - base_data = NULL; + base_data = nullptr; - custom_aabb = NULL; + custom_aabb = nullptr; } ~Instance() { @@ -301,9 +301,9 @@ public: InstanceLightData() { shadow_dirty = true; - D = NULL; + D = nullptr; last_version = 0; - baked_light = NULL; + baked_light = nullptr; } }; diff --git a/servers/rendering/rendering_server_viewport.cpp b/servers/rendering/rendering_server_viewport.cpp index f80b914760..aa65101ddf 100644 --- a/servers/rendering/rendering_server_viewport.cpp +++ b/servers/rendering/rendering_server_viewport.cpp @@ -67,7 +67,7 @@ void RenderingServerViewport::_draw_3d(Viewport *p_viewport, ARVRInterface::Eyes RENDER_TIMESTAMP(">Begin Rendering 3D Scene"); Ref<ARVRInterface> arvr_interface; - if (ARVRServer::get_singleton() != NULL) { + if (ARVRServer::get_singleton() != nullptr) { arvr_interface = ARVRServer::get_singleton()->get_primary_interface(); } @@ -128,9 +128,9 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface Map<Viewport::CanvasKey, Viewport::CanvasData *> canvas_map; Rect2 clip_rect(0, 0, p_viewport->size.x, p_viewport->size.y); - RasterizerCanvas::Light *lights = NULL; - RasterizerCanvas::Light *lights_with_shadow = NULL; - RasterizerCanvas::Light *lights_with_mask = NULL; + RasterizerCanvas::Light *lights = nullptr; + RasterizerCanvas::Light *lights_with_shadow = nullptr; + RasterizerCanvas::Light *lights_with_mask = nullptr; Rect2 shadow_rect; int light_count = 0; @@ -160,7 +160,7 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface cl->filter_next_ptr = lights; lights = cl; - // cl->texture_cache = NULL; + // cl->texture_cache = nullptr; Transform2D scale; scale.scale(cl->rect_cache.size); scale.elements[2] = cl->rect_cache.position; @@ -169,7 +169,7 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface if (cl->use_shadow) { cl->shadows_next_ptr = lights_with_shadow; - if (lights_with_shadow == NULL) { + if (lights_with_shadow == nullptr) { shadow_rect = cl->xform_cache.xform(cl->rect_cache); } else { shadow_rect = shadow_rect.merge(cl->xform_cache.xform(cl->rect_cache)); @@ -196,7 +196,7 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface if (lights_with_shadow) { //update shadows if any - RasterizerCanvas::LightOccluderInstance *occluders = NULL; + RasterizerCanvas::LightOccluderInstance *occluders = nullptr; RENDER_TIMESTAMP(">Render 2D Shadows"); RENDER_TIMESTAMP("Cull Occluders"); @@ -249,7 +249,7 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface Transform2D xform = _canvas_get_transform(p_viewport, canvas, E->get(), clip_rect.size); - RasterizerCanvas::Light *canvas_lights = NULL; + RasterizerCanvas::Light *canvas_lights = nullptr; RasterizerCanvas::Light *ptr = lights; while (ptr) { @@ -297,7 +297,7 @@ void RenderingServerViewport::draw_viewports() { // get our arvr interface in case we need it Ref<ARVRInterface> arvr_interface; - if (ARVRServer::get_singleton() != NULL) { + if (ARVRServer::get_singleton() != nullptr) { arvr_interface = ARVRServer::get_singleton()->get_primary_interface(); // process all our active interfaces diff --git a/servers/rendering/rendering_server_wrap_mt.cpp b/servers/rendering/rendering_server_wrap_mt.cpp index 5d6d523901..aa3bf583c7 100644 --- a/servers/rendering/rendering_server_wrap_mt.cpp +++ b/servers/rendering/rendering_server_wrap_mt.cpp @@ -132,7 +132,7 @@ void RenderingServerWrapMT::finish() { Thread::wait_to_finish(thread); memdelete(thread); - thread = NULL; + thread = nullptr; } else { rendering_server->finish(); } @@ -168,7 +168,7 @@ void RenderingServerWrapMT::set_use_vsync_callback(bool p_enable) { singleton_mt->call_set_use_vsync(p_enable); } -RenderingServerWrapMT *RenderingServerWrapMT::singleton_mt = NULL; +RenderingServerWrapMT *RenderingServerWrapMT::singleton_mt = nullptr; RenderingServerWrapMT::RenderingServerWrapMT(RenderingServer *p_contained, bool p_create_thread) : command_queue(p_create_thread) { @@ -178,7 +178,7 @@ RenderingServerWrapMT::RenderingServerWrapMT(RenderingServer *p_contained, bool rendering_server = p_contained; create_thread = p_create_thread; - thread = NULL; + thread = nullptr; draw_pending = 0; draw_thread_up = false; pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc"); diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 300c38db22..76a81a4a1c 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -328,7 +328,7 @@ const ShaderLanguage::KeyWord ShaderLanguage::keyword_list[] = { { TK_REPEAT_ENABLE, "repeat_enable" }, { TK_REPEAT_DISABLE, "repeat_disable" }, { TK_SHADER_TYPE, "shader_type" }, - { TK_ERROR, NULL } + { TK_ERROR, nullptr } }; ShaderLanguage::Token ShaderLanguage::_get_token() { @@ -879,7 +879,7 @@ void ShaderLanguage::clear() { current_function = StringName(); completion_type = COMPLETION_NONE; - completion_block = NULL; + completion_block = nullptr; completion_function = StringName(); completion_class = SubClassTag::TAG_GLOBAL; completion_struct = StringName(); @@ -913,7 +913,7 @@ bool ShaderLanguage::_find_identifier(const BlockNode *p_block, bool p_allow_rea return true; } - FunctionNode *function = NULL; + FunctionNode *function = nullptr; while (p_block) { @@ -2107,14 +2107,14 @@ const ShaderLanguage::BuiltinFuncDef ShaderLanguage::builtin_func_defs[] = { //array { "length", TYPE_INT, { TYPE_VOID }, TAG_ARRAY, true }, - { NULL, TYPE_VOID, { TYPE_VOID }, TAG_GLOBAL, false } + { nullptr, TYPE_VOID, { TYPE_VOID }, TAG_GLOBAL, false } }; const ShaderLanguage::BuiltinFuncOutArgs ShaderLanguage::builtin_func_out_args[] = { //constructors { "modf", 1 }, - { NULL, 0 } + { nullptr, 0 } }; bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types, OperatorNode *p_func, DataType *r_ret_type, StringName *r_ret_type_str) { @@ -3150,7 +3150,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons while (true) { - Node *expr = NULL; + Node *expr = nullptr; TkPos prepos = _get_tkpos(); Token tk = _get_token(); TkPos pos = _get_tkpos(); @@ -3162,14 +3162,14 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons expr = _parse_and_reduce_expression(p_block, p_builtin_types); if (!expr) - return NULL; + return nullptr; tk = _get_token(); if (tk.type != TK_PARENTHESIS_CLOSE) { _set_error("Expected ')' in expression"); - return NULL; + return nullptr; } } else if (tk.type == TK_REAL_CONSTANT) { @@ -3214,7 +3214,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons //make sure void is not used in expression _set_error("Void value not allowed in Expression"); - return NULL; + return nullptr; } else if (is_token_nonvoid_datatype(tk.type)) { //basic type constructor @@ -3234,7 +3234,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons tk = _get_token(); if (tk.type != TK_PARENTHESIS_OPEN) { _set_error("Expected '(' after type name"); - return NULL; + return nullptr; } int carg = -1; @@ -3250,11 +3250,11 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } if (!ok) - return NULL; + return nullptr; if (!_validate_function_call(p_block, p_builtin_types, func, &func->return_cache, &func->struct_name)) { _set_error("No matching constructor found for: '" + String(funcname->name) + "'"); - return NULL; + return nullptr; } expr = _reduce_expression(p_block, func); @@ -3265,7 +3265,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons StringName identifier; - StructNode *pstruct = NULL; + StructNode *pstruct = nullptr; bool struct_init = false; _get_completable_identifier(p_block, COMPLETION_IDENTIFIER, identifier); @@ -3317,7 +3317,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } else { if (!is_token_variable_datatype(tk.type)) { _set_error("Invalid data type for array"); - return NULL; + return nullptr; } type2 = get_token_datatype(tk.type); } @@ -3335,7 +3335,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons Node *n = _parse_and_reduce_expression(p_block, p_builtin_types); if (!n || n->type != Node::TYPE_CONSTANT || n->get_datatype() != TYPE_INT) { _set_error("Expected single integer constant > 0"); - return NULL; + return nullptr; } ConstantNode *cnode = (ConstantNode *)n; @@ -3343,24 +3343,24 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons array_size2 = cnode->values[0].sint; if (array_size2 <= 0) { _set_error("Expected single integer constant > 0"); - return NULL; + return nullptr; } } else { _set_error("Expected single integer constant > 0"); - return NULL; + return nullptr; } tk = _get_token(); if (tk.type != TK_BRACKET_CLOSE) { _set_error("Expected ']'"); - return NULL; + return nullptr; } else { tk = _get_token(); } } } else { _set_error("Expected '['"); - return NULL; + return nullptr; } if (type != type2 || struct_name != struct_name2 || array_size != array_size2) { @@ -3383,7 +3383,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons error_str += itos(array_size); error_str += "]'"; _set_error(error_str); - return NULL; + return nullptr; } } @@ -3396,12 +3396,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons Node *n = _parse_and_reduce_expression(p_block, p_builtin_types); if (!n) { - return NULL; + return nullptr; } if (type != n->get_datatype() || struct_name != n->get_datatype_name()) { _set_error("Invalid assignment of '" + (n->get_datatype() == TYPE_STRUCT ? n->get_datatype_name() : get_datatype_name(n->get_datatype())) + "' to '" + (type == TYPE_STRUCT ? struct_name : get_datatype_name(type)) + "'"); - return NULL; + return nullptr; } tk = _get_token(); @@ -3419,30 +3419,30 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons _set_error("Expected '}' or ','"); else _set_error("Expected ')' or ','"); - return NULL; + return nullptr; } } if (an->initializer.size() != array_size) { _set_error("Array size mismatch"); - return NULL; + return nullptr; } } else { _set_error("Expected array initialization!"); - return NULL; + return nullptr; } nexpr = an; } else { nexpr = _parse_and_reduce_expression(p_block, p_builtin_types); if (!nexpr) { - return NULL; + return nullptr; } Node *node = pstruct->members[i]; if (!_compare_datatypes_in_nodes(pstruct->members[i], nexpr)) { String type_name = nexpr->get_datatype() == TYPE_STRUCT ? nexpr->get_datatype_name() : get_datatype_name(nexpr->get_datatype()); String type_name2 = node->get_datatype() == TYPE_STRUCT ? node->get_datatype_name() : get_datatype_name(node->get_datatype()); _set_error("Invalid assignment of '" + type_name + "' to '" + type_name2 + "'"); - return NULL; + return nullptr; } } @@ -3450,7 +3450,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons tk = _get_token(); if (tk.type != TK_COMMA) { _set_error("Expected ','"); - return NULL; + return nullptr; } } func->arguments.push_back(nexpr); @@ -3458,7 +3458,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons tk = _get_token(); if (tk.type != TK_PARENTHESIS_CLOSE) { _set_error("Expected ')'"); - return NULL; + return nullptr; } expr = func; @@ -3482,7 +3482,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons while (bnode) { if (bnode->variables.has(name)) { _set_error("Expected function name"); - return NULL; + return nullptr; } bnode = bnode->parent_block; } @@ -3514,11 +3514,11 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } if (!ok) - return NULL; + return nullptr; if (!_validate_function_call(p_block, p_builtin_types, func, &func->return_cache, &func->struct_name)) { _set_error("No matching function found for: '" + String(funcname->name) + "'"); - return NULL; + return nullptr; } completion_class = TAG_GLOBAL; // reset sub-class if (function_index >= 0) { @@ -3529,7 +3529,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (call_function) { //get current base function - FunctionNode *base_function = NULL; + FunctionNode *base_function = nullptr; { BlockNode *b = p_block; @@ -3544,7 +3544,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } } - ERR_FAIL_COND_V(!base_function, NULL); //bug, wtf + ERR_FAIL_COND_V(!base_function, nullptr); //bug, wtf for (int i = 0; i < call_function->arguments.size(); i++) { int argidx = i + 1; @@ -3556,7 +3556,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons error = true; } else if (n->type == Node::TYPE_ARRAY) { ArrayNode *an = static_cast<ArrayNode *>(n); - if (an->call_expression != NULL) { + if (an->call_expression != nullptr) { error = true; } } else if (n->type == Node::TYPE_VARIABLE) { @@ -3584,7 +3584,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } if (error) { _set_error(vformat("Constant value cannot be passed for '%s' parameter!", _get_qualifier_str(call_function->arguments[i].qualifier))); - return NULL; + return nullptr; } } if (is_sampler_type(call_function->arguments[i].type)) { @@ -3599,12 +3599,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons ERR_CONTINUE(u->type != call_function->arguments[i].type); //this should have been validated previously //propagate if (!_propagate_function_call_sampler_uniform_settings(name, i, u->filter, u->repeat)) { - return NULL; + return nullptr; } } else if (p_builtin_types.has(varname)) { //a built-in if (!_propagate_function_call_sampler_builtin_reference(name, i, varname)) { - return NULL; + return nullptr; } } else { //or this comes from an argument, but nothing else can be a sampler @@ -3653,30 +3653,30 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } if (!found) { _set_error("Unknown identifier in expression: " + String(identifier)); - return NULL; + return nullptr; } } else { if (!_find_identifier(p_block, false, p_builtin_types, identifier, &data_type, &ident_type, &is_const, &array_size, &struct_name)) { _set_error("Unknown identifier in expression: " + String(identifier)); - return NULL; + return nullptr; } if (ident_type == IDENTIFIER_FUNCTION) { _set_error("Can't use function as identifier: " + String(identifier)); - return NULL; + return nullptr; } } - Node *index_expression = NULL; - Node *call_expression = NULL; + Node *index_expression = nullptr; + Node *call_expression = nullptr; if (array_size > 0) { tk = _get_token(); if (tk.type != TK_BRACKET_OPEN && tk.type != TK_PERIOD) { _set_error("Expected '[' or '.'"); - return NULL; + return nullptr; } if (tk.type == TK_PERIOD) { @@ -3685,17 +3685,17 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons call_expression = _parse_and_reduce_expression(p_block, p_builtin_types); p_block->block_tag = SubClassTag::TAG_GLOBAL; if (!call_expression) - return NULL; + return nullptr; data_type = call_expression->get_datatype(); } else { // indexing index_expression = _parse_and_reduce_expression(p_block, p_builtin_types); if (!index_expression) - return NULL; + return nullptr; if (index_expression->get_datatype() != TYPE_INT && index_expression->get_datatype() != TYPE_UINT) { _set_error("Only integer expressions are allowed for indexing"); - return NULL; + return nullptr; } if (index_expression->type == Node::TYPE_CONSTANT) { @@ -3705,7 +3705,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons int value = cnode->values[0].sint; if (value < 0 || value >= array_size) { _set_error(vformat("Index [%s] out of range [%s..%s]", value, 0, array_size - 1)); - return NULL; + return nullptr; } } } @@ -3714,7 +3714,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons tk = _get_token(); if (tk.type != TK_BRACKET_CLOSE) { _set_error("Expected ']'"); - return NULL; + return nullptr; } } @@ -3750,18 +3750,18 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons case TK_OP_BIT_INVERT: e.op = OP_BIT_INVERT; break; case TK_OP_INCREMENT: e.op = OP_INCREMENT; break; case TK_OP_DECREMENT: e.op = OP_DECREMENT; break; - default: ERR_FAIL_V(NULL); + default: ERR_FAIL_V(nullptr); } expression.push_back(e); continue; } else { _set_error("Expected expression, found: " + get_token_text(tk)); - return NULL; + return nullptr; //nothing } - ERR_FAIL_COND_V(!expr, NULL); + ERR_FAIL_COND_V(!expr, nullptr); /* OK now see what's NEXT to the operator.. */ /* OK now see what's NEXT to the operator.. */ @@ -3791,7 +3791,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (identifier == StringName()) { _set_error("Expected identifier as member"); - return NULL; + return nullptr; } String ident = identifier; @@ -4042,12 +4042,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (mix_error) { _set_error("Cannot combine symbols from different sets in expression ." + ident); - return NULL; + return nullptr; } if (!ok) { _set_error("Invalid member for " + (dt == TYPE_STRUCT ? st : get_datatype_name(dt)) + " expression: ." + ident); - return NULL; + return nullptr; } MemberNode *mn = alloc_node<MemberNode>(); @@ -4066,16 +4066,16 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons tk = _get_token(); if (tk.type == TK_PERIOD) { _set_error("Nested array length() is not yet implemented"); - return NULL; + return nullptr; } else if (tk.type == TK_BRACKET_OPEN) { Node *index_expression = _parse_and_reduce_expression(p_block, p_builtin_types); if (!index_expression) - return NULL; + return nullptr; if (index_expression->get_datatype() != TYPE_INT && index_expression->get_datatype() != TYPE_UINT) { _set_error("Only integer expressions are allowed for indexing"); - return NULL; + return nullptr; } if (index_expression->type == Node::TYPE_CONSTANT) { @@ -4085,7 +4085,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons int value = cnode->values[0].sint; if (value < 0 || value >= array_size) { _set_error(vformat("Index [%s] out of range [%s..%s]", value, 0, array_size - 1)); - return NULL; + return nullptr; } } } @@ -4094,13 +4094,13 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons tk = _get_token(); if (tk.type != TK_BRACKET_CLOSE) { _set_error("Expected ']'"); - return NULL; + return nullptr; } mn->index_expression = index_expression; } else { _set_error("Expected '[' or '.'"); - return NULL; + return nullptr; } } @@ -4120,11 +4120,11 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons Node *index = _parse_and_reduce_expression(p_block, p_builtin_types); if (!index) - return NULL; + return nullptr; if (index->get_datatype() != TYPE_INT && index->get_datatype() != TYPE_UINT) { _set_error("Only integer datatypes are allowed for indexing"); - return NULL; + return nullptr; } DataType member_type = TYPE_VOID; @@ -4139,7 +4139,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint; if (index_constant >= 2) { _set_error("Index out of range (0-1)"); - return NULL; + return nullptr; } } @@ -4162,7 +4162,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint; if (index_constant >= 3) { _set_error("Index out of range (0-2)"); - return NULL; + return nullptr; } } @@ -4184,7 +4184,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint; if (index_constant >= 4) { _set_error("Index out of range (0-3)"); - return NULL; + return nullptr; } } @@ -4199,7 +4199,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons break; default: { _set_error("Object of type '" + (expr->get_datatype() == TYPE_STRUCT ? expr->get_datatype_name() : get_datatype_name(expr->get_datatype())) + "' can't be indexed"); - return NULL; + return nullptr; } } @@ -4213,7 +4213,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons tk = _get_token(); if (tk.type != TK_BRACKET_CLOSE) { _set_error("Expected ']' after indexing expression"); - return NULL; + return nullptr; } } else if (tk.type == TK_OP_INCREMENT || tk.type == TK_OP_DECREMENT) { @@ -4224,12 +4224,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (!_validate_operator(op, &op->return_cache)) { _set_error("Invalid base type for increment/decrement operator"); - return NULL; + return nullptr; } if (!_validate_assign(expr, p_builtin_types)) { _set_error("Invalid use of increment/decrement operator in constant expression."); - return NULL; + return nullptr; } expr = op; } else { @@ -4287,7 +4287,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons case TK_COLON: o.op = OP_SELECT_ELSE; break; default: { _set_error("Invalid token for operator: " + get_token_text(tk)); - return NULL; + return nullptr; } } @@ -4379,7 +4379,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons break; default: - ERR_FAIL_V(NULL); //unexpected operator + ERR_FAIL_V(nullptr); //unexpected operator } if (priority < min_priority) { @@ -4392,7 +4392,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } } - ERR_FAIL_COND_V(next_op == -1, NULL); + ERR_FAIL_COND_V(next_op == -1, nullptr); // OK! create operator.. // OK! create operator.. @@ -4405,7 +4405,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (expr_pos == expression.size()) { //can happen.. _set_error("Unexpected end of expression..."); - return NULL; + return nullptr; } } @@ -4417,7 +4417,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if ((op->op == OP_INCREMENT || op->op == OP_DECREMENT) && !_validate_assign(expression[i + 1].node, p_builtin_types)) { _set_error("Can't use increment/decrement operator in constant expression."); - return NULL; + return nullptr; } op->arguments.push_back(expression[i + 1].node); @@ -4433,7 +4433,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons at += get_datatype_name(op->arguments[j]->get_datatype()); } _set_error("Invalid arguments to unary operator '" + get_operator_text(op->op) + "' :" + at); - return NULL; + return nullptr; } expression.remove(i + 1); } @@ -4442,12 +4442,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (next_op < 1 || next_op >= (expression.size() - 1)) { _set_error("Parser bug..."); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } if (next_op + 2 >= expression.size() || !expression[next_op + 2].is_op || expression[next_op + 2].op != OP_SELECT_ELSE) { _set_error("Missing matching ':' for select operator"); - return NULL; + return nullptr; } OperatorNode *op = alloc_node<OperatorNode>(); @@ -4467,7 +4467,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons at += get_datatype_name(op->arguments[i]->get_datatype()); } _set_error("Invalid argument to ternary ?: operator: " + at); - return NULL; + return nullptr; } for (int i = 0; i < 4; i++) { @@ -4478,7 +4478,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (next_op < 1 || next_op >= (expression.size() - 1)) { _set_error("Parser bug..."); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } OperatorNode *op = alloc_node<OperatorNode>(); @@ -4487,7 +4487,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (expression[next_op - 1].is_op) { _set_error("Parser bug..."); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } if (_is_operator_assign(op->op)) { @@ -4496,7 +4496,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (!_validate_assign(expression[next_op - 1].node, p_builtin_types, &assign_message)) { _set_error(assign_message); - return NULL; + return nullptr; } } @@ -4528,7 +4528,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } } _set_error("Invalid arguments to operator '" + get_operator_text(op->op) + "' :" + at); - return NULL; + return nullptr; } expression.remove(next_op); @@ -4658,7 +4658,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_and_reduce_expression(BlockNode *p_ ShaderLanguage::Node *expr = _parse_expression(p_block, p_builtin_types); if (!expr) //errored - return NULL; + return nullptr; expr = _reduce_expression(p_block, expr); @@ -4741,7 +4741,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui tk = _get_token(); - Node *vardecl = NULL; + Node *vardecl = nullptr; while (true) { @@ -4752,7 +4752,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui StringName name = tk.text; ShaderLanguage::IdentifierType itype; - if (_find_identifier(p_block, true, p_builtin_types, name, (ShaderLanguage::DataType *)0, &itype)) { + if (_find_identifier(p_block, true, p_builtin_types, name, (ShaderLanguage::DataType *)nullptr, &itype)) { if (itype != IDENTIFIER_FUNCTION) { _set_error("Redefinition of '" + String(name) + "'"); return ERR_PARSE_ERROR; @@ -5025,7 +5025,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui VariableDeclarationNode::Declaration decl; decl.name = name; - decl.initializer = NULL; + decl.initializer = nullptr; //variable created with assignment! must parse an expression Node *n = _parse_and_reduce_expression(p_block, p_builtin_types); @@ -5061,7 +5061,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui VariableDeclarationNode::Declaration decl; decl.name = name; - decl.initializer = NULL; + decl.initializer = nullptr; node->declarations.push_back(decl); } @@ -5326,7 +5326,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui // while() {} bool is_do = tk.type == TK_CF_DO; - BlockNode *do_block = NULL; + BlockNode *do_block = nullptr; if (is_do) { do_block = alloc_node<BlockNode>(); @@ -5694,7 +5694,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct while (true) { StringName mode; - _get_completable_identifier(NULL, COMPLETION_RENDER_MODE, mode); + _get_completable_identifier(nullptr, COMPLETION_RENDER_MODE, mode); if (mode == StringName()) { _set_error("Expected identifier for render mode"); @@ -5898,7 +5898,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct name = tk.text; - if (_find_identifier(NULL, false, Map<StringName, BuiltInInfo>(), name)) { + if (_find_identifier(nullptr, false, Map<StringName, BuiltInInfo>(), name)) { _set_error("Redefinition of '" + String(name) + "'"); return ERR_PARSE_ERROR; } @@ -6074,7 +6074,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct if (tk.type == TK_OP_ASSIGN) { - Node *expr = _parse_and_reduce_expression(NULL, Map<StringName, BuiltInInfo>()); + Node *expr = _parse_and_reduce_expression(nullptr, Map<StringName, BuiltInInfo>()); if (!expr) return ERR_PARSE_ERROR; if (expr->type != Node::TYPE_CONSTANT) { @@ -6191,14 +6191,14 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct } _set_tkpos(prev_pos); - _get_completable_identifier(NULL, COMPLETION_MAIN_FUNCTION, name); + _get_completable_identifier(nullptr, COMPLETION_MAIN_FUNCTION, name); if (name == StringName()) { _set_error("Expected function name after datatype"); return ERR_PARSE_ERROR; } - if (_find_identifier(NULL, false, Map<StringName, BuiltInInfo>(), name)) { + if (_find_identifier(nullptr, false, Map<StringName, BuiltInInfo>(), name)) { _set_error("Redefinition of '" + String(name) + "'"); return ERR_PARSE_ERROR; } @@ -6222,7 +6222,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct constant.type = is_struct ? TYPE_STRUCT : type; constant.type_str = struct_name; constant.precision = precision; - constant.initializer = NULL; + constant.initializer = nullptr; if (tk.type == TK_OP_ASSIGN) { @@ -6232,7 +6232,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct } //variable created with assignment! must parse an expression - Node *expr = _parse_and_reduce_expression(NULL, Map<StringName, BuiltInInfo>()); + Node *expr = _parse_and_reduce_expression(nullptr, Map<StringName, BuiltInInfo>()); if (!expr) return ERR_PARSE_ERROR; if (expr->type == Node::TYPE_OPERATOR && ((OperatorNode *)expr)->op == OP_CALL) { @@ -6266,7 +6266,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct } name = tk.text; - if (_find_identifier(NULL, false, Map<StringName, BuiltInInfo>(), name)) { + if (_find_identifier(nullptr, false, Map<StringName, BuiltInInfo>(), name)) { _set_error("Redefinition of '" + String(name) + "'"); return ERR_PARSE_ERROR; } @@ -6405,7 +6405,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct pname = tk.text; ShaderLanguage::IdentifierType itype; - if (_find_identifier(func_node->body, false, builtin_types, pname, (ShaderLanguage::DataType *)0, &itype)) { + if (_find_identifier(func_node->body, false, builtin_types, pname, (ShaderLanguage::DataType *)nullptr, &itype)) { if (itype != IDENTIFIER_FUNCTION) { _set_error("Redefinition of '" + String(pname) + "'"); return ERR_PARSE_ERROR; @@ -6645,7 +6645,7 @@ Error ShaderLanguage::compile(const String &p_code, const Map<StringName, Functi code = p_code; - nodes = NULL; + nodes = nullptr; shader = alloc_node<ShaderNode>(); Error err = _parse_shader(p_functions, p_render_modes, p_shader_types); @@ -6662,7 +6662,7 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct code = p_code; - nodes = NULL; + nodes = nullptr; shader = alloc_node<ShaderNode>(); _parse_shader(p_functions, p_render_modes, p_shader_types); @@ -7001,7 +7001,7 @@ ShaderLanguage::ShaderNode *ShaderLanguage::get_shader() { ShaderLanguage::ShaderLanguage() { - nodes = NULL; + nodes = nullptr; completion_class = TAG_GLOBAL; } diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h index 9124bee633..beabae0dda 100644 --- a/servers/rendering/shader_language.h +++ b/servers/rendering/shader_language.h @@ -342,7 +342,7 @@ public: virtual String get_datatype_name() const { return ""; } Node(Type t) : - next(NULL), + next(nullptr), type(t) {} virtual ~Node() {} }; @@ -423,8 +423,8 @@ public: ArrayNode() : Node(TYPE_ARRAY), datatype_cache(TYPE_VOID), - index_expression(NULL), - call_expression(NULL), + index_expression(nullptr), + call_expression(nullptr), is_const(false) {} }; @@ -511,8 +511,8 @@ public: BlockNode() : Node(TYPE_BLOCK), - parent_function(NULL), - parent_block(NULL), + parent_function(nullptr), + parent_block(nullptr), block_type(BLOCK_TYPE_STANDART), block_tag(SubClassTag::TAG_GLOBAL), single_statement(false) {} @@ -550,8 +550,8 @@ public: basetype_const(false), datatype(TYPE_VOID), array_size(0), - owner(NULL), - index_expression(NULL), + owner(nullptr), + index_expression(nullptr), has_swizzling_duplicates(false) {} }; @@ -592,7 +592,7 @@ public: Node(TYPE_FUNCTION), return_type(TYPE_VOID), return_precision(PRECISION_DEFAULT), - body(NULL), + body(nullptr), can_discard(false) {} }; @@ -733,7 +733,7 @@ public: static bool is_token_nonvoid_datatype(TokenType p_type); static bool is_token_operator(TokenType p_type); - static bool convert_constant(ConstantNode *p_constant, DataType p_to_type, ConstantNode::Value *p_value = NULL); + static bool convert_constant(ConstantNode *p_constant, DataType p_to_type, ConstantNode::Value *p_value = nullptr); static DataType get_scalar_type(DataType p_type); static int get_cardinality(DataType p_type); static bool is_scalar_type(DataType p_type); @@ -825,10 +825,10 @@ private: IDENTIFIER_CONSTANT, }; - bool _find_identifier(const BlockNode *p_block, bool p_allow_reassign, const Map<StringName, BuiltInInfo> &p_builtin_types, const StringName &p_identifier, DataType *r_data_type = NULL, IdentifierType *r_type = NULL, bool *r_is_const = NULL, int *r_array_size = NULL, StringName *r_struct_name = NULL); + bool _find_identifier(const BlockNode *p_block, bool p_allow_reassign, const Map<StringName, BuiltInInfo> &p_builtin_types, const StringName &p_identifier, DataType *r_data_type = nullptr, IdentifierType *r_type = nullptr, bool *r_is_const = nullptr, int *r_array_size = nullptr, StringName *r_struct_name = nullptr); bool _is_operator_assign(Operator p_op) const; - bool _validate_assign(Node *p_node, const Map<StringName, BuiltInInfo> &p_builtin_types, String *r_message = NULL); - bool _validate_operator(OperatorNode *p_op, DataType *r_ret_type = NULL); + bool _validate_assign(Node *p_node, const Map<StringName, BuiltInInfo> &p_builtin_types, String *r_message = nullptr); + bool _validate_operator(OperatorNode *p_op, DataType *r_ret_type = nullptr); struct BuiltinFuncDef { enum { MAX_ARGS = 5 }; @@ -861,7 +861,7 @@ private: bool _compare_datatypes_in_nodes(Node *a, Node *b) const; bool _validate_function_call(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types, OperatorNode *p_func, DataType *r_ret_type, StringName *r_ret_type_str); - bool _parse_function_arguments(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types, OperatorNode *p_func, int *r_complete_arg = NULL); + bool _parse_function_arguments(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types, OperatorNode *p_func, int *r_complete_arg = nullptr); bool _propagate_function_call_sampler_uniform_settings(StringName p_name, int p_argument, TextureFilter p_filter, TextureRepeat p_repeat); bool _propagate_function_call_sampler_builtin_reference(StringName p_name, int p_argument, const StringName &p_builtin); diff --git a/servers/rendering/shader_types.cpp b/servers/rendering/shader_types.cpp index b144d6d612..ba7b992e51 100644 --- a/servers/rendering/shader_types.cpp +++ b/servers/rendering/shader_types.cpp @@ -44,7 +44,7 @@ const Set<String> &ShaderTypes::get_types() { return shader_types; } -ShaderTypes *ShaderTypes::singleton = NULL; +ShaderTypes *ShaderTypes::singleton = nullptr; static ShaderLanguage::BuiltInInfo constt(ShaderLanguage::DataType p_type) { |