MCPcopy Create free account
hub / github.com/RenderKit/embree / addInstances

Function addInstances

tutorials/multi_instanced_geometry/scene.cpp:140–167  ·  view source on GitHub ↗

* Add instances to a scene. * This function also writes normal transforms to the given map. */

Source from the content-addressed store, hash-verified

138 * This function also writes normal transforms to the given map.
139 */
140void addInstances(RTCDevice device,
141 RTCScene scene,
142 RTCScene exemplar,
143 const Instances& instances,
144 LinearSpace3fa* normalTransforms)
145{
146 for (unsigned int i = 0; i < instances.numInstances; ++i)
147 {
148 const unsigned int idx = 3*i;
149 auto M = buildMatrix(instances.localX + idx,
150 instances.localY + idx,
151 instances.localZ + idx,
152 instances.position + idx);
153
154 RTCGeometry geom = rtcNewGeometry(device, RTC_GEOMETRY_TYPE_INSTANCE);
155 rtcSetGeometryInstancedScene(geom, exemplar);
156 rtcSetGeometryTimeStepCount(geom, 1);
157 rtcSetGeometryTransform(geom,
158 0,
159 RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR,
160 reinterpret_cast<float*>(&M));
161 rtcCommitGeometry(geom);
162
163 rtcAttachGeometryByID(scene, geom, i);
164 rtcReleaseGeometry(geom);
165 normalTransforms[i] = transposed(rcp(M.l));
166 }
167}
168
169/*
170 * Initialize the main scene. Note that we store complex geometry in

Callers 1

initializeSceneFunction · 0.85

Calls 9

buildMatrixFunction · 0.85
rtcSetGeometryTransformFunction · 0.85
rtcCommitGeometryFunction · 0.85
rtcAttachGeometryByIDFunction · 0.85
rtcReleaseGeometryFunction · 0.85
transposedFunction · 0.85
rcpFunction · 0.50

Tested by

no test coverage detected