1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
// Copyright 2019 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#pragma once
// ospray
#include "rkcommon/math/AffineSpace.ih"
#include "rkcommon/math/box.ih"
OSPRAY_BEGIN_ISPC_NAMESPACE
// Array of all ray intervals across ray
#define CLIPPING_INTERVALS_MAX_COUNT 64
struct RayIntervals
{
uint32 count;
range1f intervals[CLIPPING_INTERVALS_MAX_COUNT];
};
// Maximum number of intersections with clipping geometries
#define CLIPPING_HITS_MAX_COUNT ((CLIPPING_INTERVALS_MAX_COUNT - 1) * 2)
// Single clipping hit structure
struct ClippingHit
{
float t;
int primID;
int geomID;
int instID;
};
// Compare two floats using ULP distance
inline bool floatUlpCompare(float a, float b, uniform unsigned int ulpMaxDiff)
{
if (a == b)
return true;
int ulpDiff = (int)intbits(a) - (int)intbits(b);
// Integer absolute value, equivalent to:
// if (ulpDiff < 0) ulpDiff = -ulpDiff;
int mask = (ulpDiff >> 31);
unsigned int ulpDiffUnsigned = (ulpDiff ^ mask) - mask;
if (ulpDiffUnsigned <= ulpMaxDiff)
return true;
return false;
}
inline bool overlapped(const range1f &a, const range1f &b)
{
return (a.upper > b.lower) && (a.lower < b.upper);
}
OSPRAY_END_ISPC_NAMESPACE
|