| 2206 | } |
| 2207 | |
| 2208 | bool b3ConvexHullInternal::shiftFace(Face* face, b3Scalar amount, b3AlignedObjectArray<Vertex*> stack) |
| 2209 | { |
| 2210 | b3Vector3 origShift = getBtNormal(face) * -amount; |
| 2211 | if (scaling[0] != 0) |
| 2212 | { |
| 2213 | origShift[0] /= scaling[0]; |
| 2214 | } |
| 2215 | if (scaling[1] != 0) |
| 2216 | { |
| 2217 | origShift[1] /= scaling[1]; |
| 2218 | } |
| 2219 | if (scaling[2] != 0) |
| 2220 | { |
| 2221 | origShift[2] /= scaling[2]; |
| 2222 | } |
| 2223 | Point32 shift((btInt32_t)origShift[medAxis], (btInt32_t)origShift[maxAxis], (btInt32_t)origShift[minAxis]); |
| 2224 | if (shift.isZero()) |
| 2225 | { |
| 2226 | return true; |
| 2227 | } |
| 2228 | Point64 normal = face->getNormal(); |
| 2229 | #ifdef DEBUG_CONVEX_HULL |
| 2230 | b3Printf("\nShrinking face (%d %d %d) (%d %d %d) (%d %d %d) by (%d %d %d)\n", |
| 2231 | face->origin.x, face->origin.y, face->origin.z, face->dir0.x, face->dir0.y, face->dir0.z, face->dir1.x, face->dir1.y, face->dir1.z, shift.x, shift.y, shift.z); |
| 2232 | #endif |
| 2233 | btInt64_t origDot = face->origin.dot(normal); |
| 2234 | Point32 shiftedOrigin = face->origin + shift; |
| 2235 | btInt64_t shiftedDot = shiftedOrigin.dot(normal); |
| 2236 | b3Assert(shiftedDot <= origDot); |
| 2237 | if (shiftedDot >= origDot) |
| 2238 | { |
| 2239 | return false; |
| 2240 | } |
| 2241 | |
| 2242 | Edge* intersection = NULL; |
| 2243 | |
| 2244 | Edge* startEdge = face->nearbyVertex->edges; |
| 2245 | #ifdef DEBUG_CONVEX_HULL |
| 2246 | b3Printf("Start edge is "); |
| 2247 | startEdge->print(); |
| 2248 | b3Printf(", normal is (%lld %lld %lld), shifted dot is %lld\n", normal.x, normal.y, normal.z, shiftedDot); |
| 2249 | #endif |
| 2250 | Rational128 optDot = face->nearbyVertex->dot(normal); |
| 2251 | int cmp = optDot.compare(shiftedDot); |
| 2252 | #ifdef SHOW_ITERATIONS |
| 2253 | int n = 0; |
| 2254 | #endif |
| 2255 | if (cmp >= 0) |
| 2256 | { |
| 2257 | Edge* e = startEdge; |
| 2258 | do |
| 2259 | { |
| 2260 | #ifdef SHOW_ITERATIONS |
| 2261 | n++; |
| 2262 | #endif |
| 2263 | Rational128 dot = e->target->dot(normal); |
| 2264 | b3Assert(dot.compare(origDot) <= 0); |
| 2265 | #ifdef DEBUG_CONVEX_HULL |
nothing calls this directly
no test coverage detected