code a point. fills in the p3_codes field of the point, and returns the codes
| 23 | extern vector Clip_plane_point; |
| 24 | // code a point. fills in the p3_codes field of the point, and returns the codes |
| 25 | uint8_t g3_CodePoint(g3Point *p) { |
| 26 | uint8_t cc = 0; |
| 27 | |
| 28 | if (p->p3_x > p->p3_z) |
| 29 | cc |= CC_OFF_RIGHT; |
| 30 | |
| 31 | if (p->p3_y > p->p3_z) |
| 32 | cc |= CC_OFF_TOP; |
| 33 | |
| 34 | if (p->p3_x < -p->p3_z) |
| 35 | cc |= CC_OFF_LEFT; |
| 36 | |
| 37 | if (p->p3_y < -p->p3_z) |
| 38 | cc |= CC_OFF_BOT; |
| 39 | |
| 40 | if (p->p3_z < 0) |
| 41 | cc |= CC_BEHIND; |
| 42 | |
| 43 | if (p->p3_z > Far_clip_z) |
| 44 | cc |= CC_OFF_FAR; |
| 45 | |
| 46 | // Check to see if we should be clipped to the custom plane |
| 47 | if (Clip_custom) { |
| 48 | vector vec = p->p3_vec - Clip_plane_point; |
| 49 | vec.x /= Matrix_scale.x; |
| 50 | vec.y /= Matrix_scale.y; |
| 51 | vec.z /= Matrix_scale.z; |
| 52 | |
| 53 | float dp = vec * Clip_plane; |
| 54 | if (dp < -0.005f) { |
| 55 | cc |= CC_OFF_CUSTOM; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | return p->p3_codes = cc; |
| 60 | } |
| 61 | |
| 62 | // rotates a point. returns codes. does not check if already rotated |
| 63 | uint8_t g3_RotatePoint(g3Point *dest, vector *src) { |
no outgoing calls
no test coverage detected