Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ 3D
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

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

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
	
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
  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 325
1 DamithSL 265
2 CPallini 235
3 Sergey Alexandrovich Kryukov 229
4 Maciej Los 190
0 OriginalGriff 5,455
1 DamithSL 4,422
2 Maciej Los 3,860
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,010


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 1 Oct 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100