| 107 | } |
| 108 | |
| 109 | void iSphereBoundVec(xSphere* o, const xSphere* s, const xVec3* v) |
| 110 | { |
| 111 | F32 scale; |
| 112 | xSphere temp; |
| 113 | xSphere* tp; |
| 114 | U32 usetemp; |
| 115 | xIsect isx; |
| 116 | |
| 117 | usetemp = (o == s); |
| 118 | |
| 119 | iSphereIsectVec(s, v, &isx); |
| 120 | |
| 121 | if (isx.penned <= 0.0f) |
| 122 | { |
| 123 | if (!usetemp) |
| 124 | { |
| 125 | memcpy(o, s, sizeof(xSphere)); |
| 126 | } |
| 127 | } |
| 128 | else |
| 129 | { |
| 130 | if (usetemp) |
| 131 | { |
| 132 | tp = &temp; |
| 133 | } |
| 134 | else |
| 135 | { |
| 136 | tp = o; |
| 137 | } |
| 138 | |
| 139 | xVec3Copy(&tp->center, &isx.norm); |
| 140 | |
| 141 | scale = (isx.dist - s->r) / (2.0f * isx.dist); |
| 142 | |
| 143 | xVec3SMul(&tp->center, &tp->center, scale); |
| 144 | xVec3Add(&tp->center, &tp->center, &s->center); |
| 145 | |
| 146 | tp->r = 0.5f * (isx.dist + s->r); |
| 147 | |
| 148 | if (usetemp) |
| 149 | { |
| 150 | memcpy(o, tp, sizeof(xSphere)); |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | void iCylinderIsectVec(const xCylinder* c, const xVec3* v, xIsect* isx) |
| 156 | { |
no test coverage detected