// Copyright 2009-2020 Intel Corporation // SPDX-License-Identifier: Apache-2.0 #pragma once #include "bvh_node_aabb_mb.h" namespace embree { /*! Aligned 4D Motion Blur Node */ template struct AABBNodeMB4D_t : public AABBNodeMB_t { using BaseNode_t::children; using AABBNodeMB_t::set; typedef BVHNodeRecord NodeRecord; typedef BVHNodeRecordMB NodeRecordMB; typedef BVHNodeRecordMB4D NodeRecordMB4D; struct Create { template __forceinline NodeRef operator() (BuildRecord*, const size_t, const FastAllocator::CachedAllocator& alloc, bool hasTimeSplits = true) const { if (hasTimeSplits) { AABBNodeMB4D_t* node = (AABBNodeMB4D_t*) alloc.malloc0(sizeof(AABBNodeMB4D_t),NodeRef::byteNodeAlignment); node->clear(); return NodeRef::encodeNode(node); } else { AABBNodeMB_t* node = (AABBNodeMB_t*) alloc.malloc0(sizeof(AABBNodeMB_t),NodeRef::byteNodeAlignment); node->clear(); return NodeRef::encodeNode(node); } } }; struct Set { template __forceinline void operator() (const BuildRecord&, const BuildRecord*, NodeRef ref, NodeRecordMB4D* children, const size_t num) const { if (likely(ref.isAABBNodeMB())) { for (size_t i=0; iset(i, children[i]); } else { for (size_t i=0; iset(i, children[i]); } } }; /*! Clears the node. */ __forceinline void clear() { lower_t = vfloat(pos_inf); upper_t = vfloat(neg_inf); AABBNodeMB_t::clear(); } /*! Sets bounding box of child. */ __forceinline void setBounds(size_t i, const LBBox3fa& bounds, const BBox1f& tbounds) { AABBNodeMB_t::setBounds(i, bounds.global(tbounds)); lower_t[i] = tbounds.lower; upper_t[i] = tbounds.upper == 1.0f ? 1.0f+float(ulp) : tbounds.upper; } /*! Sets bounding box and ID of child. */ __forceinline void set(size_t i, const NodeRecordMB4D& child) { AABBNodeMB_t::setRef(i,child.ref); setBounds(i, child.lbounds, child.dt); } /*! Returns the expected surface area when randomly sampling the time. */ __forceinline float expectedHalfArea(size_t i) const { return AABBNodeMB_t::lbounds(i).expectedHalfArea(timeRange(i)); } /*! returns time range for specified child */ __forceinline BBox1f timeRange(size_t i) const { return BBox1f(lower_t[i],upper_t[i]); } /*! stream output operator */ friend embree_ostream operator<<(embree_ostream cout, const AABBNodeMB4D_t& n) { cout << "AABBNodeMB4D {" << embree_endl; for (size_t i=0; i lower_t; //!< time dimension of lower bounds of all N children vfloat upper_t; //!< time dimension of upper bounds of all N children }; }