mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
wg_engine: prevent adding duplicate points while trimming
In cases where the distance between points is 0, further processing of the points results in division by zero. To avoid this check, we ensure that duplicate points are not added during trimming.
This commit is contained in:
parent
2fc0aad2d1
commit
dc754833bc
1 changed files with 4 additions and 2 deletions
|
@ -174,9 +174,11 @@ struct WgVertexBuffer {
|
|||
// append points
|
||||
float t_beg = len_seg_beg > 0.0f ? 1.0f - (len_total_beg - len_beg) / len_seg_beg : 0.0f;
|
||||
float t_end = len_seg_end > 0.0f ? 1.0f - (len_total_end - len_end) / len_seg_end : 0.0f;
|
||||
if (index_beg > 0) append(lerp(buff.vbuff[index_beg-1], buff.vbuff[index_beg], t_beg));
|
||||
//t_beg == 1 handled in appendRange
|
||||
if (index_beg > 0 && t_beg != 1.0f) append(lerp(buff.vbuff[index_beg-1], buff.vbuff[index_beg], t_beg));
|
||||
appendRange(buff, index_beg, index_end);
|
||||
if (index_end > 0) append(lerp(buff.vbuff[index_end-1], buff.vbuff[index_end], t_end));
|
||||
//t_end == 0 handled in appendRange
|
||||
if (index_end > 0 && t_end != 0.0f) append(lerp(buff.vbuff[index_end-1], buff.vbuff[index_end], t_end));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue