diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-04-19 08:47:03 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-04-19 08:47:03 +0300 |
commit | 1f5d51e44ecf99f34d8e733559a9312e5ae3ef33 (patch) | |
tree | f8a2465eac96414a4bfe1da812aed48c8e284cb8 /source/blender/draw | |
parent | 5b45d32f3a4dfaa5f65e7ba59311863bf37c08da (diff) |
Cleanup: style
Diffstat (limited to 'source/blender/draw')
10 files changed, 69 insertions, 62 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_render.c b/source/blender/draw/engines/eevee/eevee_render.c index 08dcb626964..6d9824f7ca9 100644 --- a/source/blender/draw/engines/eevee/eevee_render.c +++ b/source/blender/draw/engines/eevee/eevee_render.c @@ -256,8 +256,8 @@ static void eevee_render_result_normal( } float fenc[2]; - fenc[0] = rp->rect[i+0] * 4.0f - 2.0f; - fenc[1] = rp->rect[i+1] * 4.0f - 2.0f; + fenc[0] = rp->rect[i + 0] * 4.0f - 2.0f; + fenc[1] = rp->rect[i + 1] * 4.0f - 2.0f; float f = dot_v2v2(fenc, fenc); float g = sqrtf(1.0f - f / 4.0f); @@ -360,7 +360,7 @@ static void eevee_render_result_occlusion( /* This is the accumulated color. Divide by the number of samples. */ for (int i = 0; i < rp->rectx * rp->recty * 3; i += 3) { - rp->rect[i] = rp->rect[i + 1] = rp->rect[i+2] = min_ff(1.0f, rp->rect[i] / (float)render_samples); + rp->rect[i] = rp->rect[i + 1] = rp->rect[i + 2] = min_ff(1.0f, rp->rect[i] / (float)render_samples); } } } @@ -483,7 +483,7 @@ void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine *engine, RenderLayer *rl DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data); char info[42]; - BLI_snprintf(info, sizeof(info), "Rendering %u / %u samples", render_samples+1, tot_sample); + BLI_snprintf(info, sizeof(info), "Rendering %u / %u samples", render_samples + 1, tot_sample); RE_engine_update_stats(engine, NULL, info); /* Refresh Shadows */ diff --git a/source/blender/draw/engines/workbench/solid_flat_mode.c b/source/blender/draw/engines/workbench/solid_flat_mode.c index 5ae46c060db..bed87518f39 100644 --- a/source/blender/draw/engines/workbench/solid_flat_mode.c +++ b/source/blender/draw/engines/workbench/solid_flat_mode.c @@ -71,7 +71,7 @@ static void workbench_solid_flat_cache_populate(void *vedata, Object *ob) WORKBENCH_StorageList *stl = data->stl; IDProperty *props = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_WORKBENCH); - const float* color = BKE_collection_engine_property_value_get_float_array(props, "object_color"); + const float *color = BKE_collection_engine_property_value_get_float_array(props, "object_color"); if (!DRW_object_is_renderable(ob)) return; @@ -90,7 +90,7 @@ static void workbench_solid_flat_cache_populate(void *vedata, Object *ob) static void workbench_solid_flat_cache_finish(void *vedata) { - workbench_materials_cache_finish((WORKBENCH_Data*)vedata); + workbench_materials_cache_finish((WORKBENCH_Data *)vedata); } static void workbench_solid_flat_draw_scene(void *vedata) diff --git a/source/blender/draw/engines/workbench/solid_studio_mode.c b/source/blender/draw/engines/workbench/solid_studio_mode.c index e8664bda740..6ac63fbca67 100644 --- a/source/blender/draw/engines/workbench/solid_studio_mode.c +++ b/source/blender/draw/engines/workbench/solid_studio_mode.c @@ -90,7 +90,7 @@ static void workbench_solid_studio_cache_populate(void *vedata, Object *ob) static void workbench_solid_studio_cache_finish(void *vedata) { - workbench_materials_cache_finish((WORKBENCH_Data*)vedata); + workbench_materials_cache_finish((WORKBENCH_Data *)vedata); } static void workbench_solid_studio_draw_scene(void *vedata) diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c index e9337761231..873d24116a1 100644 --- a/source/blender/draw/engines/workbench/workbench_materials.c +++ b/source/blender/draw/engines/workbench/workbench_materials.c @@ -22,7 +22,7 @@ /** \file workbench_materials.c * \ingroup draw_engine */ - + #include "workbench_private.h" #include "GPU_shader.h" @@ -32,7 +32,7 @@ static struct { /* Solid flat mode */ struct GPUShader *solid_flat_sh; - + /* Solid studio mode */ struct GPUShader *solid_studio_sh; @@ -46,22 +46,24 @@ extern char datatoc_workbench_studio_vert_glsl[]; extern char datatoc_workbench_diffuse_lib_glsl[]; /* Functions */ -static uint get_material_hash(const float color[3]) { +static uint get_material_hash(const float color[3]) +{ uint r = (uint)(color[0] * 512); uint g = (uint)(color[1] * 512); uint b = (uint)(color[2] * 512); - + return r + g * 4096 + b * 4096 * 4096; } -WORKBENCH_MaterialData* workbench_get_or_create_solid_flat_material_data(WORKBENCH_Data *vedata, const float color[3]) { +WORKBENCH_MaterialData *workbench_get_or_create_solid_flat_material_data(WORKBENCH_Data *vedata, const float color[3]) +{ WORKBENCH_StorageList *stl = vedata->stl; WORKBENCH_PassList *psl = vedata->psl; - WORKBENCH_PrivateData* wpd = stl->g_data; - + WORKBENCH_PrivateData *wpd = stl->g_data; + uint hash = get_material_hash(color); WORKBENCH_MaterialData *material; - + material = BLI_ghash_lookup(wpd->material_hash, SET_UINT_IN_POINTER(hash)); if (material == NULL) { material = MEM_mallocN(sizeof(WORKBENCH_MaterialData), "WORKBENCH_MaterialData"); @@ -75,14 +77,15 @@ WORKBENCH_MaterialData* workbench_get_or_create_solid_flat_material_data(WORKBEN return material; } -WORKBENCH_MaterialData* workbench_get_or_create_solid_studio_material_data(WORKBENCH_Data *vedata, const float color[3]) { +WORKBENCH_MaterialData *workbench_get_or_create_solid_studio_material_data(WORKBENCH_Data *vedata, const float color[3]) +{ WORKBENCH_StorageList *stl = vedata->stl; WORKBENCH_PassList *psl = vedata->psl; - WORKBENCH_PrivateData* wpd = stl->g_data; - + WORKBENCH_PrivateData *wpd = stl->g_data; + uint hash = get_material_hash(color); WORKBENCH_MaterialData *material; - + material = BLI_ghash_lookup(wpd->material_hash, SET_UINT_IN_POINTER(hash)); if (material == NULL) { material = MEM_mallocN(sizeof(WORKBENCH_MaterialData), "WORKBENCH_MaterialData"); @@ -96,7 +99,8 @@ WORKBENCH_MaterialData* workbench_get_or_create_solid_studio_material_data(WORKB return material; } -void workbench_materials_engine_init(void) { +void workbench_materials_engine_init(void) +{ if (!e_data.depth_sh) { /* Depth pass */ e_data.depth_sh = DRW_shader_create_3D_depth_only(); @@ -107,22 +111,25 @@ void workbench_materials_engine_init(void) { } } -void workbench_materials_engine_finish(void) { +void workbench_materials_engine_finish(void) +{ DRW_SHADER_FREE_SAFE(e_data.solid_flat_sh); DRW_SHADER_FREE_SAFE(e_data.solid_studio_sh); } -void workbench_materials_cache_init(WORKBENCH_Data *vedata) { - WORKBENCH_StorageList* stl = vedata->stl; - WORKBENCH_PassList* psl = vedata->psl; - WORKBENCH_PrivateData* wpd = stl->g_data; - +void workbench_materials_cache_init(WORKBENCH_Data *vedata) +{ + WORKBENCH_StorageList *stl = vedata->stl; + WORKBENCH_PassList *psl = vedata->psl; + WORKBENCH_PrivateData *wpd = stl->g_data; + wpd->depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass); wpd->material_hash = BLI_ghash_ptr_new("Workbench material_hash"); } -void workbench_materials_cache_finish(WORKBENCH_Data *vedata) { - WORKBENCH_StorageList* stl = vedata->stl; - WORKBENCH_PrivateData* wpd = stl->g_data; +void workbench_materials_cache_finish(WORKBENCH_Data *vedata) +{ + WORKBENCH_StorageList *stl = vedata->stl; + WORKBENCH_PrivateData *wpd = stl->g_data; BLI_ghash_free(wpd->material_hash, NULL, MEM_freeN); } diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index d96565b6864..e45ee9bd043 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -62,24 +62,24 @@ typedef struct WORKBENCH_MaterialData { float color[3]; /* Linked shgroup for drawing */ - DRWShadingGroup * shgrp; + DRWShadingGroup *shgrp; } WORKBENCH_MaterialData; /* workbench_engine.c */ void workbench_solid_materials_init(void); -void workbench_solid_materials_cache_init(WORKBENCH_Data* vedata); -void workbench_solid_materials_cache_populate(WORKBENCH_Data* vedata, Object* ob); -void workbench_solid_materials_cache_finish(WORKBENCH_Data* vedata); -void workbench_solid_materials_draw_scene(WORKBENCH_Data* vedata); +void workbench_solid_materials_cache_init(WORKBENCH_Data *vedata); +void workbench_solid_materials_cache_populate(WORKBENCH_Data *vedata, Object *ob); +void workbench_solid_materials_cache_finish(WORKBENCH_Data *vedata); +void workbench_solid_materials_draw_scene(WORKBENCH_Data *vedata); void workbench_solid_materials_free(void); /* workbench_materials.c */ void workbench_materials_engine_init(void); void workbench_materials_engine_finish(void); void workbench_materials_cache_init(WORKBENCH_Data *vedata); -WORKBENCH_MaterialData* workbench_get_or_create_solid_flat_material_data(WORKBENCH_Data *vedata, const float color[3]); -WORKBENCH_MaterialData* workbench_get_or_create_solid_studio_material_data(WORKBENCH_Data *vedata, const float color[3]); +WORKBENCH_MaterialData *workbench_get_or_create_solid_flat_material_data(WORKBENCH_Data *vedata, const float color[3]); +WORKBENCH_MaterialData *workbench_get_or_create_solid_studio_material_data(WORKBENCH_Data *vedata, const float color[3]); void workbench_materials_cache_finish(WORKBENCH_Data *vedata); diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c index ee73a2ba2c6..350d4a0c20d 100644 --- a/source/blender/draw/intern/draw_instance_data.c +++ b/source/blender/draw/intern/draw_instance_data.c @@ -297,13 +297,13 @@ static DRWInstanceData *drw_instance_data_create( BLI_assert(attrib_size > 0); /* Push to linked list. */ - if (idatalist->idata_head[attrib_size-1] == NULL) { - idatalist->idata_head[attrib_size-1] = idata; + if (idatalist->idata_head[attrib_size - 1] == NULL) { + idatalist->idata_head[attrib_size - 1] = idata; } else { - idatalist->idata_tail[attrib_size-1]->next = idata; + idatalist->idata_tail[attrib_size - 1]->next = idata; } - idatalist->idata_tail[attrib_size-1] = idata; + idatalist->idata_tail[attrib_size - 1] = idata; return idata; } diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 66de79314b4..c99cd25df67 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -496,7 +496,7 @@ static void drw_viewport_var_init(void) void DRW_viewport_matrix_get(float mat[4][4], DRWViewportMatrixType type) { BLI_assert(type >= 0 && type < DRW_MAT_COUNT); - BLI_assert(((DST.override_mat & (1 << type)) != 0)|| DST.draw_ctx.rv3d != NULL); /* Can't use this in render mode. */ + BLI_assert(((DST.override_mat & (1 << type)) != 0) || DST.draw_ctx.rv3d != NULL); /* Can't use this in render mode. */ copy_m4_m4(mat, DST.view_data.matstate.mat[type]); } @@ -905,8 +905,8 @@ static void drw_engines_enable_from_engine(RenderEngineType *engine_type, int dr case OB_SOLID: if (drawtype_solid == OB_LIGHTING_FLAT) { use_drw_engine(&draw_engine_workbench_solid_flat); - - } else if (drawtype_solid == OB_LIGHTING_STUDIO) { + } + else if (drawtype_solid == OB_LIGHTING_STUDIO) { use_drw_engine(&draw_engine_workbench_solid_studio); } @@ -1465,8 +1465,8 @@ static void draw_select_framebuffer_setup(const rcti *rect) /* If size mismatch recreate the texture. */ if ((g_select_buffer.texture_depth != NULL) && - ((GPU_texture_width(g_select_buffer.texture_depth) != BLI_rcti_size_x(rect)) || - (GPU_texture_height(g_select_buffer.texture_depth) != BLI_rcti_size_y(rect)))) + ((GPU_texture_width(g_select_buffer.texture_depth) != BLI_rcti_size_x(rect)) || + (GPU_texture_height(g_select_buffer.texture_depth) != BLI_rcti_size_y(rect)))) { GPU_texture_free(g_select_buffer.texture_depth); g_select_buffer.texture_depth = NULL; diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index 3208e4e5017..ff29d7d7f3d 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -462,12 +462,12 @@ static void draw_clipping_setup_from_view(void) for (int p = 0; p < 6; p++) { int q, r; switch (p) { - case 0: q=1; r=2; break; - case 1: q=0; r=5; break; - case 2: q=1; r=5; break; - case 3: q=2; r=6; break; - case 4: q=0; r=3; break; - default: q=4; r=7; break; + case 0: q = 1; r = 2; break; + case 1: q = 0; r = 5; break; + case 2: q = 1; r = 5; break; + case 3: q = 2; r = 6; break; + case 4: q = 0; r = 3; break; + default: q = 4; r = 7; break; } if (DST.frontface == GL_CW) { SWAP(int, q, r); @@ -573,8 +573,8 @@ static void draw_clipping_setup_from_view(void) /* the big formula, it simplifies to (F-N)/(2(e-s)) for the symmetric case */ z = (F-N) / (2.0f * (e-s + c*(f-n))); - bsphere->center[0] = farcenter[0] * z/e; - bsphere->center[1] = farcenter[1] * z/e; + bsphere->center[0] = farcenter[0] * z / e; + bsphere->center[1] = farcenter[1] * z / e; bsphere->center[2] = z; bsphere->radius = len_v3v3(bsphere->center, farpoint); diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c index 814109ee1e9..a0c8cd4195a 100644 --- a/source/blender/draw/intern/draw_manager_shader.c +++ b/source/blender/draw/intern/draw_manager_shader.c @@ -90,7 +90,7 @@ static void drw_deferred_shader_free(DRWDeferredShader *dsh) static void drw_deferred_shader_queue_free(ListBase *queue) { DRWDeferredShader *dsh; - while((dsh = BLI_pophead(queue))) { + while ((dsh = BLI_pophead(queue))) { drw_deferred_shader_free(dsh); } } diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 7868e8a8232..b7d20fd48d1 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -826,10 +826,10 @@ static void DRW_shgroup_empty_image( if (tex) { DRW_shgroup_instance_format(e_data.empty_image_format, { - {"objectColor" , DRW_ATTRIB_FLOAT, 4}, - {"size" , DRW_ATTRIB_FLOAT, 1}, - {"offset" , DRW_ATTRIB_FLOAT, 2}, - {"InstanceModelMatrix" , DRW_ATTRIB_FLOAT, 16}, + {"objectColor", DRW_ATTRIB_FLOAT, 4}, + {"size", DRW_ATTRIB_FLOAT, 1}, + {"offset", DRW_ATTRIB_FLOAT, 2}, + {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16}, }); struct Gwn_Batch *geom = DRW_cache_image_plane_get(); @@ -846,10 +846,10 @@ static void DRW_shgroup_empty_image( { DRW_shgroup_instance_format(e_data.empty_image_wire_format, { - {"objectColor" , DRW_ATTRIB_FLOAT, 4}, - {"size" , DRW_ATTRIB_FLOAT, 1}, - {"offset" , DRW_ATTRIB_FLOAT, 2}, - {"InstanceModelMatrix" , DRW_ATTRIB_FLOAT, 16} + {"objectColor", DRW_ATTRIB_FLOAT, 4}, + {"size", DRW_ATTRIB_FLOAT, 1}, + {"offset", DRW_ATTRIB_FLOAT, 2}, + {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16} }); struct Gwn_Batch *geom = DRW_cache_image_plane_wire_get(); |