使用SSE的AABB碰撞检测 [英] AABB Collision Detection using SSE

查看:120
本文介绍了使用SSE的AABB碰撞检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



任何人都可以帮助我,如果我可以使用SIMD指令执行AABB碰撞测试,如果可以,那么我应该如何实现它.

谢谢
Andy.



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.

推荐答案

嗨!

我在平面汇编器中编写了一个简单的函数,如果point在框中,则返回true.第一个和第二个16字节向量描述了该框,第三个向量是点.它可以用来测试第一个方框中的一个点是否在第二个方框中.或测试第一个中间点是否在第二个盒子中,第二个盒子的大小是第一个盒子的一半.
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


这篇关于使用SSE的AABB碰撞检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆