Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/gpencil/gpencil_draw_data.c
| Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | static void gpencil_shade_color(float color[3]) | ||||
| } | } | ||||
| else { | else { | ||||
| add_v3_fl(color, 0.15f); | add_v3_fl(color, 0.15f); | ||||
| } | } | ||||
| CLAMP3(color, 0.0f, 1.0f); | CLAMP3(color, 0.0f, 1.0f); | ||||
| } | } | ||||
| /* Apply all overrides from the solid viewport mode to the GPencil material. */ | /* Apply all overrides from the solid viewport mode to the GPencil material. */ | ||||
| static MaterialGPencilStyle *gpencil_viewport_material_overrides(GPENCIL_PrivateData *pd, | static MaterialGPencilStyle *gpencil_viewport_material_overrides( | ||||
| GPENCIL_PrivateData *pd, | |||||
fclem: Use `eV3DShadingLightingMode` instead of char. | |||||
| Object *ob, | Object *ob, | ||||
| int color_type, | int color_type, | ||||
| MaterialGPencilStyle *gp_style) | MaterialGPencilStyle *gp_style, | ||||
| const eV3DShadingLightingMode lighting_mode) | |||||
| { | { | ||||
| static MaterialGPencilStyle gp_style_tmp; | static MaterialGPencilStyle gp_style_tmp; | ||||
| switch (color_type) { | switch (color_type) { | ||||
| case V3D_SHADING_MATERIAL_COLOR: | case V3D_SHADING_MATERIAL_COLOR: | ||||
| case V3D_SHADING_RANDOM_COLOR: | case V3D_SHADING_RANDOM_COLOR: | ||||
| /* Random uses a random color by layer and this is done using the tint | /* Random uses a random color by layer and this is done using the tint | ||||
| * layer. A simple color by object, like meshes, is not practical in | * layer. A simple color by object, like meshes, is not practical in | ||||
| Show All 23 Lines | case V3D_SHADING_TEXTURE_COLOR: | ||||
| break; | break; | ||||
| case V3D_SHADING_SINGLE_COLOR: | case V3D_SHADING_SINGLE_COLOR: | ||||
| gp_style = &gp_style_tmp; | gp_style = &gp_style_tmp; | ||||
| gp_style->stroke_style = GP_MATERIAL_STROKE_STYLE_SOLID; | gp_style->stroke_style = GP_MATERIAL_STROKE_STYLE_SOLID; | ||||
| gp_style->fill_style = GP_MATERIAL_FILL_STYLE_SOLID; | gp_style->fill_style = GP_MATERIAL_FILL_STYLE_SOLID; | ||||
| copy_v3_v3(gp_style->fill_rgba, pd->v3d_single_color); | copy_v3_v3(gp_style->fill_rgba, pd->v3d_single_color); | ||||
| gp_style->fill_rgba[3] = 1.0f; | gp_style->fill_rgba[3] = 1.0f; | ||||
| copy_v4_v4(gp_style->stroke_rgba, gp_style->fill_rgba); | copy_v4_v4(gp_style->stroke_rgba, gp_style->fill_rgba); | ||||
| if (lighting_mode != V3D_LIGHTING_FLAT) { | |||||
| gpencil_shade_color(gp_style->stroke_rgba); | gpencil_shade_color(gp_style->stroke_rgba); | ||||
| } | |||||
| break; | break; | ||||
| case V3D_SHADING_OBJECT_COLOR: | case V3D_SHADING_OBJECT_COLOR: | ||||
| gp_style = &gp_style_tmp; | gp_style = &gp_style_tmp; | ||||
| gp_style->stroke_style = GP_MATERIAL_STROKE_STYLE_SOLID; | gp_style->stroke_style = GP_MATERIAL_STROKE_STYLE_SOLID; | ||||
| gp_style->fill_style = GP_MATERIAL_FILL_STYLE_SOLID; | gp_style->fill_style = GP_MATERIAL_FILL_STYLE_SOLID; | ||||
| copy_v4_v4(gp_style->fill_rgba, ob->color); | copy_v4_v4(gp_style->fill_rgba, ob->color); | ||||
| copy_v4_v4(gp_style->stroke_rgba, ob->color); | copy_v4_v4(gp_style->stroke_rgba, ob->color); | ||||
| if (lighting_mode != V3D_LIGHTING_FLAT) { | |||||
| gpencil_shade_color(gp_style->stroke_rgba); | gpencil_shade_color(gp_style->stroke_rgba); | ||||
| } | |||||
| break; | break; | ||||
| case V3D_SHADING_VERTEX_COLOR: | case V3D_SHADING_VERTEX_COLOR: | ||||
| gp_style = &gp_style_tmp; | gp_style = &gp_style_tmp; | ||||
| gp_style->stroke_style = GP_MATERIAL_STROKE_STYLE_SOLID; | gp_style->stroke_style = GP_MATERIAL_STROKE_STYLE_SOLID; | ||||
| gp_style->fill_style = GP_MATERIAL_FILL_STYLE_SOLID; | gp_style->fill_style = GP_MATERIAL_FILL_STYLE_SOLID; | ||||
| copy_v4_fl(gp_style->fill_rgba, 1.0f); | copy_v4_fl(gp_style->fill_rgba, 1.0f); | ||||
| copy_v4_fl(gp_style->stroke_rgba, 1.0f); | copy_v4_fl(gp_style->stroke_rgba, 1.0f); | ||||
| break; | break; | ||||
| Show All 25 Lines | else { | ||||
| *ofs = 0; | *ofs = 0; | ||||
| } | } | ||||
| /* Force vertex color in solid mode with vertex paint mode. Same behavior as meshes. */ | /* Force vertex color in solid mode with vertex paint mode. Same behavior as meshes. */ | ||||
| bGPdata *gpd = (bGPdata *)ob->data; | bGPdata *gpd = (bGPdata *)ob->data; | ||||
| int color_type = (pd->v3d_color_type != -1 && GPENCIL_VERTEX_MODE(gpd)) ? | int color_type = (pd->v3d_color_type != -1 && GPENCIL_VERTEX_MODE(gpd)) ? | ||||
| V3D_SHADING_VERTEX_COLOR : | V3D_SHADING_VERTEX_COLOR : | ||||
| pd->v3d_color_type; | pd->v3d_color_type; | ||||
| const eV3DShadingLightingMode lighting_mode = (pd->v3d != NULL) ? pd->v3d->shading.light : | |||||
Not Done Inline ActionsBetter use the light mode instead of 1, no? antoniov: Better use the light mode instead of 1, no? | |||||
| V3D_LIGHTING_STUDIO; | |||||
| GPENCIL_MaterialPool *pool = matpool; | GPENCIL_MaterialPool *pool = matpool; | ||||
| for (int i = 0; i < mat_len; i++) { | for (int i = 0; i < mat_len; i++) { | ||||
| if ((i > 0) && (pool->used_count == GP_MATERIAL_BUFFER_LEN)) { | if ((i > 0) && (pool->used_count == GP_MATERIAL_BUFFER_LEN)) { | ||||
| pool->next = gpencil_material_pool_add(pd); | pool->next = gpencil_material_pool_add(pd); | ||||
| pool = pool->next; | pool = pool->next; | ||||
| } | } | ||||
| int mat_id = pool->used_count++; | int mat_id = pool->used_count++; | ||||
| Show All 31 Lines | for (int i = 0; i < mat_len; i++) { | ||||
| /* Material with holdout. */ | /* Material with holdout. */ | ||||
| if (gp_style->flag & GP_MATERIAL_IS_STROKE_HOLDOUT) { | if (gp_style->flag & GP_MATERIAL_IS_STROKE_HOLDOUT) { | ||||
| mat_data->flag |= GP_STROKE_HOLDOUT; | mat_data->flag |= GP_STROKE_HOLDOUT; | ||||
| } | } | ||||
| if (gp_style->flag & GP_MATERIAL_IS_FILL_HOLDOUT) { | if (gp_style->flag & GP_MATERIAL_IS_FILL_HOLDOUT) { | ||||
| mat_data->flag |= GP_FILL_HOLDOUT; | mat_data->flag |= GP_FILL_HOLDOUT; | ||||
| } | } | ||||
| gp_style = gpencil_viewport_material_overrides(pd, ob, color_type, gp_style); | gp_style = gpencil_viewport_material_overrides(pd, ob, color_type, gp_style, lighting_mode); | ||||
| /* Dots or Squares rotation. */ | /* Dots or Squares rotation. */ | ||||
| mat_data->alignment_rot_cos = cosf(gp_style->alignment_rotation); | mat_data->alignment_rot_cos = cosf(gp_style->alignment_rotation); | ||||
| mat_data->alignment_rot_sin = sinf(gp_style->alignment_rotation); | mat_data->alignment_rot_sin = sinf(gp_style->alignment_rotation); | ||||
| /* Stroke Style */ | /* Stroke Style */ | ||||
| if ((gp_style->stroke_style == GP_MATERIAL_STROKE_STYLE_TEXTURE) && (gp_style->sima)) { | if ((gp_style->stroke_style == GP_MATERIAL_STROKE_STYLE_TEXTURE) && (gp_style->sima)) { | ||||
| bool premul; | bool premul; | ||||
| ▲ Show 20 Lines • Show All 237 Lines • Show Last 20 Lines | |||||
Use eV3DShadingLightingMode instead of char.