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

Function device_init

tutorials/dynamic_scene/dynamic_scene_device.cpp:115–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113
114/* called by the C++ code for initialization */
115extern "C" void device_init (char* cfg)
116{
117 TutorialData_Constructor(&data);
118
119 /* create scene */
120 data.g_scene = g_scene = rtcNewScene(g_device);
121 rtcSetSceneFlags(data.g_scene,RTC_SCENE_FLAG_DYNAMIC | RTC_SCENE_FLAG_ROBUST);
122 rtcSetSceneBuildQuality(data.g_scene,RTC_BUILD_QUALITY_LOW);
123
124 /* create some triangulated spheres */
125 for (int i=0; i<data.numSpheres; i++)
126 {
127 const float phi = i*2.0f*float(pi)/data.numSpheres;
128 const float r = 2.0f*float(pi)/data.numSpheres;
129 const Vec3fa p = 2.0f*Vec3fa(sin(phi),0.0f,-cos(phi));
130 //RTCBuildQuality quality = i%3 == 0 ? RTC_BUILD_QUALITY_MEDIUM : i%3 == 1 ? RTC_BUILD_QUALITY_REFIT : RTC_BUILD_QUALITY_LOW;
131 RTCBuildQuality quality = i%2 ? RTC_BUILD_QUALITY_REFIT : RTC_BUILD_QUALITY_LOW;
132 //RTCBuildQuality quality = RTC_BUILD_QUALITY_REFIT;
133 int id = createSphere(quality,p,r);
134 data.position[id] = Vec3fa(p);
135 data.radius[id] = r;
136 data.colors[id].x = (i%16+1)/17.0f;
137 data.colors[id].y = (i%8+1)/9.0f;
138 data.colors[id].z = (i%4+1)/5.0f;
139 }
140
141 /* add ground plane to scene */
142 int id = addGroundPlane(data.g_scene);
143 data.colors[id] = Vec3fa(1.0f,1.0f,1.0f);
144
145 /* commit changes to scene */
146 rtcCommitScene (data.g_scene);
147}
148
149/* animates the sphere */
150void animateSphere (int taskIndex, int threadIndex, Vertex* vertices,

Callers

nothing calls this directly

Calls 10

rtcNewSceneFunction · 0.85
rtcSetSceneFlagsFunction · 0.85
rtcSetSceneBuildQualityFunction · 0.85
rtcCommitSceneFunction · 0.85
TutorialData_ConstructorFunction · 0.70
createSphereFunction · 0.70
addGroundPlaneFunction · 0.70
Vec3faClass · 0.50
sinFunction · 0.50
cosFunction · 0.50

Tested by

no test coverage detected