// Copyright 2009-2020 Intel Corporation // SPDX-License-Identifier: Apache-2.0 #pragma once #include "../common/ray.h" namespace embree { namespace isa { struct HalfPlane { const Vec3fa P; //!< plane origin const Vec3fa N; //!< plane normal __forceinline HalfPlane(const Vec3fa& P, const Vec3fa& N) : P(P), N(N) {} __forceinline BBox1f intersect(const Vec3fa& ray_org, const Vec3fa& ray_dir) const { Vec3fa O = Vec3fa(ray_org) - P; Vec3fa D = Vec3fa(ray_dir); float ON = dot(O,N); float DN = dot(D,N); bool eps = abs(DN) < min_rcp_input; float t = -ON*rcp(DN); float lower = select(eps || DN < 0.0f, float(neg_inf), t); float upper = select(eps || DN > 0.0f, float(pos_inf), t); return BBox1f(lower,upper); } }; template struct HalfPlaneN { const Vec3vf P; //!< plane origin const Vec3vf N; //!< plane normal __forceinline HalfPlaneN(const Vec3vf& P, const Vec3vf& N) : P(P), N(N) {} __forceinline BBox> intersect(const Vec3fa& ray_org, const Vec3fa& ray_dir) const { Vec3vf O = Vec3vf((Vec3fa)ray_org) - P; Vec3vf D = Vec3vf((Vec3fa)ray_dir); vfloat ON = dot(O,N); vfloat DN = dot(D,N); vbool eps = abs(DN) < min_rcp_input; vfloat t = -ON*rcp(DN); vfloat lower = select(eps | DN < 0.0f, vfloat(neg_inf), t); vfloat upper = select(eps | DN > 0.0f, vfloat(pos_inf), t); return BBox>(lower,upper); } }; } }