MCPcopy Create free account
hub / github.com/assaultcube/AC / genclipmatrix

Function genclipmatrix

source/src/rendergl.cpp:612–627  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

610glmatrixf clipmatrix;
611
612void genclipmatrix(float a, float b, float c, float d)
613{
614 // transform the clip plane into camera space
615 float clip[4];
616 loopi(4) clip[i] = a*invmvmatrix[i*4 + 0] + b*invmvmatrix[i*4 + 1] + c*invmvmatrix[i*4 + 2] + d*invmvmatrix[i*4 + 3];
617
618 float x = ((clip[0]<0 ? -1 : (clip[0]>0 ? 1 : 0)) + projmatrix[8]) / projmatrix[0],
619 y = ((clip[1]<0 ? -1 : (clip[1]>0 ? 1 : 0)) + projmatrix[9]) / projmatrix[5],
620 w = (1 + projmatrix[10]) / projmatrix[14],
621 scale = 2 / (x*clip[0] + y*clip[1] - clip[2] + w*clip[3]);
622 clipmatrix = projmatrix;
623 clipmatrix[2] = clip[0]*scale;
624 clipmatrix[6] = clip[1]*scale;
625 clipmatrix[10] = clip[2]*scale + 1.0f;
626 clipmatrix[14] = clip[3]*scale;
627}
628
629bool reflecting = false, refracting = false;
630GLuint reflecttex = 0, refracttex = 0;

Callers 1

drawreflectionFunction · 0.85

Calls 1

loopiFunction · 0.70

Tested by

no test coverage detected