12,070,942 members (64,000 online)
Rate this:
See more:
hi,

can anyone help me as to if I can use SIMD instructions to perform AABB collision testing and if yes then how should I go about implementing it.

Thanks
Andy.
Posted 1-Oct-11 3:55am

Rate this:

Solution 1

Hi!

I wrote a simple function in flat assembler that returns true if point is in the box. The 1st and 2nd 16 byte vector describes the box, the 3rd vector is the point. It can be used to test whether one of the 1st box point is in the 2nd box. Or to test whether the 1st's midpoint is in a 2nd box that is larger by the half of the 1st.
```    format MS COFF
public _TestPoint

_TestPoint:
movaps xmm0, dqword[esp + 36]
cmpps xmm0, dqword[esp + 4], 1
pshufb xmm0, dqword[_1]
movd eax, xmm0
test eax, eax
jnz _2

movaps xmm0, dqword[esp + 36]
cmpps xmm0, dqword[esp + 20], 6
pshufb xmm0, dqword[_1]
movd eax, xmm0
test eax, eax
jz _3
_2:
xor eax, eax
ret 48
_3:
mov eax, 1
ret 48

_1:
dq 004080C001010101h
dq 0101010101010101h```
v2

Top Experts
Last 24hrsThis month
 CHill60 210 OriginalGriff 183 Dave Kreskowiak 150 CPallini 130 Sascha Lefèvre 110
 Dave Kreskowiak 2,276 OriginalGriff 1,654 Richard MacCutchan 1,535 CHill60 1,179 CPallini 1,122