Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/gpencil_geom.cc
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Stroke Sample | /** \name Stroke Sample | ||||
| * \{ */ | * \{ */ | ||||
| static int stroke_march_next_point(const bGPDstroke *gps, | __attribute__((optimize("O0"))) static int stroke_march_next_point(const bGPDstroke *gps, | ||||
| const int index_next_pt, | const int index_next_pt, | ||||
| const float *current, | const float *current, | ||||
| const float dist, | const float dist, | ||||
| float *result, | float *result, | ||||
| float *pressure, | float *pressure, | ||||
| float *strength, | float *strength, | ||||
| float *vert_color, | float *vert_color, | ||||
| float *ratio_result, | float *ratio_result, | ||||
| int *index_from, | int *index_from, | ||||
| int *index_to) | int *index_to) | ||||
| { | { | ||||
| float remaining_till_next = 0.0f; | float remaining_till_next = 0.0f; | ||||
| float remaining_march = dist; | float remaining_march = dist; | ||||
| float step_start[3]; | float step_start[3]; | ||||
| float point[3]; | float point[3]; | ||||
| int next_point_index = index_next_pt; | int next_point_index = index_next_pt; | ||||
| bGPDspoint *pt = nullptr; | bGPDspoint *pt = nullptr; | ||||
| Show All 26 Lines | |||||
| copy_v3_v3(point, &pt->x); | copy_v3_v3(point, &pt->x); | ||||
| copy_v3_v3(step_start, point); | copy_v3_v3(step_start, point); | ||||
| if (!(next_point_index < gps->totpoints)) { | if (!(next_point_index < gps->totpoints)) { | ||||
| if (gps->flag & GP_STROKE_CYCLIC) { | if (gps->flag & GP_STROKE_CYCLIC) { | ||||
| next_point_index = 0; | next_point_index = 0; | ||||
| } | } | ||||
| else { | else { | ||||
| next_point_index = gps->totpoints - 1; | next_point_index = gps->totpoints - 1; | ||||
| remaining_till_next = 0; | |||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| pt = &gps->points[next_point_index]; | pt = &gps->points[next_point_index]; | ||||
| copy_v3_v3(point, &pt->x); | copy_v3_v3(point, &pt->x); | ||||
| remaining_till_next = len_v3v3(point, step_start); | remaining_till_next = len_v3v3(point, step_start); | ||||
| } | } | ||||
| if (remaining_till_next < remaining_march) { | if (remaining_till_next < remaining_march) { | ||||
| Show All 11 Lines | |||||
| } | } | ||||
| *index_from = next_point_index == 0 ? (gps->totpoints - 1) : (next_point_index - 1); | *index_from = next_point_index == 0 ? (gps->totpoints - 1) : (next_point_index - 1); | ||||
| *index_to = next_point_index; | *index_to = next_point_index; | ||||
| float ratio = remaining_march / remaining_till_next; | float ratio = remaining_march / remaining_till_next; | ||||
| interp_v3_v3v3(result, step_start, point, ratio); | interp_v3_v3v3(result, step_start, point, ratio); | ||||
| *ratio_result = ratio; | *ratio_result = ratio; | ||||
| float d1 = len_v3v3(result, &gps->points[*index_from].x); | |||||
| float d2 = len_v3v3(result, &gps->points[next_point_index].x); | |||||
| float vratio = d1 / (d1 + d2); | |||||
| *pressure = interpf( | *pressure = interpf( | ||||
| gps->points[next_point_index].pressure, gps->points[*index_from].pressure, ratio); | gps->points[next_point_index].pressure, gps->points[*index_from].pressure, vratio); | ||||
| *strength = interpf( | *strength = interpf( | ||||
| gps->points[next_point_index].strength, gps->points[*index_from].strength, ratio); | gps->points[next_point_index].strength, gps->points[*index_from].strength, vratio); | ||||
| interp_v4_v4v4(vert_color, | interp_v4_v4v4(vert_color, | ||||
| gps->points[*index_from].vert_color, | gps->points[*index_from].vert_color, | ||||
| gps->points[next_point_index].vert_color, | gps->points[next_point_index].vert_color, | ||||
| ratio); | vratio); | ||||
| return next_point_index == 0 ? gps->totpoints : next_point_index; | return next_point_index == 0 ? gps->totpoints : next_point_index; | ||||
| } | } | ||||
| static int stroke_march_next_point_no_interp(const bGPDstroke *gps, | static int stroke_march_next_point_no_interp(const bGPDstroke *gps, | ||||
| const int index_next_pt, | const int index_next_pt, | ||||
| const float *current, | const float *current, | ||||
| const float dist, | const float dist, | ||||
| Show All 32 Lines | |||||
| copy_v3_v3(point, &pt->x); | copy_v3_v3(point, &pt->x); | ||||
| copy_v3_v3(step_start, point); | copy_v3_v3(step_start, point); | ||||
| if (!(next_point_index < gps->totpoints)) { | if (!(next_point_index < gps->totpoints)) { | ||||
| if (gps->flag & GP_STROKE_CYCLIC) { | if (gps->flag & GP_STROKE_CYCLIC) { | ||||
| next_point_index = 0; | next_point_index = 0; | ||||
| } | } | ||||
| else { | else { | ||||
| next_point_index = gps->totpoints - 1; | next_point_index = gps->totpoints - 1; | ||||
| remaining_till_next = 0; | |||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| pt = &gps->points[next_point_index]; | pt = &gps->points[next_point_index]; | ||||
| copy_v3_v3(point, &pt->x); | copy_v3_v3(point, &pt->x); | ||||
| remaining_till_next = len_v3v3(point, step_start); | remaining_till_next = len_v3v3(point, step_start); | ||||
| } | } | ||||
| if (remaining_till_next < remaining_march) { | if (remaining_till_next < remaining_march) { | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||