| 6002 | //---------------------------------------------------------------------------- |
| 6003 | |
| 6004 | bool Player::castRay(const Point3F &start, const Point3F &end, RayInfo* info) |
| 6005 | { |
| 6006 | // In standard Torque there's a rather brute force culling of all |
| 6007 | // non-enabled players (corpses) from the ray cast. But, to |
| 6008 | // demonstrate a resurrection spell, we need corpses to be |
| 6009 | // selectable, so this code change allows consideration of corpses |
| 6010 | // in the ray cast if corpsesHiddenFromRayCast is set to false. |
| 6011 | if (sCorpsesHiddenFromRayCast && getDamageState() != Enabled) |
| 6012 | return false; |
| 6013 | |
| 6014 | // Collide against bounding box. Need at least this for the editor. |
| 6015 | F32 st,et,fst = 0.0f,fet = 1.0f; |
| 6016 | F32 *bmin = &mObjBox.minExtents.x; |
| 6017 | F32 *bmax = &mObjBox.maxExtents.x; |
| 6018 | F32 const *si = &start.x; |
| 6019 | F32 const *ei = &end.x; |
| 6020 | |
| 6021 | for (S32 i = 0; i < 3; i++) { |
| 6022 | if (*si < *ei) { |
| 6023 | if (*si > *bmax || *ei < *bmin) |
| 6024 | return false; |
| 6025 | F32 di = *ei - *si; |
| 6026 | st = (*si < *bmin)? (*bmin - *si) / di: 0.0f; |
| 6027 | et = (*ei > *bmax)? (*bmax - *si) / di: 1.0f; |
| 6028 | } |
| 6029 | else { |
| 6030 | if (*ei > *bmax || *si < *bmin) |
| 6031 | return false; |
| 6032 | F32 di = *ei - *si; |
| 6033 | st = (*si > *bmax)? (*bmax - *si) / di: 0.0f; |
| 6034 | et = (*ei < *bmin)? (*bmin - *si) / di: 1.0f; |
| 6035 | } |
| 6036 | if (st > fst) fst = st; |
| 6037 | if (et < fet) fet = et; |
| 6038 | if (fet < fst) |
| 6039 | return false; |
| 6040 | bmin++; bmax++; |
| 6041 | si++; ei++; |
| 6042 | } |
| 6043 | |
| 6044 | info->normal = start - end; |
| 6045 | info->normal.normalizeSafe(); |
| 6046 | getTransform().mulV( info->normal ); |
| 6047 | |
| 6048 | info->t = fst; |
| 6049 | info->object = this; |
| 6050 | info->point.interpolate(start,end,fst); |
| 6051 | info->material = 0; |
| 6052 | return true; |
| 6053 | } |
| 6054 | |
| 6055 | |
| 6056 | //---------------------------------------------------------------------------- |
no test coverage detected