Fix various assorted warnings

Fix various warnings that don't have enough instances to merit
individual commits. Also fixes a potential bug in audio_server.cpp.
This commit is contained in:
Hein-Pieter van Braam 2017-09-07 21:48:50 +02:00
parent d1cb73b47a
commit 67a706fc1b
17 changed files with 125 additions and 136 deletions

View File

@ -1814,11 +1814,11 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
if (skip_editor && F->get().name.begins_with("__editor")) if (skip_editor && F->get().name.begins_with("__editor"))
continue; continue;
if (F->get().usage & PROPERTY_USAGE_STORAGE) { if ((F->get().usage & PROPERTY_USAGE_STORAGE)) {
Property p; Property p;
p.name_idx = get_string_index(F->get().name); p.name_idx = get_string_index(F->get().name);
p.value = E->get()->get(F->get().name); p.value = E->get()->get(F->get().name);
if ((F->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO && p.value.is_zero()) || (F->get().usage & PROPERTY_USAGE_STORE_IF_NONONE && p.value.is_one())) if (((F->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO) && p.value.is_zero()) || ((F->get().usage & PROPERTY_USAGE_STORE_IF_NONONE) && p.value.is_one()))
continue; continue;
p.pi = F->get(); p.pi = F->get();

View File

@ -446,6 +446,7 @@ Error StreamPeerBuffer::get_data(uint8_t *p_buffer, int p_bytes) {
return OK; return OK;
} }
Error StreamPeerBuffer::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) { Error StreamPeerBuffer::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) {
if (pointer + p_bytes > data.size()) { if (pointer + p_bytes > data.size()) {
@ -463,6 +464,8 @@ Error StreamPeerBuffer::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_
pointer += r_received; pointer += r_received;
// FIXME: return what? OK or ERR_* // FIXME: return what? OK or ERR_*
// return OK for now so we don't maybe return garbage
return OK;
} }
int StreamPeerBuffer::get_available_bytes() const { int StreamPeerBuffer::get_available_bytes() const {

View File

@ -55,8 +55,8 @@ public:
friend class OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>; friend class OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>;
typename InternalList::Element *list_element; typename InternalList::Element *list_element;
typename InternalList::Element *next_element;
typename InternalList::Element *prev_element; typename InternalList::Element *prev_element;
typename InternalList::Element *next_element;
Element(typename InternalList::Element *p_element) { Element(typename InternalList::Element *p_element) {
list_element = p_element; list_element = p_element;
@ -69,7 +69,7 @@ public:
public: public:
_FORCE_INLINE_ Element() _FORCE_INLINE_ Element()
: list_element(NULL), next_element(NULL), prev_element(NULL) { : list_element(NULL), prev_element(NULL), next_element(NULL) {
} }
Element next() const { Element next() const {
@ -312,4 +312,4 @@ bool operator!=(const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH
return (first.list_element != second.list_element); return (first.list_element != second.list_element);
} }
#endif // ORDERED_HASH_MAP_H #endif // ORDERED_HASH_MAP_H

View File

@ -165,7 +165,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
} break; } break;
case Image::FORMAT_RGB8: { case Image::FORMAT_RGB8: {
r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? GL_SRGB8 : GL_RGB8; r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? GL_SRGB8 : GL_RGB8;
r_gl_format = GL_RGB; r_gl_format = GL_RGB;
r_gl_type = GL_UNSIGNED_BYTE; r_gl_type = GL_UNSIGNED_BYTE;
srgb = true; srgb = true;
@ -174,7 +174,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
case Image::FORMAT_RGBA8: { case Image::FORMAT_RGBA8: {
r_gl_format = GL_RGBA; r_gl_format = GL_RGBA;
r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? GL_SRGB8_ALPHA8 : GL_RGBA8; r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? GL_SRGB8_ALPHA8 : GL_RGBA8;
r_gl_type = GL_UNSIGNED_BYTE; r_gl_type = GL_UNSIGNED_BYTE;
srgb = true; srgb = true;
@ -254,7 +254,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.s3tc_supported) { if (config.s3tc_supported) {
r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV : _EXT_COMPRESSED_RGBA_S3TC_DXT1_EXT; r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV : _EXT_COMPRESSED_RGBA_S3TC_DXT1_EXT;
r_gl_format = GL_RGBA; r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE; r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true; r_compressed = true;
@ -270,7 +270,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.s3tc_supported) { if (config.s3tc_supported) {
r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV : _EXT_COMPRESSED_RGBA_S3TC_DXT3_EXT; r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV : _EXT_COMPRESSED_RGBA_S3TC_DXT3_EXT;
r_gl_format = GL_RGBA; r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE; r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true; r_compressed = true;
@ -286,7 +286,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.s3tc_supported) { if (config.s3tc_supported) {
r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV : _EXT_COMPRESSED_RGBA_S3TC_DXT5_EXT; r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV : _EXT_COMPRESSED_RGBA_S3TC_DXT5_EXT;
r_gl_format = GL_RGBA; r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE; r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true; r_compressed = true;
@ -331,7 +331,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.bptc_supported) { if (config.bptc_supported) {
r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM : _EXT_COMPRESSED_RGBA_BPTC_UNORM; r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM : _EXT_COMPRESSED_RGBA_BPTC_UNORM;
r_gl_format = GL_RGBA; r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE; r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true; r_compressed = true;
@ -371,7 +371,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.pvrtc_supported) { if (config.pvrtc_supported) {
r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT : _EXT_COMPRESSED_RGB_PVRTC_2BPPV1_IMG; r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT : _EXT_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
r_gl_format = GL_RGBA; r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE; r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true; r_compressed = true;
@ -386,7 +386,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.pvrtc_supported) { if (config.pvrtc_supported) {
r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT : _EXT_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT : _EXT_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
r_gl_format = GL_RGBA; r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE; r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true; r_compressed = true;
@ -402,7 +402,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.pvrtc_supported) { if (config.pvrtc_supported) {
r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT : _EXT_COMPRESSED_RGB_PVRTC_4BPPV1_IMG; r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT : _EXT_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
r_gl_format = GL_RGBA; r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE; r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true; r_compressed = true;
@ -418,7 +418,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.pvrtc_supported) { if (config.pvrtc_supported) {
r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT : _EXT_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT : _EXT_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
r_gl_format = GL_RGBA; r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE; r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true; r_compressed = true;
@ -503,7 +503,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.etc2_supported) { if (config.etc2_supported) {
r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB8_ETC2 : _EXT_COMPRESSED_RGB8_ETC2; r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB8_ETC2 : _EXT_COMPRESSED_RGB8_ETC2;
r_gl_format = GL_RGB; r_gl_format = GL_RGB;
r_gl_type = GL_UNSIGNED_BYTE; r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true; r_compressed = true;
@ -518,7 +518,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.etc2_supported) { if (config.etc2_supported) {
r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : _EXT_COMPRESSED_RGBA8_ETC2_EAC; r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : _EXT_COMPRESSED_RGBA8_ETC2_EAC;
r_gl_format = GL_RGBA; r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE; r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true; r_compressed = true;
@ -533,7 +533,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.etc2_supported) { if (config.etc2_supported) {
r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 : _EXT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 : _EXT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;
r_gl_format = GL_RGBA; r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE; r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true; r_compressed = true;
@ -560,7 +560,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
} }
r_gl_format = GL_RGBA; r_gl_format = GL_RGBA;
r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? GL_SRGB8_ALPHA8 : GL_RGBA8; r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? GL_SRGB8_ALPHA8 : GL_RGBA8;
r_gl_type = GL_UNSIGNED_BYTE; r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = false; r_compressed = false;
srgb = true; srgb = true;
@ -686,7 +686,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture, const Ref<Image> &p
texture->ignore_mipmaps = compressed && !img->has_mipmaps(); texture->ignore_mipmaps = compressed && !img->has_mipmaps();
if (texture->flags & VS::TEXTURE_FLAG_MIPMAPS && !texture->ignore_mipmaps) if ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && !texture->ignore_mipmaps)
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, config.use_fast_texture_filter ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, config.use_fast_texture_filter ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR);
else { else {
if (texture->flags & VS::TEXTURE_FLAG_FILTER) { if (texture->flags & VS::TEXTURE_FLAG_FILTER) {
@ -717,7 +717,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture, const Ref<Image> &p
glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // raw Filtering glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // raw Filtering
} }
if ((texture->flags & VS::TEXTURE_FLAG_REPEAT || texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT) && texture->target != GL_TEXTURE_CUBE_MAP) { if (((texture->flags & VS::TEXTURE_FLAG_REPEAT) || (texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT)) && texture->target != GL_TEXTURE_CUBE_MAP) {
if (texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT) { if (texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
@ -770,7 +770,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture, const Ref<Image> &p
} }
} }
int mipmaps = (texture->flags & VS::TEXTURE_FLAG_MIPMAPS && img->has_mipmaps()) ? img->get_mipmap_count() + 1 : 1; int mipmaps = ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && img->has_mipmaps()) ? img->get_mipmap_count() + 1 : 1;
int w = img->get_width(); int w = img->get_width();
int h = img->get_height(); int h = img->get_height();
@ -820,7 +820,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture, const Ref<Image> &p
texture->stored_cube_sides |= (1 << p_cube_side); texture->stored_cube_sides |= (1 << p_cube_side);
if (texture->flags & VS::TEXTURE_FLAG_MIPMAPS && mipmaps == 1 && !texture->ignore_mipmaps && (!(texture->flags & VS::TEXTURE_FLAG_CUBEMAP) || texture->stored_cube_sides == (1 << 6) - 1)) { if ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && mipmaps == 1 && !texture->ignore_mipmaps && (!(texture->flags & VS::TEXTURE_FLAG_CUBEMAP) || texture->stored_cube_sides == (1 << 6) - 1)) {
//generate mipmaps if they were requested and the image does not contain them //generate mipmaps if they were requested and the image does not contain them
glGenerateMipmap(texture->target); glGenerateMipmap(texture->target);
} else if (mipmaps > 1) { } else if (mipmaps > 1) {
@ -912,7 +912,7 @@ void RasterizerStorageGLES3::texture_set_flags(RID p_texture, uint32_t p_flags)
uint32_t cube = texture->flags & VS::TEXTURE_FLAG_CUBEMAP; uint32_t cube = texture->flags & VS::TEXTURE_FLAG_CUBEMAP;
texture->flags = p_flags | cube; // can't remove a cube from being a cube texture->flags = p_flags | cube; // can't remove a cube from being a cube
if ((texture->flags & VS::TEXTURE_FLAG_REPEAT || texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT) && texture->target != GL_TEXTURE_CUBE_MAP) { if (((texture->flags & VS::TEXTURE_FLAG_REPEAT) || (texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT)) && texture->target != GL_TEXTURE_CUBE_MAP) {
if (texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT) { if (texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
@ -937,7 +937,7 @@ void RasterizerStorageGLES3::texture_set_flags(RID p_texture, uint32_t p_flags)
} }
} }
if (texture->flags & VS::TEXTURE_FLAG_MIPMAPS && !texture->ignore_mipmaps) { if ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && !texture->ignore_mipmaps) {
if (!had_mipmaps && texture->mipmaps == 1) { if (!had_mipmaps && texture->mipmaps == 1) {
glGenerateMipmap(texture->target); glGenerateMipmap(texture->target);
} }
@ -3360,7 +3360,7 @@ Rect3 RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
for (int i = 0; i < mesh->surfaces.size(); i++) { for (int i = 0; i < mesh->surfaces.size(); i++) {
Rect3 laabb; Rect3 laabb;
if (mesh->surfaces[i]->format & VS::ARRAY_FORMAT_BONES && mesh->surfaces[i]->skeleton_bone_aabb.size()) { if ((mesh->surfaces[i]->format & VS::ARRAY_FORMAT_BONES) && mesh->surfaces[i]->skeleton_bone_aabb.size()) {
int bs = mesh->surfaces[i]->skeleton_bone_aabb.size(); int bs = mesh->surfaces[i]->skeleton_bone_aabb.size();
const Rect3 *skbones = mesh->surfaces[i]->skeleton_bone_aabb.ptr(); const Rect3 *skbones = mesh->surfaces[i]->skeleton_bone_aabb.ptr();
@ -4631,7 +4631,7 @@ void RasterizerStorageGLES3::light_directional_set_shadow_depth_range_mode(RID p
Light *light = light_owner.getornull(p_light); Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light); ERR_FAIL_COND(!light);
light->directional_range_mode=p_range_mode; light->directional_range_mode = p_range_mode;
} }
VS::LightDirectionalShadowDepthRangeMode RasterizerStorageGLES3::light_directional_get_shadow_depth_range_mode(RID p_light) const { VS::LightDirectionalShadowDepthRangeMode RasterizerStorageGLES3::light_directional_get_shadow_depth_range_mode(RID p_light) const {
@ -6864,42 +6864,28 @@ int RasterizerStorageGLES3::get_captured_render_info(VS::RenderInfo p_info) {
int RasterizerStorageGLES3::get_render_info(VS::RenderInfo p_info) { int RasterizerStorageGLES3::get_render_info(VS::RenderInfo p_info) {
switch (p_info) { switch (p_info) {
case VS::INFO_OBJECTS_IN_FRAME: { case VS::INFO_OBJECTS_IN_FRAME:
return info.render_final.object_count; return info.render_final.object_count;
} break; case VS::INFO_VERTICES_IN_FRAME:
case VS::INFO_VERTICES_IN_FRAME: {
return info.render_final.vertices_count; return info.render_final.vertices_count;
} break; case VS::INFO_MATERIAL_CHANGES_IN_FRAME:
case VS::INFO_MATERIAL_CHANGES_IN_FRAME: {
return info.render_final.material_switch_count; return info.render_final.material_switch_count;
} break; case VS::INFO_SHADER_CHANGES_IN_FRAME:
case VS::INFO_SHADER_CHANGES_IN_FRAME: {
return info.render_final.shader_rebind_count; return info.render_final.shader_rebind_count;
} break; case VS::INFO_SURFACE_CHANGES_IN_FRAME:
case VS::INFO_SURFACE_CHANGES_IN_FRAME: {
return info.render_final.surface_switch_count; return info.render_final.surface_switch_count;
} break; case VS::INFO_DRAW_CALLS_IN_FRAME:
case VS::INFO_DRAW_CALLS_IN_FRAME: {
return info.render_final.draw_call_count; return info.render_final.draw_call_count;
} break; case VS::INFO_USAGE_VIDEO_MEM_TOTAL:
case VS::INFO_USAGE_VIDEO_MEM_TOTAL: {
return 0; //no idea return 0; //no idea
} break; case VS::INFO_VIDEO_MEM_USED:
case VS::INFO_VIDEO_MEM_USED: {
return info.vertex_mem + info.texture_mem; return info.vertex_mem + info.texture_mem;
} break; case VS::INFO_TEXTURE_MEM_USED:
case VS::INFO_TEXTURE_MEM_USED: {
return info.texture_mem; return info.texture_mem;
} break; case VS::INFO_VERTEX_MEM_USED:
case VS::INFO_VERTEX_MEM_USED: {
return info.vertex_mem; return info.vertex_mem;
} break; default:
return 0; //no idea either
} }
} }

View File

@ -34,7 +34,7 @@
#include "io/marshalls.h" #include "io/marshalls.h"
//#define DEBUG_PRINT(m_p) print_line(m_p) //#define DEBUG_PRINT(m_p) print_line(m_p)
#define DEBUG_TIME(m_what) printf("MS: %s - %lli\n", m_what, OS::get_singleton()->get_ticks_usec()); #define DEBUG_TIME(m_what) printf("MS: %s - %lu\n", m_what, OS::get_singleton()->get_ticks_usec());
//#define DEBUG_TIME(m_what) //#define DEBUG_TIME(m_what)

View File

@ -1024,7 +1024,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
String root_type = p_options["nodes/root_type"]; String root_type = p_options["nodes/root_type"];
if (scene->get_class() != root_type) { if (scene->get_class() != root_type) {
Node *base_node = base_node = Object::cast_to<Node>(ClassDB::instance(root_type)); Node *base_node = Object::cast_to<Node>(ClassDB::instance(root_type));
if (base_node) { if (base_node) {

View File

@ -1515,7 +1515,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
} }
if (drag == DRAG_NONE) { if (drag == DRAG_NONE) {
if ((m->get_button_mask() & BUTTON_MASK_LEFT && tool == TOOL_PAN) || m->get_button_mask() & BUTTON_MASK_MIDDLE || (m->get_button_mask() & BUTTON_MASK_LEFT && Input::get_singleton()->is_key_pressed(KEY_SPACE))) { if (((m->get_button_mask() & BUTTON_MASK_LEFT) && tool == TOOL_PAN) || (m->get_button_mask() & BUTTON_MASK_MIDDLE) || ((m->get_button_mask() & BUTTON_MASK_LEFT) && Input::get_singleton()->is_key_pressed(KEY_SPACE))) {
// Pan the viewport // Pan the viewport
Point2i relative; Point2i relative;
if (bool(EditorSettings::get_singleton()->get("editors/2d/warped_mouse_panning"))) { if (bool(EditorSettings::get_singleton()->get("editors/2d/warped_mouse_panning"))) {
@ -2269,7 +2269,6 @@ void CanvasItemEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_FIXED_PROCESS) { if (p_what == NOTIFICATION_FIXED_PROCESS) {
EditorNode::get_singleton()->get_scene_root()->set_snap_controls_to_pixels(GLOBAL_GET("gui/common/snap_controls_to_pixels")); EditorNode::get_singleton()->get_scene_root()->set_snap_controls_to_pixels(GLOBAL_GET("gui/common/snap_controls_to_pixels"));
List<Node *> &selection = editor_selection->get_selected_node_list(); List<Node *> &selection = editor_selection->get_selected_node_list();

View File

@ -395,7 +395,7 @@ bool Polygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (mm.is_valid()) { if (mm.is_valid()) {
if (edited_point != -1 && (wip_active || mm->get_button_mask() & BUTTON_MASK_LEFT)) { if (edited_point != -1 && (wip_active || (mm->get_button_mask() & BUTTON_MASK_LEFT))) {
Vector2 gpoint = mm->get_position(); Vector2 gpoint = mm->get_position();
Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint); Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint);
@ -554,7 +554,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
if (mm.is_valid()) { if (mm.is_valid()) {
if (mm->get_button_mask() & BUTTON_MASK_MIDDLE || Input::get_singleton()->is_key_pressed(KEY_SPACE)) { if ((mm->get_button_mask() & BUTTON_MASK_MIDDLE) || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
Vector2 drag(mm->get_relative().x, mm->get_relative().y); Vector2 drag(mm->get_relative().x, mm->get_relative().y);
uv_hscroll->set_value(uv_hscroll->get_value() - drag.x); uv_hscroll->set_value(uv_hscroll->get_value() - drag.x);

View File

@ -866,7 +866,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
MethodBind *mb = ClassDB::get_method(base_type, getter); MethodBind *mb = ClassDB::get_method(base_type, getter);
if (mb) { if (mb) {
PropertyInfo rt = mb->get_return_info(); PropertyInfo rt = mb->get_return_info();
if (rt.usage & PROPERTY_USAGE_CLASS_IS_ENUM && t == Variant::INT) { if ((rt.usage & PROPERTY_USAGE_CLASS_IS_ENUM) && t == Variant::INT) {
r_type.enumeration = rt.class_name; r_type.enumeration = rt.class_name;
} else if (t == Variant::OBJECT) { } else if (t == Variant::OBJECT) {
@ -1903,11 +1903,11 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N
arghint += ", "; arghint += ", ";
else else
arghint += " "; arghint += " ";
if (i == p_argidx || (mi.flags & METHOD_FLAG_VARARG && i > p_argidx)) { if (i == p_argidx || ((mi.flags & METHOD_FLAG_VARARG) && i > p_argidx)) {
arghint += String::chr(0xFFFF); arghint += String::chr(0xFFFF);
} }
arghint += _get_visual_datatype(mi.arguments[i]) + " " + mi.arguments[i].name; arghint += _get_visual_datatype(mi.arguments[i]) + " " + mi.arguments[i].name;
if (i == p_argidx || (mi.flags & METHOD_FLAG_VARARG && i > p_argidx)) { if (i == p_argidx || ((mi.flags & METHOD_FLAG_VARARG) && i > p_argidx)) {
arghint += String::chr(0xFFFF); arghint += String::chr(0xFFFF);
} }
} }

View File

@ -173,13 +173,15 @@ void LineBuilder::build() {
strip_begin(pos_up0, pos_down0, color0, uvx0); strip_begin(pos_up0, pos_down0, color0, uvx0);
// pos_up0 ------------- pos_up1 -------------------- /*
// | | * pos_up0 ------------- pos_up1 --------------------
// pos0 - - - - - - - - - pos1 - - - - - - - - - pos2 * | |
// | | * pos0 - - - - - - - - - pos1 - - - - - - - - - pos2
// pos_down0 ------------ pos_down1 ------------------ * | |
// * pos_down0 ------------ pos_down1 ------------------
// i-1 i i+1 *
* i-1 i i+1
*/
// http://labs.hyperandroid.com/tag/opengl-lines // http://labs.hyperandroid.com/tag/opengl-lines
// (not the same implementation but visuals help a lot) // (not the same implementation but visuals help a lot)
@ -206,17 +208,19 @@ void LineBuilder::build() {
inner_normal1 = -u1 * hw; inner_normal1 = -u1 * hw;
} }
// --------------------------- /*
// / * ---------------------------
// 0 / 1 * /
// / / * 0 / 1
// --------------------x------ / * / /
// / / (here shown with orientation == DOWN) * --------------------x------ /
// / / * / / (here shown with orientation == DOWN)
// / / * / /
// / / * / /
// 2 / * / /
// / * 2 /
* /
*/
// Find inner intersection at the joint // Find inner intersection at the joint
Vector2 corner_pos_in, corner_pos_out; Vector2 corner_pos_in, corner_pos_out;
@ -315,13 +319,14 @@ void LineBuilder::build() {
// Add joint geometry // Add joint geometry
if (current_joint_mode != LINE_JOINT_SHARP) { if (current_joint_mode != LINE_JOINT_SHARP) {
// ________________ cbegin /* ________________ cbegin
// / \ * / \
// / \ * / \
// ____________/_ _ _\ cend * ____________/_ _ _\ cend
// | | * | |
// | | * | |
// | | * | |
*/
Vector2 cbegin, cend; Vector2 cbegin, cend;
if (orientation == UP) { if (orientation == UP) {

View File

@ -2304,7 +2304,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
int col, h, section; int col, h, section;
TreeItem *it = _find_item_at_pos(root, mpos, col, h, section); TreeItem *it = _find_item_at_pos(root, mpos, col, h, section);
if (drop_mode_flags && it != drop_mode_over || section != drop_mode_section) { if ((drop_mode_flags && it != drop_mode_over) || section != drop_mode_section) {
drop_mode_over = it; drop_mode_over = it;
drop_mode_section = section; drop_mode_section = section;
update(); update();

View File

@ -331,18 +331,19 @@ real_t Curve::interpolate_local_nocheck(int index, real_t local_offset) const {
const Point a = _points[index]; const Point a = _points[index];
const Point b = _points[index + 1]; const Point b = _points[index + 1];
// Cubic bezier /* Cubic bezier
*
// ac-----bc * ac-----bc
// / \ * / \
// / \ Here with a.right_tangent > 0 * / \ Here with a.right_tangent > 0
// / \ and b.left_tangent < 0 * / \ and b.left_tangent < 0
// / \ * / \
// a b * a b
// *
// |-d1--|-d2--|-d3--| * |-d1--|-d2--|-d3--|
// *
// d1 == d2 == d3 == d / 3 * d1 == d2 == d3 == d / 3
*/
// Control points are chosen at equal distances // Control points are chosen at equal distances
real_t d = b.pos.x - a.pos.x; real_t d = b.pos.x - a.pos.x;

View File

@ -92,7 +92,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
NODE_FROM_ID(nparent, n.parent); NODE_FROM_ID(nparent, n.parent);
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (!nparent && n.parent & FLAG_ID_IS_PATH) { if (!nparent && (n.parent & FLAG_ID_IS_PATH)) {
WARN_PRINT(String("Parent path '" + String(node_paths[n.parent & FLAG_MASK]) + "' for node '" + String(snames[n.name]) + "' has vanished when instancing: '" + get_path() + "'.").ascii().get_data()); WARN_PRINT(String("Parent path '" + String(node_paths[n.parent & FLAG_MASK]) + "' for node '" + String(snames[n.name]) + "' has vanished when instancing: '" + get_path() + "'.").ascii().get_data());
} }
@ -489,7 +489,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
// only save what has been changed // only save what has been changed
// only save changed properties in instance // only save changed properties in instance
if (E->get().usage & PROPERTY_USAGE_NO_INSTANCE_STATE || E->get().name == "__meta__") { if ((E->get().usage & PROPERTY_USAGE_NO_INSTANCE_STATE) || E->get().name == "__meta__") {
//property has requested that no instance state is saved, sorry //property has requested that no instance state is saved, sorry
//also, meta won't be overridden or saved //also, meta won't be overridden or saved
continue; continue;
@ -1288,7 +1288,7 @@ bool SceneState::is_node_instance_placeholder(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, nodes.size(), false); ERR_FAIL_INDEX_V(p_idx, nodes.size(), false);
return nodes[p_idx].instance >= 0 && nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER; return nodes[p_idx].instance >= 0 && (nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER);
} }
Ref<PackedScene> SceneState::get_node_instance(int p_idx) const { Ref<PackedScene> SceneState::get_node_instance(int p_idx) const {
@ -1313,7 +1313,7 @@ String SceneState::get_node_instance_placeholder(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, nodes.size(), String()); ERR_FAIL_INDEX_V(p_idx, nodes.size(), String());
if (nodes[p_idx].instance >= 0 && nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER) { if (nodes[p_idx].instance >= 0 && (nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER)) {
return variants[nodes[p_idx].instance & FLAG_MASK]; return variants[nodes[p_idx].instance & FLAG_MASK];
} }

View File

@ -213,7 +213,6 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) const {
prevrow = 0; prevrow = 0;
for (j = 0; j <= (rings + 1); j++) { for (j = 0; j <= (rings + 1); j++) {
v = j; v = j;
w;
v /= (rings + 1); v /= (rings + 1);
w = sin(0.5 * Math_PI * v); w = sin(0.5 * Math_PI * v);
@ -292,7 +291,6 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) const {
prevrow = 0; prevrow = 0;
for (j = 0; j <= (rings + 1); j++) { for (j = 0; j <= (rings + 1); j++) {
v = j; v = j;
w;
v /= (rings + 1); v /= (rings + 1);
v += 1.0; v += 1.0;

View File

@ -203,8 +203,9 @@ void AudioServer::_mix_step() {
if (!bus_map.has(bus->send)) { if (!bus_map.has(bus->send)) {
bus = buses[0]; //send to master bus = buses[0]; //send to master
} else { } else {
int prev_index_cache = bus->index_cache;
bus = bus_map[bus->send]; bus = bus_map[bus->send];
if (bus->index_cache >= bus->index_cache) { //invalid, send to master if (prev_index_cache >= bus->index_cache) { //invalid, send to master
bus = buses[0]; bus = buses[0];
} }
} }

View File

@ -30,9 +30,10 @@
#include "broad_phase_basic.h" #include "broad_phase_basic.h"
#include "list.h" #include "list.h"
#include "print_string.h" #include "print_string.h"
BroadPhaseSW::ID BroadPhaseBasic::create(CollisionObjectSW *p_object, int p_subindex) { BroadPhaseSW::ID BroadPhaseBasic::create(CollisionObjectSW *p_object, int p_subindex) {
ERR_FAIL_COND_V(p_object == NULL, NULL); ERR_FAIL_COND_V(p_object == NULL, 0);
current++; current++;

View File

@ -101,7 +101,7 @@ void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance
SWAP(A, B); //lesser always first SWAP(A, B); //lesser always first
} }
if (B->base_type == VS::INSTANCE_LIGHT && (1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK) { if (B->base_type == VS::INSTANCE_LIGHT && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) {
InstanceLightData *light = static_cast<InstanceLightData *>(B->base_data); InstanceLightData *light = static_cast<InstanceLightData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data); InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@ -119,7 +119,7 @@ void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance
geom->lighting_dirty = true; geom->lighting_dirty = true;
return E; //this element should make freeing faster return E; //this element should make freeing faster
} else if (B->base_type == VS::INSTANCE_REFLECTION_PROBE && (1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK) { } else if (B->base_type == VS::INSTANCE_REFLECTION_PROBE && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) {
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(B->base_data); InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data); InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@ -133,7 +133,7 @@ void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance
geom->reflection_dirty = true; geom->reflection_dirty = true;
return E; //this element should make freeing faster return E; //this element should make freeing faster
} else if (B->base_type == VS::INSTANCE_GI_PROBE && (1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK) { } else if (B->base_type == VS::INSTANCE_GI_PROBE && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data); InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data); InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@ -169,7 +169,7 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance
SWAP(A, B); //lesser always first SWAP(A, B); //lesser always first
} }
if (B->base_type == VS::INSTANCE_LIGHT && (1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK) { if (B->base_type == VS::INSTANCE_LIGHT && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) {
InstanceLightData *light = static_cast<InstanceLightData *>(B->base_data); InstanceLightData *light = static_cast<InstanceLightData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data); InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@ -184,7 +184,7 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance
} }
geom->lighting_dirty = true; geom->lighting_dirty = true;
} else if (B->base_type == VS::INSTANCE_REFLECTION_PROBE && (1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK) { } else if (B->base_type == VS::INSTANCE_REFLECTION_PROBE && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) {
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(B->base_data); InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data); InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@ -196,7 +196,7 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance
geom->reflection_dirty = true; geom->reflection_dirty = true;
} else if (B->base_type == VS::INSTANCE_GI_PROBE && (1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK) { } else if (B->base_type == VS::INSTANCE_GI_PROBE && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data); InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data); InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@ -890,50 +890,48 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
max_distance = MIN(shadow_max, max_distance); max_distance = MIN(shadow_max, max_distance);
} }
max_distance = MAX(max_distance, p_cam_projection.get_z_near() + 0.001); max_distance = MAX(max_distance, p_cam_projection.get_z_near() + 0.001);
float min_distance = MIN(p_cam_projection.get_z_near(),max_distance); float min_distance = MIN(p_cam_projection.get_z_near(), max_distance);
VS::LightDirectionalShadowDepthRangeMode depth_range_mode = VSG::storage->light_directional_get_shadow_depth_range_mode(p_instance->base); VS::LightDirectionalShadowDepthRangeMode depth_range_mode = VSG::storage->light_directional_get_shadow_depth_range_mode(p_instance->base);
if (depth_range_mode==VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_OPTIMIZED) { if (depth_range_mode == VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_OPTIMIZED) {
//optimize min/max //optimize min/max
Vector<Plane> planes = p_cam_projection.get_projection_planes(p_cam_transform); Vector<Plane> planes = p_cam_projection.get_projection_planes(p_cam_transform);
int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, VS::INSTANCE_GEOMETRY_MASK); int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, VS::INSTANCE_GEOMETRY_MASK);
Plane base(p_cam_transform.origin,-p_cam_transform.basis.get_axis(2)); Plane base(p_cam_transform.origin, -p_cam_transform.basis.get_axis(2));
//check distance max and min //check distance max and min
bool found_items=false; bool found_items = false;
float z_max=-1e20; float z_max = -1e20;
float z_min=1e20; float z_min = 1e20;
for(int i=0;i<cull_count;i++) { for (int i = 0; i < cull_count; i++) {
Instance *instance = instance_shadow_cull_result[i]; Instance *instance = instance_shadow_cull_result[i];
if (!instance->visible || !((1 << instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) { if (!instance->visible || !((1 << instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
continue; continue;
} }
float max,min; float max, min;
instance->transformed_aabb.project_range_in_plane(base, min, max); instance->transformed_aabb.project_range_in_plane(base, min, max);
if (max>z_max) { if (max > z_max) {
z_max=max; z_max = max;
} }
if (min<z_min) { if (min < z_min) {
z_min=min; z_min = min;
} }
found_items=true; found_items = true;
} }
if (found_items) { if (found_items) {
min_distance=MAX(min_distance,z_min); min_distance = MAX(min_distance, z_min);
max_distance=MIN(max_distance,z_max); max_distance = MIN(max_distance, z_max);
} }
} }
float range = max_distance - min_distance; float range = max_distance - min_distance;
int splits = 0; int splits = 0;
@ -1062,7 +1060,7 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
z_max_cam = z_vec.dot(center) + radius; z_max_cam = z_vec.dot(center) + radius;
z_min_cam = z_vec.dot(center) - radius; z_min_cam = z_vec.dot(center) - radius;
if (depth_range_mode==VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE) { if (depth_range_mode == VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE) {
//this trick here is what stabilizes the shadow (make potential jaggies to not move) //this trick here is what stabilizes the shadow (make potential jaggies to not move)
//at the cost of some wasted resolution. Still the quality increase is very well worth it //at the cost of some wasted resolution. Still the quality increase is very well worth it
@ -1073,8 +1071,6 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
y_max_cam = Math::stepify(y_max_cam, unit); y_max_cam = Math::stepify(y_max_cam, unit);
y_min_cam = Math::stepify(y_min_cam, unit); y_min_cam = Math::stepify(y_min_cam, unit);
} }
} }
//now that we now all ranges, we can proceed to make the light frustum planes, for culling octree //now that we now all ranges, we can proceed to make the light frustum planes, for culling octree
@ -1118,7 +1114,6 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
{ {
CameraMatrix ortho_camera; CameraMatrix ortho_camera;
real_t half_x = (x_max_cam - x_min_cam) * 0.5; real_t half_x = (x_max_cam - x_min_cam) * 0.5;
real_t half_y = (y_max_cam - y_min_cam) * 0.5; real_t half_y = (y_max_cam - y_min_cam) * 0.5;
@ -1425,7 +1420,7 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform, const Cam
gi_probe_update_list.add(&gi_probe->update_element); gi_probe_update_list.add(&gi_probe->update_element);
} }
} else if ((1 << ins->base_type) & VS::INSTANCE_GEOMETRY_MASK && ins->visible && ins->cast_shadows != VS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) { } else if (((1 << ins->base_type) & VS::INSTANCE_GEOMETRY_MASK) && ins->visible && ins->cast_shadows != VS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) {
keep = true; keep = true;