summaryrefslogtreecommitdiff
path: root/servers/rendering_server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'servers/rendering_server.cpp')
-rw-r--r--servers/rendering_server.cpp50
1 files changed, 33 insertions, 17 deletions
diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp
index d5bc1cb4ef..906946f074 100644
--- a/servers/rendering_server.cpp
+++ b/servers/rendering_server.cpp
@@ -43,8 +43,9 @@ RenderingServer *RenderingServer::get_singleton() {
RenderingServer *RenderingServer::create() {
ERR_FAIL_COND_V(singleton, nullptr);
- if (create_func)
+ if (create_func) {
return create_func();
+ }
return nullptr;
}
@@ -148,12 +149,15 @@ RID RenderingServer::get_test_texture() {
}
void RenderingServer::_free_internal_rids() {
- if (test_texture.is_valid())
+ if (test_texture.is_valid()) {
free(test_texture);
- if (white_texture.is_valid())
+ }
+ if (white_texture.is_valid()) {
free(white_texture);
- if (test_material.is_valid())
+ }
+ if (test_material.is_valid()) {
free(test_material);
+ }
}
RID RenderingServer::_make_test_cube() {
@@ -183,10 +187,11 @@ RID RenderingServer::_make_test_cube() {
v[2] = v[1] * (1 - 2 * (j & 1));
for (int k = 0; k < 3; k++) {
- if (i < 3)
+ if (i < 3) {
face_points[j][(i + k) % 3] = v[k];
- else
+ } else {
face_points[3 - j][(i + k) % 3] = -v[k];
+ }
}
normal_points[j] = Vector3();
normal_points[j][i % 3] = (i >= 3 ? -1 : 1);
@@ -213,8 +218,9 @@ RID RenderingServer::_make_test_cube() {
Vector<int> indices;
indices.resize(vertices.size());
- for (int i = 0; i < vertices.size(); i++)
+ for (int i = 0; i < vertices.size(); i++) {
indices.set(i, i);
+ }
d[RenderingServer::ARRAY_INDEX] = indices;
mesh_add_surface_from_arrays(test_cube, PRIMITIVE_TRIANGLES, d);
@@ -290,15 +296,17 @@ RID RenderingServer::make_sphere_mesh(int p_lats, int p_lons, float p_radius) {
}
RID RenderingServer::get_white_texture() {
- if (white_texture.is_valid())
+ if (white_texture.is_valid()) {
return white_texture;
+ }
Vector<uint8_t> wt;
wt.resize(16 * 3);
{
uint8_t *w = wt.ptrw();
- for (int i = 0; i < 16 * 3; i++)
+ for (int i = 0; i < 16 * 3; i++) {
w[i] = 255;
+ }
}
Ref<Image> white = memnew(Image(4, 4, 0, Image::FORMAT_RGB8, wt));
white_texture = texture_2d_create(white);
@@ -319,8 +327,9 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
int max_bone = 0;
for (int ai = 0; ai < RS::ARRAY_MAX; ai++) {
- if (!(p_format & (1 << ai))) // no array
+ if (!(p_format & (1 << ai))) { // no array
continue;
+ }
switch (ai) {
case RS::ARRAY_VERTEX: {
@@ -621,8 +630,9 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
for (int j = 0; j < 4; j++) {
int idx = rb[i * 4 + j];
float w = rw[i * 4 + j];
- if (w == 0)
+ if (w == 0) {
continue; //break;
+ }
ERR_FAIL_INDEX_V(idx, total_bones, ERR_INVALID_DATA);
if (bptr[idx].size.x < 0) {
@@ -660,8 +670,9 @@ uint32_t RenderingServer::mesh_surface_make_offsets_from_format(uint32_t p_forma
for (int i = 0; i < RS::ARRAY_MAX; i++) {
r_offsets[i] = 0; //reset
- if (!(p_format & (1 << i))) // no array
+ if (!(p_format & (1 << i))) { // no array
continue;
+ }
int elem_size = 0;
@@ -768,8 +779,9 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa
int array_len = 0;
for (int i = 0; i < p_arrays.size(); i++) {
- if (p_arrays[i].get_type() == Variant::NIL)
+ if (p_arrays[i].get_type() == Variant::NIL) {
continue;
+ }
format |= (1 << i);
@@ -802,8 +814,9 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa
uint32_t bsformat = 0;
Array arr = p_blend_shapes[i];
for (int j = 0; j < arr.size(); j++) {
- if (arr[j].get_type() != Variant::NIL)
+ if (arr[j].get_type() != Variant::NIL) {
bsformat |= (1 << j);
+ }
}
ERR_FAIL_COND_V((bsformat) != (format & (RS::ARRAY_FORMAT_INDEX - 1)), ERR_INVALID_PARAMETER);
@@ -817,8 +830,9 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa
for (int i = 0; i < RS::ARRAY_MAX; i++) {
offsets[i] = 0; //reset
- if (!(format & (1 << i))) // no array
+ if (!(format & (1 << i))) { // no array
continue;
+ }
int elem_size = 0;
@@ -1018,8 +1032,9 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
for (int i = 0; i < RS::ARRAY_MAX; i++) {
offsets[i] = 0; //reset
- if (!(p_format & (1 << i))) // no array
+ if (!(p_format & (1 << i))) { // no array
continue;
+ }
int elem_size = 0;
@@ -1115,8 +1130,9 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
const uint8_t *r = p_vertex_data.ptr();
for (int i = 0; i < RS::ARRAY_MAX; i++) {
- if (!(p_format & (1 << i)))
+ if (!(p_format & (1 << i))) {
continue;
+ }
switch (i) {
case RS::ARRAY_VERTEX: {