/////////////////////////////////////////////////////////////////////////// Stuff for the pDomain.
| 32 | //////////////////////////////////////////////////////////////////////////////// |
| 33 | // Stuff for the pDomain. |
| 34 | pDomain::pDomain(PDomainEnum dtype, float a0, float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8) |
| 35 | { |
| 36 | type = dtype; |
| 37 | switch (type) |
| 38 | { |
| 39 | case PDPoint: p1 = pVector(a0, a1, a2); break; |
| 40 | case PDLine: { |
| 41 | p1 = pVector(a0, a1, a2); |
| 42 | pVector tmp(a3, a4, a5); |
| 43 | // p2 is vector3 from p1 to other endpoint. |
| 44 | p2 = tmp - p1; |
| 45 | } |
| 46 | break; |
| 47 | case PDBox: |
| 48 | // p1 is the min corner. p2 is the max corner. |
| 49 | if (a0 < a3) |
| 50 | { |
| 51 | p1.x = a0; |
| 52 | p2.x = a3; |
| 53 | } |
| 54 | else |
| 55 | { |
| 56 | p1.x = a3; |
| 57 | p2.x = a0; |
| 58 | } |
| 59 | if (a1 < a4) |
| 60 | { |
| 61 | p1.y = a1; |
| 62 | p2.y = a4; |
| 63 | } |
| 64 | else |
| 65 | { |
| 66 | p1.y = a4; |
| 67 | p2.y = a1; |
| 68 | } |
| 69 | if (a2 < a5) |
| 70 | { |
| 71 | p1.z = a2; |
| 72 | p2.z = a5; |
| 73 | } |
| 74 | else |
| 75 | { |
| 76 | p1.z = a5; |
| 77 | p2.z = a2; |
| 78 | } |
| 79 | break; |
| 80 | case PDTriangle: { |
| 81 | p1 = pVector(a0, a1, a2); |
| 82 | pVector tp2 = pVector(a3, a4, a5); |
| 83 | pVector tp3 = pVector(a6, a7, a8); |
| 84 | |
| 85 | u = tp2 - p1; |
| 86 | v = tp3 - p1; |
| 87 | |
| 88 | // The rest of this is needed for bouncing. |
| 89 | radius1Sqr = u.length(); |
| 90 | pVector tu = u / radius1Sqr; |
| 91 | radius2Sqr = v.length(); |