summaryrefslogtreecommitdiff
path: root/thirdparty/embree/kernels/geometry/object.h
blob: 2a61829ffd2a8d19486d5c04fab4ea861f18f6d4 (plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright 2009-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include "primitive.h"

namespace embree
{
  struct Object
  {
    struct Type : public PrimitiveType 
    {
      const char* name() const;
      size_t sizeActive(const char* This) const;
      size_t sizeTotal(const char* This) const;
      size_t getBytes(const char* This) const;
    };
    static Type type;

  public:

    /* primitive supports multiple time segments */
    static const bool singleTimeSegment = false;

    /* Returns maximum number of stored primitives */
    static __forceinline size_t max_size() { return 1; }

    /* Returns required number of primitive blocks for N primitives */
    static __forceinline size_t blocks(size_t N) { return N; }

  public:

    /*! constructs a virtual object */
    Object (unsigned geomID, unsigned primID) 
    : _geomID(geomID), _primID(primID) {}

    __forceinline unsigned geomID() const {
      return _geomID;
    }

    __forceinline unsigned primID() const {
      return _primID;
    }

    /*! fill triangle from triangle list */
    __forceinline void fill(const PrimRef* prims, size_t& i, size_t end, Scene* scene)
    {
      const PrimRef& prim = prims[i]; i++;
      new (this) Object(prim.geomID(), prim.primID());
    }

    /*! fill triangle from triangle list */
    __forceinline LBBox3fa fillMB(const PrimRef* prims, size_t& i, size_t end, Scene* scene, size_t itime)
    {
      const PrimRef& prim = prims[i]; i++;
      const unsigned geomID = prim.geomID();
      const unsigned primID = prim.primID();
      new (this) Object(geomID, primID);
      AccelSet* accel = (AccelSet*) scene->get(geomID);
      return accel->linearBounds(primID,itime);
    }

    /*! fill triangle from triangle list */
    __forceinline LBBox3fa fillMB(const PrimRefMB* prims, size_t& i, size_t end, Scene* scene, const BBox1f time_range)
    {
      const PrimRefMB& prim = prims[i]; i++;
      const unsigned geomID = prim.geomID();
      const unsigned primID = prim.primID();
      new (this) Object(geomID, primID);
      AccelSet* accel = (AccelSet*) scene->get(geomID);
      return accel->linearBounds(primID,time_range);
    }

    /* Updates the primitive */
    __forceinline BBox3fa update(AccelSet* mesh) {
      return mesh->bounds(primID());
    }

  private:
    unsigned int _geomID;  //!< geometry ID
    unsigned int _primID;  //!< primitive ID
  };
}