diff options
36 files changed, 387 insertions, 111 deletions
@@ -63,4 +63,4 @@ such as text and video tutorials, demos, etc. Consult the [community channels](h for more info. [](https://travis-ci.org/godotengine/godot) -[](http://www.codetriage.com/godotengine/godot) +[](https://www.codetriage.com/godotengine/godot) diff --git a/core/object.cpp b/core/object.cpp index 3416cd8c5a..9184fb9cd0 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1655,7 +1655,7 @@ void Object::_bind_methods() { ClassDB::bind_method(D_METHOD("get_script:Script"), &Object::get_script); ClassDB::bind_method(D_METHOD("set_meta", "name", "value"), &Object::set_meta); - ClassDB::bind_method(D_METHOD("get_meta", "name", "value"), &Object::get_meta); + ClassDB::bind_method(D_METHOD("get_meta:Variant", "name", "value"), &Object::get_meta); ClassDB::bind_method(D_METHOD("has_meta", "name"), &Object::has_meta); ClassDB::bind_method(D_METHOD("get_meta_list"), &Object::_get_meta_list_bind); @@ -1817,6 +1817,23 @@ uint32_t Object::get_edited_version() const { } #endif +void *Object::get_script_instance_binding(int p_script_language_index) { +#ifdef DEBUG_ENABLED + ERR_FAIL_INDEX_V(p_script_language_index, MAX_SCRIPT_INSTANCE_BINDINGS, NULL); +#endif + + //it's up to the script language to make this thread safe, if the function is called twice due to threads being out of syncro + //just return the same pointer. + //if you want to put a big lock in the entire function and keep allocated pointers in a map or something, feel free to do it + //as it should not really affect performance much (won't be called too often), as in far most caes the condition below will be false afterwards + + if (!_script_instance_bindings[p_script_language_index]) { + _script_instance_bindings[p_script_language_index] = ScriptServer::get_language(p_script_language_index)->alloc_instance_binding_data(this); + } + + return _script_instance_bindings[p_script_language_index]; +} + Object::Object() { _class_ptr = NULL; @@ -1826,6 +1843,7 @@ Object::Object() { _instance_ID = ObjectDB::add_instance(this); _can_translate = true; _is_queued_for_deletion = false; + memset(_script_instance_bindings, 0, sizeof(void *) * MAX_SCRIPT_INSTANCE_BINDINGS); script_instance = NULL; #ifdef TOOLS_ENABLED @@ -1877,6 +1895,12 @@ Object::~Object() { ObjectDB::remove_instance(this); _instance_ID = 0; _predelete_ok = 2; + + for (int i = 0; i < MAX_SCRIPT_INSTANCE_BINDINGS; i++) { + if (_script_instance_bindings[i]) { + ScriptServer::get_language(i)->free_instance_binding_data(_script_instance_bindings[i]); + } + } } bool predelete_handler(Object *p_object) { diff --git a/core/object.h b/core/object.h index f87705c48b..556f3f1586 100644 --- a/core/object.h +++ b/core/object.h @@ -381,6 +381,10 @@ public: }; private: + enum { + MAX_SCRIPT_INSTANCE_BINDINGS = 8 + }; + #ifdef DEBUG_ENABLED friend class _ObjectDebugLock; #endif @@ -447,6 +451,8 @@ private: void _set_bind(const String &p_set, const Variant &p_value); Variant _get_bind(const String &p_name) const; + void *_script_instance_bindings[MAX_SCRIPT_INSTANCE_BINDINGS]; + void property_list_changed_notify(); protected: @@ -683,6 +689,9 @@ public: bool editor_is_section_unfolded(const String &p_section); #endif + //used by script languages to store binding data + void *get_script_instance_binding(int p_script_language_index); + void clear_internal_resource_paths(); Object(); diff --git a/core/script_language.cpp b/core/script_language.cpp index 72f0acec3b..4a7fdc9d64 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -66,11 +66,6 @@ bool ScriptServer::is_scripting_enabled() { return scripting_enabled; } -int ScriptServer::get_language_count() { - - return _language_count; -} - ScriptLanguage *ScriptServer::get_language(int p_idx) { ERR_FAIL_INDEX_V(p_idx, _language_count, NULL); diff --git a/core/script_language.h b/core/script_language.h index 6e39593a89..a81300233f 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -57,7 +57,7 @@ public: static void set_scripting_enabled(bool p_enabled); static bool is_scripting_enabled(); - static int get_language_count(); + _FORCE_INLINE_ static int get_language_count() { return _language_count; } static ScriptLanguage *get_language(int p_idx); static void register_language(ScriptLanguage *p_language); static void unregister_language(ScriptLanguage *p_language); @@ -274,6 +274,9 @@ public: virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) = 0; virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) = 0; + virtual void *alloc_instance_binding_data(Object *p_object) { return NULL; } //optional, not used by all languages + virtual void free_instance_binding_data(void *p_data) {} //optional, not used by all languages + virtual void frame(); virtual ~ScriptLanguage(){}; diff --git a/core/self_list.h b/core/self_list.h index 9edf735f7b..e229d5bf8e 100644 --- a/core/self_list.h +++ b/core/self_list.h @@ -51,6 +51,25 @@ public: _first->_prev = p_elem; _first = p_elem; } + void add_last(SelfList<T> *p_elem) { + + ERR_FAIL_COND(p_elem->_root); + + if (!_first) { + add(p_elem); + return; + } + + SelfList<T> *e = _first; + + while (e->next()) { + e = e->next(); + } + + e->_next = p_elem; + p_elem->_prev = e->_next; + p_elem->_root = this; + } void remove(SelfList<T> *p_elem) { diff --git a/doc/base/classes.xml b/doc/base/classes.xml index d6ee2ab0c5..5e8eaffa33 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -27894,6 +27894,11 @@ <return type="Array"> </return> <description> + Returns an [Array] of dictionaries with informations about signals that are connected to this object. + Inside each [Dictionary] there are 3 fields: + - "source" is a reference to signal emitter. + - "signal_name" is name of connected signal. + - "method_name" is a name of method to which signal is connected. </description> </method> <method name="get_instance_ID" qualifiers="const"> diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 89c4c909ee..8dfa91473a 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -761,7 +761,7 @@ bool RasterizerSceneGLES3::reflection_probe_instance_postprocess_step(RID p_inst storage->shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::LOW_QUALITY, rpi->probe_ptr->update_mode == VS::REFLECTION_PROBE_UPDATE_ALWAYS); for (int i = 0; i < 2; i++) { - storage->shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::Z_FLIP, i > 0); + storage->shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::Z_FLIP, i == 0); storage->shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::ROUGHNESS, rpi->render_step / 5.0); uint32_t local_width = width, local_height = height; @@ -1834,12 +1834,14 @@ void RasterizerSceneGLES3::_setup_light(RenderList::Element *e, const Transform GIProbeInstance *gipi = gi_probe_instance_owner.getptr(ridp[0]); + float bias_scale = e->instance->baked_light ? 1 : 0; glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 9); glBindTexture(GL_TEXTURE_3D, gipi->tex_cache); state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_XFORM1, gipi->transform_to_data * p_view_transform); state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BOUNDS1, gipi->bounds); state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_MULTIPLIER1, gipi->probe ? gipi->probe->dynamic_range * gipi->probe->energy : 0.0); - state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BIAS1, gipi->probe ? gipi->probe->bias : 0.0); + state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BIAS1, gipi->probe ? gipi->probe->bias * bias_scale : 0.0); + state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_NORMAL_BIAS1, gipi->probe ? gipi->probe->normal_bias * bias_scale : 0.0); state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BLEND_AMBIENT1, gipi->probe ? !gipi->probe->interior : false); state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_CELL_SIZE1, gipi->cell_size_cache); if (gi_probe_count > 1) { @@ -1852,7 +1854,8 @@ void RasterizerSceneGLES3::_setup_light(RenderList::Element *e, const Transform state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BOUNDS2, gipi2->bounds); state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_CELL_SIZE2, gipi2->cell_size_cache); state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_MULTIPLIER2, gipi2->probe ? gipi2->probe->dynamic_range * gipi2->probe->energy : 0.0); - state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BIAS2, gipi2->probe ? gipi2->probe->bias : 0.0); + state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BIAS2, gipi2->probe ? gipi2->probe->bias * bias_scale : 0.0); + state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_NORMAL_BIAS2, gipi2->probe ? gipi2->probe->normal_bias * bias_scale : 0.0); state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BLEND_AMBIENT2, gipi2->probe ? !gipi2->probe->interior : false); state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE2_ENABLED, true); } else { @@ -2889,7 +2892,7 @@ void RasterizerSceneGLES3::_setup_reflections(RID *p_reflection_probe_cull_resul reflection_ubo.atlas_clamp[0] = float(x) / reflection_atlas->size; reflection_ubo.atlas_clamp[1] = float(y) / reflection_atlas->size; reflection_ubo.atlas_clamp[2] = float(width) / reflection_atlas->size; - reflection_ubo.atlas_clamp[3] = float(height / 2) / reflection_atlas->size; + reflection_ubo.atlas_clamp[3] = float(height) / reflection_atlas->size; Transform proj = (p_camera_inverse_transform * rpi->transform).inverse(); store_transform(proj, reflection_ubo.local_matrix); @@ -4156,7 +4159,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const glDrawBuffers(1, &gldb); } - if (env && env->bg_mode == VS::ENV_BG_SKY && !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT] && state.debug_draw != VS::VIEWPORT_DEBUG_DRAW_OVERDRAW) { + if (env && env->bg_mode == VS::ENV_BG_SKY && (!storage->frame.current_rt || (!storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT] && state.debug_draw != VS::VIEWPORT_DEBUG_DRAW_OVERDRAW))) { /* if (use_mrt) { @@ -4175,7 +4178,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const _render_mrts(env, p_cam_projection); } else { //FIXME: check that this is possible to use - if (state.used_screen_texture) { + if (storage->frame.current_rt && state.used_screen_texture) { glBindFramebuffer(GL_READ_FRAMEBUFFER, storage->frame.current_rt->buffers.fbo); glReadBuffer(GL_COLOR_ATTACHMENT0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[0].sizes[0].fbo); @@ -4189,7 +4192,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const } } - if (state.used_screen_texture) { + if (storage->frame.current_rt && state.used_screen_texture) { glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 7); glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.mip_maps[0].color); } diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 14fb36f3b0..ab12bcef6d 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -4866,6 +4866,7 @@ RID RasterizerStorageGLES3::gi_probe_create() { gip->energy = 1.0; gip->propagation = 1.0; gip->bias = 0.4; + gip->normal_bias = 0.4; gip->interior = false; gip->compress = false; gip->version = 1; @@ -4972,6 +4973,14 @@ void RasterizerStorageGLES3::gi_probe_set_bias(RID p_probe, float p_range) { gip->bias = p_range; } +void RasterizerStorageGLES3::gi_probe_set_normal_bias(RID p_probe, float p_range) { + + GIProbe *gip = gi_probe_owner.getornull(p_probe); + ERR_FAIL_COND(!gip); + + gip->normal_bias = p_range; +} + void RasterizerStorageGLES3::gi_probe_set_propagation(RID p_probe, float p_range) { GIProbe *gip = gi_probe_owner.getornull(p_probe); @@ -5027,6 +5036,14 @@ float RasterizerStorageGLES3::gi_probe_get_bias(RID p_probe) const { return gip->bias; } +float RasterizerStorageGLES3::gi_probe_get_normal_bias(RID p_probe) const { + + const GIProbe *gip = gi_probe_owner.getornull(p_probe); + ERR_FAIL_COND_V(!gip, 0); + + return gip->normal_bias; +} + float RasterizerStorageGLES3::gi_probe_get_propagation(RID p_probe) const { const GIProbe *gip = gi_probe_owner.getornull(p_probe); diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index 183db534ac..b24da44afd 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -972,6 +972,7 @@ public: int dynamic_range; float energy; float bias; + float normal_bias; float propagation; bool interior; bool compress; @@ -1006,6 +1007,9 @@ public: virtual void gi_probe_set_bias(RID p_probe, float p_range); virtual float gi_probe_get_bias(RID p_probe) const; + virtual void gi_probe_set_normal_bias(RID p_probe, float p_range); + virtual float gi_probe_get_normal_bias(RID p_probe) const; + virtual void gi_probe_set_propagation(RID p_probe, float p_range); virtual float gi_probe_get_propagation(RID p_probe) const; diff --git a/drivers/gles3/shaders/cubemap_filter.glsl b/drivers/gles3/shaders/cubemap_filter.glsl index 393ef2892a..ac4e47a440 100644 --- a/drivers/gles3/shaders/cubemap_filter.glsl +++ b/drivers/gles3/shaders/cubemap_filter.glsl @@ -247,6 +247,7 @@ void main() { #if !defined(USE_SOURCE_DUAL_PARABOLOID_ARRAY) && !defined(USE_SOURCE_PANORAMA) + N.y=-N.y; frag_color=vec4(texture(N,source_cube).rgb,1.0); #endif @@ -277,6 +278,7 @@ void main() { #endif #if !defined(USE_SOURCE_DUAL_PARABOLOID_ARRAY) && !defined(USE_SOURCE_PANORAMA) + H.y=-H.y; sum.rgb += textureLod(source_cube, H, 0.0).rgb *ndotl; #endif sum.a += ndotl; diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index 6fbfeeff6c..9d474d3902 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -1093,27 +1093,19 @@ void reflection_process(int idx, vec3 vertex, vec3 normal,vec3 binormal, vec3 ta } - - vec3 splane=normalize(local_ref_vec); vec4 clamp_rect=reflections[idx].atlas_clamp; - - splane.z*=-1.0; - if (splane.z>=0.0) { - splane.z+=1.0; - clamp_rect.y+=clamp_rect.w; - } else { - splane.z=1.0 - splane.z; - splane.y=-splane.y; + vec3 norm = normalize(local_ref_vec); + norm.xy/=1.0+abs(norm.z); + norm.xy=norm.xy * vec2(0.5,0.25) + vec2(0.5,0.25); + if (norm.z>0) { + norm.y=0.5-norm.y+0.5; } - splane.xy/=splane.z; - splane.xy=splane.xy * 0.5 + 0.5; - - splane.xy = splane.xy * clamp_rect.zw + clamp_rect.xy; - splane.xy = clamp(splane.xy,clamp_rect.xy,clamp_rect.xy+clamp_rect.zw); + vec2 atlas_uv = norm.xy * clamp_rect.zw + clamp_rect.xy; + atlas_uv = clamp(atlas_uv,clamp_rect.xy,clamp_rect.xy+clamp_rect.zw); highp vec4 reflection; - reflection.rgb = textureLod(reflection_atlas,splane.xy,roughness*5.0).rgb; + reflection.rgb = textureLod(reflection_atlas,atlas_uv,roughness*5.0).rgb; if (reflections[idx].params.z < 0.5) { reflection.rgb = mix(skybox,reflection.rgb,blend); @@ -1180,6 +1172,7 @@ uniform highp vec3 gi_probe_bounds1; uniform highp vec3 gi_probe_cell_size1; uniform highp float gi_probe_multiplier1; uniform highp float gi_probe_bias1; +uniform highp float gi_probe_normal_bias1; uniform bool gi_probe_blend_ambient1; uniform mediump sampler3D gi_probe2; //texunit:-10 @@ -1188,12 +1181,12 @@ uniform highp vec3 gi_probe_bounds2; uniform highp vec3 gi_probe_cell_size2; uniform highp float gi_probe_multiplier2; uniform highp float gi_probe_bias2; +uniform highp float gi_probe_normal_bias2; uniform bool gi_probe2_enabled; uniform bool gi_probe_blend_ambient2; vec3 voxel_cone_trace(sampler3D probe, vec3 cell_size, vec3 pos, vec3 ambient, bool blend_ambient, vec3 direction, float tan_half_angle, float max_distance, float p_bias) { - float dist = p_bias;//1.0; //dot(direction,mix(vec3(-1.0),vec3(1.0),greaterThan(direction,vec3(0.0))))*2.0; float alpha=0.0; vec3 color = vec3(0.0); @@ -1214,27 +1207,30 @@ vec3 voxel_cone_trace(sampler3D probe, vec3 cell_size, vec3 pos, vec3 ambient, b return color; } -void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_size,vec3 pos, vec3 ambient, vec3 environment, bool blend_ambient,float multiplier, mat3 normal_mtx,vec3 ref_vec, float roughness,float p_bias, out vec4 out_spec, out vec4 out_diff) { +void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_size,vec3 pos, vec3 ambient, vec3 environment, bool blend_ambient,float multiplier, mat3 normal_mtx,vec3 ref_vec, float roughness,float p_bias,float p_normal_bias, inout vec4 out_spec, inout vec4 out_diff) { vec3 probe_pos = (probe_xform * vec4(pos,1.0)).xyz; vec3 ref_pos = (probe_xform * vec4(pos+ref_vec,1.0)).xyz; - ref_vec = normalize(ref_pos - probe_pos); + probe_pos+=(probe_xform * vec4(normal_mtx[2],0.0)).xyz*p_normal_bias; + /* out_diff.rgb = voxel_cone_trace(probe,cell_size,probe_pos,normalize((probe_xform * vec4(ref_vec,0.0)).xyz),0.0 ,100.0); out_diff.a = 1.0; return;*/ //out_diff = vec4(textureLod(probe,probe_pos*cell_size,3.0).rgb,1.0); //return; - if (any(bvec2(any(lessThan(probe_pos,vec3(0.0))),any(greaterThan(probe_pos,bounds))))) + //this causes corrupted pixels, i have no idea why.. + if (any(bvec2(any(lessThan(probe_pos,vec3(0.0))),any(greaterThan(probe_pos,bounds))))) { return; + } - vec3 blendv = probe_pos/bounds * 2.0 - 1.0; - float blend = 1.001-max(blendv.x,max(blendv.y,blendv.z)); - blend=1.0; + //vec3 blendv = probe_pos/bounds * 2.0 - 1.0; + //float blend = 1.001-max(blendv.x,max(blendv.y,blendv.z)); + float blend=1.0; float max_distance = length(bounds); @@ -1281,7 +1277,7 @@ void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_s light*=multiplier; - out_diff = vec4(light*blend,blend); + out_diff += vec4(light*blend,blend); //irradiance @@ -1290,7 +1286,8 @@ void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_s irr_light *= multiplier; //irr_light=vec3(0.0); - out_spec = vec4(irr_light*blend,blend); + out_spec += vec4(irr_light*blend,blend); + } @@ -1316,11 +1313,11 @@ void gi_probes_compute(vec3 pos, vec3 normal, float roughness, inout vec3 out_sp out_specular = vec3(0.0); - gi_probe_compute(gi_probe1,gi_probe_xform1,gi_probe_bounds1,gi_probe_cell_size1,pos,ambient,environment,gi_probe_blend_ambient1,gi_probe_multiplier1,normal_mat,ref_vec,roughness,gi_probe_bias1,spec_accum,diff_accum); + gi_probe_compute(gi_probe1,gi_probe_xform1,gi_probe_bounds1,gi_probe_cell_size1,pos,ambient,environment,gi_probe_blend_ambient1,gi_probe_multiplier1,normal_mat,ref_vec,roughness,gi_probe_bias1,gi_probe_normal_bias1,spec_accum,diff_accum); if (gi_probe2_enabled) { - gi_probe_compute(gi_probe2,gi_probe_xform2,gi_probe_bounds2,gi_probe_cell_size2,pos,ambient,environment,gi_probe_blend_ambient2,gi_probe_multiplier2,normal_mat,ref_vec,roughness,gi_probe_bias2,spec_accum,diff_accum); + gi_probe_compute(gi_probe2,gi_probe_xform2,gi_probe_bounds2,gi_probe_cell_size2,pos,ambient,environment,gi_probe_blend_ambient2,gi_probe_multiplier2,normal_mat,ref_vec,roughness,gi_probe_bias2,gi_probe_normal_bias2,spec_accum,diff_accum); } if (diff_accum.a>0.0) { @@ -1466,6 +1463,7 @@ FRAGMENT_SHADER_CODE vec3 specular_light = vec3(0.0,0.0,0.0); vec3 ambient_light; vec3 diffuse_light = vec3(0.0,0.0,0.0); + vec3 env_reflection_light = vec3(0.0,0.0,0.0); vec3 eye_vec = -normalize( vertex_interp ); @@ -1483,7 +1481,7 @@ FRAGMENT_SHADER_CODE vec3 ref_vec = reflect(-eye_vec,normal); //2.0 * ndotv * normal - view; // reflect(v, n); ref_vec=normalize((radiance_inverse_xform * vec4(ref_vec,0.0)).xyz); vec3 radiance = textureDualParaboloid(radiance_map,ref_vec,roughness) * bg_energy; - specular_light = radiance; + env_reflection_light = radiance; } //no longer a cubemap @@ -1662,7 +1660,7 @@ FRAGMENT_SHADER_CODE #endif //#USE_LIGHT_DIRECTIONAL #ifdef USE_GI_PROBES - gi_probes_compute(vertex,normal,roughness,specular_light,ambient_light); + gi_probes_compute(vertex,normal,roughness,env_reflection_light,ambient_light); #endif @@ -1673,12 +1671,15 @@ FRAGMENT_SHADER_CODE highp vec4 ambient_accum = vec4(0.0,0.0,0.0,0.0); for(int i=0;i<reflection_count;i++) { - reflection_process(reflection_indices[i],vertex,normal,binormal,tangent,roughness,anisotropy,ambient_light,specular_light,reflection_accum,ambient_accum); + reflection_process(reflection_indices[i],vertex,normal,binormal,tangent,roughness,anisotropy,ambient_light,env_reflection_light,reflection_accum,ambient_accum); } if (reflection_accum.a>0.0) { specular_light+=reflection_accum.rgb/reflection_accum.a; + } else { + specular_light+=env_reflection_light; } + if (ambient_accum.a>0.0) { ambient_light+=ambient_accum.rgb/ambient_accum.a; } diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 75f40cacca..479d97e563 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -50,7 +50,7 @@ #include <mach-o/dyld.h> #endif -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__OpenBSD__) #include <sys/param.h> #endif #include "global_config.h" @@ -532,7 +532,7 @@ String OS_Unix::get_executable_path() const { return OS::get_executable_path(); } return b; -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__OpenBSD__) char resolved_path[MAXPATHLEN]; realpath(OS::get_executable_path().utf8().get_data(), resolved_path); diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/editor/plugins/collision_polygon_2d_editor_plugin.cpp index abee3ead71..346c00df64 100644 --- a/editor/plugins/collision_polygon_2d_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_2d_editor_plugin.cpp @@ -99,7 +99,7 @@ bool CollisionPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) if (!node) return false; - Ref<InputEventMouseButton> mb; + Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid()) { Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 886474200e..cdae9baaf2 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -663,13 +663,16 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (List<Node *>::Element *e = selection.front()) { if (Node *node = e->get()) { bool editable = EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(node); + int editable_item_idx = menu->get_item_idx_from_text(TTR("Editable Children")); + int placeholder_item_idx = menu->get_item_idx_from_text(TTR("Load As Placeholder")); editable = !editable; EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(node, editable); - menu->set_item_checked(18, editable); + + menu->set_item_checked(editable_item_idx, editable); if (editable) { node->set_scene_instance_load_placeholder(false); - menu->set_item_checked(19, false); + menu->set_item_checked(placeholder_item_idx, false); } scene_tree->update_tree(); } @@ -681,12 +684,14 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (Node *node = e->get()) { bool placeholder = node->get_scene_instance_load_placeholder(); placeholder = !placeholder; + int editable_item_idx = menu->get_item_idx_from_text(TTR("Editable Children")); + int placeholder_item_idx = menu->get_item_idx_from_text(TTR("Load As Placeholder")); if (placeholder) EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(node, false); node->set_scene_instance_load_placeholder(placeholder); - menu->set_item_checked(18, false); - menu->set_item_checked(19, placeholder); + menu->set_item_checked(editable_item_idx, false); + menu->set_item_checked(placeholder_item_idx, placeholder); scene_tree->update_tree(); } } @@ -1892,8 +1897,8 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_check_item(TTR("Load As Placeholder"), TOOL_SCENE_USE_PLACEHOLDER); menu->add_item(TTR("Discard Instancing"), TOOL_SCENE_CLEAR_INSTANCING); menu->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Open in Editor"), TOOL_SCENE_OPEN); - menu->set_item_checked(18, editable); - menu->set_item_checked(19, placeholder); + menu->set_item_checked(menu->get_item_idx_from_text(TTR("Editable Children")), editable); + menu->set_item_checked(menu->get_item_idx_from_text(TTR("Load As Placeholder")), placeholder); } } } diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 94c94e126d..f35e098065 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -224,11 +224,11 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { } if (p_node == get_scene_node() && p_node->get_scene_inherited_state().is_valid()) { - item->add_button(0, get_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Subscene options")); + item->add_button(0, get_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Open in Editor")); item->set_tooltip(0, TTR("Inherits:") + " " + p_node->get_scene_inherited_state()->get_path() + "\n" + TTR("Type:") + " " + p_node->get_class()); } else if (p_node != get_scene_node() && p_node->get_filename() != "" && can_open_instance) { - item->add_button(0, get_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Subscene options")); + item->add_button(0, get_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Open in Editor")); item->set_tooltip(0, TTR("Instance:") + " " + p_node->get_filename() + "\n" + TTR("Type:") + " " + p_node->get_class()); } else { item->set_tooltip(0, String(p_node->get_name()) + "\n" + TTR("Type:") + " " + p_node->get_class()); diff --git a/modules/gdnative/godot/godot_dictionary.cpp b/modules/gdnative/godot/godot_dictionary.cpp index 12c40f0564..a14a86248b 100644 --- a/modules/gdnative/godot/godot_dictionary.cpp +++ b/modules/gdnative/godot/godot_dictionary.cpp @@ -124,11 +124,17 @@ void GDAPI godot_dictionary_set(godot_dictionary *p_self, const godot_variant *p } godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_self, const godot_variant *p_key) { - Array *self = (Array *)p_self; + Dictionary *self = (Dictionary *)p_self; const Variant *key = (const Variant *)p_key; return (godot_variant *)&self->operator[](*key); } +godot_variant GDAPI *godot_dictionary_next(const godot_dictionary *p_self, const godot_variant *p_key) { + Dictionary *self = (Dictionary *)p_self; + const Variant *key = (const Variant *)p_key; + return (godot_variant *)self->next(key); +} + godot_bool GDAPI godot_dictionary_operator_equal(const godot_dictionary *p_self, const godot_dictionary *p_b) { const Dictionary *self = (const Dictionary *)p_self; const Dictionary *b = (const Dictionary *)p_b; diff --git a/modules/gdnative/godot/godot_dictionary.h b/modules/gdnative/godot/godot_dictionary.h index 0325670b15..4ded0d38da 100644 --- a/modules/gdnative/godot/godot_dictionary.h +++ b/modules/gdnative/godot/godot_dictionary.h @@ -74,6 +74,8 @@ void GDAPI godot_dictionary_set(godot_dictionary *p_self, const godot_variant *p godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_self, const godot_variant *p_key); +godot_variant GDAPI *godot_dictionary_next(const godot_dictionary *p_self, const godot_variant *p_key); + godot_bool GDAPI godot_dictionary_operator_equal(const godot_dictionary *p_self, const godot_dictionary *p_b); godot_string GDAPI godot_dictionary_to_json(const godot_dictionary *p_self); diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 9d3da8227c..8c2c2ea345 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -380,6 +380,7 @@ void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) { ii.multimesh->set_mesh(ii.mesh); ii.multimesh_instance = VS::get_singleton()->instance_create(); VS::get_singleton()->instance_set_base(ii.multimesh_instance, ii.multimesh->get_rid()); + VS::get_singleton()->instance_geometry_set_flag(ii.multimesh_instance, VS::INSTANCE_FLAG_USE_BAKED_LIGHT, true); g.items[p_item] = ii; } diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub index 02ff2090f9..ca9fcb54e4 100644 --- a/platform/javascript/SCsub +++ b/platform/javascript/SCsub @@ -22,26 +22,31 @@ for x in javascript_files: env.Append(LINKFLAGS=["-s", "EXPORTED_FUNCTIONS=\"['_main','_audio_server_mix_function','_main_after_fs_sync']\""]) env.Append(LINKFLAGS=["--shell-file", '"platform/javascript/godot_shell.html"']) -html_file = env.Program('#bin/godot', javascript_objects, PROGSUFFIX=env["PROGSUFFIX"] + ".html")[0] +# output file name without file extension +basename = "godot" + env["PROGSUFFIX"] +target_dir = env.Dir("#bin") +js_file = target_dir.File(basename + ".js") +implicit_targets = [js_file] + +zip_dir = target_dir.Dir('.javascript_zip') +zip_files = env.InstallAs([zip_dir.File("godot.js"), zip_dir.File("godotfs.js")], [js_file, "#misc/dist/html_fs/godotfs.js"]) + +if env['wasm'] == 'yes': + wasm_file = target_dir.File(basename+'.wasm') + implicit_targets.append(wasm_file) + zip_files.append(InstallAs(zip_dir.File('godot.wasm'), wasm_file)) +else: + asmjs_files = [target_dir.File(basename+'.asm.js'), target_dir.File(basename+'.html.mem')] + zip_files.append(InstallAs([zip_dir.File('godot.asm.js'), zip_dir.File('godot.mem')], asmjs_files)) + implicit_targets.extend(asmjs_files) + +# HTML file must be the first target in the list +html_file = env.Program(["#bin/godot"] + implicit_targets, javascript_objects, PROGSUFFIX=env["PROGSUFFIX"]+".html")[0] Depends(html_file, "godot_shell.html") -basename = "godot" + env["PROGSUFFIX"] # output file name without file extension # Emscripten hardcodes file names, so replace common base name with # placeholder while leaving extension; also change `.html.mem` to just `.mem` fixup_html = env.Substfile(html_file, SUBST_DICT=[(basename, '$$GODOT_BASE'), ('.html.mem', '.mem')], SUBSTFILESUFFIX='.fixup.html') -zip_dir = env.Dir('#bin/.javascript_zip') -zip_files = [] -js_file = env.SideEffect(html_file.File(basename+'.js'), html_file) -zip_files.append(env.InstallAs( - [zip_dir.File('godot.html'), zip_dir.File('godot.js'), zip_dir.File('godotfs.js')], - [fixup_html, js_file, '#misc/dist/html_fs/godotfs.js'])) - -if env['wasm'] == 'yes': - wasm_file = env.SideEffect(html_file.File(basename+'.wasm'), html_file) - zip_files.append(env.InstallAs(zip_dir.File('godot.wasm'), wasm_file)) -else: - asmjs_files = env.SideEffect([html_file.File(basename+'.asm.js'), html_file.File(basename+'.html.mem')], html_file) - zip_files.append(env.InstallAs([zip_dir.File('godot.asm.js'), zip_dir.File('godot.mem')], asmjs_files)) - -Zip('#bin/godot', zip_files, ZIPSUFFIX=env['PROGSUFFIX']+env['ZIPSUFFIX'], ZIPROOT=zip_dir) +zip_files.append(InstallAs(zip_dir.File('godot.html'), fixup_html)) +Zip('#bin/godot', zip_files, ZIPSUFFIX=env['PROGSUFFIX']+env['ZIPSUFFIX'], ZIPROOT=zip_dir, ZIPCOMSTR="Archving $SOURCES as $TARGET") diff --git a/platform/osx/audio_driver_osx.cpp b/platform/osx/audio_driver_osx.cpp index 7469d52976..a4233b5264 100644 --- a/platform/osx/audio_driver_osx.cpp +++ b/platform/osx/audio_driver_osx.cpp @@ -31,11 +31,15 @@ #include "audio_driver_osx.h" -Error AudioDriverOSX::init() { +static OSStatus outputDeviceAddressCB(AudioObjectID inObjectID, UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses, void *__nullable inClientData) { + AudioDriverOSX *driver = (AudioDriverOSX *)inClientData; - active = false; - channels = 2; + driver->reopen(); + + return noErr; +} +Error AudioDriverOSX::initDevice() { AudioStreamBasicDescription strdesc; strdesc.mFormatID = kAudioFormatLinearPCM; strdesc.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked; @@ -43,12 +47,10 @@ Error AudioDriverOSX::init() { strdesc.mSampleRate = 44100; strdesc.mFramesPerPacket = 1; strdesc.mBitsPerChannel = 16; - strdesc.mBytesPerFrame = - strdesc.mBitsPerChannel * strdesc.mChannelsPerFrame / 8; - strdesc.mBytesPerPacket = - strdesc.mBytesPerFrame * strdesc.mFramesPerPacket; + strdesc.mBytesPerFrame = strdesc.mBitsPerChannel * strdesc.mChannelsPerFrame / 8; + strdesc.mBytesPerPacket = strdesc.mBytesPerFrame * strdesc.mFramesPerPacket; - OSStatus result = noErr; + OSStatus result; AURenderCallbackStruct callback; AudioComponentDescription desc; AudioComponent comp = NULL; @@ -66,32 +68,90 @@ Error AudioDriverOSX::init() { ERR_FAIL_COND_V(result != noErr, FAILED); ERR_FAIL_COND_V(comp == NULL, FAILED); - result = AudioUnitSetProperty(audio_unit, - kAudioUnitProperty_StreamFormat, - scope, bus, &strdesc, sizeof(strdesc)); + result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_StreamFormat, scope, bus, &strdesc, sizeof(strdesc)); ERR_FAIL_COND_V(result != noErr, FAILED); zeromem(&callback, sizeof(AURenderCallbackStruct)); callback.inputProc = &AudioDriverOSX::output_callback; callback.inputProcRefCon = this; - result = AudioUnitSetProperty(audio_unit, - kAudioUnitProperty_SetRenderCallback, - scope, bus, &callback, sizeof(callback)); + result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_SetRenderCallback, scope, bus, &callback, sizeof(callback)); ERR_FAIL_COND_V(result != noErr, FAILED); result = AudioUnitInitialize(audio_unit); ERR_FAIL_COND_V(result != noErr, FAILED); - result = AudioOutputUnitStart(audio_unit); + return OK; +} + +Error AudioDriverOSX::finishDevice() { + OSStatus result; + + if (active) { + result = AudioOutputUnitStop(audio_unit); + ERR_FAIL_COND_V(result != noErr, FAILED); + + active = false; + } + + result = AudioUnitUninitialize(audio_unit); + ERR_FAIL_COND_V(result != noErr, FAILED); + + return OK; +} + +Error AudioDriverOSX::init() { + OSStatus result; + + active = false; + channels = 2; + + outputDeviceAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice; + outputDeviceAddress.mScope = kAudioObjectPropertyScopeGlobal; + outputDeviceAddress.mElement = kAudioObjectPropertyElementMaster; + + result = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &outputDeviceAddress, &outputDeviceAddressCB, this); ERR_FAIL_COND_V(result != noErr, FAILED); const int samples = 1024; samples_in = memnew_arr(int32_t, samples); // whatever buffer_frames = samples / channels; - return OK; + return initDevice(); }; +Error AudioDriverOSX::reopen() { + Error err; + bool restart = false; + + lock(); + + if (active) { + restart = true; + } + + err = finishDevice(); + if (err != OK) { + ERR_PRINT("finishDevice failed"); + unlock(); + return err; + } + + err = initDevice(); + if (err != OK) { + ERR_PRINT("initDevice failed"); + unlock(); + return err; + } + + if (restart) { + start(); + } + + unlock(); + + return OK; +} + OSStatus AudioDriverOSX::output_callback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, @@ -149,7 +209,14 @@ OSStatus AudioDriverOSX::output_callback(void *inRefCon, }; void AudioDriverOSX::start() { - active = true; + if (!active) { + OSStatus result = AudioOutputUnitStart(audio_unit); + if (result != noErr) { + ERR_PRINT("AudioOutputUnitStart failed"); + } else { + active = true; + } + } }; int AudioDriverOSX::get_mix_rate() const { @@ -161,18 +228,23 @@ AudioDriver::SpeakerMode AudioDriverOSX::get_speaker_mode() const { }; void AudioDriverOSX::lock() { - if (active && mutex) + if (mutex) mutex->lock(); }; void AudioDriverOSX::unlock() { - if (active && mutex) + if (mutex) mutex->unlock(); }; void AudioDriverOSX::finish() { + OSStatus result; + + finishDevice(); - if (active) - AudioOutputUnitStop(audio_unit); + result = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &outputDeviceAddress, &outputDeviceAddressCB, this); + if (result != noErr) { + ERR_PRINT("AudioObjectRemovePropertyListener failed"); + } memdelete_arr(samples_in); }; diff --git a/platform/osx/audio_driver_osx.h b/platform/osx/audio_driver_osx.h index 9b48dab405..d6d00b7970 100644 --- a/platform/osx/audio_driver_osx.h +++ b/platform/osx/audio_driver_osx.h @@ -35,10 +35,12 @@ #include "servers/audio_server.h" #include <AudioUnit/AudioUnit.h> +#include <CoreAudio/AudioHardware.h> class AudioDriverOSX : public AudioDriver { AudioComponentInstance audio_unit; + AudioObjectPropertyAddress outputDeviceAddress; bool active; Mutex *mutex; @@ -52,6 +54,9 @@ class AudioDriverOSX : public AudioDriver { UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData); + Error initDevice(); + Error finishDevice(); + public: const char *get_name() const { return "AudioUnit"; @@ -65,6 +70,8 @@ public: virtual void unlock(); virtual void finish(); + Error reopen(); + AudioDriverOSX(); ~AudioDriverOSX(); }; diff --git a/platform/osx/detect.py b/platform/osx/detect.py index dfefbbc1ba..d9891dda61 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -90,7 +90,7 @@ def configure(env): env.Append(CPPPATH=['#platform/osx']) env.Append(CPPFLAGS=['-DOSX_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DAPPLE_STYLE_KEYS']) - env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit', '-lz', '-framework', 'IOKit', '-framework', 'ForceFeedback']) + env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit', '-framework', 'CoreAudio', '-lz', '-framework', 'IOKit', '-framework', 'ForceFeedback']) env.Append(LIBS=['pthread']) env.Append(CPPFLAGS=['-mmacosx-version-min=10.9']) diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index cc9470e88d..87ea018425 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -382,6 +382,9 @@ void AudioStreamPlayer3D::_notification(int p_what) { } break; } + bool filled_reverb = false; + int vol_index_max = AudioServer::get_singleton()->get_speaker_mode() + 1; + if (area) { if (area->is_overriding_audio_bus()) { @@ -391,14 +394,14 @@ void AudioStreamPlayer3D::_notification(int p_what) { } if (area->is_using_reverb_bus()) { + + filled_reverb = true; StringName bus_name = area->get_reverb_bus(); output.reverb_bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus_name); float uniformity = area->get_reverb_uniformity(); float area_send = area->get_reverb_amount(); - int vol_index_max = AudioServer::get_singleton()->get_speaker_mode() + 1; - if (uniformity > 0.0) { float distance = cam_area_pos.length(); @@ -406,6 +409,9 @@ void AudioStreamPlayer3D::_notification(int p_what) { //float dist_att_db = -20 * Math::log(dist + 0.00001); //logarithmic attenuation, like in real life + float center_val[3] = { 0.5, 0.25, 0.16666 }; + AudioFrame center_frame(center_val[vol_index_max - 1], center_val[vol_index_max - 1]); + if (attenuation < 1.0) { //pan the uniform sound Vector3 rev_pos = cam_area_pos; @@ -448,14 +454,20 @@ void AudioStreamPlayer3D::_notification(int p_what) { } break; } - } - float center_val[3] = { 0.5, 0.25, 0.16666 }; - AudioFrame center_frame(center_val[vol_index_max - 1], center_val[vol_index_max - 1]); + for (int i = 0; i < vol_index_max; i++) { + + output.reverb_vol[i] = output.reverb_vol[i].linear_interpolate(center_frame, attenuation); + } + } else { + for (int i = 0; i < vol_index_max; i++) { + + output.reverb_vol[i] = center_frame; + } + } for (int i = 0; i < vol_index_max; i++) { - output.reverb_vol[i] = output.reverb_vol[i].linear_interpolate(center_frame, attenuation); output.reverb_vol[i] = output.vol[i].linear_interpolate(output.reverb_vol[i] * attenuation, uniformity); output.reverb_vol[i] *= area_send; } @@ -491,6 +503,14 @@ void AudioStreamPlayer3D::_notification(int p_what) { output.pitch_scale = 1.0; } + if (!filled_reverb) { + + for (int i = 0; i < vol_index_max; i++) { + + output.reverb_vol[i] = AudioFrame(0, 0); + } + } + outputs[new_output_count] = output; new_output_count++; if (new_output_count == MAX_OUTPUTS) diff --git a/scene/3d/audio_stream_player_3d.h b/scene/3d/audio_stream_player_3d.h index 549bf67a2f..8603cab5a4 100644 --- a/scene/3d/audio_stream_player_3d.h +++ b/scene/3d/audio_stream_player_3d.h @@ -48,7 +48,12 @@ private: AudioFrame reverb_vol[3]; Viewport *viewport; //pointer only used for reference to previous mix - Output() { filter_gain = 0; } + Output() { + filter_gain = 0; + viewport = NULL; + reverb_bus_index = -1; + bus_index = -1; + } }; Output outputs[MAX_OUTPUTS]; diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index adca1492c3..581dfb32c8 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -95,6 +95,16 @@ float GIProbeData::get_bias() const { return VS::get_singleton()->gi_probe_get_bias(probe); } +void GIProbeData::set_normal_bias(float p_range) { + + VS::get_singleton()->gi_probe_set_normal_bias(probe, p_range); +} + +float GIProbeData::get_normal_bias() const { + + return VS::get_singleton()->gi_probe_get_normal_bias(probe); +} + void GIProbeData::set_propagation(float p_range) { VS::get_singleton()->gi_probe_set_propagation(probe, p_range); @@ -158,6 +168,9 @@ void GIProbeData::_bind_methods() { ClassDB::bind_method(D_METHOD("set_bias", "bias"), &GIProbeData::set_bias); ClassDB::bind_method(D_METHOD("get_bias"), &GIProbeData::get_bias); + ClassDB::bind_method(D_METHOD("set_normal_bias", "bias"), &GIProbeData::set_normal_bias); + ClassDB::bind_method(D_METHOD("get_normal_bias"), &GIProbeData::get_normal_bias); + ClassDB::bind_method(D_METHOD("set_propagation", "propagation"), &GIProbeData::set_propagation); ClassDB::bind_method(D_METHOD("get_propagation"), &GIProbeData::get_propagation); @@ -175,6 +188,7 @@ void GIProbeData::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "dynamic_range", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_dynamic_range", "get_dynamic_range"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "energy", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_energy", "get_energy"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "bias", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_bias", "get_bias"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "normal_bias", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_normal_bias", "get_normal_bias"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "propagation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_propagation", "get_propagation"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "interior", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_interior", "is_interior"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "compress", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_compress", "is_compressed"); @@ -265,6 +279,18 @@ float GIProbe::get_bias() const { return bias; } +void GIProbe::set_normal_bias(float p_normal_bias) { + + normal_bias = p_normal_bias; + if (probe_data.is_valid()) { + probe_data->set_normal_bias(normal_bias); + } +} +float GIProbe::get_normal_bias() const { + + return normal_bias; +} + void GIProbe::set_propagation(float p_propagation) { propagation = p_propagation; @@ -1261,6 +1287,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) { probe_data->set_dynamic_range(dynamic_range); probe_data->set_energy(energy); probe_data->set_bias(bias); + probe_data->set_normal_bias(normal_bias); probe_data->set_propagation(propagation); probe_data->set_interior(interior); probe_data->set_compress(compress); @@ -1434,6 +1461,9 @@ void GIProbe::_bind_methods() { ClassDB::bind_method(D_METHOD("set_bias", "max"), &GIProbe::set_bias); ClassDB::bind_method(D_METHOD("get_bias"), &GIProbe::get_bias); + ClassDB::bind_method(D_METHOD("set_normal_bias", "max"), &GIProbe::set_normal_bias); + ClassDB::bind_method(D_METHOD("get_normal_bias"), &GIProbe::get_normal_bias); + ClassDB::bind_method(D_METHOD("set_propagation", "max"), &GIProbe::set_propagation); ClassDB::bind_method(D_METHOD("get_propagation"), &GIProbe::get_propagation); @@ -1453,6 +1483,7 @@ void GIProbe::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_energy", "get_energy"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "propagation", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_propagation", "get_propagation"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "bias", PROPERTY_HINT_RANGE, "0,4,0.001"), "set_bias", "get_bias"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "normal_bias", PROPERTY_HINT_RANGE, "0,4,0.001"), "set_normal_bias", "get_normal_bias"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "interior"), "set_interior", "is_interior"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "compress"), "set_compress", "is_compressed"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "GIProbeData"), "set_probe_data", "get_probe_data"); @@ -1468,7 +1499,8 @@ GIProbe::GIProbe() { subdiv = SUBDIV_128; dynamic_range = 4; energy = 1.0; - bias = 1.8; + bias = 0.0; + normal_bias = 0.8; propagation = 1.0; extents = Vector3(10, 10, 10); color_scan_cell_width = 4; diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h index b5ee86455e..3f5a50a560 100644 --- a/scene/3d/gi_probe.h +++ b/scene/3d/gi_probe.h @@ -67,6 +67,9 @@ public: void set_bias(float p_range); float get_bias() const; + void set_normal_bias(float p_range); + float get_normal_bias() const; + void set_interior(bool p_enable); bool is_interior() const; @@ -163,6 +166,7 @@ private: int dynamic_range; float energy; float bias; + float normal_bias; float propagation; bool interior; bool compress; @@ -204,6 +208,9 @@ public: void set_bias(float p_bias); float get_bias() const; + void set_normal_bias(float p_normal_bias); + float get_normal_bias() const; + void set_propagation(float p_propagation); float get_propagation() const; diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp index 86a62bec97..0dc5b58e45 100644 --- a/scene/3d/reflection_probe.cpp +++ b/scene/3d/reflection_probe.cpp @@ -162,7 +162,7 @@ bool ReflectionProbe::are_shadows_enabled() const { void ReflectionProbe::set_cull_mask(uint32_t p_layers) { cull_mask = p_layers; - VS::get_singleton()->reflection_probe_set_enable_shadows(probe, p_layers); + VS::get_singleton()->reflection_probe_set_cull_mask(probe, p_layers); } uint32_t ReflectionProbe::get_cull_mask() const { diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index bf19ebccec..adcf86357d 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -1196,7 +1196,9 @@ void LineEdit::menu_option(int p_option) { select_all(); } break; case MENU_UNDO: { - undo(); + if (editable) { + undo(); + } } break; } } diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 072e90df3a..864fb3d3d5 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -696,6 +696,17 @@ String PopupMenu::get_item_text(int p_idx) const { ERR_FAIL_INDEX_V(p_idx, items.size(), ""); return items[p_idx].text; } + +int PopupMenu::get_item_idx_from_text(const String &text) const { + + for (int idx = 0; idx < items.size(); idx++) { + if (items[idx].text == text) + return idx; + } + + return -1; +} + Ref<Texture> PopupMenu::get_item_icon(int p_idx) const { ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture>()); diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h index a9bd8f7e50..6f1a2db363 100644 --- a/scene/gui/popup_menu.h +++ b/scene/gui/popup_menu.h @@ -132,6 +132,7 @@ public: void toggle_item_checked(int p_idx); String get_item_text(int p_idx) const; + int get_item_idx_from_text(const String &text) const; Ref<Texture> get_item_icon(int p_idx) const; bool is_item_checked(int p_idx) const; int get_item_ID(int p_idx) const; diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index ca80d5e457..9c264ead49 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -109,19 +109,20 @@ public: bool mirror : 8; bool receive_shadows : 8; bool visible : 8; + bool baked_light : 8; //this flag is only to know if it actually did use baked light float depth; //used for sorting SelfList<InstanceBase> dependency_item; - InstanceBase *baked_light; //baked light to use - SelfList<InstanceBase> baked_light_item; + //InstanceBase *baked_light; //baked light to use + //SelfList<InstanceBase> baked_light_item; virtual void base_removed() = 0; virtual void base_changed() = 0; virtual void base_material_changed() = 0; InstanceBase() - : dependency_item(this), baked_light_item(this) { + : dependency_item(this) { base_type = VS::INSTANCE_NONE; cast_shadows = VS::SHADOW_CASTING_SETTING_ON; @@ -129,7 +130,7 @@ public: visible = true; depth_layer = 0; layer_mask = 1; - baked_light = NULL; + baked_light = false; } }; @@ -422,6 +423,9 @@ public: virtual void gi_probe_set_bias(RID p_probe, float p_range) = 0; virtual float gi_probe_get_bias(RID p_probe) const = 0; + virtual void gi_probe_set_normal_bias(RID p_probe, float p_range) = 0; + virtual float gi_probe_get_normal_bias(RID p_probe) const = 0; + virtual void gi_probe_set_propagation(RID p_probe, float p_range) = 0; virtual float gi_probe_get_propagation(RID p_probe) const = 0; diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 1573116c50..58481fc3f6 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -844,6 +844,9 @@ public: BIND2(gi_probe_set_bias, RID, float) BIND1RC(float, gi_probe_get_bias, RID) + BIND2(gi_probe_set_normal_bias, RID, float) + BIND1RC(float, gi_probe_get_normal_bias, RID) + BIND2(gi_probe_set_propagation, RID, float) BIND1RC(float, gi_probe_get_propagation, RID) diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index 5009d76d43..97583dc849 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -993,6 +993,11 @@ void VisualServerScene::instance_geometry_set_flag(RID p_instance, VS::InstanceF instance->visible_in_all_rooms = p_enabled; } break; + case VS::INSTANCE_FLAG_USE_BAKED_LIGHT: { + + instance->baked_light = p_enabled; + + } break; } } void VisualServerScene::instance_geometry_set_cast_shadows_setting(RID p_instance, VS::ShadowCastingSetting p_shadow_casting_setting) { @@ -1849,7 +1854,7 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform, const Cam if (reflection_probe->reflection_dirty || VSG::scene_render->reflection_probe_instance_needs_redraw(reflection_probe->instance)) { if (!reflection_probe->update_list.in_list()) { reflection_probe->render_step = 0; - reflection_probe_render_list.add(&reflection_probe->update_list); + reflection_probe_render_list.add_last(&reflection_probe->update_list); } reflection_probe->reflection_dirty = false; diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 6a1b0f7e46..4567d87706 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -288,6 +288,9 @@ public: FUNC2(gi_probe_set_bias, RID, float) FUNC1RC(float, gi_probe_get_bias, RID) + FUNC2(gi_probe_set_normal_bias, RID, float) + FUNC1RC(float, gi_probe_get_normal_bias, RID) + FUNC2(gi_probe_set_propagation, RID, float) FUNC1RC(float, gi_probe_get_propagation, RID) diff --git a/servers/visual_server.h b/servers/visual_server.h index fbd7fc16ac..f515a7b990 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -463,6 +463,9 @@ public: virtual void gi_probe_set_bias(RID p_probe, float p_range) = 0; virtual float gi_probe_get_bias(RID p_probe) const = 0; + virtual void gi_probe_set_normal_bias(RID p_probe, float p_range) = 0; + virtual float gi_probe_get_normal_bias(RID p_probe) const = 0; + virtual void gi_probe_set_propagation(RID p_probe, float p_range) = 0; virtual float gi_probe_get_propagation(RID p_probe) const = 0; |