(A, B, C)
| 2196 | |
| 2197 | |
| 2198 | def depth(A, B, C): |
| 2199 | # Sorting by y, from lowest to highest in value but from top to bottom in what u see |
| 2200 | if A[9] > B[9]: |
| 2201 | A, B = B, A |
| 2202 | if B[9] > C[9]: |
| 2203 | B, C = C, B |
| 2204 | if A[9] > B[9]: |
| 2205 | A, B = B, A |
| 2206 | # Remove some of those out of screen |
| 2207 | if (A[9] >= cam.height or |
| 2208 | C[9] < 0 or |
| 2209 | A[9] == C[9] or |
| 2210 | A[8] < 0 and B[8] < 0 and C[8] < 0 or |
| 2211 | A[8] >= cam.width and B[8] >= cam.width and C[8] >= cam.width): |
| 2212 | return |
| 2213 | |
| 2214 | # Perspective correction |
| 2215 | A[2] = 1 / A[2] |
| 2216 | B[2] = 1 / B[2] |
| 2217 | C[2] = 1 / C[2] |
| 2218 | |
| 2219 | if A[9] == B[9]: |
| 2220 | if A[8] > B[8]: |
| 2221 | A, B = B, A |
| 2222 | if A[9] >= 0: |
| 2223 | if A[8] <= 0: |
| 2224 | x_start = 0 |
| 2225 | else: |
| 2226 | x_start = A[8] |
| 2227 | if B[8] >= cam.width - 1: |
| 2228 | x_end = cam.width - 1 |
| 2229 | else: |
| 2230 | x_end = B[8] |
| 2231 | |
| 2232 | for x in range(x_start, x_end): |
| 2233 | p1 = (x - A[8]) / (B[8] - A[8]) |
| 2234 | p2 = 1 - p1 |
| 2235 | z3d = 1 / (p2 * A[2] + p1 * B[2]) |
| 2236 | if z3d < depth_buffer[A[9]][x]: |
| 2237 | depth_buffer[A[9]][x] = z3d |
| 2238 | frame[A[9]][x] = (int(255 * (cam.z_far - z3d) // (cam.z_far - cam.z_near)),) * 3 |
| 2239 | |
| 2240 | tAC = (A[8] - C[8]) / (A[9] - C[9]) |
| 2241 | bAC = A[8] - A[9] * tAC |
| 2242 | tBC = (B[8] - C[8]) / (B[9] - C[9]) |
| 2243 | bBC = B[8] - B[9] * tBC |
| 2244 | |
| 2245 | if B[9] <= 0: |
| 2246 | y_start = 0 |
| 2247 | else: |
| 2248 | y_start = B[9] |
| 2249 | if C[9] >= cam.height - 1: |
| 2250 | y_end = cam.height - 1 |
| 2251 | else: |
| 2252 | y_end = C[9] |
| 2253 | for y in range(y_start, y_end): |
| 2254 | m1 = (y - A[9]) / (C[9] - A[9]) |
| 2255 | m2 = 1 - m1 |
no outgoing calls
no test coverage detected