Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool rayHitsAABB(vec3f a, vec3f b, vec3f pos, vec3f dir) {
- xmm[4] = dir;
- xmm[5] = pos;
- xmm[6] = a;
- xmm[7] = b;
- int i = 1 << 31;
- asm "movd (%esp), %xmm3";
- asm `shufps $0, %xmm3, %xmm3`;
- asm "movaps %xmm4, %xmm2";
- asm "andps %xmm3, %xmm2"; // select sign bits of dir
- asm "xorps %xmm2, %xmm4"; // flip signs where negative
- asm "xorps %xmm2, %xmm5";
- asm "xorps %xmm2, %xmm6";
- asm "xorps %xmm2, %xmm7";
- asm "movaps %xmm6, %xmm2";
- asm "movaps %xmm7, %xmm3";
- asm "minps %xmm3, %xmm6"; // a = min(a, b);
- asm "maxps %xmm2, %xmm7"; // b = max(a, b);
- // pretend ray starts at origin
- dir = xmm[4];
- pos = xmm[5];
- a = xmm[6];
- b = xmm[7];
- a -= pos;
- b -= pos;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement