summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
Diffstat (limited to 'servers')
-rw-r--r--servers/physics_2d/godot_space_2d.cpp4
-rw-r--r--servers/physics_server_2d_wrap_mt.cpp22
-rw-r--r--servers/physics_server_2d_wrap_mt.h22
-rw-r--r--servers/physics_server_3d_wrap_mt.cpp22
-rw-r--r--servers/physics_server_3d_wrap_mt.h20
-rw-r--r--servers/register_server_types.cpp8
-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
15 files changed, 98 insertions, 98 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/physics_server_2d_wrap_mt.cpp b/servers/physics_server_2d_wrap_mt.cpp
index 02223b83f0..699f515270 100644
--- a/servers/physics_server_2d_wrap_mt.cpp
+++ b/servers/physics_server_2d_wrap_mt.cpp
@@ -37,7 +37,7 @@ void PhysicsServer2DWrapMT::thread_exit() {
}
void PhysicsServer2DWrapMT::thread_step(real_t p_delta) {
- physics_2d_server->step(p_delta);
+ physics_server_2d->step(p_delta);
step_sem.post();
}
@@ -50,7 +50,7 @@ void PhysicsServer2DWrapMT::_thread_callback(void *_instance) {
void PhysicsServer2DWrapMT::thread_loop() {
server_thread = Thread::get_caller_id();
- physics_2d_server->init();
+ physics_server_2d->init();
exit.clear();
step_thread_up.set();
@@ -61,7 +61,7 @@ void PhysicsServer2DWrapMT::thread_loop() {
command_queue.flush_all(); // flush all
- physics_2d_server->finish();
+ physics_server_2d->finish();
}
/* EVENT QUEUING */
@@ -71,7 +71,7 @@ void PhysicsServer2DWrapMT::step(real_t p_step) {
command_queue.push(this, &PhysicsServer2DWrapMT::thread_step, p_step);
} else {
command_queue.flush_all(); //flush all pending from other threads
- physics_2d_server->step(p_step);
+ physics_server_2d->step(p_step);
}
}
@@ -83,15 +83,15 @@ void PhysicsServer2DWrapMT::sync() {
step_sem.wait(); //must not wait if a step was not issued
}
}
- physics_2d_server->sync();
+ physics_server_2d->sync();
}
void PhysicsServer2DWrapMT::flush_queries() {
- physics_2d_server->flush_queries();
+ physics_server_2d->flush_queries();
}
void PhysicsServer2DWrapMT::end_sync() {
- physics_2d_server->end_sync();
+ physics_server_2d->end_sync();
}
void PhysicsServer2DWrapMT::init() {
@@ -102,7 +102,7 @@ void PhysicsServer2DWrapMT::init() {
OS::get_singleton()->delay_usec(1000);
}
} else {
- physics_2d_server->init();
+ physics_server_2d->init();
}
}
@@ -111,13 +111,13 @@ void PhysicsServer2DWrapMT::finish() {
command_queue.push(this, &PhysicsServer2DWrapMT::thread_exit);
thread.wait_to_finish();
} else {
- physics_2d_server->finish();
+ physics_server_2d->finish();
}
}
PhysicsServer2DWrapMT::PhysicsServer2DWrapMT(PhysicsServer2D *p_contained, bool p_create_thread) :
command_queue(p_create_thread) {
- physics_2d_server = p_contained;
+ physics_server_2d = p_contained;
create_thread = p_create_thread;
pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
@@ -132,6 +132,6 @@ PhysicsServer2DWrapMT::PhysicsServer2DWrapMT(PhysicsServer2D *p_contained, bool
}
PhysicsServer2DWrapMT::~PhysicsServer2DWrapMT() {
- memdelete(physics_2d_server);
+ memdelete(physics_server_2d);
//finish();
}
diff --git a/servers/physics_server_2d_wrap_mt.h b/servers/physics_server_2d_wrap_mt.h
index aa3a8bc04a..ddb071f603 100644
--- a/servers/physics_server_2d_wrap_mt.h
+++ b/servers/physics_server_2d_wrap_mt.h
@@ -44,7 +44,7 @@
#endif
class PhysicsServer2DWrapMT : public PhysicsServer2D {
- mutable PhysicsServer2D *physics_2d_server;
+ mutable PhysicsServer2D *physics_server_2d;
mutable CommandQueueMT command_queue;
@@ -71,7 +71,7 @@ class PhysicsServer2DWrapMT : public PhysicsServer2D {
public:
#define ServerName PhysicsServer2D
#define ServerNameWrapMT PhysicsServer2DWrapMT
-#define server_name physics_2d_server
+#define server_name physics_server_2d
#define WRITE_ACTION
#include "servers/server_wrap_mt_common.h"
@@ -96,7 +96,7 @@ public:
//these work well, but should be used from the main thread only
bool shape_collide(RID p_shape_A, const Transform2D &p_xform_A, const Vector2 &p_motion_A, RID p_shape_B, const Transform2D &p_xform_B, const Vector2 &p_motion_B, Vector2 *r_results, int p_result_max, int &r_result_count) override {
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), false);
- return physics_2d_server->shape_collide(p_shape_A, p_xform_A, p_motion_A, p_shape_B, p_xform_B, p_motion_B, r_results, p_result_max, r_result_count);
+ return physics_server_2d->shape_collide(p_shape_A, p_xform_A, p_motion_A, p_shape_B, p_xform_B, p_motion_B, r_results, p_result_max, r_result_count);
}
/* SPACE API */
@@ -111,18 +111,18 @@ public:
// this function only works on physics process, errors and returns null otherwise
PhysicsDirectSpaceState2D *space_get_direct_state(RID p_space) override {
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), nullptr);
- return physics_2d_server->space_get_direct_state(p_space);
+ return physics_server_2d->space_get_direct_state(p_space);
}
FUNC2(space_set_debug_contacts, RID, int);
virtual Vector<Vector2> space_get_contacts(RID p_space) const override {
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), Vector<Vector2>());
- return physics_2d_server->space_get_contacts(p_space);
+ return physics_server_2d->space_get_contacts(p_space);
}
virtual int space_get_contact_count(RID p_space) const override {
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), 0);
- return physics_2d_server->space_get_contact_count(p_space);
+ return physics_server_2d->space_get_contact_count(p_space);
}
/* AREA API */
@@ -250,20 +250,20 @@ public:
FUNC3(body_set_force_integration_callback, RID, const Callable &, const Variant &);
bool body_collide_shape(RID p_body, int p_body_shape, RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, Vector2 *r_results, int p_result_max, int &r_result_count) override {
- return physics_2d_server->body_collide_shape(p_body, p_body_shape, p_shape, p_shape_xform, p_motion, r_results, p_result_max, r_result_count);
+ return physics_server_2d->body_collide_shape(p_body, p_body_shape, p_shape, p_shape_xform, p_motion, r_results, p_result_max, r_result_count);
}
FUNC2(body_set_pickable, RID, bool);
bool body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result = nullptr) override {
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), false);
- return physics_2d_server->body_test_motion(p_body, p_parameters, r_result);
+ return physics_server_2d->body_test_motion(p_body, p_parameters, r_result);
}
// this function only works on physics process, errors and returns null otherwise
PhysicsDirectBodyState2D *body_get_direct_state(RID p_body) override {
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), nullptr);
- return physics_2d_server->body_get_direct_state(p_body);
+ return physics_server_2d->body_get_direct_state(p_body);
}
/* JOINT API */
@@ -309,11 +309,11 @@ public:
virtual void finish() override;
virtual bool is_flushing_queries() const override {
- return physics_2d_server->is_flushing_queries();
+ return physics_server_2d->is_flushing_queries();
}
int get_process_info(ProcessInfo p_info) override {
- return physics_2d_server->get_process_info(p_info);
+ return physics_server_2d->get_process_info(p_info);
}
PhysicsServer2DWrapMT(PhysicsServer2D *p_contained, bool p_create_thread);
diff --git a/servers/physics_server_3d_wrap_mt.cpp b/servers/physics_server_3d_wrap_mt.cpp
index 822ca44b72..7faa193ec2 100644
--- a/servers/physics_server_3d_wrap_mt.cpp
+++ b/servers/physics_server_3d_wrap_mt.cpp
@@ -37,7 +37,7 @@ void PhysicsServer3DWrapMT::thread_exit() {
}
void PhysicsServer3DWrapMT::thread_step(real_t p_delta) {
- physics_3d_server->step(p_delta);
+ physics_server_3d->step(p_delta);
step_sem.post();
}
@@ -50,7 +50,7 @@ void PhysicsServer3DWrapMT::_thread_callback(void *_instance) {
void PhysicsServer3DWrapMT::thread_loop() {
server_thread = Thread::get_caller_id();
- physics_3d_server->init();
+ physics_server_3d->init();
exit = false;
step_thread_up = true;
@@ -61,7 +61,7 @@ void PhysicsServer3DWrapMT::thread_loop() {
command_queue.flush_all(); // flush all
- physics_3d_server->finish();
+ physics_server_3d->finish();
}
/* EVENT QUEUING */
@@ -71,7 +71,7 @@ void PhysicsServer3DWrapMT::step(real_t p_step) {
command_queue.push(this, &PhysicsServer3DWrapMT::thread_step, p_step);
} else {
command_queue.flush_all(); //flush all pending from other threads
- physics_3d_server->step(p_step);
+ physics_server_3d->step(p_step);
}
}
@@ -83,15 +83,15 @@ void PhysicsServer3DWrapMT::sync() {
step_sem.wait(); //must not wait if a step was not issued
}
}
- physics_3d_server->sync();
+ physics_server_3d->sync();
}
void PhysicsServer3DWrapMT::flush_queries() {
- physics_3d_server->flush_queries();
+ physics_server_3d->flush_queries();
}
void PhysicsServer3DWrapMT::end_sync() {
- physics_3d_server->end_sync();
+ physics_server_3d->end_sync();
}
void PhysicsServer3DWrapMT::init() {
@@ -102,7 +102,7 @@ void PhysicsServer3DWrapMT::init() {
OS::get_singleton()->delay_usec(1000);
}
} else {
- physics_3d_server->init();
+ physics_server_3d->init();
}
}
@@ -111,13 +111,13 @@ void PhysicsServer3DWrapMT::finish() {
command_queue.push(this, &PhysicsServer3DWrapMT::thread_exit);
thread.wait_to_finish();
} else {
- physics_3d_server->finish();
+ physics_server_3d->finish();
}
}
PhysicsServer3DWrapMT::PhysicsServer3DWrapMT(PhysicsServer3D *p_contained, bool p_create_thread) :
command_queue(p_create_thread) {
- physics_3d_server = p_contained;
+ physics_server_3d = p_contained;
create_thread = p_create_thread;
pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
@@ -132,6 +132,6 @@ PhysicsServer3DWrapMT::PhysicsServer3DWrapMT(PhysicsServer3D *p_contained, bool
}
PhysicsServer3DWrapMT::~PhysicsServer3DWrapMT() {
- memdelete(physics_3d_server);
+ memdelete(physics_server_3d);
//finish();
}
diff --git a/servers/physics_server_3d_wrap_mt.h b/servers/physics_server_3d_wrap_mt.h
index e44f82672d..d4a4ad3132 100644
--- a/servers/physics_server_3d_wrap_mt.h
+++ b/servers/physics_server_3d_wrap_mt.h
@@ -43,7 +43,7 @@
#endif
class PhysicsServer3DWrapMT : public PhysicsServer3D {
- mutable PhysicsServer3D *physics_3d_server;
+ mutable PhysicsServer3D *physics_server_3d;
mutable CommandQueueMT command_queue;
@@ -70,7 +70,7 @@ class PhysicsServer3DWrapMT : public PhysicsServer3D {
public:
#define ServerName PhysicsServer3D
#define ServerNameWrapMT PhysicsServer3DWrapMT
-#define server_name physics_3d_server
+#define server_name physics_server_3d
#define WRITE_ACTION
#include "servers/server_wrap_mt_common.h"
@@ -100,7 +100,7 @@ public:
//these work well, but should be used from the main thread only
bool shape_collide(RID p_shape_A, const Transform &p_xform_A, const Vector3 &p_motion_A, RID p_shape_B, const Transform &p_xform_B, const Vector3 &p_motion_B, Vector3 *r_results, int p_result_max, int &r_result_count) {
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), false);
- return physics_3d_server->shape_collide(p_shape_A, p_xform_A, p_motion_A, p_shape_B, p_xform_B, p_motion_B, r_results, p_result_max, r_result_count);
+ return physics_server_3d->shape_collide(p_shape_A, p_xform_A, p_motion_A, p_shape_B, p_xform_B, p_motion_B, r_results, p_result_max, r_result_count);
}
#endif
/* SPACE API */
@@ -115,18 +115,18 @@ public:
// this function only works on physics process, errors and returns null otherwise
PhysicsDirectSpaceState3D *space_get_direct_state(RID p_space) override {
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), nullptr);
- return physics_3d_server->space_get_direct_state(p_space);
+ return physics_server_3d->space_get_direct_state(p_space);
}
FUNC2(space_set_debug_contacts, RID, int);
virtual Vector<Vector3> space_get_contacts(RID p_space) const override {
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), Vector<Vector3>());
- return physics_3d_server->space_get_contacts(p_space);
+ return physics_server_3d->space_get_contacts(p_space);
}
virtual int space_get_contact_count(RID p_space) const override {
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), 0);
- return physics_3d_server->space_get_contact_count(p_space);
+ return physics_server_3d->space_get_contact_count(p_space);
}
/* AREA API */
@@ -256,13 +256,13 @@ public:
bool body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result = nullptr) override {
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), false);
- return physics_3d_server->body_test_motion(p_body, p_parameters, r_result);
+ return physics_server_3d->body_test_motion(p_body, p_parameters, r_result);
}
// this function only works on physics process, errors and returns null otherwise
PhysicsDirectBodyState3D *body_get_direct_state(RID p_body) override {
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), nullptr);
- return physics_3d_server->body_get_direct_state(p_body);
+ return physics_server_3d->body_get_direct_state(p_body);
}
/* SOFT BODY API */
@@ -385,11 +385,11 @@ public:
virtual void finish() override;
virtual bool is_flushing_queries() const override {
- return physics_3d_server->is_flushing_queries();
+ return physics_server_3d->is_flushing_queries();
}
int get_process_info(ProcessInfo p_info) override {
- return physics_3d_server->get_process_info(p_info);
+ return physics_server_3d->get_process_info(p_info);
}
PhysicsServer3DWrapMT(PhysicsServer3D *p_contained, bool p_create_thread);
diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp
index 9843492316..f02bf80645 100644
--- a/servers/register_server_types.cpp
+++ b/servers/register_server_types.cpp
@@ -85,17 +85,17 @@ ShaderTypes *shader_types = nullptr;
PhysicsServer3D *_createGodotPhysics3DCallback() {
bool using_threads = GLOBAL_GET("physics/3d/run_on_separate_thread");
- PhysicsServer3D *physics_server = memnew(GodotPhysicsServer3D(using_threads));
+ PhysicsServer3D *physics_server_3d = memnew(GodotPhysicsServer3D(using_threads));
- return memnew(PhysicsServer3DWrapMT(physics_server, using_threads));
+ return memnew(PhysicsServer3DWrapMT(physics_server_3d, using_threads));
}
PhysicsServer2D *_createGodotPhysics2DCallback() {
bool using_threads = GLOBAL_GET("physics/2d/run_on_separate_thread");
- PhysicsServer2D *physics_server = memnew(GodotPhysicsServer2D(using_threads));
+ PhysicsServer2D *physics_server_2d = memnew(GodotPhysicsServer2D(using_threads));
- return memnew(PhysicsServer2DWrapMT(physics_server, using_threads));
+ return memnew(PhysicsServer2DWrapMT(physics_server_2d, using_threads));
}
static bool has_server_feature_callback(const String &p_feature) {
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 3be15db9e8..ace948d149 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 c30499da29..0e588aecb4 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 d9c339097a..b9f49cf008 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 29bc767c86..8c727b2512 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;
@@ -1843,7 +1843,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;