Click here to Skip to main content
15,886,664 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 solution

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
	
section ".text" code readable executable

_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

section ".data" data readable writeable

_1:
    dq 004080C001010101h
    dq 0101010101010101h
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900