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

Function SetSurfaceView

editor/rad_hemicube.cpp:309–335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

307}
308
309void SetSurfaceView(rad_surface *surf) {
310 vector rv; // Random vector
311 vector u, v, n;
312
313 // Select random vector for hemicube orientation
314 rv.x = ((rand() / RAND_MAX) * 2.0 - 1.0);
315 rv.y = ((rand() / RAND_MAX) * 2.0 - 1.0);
316 rv.z = ((rand() / RAND_MAX) * 2.0 - 1.0);
317
318 n = rad_MaxSurface->normal; // Get patch normal
319
320 do // Get valid u-axis vector
321 {
322 vm_CrossProduct(&u, &n, &rv);
323 } while (vm_GetMagnitude(&u) < .0001);
324
325 vm_NormalizeVector(&u);
326 vm_CrossProduct(&v, &u, &n); // Determine v-axis
327
328 rad_Hemicube.head_matrix.rvec = u;
329 rad_Hemicube.head_matrix.uvec = v;
330 rad_Hemicube.head_matrix.fvec = n;
331
332 vm_VectorToMatrix(&rad_Hemicube.head_matrix, &n, NULL, NULL);
333
334 rad_Hemicube.shooting_surface = surf;
335}
336
337// Build transformation matrix for our hemicube
338void BuildTransform(vector *nu, vector *nv, vector *nn) {

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