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

Method commit

kernels/common/scene_line_segments.cpp:190–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188 }
189
190 void LineSegments::commit()
191 {
192 /* verify that stride of all time steps are identical */
193 for (unsigned int t=0; t<numTimeSteps; t++) {
194 if (vertices[t].getStride() != vertices[0].getStride())
195 throw_RTCError(RTC_ERROR_INVALID_OPERATION,"stride of vertex buffers have to be identical for each time step");
196 vertices[t].buffer->commitIfNeeded();
197 }
198
199 for (auto& buffer : normals) {
200 if (buffer.getStride() != normals[0].getStride())
201 throw_RTCError(RTC_ERROR_INVALID_OPERATION,"stride of normal buffers have to be identical for each time step");
202 buffer.buffer->commitIfNeeded();
203 }
204
205 vertices0 = vertices[0];
206 if (getCurveType() == GTY_SUBTYPE_ORIENTED_CURVE)
207 normals0 = normals[0];
208
209 /* if no flags buffer is specified we manage and calculate the flags buffer */
210 if (!flags.buffer) flags.userData = 0; // to encode that we manage this buffer
211 bool recompute_flags_buffer = segments.isLocalModified();
212
213 /* resize flags buffer if number of primitives changed */
214 if (!flags.userData && (!flags.buffer || flags.size() != numPrimitives))
215 {
216 Ref<Buffer> buffer = new Buffer(device, numPrimitives*sizeof(char), nullptr, nullptr);
217 flags.set(buffer, 0, sizeof(char), numPrimitives, RTC_FORMAT_UCHAR);
218 recompute_flags_buffer = true;
219 }
220
221 /* recalculate the flags buffer if index buffer got modified */
222 if (!flags.userData && recompute_flags_buffer)
223 {
224 bool hasLeft = false;
225 for (size_t i=0; i<numPrimitives; i++) {
226 bool hasRight = (i==numPrimitives-1) ? false : segment(i+1) == segment(i)+1;
227 flags[i] = hasLeft * RTC_CURVE_FLAG_NEIGHBOR_LEFT;
228 flags[i] |= hasRight * RTC_CURVE_FLAG_NEIGHBOR_RIGHT;
229 hasLeft = hasRight;
230 }
231 flags.buffer->commit();
232 }
233
234 if (recompute_flags_buffer) {
235 segments.buffer->commit();
236 }
237 segments.clearLocalModified();
238
239 Geometry::commit();
240 }
241
242 void LineSegments::addElementsToCount (GeometryCounts & counts) const
243 {

Callers

nothing calls this directly

Calls 7

getCurveTypeFunction · 0.85
getStrideMethod · 0.80
commitIfNeededMethod · 0.80
isLocalModifiedMethod · 0.80
clearLocalModifiedMethod · 0.80
sizeMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected