Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/mask_rasterize.c
| Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | |||||
| * | * | ||||
| * This is getting a bit complicated with the addition of unfilled splines and end capping - | * This is getting a bit complicated with the addition of unfilled splines and end capping - | ||||
| * If large changes are needed here we would be better off using an iterable | * If large changes are needed here we would be better off using an iterable | ||||
| * BLI_mempool for triangles and converting to a contiguous array afterwards. | * BLI_mempool for triangles and converting to a contiguous array afterwards. | ||||
| * | * | ||||
| * - Campbell | * - Campbell | ||||
| */ | */ | ||||
| #include "CLG_log.h" | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_vec_types.h" | #include "DNA_vec_types.h" | ||||
| #include "DNA_mask_types.h" | #include "DNA_mask_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_scanfill.h" | #include "BLI_scanfill.h" | ||||
| Show All 37 Lines | # define FACE_ASSERT(face, vert_max) \ | ||||
| BLI_assert(_t[2] < vert_max); \ | BLI_assert(_t[2] < vert_max); \ | ||||
| BLI_assert(_t[3] < vert_max || _t[3] == TRI_VERT); \ | BLI_assert(_t[3] < vert_max || _t[3] == TRI_VERT); \ | ||||
| } (void)0 | } (void)0 | ||||
| #else | #else | ||||
| /* do nothing */ | /* do nothing */ | ||||
| # define FACE_ASSERT(face, vert_max) | # define FACE_ASSERT(face, vert_max) | ||||
| #endif | #endif | ||||
| static CLG_LogRef LOG = {"bke.mask_rasterize"}; | |||||
| static void rotate_point_v2(float r_p[2], const float p[2], const float cent[2], const float angle, const float asp[2]) | static void rotate_point_v2(float r_p[2], const float p[2], const float cent[2], const float angle, const float asp[2]) | ||||
| { | { | ||||
| const float s = sinf(angle); | const float s = sinf(angle); | ||||
| const float c = cosf(angle); | const float c = cosf(angle); | ||||
| float p_new[2]; | float p_new[2]; | ||||
| /* translate point back to origin */ | /* translate point back to origin */ | ||||
| r_p[0] = (p[0] - cent[0]) / asp[0]; | r_p[0] = (p[0] - cent[0]) / asp[0]; | ||||
| ▲ Show 20 Lines • Show All 1,264 Lines • ▼ Show 20 Lines | switch (layer->blend) { | ||||
| break; | break; | ||||
| case MASK_BLEND_REPLACE: | case MASK_BLEND_REPLACE: | ||||
| value = (value * (1.0f - layer->alpha)) + (value_layer * layer->alpha); | value = (value * (1.0f - layer->alpha)) + (value_layer * layer->alpha); | ||||
| break; | break; | ||||
| case MASK_BLEND_DIFFERENCE: | case MASK_BLEND_DIFFERENCE: | ||||
| value = fabsf(value - value_layer); | value = fabsf(value - value_layer); | ||||
| break; | break; | ||||
| default: /* same as add */ | default: /* same as add */ | ||||
| CLOG_FATAL(&LOG, "unhandled blend type: %d", layer->blend); | |||||
| BLI_assert(0); | BLI_assert(0); | ||||
| value += value_layer; | value += value_layer; | ||||
| break; | break; | ||||
| } | } | ||||
| /* clamp after applying each layer so we don't get | /* clamp after applying each layer so we don't get | ||||
| * issues subtracting after accumulating over 1.0f */ | * issues subtracting after accumulating over 1.0f */ | ||||
| CLAMP(value, 0.0f, 1.0f); | CLAMP(value, 0.0f, 1.0f); | ||||
| ▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines | |||||