// Copyright 2009-2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 #pragma once #include "object.h" #include "../common/ray.h" namespace embree { namespace isa { template struct ObjectIntersector1 { typedef Object Primitive; static const bool validIntersectorK = false; struct Precalculations { __forceinline Precalculations() {} __forceinline Precalculations (const Ray& ray, const void *ptr) {} }; static __forceinline void intersect(const Precalculations& pre, RayHit& ray, IntersectContext* context, const Primitive& prim) { AccelSet* accel = (AccelSet*) context->scene->get(prim.geomID()); /* perform ray mask test */ #if defined(EMBREE_RAY_MASK) if ((ray.mask & accel->mask) == 0) return; #endif accel->intersect(ray,prim.geomID(),prim.primID(),context,reportIntersection1); } static __forceinline bool occluded(const Precalculations& pre, Ray& ray, IntersectContext* context, const Primitive& prim) { AccelSet* accel = (AccelSet*) context->scene->get(prim.geomID()); /* perform ray mask test */ #if defined(EMBREE_RAY_MASK) if ((ray.mask & accel->mask) == 0) return false; #endif accel->occluded(ray,prim.geomID(),prim.primID(),context,&reportOcclusion1); return ray.tfar < 0.0f; } static __forceinline bool pointQuery(PointQuery* query, PointQueryContext* context, const Primitive& prim) { AccelSet* accel = (AccelSet*)context->scene->get(prim.geomID()); context->geomID = prim.geomID(); context->primID = prim.primID(); return accel->pointQuery(query, context); } template static __forceinline void intersectK(const vbool& valid, /* PrecalculationsK& pre, */ RayHitK& ray, IntersectContext* context, const Primitive* prim, size_t num, size_t& lazy_node) { assert(false); } template static __forceinline vbool occludedK(const vbool& valid, /* PrecalculationsK& pre, */ RayK& ray, IntersectContext* context, const Primitive* prim, size_t num, size_t& lazy_node) { assert(false); return valid; } }; template struct ObjectIntersectorK { typedef Object Primitive; struct Precalculations { __forceinline Precalculations (const vbool& valid, const RayK& ray) {} }; static __forceinline void intersect(const vbool& valid_i, const Precalculations& pre, RayHitK& ray, IntersectContext* context, const Primitive& prim) { vbool valid = valid_i; AccelSet* accel = (AccelSet*) context->scene->get(prim.geomID()); /* perform ray mask test */ #if defined(EMBREE_RAY_MASK) valid &= (ray.mask & accel->mask) != 0; if (none(valid)) return; #endif accel->intersect(valid,ray,prim.geomID(),prim.primID(),context,&reportIntersection1); } static __forceinline vbool occluded(const vbool& valid_i, const Precalculations& pre, RayK& ray, IntersectContext* context, const Primitive& prim) { vbool valid = valid_i; AccelSet* accel = (AccelSet*) context->scene->get(prim.geomID()); /* perform ray mask test */ #if defined(EMBREE_RAY_MASK) valid &= (ray.mask & accel->mask) != 0; if (none(valid)) return false; #endif accel->occluded(valid,ray,prim.geomID(),prim.primID(),context,&reportOcclusion1); return ray.tfar < 0.0f; } static __forceinline void intersect(Precalculations& pre, RayHitK& ray, size_t k, IntersectContext* context, const Primitive& prim) { intersect(vbool(1<& ray, size_t k, IntersectContext* context, const Primitive& prim) { occluded(vbool(1< ObjectIntersector4; typedef ObjectIntersectorK<8,false> ObjectIntersector8; typedef ObjectIntersectorK<16,false> ObjectIntersector16; typedef ObjectIntersectorK<4,true> ObjectIntersector4MB; typedef ObjectIntersectorK<8,true> ObjectIntersector8MB; typedef ObjectIntersectorK<16,true> ObjectIntersector16MB; } }