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

Function createInstance

tutorials/user_geometry/user_geometry_device.cpp:206–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204}
205
206Instance* createInstance (RTCScene scene, RTCScene object, int geomID, const Vec3fa& lower, const Vec3fa& upper)
207{
208#if !ENABLE_NATIVE_INSTANCING
209 Instance* instance = (Instance*) alignedUSMMalloc(sizeof(Instance),16);
210 instance->type = USER_GEOMETRY_INSTANCE;
211 instance->object = rtcGetSceneTraversable(object);
212 instance->lower = lower;
213 instance->upper = upper;
214 instance->local2world.l.vx = Vec3fa(1,0,0);
215 instance->local2world.l.vy = Vec3fa(0,1,0);
216 instance->local2world.l.vz = Vec3fa(0,0,1);
217 instance->local2world.p = Vec3fa(0,0,0);
218 instance->geometry = rtcNewGeometry(g_device, RTC_GEOMETRY_TYPE_USER);
219 rtcSetGeometryUserPrimitiveCount(instance->geometry,1);
220 rtcSetGeometryUserData(instance->geometry,instance);
221 rtcSetGeometryBoundsFunction(instance->geometry,instanceBoundsFunc,nullptr);
222 rtcSetGeometryIntersectFunction(instance->geometry,instanceIntersectFuncPtr);
223 rtcSetGeometryOccludedFunction (instance->geometry,instanceOccludedFuncPtr);
224 rtcCommitGeometry(instance->geometry);
225 rtcAttachGeometry(scene,instance->geometry);
226 rtcReleaseGeometry(instance->geometry);
227 return instance;
228#else
229 Instance* instance = (Instance*) alignedUSMMalloc(sizeof(Instance),16);
230 instance->type = USER_GEOMETRY_INSTANCE;
231 instance->geometry = rtcNewGeometry (g_device, RTC_GEOMETRY_TYPE_INSTANCE);
232 rtcSetGeometryInstancedScene(instance->geometry,object);
233 rtcSetGeometryTimeStepCount(instance->geometry,1);
234 rtcCommitGeometry(instance->geometry);
235 rtcAttachGeometryByID(scene,instance->geometry,geomID);
236 rtcReleaseGeometry(instance->geometry);
237 return instance;
238#endif
239}
240
241void updateInstance (RTCScene scene, Instance* instance)
242{

Callers 1

device_initFunction · 0.70

Calls 13

alignedUSMMallocFunction · 0.85
rtcSetGeometryUserDataFunction · 0.85
rtcCommitGeometryFunction · 0.85
rtcAttachGeometryFunction · 0.85
rtcReleaseGeometryFunction · 0.85
rtcAttachGeometryByIDFunction · 0.85

Tested by

no test coverage detected