File: Clipping.ih

package info (click to toggle)
ospray 3.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 10,040 kB
  • sloc: cpp: 80,569; ansic: 951; sh: 805; makefile: 171; python: 69
file content (56 lines) | stat: -rw-r--r-- 1,219 bytes parent folder | download | duplicates (2)
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