summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2022-04-07 13:23:40 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2022-04-20 10:34:00 +0300
commitde4c97758af117af97fad58e4a80ffeba0154ba8 (patch)
tree2139631cc24a59900a840b9371d5043183558fbd /servers
parentf4b0c7a1ea8d86c1dfd96478ca12ad1360903d9d (diff)
Fix more issues found by cppcheck.
Diffstat (limited to 'servers')
-rw-r--r--servers/physics_2d/godot_space_2d.cpp4
-rw-r--r--servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp2
-rw-r--r--servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h2
-rw-r--r--servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp2
-rw-r--r--servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp8
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp2
-rw-r--r--servers/rendering/renderer_rd/storage_rd/material_storage.cpp32
-rw-r--r--servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp30
-rw-r--r--servers/rendering/renderer_rd/storage_rd/particles_storage.cpp2
-rw-r--r--servers/rendering_server.cpp18
10 files changed, 51 insertions, 51 deletions
diff --git a/servers/physics_2d/godot_space_2d.cpp b/servers/physics_2d/godot_space_2d.cpp
index 63e3af1395..a2459501c8 100644
--- a/servers/physics_2d/godot_space_2d.cpp
+++ b/servers/physics_2d/godot_space_2d.cpp
@@ -1033,9 +1033,9 @@ void GodotSpace2D::_broadphase_unpair(GodotCollisionObject2D *A, int p_subindex_
return;
}
- GodotSpace2D *self = (GodotSpace2D *)p_self;
+ GodotSpace2D *self = static_cast<GodotSpace2D *>(p_self);
self->collision_pairs--;
- GodotConstraint2D *c = (GodotConstraint2D *)p_data;
+ GodotConstraint2D *c = static_cast<GodotConstraint2D *>(p_data);
memdelete(c);
}
diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
index 93baa9a96f..a03fb968f5 100644
--- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
+++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
@@ -210,7 +210,7 @@ void RenderForwardClustered::RenderBufferDataForwardClustered::configure(RID p_c
tf.array_layers = view_count; // create a layer for every view
tf.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT;
- RD::TextureSamples ts[RS::VIEWPORT_MSAA_MAX] = {
+ const RD::TextureSamples ts[RS::VIEWPORT_MSAA_MAX] = {
RD::TEXTURE_SAMPLES_1,
RD::TEXTURE_SAMPLES_2,
RD::TEXTURE_SAMPLES_4,
diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h
index 37366d3e14..d5fc941492 100644
--- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h
+++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h
@@ -218,7 +218,7 @@ class RenderForwardClustered : public RendererSceneRenderRD {
INSTANCE_DATA_FLAGS_PARTICLE_TRAIL_SHIFT = 16,
INSTANCE_DATA_FLAGS_PARTICLE_TRAIL_MASK = 0xFF,
INSTANCE_DATA_FLAGS_FADE_SHIFT = 24,
- INSTANCE_DATA_FLAGS_FADE_MASK = 0xFF << INSTANCE_DATA_FLAGS_FADE_SHIFT
+ INSTANCE_DATA_FLAGS_FADE_MASK = 0xFFUL << INSTANCE_DATA_FLAGS_FADE_SHIFT
};
struct SceneState {
diff --git a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
index ade2b976c8..f39ba81284 100644
--- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
+++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
@@ -158,7 +158,7 @@ void RenderForwardMobile::RenderBufferDataForwardMobile::configure(RID p_color_b
tf.array_layers = view_count; // create a layer for every view
tf.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT;
- RD::TextureSamples ts[RS::VIEWPORT_MSAA_MAX] = {
+ const RD::TextureSamples ts[RS::VIEWPORT_MSAA_MAX] = {
RD::TEXTURE_SAMPLES_1,
RD::TEXTURE_SAMPLES_2,
RD::TEXTURE_SAMPLES_4,
diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
index fce798e3df..134b82da4a 100644
--- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
@@ -132,9 +132,9 @@ RendererCanvasRender::PolygonID RendererCanvasRenderRD::request_polygon(const Ve
buffers.resize(5);
{
- const uint8_t *r = polygon_buffer.ptr();
- float *fptr = (float *)r;
- uint32_t *uptr = (uint32_t *)r;
+ uint8_t *r = polygon_buffer.ptrw();
+ float *fptr = reinterpret_cast<float *>(r);
+ uint32_t *uptr = reinterpret_cast<uint32_t *>(r);
uint32_t base_offset = 0;
{ //vertices
RD::VertexAttribute vd;
@@ -1833,7 +1833,7 @@ void RendererCanvasRenderRD::occluder_polygon_set_shape(RID p_occluder, const Ve
{
uint8_t *vw = geometry.ptrw();
- float *vwptr = (float *)vw;
+ float *vwptr = reinterpret_cast<float *>(vw);
uint8_t *iw = indices.ptrw();
uint16_t *iwptr = (uint16_t *)iw;
diff --git a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp
index d8b7d5384e..0a16bf4bd1 100644
--- a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp
@@ -879,7 +879,7 @@ void RendererSceneGIRD::SDFGI::update_light() {
push_constant.process_offset = 0;
push_constant.process_increment = 1;
} else {
- static uint32_t frames_to_update_table[RS::ENV_SDFGI_UPDATE_LIGHT_MAX] = {
+ static const uint32_t frames_to_update_table[RS::ENV_SDFGI_UPDATE_LIGHT_MAX] = {
1, 2, 4, 8, 16
};
diff --git a/servers/rendering/renderer_rd/storage_rd/material_storage.cpp b/servers/rendering/renderer_rd/storage_rd/material_storage.cpp
index 75c502c666..d939a0d641 100644
--- a/servers/rendering/renderer_rd/storage_rd/material_storage.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/material_storage.cpp
@@ -339,7 +339,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
}
} break;
case ShaderLanguage::TYPE_FLOAT: {
- float *gui = (float *)data;
+ float *gui = reinterpret_cast<float *>(data);
if (p_array_size > 0) {
const PackedFloat32Array &a = value;
@@ -361,7 +361,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
}
} break;
case ShaderLanguage::TYPE_VEC2: {
- float *gui = (float *)data;
+ float *gui = reinterpret_cast<float *>(data);
if (p_array_size > 0) {
const PackedVector2Array &a = value;
@@ -385,7 +385,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
}
} break;
case ShaderLanguage::TYPE_VEC3: {
- float *gui = (float *)data;
+ float *gui = reinterpret_cast<float *>(data);
if (p_array_size > 0) {
const PackedVector3Array &a = value;
@@ -411,7 +411,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
}
} break;
case ShaderLanguage::TYPE_VEC4: {
- float *gui = (float *)data;
+ float *gui = reinterpret_cast<float *>(data);
if (p_array_size > 0) {
if (value.get_type() == Variant::PACKED_COLOR_ARRAY) {
@@ -491,7 +491,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
}
} break;
case ShaderLanguage::TYPE_MAT2: {
- float *gui = (float *)data;
+ float *gui = reinterpret_cast<float *>(data);
if (p_array_size > 0) {
const PackedFloat32Array &a = value;
@@ -532,7 +532,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
}
} break;
case ShaderLanguage::TYPE_MAT3: {
- float *gui = (float *)data;
+ float *gui = reinterpret_cast<float *>(data);
if (p_array_size > 0) {
const PackedFloat32Array &a = value;
@@ -587,7 +587,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
}
} break;
case ShaderLanguage::TYPE_MAT4: {
- float *gui = (float *)data;
+ float *gui = reinterpret_cast<float *>(data);
if (p_array_size > 0) {
const PackedFloat32Array &a = value;
@@ -748,12 +748,12 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type,
}
} break;
case ShaderLanguage::TYPE_FLOAT: {
- float *gui = (float *)data;
+ float *gui = reinterpret_cast<float *>(data);
gui[0] = value[0].real;
} break;
case ShaderLanguage::TYPE_VEC2: {
- float *gui = (float *)data;
+ float *gui = reinterpret_cast<float *>(data);
for (int i = 0; i < 2; i++) {
gui[i] = value[i].real;
@@ -761,7 +761,7 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type,
} break;
case ShaderLanguage::TYPE_VEC3: {
- float *gui = (float *)data;
+ float *gui = reinterpret_cast<float *>(data);
for (int i = 0; i < 3; i++) {
gui[i] = value[i].real;
@@ -769,14 +769,14 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type,
} break;
case ShaderLanguage::TYPE_VEC4: {
- float *gui = (float *)data;
+ float *gui = reinterpret_cast<float *>(data);
for (int i = 0; i < 4; i++) {
gui[i] = value[i].real;
}
} break;
case ShaderLanguage::TYPE_MAT2: {
- float *gui = (float *)data;
+ float *gui = reinterpret_cast<float *>(data);
//in std140 members of mat2 are treated as vec4s
gui[0] = value[0].real;
@@ -789,7 +789,7 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type,
gui[7] = 0;
} break;
case ShaderLanguage::TYPE_MAT3: {
- float *gui = (float *)data;
+ float *gui = reinterpret_cast<float *>(data);
gui[0] = value[0].real;
gui[1] = value[1].real;
@@ -805,7 +805,7 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type,
gui[11] = 0;
} break;
case ShaderLanguage::TYPE_MAT4: {
- float *gui = (float *)data;
+ float *gui = reinterpret_cast<float *>(data);
for (int i = 0; i < 16; i++) {
gui[i] = value[i].real;
@@ -1885,7 +1885,7 @@ void MaterialStorage::global_variable_remove(const StringName &p_name) {
if (!global_variables.variables.has(p_name)) {
return;
}
- GlobalVariables::Variable &gv = global_variables.variables[p_name];
+ const GlobalVariables::Variable &gv = global_variables.variables[p_name];
if (gv.buffer_index >= 0) {
global_variables.buffer_usage[gv.buffer_index].elements = 0;
@@ -2110,7 +2110,7 @@ void MaterialStorage::global_variables_instance_update(RID p_instance, int p_ind
ERR_FAIL_INDEX(p_index, ShaderLanguage::MAX_INSTANCE_UNIFORM_INDICES);
ERR_FAIL_COND_MSG(p_value.get_type() > Variant::COLOR, "Unsupported variant type for instance parameter: " + Variant::get_type_name(p_value.get_type())); //anything greater not supported
- ShaderLanguage::DataType datatype_from_value[Variant::COLOR + 1] = {
+ const ShaderLanguage::DataType datatype_from_value[Variant::COLOR + 1] = {
ShaderLanguage::TYPE_MAX, //nil
ShaderLanguage::TYPE_BOOL, //bool
ShaderLanguage::TYPE_INT, //int
diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
index 8c60264ce3..0f74c591c6 100644
--- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
@@ -50,7 +50,7 @@ MeshStorage::MeshStorage() {
buffer.resize(sizeof(float) * 3);
{
uint8_t *w = buffer.ptrw();
- float *fptr = (float *)w;
+ float *fptr = reinterpret_cast<float *>(w);
fptr[0] = 0.0;
fptr[1] = 0.0;
fptr[2] = 0.0;
@@ -62,7 +62,7 @@ MeshStorage::MeshStorage() {
buffer.resize(sizeof(float) * 3);
{
uint8_t *w = buffer.ptrw();
- float *fptr = (float *)w;
+ float *fptr = reinterpret_cast<float *>(w);
fptr[0] = 1.0;
fptr[1] = 0.0;
fptr[2] = 0.0;
@@ -74,7 +74,7 @@ MeshStorage::MeshStorage() {
buffer.resize(sizeof(float) * 4);
{
uint8_t *w = buffer.ptrw();
- float *fptr = (float *)w;
+ float *fptr = reinterpret_cast<float *>(w);
fptr[0] = 1.0;
fptr[1] = 0.0;
fptr[2] = 0.0;
@@ -87,7 +87,7 @@ MeshStorage::MeshStorage() {
buffer.resize(sizeof(float) * 4);
{
uint8_t *w = buffer.ptrw();
- float *fptr = (float *)w;
+ float *fptr = reinterpret_cast<float *>(w);
fptr[0] = 1.0;
fptr[1] = 1.0;
fptr[2] = 1.0;
@@ -100,7 +100,7 @@ MeshStorage::MeshStorage() {
buffer.resize(sizeof(float) * 2);
{
uint8_t *w = buffer.ptrw();
- float *fptr = (float *)w;
+ float *fptr = reinterpret_cast<float *>(w);
fptr[0] = 0.0;
fptr[1] = 0.0;
}
@@ -110,7 +110,7 @@ MeshStorage::MeshStorage() {
buffer.resize(sizeof(float) * 2);
{
uint8_t *w = buffer.ptrw();
- float *fptr = (float *)w;
+ float *fptr = reinterpret_cast<float *>(w);
fptr[0] = 0.0;
fptr[1] = 0.0;
}
@@ -121,7 +121,7 @@ MeshStorage::MeshStorage() {
buffer.resize(sizeof(float) * 4);
{
uint8_t *w = buffer.ptrw();
- float *fptr = (float *)w;
+ float *fptr = reinterpret_cast<float *>(w);
fptr[0] = 0.0;
fptr[1] = 0.0;
fptr[2] = 0.0;
@@ -134,7 +134,7 @@ MeshStorage::MeshStorage() {
buffer.resize(sizeof(uint32_t) * 4);
{
uint8_t *w = buffer.ptrw();
- uint32_t *fptr = (uint32_t *)w;
+ uint32_t *fptr = reinterpret_cast<uint32_t *>(w);
fptr[0] = 0;
fptr[1] = 0;
fptr[2] = 0;
@@ -147,7 +147,7 @@ MeshStorage::MeshStorage() {
buffer.resize(sizeof(float) * 4);
{
uint8_t *w = buffer.ptrw();
- float *fptr = (float *)w;
+ float *fptr = reinterpret_cast<float *>(w);
fptr[0] = 0.0;
fptr[1] = 0.0;
fptr[2] = 0.0;
@@ -284,9 +284,9 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
case RS::ARRAY_CUSTOM2:
case RS::ARRAY_CUSTOM3: {
int idx = i - RS::ARRAY_CUSTOM0;
- uint32_t fmt_shift[RS::ARRAY_CUSTOM_COUNT] = { RS::ARRAY_FORMAT_CUSTOM0_SHIFT, RS::ARRAY_FORMAT_CUSTOM1_SHIFT, RS::ARRAY_FORMAT_CUSTOM2_SHIFT, RS::ARRAY_FORMAT_CUSTOM3_SHIFT };
+ const uint32_t fmt_shift[RS::ARRAY_CUSTOM_COUNT] = { RS::ARRAY_FORMAT_CUSTOM0_SHIFT, RS::ARRAY_FORMAT_CUSTOM1_SHIFT, RS::ARRAY_FORMAT_CUSTOM2_SHIFT, RS::ARRAY_FORMAT_CUSTOM3_SHIFT };
uint32_t fmt = (p_surface.format >> fmt_shift[idx]) & RS::ARRAY_FORMAT_CUSTOM_MASK;
- uint32_t fmtsize[RS::ARRAY_CUSTOM_MAX] = { 4, 4, 4, 8, 4, 8, 12, 16 };
+ const uint32_t fmtsize[RS::ARRAY_CUSTOM_MAX] = { 4, 4, 4, 8, 4, 8, 12, 16 };
attrib_stride += fmtsize[fmt];
} break;
@@ -1098,10 +1098,10 @@ void MeshStorage::_mesh_surface_generate_version_for_input_mask(Mesh::Surface::V
vd.offset = attribute_stride;
int idx = i - RS::ARRAY_CUSTOM0;
- uint32_t fmt_shift[RS::ARRAY_CUSTOM_COUNT] = { RS::ARRAY_FORMAT_CUSTOM0_SHIFT, RS::ARRAY_FORMAT_CUSTOM1_SHIFT, RS::ARRAY_FORMAT_CUSTOM2_SHIFT, RS::ARRAY_FORMAT_CUSTOM3_SHIFT };
+ const uint32_t fmt_shift[RS::ARRAY_CUSTOM_COUNT] = { RS::ARRAY_FORMAT_CUSTOM0_SHIFT, RS::ARRAY_FORMAT_CUSTOM1_SHIFT, RS::ARRAY_FORMAT_CUSTOM2_SHIFT, RS::ARRAY_FORMAT_CUSTOM3_SHIFT };
uint32_t fmt = (s->format >> fmt_shift[idx]) & RS::ARRAY_FORMAT_CUSTOM_MASK;
- uint32_t fmtsize[RS::ARRAY_CUSTOM_MAX] = { 4, 4, 4, 8, 4, 8, 12, 16 };
- RD::DataFormat fmtrd[RS::ARRAY_CUSTOM_MAX] = { RD::DATA_FORMAT_R8G8B8A8_UNORM, RD::DATA_FORMAT_R8G8B8A8_SNORM, RD::DATA_FORMAT_R16G16_SFLOAT, RD::DATA_FORMAT_R16G16B16A16_SFLOAT, RD::DATA_FORMAT_R32_SFLOAT, RD::DATA_FORMAT_R32G32_SFLOAT, RD::DATA_FORMAT_R32G32B32_SFLOAT, RD::DATA_FORMAT_R32G32B32A32_SFLOAT };
+ const uint32_t fmtsize[RS::ARRAY_CUSTOM_MAX] = { 4, 4, 4, 8, 4, 8, 12, 16 };
+ const RD::DataFormat fmtrd[RS::ARRAY_CUSTOM_MAX] = { RD::DATA_FORMAT_R8G8B8A8_UNORM, RD::DATA_FORMAT_R8G8B8A8_SNORM, RD::DATA_FORMAT_R16G16_SFLOAT, RD::DATA_FORMAT_R16G16B16A16_SFLOAT, RD::DATA_FORMAT_R32_SFLOAT, RD::DATA_FORMAT_R32G32_SFLOAT, RD::DATA_FORMAT_R32G32B32_SFLOAT, RD::DATA_FORMAT_R32G32B32A32_SFLOAT };
vd.format = fmtrd[fmt];
attribute_stride += fmtsize[fmt];
buffer = s->attribute_buffer;
@@ -1238,7 +1238,7 @@ void MeshStorage::multimesh_set_mesh(RID p_multimesh, RID p_mesh) {
if (multimesh->buffer_set) {
Vector<uint8_t> buffer = RD::get_singleton()->buffer_get_data(multimesh->buffer);
const uint8_t *r = buffer.ptr();
- const float *data = (const float *)r;
+ const float *data = reinterpret_cast<const float *>(r);
_multimesh_re_create_aabb(multimesh, data, multimesh->instances);
}
}
diff --git a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp
index 75dd20bdbd..402536de88 100644
--- a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp
@@ -1722,7 +1722,7 @@ RID ParticlesStorage::particles_collision_get_heightfield_framebuffer(RID p_part
if (particles_collision->heightfield_texture == RID()) {
//create
- int resolutions[RS::PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_MAX] = { 256, 512, 1024, 2048, 4096, 8192 };
+ const int resolutions[RS::PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_MAX] = { 256, 512, 1024, 2048, 4096, 8192 };
Size2i size;
if (particles_collision->extents.x > particles_collision->extents.z) {
size.x = resolutions[particles_collision->heightfield_resolution];
diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp
index b58e6138eb..c2a6b83485 100644
--- a/servers/rendering_server.cpp
+++ b/servers/rendering_server.cpp
@@ -424,7 +424,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
value |= CLAMP(int((src[i * 4 + 1] * 0.5 + 0.5) * 1023.0), 0, 1023) << 10;
value |= CLAMP(int((src[i * 4 + 2] * 0.5 + 0.5) * 1023.0), 0, 1023) << 20;
if (src[i * 4 + 3] > 0) {
- value |= 3 << 30;
+ value |= 3UL << 30;
}
memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], &value, 4);
@@ -440,7 +440,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
value |= CLAMP(int((src[i * 4 + 1] * 0.5 + 0.5) * 1023.0), 0, 1023) << 10;
value |= CLAMP(int((src[i * 4 + 2] * 0.5 + 0.5) * 1023.0), 0, 1023) << 20;
if (src[i * 4 + 3] > 0) {
- value |= 3 << 30;
+ value |= 3UL << 30;
}
memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], &value, 4);
}
@@ -1093,7 +1093,7 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
Vector2 *w = arr_2d.ptrw();
for (int j = 0; j < p_vertex_len; j++) {
- const float *v = (const float *)&r[j * vertex_elem_size + offsets[i]];
+ const float *v = reinterpret_cast<const float *>(&r[j * vertex_elem_size + offsets[i]]);
w[j] = Vector2(v[0], v[1]);
}
}
@@ -1107,7 +1107,7 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
Vector3 *w = arr_3d.ptrw();
for (int j = 0; j < p_vertex_len; j++) {
- const float *v = (const float *)&r[j * vertex_elem_size + offsets[i]];
+ const float *v = reinterpret_cast<const float *>(&r[j * vertex_elem_size + offsets[i]]);
w[j] = Vector3(v[0], v[1], v[2]);
}
}
@@ -1156,7 +1156,7 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
Color *w = arr.ptrw();
for (int32_t j = 0; j < p_vertex_len; j++) {
- const uint8_t *v = (const uint8_t *)&ar[j * attrib_elem_size + offsets[i]];
+ const uint8_t *v = reinterpret_cast<const uint8_t *>(&ar[j * attrib_elem_size + offsets[i]]);
w[j] = Color(v[0] / 255.0, v[1] / 255.0, v[2] / 255.0, v[3] / 255.0);
}
@@ -1170,7 +1170,7 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
Vector2 *w = arr.ptrw();
for (int j = 0; j < p_vertex_len; j++) {
- const float *v = (const float *)&ar[j * attrib_elem_size + offsets[i]];
+ const float *v = reinterpret_cast<const float *>(&ar[j * attrib_elem_size + offsets[i]]);
w[j] = Vector2(v[0], v[1]);
}
@@ -1184,7 +1184,7 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
Vector2 *w = arr.ptrw();
for (int j = 0; j < p_vertex_len; j++) {
- const float *v = (const float *)&ar[j * attrib_elem_size + offsets[i]];
+ const float *v = reinterpret_cast<const float *>(&ar[j * attrib_elem_size + offsets[i]]);
w[j] = Vector2(v[0], v[1]);
}
@@ -1209,7 +1209,7 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
uint8_t *w = arr.ptrw();
for (int j = 0; j < p_vertex_len; j++) {
- const uint8_t *v = (const uint8_t *)&ar[j * attrib_elem_size + offsets[i]];
+ const uint8_t *v = reinterpret_cast<const uint8_t *>(&ar[j * attrib_elem_size + offsets[i]]);
memcpy(&w[j * s], v, s);
}
@@ -1228,7 +1228,7 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
float *w = arr.ptrw();
for (int j = 0; j < p_vertex_len; j++) {
- const float *v = (const float *)&ar[j * attrib_elem_size + offsets[i]];
+ const float *v = reinterpret_cast<const float *>(&ar[j * attrib_elem_size + offsets[i]]);
memcpy(&w[j * s], v, s * sizeof(float));
}
ret[i] = arr;