| 512 | } |
| 513 | |
| 514 | void NpBatchQuery::sweep( |
| 515 | const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance, PxU16 maxTouchHits, |
| 516 | PxHitFlags hitFlags, const PxQueryFilterData& fd, void* userData, const PxQueryCache* cache, const PxReal inflation) |
| 517 | { |
| 518 | PX_CHECK_AND_RETURN(pose.isValid(), "Batch sweep input check: pose is not valid."); |
| 519 | PX_CHECK_AND_RETURN(unitDir.isFinite(), "Batch sweep input check: unitDir is not valid."); |
| 520 | PX_CHECK_AND_RETURN(unitDir.isNormalized(), "Batch sweep input check: direction must be normalized"); |
| 521 | PX_CHECK_AND_RETURN(distance >= 0.0f, "Batch sweep input check: distance cannot be negative"); |
| 522 | PX_CHECK_AND_RETURN(distance != 0.0f || !(hitFlags & PxHitFlag::eASSUME_NO_INITIAL_OVERLAP), |
| 523 | "Batch sweep input check: zero-length sweep only valid without the PxHitFlag::eASSUME_NO_INITIAL_OVERLAP flag"); |
| 524 | |
| 525 | #if PX_CHECKED |
| 526 | if(!PxGeometryQuery::isValid(geometry)) |
| 527 | { |
| 528 | Ps::getFoundation().error(PxErrorCode::eINVALID_PARAMETER, __FILE__, __LINE__, "Provided geometry is not valid"); |
| 529 | return; |
| 530 | } |
| 531 | #endif // PX_CHECKED |
| 532 | |
| 533 | if (mNbSweeps >= mDesc.queryMemory.getMaxSweepsPerExecute()) |
| 534 | { |
| 535 | PX_CHECK_AND_RETURN(mNbSweeps < mDesc.queryMemory.getMaxSweepsPerExecute(), |
| 536 | "PxBatchQuery: number of sweep() calls exceeds PxBatchQueryMemory::sweepResultBufferSize, query discarded"); |
| 537 | return; |
| 538 | } |
| 539 | |
| 540 | |
| 541 | CHECK_RUNNING("PxBatchQuery::sweep: This batch is still executing, skipping query.") |
| 542 | mNbSweeps++; |
| 543 | |
| 544 | writeBatchHeader(BatchStreamHeader(hitFlags, cache, fd, userData, maxTouchHits, QTypeROS::eSWEEP)); |
| 545 | |
| 546 | //set the MTD flag |
| 547 | mHasMtdSweep |= !!(hitFlags & PxHitFlag::eMTD); |
| 548 | |
| 549 | if((hitFlags & PxHitFlag::ePRECISE_SWEEP) && (hitFlags & PxHitFlag::eMTD)) |
| 550 | { |
| 551 | Ps::getFoundation().error(PxErrorCode::eINVALID_PARAMETER, __FILE__, __LINE__, " Precise sweep doesn't support MTD. Perform MTD with default sweep"); |
| 552 | hitFlags &= ~PxHitFlag::ePRECISE_SWEEP; |
| 553 | } |
| 554 | |
| 555 | if((hitFlags & PxHitFlag::eASSUME_NO_INITIAL_OVERLAP) && (hitFlags & PxHitFlag::eMTD)) |
| 556 | { |
| 557 | Ps::getFoundation().error(PxErrorCode::eINVALID_PARAMETER, __FILE__, __LINE__, " eMTD cannot be used in conjunction with eASSUME_NO_INITIAL_OVERLAP. eASSUME_NO_INITIAL_OVERLAP will be ignored"); |
| 558 | hitFlags &= ~PxHitFlag::eASSUME_NO_INITIAL_OVERLAP; |
| 559 | } |
| 560 | |
| 561 | PxReal realInflation = inflation; |
| 562 | if((hitFlags & PxHitFlag::ePRECISE_SWEEP)&& inflation > 0.0f) |
| 563 | { |
| 564 | realInflation = 0.0f; |
| 565 | Ps::getFoundation().error(PxErrorCode::eINVALID_PARAMETER, __FILE__, __LINE__, " Precise sweep doesn't support inflation, inflation will be overwritten to be zero"); |
| 566 | } |
| 567 | |
| 568 | writeQueryInput(mStream, MultiQueryInput(&geometry, &pose, unitDir, distance, realInflation)); |
| 569 | |
| 570 | Ps::atomicExchange(&mBatchQueryIsRunning, 0); |
| 571 | } |
no test coverage detected