Cleanup: style

This commit is contained in:
Campbell Barton
2018-05-11 07:47:25 +02:00
parent 83a83a3d4b
commit df10a2e030
3 changed files with 22 additions and 23 deletions

View File

@@ -36,38 +36,38 @@
static void workbench_solid_engine_init(void *vedata)
{
WORKBENCH_Data * data = (WORKBENCH_Data *)vedata;
WORKBENCH_Data *data = vedata;
workbench_materials_engine_init(data);
}
static void workbench_solid_cache_init(void *vedata)
{
WORKBENCH_Data * data = (WORKBENCH_Data *)vedata;
WORKBENCH_Data *data = vedata;
workbench_materials_cache_init(data);
}
static void workbench_solid_cache_populate(void *vedata, Object *ob)
{
WORKBENCH_Data * data = (WORKBENCH_Data *)vedata;
WORKBENCH_Data *data = vedata;
workbench_materials_solid_cache_populate(data, ob);
}
static void workbench_solid_cache_finish(void *vedata)
{
WORKBENCH_Data * data = (WORKBENCH_Data *)vedata;
WORKBENCH_Data *data = vedata;
workbench_materials_cache_finish(data);
}
static void workbench_solid_draw_background(void *vedata)
{
WORKBENCH_Data * data = (WORKBENCH_Data *)vedata;
WORKBENCH_Data *data = vedata;
workbench_materials_draw_background(data);
}
static void workbench_solid_draw_scene(void *vedata)
{
WORKBENCH_Data * data = (WORKBENCH_Data *)vedata;
WORKBENCH_Data *data = vedata;
workbench_materials_draw_scene(data);
}

View File

@@ -223,7 +223,7 @@ static void workbench_init_object_data(ObjectEngineData *engine_data)
static void get_material_solid_color(WORKBENCH_PrivateData *wpd, Object *ob, Material *mat, float *color, float hsv_saturation, float hsv_value)
{
/* When in OB_TEXTURE always uyse V3D_SHADING_MATERIAL_COLOR as fallback when no texture could be determined */
int color_type = wpd->drawtype == OB_SOLID? wpd->shading.color_type:V3D_SHADING_MATERIAL_COLOR;
int color_type = wpd->drawtype == OB_SOLID ? wpd->shading.color_type : V3D_SHADING_MATERIAL_COLOR;
static float default_color[] = {0.8f, 0.8f, 0.8f};
if (DRW_object_is_paint_mode(ob) || color_type == V3D_SHADING_SINGLE_COLOR) {
copy_v3_v3(color, wpd->shading.single_color);
@@ -304,7 +304,7 @@ void workbench_materials_engine_init(WORKBENCH_Data *vedata)
void workbench_materials_engine_free()
{
for (int index = 0; index < MAX_SHADERS; index ++) {
for (int index = 0; index < MAX_SHADERS; index++) {
DRW_SHADER_FREE_SAFE(e_data.prepass_sh_cache[index]);
DRW_SHADER_FREE_SAFE(e_data.composite_sh_cache[index]);
}
@@ -352,7 +352,7 @@ void workbench_materials_cache_init(WORKBENCH_Data *vedata)
/* Deferred Mix Pass */
{
WORKBENCH_UBO_World *wd = &wpd->world_data;
UI_GetThemeColor3fv(UI_GetThemeValue(TH_SHOW_BACK_GRAD) ? TH_LOW_GRAD:TH_HIGH_GRAD, wd->background_color_low);
UI_GetThemeColor3fv(UI_GetThemeValue(TH_SHOW_BACK_GRAD) ? TH_LOW_GRAD : TH_HIGH_GRAD, wd->background_color_low);
UI_GetThemeColor3fv(TH_HIGH_GRAD, wd->background_color_high);
/* XXX: Really quick conversion to avoid washed out background.
@@ -428,7 +428,7 @@ static WORKBENCH_MaterialData *get_or_create_material_data(WORKBENCH_Data *vedat
material = BLI_ghash_lookup(wpd->material_hash, SET_UINT_IN_POINTER(hash));
if (material == NULL) {
material = MEM_mallocN(sizeof(WORKBENCH_MaterialData), __func__);
material->shgrp = DRW_shgroup_create(drawtype == OB_SOLID?wpd->prepass_solid_sh:wpd->prepass_texture_sh, psl->prepass_pass);
material->shgrp = DRW_shgroup_create(drawtype == OB_SOLID ? wpd->prepass_solid_sh : wpd->prepass_texture_sh, psl->prepass_pass);
DRW_shgroup_stencil_mask(material->shgrp, 0xFF);
material->object_id = engine_object_data->object_id;
copy_v3_v3(material->color, material_template.color);
@@ -540,7 +540,7 @@ void workbench_materials_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob
else { /* MATERIAL colors */
const int materials_len = MAX2(1, (is_sculpt_mode ? 1 : ob->totcol));
struct GPUMaterial **gpumat_array = BLI_array_alloca(gpumat_array, materials_len);
for (int i = 0; i < materials_len; i ++) {
for (int i = 0; i < materials_len; i++) {
gpumat_array[i] = NULL;
}

View File

@@ -90,22 +90,22 @@ void studiolight_update_world(int studio_light, WORKBENCH_UBO_World *wd)
uint *WORKBENCH_generate_studiolight_preview(int studiolight_id, int icon_size)
{
unsigned int* rect = MEM_mallocN(icon_size * icon_size * sizeof(unsigned int), __func__);
unsigned int *rect = MEM_mallocN(icon_size * icon_size * sizeof(unsigned int), __func__);
int icon_center = icon_size / 2;
float sphere_radius = icon_center * 0.9;
int offset = 0;
for (int y = 0 ; y < icon_size ; y ++) {
for (int y = 0; y < icon_size; y++) {
float dy = y - icon_center;
for (int x = 0 ; x < icon_size ; x ++) {
for (int x = 0; x < icon_size; x++) {
float dx = x - icon_center;
/* calculate aliasing */
float alias = 0;
const float alias_step = 0.2;
for (float ay = dy - 0.5; ay < dy + 0.5 ; ay += alias_step) {
for (float ax = dx - 0.5; ax < dx + 0.5 ; ax += alias_step) {
if (sqrt(ay*ay + ax*ax) < sphere_radius) {
alias += alias_step*alias_step;
for (float ay = dy - 0.5; ay < dy + 0.5; ay += alias_step) {
for (float ax = dx - 0.5; ax < dx + 0.5; ax += alias_step) {
if (sqrt(ay * ay + ax * ax) < sphere_radius) {
alias += alias_step * alias_step;
}
}
}
@@ -117,7 +117,7 @@ uint *WORKBENCH_generate_studiolight_preview(int studiolight_id, int icon_size)
float normal[3];
normal[0] = dx / sphere_radius;
normal[1] = dy / sphere_radius;
normal[2] = sqrt(-(normal[0]*normal[0])-(normal[1]*normal[1]) + 1);
normal[2] = sqrt(-(normal[0] * normal[0]) - (normal[1] * normal[1]) + 1);
normalize_v3(normal);
float color[3];
@@ -128,10 +128,9 @@ uint *WORKBENCH_generate_studiolight_preview(int studiolight_id, int icon_size)
interp_v3_v3v3(color, color, studiolights[studiolight_id][STUDIOLIGHT_Z_POS], clamp_f(normal[2], 0.0, 1.0));
pixelresult = rgb_to_cpack(
linearrgb_to_srgb(color[0]),
linearrgb_to_srgb(color[1]),
linearrgb_to_srgb(color[2])
) | alias_mask;
linearrgb_to_srgb(color[0]),
linearrgb_to_srgb(color[1]),
linearrgb_to_srgb(color[2])) | alias_mask;
}
rect[offset++] = pixelresult;
}