Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

Anonymous
Friday, August 17th, 2012 at 10:23:24pm MDT 

  1. void
  2. M_MatrixRotateAxis44_SSE(M_Matrix44 *M, M_Real theta, M_Vector3 A)
  3. {
  4.         float s = sinf((float)theta);
  5.         float c = cosf((float)theta);
  6.         float t = 1.0f - c;
  7.         M_Matrix44 R;
  8.         __m128 a = A.m128, r1;
  9. #ifdef HAVE_SSE3
  10.         __m128 rC1 = _mm_set_ps(-c,    s*A.z, 0.0f,  +c);       /* 1,3 1,2 3 2 */
  11.         __m128 rC2 = _mm_set_ps(0.0f, -s*A.y, s*A.y, -s*A.x);   /* 1,2 3 1 2,3 */
  12. #endif
  13.  
  14.         /* m1: [t*AxAx + c,    t*AxAy + sAz,    t*AxAz - sAy,    0] */
  15.         r1 = _mm_mul_ps(_mm_set1_ps(t), a);
  16.         r1 = _mm_mul_ps(r1, _mm_shuffle_ps(a,a,_MM_SHUFFLE(0,0,0,0)));
  17. #ifdef HAVE_SSE3
  18.         R.m1 = _mm_addsub_ps(r1, _mm_shuffle_ps(rC1,rC2,_MM_SHUFFLE(3,1,2,3)));
  19. #else
  20.         R.m1 = _mm_add_ps(r1, _mm_set_ps(0.0f, -s*A.y, s*A.z, c));
  21. #endif
  22.  
  23.         /* m2: [t*AxAy - sAz,    t*AyAy + c,    t*AyAz + sAx,    0] */
  24.         r1 = _mm_mul_ps(_mm_set1_ps(t), _mm_shuffle_ps(a,a,_MM_SHUFFLE(3,1,1,0)));
  25.         r1 = _mm_mul_ps(r1, _mm_shuffle_ps(a,a,_MM_SHUFFLE(3,2,1,1)));
  26. #ifdef HAVE_SSE3
  27.         R.m2 = _mm_addsub_ps(r1, _mm_shuffle_ps(rC1,rC2,_MM_SHUFFLE(3,0,0,2)));
  28. #else
  29.         R.m2 = _mm_add_ps(r1, _mm_set_ps(0.0f, +s*A.x, c, -s*A.z));
  30. #endif
  31.  
  32.         /* m3: [t*AxAz + sAy,    t*AyAz - sAx,    t*AzAz + c,    0] */
  33.         r1 = _mm_mul_ps(_mm_set1_ps(t), a);
  34.         r1 = _mm_mul_ps(r1, _mm_shuffle_ps(a,a,_MM_SHUFFLE(0,2,2,2)));
  35. #ifdef HAVE_SSE3
  36.         R.m3 = _mm_addsub_ps(r1, _mm_shuffle_ps(rC2,rC1,_MM_SHUFFLE(1,3,0,2)));
  37. #else
  38.         R.m3 = _mm_add_ps(r1, _mm_set_ps(0.0f, c, -s*A.x, +s*A.y));
  39. #endif
  40.         /* m4: [0,    0,    0,    1] */
  41.         R.m4 = _mm_set_ps(1.0f, 0.0f, 0.0f, 0.0f);
  42.  
  43.         M_MatrixMult44v_SSE(M, &R);
  44. }

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

fantasy-obligation