OWL
Loading...
Searching...
No Matches
Triangles.h
1// ======================================================================== //
2// Copyright 2019-2021 Ingo Wald //
3// //
4// Licensed under the Apache License, Version 2.0 (the "License"); //
5// you may not use this file except in compliance with the License. //
6// You may obtain a copy of the License at //
7// //
8// http://www.apache.org/licenses/LICENSE-2.0 //
9// //
10// Unless required by applicable law or agreed to in writing, software //
11// distributed under the License is distributed on an "AS IS" BASIS, //
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
13// See the License for the specific language governing permissions and //
14// limitations under the License. //
15// ======================================================================== //
16
17#pragma once
18
19#include "Geometry.h"
20
21namespace owl {
22
26 struct TrianglesGeomType : public GeomType {
27 typedef std::shared_ptr<TrianglesGeomType> SP;
28
29 TrianglesGeomType(Context *const context,
30 size_t varStructSize,
31 const std::vector<OWLVarDecl> &varDecls);
32
34 std::string toString() const override { return "TriangleGeomType"; }
35
36 std::shared_ptr<Geom> createGeom() override;
37 };
38
44 struct TrianglesGeom : public Geom {
45
46 typedef std::shared_ptr<TrianglesGeom> SP;
47
50 struct DeviceData : public Geom::DeviceData {
51 DeviceData(const DeviceContext::SP &device);
52
56 std::vector<CUdeviceptr> vertexPointers;
57
61 CUdeviceptr indexPointer = (CUdeviceptr)0;
62 };
63
66 TrianglesGeom(Context *const context,
67 GeomType::SP geometryType);
68
70 RegisteredObject::DeviceData::SP createOn(const DeviceContext::SP &device) override;
74 inline DeviceData &getDD(const DeviceContext::SP &device) const;
75
78 void setVertices(const std::vector<Buffer::SP> &vertices,
80 size_t count,
81 size_t stride,
82 size_t offset);
83
85 void setIndices(Buffer::SP indices,
86 size_t count,
87 size_t stride,
88 size_t offset);
89
91 void computeBounds(box3f bounds[2]);
92
94 std::string toString() const override;
95
96 struct {
97 size_t count = 0;
98 size_t stride = 0;
99 size_t offset = 0;
100 Buffer::SP buffer;
101 } index;
102 struct {
103 size_t count = 0;
104 size_t stride = 0;
105 size_t offset = 0;
106 std::vector<Buffer::SP> buffers;
107 } vertex;
108 };
109
110 // ------------------------------------------------------------------
111 // implementation section
112 // ------------------------------------------------------------------
113
115 inline TrianglesGeom::DeviceData &TrianglesGeom::getDD(const DeviceContext::SP &device) const
116 {
117 assert(device->ID < (int)deviceData.size());
118 return deviceData[device->ID]->as<TrianglesGeom::DeviceData>();
119 }
120
121} // ::owl
Definition: Context.h:32
Definition: Geometry.h:41
Definition: Geometry.h:108
Definition: Object.h:36
DeviceContext::SP device
Definition: Object.h:53
std::vector< DeviceData::SP > deviceData
Definition: Object.h:86
const std::vector< OWLVarDecl > varDecls
Definition: SBTObject.h:70
const size_t varStructSize
Definition: SBTObject.h:66
Definition: Triangles.h:26
std::shared_ptr< Geom > createGeom() override
std::string toString() const override
Definition: Triangles.h:34
Definition: Triangles.h:50
std::vector< CUdeviceptr > vertexPointers
Definition: Triangles.h:56
CUdeviceptr indexPointer
Definition: Triangles.h:61
Definition: Triangles.h:44
DeviceData & getDD(const DeviceContext::SP &device) const
Definition: Triangles.h:115
std::string toString() const override
void setVertices(const std::vector< Buffer::SP > &vertices, size_t count, size_t stride, size_t offset)
void setIndices(Buffer::SP indices, size_t count, size_t stride, size_t offset)
TrianglesGeom(Context *const context, GeomType::SP geometryType)
RegisteredObject::DeviceData::SP createOn(const DeviceContext::SP &device) override
void computeBounds(box3f bounds[2])