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

Function ClipFarEdge

renderer/HardwareClipper.cpp:85–123  ·  view source on GitHub ↗

Clips an edge against the far plane

Source from the content-addressed store, hash-verified

83
84// Clips an edge against the far plane
85g3Point *ClipFarEdge(g3Point *on_pnt, g3Point *off_pnt) {
86 float z_on = on_pnt->p3_z;
87 float z_off = off_pnt->p3_z;
88
89 float k = 1.0f - ((z_off - Far_clip_z) / (z_off - z_on));
90
91 g3Point *tmp = GetTempPoint();
92 tmp->p3_z = on_pnt->p3_z + ((off_pnt->p3_z - on_pnt->p3_z) * k);
93 tmp->p3_x = on_pnt->p3_x + ((off_pnt->p3_x - on_pnt->p3_x) * k);
94 tmp->p3_y = on_pnt->p3_y + ((off_pnt->p3_y - on_pnt->p3_y) * k);
95
96 if (on_pnt->p3_flags & PF_UV) {
97 tmp->p3_u = on_pnt->p3_u + ((off_pnt->p3_u - on_pnt->p3_u) * k);
98 tmp->p3_v = on_pnt->p3_v + ((off_pnt->p3_v - on_pnt->p3_v) * k);
99 tmp->p3_flags |= PF_UV;
100 }
101
102 if (on_pnt->p3_flags & PF_UV2) {
103 tmp->p3_u2 = on_pnt->p3_u2 + ((off_pnt->p3_u2 - on_pnt->p3_u2) * k);
104 tmp->p3_v2 = on_pnt->p3_v2 + ((off_pnt->p3_v2 - on_pnt->p3_v2) * k);
105 tmp->p3_flags |= PF_UV2;
106 }
107
108 if (on_pnt->p3_flags & PF_L) {
109 tmp->p3_l = on_pnt->p3_l + ((off_pnt->p3_l - on_pnt->p3_l) * k);
110 tmp->p3_flags |= PF_L;
111 }
112
113 if (on_pnt->p3_flags & PF_RGBA) {
114 tmp->p3_r = on_pnt->p3_r + ((off_pnt->p3_r - on_pnt->p3_r) * k);
115 tmp->p3_g = on_pnt->p3_g + ((off_pnt->p3_g - on_pnt->p3_g) * k);
116 tmp->p3_b = on_pnt->p3_b + ((off_pnt->p3_b - on_pnt->p3_b) * k);
117 tmp->p3_a = on_pnt->p3_a + ((off_pnt->p3_a - on_pnt->p3_a) * k);
118 tmp->p3_flags |= PF_RGBA;
119 }
120
121 g3_CodePoint(tmp);
122 return tmp;
123}
124
125// Clips an edge against the far plane
126g3Point *ClipCustomEdge(g3Point *on_pnt, g3Point *off_pnt) {

Callers 1

ClipEdgeFunction · 0.85

Calls 2

GetTempPointFunction · 0.85
g3_CodePointFunction · 0.85

Tested by

no test coverage detected