Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Point* neighbour1 = &grid[y + yoffset[0]][x + xoffset[0]];
- Point* neighbour2 = &grid[y + yoffset[1]][x + xoffset[1]];
- Point* neighbour3 = &grid[y + yoffset[2]][x + xoffset[2]];
- Point* neighbour4 = &grid[y + yoffset[3]][x + xoffset[3]];
- vector3 n1, n2, n3, n4;
- n1 = neighbour1->pos - pointpos;
- n2 = neighbour2->pos - pointpos;
- n3 = neighbour3->pos - pointpos;
- n4 = neighbour4->pos - pointpos;
- __m128 distance_x = _mm_set_ps( n1.x, n2.x, n3.x, n4.x );
- __m128 distance_y = _mm_set_ps( n1.y, n2.y, n3.y, n4.y );
- __m128 distance_z = _mm_set_ps( n1.z, n2.z, n3.z, n4.z );
- distance_x = _mm_mul_ps( distance_x, distance_x );
- distance_y = _mm_mul_ps( distance_y, distance_y );
- distance_z = _mm_mul_ps( distance_z, distance_z );
- __m128 distance = _mm_add_ps( distance_x, _mm_add_ps( distance_y, distance_z ) );
- __m128 restlen = _mm_set_ps( grid[y][x].restlength[0], grid[y][x].restlength[1], grid[y][x].restlength[2], grid[y][x].restlength[3] );
- distance = _mm_sqrt_ps( distance );
- __m128 cmp_distance = _mm_cmpgt_ps( distance, restlen );
- int check = _mm_movemask_ps(cmp_distance);
- cmp_distance = _mm_and_ps( cmp_distance, distance );
- if ( check == 0 ) continue;
- __m128 restlen_res = _mm_div_ps( distance, restlen );
- restlen_res = _mm_sub_ps( restlen_res, _mm_set_ps1( 1 ) );
- float extra;
- if ( cmp_distance.m128_f32[0] != 0 )
- {
- extra = (restlen_res.m128_f32[0]);
- pointpos += extra * n1 * 0.5f;
- neighbour1->pos -= extra * n1 * 0.5f;
- }
- if ( cmp_distance.m128_f32[1] != 0 )
- {
- extra = (restlen_res.m128_f32[1]);
- pointpos += extra * n2 * 0.5f;
- neighbour2->pos -= extra * n2 * 0.5f;
- }
- if ( cmp_distance.m128_f32[2] != 0 )
- {
- extra = (restlen_res.m128_f32[2]);
- pointpos += extra * n3 * 0.5f;
- neighbour3->pos -= extra * n3 * 0.5f;
- }
- if ( cmp_distance.m128_f32[3] != 0 )
- {
- extra = (restlen_res.m128_f32[3]);
- pointpos += extra * n4 * 0.5f;
- neighbour4->pos -= extra * n4 * 0.5f;
- }
Add Comment
Please, Sign In to add comment