Jump to content

[SOLVED] BoundBox ( only check x,y )


photo

Recommended Posts

how to change code that only check x ,y?

 

USE_SSE , USE_ALTIVEC , USE_NEON

 

INLINE int BoundBox::insideValid(const vec3 &point,float radius) const {

#ifdef USE_SSE

__m128 r = vec3(radius).vec;

__m128 res_0 = _mm_cmpgt_ps(min.vec,_mm_add_ps(point.vec,r));

__m128 res_1 = _mm_cmplt_ps(max.vec,_mm_sub_ps(point.vec,r));

return ((_mm_movemask_ps(_mm_or_ps(res_0,res_1)) & 0x07) == 0);

#elif USE_ALTIVEC

vec_float4 r = vec_splats(radius);

vec_uint4 res_0 = (vec_uint4)vec_cmpgt(min.vec,vec_add(point.vec,r));

vec_uint4 res_1 = (vec_uint4)vec_cmplt(max.vec,vec_sub(point.vec,r));

return ((vec_perm(vec_or(res_0,res_1),res_1,VEC_PERM2(B0,B0,B0,B0))[0] & 0xffffff00) == 0);

#elif USE_NEON

float32x4_t r = vdupq_n_f32(radius);

uint32x4_t res_0 = vcgtq_f32(min.vec,vaddq_f32(point.vec,r));

uint32x4_t res_1 = vcltq_f32(max.vec,vsubq_f32(point.vec,r));

return ((vmaskq_u32(vorrq_u32(res_0,res_1)) & 0x07) == 0);

#else

if(min.x > point.x + radius || max.x < point.x - radius) return 0;

if(min.y > point.y + radius || max.y < point.y - radius) return 0;

// if(min.z > point.z + radius || max.z < point.z - radius) return 0; <= like this

return 1;

#endif

}

Link to comment
×
×
  • Create New...