Style: Apply clang-tidy fixes (superficial)

• `modernize-use-bool-literals`, `modernize-use-nullptr`, and `readability-braces-around-statements`
This commit is contained in:
Thaddeus Crews 2024-06-21 11:21:18 -05:00
parent 89a311205f
commit bb5f390fb9
No known key found for this signature in database
GPG Key ID: 62181B86FE9E5D84
46 changed files with 126 additions and 102 deletions

View File

@ -1034,7 +1034,7 @@ void Input::action_release(const StringName &p_action) {
// Create or retrieve existing action. // Create or retrieve existing action.
ActionState &action_state = action_states[p_action]; ActionState &action_state = action_states[p_action];
action_state.cache.pressed = 0; action_state.cache.pressed = false;
action_state.cache.strength = 0.0; action_state.cache.strength = 0.0;
action_state.cache.raw_strength = 0.0; action_state.cache.raw_strength = 0.0;
// As input may come in part way through a physics tick, the earliest we can react to it is the next physics tick. // As input may come in part way through a physics tick, the earliest we can react to it is the next physics tick.

View File

@ -153,7 +153,7 @@ public:
bool is_flushing() const; bool is_flushing() const;
int get_max_buffer_usage() const; int get_max_buffer_usage() const;
CallQueue(Allocator *p_custom_allocator = 0, uint32_t p_max_pages = 8192, const String &p_error_text = String()); CallQueue(Allocator *p_custom_allocator = nullptr, uint32_t p_max_pages = 8192, const String &p_error_text = String());
virtual ~CallQueue(); virtual ~CallQueue();
}; };

View File

@ -396,7 +396,7 @@ public:
_FORCE_INLINE_ bool particles_has_collision(RID p_particles) { _FORCE_INLINE_ bool particles_has_collision(RID p_particles) {
Particles *particles = particles_owner.get_or_null(p_particles); Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_NULL_V(particles, 0); ERR_FAIL_NULL_V(particles, false);
return particles->has_collision_cache; return particles->has_collision_cache;
} }

View File

@ -1519,7 +1519,7 @@ RDD::BufferID RenderingDeviceDriverVulkan::buffer_create(uint64_t p_size, BitFie
ERR_FAIL_COND_V_MSG(err, BufferID(), "Can't create buffer of size: " + itos(p_size) + ", error " + itos(err) + "."); ERR_FAIL_COND_V_MSG(err, BufferID(), "Can't create buffer of size: " + itos(p_size) + ", error " + itos(err) + ".");
err = vmaAllocateMemoryForBuffer(allocator, vk_buffer, &alloc_create_info, &allocation, &alloc_info); err = vmaAllocateMemoryForBuffer(allocator, vk_buffer, &alloc_create_info, &allocation, &alloc_info);
ERR_FAIL_COND_V_MSG(err, BufferID(), "Can't allocate memory for buffer of size: " + itos(p_size) + ", error " + itos(err) + "."); ERR_FAIL_COND_V_MSG(err, BufferID(), "Can't allocate memory for buffer of size: " + itos(p_size) + ", error " + itos(err) + ".");
err = vmaBindBufferMemory2(allocator, allocation, 0, vk_buffer, NULL); err = vmaBindBufferMemory2(allocator, allocation, 0, vk_buffer, nullptr);
ERR_FAIL_COND_V_MSG(err, BufferID(), "Can't bind memory to buffer of size: " + itos(p_size) + ", error " + itos(err) + "."); ERR_FAIL_COND_V_MSG(err, BufferID(), "Can't bind memory to buffer of size: " + itos(p_size) + ", error " + itos(err) + ".");
// Bookkeep. // Bookkeep.
@ -1745,7 +1745,7 @@ RDD::TextureID RenderingDeviceDriverVulkan::texture_create(const TextureFormat &
ERR_FAIL_COND_V_MSG(err, TextureID(), "vkCreateImage failed with error " + itos(err) + "."); ERR_FAIL_COND_V_MSG(err, TextureID(), "vkCreateImage failed with error " + itos(err) + ".");
err = vmaAllocateMemoryForImage(allocator, vk_image, &alloc_create_info, &allocation, &alloc_info); err = vmaAllocateMemoryForImage(allocator, vk_image, &alloc_create_info, &allocation, &alloc_info);
ERR_FAIL_COND_V_MSG(err, TextureID(), "Can't allocate memory for image, error: " + itos(err) + "."); ERR_FAIL_COND_V_MSG(err, TextureID(), "Can't allocate memory for image, error: " + itos(err) + ".");
err = vmaBindImageMemory2(allocator, allocation, 0, vk_image, NULL); err = vmaBindImageMemory2(allocator, allocation, 0, vk_image, nullptr);
ERR_FAIL_COND_V_MSG(err, TextureID(), "Can't bind memory to image, error: " + itos(err) + "."); ERR_FAIL_COND_V_MSG(err, TextureID(), "Can't bind memory to image, error: " + itos(err) + ".");
// Create view. // Create view.

View File

@ -282,7 +282,7 @@ Error DirAccessWindows::rename(String p_path, String p_new_path) {
uint64_t id = OS::get_singleton()->get_ticks_usec(); uint64_t id = OS::get_singleton()->get_ticks_usec();
while (true) { while (true) {
tmpfile_utf16 = (path + itos(id++) + ".tmp").utf16(); tmpfile_utf16 = (path + itos(id++) + ".tmp").utf16();
HANDLE handle = CreateFileW((LPCWSTR)tmpfile_utf16.get_data(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); HANDLE handle = CreateFileW((LPCWSTR)tmpfile_utf16.get_data(), GENERIC_WRITE, 0, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
if (handle != INVALID_HANDLE_VALUE) { if (handle != INVALID_HANDLE_VALUE) {
CloseHandle(handle); CloseHandle(handle);
break; break;

View File

@ -193,7 +193,7 @@ Error FileAccessWindows::open_internal(const String &p_path, int p_mode_flags) {
uint64_t id = OS::get_singleton()->get_ticks_usec(); uint64_t id = OS::get_singleton()->get_ticks_usec();
while (true) { while (true) {
tmpfile = path + itos(id++) + ".tmp"; tmpfile = path + itos(id++) + ".tmp";
HANDLE handle = CreateFileW((LPCWSTR)tmpfile.utf16().get_data(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); HANDLE handle = CreateFileW((LPCWSTR)tmpfile.utf16().get_data(), GENERIC_WRITE, 0, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
if (handle != INVALID_HANDLE_VALUE) { if (handle != INVALID_HANDLE_VALUE) {
CloseHandle(handle); CloseHandle(handle);
break; break;

View File

@ -40,7 +40,7 @@ Error FileAccessWindowsPipe::open_existing(HANDLE p_rfd, HANDLE p_wfd, bool p_bl
_close(); _close();
path_src = String(); path_src = String();
ERR_FAIL_COND_V_MSG(fd[0] != 0 || fd[1] != 0, ERR_ALREADY_IN_USE, "Pipe is already in use."); ERR_FAIL_COND_V_MSG(fd[0] != nullptr || fd[1] != nullptr, ERR_ALREADY_IN_USE, "Pipe is already in use.");
fd[0] = p_rfd; fd[0] = p_rfd;
fd[1] = p_wfd; fd[1] = p_wfd;
@ -58,18 +58,18 @@ Error FileAccessWindowsPipe::open_internal(const String &p_path, int p_mode_flag
_close(); _close();
path_src = p_path; path_src = p_path;
ERR_FAIL_COND_V_MSG(fd[0] != 0 || fd[1] != 0, ERR_ALREADY_IN_USE, "Pipe is already in use."); ERR_FAIL_COND_V_MSG(fd[0] != nullptr || fd[1] != nullptr, ERR_ALREADY_IN_USE, "Pipe is already in use.");
path = String("\\\\.\\pipe\\LOCAL\\") + p_path.replace("pipe://", "").replace("/", "_"); path = String("\\\\.\\pipe\\LOCAL\\") + p_path.replace("pipe://", "").replace("/", "_");
HANDLE h = CreateFileW((LPCWSTR)path.utf16().get_data(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); HANDLE h = CreateFileW((LPCWSTR)path.utf16().get_data(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
if (h == INVALID_HANDLE_VALUE) { if (h == INVALID_HANDLE_VALUE) {
h = CreateNamedPipeW((LPCWSTR)path.utf16().get_data(), PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT, 1, 4096, 4096, 0, nullptr); h = CreateNamedPipeW((LPCWSTR)path.utf16().get_data(), PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT, 1, 4096, 4096, 0, nullptr);
if (h == INVALID_HANDLE_VALUE) { if (h == INVALID_HANDLE_VALUE) {
last_error = ERR_FILE_CANT_OPEN; last_error = ERR_FILE_CANT_OPEN;
return last_error; return last_error;
} }
ConnectNamedPipe(h, NULL); ConnectNamedPipe(h, nullptr);
} }
fd[0] = h; fd[0] = h;
fd[1] = h; fd[1] = h;
@ -79,19 +79,19 @@ Error FileAccessWindowsPipe::open_internal(const String &p_path, int p_mode_flag
} }
void FileAccessWindowsPipe::_close() { void FileAccessWindowsPipe::_close() {
if (fd[0] == 0) { if (fd[0] == nullptr) {
return; return;
} }
if (fd[1] != fd[0]) { if (fd[1] != fd[0]) {
CloseHandle(fd[1]); CloseHandle(fd[1]);
} }
CloseHandle(fd[0]); CloseHandle(fd[0]);
fd[0] = 0; fd[0] = nullptr;
fd[1] = 0; fd[1] = nullptr;
} }
bool FileAccessWindowsPipe::is_open() const { bool FileAccessWindowsPipe::is_open() const {
return (fd[0] != 0 || fd[1] != 0); return (fd[0] != nullptr || fd[1] != nullptr);
} }
String FileAccessWindowsPipe::get_path() const { String FileAccessWindowsPipe::get_path() const {
@ -103,7 +103,7 @@ String FileAccessWindowsPipe::get_path_absolute() const {
} }
uint64_t FileAccessWindowsPipe::get_buffer(uint8_t *p_dst, uint64_t p_length) const { uint64_t FileAccessWindowsPipe::get_buffer(uint8_t *p_dst, uint64_t p_length) const {
ERR_FAIL_COND_V_MSG(fd[0] == 0, -1, "Pipe must be opened before use."); ERR_FAIL_COND_V_MSG(fd[0] == nullptr, -1, "Pipe must be opened before use.");
ERR_FAIL_COND_V(!p_dst && p_length > 0, -1); ERR_FAIL_COND_V(!p_dst && p_length > 0, -1);
DWORD read = 0; DWORD read = 0;
@ -120,7 +120,7 @@ Error FileAccessWindowsPipe::get_error() const {
} }
void FileAccessWindowsPipe::store_buffer(const uint8_t *p_src, uint64_t p_length) { void FileAccessWindowsPipe::store_buffer(const uint8_t *p_src, uint64_t p_length) {
ERR_FAIL_COND_MSG(fd[1] == 0, "Pipe must be opened before use."); ERR_FAIL_COND_MSG(fd[1] == nullptr, "Pipe must be opened before use.");
ERR_FAIL_COND(!p_src && p_length > 0); ERR_FAIL_COND(!p_src && p_length > 0);
DWORD read = -1; DWORD read = -1;

View File

@ -39,7 +39,7 @@
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
class FileAccessWindowsPipe : public FileAccess { class FileAccessWindowsPipe : public FileAccess {
HANDLE fd[2] = { 0, 0 }; HANDLE fd[2] = { nullptr, nullptr };
mutable Error last_error = OK; mutable Error last_error = OK;

View File

@ -6337,8 +6337,9 @@ bool AnimationTrackEditor::_is_track_compatible(int p_target_track_idx, Variant:
} }
if (path_valid) { if (path_valid) {
if (is_source_bezier) if (is_source_bezier) {
p_source_value_type = Variant::FLOAT; p_source_value_type = Variant::FLOAT;
}
return property_type == p_source_value_type; return property_type == p_source_value_type;
} else { } else {
if (animation->track_get_key_count(p_target_track_idx) > 0) { if (animation->track_get_key_count(p_target_track_idx) > 0) {

View File

@ -859,7 +859,7 @@ void BoneMapper::auto_mapping_process(Ref<BoneMap> &p_bone_map) {
// 4-1. Guess Finger // 4-1. Guess Finger
int tips_index = -1; int tips_index = -1;
bool thumb_tips_size = 0; bool thumb_tips_size = false;
bool named_finger_is_found = false; bool named_finger_is_found = false;
LocalVector<String> fingers; LocalVector<String> fingers;
fingers.push_back("thumb|pollex"); fingers.push_back("thumb|pollex");
@ -994,7 +994,7 @@ void BoneMapper::auto_mapping_process(Ref<BoneMap> &p_bone_map) {
} }
tips_index = -1; tips_index = -1;
thumb_tips_size = 0; thumb_tips_size = false;
named_finger_is_found = false; named_finger_is_found = false;
if (right_hand_or_palm != -1) { if (right_hand_or_palm != -1) {
LocalVector<LocalVector<String>> right_fingers_map; LocalVector<LocalVector<String>> right_fingers_map;

View File

@ -470,7 +470,7 @@ void EditorPropertyOTVariation::update_property() {
Vector3i range = supported.get_value_at_index(i); Vector3i range = supported.get_value_at_index(i);
EditorPropertyInteger *prop = memnew(EditorPropertyInteger); EditorPropertyInteger *prop = memnew(EditorPropertyInteger);
prop->setup(range.x, range.y, false, 1, false, false); prop->setup(range.x, range.y, false, true, false, false);
prop->set_object_and_property(object.ptr(), "keys/" + itos(name_tag)); prop->set_object_and_property(object.ptr(), "keys/" + itos(name_tag));
String name = TS->tag_to_name(name_tag); String name = TS->tag_to_name(name_tag);

View File

@ -1550,6 +1550,7 @@ int TileMapLayerEditorTilesPlugin::_get_transformed_alternative(int p_alternativ
case TRANSFORM_ROTATE_RIGHT: { case TRANSFORM_ROTATE_RIGHT: {
// A matrix with every possible flip/transpose combination, sorted by what comes next when you rotate. // A matrix with every possible flip/transpose combination, sorted by what comes next when you rotate.
const LocalVector<bool> rotation_matrix = { const LocalVector<bool> rotation_matrix = {
// NOLINTBEGIN(modernize-use-bool-literals)
0, 0, 0, 0, 0, 0,
0, 1, 1, 0, 1, 1,
1, 1, 0, 1, 1, 0,
@ -1558,6 +1559,7 @@ int TileMapLayerEditorTilesPlugin::_get_transformed_alternative(int p_alternativ
0, 0, 1, 0, 0, 1,
0, 1, 0, 0, 1, 0,
1, 1, 1 1, 1, 1
// NOLINTEND(modernize-use-bool-literals)
}; };
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {

View File

@ -716,8 +716,9 @@ Vector<String> ProjectConverter3To4::check_for_files() {
directories_to_check.append(current_dir.path_join(file_name) + "/"); directories_to_check.append(current_dir.path_join(file_name) + "/");
} else { } else {
bool proper_extension = false; bool proper_extension = false;
if (file_name.ends_with(".gd") || file_name.ends_with(".shader") || file_name.ends_with(".gdshader") || file_name.ends_with(".tscn") || file_name.ends_with(".tres") || file_name.ends_with(".godot") || file_name.ends_with(".cs") || file_name.ends_with(".csproj") || file_name.ends_with(".import")) if (file_name.ends_with(".gd") || file_name.ends_with(".shader") || file_name.ends_with(".gdshader") || file_name.ends_with(".tscn") || file_name.ends_with(".tres") || file_name.ends_with(".godot") || file_name.ends_with(".cs") || file_name.ends_with(".csproj") || file_name.ends_with(".import")) {
proper_extension = true; proper_extension = true;
}
if (proper_extension) { if (proper_extension) {
collected_files.append(current_dir.path_join(file_name)); collected_files.append(current_dir.path_join(file_name));
@ -1321,8 +1322,9 @@ Vector<String> ProjectConverter3To4::parse_arguments(const String &line) {
break; break;
}; };
case '"': { case '"': {
if (previous_character != '\\') if (previous_character != '\\') {
is_inside_string = !is_inside_string; is_inside_string = !is_inside_string;
}
} }
} }
previous_character = character; previous_character = character;

View File

@ -145,7 +145,7 @@ bool CameraFeedLinux::_request_buffers() {
} }
buffers[i].length = buffer.length; buffers[i].length = buffer.length;
buffers[i].start = mmap(NULL, buffer.length, PROT_READ | PROT_WRITE, MAP_SHARED, file_descriptor, buffer.m.offset); buffers[i].start = mmap(nullptr, buffer.length, PROT_READ | PROT_WRITE, MAP_SHARED, file_descriptor, buffer.m.offset);
if (buffers[i].start == MAP_FAILED) { if (buffers[i].start == MAP_FAILED) {
for (unsigned int b = 0; b < i; b++) { for (unsigned int b = 0; b < i; b++) {

View File

@ -369,21 +369,25 @@ Error FBXDocument::_parse_nodes(Ref<FBXState> p_state) {
// all skin clusters connected to the bone. // all skin clusters connected to the bone.
for (const ufbx_connection &child_conn : fbx_node->element.connections_src) { for (const ufbx_connection &child_conn : fbx_node->element.connections_src) {
ufbx_skin_cluster *child_cluster = ufbx_as_skin_cluster(child_conn.dst); ufbx_skin_cluster *child_cluster = ufbx_as_skin_cluster(child_conn.dst);
if (!child_cluster) if (!child_cluster) {
continue; continue;
}
ufbx_skin_deformer *child_deformer = _find_skin_deformer(child_cluster); ufbx_skin_deformer *child_deformer = _find_skin_deformer(child_cluster);
if (!child_deformer) if (!child_deformer) {
continue; continue;
}
// Found a skin cluster: Now iterate through all the skin clusters of the parent and // Found a skin cluster: Now iterate through all the skin clusters of the parent and
// try to find one that used by the same deformer. // try to find one that used by the same deformer.
for (const ufbx_connection &parent_conn : fbx_node->parent->element.connections_src) { for (const ufbx_connection &parent_conn : fbx_node->parent->element.connections_src) {
ufbx_skin_cluster *parent_cluster = ufbx_as_skin_cluster(parent_conn.dst); ufbx_skin_cluster *parent_cluster = ufbx_as_skin_cluster(parent_conn.dst);
if (!parent_cluster) if (!parent_cluster) {
continue; continue;
}
ufbx_skin_deformer *parent_deformer = _find_skin_deformer(parent_cluster); ufbx_skin_deformer *parent_deformer = _find_skin_deformer(parent_cluster);
if (parent_deformer != child_deformer) if (parent_deformer != child_deformer) {
continue; continue;
}
// Success: Found two skin clusters from the same deformer, now we can resolve the // Success: Found two skin clusters from the same deformer, now we can resolve the
// local bind pose from the difference between the two world-space bind poses. // local bind pose from the difference between the two world-space bind poses.

View File

@ -790,8 +790,9 @@ void GDScriptFunction::disassemble(const Vector<String> &p_code_lines) const {
text += method->get_name(); text += method->get_name();
text += "("; text += "(";
for (int i = 0; i < argc; i++) { for (int i = 0; i < argc; i++) {
if (i > 0) if (i > 0) {
text += ", "; text += ", ";
}
text += DADDR(1 + i); text += DADDR(1 + i);
} }
text += ")"; text += ")";
@ -833,8 +834,9 @@ void GDScriptFunction::disassemble(const Vector<String> &p_code_lines) const {
text += method->get_name(); text += method->get_name();
text += "("; text += "(";
for (int i = 0; i < argc; i++) { for (int i = 0; i < argc; i++) {
if (i > 0) if (i > 0) {
text += ", "; text += ", ";
}
text += DADDR(1 + i); text += DADDR(1 + i);
} }
text += ")"; text += ")";

View File

@ -311,7 +311,7 @@ bool GodotPinJoint2D::get_flag(PhysicsServer2D::PinJointFlag p_flag) const {
return motor_enabled; return motor_enabled;
} }
} }
ERR_FAIL_V(0); ERR_FAIL_V(false);
} }
GodotPinJoint2D::GodotPinJoint2D(const Vector2 &p_pos, GodotBody2D *p_body_a, GodotBody2D *p_body_b) : GodotPinJoint2D::GodotPinJoint2D(const Vector2 &p_pos, GodotBody2D *p_body_a, GodotBody2D *p_body_b) :

View File

@ -1169,8 +1169,8 @@ void GodotPhysicsServer2D::pin_joint_set_flag(RID p_joint, PinJointFlag p_flag,
bool GodotPhysicsServer2D::pin_joint_get_flag(RID p_joint, PinJointFlag p_flag) const { bool GodotPhysicsServer2D::pin_joint_get_flag(RID p_joint, PinJointFlag p_flag) const {
GodotJoint2D *joint = joint_owner.get_or_null(p_joint); GodotJoint2D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0); ERR_FAIL_NULL_V(joint, false);
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, 0); ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, false);
GodotPinJoint2D *pin_joint = static_cast<GodotPinJoint2D *>(joint); GodotPinJoint2D *pin_joint = static_cast<GodotPinJoint2D *>(joint);
return pin_joint->get_flag(p_flag); return pin_joint->get_flag(p_flag);

View File

@ -342,7 +342,7 @@ bool GodotPhysicsDirectSpaceState2D::collide_shape(const ShapeParameters &p_para
} }
GodotShape2D *shape = GodotPhysicsServer2D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid); GodotShape2D *shape = GodotPhysicsServer2D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid);
ERR_FAIL_NULL_V(shape, 0); ERR_FAIL_NULL_V(shape, false);
Rect2 aabb = p_parameters.transform.xform(shape->get_aabb()); Rect2 aabb = p_parameters.transform.xform(shape->get_aabb());
aabb = aabb.merge(Rect2(aabb.position + p_parameters.motion, aabb.size)); //motion aabb = aabb.merge(Rect2(aabb.position + p_parameters.motion, aabb.size)); //motion
@ -439,7 +439,7 @@ static void _rest_cbk_result(const Vector2 &p_point_A, const Vector2 &p_point_B,
bool GodotPhysicsDirectSpaceState2D::rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) { bool GodotPhysicsDirectSpaceState2D::rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) {
GodotShape2D *shape = GodotPhysicsServer2D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid); GodotShape2D *shape = GodotPhysicsServer2D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid);
ERR_FAIL_NULL_V(shape, 0); ERR_FAIL_NULL_V(shape, false);
real_t margin = MAX(p_parameters.margin, TEST_MOTION_MARGIN_MIN_VALUE); real_t margin = MAX(p_parameters.margin, TEST_MOTION_MARGIN_MIN_VALUE);

View File

@ -76,8 +76,9 @@ struct _CollectorCallback {
Vector3 *prev_axis = nullptr; Vector3 *prev_axis = nullptr;
_FORCE_INLINE_ void call(const Vector3 &p_point_A, const Vector3 &p_point_B, Vector3 p_normal) { _FORCE_INLINE_ void call(const Vector3 &p_point_A, const Vector3 &p_point_B, Vector3 p_normal) {
if (p_normal.dot(p_point_B - p_point_A) < 0) if (p_normal.dot(p_point_B - p_point_A) < 0) {
p_normal = -p_normal; p_normal = -p_normal;
}
if (swap) { if (swap) {
callback(p_point_B, 0, p_point_A, 0, -p_normal, userdata); callback(p_point_B, 0, p_point_A, 0, -p_normal, userdata);
} else { } else {
@ -175,10 +176,11 @@ static void _generate_contacts_edge_edge(const Vector3 *p_points_A, int p_point_
// The normal should be perpendicular to both edges. // The normal should be perpendicular to both edges.
Vector3 normal = rel_A.cross(rel_B); Vector3 normal = rel_A.cross(rel_B);
real_t normal_len = normal.length(); real_t normal_len = normal.length();
if (normal_len > 1e-3) if (normal_len > 1e-3) {
normal /= normal_len; normal /= normal_len;
else } else {
normal = p_callback->normal; normal = p_callback->normal;
}
p_callback->call(closest_A, closest_B, normal); p_callback->call(closest_A, closest_B, normal);
} }
@ -784,8 +786,9 @@ static void analytic_sphere_collision(const Vector3 &p_origin_a, real_t p_radius
// Calculate the sphere overlap, and bail if not overlapping // Calculate the sphere overlap, and bail if not overlapping
real_t overlap = p_radius_a + p_radius_b - b_to_a_len; real_t overlap = p_radius_a + p_radius_b - b_to_a_len;
if (overlap < 0) if (overlap < 0) {
return; return;
}
// Report collision // Report collision
p_collector->collided = true; p_collector->collided = true;

View File

@ -826,7 +826,7 @@ void GodotPhysicsServer3D::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool
bool GodotPhysicsServer3D::body_is_axis_locked(RID p_body, BodyAxis p_axis) const { bool GodotPhysicsServer3D::body_is_axis_locked(RID p_body, BodyAxis p_axis) const {
const GodotBody3D *body = body_owner.get_or_null(p_body); const GodotBody3D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL_V(body, 0); ERR_FAIL_NULL_V(body, false);
return body->is_axis_locked(p_axis); return body->is_axis_locked(p_axis);
} }

View File

@ -1133,8 +1133,9 @@ void GodotConvexPolygonShape3D::_setup(const Vector<Vector3> &p_vertices) {
max_support = s; max_support = s;
} }
} }
if (!extreme_vertices.has(best_vertex)) if (!extreme_vertices.has(best_vertex)) {
extreme_vertices.push_back(best_vertex); extreme_vertices.push_back(best_vertex);
}
} }
} }
} }

View File

@ -385,7 +385,7 @@ bool GodotPhysicsDirectSpaceState3D::collide_shape(const ShapeParameters &p_para
} }
GodotShape3D *shape = GodotPhysicsServer3D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid); GodotShape3D *shape = GodotPhysicsServer3D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid);
ERR_FAIL_NULL_V(shape, 0); ERR_FAIL_NULL_V(shape, false);
AABB aabb = p_parameters.transform.xform(shape->get_aabb()); AABB aabb = p_parameters.transform.xform(shape->get_aabb());
aabb = aabb.grow(p_parameters.margin); aabb = aabb.grow(p_parameters.margin);
@ -511,7 +511,7 @@ static void _rest_cbk_result(const Vector3 &p_point_A, int p_index_A, const Vect
bool GodotPhysicsDirectSpaceState3D::rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) { bool GodotPhysicsDirectSpaceState3D::rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) {
GodotShape3D *shape = GodotPhysicsServer3D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid); GodotShape3D *shape = GodotPhysicsServer3D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid);
ERR_FAIL_NULL_V(shape, 0); ERR_FAIL_NULL_V(shape, false);
real_t margin = MAX(p_parameters.margin, TEST_MOTION_MARGIN_MIN_VALUE); real_t margin = MAX(p_parameters.margin, TEST_MOTION_MARGIN_MIN_VALUE);

View File

@ -647,7 +647,7 @@ void GodotGeneric6DOFJoint3D::set_flag(Vector3::Axis p_axis, PhysicsServer3D::G6
} }
bool GodotGeneric6DOFJoint3D::get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const { bool GodotGeneric6DOFJoint3D::get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const {
ERR_FAIL_INDEX_V(p_axis, 3, 0); ERR_FAIL_INDEX_V(p_axis, 3, false);
switch (p_flag) { switch (p_flag) {
case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: { case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: {
return m_linearLimits.enable_limit[p_axis]; return m_linearLimits.enable_limit[p_axis];

View File

@ -341,7 +341,7 @@ XrCompositionLayerBaseHeader *OpenXRViewportCompositionLayerProvider::get_compos
} }
XrSwapchainSubImage subimage = { XrSwapchainSubImage subimage = {
0, // swapchain 0, // swapchain // NOLINT(modernize-use-nullptr) - 32-bit uses non-pointer uint64
{ { 0, 0 }, { 0, 0 } }, // imageRect { { 0, 0 }, { 0, 0 } }, // imageRect
0, // imageArrayIndex 0, // imageArrayIndex
}; };

View File

@ -173,7 +173,7 @@ void OpenXRDebugUtilsExtension::begin_debug_label_region(const char *p_label_nam
const XrDebugUtilsLabelEXT session_active_region_label = { const XrDebugUtilsLabelEXT session_active_region_label = {
XR_TYPE_DEBUG_UTILS_LABEL_EXT, // type XR_TYPE_DEBUG_UTILS_LABEL_EXT, // type
NULL, // next nullptr, // next
p_label_name, // labelName p_label_name, // labelName
}; };
@ -199,7 +199,7 @@ void OpenXRDebugUtilsExtension::insert_debug_label(const char *p_label_name) {
const XrDebugUtilsLabelEXT session_active_region_label = { const XrDebugUtilsLabelEXT session_active_region_label = {
XR_TYPE_DEBUG_UTILS_LABEL_EXT, // type XR_TYPE_DEBUG_UTILS_LABEL_EXT, // type
NULL, // next nullptr, // next
p_label_name, // labelName p_label_name, // labelName
}; };

View File

@ -193,7 +193,7 @@ void *OpenXROpenGLExtension::set_session_create_and_get_next_pointer(void *p_nex
// spec says to use proper values but runtimes don't care // spec says to use proper values but runtimes don't care
graphics_binding_gl.visualid = 0; graphics_binding_gl.visualid = 0;
graphics_binding_gl.glxFBConfig = 0; graphics_binding_gl.glxFBConfig = nullptr;
#endif #endif
#endif #endif

View File

@ -2752,8 +2752,9 @@ void OpenXRAPI::parse_velocities(const XrSpaceVelocity &p_velocity, Vector3 &r_l
} }
bool OpenXRAPI::xr_result(XrResult result, const char *format, Array args) const { bool OpenXRAPI::xr_result(XrResult result, const char *format, Array args) const {
if (XR_SUCCEEDED(result)) if (XR_SUCCEEDED(result)) {
return true; return true;
}
char resultString[XR_MAX_RESULT_STRING_SIZE]; char resultString[XR_MAX_RESULT_STRING_SIZE];
xrResultToString(instance, result, resultString); xrResultToString(instance, result, resultString);

View File

@ -115,7 +115,7 @@ void VideoStreamPlaybackTheora::video_write() {
format = Image::FORMAT_RGBA8; format = Image::FORMAT_RGBA8;
} }
Ref<Image> img = memnew(Image(size.x, size.y, 0, Image::FORMAT_RGBA8, frame_data)); //zero copy image creation Ref<Image> img = memnew(Image(size.x, size.y, false, Image::FORMAT_RGBA8, frame_data)); //zero copy image creation
texture->update(img); //zero copy send to rendering server texture->update(img); //zero copy send to rendering server

View File

@ -149,7 +149,7 @@ Ref<Image> _webp_unpack(const Vector<uint8_t> &p_buffer) {
ERR_FAIL_COND_V_MSG(errdec, Ref<Image>(), "Failed decoding WebP image."); ERR_FAIL_COND_V_MSG(errdec, Ref<Image>(), "Failed decoding WebP image.");
Ref<Image> img = memnew(Image(features.width, features.height, 0, features.has_alpha ? Image::FORMAT_RGBA8 : Image::FORMAT_RGB8, dst_image)); Ref<Image> img = memnew(Image(features.width, features.height, false, features.has_alpha ? Image::FORMAT_RGBA8 : Image::FORMAT_RGB8, dst_image));
return img; return img;
} }

View File

@ -771,11 +771,11 @@ Vector<String> OS_LinuxBSD::get_system_font_path_for_text(const String &p_font_n
FcLangSetAdd(lang_set, reinterpret_cast<const FcChar8 *>(p_locale.utf8().get_data())); FcLangSetAdd(lang_set, reinterpret_cast<const FcChar8 *>(p_locale.utf8().get_data()));
FcPatternAddLangSet(pattern, FC_LANG, lang_set); FcPatternAddLangSet(pattern, FC_LANG, lang_set);
FcConfigSubstitute(0, pattern, FcMatchPattern); FcConfigSubstitute(nullptr, pattern, FcMatchPattern);
FcDefaultSubstitute(pattern); FcDefaultSubstitute(pattern);
FcResult result; FcResult result;
FcPattern *match = FcFontMatch(0, pattern, &result); FcPattern *match = FcFontMatch(nullptr, pattern, &result);
if (match) { if (match) {
char *file_name = nullptr; char *file_name = nullptr;
if (FcPatternGetString(match, FC_FILE, 0, reinterpret_cast<FcChar8 **>(&file_name)) == FcResultMatch) { if (FcPatternGetString(match, FC_FILE, 0, reinterpret_cast<FcChar8 **>(&file_name)) == FcResultMatch) {
@ -816,11 +816,11 @@ String OS_LinuxBSD::get_system_font_path(const String &p_font_name, int p_weight
FcPatternAddInteger(pattern, FC_WIDTH, _stretch_to_fc(p_stretch)); FcPatternAddInteger(pattern, FC_WIDTH, _stretch_to_fc(p_stretch));
FcPatternAddInteger(pattern, FC_SLANT, p_italic ? FC_SLANT_ITALIC : FC_SLANT_ROMAN); FcPatternAddInteger(pattern, FC_SLANT, p_italic ? FC_SLANT_ITALIC : FC_SLANT_ROMAN);
FcConfigSubstitute(0, pattern, FcMatchPattern); FcConfigSubstitute(nullptr, pattern, FcMatchPattern);
FcDefaultSubstitute(pattern); FcDefaultSubstitute(pattern);
FcResult result; FcResult result;
FcPattern *match = FcFontMatch(0, pattern, &result); FcPattern *match = FcFontMatch(nullptr, pattern, &result);
if (match) { if (match) {
if (!allow_substitutes) { if (!allow_substitutes) {
char *family_name = nullptr; char *family_name = nullptr;

View File

@ -159,7 +159,7 @@ extern void CrashHandlerException(int signal) {
// Load process and image info to determine ASLR addresses offset. // Load process and image info to determine ASLR addresses offset.
MODULEINFO mi; MODULEINFO mi;
GetModuleInformation(GetCurrentProcess(), GetModuleHandle(NULL), &mi, sizeof(mi)); GetModuleInformation(GetCurrentProcess(), GetModuleHandle(nullptr), &mi, sizeof(mi));
int64_t image_mem_base = reinterpret_cast<int64_t>(mi.lpBaseOfDll); int64_t image_mem_base = reinterpret_cast<int64_t>(mi.lpBaseOfDll);
int64_t image_file_base = get_image_base(_execpath); int64_t image_file_base = get_image_base(_execpath);
data.offset = image_mem_base - image_file_base; data.offset = image_mem_base - image_file_base;

View File

@ -735,7 +735,7 @@ Error DisplayServerWindows::_file_dialog_with_options_show(const String &p_title
GetWindowRect(fd->hwnd_owner, &crect); GetWindowRect(fd->hwnd_owner, &crect);
fd->wrect = Rect2i(crect.left, crect.top, crect.right - crect.left, crect.bottom - crect.top); fd->wrect = Rect2i(crect.left, crect.top, crect.right - crect.left, crect.bottom - crect.top);
} else { } else {
fd->hwnd_owner = 0; fd->hwnd_owner = nullptr;
fd->wrect = Rect2i(CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT); fd->wrect = Rect2i(CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT);
} }
fd->appid = appname; fd->appid = appname;

View File

@ -122,8 +122,9 @@ bool JoypadWindows::is_xinput_device(const GUID *p_guid) {
memcmp(p_guid, &IID_XOneSWirelessGamepad, sizeof(*p_guid)) == 0 || memcmp(p_guid, &IID_XOneSWirelessGamepad, sizeof(*p_guid)) == 0 ||
memcmp(p_guid, &IID_XOneSBluetoothGamepad, sizeof(*p_guid)) == 0 || memcmp(p_guid, &IID_XOneSBluetoothGamepad, sizeof(*p_guid)) == 0 ||
memcmp(p_guid, &IID_XOneEliteWirelessGamepad, sizeof(*p_guid)) == 0 || memcmp(p_guid, &IID_XOneEliteWirelessGamepad, sizeof(*p_guid)) == 0 ||
memcmp(p_guid, &IID_XOneElite2WirelessGamepad, sizeof(*p_guid)) == 0) memcmp(p_guid, &IID_XOneElite2WirelessGamepad, sizeof(*p_guid)) == 0) {
return true; return true;
}
PRAWINPUTDEVICELIST dev_list = nullptr; PRAWINPUTDEVICELIST dev_list = nullptr;
unsigned int dev_list_count = 0; unsigned int dev_list_count = 0;

View File

@ -158,7 +158,7 @@ Size2 NativeMenuWindows::get_size(const RID &p_rid) const {
int count = GetMenuItemCount(md->menu); int count = GetMenuItemCount(md->menu);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
RECT rect; RECT rect;
if (GetMenuItemRect(NULL, md->menu, i, &rect)) { if (GetMenuItemRect(nullptr, md->menu, i, &rect)) {
size.x = MAX(size.x, rect.right - rect.left); size.x = MAX(size.x, rect.right - rect.left);
size.y += rect.bottom - rect.top; size.y += rect.bottom - rect.top;
} }
@ -992,7 +992,7 @@ void NativeMenuWindows::set_item_submenu(const RID &p_rid, int p_idx, const RID
if (p_submenu_rid.is_valid()) { if (p_submenu_rid.is_valid()) {
item.hSubMenu = md_sub->menu; item.hSubMenu = md_sub->menu;
} else { } else {
item.hSubMenu = 0; item.hSubMenu = nullptr;
} }
SetMenuItemInfoW(md->menu, p_idx, true, &item); SetMenuItemInfoW(md->menu, p_idx, true, &item);
} }
@ -1095,7 +1095,7 @@ void NativeMenuWindows::set_item_icon(const RID &p_rid, int p_idx, const Ref<Tex
item_data->bmp = _make_bitmap(item_data->img); item_data->bmp = _make_bitmap(item_data->img);
} else { } else {
item_data->img = Ref<Image>(); item_data->img = Ref<Image>();
item_data->bmp = 0; item_data->bmp = nullptr;
} }
item.hbmpItem = item_data->bmp; item.hbmpItem = item_data->bmp;
SetMenuItemInfoW(md->menu, p_idx, true, &item); SetMenuItemInfoW(md->menu, p_idx, true, &item);

View File

@ -139,13 +139,13 @@ void RedirectIOToConsole() {
if (AttachConsole(ATTACH_PARENT_PROCESS)) { if (AttachConsole(ATTACH_PARENT_PROCESS)) {
// Restore redirection (Note: if not redirected it's NULL handles not INVALID_HANDLE_VALUE). // Restore redirection (Note: if not redirected it's NULL handles not INVALID_HANDLE_VALUE).
if (h_stdin != 0) { if (h_stdin != nullptr) {
SetStdHandle(STD_INPUT_HANDLE, h_stdin); SetStdHandle(STD_INPUT_HANDLE, h_stdin);
} }
if (h_stdout != 0) { if (h_stdout != nullptr) {
SetStdHandle(STD_OUTPUT_HANDLE, h_stdout); SetStdHandle(STD_OUTPUT_HANDLE, h_stdout);
} }
if (h_stderr != 0) { if (h_stderr != nullptr) {
SetStdHandle(STD_ERROR_HANDLE, h_stderr); SetStdHandle(STD_ERROR_HANDLE, h_stderr);
} }
@ -908,9 +908,9 @@ Dictionary OS_Windows::execute_with_pipe(const String &p_path, const List<String
} }
// Create pipes. // Create pipes.
HANDLE pipe_in[2] = { 0, 0 }; HANDLE pipe_in[2] = { nullptr, nullptr };
HANDLE pipe_out[2] = { 0, 0 }; HANDLE pipe_out[2] = { nullptr, nullptr };
HANDLE pipe_err[2] = { 0, 0 }; HANDLE pipe_err[2] = { nullptr, nullptr };
SECURITY_ATTRIBUTES sa; SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof(SECURITY_ATTRIBUTES); sa.nLength = sizeof(SECURITY_ATTRIBUTES);
@ -981,7 +981,7 @@ Dictionary OS_Windows::execute_with_pipe(const String &p_path, const List<String
Ref<FileAccessWindowsPipe> err_pipe; Ref<FileAccessWindowsPipe> err_pipe;
err_pipe.instantiate(); err_pipe.instantiate();
err_pipe->open_existing(pipe_err[0], 0, p_blocking); err_pipe->open_existing(pipe_err[0], nullptr, p_blocking);
ret["stdio"] = main_pipe; ret["stdio"] = main_pipe;
ret["stderr"] = err_pipe; ret["stderr"] = err_pipe;

View File

@ -67,11 +67,11 @@ Error WindowsUtils::copy_and_rename_pdb(const String &p_dll_path) {
{ {
// The custom LoadLibraryExW is used instead of open_dynamic_library // The custom LoadLibraryExW is used instead of open_dynamic_library
// to avoid loading the original PDB into the debugger. // to avoid loading the original PDB into the debugger.
HMODULE library_ptr = LoadLibraryExW((LPCWSTR)(p_dll_path.utf16().get_data()), NULL, LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE); HMODULE library_ptr = LoadLibraryExW((LPCWSTR)(p_dll_path.utf16().get_data()), nullptr, LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE);
ERR_FAIL_NULL_V_MSG(library_ptr, ERR_FILE_CANT_OPEN, vformat("Failed to load library '%s'.", p_dll_path)); ERR_FAIL_NULL_V_MSG(library_ptr, ERR_FILE_CANT_OPEN, vformat("Failed to load library '%s'.", p_dll_path));
IMAGE_DEBUG_DIRECTORY *dbg_dir = (IMAGE_DEBUG_DIRECTORY *)ImageDirectoryEntryToDataEx(library_ptr, FALSE, IMAGE_DIRECTORY_ENTRY_DEBUG, &dbg_info_size, NULL); IMAGE_DEBUG_DIRECTORY *dbg_dir = (IMAGE_DEBUG_DIRECTORY *)ImageDirectoryEntryToDataEx(library_ptr, FALSE, IMAGE_DIRECTORY_ENTRY_DEBUG, &dbg_info_size, nullptr);
bool has_debug = dbg_dir && dbg_dir->Type == IMAGE_DEBUG_TYPE_CODEVIEW; bool has_debug = dbg_dir && dbg_dir->Type == IMAGE_DEBUG_TYPE_CODEVIEW;
if (has_debug) { if (has_debug) {

View File

@ -5069,7 +5069,7 @@ bool TextEdit::multicaret_edit_ignore_caret(int p_caret) const {
} }
bool TextEdit::is_caret_visible(int p_caret) const { bool TextEdit::is_caret_visible(int p_caret) const {
ERR_FAIL_INDEX_V(p_caret, carets.size(), 0); ERR_FAIL_INDEX_V(p_caret, carets.size(), false);
return carets[p_caret].visible; return carets[p_caret].visible;
} }
@ -5736,7 +5736,7 @@ TextServer::AutowrapMode TextEdit::get_autowrap_mode() const {
} }
bool TextEdit::is_line_wrapped(int p_line) const { bool TextEdit::is_line_wrapped(int p_line) const {
ERR_FAIL_INDEX_V(p_line, text.size(), 0); ERR_FAIL_INDEX_V(p_line, text.size(), false);
if (get_line_wrapping_mode() == LineWrappingMode::LINE_WRAPPING_NONE) { if (get_line_wrapping_mode() == LineWrappingMode::LINE_WRAPPING_NONE) {
return false; return false;
} }

View File

@ -647,13 +647,13 @@ void FontFile::_convert_packed_8bit(Ref<Image> &p_source, int p_page, int p_sz)
wa[ofs_dst + 1] = r[ofs_src + 3]; wa[ofs_dst + 1] = r[ofs_src + 3];
} }
} }
Ref<Image> img_r = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_r)); Ref<Image> img_r = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_r));
set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 0, img_r); set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 0, img_r);
Ref<Image> img_g = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_g)); Ref<Image> img_g = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_g));
set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 1, img_g); set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 1, img_g);
Ref<Image> img_b = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_b)); Ref<Image> img_b = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_b));
set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 2, img_b); set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 2, img_b);
Ref<Image> img_a = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_a)); Ref<Image> img_a = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_a));
set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 3, img_a); set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 3, img_a);
} }
@ -738,22 +738,22 @@ void FontFile::_convert_packed_4bit(Ref<Image> &p_source, int p_page, int p_sz)
} }
} }
} }
Ref<Image> img_r = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_r)); Ref<Image> img_r = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_r));
set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 0, img_r); set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 0, img_r);
Ref<Image> img_g = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_g)); Ref<Image> img_g = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_g));
set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 1, img_g); set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 1, img_g);
Ref<Image> img_b = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_b)); Ref<Image> img_b = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_b));
set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 2, img_b); set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 2, img_b);
Ref<Image> img_a = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_a)); Ref<Image> img_a = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_a));
set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 3, img_a); set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 3, img_a);
Ref<Image> img_ro = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_ro)); Ref<Image> img_ro = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_ro));
set_texture_image(0, Vector2i(p_sz, 1), p_page * 4 + 0, img_ro); set_texture_image(0, Vector2i(p_sz, 1), p_page * 4 + 0, img_ro);
Ref<Image> img_go = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_go)); Ref<Image> img_go = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_go));
set_texture_image(0, Vector2i(p_sz, 1), p_page * 4 + 1, img_go); set_texture_image(0, Vector2i(p_sz, 1), p_page * 4 + 1, img_go);
Ref<Image> img_bo = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_bo)); Ref<Image> img_bo = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_bo));
set_texture_image(0, Vector2i(p_sz, 1), p_page * 4 + 2, img_bo); set_texture_image(0, Vector2i(p_sz, 1), p_page * 4 + 2, img_bo);
Ref<Image> img_ao = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_ao)); Ref<Image> img_ao = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_ao));
set_texture_image(0, Vector2i(p_sz, 1), p_page * 4 + 3, img_ao); set_texture_image(0, Vector2i(p_sz, 1), p_page * 4 + 3, img_ao);
} }
@ -806,10 +806,10 @@ void FontFile::_convert_rgba_4bit(Ref<Image> &p_source, int p_page, int p_sz) {
} }
} }
} }
Ref<Image> img_g = memnew(Image(w, h, 0, Image::FORMAT_RGBA8, imgdata_g)); Ref<Image> img_g = memnew(Image(w, h, false, Image::FORMAT_RGBA8, imgdata_g));
set_texture_image(0, Vector2i(p_sz, 0), p_page, img_g); set_texture_image(0, Vector2i(p_sz, 0), p_page, img_g);
Ref<Image> img_o = memnew(Image(w, h, 0, Image::FORMAT_RGBA8, imgdata_o)); Ref<Image> img_o = memnew(Image(w, h, false, Image::FORMAT_RGBA8, imgdata_o));
set_texture_image(0, Vector2i(p_sz, 1), p_page, img_o); set_texture_image(0, Vector2i(p_sz, 1), p_page, img_o);
} }
@ -838,7 +838,7 @@ void FontFile::_convert_mono_8bit(Ref<Image> &p_source, int p_page, int p_ch, in
wg[ofs_dst + 1] = r[ofs_src + p_ch]; wg[ofs_dst + 1] = r[ofs_src + p_ch];
} }
} }
Ref<Image> img_g = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_g)); Ref<Image> img_g = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_g));
set_texture_image(0, Vector2i(p_sz, p_ol), p_page, img_g); set_texture_image(0, Vector2i(p_sz, p_ol), p_page, img_g);
} }
@ -878,10 +878,10 @@ void FontFile::_convert_mono_4bit(Ref<Image> &p_source, int p_page, int p_ch, in
} }
} }
} }
Ref<Image> img_g = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_g)); Ref<Image> img_g = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_g));
set_texture_image(0, Vector2i(p_sz, 0), p_page, img_g); set_texture_image(0, Vector2i(p_sz, 0), p_page, img_g);
Ref<Image> img_o = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_o)); Ref<Image> img_o = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_o));
set_texture_image(0, Vector2i(p_sz, p_ol), p_page, img_o); set_texture_image(0, Vector2i(p_sz, p_ol), p_page, img_o);
} }

View File

@ -281,7 +281,7 @@ double AudioStream::get_bpm() const {
} }
bool AudioStream::has_loop() const { bool AudioStream::has_loop() const {
bool ret = 0; bool ret = false;
GDVIRTUAL_CALL(_has_loop, ret); GDVIRTUAL_CALL(_has_loop, ret);
return ret; return ret;
} }

View File

@ -612,8 +612,9 @@ void RendererCanvasCull::canvas_item_set_visibility_layer(RID p_item, uint32_t p
uint32_t RendererCanvasCull::canvas_item_get_visibility_layer(RID p_item) { uint32_t RendererCanvasCull::canvas_item_get_visibility_layer(RID p_item) {
Item *canvas_item = canvas_item_owner.get_or_null(p_item); Item *canvas_item = canvas_item_owner.get_or_null(p_item);
if (!canvas_item) if (!canvas_item) {
return 0; return 0;
}
return canvas_item->visibility_layer; return canvas_item->visibility_layer;
} }

View File

@ -350,7 +350,7 @@ bool GI::voxel_gi_is_using_two_bounces(RID p_voxel_gi) const {
bool GI::voxel_gi_is_interior(RID p_voxel_gi) const { bool GI::voxel_gi_is_interior(RID p_voxel_gi) const {
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi); VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_NULL_V(voxel_gi, 0); ERR_FAIL_NULL_V(voxel_gi, false);
return voxel_gi->interior; return voxel_gi->interior;
} }

View File

@ -509,7 +509,7 @@ public:
_FORCE_INLINE_ bool particles_has_collision(RID p_particles) { _FORCE_INLINE_ bool particles_has_collision(RID p_particles) {
Particles *particles = particles_owner.get_or_null(p_particles); Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_NULL_V(particles, 0); ERR_FAIL_NULL_V(particles, false);
return particles->has_collision_cache; return particles->has_collision_cache;
} }

View File

@ -309,7 +309,7 @@ RID RenderingServer::get_white_texture() {
w[i] = 255; w[i] = 255;
} }
} }
Ref<Image> white = memnew(Image(4, 4, 0, Image::FORMAT_RGB8, wt)); Ref<Image> white = memnew(Image(4, 4, false, Image::FORMAT_RGB8, wt));
white_texture = texture_2d_create(white); white_texture = texture_2d_create(white);
return white_texture; return white_texture;
} }

View File

@ -104,8 +104,9 @@ TEST_CASE("[SceneTree][Primitive][Capsule] Capsule Primitive") {
float dist_to_yaxis = 0.f; float dist_to_yaxis = 0.f;
for (Vector3 point : points) { for (Vector3 point : points) {
float new_dist_to_y = point.x * point.x + point.z * point.z; float new_dist_to_y = point.x * point.x + point.z * point.z;
if (new_dist_to_y > dist_to_yaxis) if (new_dist_to_y > dist_to_yaxis) {
dist_to_yaxis = new_dist_to_y; dist_to_yaxis = new_dist_to_y;
}
} }
CHECK(dist_to_yaxis <= radius * radius); CHECK(dist_to_yaxis <= radius * radius);
@ -114,10 +115,12 @@ TEST_CASE("[SceneTree][Primitive][Capsule] Capsule Primitive") {
float max_y{ 0.f }; float max_y{ 0.f };
float min_y{ 0.f }; float min_y{ 0.f };
for (Vector3 point : points) { for (Vector3 point : points) {
if (point.y > max_y) if (point.y > max_y) {
max_y = point.y; max_y = point.y;
if (point.y < min_y) }
if (point.y < min_y) {
min_y = point.y; min_y = point.y;
}
} }
CHECK(max_y - min_y <= height); CHECK(max_y - min_y <= height);
@ -196,12 +199,14 @@ TEST_CASE("[SceneTree][Primitive][Box] Box Primitive") {
for (const Vector3 &normal : normals) { for (const Vector3 &normal : normals) {
bool add_normal{ true }; bool add_normal{ true };
for (const Vector3 &vec : distinct_normals) { for (const Vector3 &vec : distinct_normals) {
if (vec.is_equal_approx(normal)) if (vec.is_equal_approx(normal)) {
add_normal = false; add_normal = false;
}
} }
if (add_normal) if (add_normal) {
distinct_normals.push_back(normal); distinct_normals.push_back(normal);
}
} }
CHECK_MESSAGE(distinct_normals.size() == 6, CHECK_MESSAGE(distinct_normals.size() == 6,
@ -218,8 +223,9 @@ TEST_CASE("[SceneTree][Primitive][Box] Box Primitive") {
break; break;
} }
} }
if (!normal_correct_direction) if (!normal_correct_direction) {
break; break;
}
} }
CHECK_MESSAGE(normal_correct_direction, CHECK_MESSAGE(normal_correct_direction,

View File

@ -474,6 +474,6 @@ public:
for (int i = 0; i < string_list.size(); ++i) { \ for (int i = 0; i < string_list.size(); ++i) { \
CHECK(string_list[i] == m_slices[i]); \ CHECK(string_list[i] == m_slices[i]); \
} \ } \
} while (0) } while (false)
#endif // TEST_MACROS_H #endif // TEST_MACROS_H