Fix another batch of -Wmaybe-uninitialized warnings

And simplify code in CSGShape.
This commit is contained in:
Rémi Verschelde 2020-03-27 16:04:01 +01:00
parent b383484e44
commit f097511b96
3 changed files with 8 additions and 11 deletions

View File

@ -158,8 +158,8 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) {
const uint8_t *ptr = r; const uint8_t *ptr = r;
int size = p_buffer.size(); int size = p_buffer.size();
basist::transcoder_texture_format format; basist::transcoder_texture_format format = basist::transcoder_texture_format::cTFTotalTextureFormats;
Image::Format imgfmt; Image::Format imgfmt = Image::FORMAT_MAX;
switch (*(uint32_t *)(ptr)) { switch (*(uint32_t *)(ptr)) {
case BASIS_DECOMPRESS_RG: { case BASIS_DECOMPRESS_RG: {

View File

@ -742,18 +742,14 @@ CSGBrush *CSGMesh3D::_build_brush() {
Vector<Vector3> anormals = arrays[Mesh::ARRAY_NORMAL]; Vector<Vector3> anormals = arrays[Mesh::ARRAY_NORMAL];
const Vector3 *nr = NULL; const Vector3 *nr = NULL;
bool nr_used = false;
if (anormals.size()) { if (anormals.size()) {
nr = anormals.ptr(); nr = anormals.ptr();
nr_used = true;
} }
Vector<Vector2> auvs = arrays[Mesh::ARRAY_TEX_UV]; Vector<Vector2> auvs = arrays[Mesh::ARRAY_TEX_UV];
const Vector2 *uvr = NULL; const Vector2 *uvr = NULL;
bool uvr_used = false;
if (auvs.size()) { if (auvs.size()) {
uvr = auvs.ptr(); uvr = auvs.ptr();
uvr_used = true;
} }
Ref<Material> mat; Ref<Material> mat;
@ -789,10 +785,10 @@ CSGBrush *CSGMesh3D::_build_brush() {
for (int k = 0; k < 3; k++) { for (int k = 0; k < 3; k++) {
int idx = ir[j + k]; int idx = ir[j + k];
vertex[k] = vr[idx]; vertex[k] = vr[idx];
if (nr_used) { if (nr) {
normal[k] = nr[idx]; normal[k] = nr[idx];
} }
if (uvr_used) { if (uvr) {
uv[k] = uvr[idx]; uv[k] = uvr[idx];
} }
} }
@ -832,10 +828,10 @@ CSGBrush *CSGMesh3D::_build_brush() {
for (int k = 0; k < 3; k++) { for (int k = 0; k < 3; k++) {
vertex[k] = vr[j + k]; vertex[k] = vr[j + k];
if (nr_used) { if (nr) {
normal[k] = nr[j + k]; normal[k] = nr[j + k];
} }
if (uvr_used) { if (uvr) {
uv[k] = uvr[j + k]; uv[k] = uvr[j + k];
} }
} }

View File

@ -29,6 +29,7 @@
/*************************************************************************/ /*************************************************************************/
#include "audio_stream_player_3d.h" #include "audio_stream_player_3d.h"
#include "core/engine.h" #include "core/engine.h"
#include "scene/3d/area_3d.h" #include "scene/3d/area_3d.h"
#include "scene/3d/camera_3d.h" #include "scene/3d/camera_3d.h"
@ -96,7 +97,7 @@ static const Vector3 speaker_directions[7] = {
}; };
void AudioStreamPlayer3D::_calc_output_vol(const Vector3 &source_dir, real_t tightness, AudioStreamPlayer3D::Output &output) { void AudioStreamPlayer3D::_calc_output_vol(const Vector3 &source_dir, real_t tightness, AudioStreamPlayer3D::Output &output) {
unsigned int speaker_count; // only main speakers (no LFE) unsigned int speaker_count = 0; // only main speakers (no LFE)
switch (AudioServer::get_singleton()->get_speaker_mode()) { switch (AudioServer::get_singleton()->get_speaker_mode()) {
case AudioServer::SPEAKER_MODE_STEREO: case AudioServer::SPEAKER_MODE_STEREO:
speaker_count = 2; speaker_count = 2;