1// Copyright 2009-2021 Intel Corporation
2// SPDX-License-Identifier: Apache-2.0
3
4#pragma once
5
6#include "primitive.h"
7
8namespace embree
9{
10 struct Object
11 {
12 struct Type : public PrimitiveType
13 {
14 const char* name() const;
15 size_t sizeActive(const char* This) const;
16 size_t sizeTotal(const char* This) const;
17 size_t getBytes(const char* This) const;
18 };
19 static Type type;
20
21 public:
22
23 /* primitive supports multiple time segments */
24 static const bool singleTimeSegment = false;
25
26 /* Returns maximum number of stored primitives */
27 static __forceinline size_t max_size() { return 1; }
28
29 /* Returns required number of primitive blocks for N primitives */
30 static __forceinline size_t blocks(size_t N) { return N; }
31
32 public:
33
34 /*! constructs a virtual object */
35 Object (unsigned geomID, unsigned primID)
36 : _geomID(geomID), _primID(primID) {}
37
38 __forceinline unsigned geomID() const {
39 return _geomID;
40 }
41
42 __forceinline unsigned primID() const {
43 return _primID;
44 }
45
46 /*! fill triangle from triangle list */
47 __forceinline void fill(const PrimRef* prims, size_t& i, size_t end, Scene* scene)
48 {
49 const PrimRef& prim = prims[i]; i++;
50 new (this) Object(prim.geomID(), prim.primID());
51 }
52
53 /*! fill triangle from triangle list */
54 __forceinline LBBox3fa fillMB(const PrimRef* prims, size_t& i, size_t end, Scene* scene, size_t itime)
55 {
56 const PrimRef& prim = prims[i]; i++;
57 const unsigned geomID = prim.geomID();
58 const unsigned primID = prim.primID();
59 new (this) Object(geomID, primID);
60 AccelSet* accel = (AccelSet*) scene->get(geomID);
61 return accel->linearBounds(primID,itime);
62 }
63
64 /*! fill triangle from triangle list */
65 __forceinline LBBox3fa fillMB(const PrimRefMB* prims, size_t& i, size_t end, Scene* scene, const BBox1f time_range)
66 {
67 const PrimRefMB& prim = prims[i]; i++;
68 const unsigned geomID = prim.geomID();
69 const unsigned primID = prim.primID();
70 new (this) Object(geomID, primID);
71 AccelSet* accel = (AccelSet*) scene->get(geomID);
72 return accel->linearBounds(primID,time_range);
73 }
74
75 /* Updates the primitive */
76 __forceinline BBox3fa update(AccelSet* mesh) {
77 return mesh->bounds(primID());
78 }
79
80 private:
81 unsigned int _geomID; //!< geometry ID
82 unsigned int _primID; //!< primitive ID
83 };
84}
85