| 2094 | } |
| 2095 | |
| 2096 | bool MeshRoad::castRay( const Point3F &s, const Point3F &e, RayInfo *info ) |
| 2097 | { |
| 2098 | Point3F start = s; |
| 2099 | Point3F end = e; |
| 2100 | mObjToWorld.mulP(start); |
| 2101 | mObjToWorld.mulP(end); |
| 2102 | |
| 2103 | F32 out = 1.0f; // The output fraction/percentage along the line defined by s and e |
| 2104 | VectorF norm(0.0f, 0.0f, 0.0f); // The normal of the face intersected |
| 2105 | |
| 2106 | Vector<MeshRoadHitSegment> hitSegments; |
| 2107 | |
| 2108 | for ( U32 i = 0; i < mSegments.size(); i++ ) |
| 2109 | { |
| 2110 | const MeshRoadSegment &segment = mSegments[i]; |
| 2111 | |
| 2112 | F32 t; |
| 2113 | VectorF n; |
| 2114 | |
| 2115 | if ( segment.getWorldBounds().collideLine( start, end, &t, &n ) ) |
| 2116 | { |
| 2117 | hitSegments.increment(); |
| 2118 | hitSegments.last().t = t; |
| 2119 | hitSegments.last().idx = i; |
| 2120 | } |
| 2121 | } |
| 2122 | |
| 2123 | dQsort( hitSegments.address(), hitSegments.size(), sizeof(MeshRoadHitSegment), compareHitSegments ); |
| 2124 | |
| 2125 | U32 idx0, idx1, idx2; |
| 2126 | F32 t; |
| 2127 | |
| 2128 | for ( U32 i = 0; i < hitSegments.size(); i++ ) |
| 2129 | { |
| 2130 | U32 segIdx = hitSegments[i].idx; |
| 2131 | const MeshRoadSegment &segment = mSegments[segIdx]; |
| 2132 | |
| 2133 | U32 numConvexes ; |
| 2134 | U32 halfConvexes; |
| 2135 | U32 nextSegOffset = 2*mSideProfile.mNodes.size(); |
| 2136 | U32 leftSideOffset = nextSegOffset/2; |
| 2137 | U32 k2, capIdx1, capIdx2, capIdx3; |
| 2138 | |
| 2139 | // Each segment has 6 faces |
| 2140 | for ( U32 j = 0; j < 6; j++ ) |
| 2141 | { |
| 2142 | if ( j == 4 && segIdx != 0 ) |
| 2143 | continue; |
| 2144 | |
| 2145 | if ( j == 5 && segIdx != mSegments.size() - 1 ) |
| 2146 | continue; |
| 2147 | |
| 2148 | // The top and bottom sides have 2 convex(s) |
| 2149 | // The left, right, front, and back sides depend on the user-defined profile |
| 2150 | switch(j) |
| 2151 | { |
| 2152 | case 0: numConvexes = 2; break; // Top |
| 2153 | case 1: // Left |
nothing calls this directly
no test coverage detected