MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / SetElementView

Function SetElementView

editor/rad_hemicube.cpp:281–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279}
280
281void SetElementView(rad_element *ep) {
282 vector rv; // Random vector
283 vector u, v, n;
284
285 // Select random vector for hemicube orientation
286 rv.x = ((rand() / RAND_MAX) * 2.0 - 1.0);
287 rv.y = ((rand() / RAND_MAX) * 2.0 - 1.0);
288 rv.z = ((rand() / RAND_MAX) * 2.0 - 1.0);
289
290 n = rad_MaxSurface->normal; // Get patch normal
291
292 do // Get valid u-axis vector
293 {
294 vm_CrossProduct(&u, &n, &rv);
295 } while (vm_GetMagnitude(&u) < .0001);
296
297 vm_NormalizeVector(&u);
298 vm_CrossProduct(&v, &u, &n); // Determine v-axis
299
300 rad_Hemicube.head_matrix.rvec = u;
301 rad_Hemicube.head_matrix.uvec = v;
302 rad_Hemicube.head_matrix.fvec = n;
303
304 vm_VectorToMatrix(&rad_Hemicube.head_matrix, &n, NULL, NULL);
305
306 rad_Hemicube.shooting_element = ep;
307}
308
309void SetSurfaceView(rad_surface *surf) {
310 vector rv; // Random vector

Callers 1

Calls 4

vm_NormalizeVectorFunction · 0.85
vm_CrossProductFunction · 0.50
vm_GetMagnitudeFunction · 0.50
vm_VectorToMatrixFunction · 0.50

Tested by

no test coverage detected