// Copyright 2009-2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 #pragma once #include "primitive.h" #include "../subdiv/bezier_curve.h" #include "../common/primref.h" #include "bezier_hair_intersector.h" #include "bezier_ribbon_intersector.h" #include "bezier_curve_intersector.h" #include "oriented_curve_intersector.h" #include "../bvh/node_intersector1.h" // FIXME: this file seems replicate of curve_intersector_virtual.h namespace embree { namespace isa { struct VirtualCurveIntersector1 { typedef unsigned char Primitive; typedef CurvePrecalculations1 Precalculations; template static __forceinline void intersect(const Accel::Intersectors* This, Precalculations& pre, RayHit& ray, IntersectContext* context, const Primitive* prim, size_t num, const TravRay &tray, size_t& lazy_node) { assert(num == 1); RTCGeometryType ty = (RTCGeometryType)(*prim); assert(This->leafIntersector); VirtualCurvePrimitive::Intersectors& leafIntersector = ((VirtualCurvePrimitive*) This->leafIntersector)->vtbl[ty]; leafIntersector.intersect<1>(&pre,&ray,context,prim); } template static __forceinline bool occluded(const Accel::Intersectors* This, Precalculations& pre, Ray& ray, IntersectContext* context, const Primitive* prim, size_t num, const TravRay &tray, size_t& lazy_node) { assert(num == 1); RTCGeometryType ty = (RTCGeometryType)(*prim); assert(This->leafIntersector); VirtualCurvePrimitive::Intersectors& leafIntersector = ((VirtualCurvePrimitive*) This->leafIntersector)->vtbl[ty]; return leafIntersector.occluded<1>(&pre,&ray,context,prim); } }; template struct VirtualCurveIntersectorK { typedef unsigned char Primitive; typedef CurvePrecalculationsK Precalculations; static __forceinline void intersect(const vbool& valid_i, const Accel::Intersectors* This, Precalculations& pre, RayHitK& ray, IntersectContext* context, const Primitive* prim, size_t num, size_t& lazy_node) { assert(num == 1); RTCGeometryType ty = (RTCGeometryType)(*prim); assert(This->leafIntersector); VirtualCurvePrimitive::Intersectors& leafIntersector = ((VirtualCurvePrimitive*) This->leafIntersector)->vtbl[ty]; size_t mask = movemask(valid_i); while (mask) leafIntersector.intersect(&pre,&ray,bscf(mask),context,prim); } static __forceinline vbool occluded(const vbool& valid_i, const Accel::Intersectors* This, Precalculations& pre, RayK& ray, IntersectContext* context, const Primitive* prim, size_t num, size_t& lazy_node) { assert(num == 1); RTCGeometryType ty = (RTCGeometryType)(*prim); assert(This->leafIntersector); VirtualCurvePrimitive::Intersectors& leafIntersector = ((VirtualCurvePrimitive*) This->leafIntersector)->vtbl[ty]; vbool valid_o = false; size_t mask = movemask(valid_i); while (mask) { size_t k = bscf(mask); if (leafIntersector.occluded(&pre,&ray,k,context,prim)) set(valid_o, k); } return valid_o; } static __forceinline void intersect(const Accel::Intersectors* This, Precalculations& pre, RayHitK& ray, size_t k, IntersectContext* context, const Primitive* prim, size_t num, size_t& lazy_node) { assert(num == 1); RTCGeometryType ty = (RTCGeometryType)(*prim); assert(This->leafIntersector); VirtualCurvePrimitive::Intersectors& leafIntersector = ((VirtualCurvePrimitive*) This->leafIntersector)->vtbl[ty]; leafIntersector.intersect(&pre,&ray,k,context,prim); } static __forceinline bool occluded(const Accel::Intersectors* This, Precalculations& pre, RayK& ray, size_t k, IntersectContext* context, const Primitive* prim, size_t num, size_t& lazy_node) { assert(num == 1); RTCGeometryType ty = (RTCGeometryType)(*prim); assert(This->leafIntersector); VirtualCurvePrimitive::Intersectors& leafIntersector = ((VirtualCurvePrimitive*) This->leafIntersector)->vtbl[ty]; return leafIntersector.occluded(&pre,&ray,k,context,prim); } }; } }