summaryrefslogtreecommitdiff
path: root/thirdparty/embree/kernels/common/accelinstance.h
blob: c63ef998bd278ed407e4261eff0f59d46c0734b9 (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
// Copyright 2009-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include "accel.h"
#include "builder.h"

namespace embree
{
  class AccelInstance : public Accel
  {
  public:
    AccelInstance (AccelData* accel, Builder* builder, Intersectors& intersectors)
      : Accel(AccelData::TY_ACCEL_INSTANCE,intersectors), accel(accel), builder(builder) {}

    void immutable () {
      builder.reset(nullptr);
    }

  public:
    void build () {
      if (builder) builder->build();
      bounds = accel->bounds;
    }

    void deleteGeometry(size_t geomID) {
      if (accel  ) accel->deleteGeometry(geomID);
      if (builder) builder->deleteGeometry(geomID);
    }
    
    void clear() {
      if (accel) accel->clear();
      if (builder) builder->clear();
    }

  private:
    std::unique_ptr<AccelData> accel;
    std::unique_ptr<Builder> builder;
  };
}