Merge pull request #10846 from hpvb/fix-sign-compare

Fix signed and unsigned comparisons
This commit is contained in:
Rémi Verschelde 2017-09-01 21:52:55 +02:00 committed by GitHub
commit dac150108a
34 changed files with 105 additions and 105 deletions

View file

@ -1705,7 +1705,7 @@ Variant _File::get_var() const {
ERR_FAIL_COND_V(!f, Variant()); ERR_FAIL_COND_V(!f, Variant());
uint32_t len = get_32(); uint32_t len = get_32();
PoolVector<uint8_t> buff = get_buffer(len); PoolVector<uint8_t> buff = get_buffer(len);
ERR_FAIL_COND_V(buff.size() != len, Variant()); ERR_FAIL_COND_V((uint32_t)buff.size() != len, Variant());
PoolVector<uint8_t>::Read r = buff.read(); PoolVector<uint8_t>::Read r = buff.read();

View file

@ -37,11 +37,11 @@ class FileAccessCompressed : public FileAccess {
Compression::Mode cmode; Compression::Mode cmode;
bool writing; bool writing;
int write_pos; uint32_t write_pos;
uint8_t *write_ptr; uint8_t *write_ptr;
int write_buffer_size; uint32_t write_buffer_size;
int write_max; uint32_t write_max;
int block_size; uint32_t block_size;
mutable bool read_eof; mutable bool read_eof;
mutable bool at_end; mutable bool at_end;
@ -57,7 +57,7 @@ class FileAccessCompressed : public FileAccess {
mutable int read_block_size; mutable int read_block_size;
mutable int read_pos; mutable int read_pos;
Vector<ReadBlock> read_blocks; Vector<ReadBlock> read_blocks;
int read_total; uint32_t read_total;
String magic; String magic;
mutable Vector<uint8_t> buffer; mutable Vector<uint8_t> buffer;

View file

@ -73,14 +73,14 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8
length = p_base->get_64(); length = p_base->get_64();
base = p_base->get_pos(); base = p_base->get_pos();
ERR_FAIL_COND_V(p_base->get_len() < base + length, ERR_FILE_CORRUPT); ERR_FAIL_COND_V(p_base->get_len() < base + length, ERR_FILE_CORRUPT);
int ds = length; uint32_t ds = length;
if (ds % 16) { if (ds % 16) {
ds += 16 - (ds % 16); ds += 16 - (ds % 16);
} }
data.resize(ds); data.resize(ds);
int blen = p_base->get_buffer(data.ptr(), ds); uint32_t blen = p_base->get_buffer(data.ptr(), ds);
ERR_FAIL_COND_V(blen != ds, ERR_FILE_CORRUPT); ERR_FAIL_COND_V(blen != ds, ERR_FILE_CORRUPT);
aes256_context ctx; aes256_context ctx;

View file

@ -48,7 +48,7 @@ private:
size_t base; size_t base;
size_t length; size_t length;
Vector<uint8_t> data; Vector<uint8_t> data;
mutable size_t pos; mutable int pos;
mutable bool eofed; mutable bool eofed;
public: public:

View file

@ -244,14 +244,14 @@ FileAccessNetworkClient::~FileAccessNetworkClient() {
memdelete(sem); memdelete(sem);
} }
void FileAccessNetwork::_set_block(size_t p_offset, const Vector<uint8_t> &p_block) { void FileAccessNetwork::_set_block(int p_offset, const Vector<uint8_t> &p_block) {
int page = p_offset / page_size; int page = p_offset / page_size;
ERR_FAIL_INDEX(page, pages.size()); ERR_FAIL_INDEX(page, pages.size());
if (page < pages.size() - 1) { if (page < pages.size() - 1) {
ERR_FAIL_COND(p_block.size() != page_size); ERR_FAIL_COND(p_block.size() != page_size);
} else { } else {
ERR_FAIL_COND((p_block.size() != (total_size % page_size))); ERR_FAIL_COND((p_block.size() != (int)(total_size % page_size)));
} }
buffer_mutex->lock(); buffer_mutex->lock();

View file

@ -97,7 +97,7 @@ class FileAccessNetwork : public FileAccess {
mutable int last_page; mutable int last_page;
mutable uint8_t *last_page_buff; mutable uint8_t *last_page_buff;
uint32_t page_size; int page_size;
int read_ahead; int read_ahead;
int max_pages; int max_pages;
@ -121,7 +121,7 @@ class FileAccessNetwork : public FileAccess {
friend class FileAccessNetworkClient; friend class FileAccessNetworkClient;
void _queue_page(int p_page) const; void _queue_page(int p_page) const;
void _respond(size_t p_len, Error p_status); void _respond(size_t p_len, Error p_status);
void _set_block(size_t p_offset, const Vector<uint8_t> &p_block); void _set_block(int p_offset, const Vector<uint8_t> &p_block);
public: public:
enum Command { enum Command {

View file

@ -333,14 +333,14 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
len -= 12; len -= 12;
buf += 12; buf += 12;
int total = namecount + subnamecount; uint32_t total = namecount + subnamecount;
if (flags & 2) if (flags & 2)
total++; total++;
if (r_len) if (r_len)
(*r_len) += 12; (*r_len) += 12;
for (int i = 0; i < total; i++) { for (uint32_t i = 0; i < total; i++) {
ERR_FAIL_COND_V((int)len < 4, ERR_INVALID_DATA); ERR_FAIL_COND_V((int)len < 4, ERR_INVALID_DATA);
strlen = decode_uint32(buf); strlen = decode_uint32(buf);
@ -566,7 +566,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
if (count) { if (count) {
data.resize(count); data.resize(count);
PoolVector<uint8_t>::Write w = data.write(); PoolVector<uint8_t>::Write w = data.write();
for (int i = 0; i < count; i++) { for (uint32_t i = 0; i < count; i++) {
w[i] = buf[i]; w[i] = buf[i];
} }
@ -597,7 +597,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
//const int*rbuf=(const int*)buf; //const int*rbuf=(const int*)buf;
data.resize(count); data.resize(count);
PoolVector<int>::Write w = data.write(); PoolVector<int>::Write w = data.write();
for (int i = 0; i < count; i++) { for (uint32_t i = 0; i < count; i++) {
w[i] = decode_uint32(&buf[i * 4]); w[i] = decode_uint32(&buf[i * 4]);
} }
@ -624,7 +624,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
//const float*rbuf=(const float*)buf; //const float*rbuf=(const float*)buf;
data.resize(count); data.resize(count);
PoolVector<float>::Write w = data.write(); PoolVector<float>::Write w = data.write();
for (int i = 0; i < count; i++) { for (uint32_t i = 0; i < count; i++) {
w[i] = decode_float(&buf[i * 4]); w[i] = decode_float(&buf[i * 4]);
} }

View file

@ -102,7 +102,7 @@ StringName ResourceInteractiveLoaderBinary::_get_string() {
uint32_t id = f->get_32(); uint32_t id = f->get_32();
if (id & 0x80000000) { if (id & 0x80000000) {
uint32_t len = id & 0x7FFFFFFF; int len = id & 0x7FFFFFFF;
if (len > str_buf.size()) { if (len > str_buf.size()) {
str_buf.resize(len); str_buf.resize(len);
} }
@ -336,9 +336,9 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
} break; } break;
case OBJECT_EXTERNAL_RESOURCE_INDEX: { case OBJECT_EXTERNAL_RESOURCE_INDEX: {
//new file format, just refers to an index in the external list //new file format, just refers to an index in the external list
uint32_t erindex = f->get_32(); int erindex = f->get_32();
if (erindex >= external_resources.size()) { if (erindex < 0 || erindex >= external_resources.size()) {
WARN_PRINT("Broken external resource! (index out of size"); WARN_PRINT("Broken external resource! (index out of size");
r_v = Variant(); r_v = Variant();
} else { } else {

View file

@ -385,7 +385,7 @@ void XMLParser::_bind_methods() {
Error XMLParser::read() { Error XMLParser::read() {
// if not end reached, parse the node // if not end reached, parse the node
if (P && (P - data) < length - 1 && *P != 0) { if (P && (P - data) < (int64_t)length - 1 && *P != 0) {
_parse_current_node(); _parse_current_node();
return OK; return OK;
} }

View file

@ -67,7 +67,7 @@ public:
private: private:
char *data; char *data;
char *P; char *P;
int length; uint64_t length;
void unescape(String &p_str); void unescape(String &p_str);
Vector<String> special_characters; Vector<String> special_characters;
String node_name; String node_name;

View file

@ -389,8 +389,8 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
for (int i = 0; i < f.indices.size(); i++) { for (int i = 0; i < f.indices.size(); i++) {
uint32_t a = E->get().indices[i]; int a = E->get().indices[i];
uint32_t b = E->get().indices[(i + 1) % f.indices.size()]; int b = E->get().indices[(i + 1) % f.indices.size()];
Edge e(a, b); Edge e(a, b);
Map<Edge, RetFaceConnect>::Element *F = ret_edges.find(e); Map<Edge, RetFaceConnect>::Element *F = ret_edges.find(e);

View file

@ -61,7 +61,7 @@ Variant PackedDataContainer::_iter_init_ofs(const Array &p_iter, uint32_t p_offs
Variant PackedDataContainer::_iter_next_ofs(const Array &p_iter, uint32_t p_offset) { Variant PackedDataContainer::_iter_next_ofs(const Array &p_iter, uint32_t p_offset) {
Array ref = p_iter; Array ref = p_iter;
uint32_t size = _size(p_offset); int size = _size(p_offset);
if (ref.size() != 1) if (ref.size() != 1)
return false; return false;
int pos = ref[0]; int pos = ref[0];
@ -74,7 +74,7 @@ Variant PackedDataContainer::_iter_next_ofs(const Array &p_iter, uint32_t p_offs
Variant PackedDataContainer::_iter_get_ofs(const Variant &p_iter, uint32_t p_offset) { Variant PackedDataContainer::_iter_get_ofs(const Variant &p_iter, uint32_t p_offset) {
uint32_t size = _size(p_offset); int size = _size(p_offset);
int pos = p_iter; int pos = p_iter;
if (pos < 0 || pos >= size) if (pos < 0 || pos >= size)
return Variant(); return Variant();
@ -164,7 +164,7 @@ Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, b
if (p_key.is_num()) { if (p_key.is_num()) {
int idx = p_key; int idx = p_key;
uint32_t len = decode_uint32(r + 4); int len = decode_uint32(r + 4);
if (idx < 0 || idx >= len) { if (idx < 0 || idx >= len) {
err = true; err = true;
return Variant(); return Variant();
@ -183,7 +183,7 @@ Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, b
uint32_t len = decode_uint32(r + 4); uint32_t len = decode_uint32(r + 4);
bool found = false; bool found = false;
for (int i = 0; i < len; i++) { for (uint32_t i = 0; i < len; i++) {
uint32_t khash = decode_uint32(r + 8 + i * 12 + 0); uint32_t khash = decode_uint32(r + 8 + i * 12 + 0);
if (khash == hash) { if (khash == hash) {
Variant key = _get_at_ofs(decode_uint32(r + 8 + i * 12 + 4), rd.ptr(), err); Variant key = _get_at_ofs(decode_uint32(r + 8 + i * 12 + 4), rd.ptr(), err);

View file

@ -339,9 +339,9 @@ Error PoolAllocator::resize(ID p_mem, int p_new_size) {
ERR_FAIL_COND_V(e->lock, ERR_ALREADY_IN_USE); ERR_FAIL_COND_V(e->lock, ERR_ALREADY_IN_USE);
} }
int alloc_size = aligned(p_new_size); uint32_t alloc_size = aligned(p_new_size);
if (aligned(e->len) == alloc_size) { if ((uint32_t)aligned(e->len) == alloc_size) {
e->len = p_new_size; e->len = p_new_size;
mt_unlock(); mt_unlock();
@ -374,7 +374,7 @@ Error PoolAllocator::resize(ID p_mem, int p_new_size) {
} }
//no need to move stuff around, it fits before the next block //no need to move stuff around, it fits before the next block
int next_pos; uint32_t next_pos;
if (entry_indices_pos + 1 == entry_count) { if (entry_indices_pos + 1 == entry_count) {
next_pos = pool_size; // - static_area_size; next_pos = pool_size; // - static_area_size;
} else { } else {

View file

@ -588,7 +588,7 @@ String String::camelcase_to_underscore(bool lowercase) const {
const char a = 'a', z = 'z'; const char a = 'a', z = 'z';
int start_index = 0; int start_index = 0;
for (size_t i = 1; i < this->size(); i++) { for (int i = 1; i < this->size(); i++) {
bool is_upper = cstr[i] >= A && cstr[i] <= Z; bool is_upper = cstr[i] >= A && cstr[i] <= Z;
bool is_number = cstr[i] >= '0' && cstr[i] <= '9'; bool is_number = cstr[i] >= '0' && cstr[i] <= '9';
bool are_next_2_lower = false; bool are_next_2_lower = false;

View file

@ -247,7 +247,7 @@ bool RasterizerSceneGLES3::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas,
int qidx = p_in_quadrants[i]; int qidx = p_in_quadrants[i];
if (shadow_atlas->quadrants[qidx].subdivision == p_current_subdiv) { if (shadow_atlas->quadrants[qidx].subdivision == (uint32_t)p_current_subdiv) {
return false; return false;
} }
@ -349,7 +349,7 @@ bool RasterizerSceneGLES3::shadow_atlas_update_light(RID p_atlas, RID p_light_in
uint32_t q = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3; uint32_t q = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3;
uint32_t s = key & ShadowAtlas::SHADOW_INDEX_MASK; uint32_t s = key & ShadowAtlas::SHADOW_INDEX_MASK;
bool should_realloc = shadow_atlas->quadrants[q].subdivision != best_subdiv && (shadow_atlas->quadrants[q].shadows[s].alloc_tick - tick > shadow_atlas_realloc_tolerance_msec); bool should_realloc = shadow_atlas->quadrants[q].subdivision != (uint32_t)best_subdiv && (shadow_atlas->quadrants[q].shadows[s].alloc_tick - tick > shadow_atlas_realloc_tolerance_msec);
bool should_redraw = shadow_atlas->quadrants[q].shadows[s].version != p_light_version; bool should_redraw = shadow_atlas->quadrants[q].shadows[s].version != p_light_version;
if (!should_realloc) { if (!should_realloc) {
@ -554,7 +554,7 @@ void RasterizerSceneGLES3::reflection_atlas_set_subdivision(RID p_ref_atlas, int
ReflectionAtlas *reflection_atlas = reflection_atlas_owner.getornull(p_ref_atlas); ReflectionAtlas *reflection_atlas = reflection_atlas_owner.getornull(p_ref_atlas);
ERR_FAIL_COND(!reflection_atlas); ERR_FAIL_COND(!reflection_atlas);
uint32_t subdiv = next_power_of_2(p_subdiv); int subdiv = next_power_of_2(p_subdiv);
if (subdiv & 0xaaaaaaaa) { //sqrt(subdiv) must be integer if (subdiv & 0xaaaaaaaa) { //sqrt(subdiv) must be integer
subdiv <<= 1; subdiv <<= 1;
} }
@ -2702,7 +2702,7 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result, int p_light_c
uint32_t quadrant = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3; uint32_t quadrant = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3;
uint32_t shadow = key & ShadowAtlas::SHADOW_INDEX_MASK; uint32_t shadow = key & ShadowAtlas::SHADOW_INDEX_MASK;
ERR_CONTINUE(shadow >= shadow_atlas->quadrants[quadrant].shadows.size()); ERR_CONTINUE(shadow >= (uint32_t)shadow_atlas->quadrants[quadrant].shadows.size());
uint32_t atlas_size = shadow_atlas->size; uint32_t atlas_size = shadow_atlas->size;
uint32_t quadrant_size = atlas_size >> 1; uint32_t quadrant_size = atlas_size >> 1;
@ -2789,7 +2789,7 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result, int p_light_c
uint32_t quadrant = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3; uint32_t quadrant = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3;
uint32_t shadow = key & ShadowAtlas::SHADOW_INDEX_MASK; uint32_t shadow = key & ShadowAtlas::SHADOW_INDEX_MASK;
ERR_CONTINUE(shadow >= shadow_atlas->quadrants[quadrant].shadows.size()); ERR_CONTINUE(shadow >= (uint32_t)shadow_atlas->quadrants[quadrant].shadows.size());
uint32_t atlas_size = shadow_atlas->size; uint32_t atlas_size = shadow_atlas->size;
uint32_t quadrant_size = atlas_size >> 1; uint32_t quadrant_size = atlas_size >> 1;
@ -4469,7 +4469,7 @@ void RasterizerSceneGLES3::render_shadow(RID p_light, RID p_shadow_atlas, int p_
uint32_t quadrant = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3; uint32_t quadrant = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3;
uint32_t shadow = key & ShadowAtlas::SHADOW_INDEX_MASK; uint32_t shadow = key & ShadowAtlas::SHADOW_INDEX_MASK;
ERR_FAIL_INDEX(shadow, shadow_atlas->quadrants[quadrant].shadows.size()); ERR_FAIL_INDEX((int)shadow, shadow_atlas->quadrants[quadrant].shadows.size());
uint32_t quadrant_size = shadow_atlas->size >> 1; uint32_t quadrant_size = shadow_atlas->size >> 1;

View file

@ -244,7 +244,7 @@ public:
GLuint fbo_id[6]; GLuint fbo_id[6];
GLuint cubemap; GLuint cubemap;
int size; uint32_t size;
}; };
Vector<ShadowCubeMap> shadow_cubemaps; Vector<ShadowCubeMap> shadow_cubemaps;

View file

@ -216,8 +216,8 @@ void ImageLoaderPNG::get_recognized_extensions(List<String> *p_extensions) const
struct PNGReadStatus { struct PNGReadStatus {
int offset; uint32_t offset;
int size; uint32_t size;
const unsigned char *image; const unsigned char *image;
}; };

View file

@ -474,7 +474,7 @@ Error EditorSceneImporterGLTF::_decode_buffer_view(GLTFState &state, int p_buffe
int buffer_end = (stride * (count - 1)) + element_size; int buffer_end = (stride * (count - 1)) + element_size;
ERR_FAIL_COND_V(buffer_end > bv.byte_length, ERR_PARSE_ERROR); ERR_FAIL_COND_V(buffer_end > bv.byte_length, ERR_PARSE_ERROR);
ERR_FAIL_COND_V((offset + buffer_end) > buffer.size(), ERR_PARSE_ERROR); ERR_FAIL_COND_V((int)(offset + buffer_end) > buffer.size(), ERR_PARSE_ERROR);
//fill everything as doubles //fill everything as doubles

View file

@ -409,7 +409,7 @@ bool CanvasItemEditor::_is_part_of_subscene(CanvasItem *p_item) {
return item_owner && item_owner != scene_node && p_item != scene_node && item_owner->get_filename() != ""; return item_owner && item_owner != scene_node && p_item != scene_node && item_owner->get_filename() != "";
} }
void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, Vector<_SelectResult> &r_items, unsigned int limit) { void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, Vector<_SelectResult> &r_items, int limit) {
if (!p_node) if (!p_node)
return; return;
if (Object::cast_to<Viewport>(p_node)) if (Object::cast_to<Viewport>(p_node))

View file

@ -291,7 +291,7 @@ class CanvasItemEditor : public VBoxContainer {
int handle_len; int handle_len;
bool _is_part_of_subscene(CanvasItem *p_item); bool _is_part_of_subscene(CanvasItem *p_item);
void _find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, Vector<_SelectResult> &r_items, unsigned int limit = 0); void _find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, Vector<_SelectResult> &r_items, int limit = 0);
void _find_canvas_items_at_rect(const Rect2 &p_rect, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, List<CanvasItem *> *r_items); void _find_canvas_items_at_rect(const Rect2 &p_rect, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, List<CanvasItem *> *r_items);
void _select_click_on_empty_area(Point2 p_click_pos, bool p_append, bool p_box_selection); void _select_click_on_empty_area(Point2 p_click_pos, bool p_append, bool p_box_selection);

View file

@ -211,7 +211,7 @@ void Line2DEditor::_bind_methods() {
} }
void Line2DEditor::_mode_selected(int p_mode) { void Line2DEditor::_mode_selected(int p_mode) {
for (unsigned int i = 0; i < _MODE_COUNT; ++i) { for (int i = 0; i < _MODE_COUNT; ++i) {
toolbar_buttons[i]->set_pressed(i == p_mode); toolbar_buttons[i]->set_pressed(i == p_mode);
} }
mode = Mode(p_mode); mode = Mode(p_mode);

View file

@ -2958,7 +2958,7 @@ void SpatialEditor::update_transform_gizmo() {
gizmo.transform.origin = pcenter; gizmo.transform.origin = pcenter;
gizmo.transform.basis = gizmo_basis; gizmo.transform.basis = gizmo_basis;
for (int i = 0; i < VIEWPORTS_COUNT; i++) { for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
viewports[i]->update_transform_gizmo_view(); viewports[i]->update_transform_gizmo_view();
} }
} }
@ -3108,7 +3108,7 @@ void SpatialEditor::set_state(const Dictionary &p_state) {
Array vp = d["viewports"]; Array vp = d["viewports"];
ERR_FAIL_COND(vp.size() > 4); ERR_FAIL_COND(vp.size() > 4);
for (int i = 0; i < VIEWPORTS_COUNT; i++) { for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
viewports[i]->set_state(vp[i]); viewports[i]->set_state(vp[i]);
} }
} }
@ -3852,15 +3852,15 @@ void SpatialEditor::_toggle_maximize_view(Object *p_viewport) {
if (!maximized) { if (!maximized) {
for (int i = 0; i < VIEWPORTS_COUNT; i++) { for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
if (i == index) if (i == (uint32_t)index)
viewports[i]->set_area_as_parent_rect(); viewports[i]->set_area_as_parent_rect();
else else
viewports[i]->hide(); viewports[i]->hide();
} }
} else { } else {
for (int i = 0; i < VIEWPORTS_COUNT; i++) for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++)
viewports[i]->show(); viewports[i]->show();
if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT))) if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT)))
@ -3904,7 +3904,7 @@ void SpatialEditor::clear() {
settings_znear->set_value(EDITOR_DEF("editors/3d/default_z_near", 0.1)); settings_znear->set_value(EDITOR_DEF("editors/3d/default_z_near", 0.1));
settings_zfar->set_value(EDITOR_DEF("editors/3d/default_z_far", 1500.0)); settings_zfar->set_value(EDITOR_DEF("editors/3d/default_z_far", 1500.0));
for (int i = 0; i < VIEWPORTS_COUNT; i++) { for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
viewports[i]->reset(); viewports[i]->reset();
} }
@ -3917,7 +3917,7 @@ void SpatialEditor::clear() {
} }
} }
for (int i = 0; i < VIEWPORTS_COUNT; i++) { for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
viewports[i]->view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(SpatialEditorViewport::VIEW_AUDIO_LISTENER), i == 0); viewports[i]->view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(SpatialEditorViewport::VIEW_AUDIO_LISTENER), i == 0);
viewports[i]->viewport->set_as_audio_listener(i == 0); viewports[i]->viewport->set_as_audio_listener(i == 0);
@ -4074,7 +4074,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
viewport_base = memnew(SpatialEditorViewportContainer); viewport_base = memnew(SpatialEditorViewportContainer);
shader_split->add_child(viewport_base); shader_split->add_child(viewport_base);
viewport_base->set_v_size_flags(SIZE_EXPAND_FILL); viewport_base->set_v_size_flags(SIZE_EXPAND_FILL);
for (int i = 0; i < VIEWPORTS_COUNT; i++) { for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
viewports[i] = memnew(SpatialEditorViewport(this, editor, i)); viewports[i] = memnew(SpatialEditorViewport(this, editor, i));
viewports[i]->connect("toggle_maximize_view", this, "_toggle_maximize_view"); viewports[i]->connect("toggle_maximize_view", this, "_toggle_maximize_view");

View file

@ -117,7 +117,7 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f
return; return;
} }
int imgw = p_img->get_width(), imgh = p_img->get_height(); uint32_t imgw = p_img->get_width(), imgh = p_img->get_height();
ERR_FAIL_COND(next_power_of_2(imgw) != imgw || next_power_of_2(imgh) != imgh); ERR_FAIL_COND(next_power_of_2(imgw) != imgw || next_power_of_2(imgh) != imgh);
Image::Format etc_format = force_etc1_format ? Image::FORMAT_ETC : _get_etc2_mode(detected_channels); Image::Format etc_format = force_etc1_format ? Image::FORMAT_ETC : _get_etc2_mode(detected_channels);

View file

@ -61,7 +61,7 @@ void GDAPI godot_array_new_pool_color_array(godot_array *r_dest, const godot_poo
memnew_placement(dest, Array); memnew_placement(dest, Array);
dest->resize(pca->size()); dest->resize(pca->size());
for (size_t i = 0; i < dest->size(); i++) { for (int i = 0; i < dest->size(); i++) {
Variant v = pca->operator[](i); Variant v = pca->operator[](i);
dest->operator[](i) = v; dest->operator[](i) = v;
} }
@ -73,7 +73,7 @@ void GDAPI godot_array_new_pool_vector3_array(godot_array *r_dest, const godot_p
memnew_placement(dest, Array); memnew_placement(dest, Array);
dest->resize(pca->size()); dest->resize(pca->size());
for (size_t i = 0; i < dest->size(); i++) { for (int i = 0; i < dest->size(); i++) {
Variant v = pca->operator[](i); Variant v = pca->operator[](i);
dest->operator[](i) = v; dest->operator[](i) = v;
} }
@ -85,7 +85,7 @@ void GDAPI godot_array_new_pool_vector2_array(godot_array *r_dest, const godot_p
memnew_placement(dest, Array); memnew_placement(dest, Array);
dest->resize(pca->size()); dest->resize(pca->size());
for (size_t i = 0; i < dest->size(); i++) { for (int i = 0; i < dest->size(); i++) {
Variant v = pca->operator[](i); Variant v = pca->operator[](i);
dest->operator[](i) = v; dest->operator[](i) = v;
} }
@ -97,7 +97,7 @@ void GDAPI godot_array_new_pool_string_array(godot_array *r_dest, const godot_po
memnew_placement(dest, Array); memnew_placement(dest, Array);
dest->resize(pca->size()); dest->resize(pca->size());
for (size_t i = 0; i < dest->size(); i++) { for (int i = 0; i < dest->size(); i++) {
Variant v = pca->operator[](i); Variant v = pca->operator[](i);
dest->operator[](i) = v; dest->operator[](i) = v;
} }
@ -109,7 +109,7 @@ void GDAPI godot_array_new_pool_real_array(godot_array *r_dest, const godot_pool
memnew_placement(dest, Array); memnew_placement(dest, Array);
dest->resize(pca->size()); dest->resize(pca->size());
for (size_t i = 0; i < dest->size(); i++) { for (int i = 0; i < dest->size(); i++) {
Variant v = pca->operator[](i); Variant v = pca->operator[](i);
dest->operator[](i) = v; dest->operator[](i) = v;
} }
@ -121,7 +121,7 @@ void GDAPI godot_array_new_pool_int_array(godot_array *r_dest, const godot_pool_
memnew_placement(dest, Array); memnew_placement(dest, Array);
dest->resize(pca->size()); dest->resize(pca->size());
for (size_t i = 0; i < dest->size(); i++) { for (int i = 0; i < dest->size(); i++) {
Variant v = pca->operator[](i); Variant v = pca->operator[](i);
dest->operator[](i) = v; dest->operator[](i) = v;
} }
@ -133,7 +133,7 @@ void GDAPI godot_array_new_pool_byte_array(godot_array *r_dest, const godot_pool
memnew_placement(dest, Array); memnew_placement(dest, Array);
dest->resize(pca->size()); dest->resize(pca->size());
for (size_t i = 0; i < dest->size(); i++) { for (int i = 0; i < dest->size(); i++) {
Variant v = pca->operator[](i); Variant v = pca->operator[](i);
dest->operator[](i) = v; dest->operator[](i) = v;
} }

View file

@ -65,7 +65,7 @@ void GDAPI godot_pool_byte_array_new_with_array(godot_pool_byte_array *r_dest, c
memnew_placement(dest, PoolVector<uint8_t>); memnew_placement(dest, PoolVector<uint8_t>);
dest->resize(a->size()); dest->resize(a->size());
for (size_t i = 0; i < a->size(); i++) { for (int i = 0; i < a->size(); i++) {
dest->set(i, (*a)[i]); dest->set(i, (*a)[i]);
} }
} }
@ -144,7 +144,7 @@ void GDAPI godot_pool_int_array_new_with_array(godot_pool_int_array *r_dest, con
memnew_placement(dest, PoolVector<godot_int>); memnew_placement(dest, PoolVector<godot_int>);
dest->resize(a->size()); dest->resize(a->size());
for (size_t i = 0; i < a->size(); i++) { for (int i = 0; i < a->size(); i++) {
dest->set(i, (*a)[i]); dest->set(i, (*a)[i]);
} }
} }
@ -223,7 +223,7 @@ void GDAPI godot_pool_real_array_new_with_array(godot_pool_real_array *r_dest, c
memnew_placement(dest, PoolVector<godot_real>); memnew_placement(dest, PoolVector<godot_real>);
dest->resize(a->size()); dest->resize(a->size());
for (size_t i = 0; i < a->size(); i++) { for (int i = 0; i < a->size(); i++) {
dest->set(i, (*a)[i]); dest->set(i, (*a)[i]);
} }
} }
@ -302,7 +302,7 @@ void GDAPI godot_pool_string_array_new_with_array(godot_pool_string_array *r_des
memnew_placement(dest, PoolVector<String>); memnew_placement(dest, PoolVector<String>);
dest->resize(a->size()); dest->resize(a->size());
for (size_t i = 0; i < a->size(); i++) { for (int i = 0; i < a->size(); i++) {
dest->set(i, (*a)[i]); dest->set(i, (*a)[i]);
} }
} }
@ -389,7 +389,7 @@ void GDAPI godot_pool_vector2_array_new_with_array(godot_pool_vector2_array *r_d
memnew_placement(dest, PoolVector<Vector2>); memnew_placement(dest, PoolVector<Vector2>);
dest->resize(a->size()); dest->resize(a->size());
for (size_t i = 0; i < a->size(); i++) { for (int i = 0; i < a->size(); i++) {
dest->set(i, (*a)[i]); dest->set(i, (*a)[i]);
} }
} }
@ -475,7 +475,7 @@ void GDAPI godot_pool_vector3_array_new_with_array(godot_pool_vector3_array *r_d
memnew_placement(dest, PoolVector<Vector3>); memnew_placement(dest, PoolVector<Vector3>);
dest->resize(a->size()); dest->resize(a->size());
for (size_t i = 0; i < a->size(); i++) { for (int i = 0; i < a->size(); i++) {
dest->set(i, (*a)[i]); dest->set(i, (*a)[i]);
} }
} }
@ -561,7 +561,7 @@ void GDAPI godot_pool_color_array_new_with_array(godot_pool_color_array *r_dest,
memnew_placement(dest, PoolVector<Color>); memnew_placement(dest, PoolVector<Color>);
dest->resize(a->size()); dest->resize(a->size());
for (size_t i = 0; i < a->size(); i++) { for (int i = 0; i < a->size(); i++) {
dest->set(i, (*a)[i]); dest->set(i, (*a)[i]);
} }
} }

View file

@ -309,7 +309,7 @@ Ref<RegExMatch> RegEx::search(const String &p_subject, int p_offset, int p_end)
_pattern_info(PCRE2_INFO_NAMETABLE, &table); _pattern_info(PCRE2_INFO_NAMETABLE, &table);
_pattern_info(PCRE2_INFO_NAMEENTRYSIZE, &entry_size); _pattern_info(PCRE2_INFO_NAMEENTRYSIZE, &entry_size);
for (int i = 0; i < count; i++) { for (uint32_t i = 0; i < count; i++) {
CharType id = table[i * entry_size]; CharType id = table[i * entry_size];
if (result->data[id].start == -1) if (result->data[id].start == -1)
@ -338,7 +338,7 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a
PCRE2_SIZE olength = output.length(); PCRE2_SIZE olength = output.length();
PCRE2_SIZE length = p_subject.length(); PCRE2_SIZE length = p_subject.length();
if (p_end >= 0 && p_end < length) if (p_end >= 0 && (uint32_t)p_end < length)
length = p_end; length = p_end;
if (sizeof(CharType) == 2) { if (sizeof(CharType) == 2) {
@ -430,7 +430,7 @@ Array RegEx::get_names() const {
_pattern_info(PCRE2_INFO_NAMETABLE, &table); _pattern_info(PCRE2_INFO_NAMETABLE, &table);
_pattern_info(PCRE2_INFO_NAMEENTRYSIZE, &entry_size); _pattern_info(PCRE2_INFO_NAMEENTRYSIZE, &entry_size);
for (int i = 0; i < count; i++) { for (uint32_t i = 0; i < count; i++) {
String name = &table[i * entry_size + 1]; String name = &table[i * entry_size + 1];
if (result.find(name) < 0) { if (result.find(name) < 0) {

View file

@ -53,19 +53,19 @@ Error ImageLoaderTGA::decode_tga_rle(const uint8_t *p_compressed_buffer, size_t
count = (c & 0x7f) + 1; count = (c & 0x7f) + 1;
if (c & 0x80) { if (c & 0x80) {
for (int i = 0; i < p_pixel_size; i++) { for (size_t i = 0; i < p_pixel_size; i++) {
pixels_w.ptr()[i] = p_compressed_buffer[compressed_pos]; pixels_w.ptr()[i] = p_compressed_buffer[compressed_pos];
compressed_pos += 1; compressed_pos += 1;
} }
for (int i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
for (int j = 0; j < p_pixel_size; j++) { for (size_t j = 0; j < p_pixel_size; j++) {
p_uncompressed_buffer[output_pos + j] = pixels_w.ptr()[j]; p_uncompressed_buffer[output_pos + j] = pixels_w.ptr()[j];
} }
output_pos += p_pixel_size; output_pos += p_pixel_size;
} }
} else { } else {
count *= p_pixel_size; count *= p_pixel_size;
for (int i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
p_uncompressed_buffer[output_pos] = p_compressed_buffer[compressed_pos]; p_uncompressed_buffer[output_pos] = p_compressed_buffer[compressed_pos];
compressed_pos += 1; compressed_pos += 1;
output_pos += 1; output_pos += 1;
@ -208,7 +208,7 @@ Error ImageLoaderTGA::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
PoolVector<uint8_t> src_image; PoolVector<uint8_t> src_image;
int src_image_len = f->get_len(); int src_image_len = f->get_len();
ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT); ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT);
ERR_FAIL_COND_V(src_image_len < sizeof(tga_header_s), ERR_FILE_CORRUPT); ERR_FAIL_COND_V(src_image_len < (int)sizeof(tga_header_s), ERR_FILE_CORRUPT);
src_image.resize(src_image_len); src_image.resize(src_image_len);
Error err = OK; Error err = OK;

View file

@ -501,7 +501,7 @@ void AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t
size_t block_size = (p_len - step) > BLOCK_SIZE ? BLOCK_SIZE : (p_len - step); size_t block_size = (p_len - step) > BLOCK_SIZE ? BLOCK_SIZE : (p_len - step);
for (int i = 0; i < block_size; i++) { for (uint32_t i = 0; i < block_size; i++) {
strm_in[i] = p_buffer[step + i]; strm_in[i] = p_buffer[step + i];
} }
@ -523,14 +523,14 @@ void AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t
//package->store_buffer(strm_out.ptr(), strm.total_out - total_out_before); //package->store_buffer(strm_out.ptr(), strm.total_out - total_out_before);
int start = file_buffer.size(); int start = file_buffer.size();
file_buffer.resize(file_buffer.size() + bh.compressed_size); file_buffer.resize(file_buffer.size() + bh.compressed_size);
for (int i = 0; i < bh.compressed_size; i++) for (uint32_t i = 0; i < bh.compressed_size; i++)
file_buffer[start + i] = strm_out[i]; file_buffer[start + i] = strm_out[i];
} else { } else {
bh.compressed_size = block_size; bh.compressed_size = block_size;
//package->store_buffer(strm_in.ptr(), block_size); //package->store_buffer(strm_in.ptr(), block_size);
int start = file_buffer.size(); int start = file_buffer.size();
file_buffer.resize(file_buffer.size() + block_size); file_buffer.resize(file_buffer.size() + block_size);
for (int i = 0; i < bh.compressed_size; i++) for (uint32_t i = 0; i < bh.compressed_size; i++)
file_buffer[start + i] = strm_in[i]; file_buffer[start + i] = strm_in[i];
} }
@ -553,7 +553,7 @@ void AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t
//package->store_buffer(strm_out.ptr(), strm.total_out - total_out_before); //package->store_buffer(strm_out.ptr(), strm.total_out - total_out_before);
int start = file_buffer.size(); int start = file_buffer.size();
file_buffer.resize(file_buffer.size() + (strm.total_out - total_out_before)); file_buffer.resize(file_buffer.size() + (strm.total_out - total_out_before));
for (int i = 0; i < (strm.total_out - total_out_before); i++) for (uint32_t i = 0; i < (strm.total_out - total_out_before); i++)
file_buffer[start + i] = strm_out[i]; file_buffer[start + i] = strm_out[i];
deflateEnd(&strm); deflateEnd(&strm);

View file

@ -534,7 +534,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
uint64_t now = OS::get_singleton()->get_ticks_msec(); uint64_t now = OS::get_singleton()->get_ticks_msec();
uint64_t diff = now - search_time_msec; uint64_t diff = now - search_time_msec;
if (diff < int(ProjectSettings::get_singleton()->get("gui/timers/incremental_search_max_interval_msec")) * 2) { if (diff < uint64_t(ProjectSettings::get_singleton()->get("gui/timers/incremental_search_max_interval_msec")) * 2) {
for (int i = current - 1; i >= 0; i--) { for (int i = current - 1; i >= 0; i--) {
@ -569,7 +569,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
uint64_t now = OS::get_singleton()->get_ticks_msec(); uint64_t now = OS::get_singleton()->get_ticks_msec();
uint64_t diff = now - search_time_msec; uint64_t diff = now - search_time_msec;
if (diff < int(ProjectSettings::get_singleton()->get("gui/timers/incremental_search_max_interval_msec")) * 2) { if (diff < uint64_t(ProjectSettings::get_singleton()->get("gui/timers/incremental_search_max_interval_msec")) * 2) {
for (int i = current + 1; i < items.size(); i++) { for (int i = current + 1; i < items.size(); i++) {

View file

@ -501,9 +501,9 @@ Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &fla
Vector<Ref<Image> > mipmap_images; Vector<Ref<Image> > mipmap_images;
int total_size = 0; int total_size = 0;
for (int i = 0; i < mipmaps; i++) { for (uint32_t i = 0; i < mipmaps; i++) {
if (i > 0) { if (i) {
size = f->get_32(); size = f->get_32();
} }

View file

@ -176,7 +176,7 @@ bool AudioRBResampler::mix(int32_t *p_dest, int p_frames) {
{ {
uint32_t read = 0; int read = 0;
switch (channels) { switch (channels) {
case 1: read = _resample<1>(p_dest, todo, increment); break; case 1: read = _resample<1>(p_dest, todo, increment); break;
case 2: read = _resample<2>(p_dest, todo, increment); break; case 2: read = _resample<2>(p_dest, todo, increment); break;
@ -189,7 +189,7 @@ bool AudioRBResampler::mix(int32_t *p_dest, int p_frames) {
if (remaining && todo > 0) { if (remaining && todo > 0) {
//print_line("fadeout"); //print_line("fadeout");
for (int c = 0; c < channels; c++) { for (uint32_t c = 0; c < channels; c++) {
for (int i = 0; i < todo; i++) { for (int i = 0; i < todo; i++) {
@ -202,7 +202,7 @@ bool AudioRBResampler::mix(int32_t *p_dest, int p_frames) {
} }
//zero out what remains there to avoid glitches //zero out what remains there to avoid glitches
for (int i = todo * channels; i < int(p_frames) * channels; i++) { for (uint32_t i = todo * channels; i < int(p_frames) * channels; i++) {
p_dest[i] = 0; p_dest[i] = 0;
} }
@ -250,7 +250,7 @@ Error AudioRBResampler::setup(int p_channels, int p_src_mix_rate, int p_target_m
rb_write_pos = 0; rb_write_pos = 0;
//avoid maybe strange noises upon load //avoid maybe strange noises upon load
for (int i = 0; i < (rb_len * channels); i++) { for (unsigned int i = 0; i < (rb_len * channels); i++) {
rb[i] = 0; rb[i] = 0;
read_buf[i] = 0; read_buf[i] = 0;

View file

@ -78,7 +78,7 @@ void AudioEffectChorusInstance::_process_chunk(const AudioFrame *p_src_frames, A
uint64_t increment = llrint(cycles_to_mix / (double)p_frame_count * (double)(1 << AudioEffectChorus::CYCLES_FRAC)); uint64_t increment = llrint(cycles_to_mix / (double)p_frame_count * (double)(1 << AudioEffectChorus::CYCLES_FRAC));
//check the LFO doesn't read ahead of the write pos //check the LFO doesn't read ahead of the write pos
if ((((int)max_depth_frames) + 10) > delay_frames) { //10 as some threshold to avoid precision stuff if ((((unsigned int)max_depth_frames) + 10) > delay_frames) { //10 as some threshold to avoid precision stuff
delay_frames += (int)max_depth_frames - delay_frames; delay_frames += (int)max_depth_frames - delay_frames;
delay_frames += 10; //threshold to avoid precision stuff delay_frames += 10; //threshold to avoid precision stuff
} }

View file

@ -640,7 +640,7 @@ BroadPhase2DHashGrid::BroadPhase2DHashGrid() {
cell_size = GLOBAL_DEF("physics/2d/cell_size", 128); cell_size = GLOBAL_DEF("physics/2d/cell_size", 128);
large_object_min_surface = GLOBAL_DEF("physics/2d/large_object_surface_threshold_in_cells", 512); large_object_min_surface = GLOBAL_DEF("physics/2d/large_object_surface_threshold_in_cells", 512);
for (int i = 0; i < hash_table_size; i++) for (uint32_t i = 0; i < hash_table_size; i++)
hash_table[i] = NULL; hash_table[i] = NULL;
pass = 1; pass = 1;
@ -649,7 +649,7 @@ BroadPhase2DHashGrid::BroadPhase2DHashGrid() {
BroadPhase2DHashGrid::~BroadPhase2DHashGrid() { BroadPhase2DHashGrid::~BroadPhase2DHashGrid() {
for (int i = 0; i < hash_table_size; i++) { for (uint32_t i = 0; i < hash_table_size; i++) {
while (hash_table[i]) { while (hash_table[i]) {
PosBin *pb = hash_table[i]; PosBin *pb = hash_table[i];
hash_table[i] = pb->next; hash_table[i] = pb->next;

View file

@ -1687,7 +1687,7 @@ bool VisualServerScene::_render_reflection_probe_step(Instance *p_instance, int
void VisualServerScene::_gi_probe_fill_local_data(int p_idx, int p_level, int p_x, int p_y, int p_z, const GIProbeDataCell *p_cell, const GIProbeDataHeader *p_header, InstanceGIProbeData::LocalData *p_local_data, Vector<uint32_t> *prev_cell) { void VisualServerScene::_gi_probe_fill_local_data(int p_idx, int p_level, int p_x, int p_y, int p_z, const GIProbeDataCell *p_cell, const GIProbeDataHeader *p_header, InstanceGIProbeData::LocalData *p_local_data, Vector<uint32_t> *prev_cell) {
if (p_level == p_header->cell_subdiv - 1) { if ((uint32_t)p_level == p_header->cell_subdiv - 1) {
Vector3 emission; Vector3 emission;
emission.x = (p_cell[p_idx].emission >> 24) / 255.0; emission.x = (p_cell[p_idx].emission >> 24) / 255.0;
@ -1798,9 +1798,9 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) {
} }
for (int i = 0; i < (int)header->cell_subdiv; i++) { for (int i = 0; i < (int)header->cell_subdiv; i++) {
uint32_t x = header->width >> i; int x = header->width >> i;
uint32_t y = header->height >> i; int y = header->height >> i;
uint32_t z = header->depth >> i; int z = header->depth >> i;
//create and clear mipmap //create and clear mipmap
PoolVector<uint8_t> mipmap; PoolVector<uint8_t> mipmap;
@ -1896,7 +1896,7 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) {
uint8_t alpha_block[4][4] = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } }; uint8_t alpha_block[4][4] = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } };
for (int j = 0; j < k.source_count; j++) { for (uint32_t j = 0; j < k.source_count; j++) {
int alpha = (cells[k.sources[j]].level_alpha >> 8) & 0xFF; int alpha = (cells[k.sources[j]].level_alpha >> 8) & 0xFF;
if (alpha < min_alpha) if (alpha < min_alpha)
@ -2389,7 +2389,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
Vector3 colors[16]; Vector3 colors[16];
for (int j = 0; j < b.source_count; j++) { for (uint32_t j = 0; j < b.source_count; j++) {
colors[j].x = (local_data[b.sources[j]].energy[0] / float(probe_data->dynamic.bake_dynamic_range)) / 1024.0; colors[j].x = (local_data[b.sources[j]].energy[0] / float(probe_data->dynamic.bake_dynamic_range)) / 1024.0;
colors[j].y = (local_data[b.sources[j]].energy[1] / float(probe_data->dynamic.bake_dynamic_range)) / 1024.0; colors[j].y = (local_data[b.sources[j]].energy[1] / float(probe_data->dynamic.bake_dynamic_range)) / 1024.0;
@ -2403,8 +2403,8 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
if (b.source_count == 16) { if (b.source_count == 16) {
//all cells are used so, find minmax between them //all cells are used so, find minmax between them
int further_apart[2] = { 0, 0 }; int further_apart[2] = { 0, 0 };
for (int j = 0; j < b.source_count; j++) { for (uint32_t j = 0; j < b.source_count; j++) {
for (int k = j + 1; k < b.source_count; k++) { for (uint32_t k = j + 1; k < b.source_count; k++) {
float d = colors[j].distance_squared_to(colors[k]); float d = colors[j].distance_squared_to(colors[k]);
if (d > distance) { if (d > distance) {
distance = d; distance = d;
@ -2424,12 +2424,12 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
//average all colors first //average all colors first
Vector3 average; Vector3 average;
for (int j = 0; j < b.source_count; j++) { for (uint32_t j = 0; j < b.source_count; j++) {
average += colors[j]; average += colors[j];
} }
average.normalize(); average.normalize();
//find max distance in normal from average //find max distance in normal from average
for (int j = 0; j < b.source_count; j++) { for (uint32_t j = 0; j < b.source_count; j++) {
float d = average.dot(colors[j]); float d = average.dot(colors[j]);
distance = MAX(d, distance); distance = MAX(d, distance);
} }
@ -2459,7 +2459,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
Vector3 dir = (to - from).normalized(); Vector3 dir = (to - from).normalized();
for (int j = 0; j < b.source_count; j++) { for (uint32_t j = 0; j < b.source_count; j++) {
float d = (colors[j] - from).dot(dir) / distance; float d = (colors[j] - from).dot(dir) / distance;
indices[j] = int(d * 3 + 0.5); indices[j] = int(d * 3 + 0.5);
@ -2469,7 +2469,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
indices[j] = index_swap[CLAMP(indices[j], 0, 3)]; indices[j] = index_swap[CLAMP(indices[j], 0, 3)];
} }
} else { } else {
for (int j = 0; j < b.source_count; j++) { for (uint32_t j = 0; j < b.source_count; j++) {
indices[j] = 0; indices[j] = 0;
} }
} }
@ -2478,7 +2478,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
uint32_t index_block[16] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; uint32_t index_block[16] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
for (int j = 0; j < b.source_count; j++) { for (uint32_t j = 0; j < b.source_count; j++) {
int x = local_data[b.sources[j]].pos[0] % 4; int x = local_data[b.sources[j]].pos[0] % 4;
int y = local_data[b.sources[j]].pos[1] % 4; int y = local_data[b.sources[j]].pos[1] % 4;