| 190 | |
| 191 | |
| 192 | void Forest::buildConvex( const Box3F &box, Convex *convex ) |
| 193 | { |
| 194 | mConvexList->collectGarbage(); |
| 195 | |
| 196 | // Get all ForestItem(s) within the box. |
| 197 | Vector<ForestItem> trees; |
| 198 | mData->getItems( box, &trees ); |
| 199 | if ( trees.empty() ) |
| 200 | return; |
| 201 | |
| 202 | for ( U32 i = 0; i < trees.size(); i++ ) |
| 203 | { |
| 204 | const ForestItem &forestItem = trees[i]; |
| 205 | |
| 206 | Box3F realBox = box; |
| 207 | mWorldToObj.mul( realBox ); |
| 208 | realBox.minExtents.convolveInverse( mObjScale ); |
| 209 | realBox.maxExtents.convolveInverse( mObjScale ); |
| 210 | |
| 211 | // JCF: is this really necessary if we already got this ForestItem |
| 212 | // as a result from getItems? |
| 213 | if ( realBox.isOverlapped( getObjBox() ) == false ) |
| 214 | continue; |
| 215 | |
| 216 | TSForestItemData *data = (TSForestItemData*)forestItem.getData(); |
| 217 | |
| 218 | // Find CollisionDetail(s) that are defined... |
| 219 | const Vector<S32> &details = data->getCollisionDetails(); |
| 220 | for ( U32 j = 0; j < details.size(); j++ ) |
| 221 | { |
| 222 | // JCFHACK: need to fix this if we want this to work with speedtree |
| 223 | // or other cases in which we don't have a TSForestItemData. |
| 224 | // Most likely via preventing this method and other torque collision |
| 225 | // specific stuff from ever getting called. |
| 226 | if ( details[j] == -1 ) |
| 227 | continue; |
| 228 | |
| 229 | // See if this convex exists in the working set already... |
| 230 | Convex* cc = 0; |
| 231 | CollisionWorkingList& wl = convex->getWorkingList(); |
| 232 | for ( CollisionWorkingList* itr = wl.wLink.mNext; itr != &wl; itr = itr->wLink.mNext ) |
| 233 | { |
| 234 | if ( itr->mConvex->getType() == ForestConvexType ) |
| 235 | { |
| 236 | ForestConvex *pConvex = static_cast<ForestConvex*>(itr->mConvex); |
| 237 | |
| 238 | if ( pConvex->mObject == this && |
| 239 | pConvex->mForestItemKey == forestItem.getKey() && |
| 240 | pConvex->hullId == j ) |
| 241 | { |
| 242 | cc = itr->mConvex; |
| 243 | break; |
| 244 | } |
| 245 | } |
| 246 | } |
| 247 | if (cc) |
| 248 | continue; |
| 249 |
nothing calls this directly
no test coverage detected