MCPcopy Create free account
hub / github.com/LuxCoreRender/LuxCore / ExportMotionTriangleMesh

Method ExportMotionTriangleMesh

src/luxrays/accelerators/embreeaccel.cpp:75–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75void EmbreeAccel::ExportMotionTriangleMesh(const RTCScene embreeScene, const MotionTriangleMesh *mtm) const {
76 const MotionSystem &ms = mtm->GetMotionSystem();
77
78 // Check if I would need more than the max. number of steps (i.e. 129) supported by Embree
79 if (ms.times.size() > RTC_MAX_TIME_STEP_COUNT)
80 throw std::runtime_error("Embree accelerator supports up to " + ToString(RTC_MAX_TIME_STEP_COUNT) +
81 " motion blur steps, unable to use " + ToString(ms.times.size()));
82
83 const RTCGeometry geom = rtcNewGeometry(embreeDevice, RTC_GEOMETRY_TYPE_TRIANGLE);
84 rtcSetGeometryTimeStepCount(geom, ms.times.size());
85
86 for (u_int step = 0; step < ms.times.size(); ++step) {
87 // Copy the mesh start position vertices
88 Point *vertices = (Point *)rtcSetNewGeometryBuffer(geom, RTC_BUFFER_TYPE_VERTEX, step, RTC_FORMAT_FLOAT3,
89 sizeof(Point), mtm->GetTotalVertexCount());
90
91 for (u_int i = 0; i < mtm->GetTotalVertexCount(); ++i)
92 vertices[i] = mtm->GetVertex(ms.times[step], i);
93 }
94
95 // Share the mesh triangles
96 Triangle *meshTris = mtm->GetTriangles();
97 rtcSetSharedGeometryBuffer(geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT3, (RTCBuffer)meshTris,
98 0, sizeof(Triangle), mtm->GetTotalTriangleCount());
99
100 rtcCommitGeometry(geom);
101
102 rtcAttachGeometry(embreeScene, geom);
103
104 rtcReleaseGeometry(geom);
105
106}
107
108void EmbreeAccel::Init(const std::deque<const Mesh *> &meshes,
109 const u_longlong totalVertexCount,

Callers

nothing calls this directly

Calls 7

GetMotionSystemMethod · 0.80
GetVertexMethod · 0.80
GetTrianglesMethod · 0.80
ToStringFunction · 0.50
sizeMethod · 0.45
GetTotalVertexCountMethod · 0.45
GetTotalTriangleCountMethod · 0.45

Tested by

no test coverage detected