MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/PhysX / invoke

Method invoke

physx/source/physx/src/NpSceneQueries.cpp:381–564  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379 }
380
381 virtual PxAgain invoke(PxReal& aDist, const PrunerPayload& aPayload)
382 {
383 const PxU32 tempCount = 1;
384 HitType tempBuf[tempCount];
385
386 // PT: TODO: do we need actorShape.actor/actorShape.shape immediately?
387 local::ActorShape actorShape;
388 local::populate(aPayload, actorShape);
389
390 const PxQueryFlags filterFlags = mFilterData.flags;
391
392 // for no filter callback, default to eTOUCH for MULTIPLE, eBLOCK otherwise
393 // also always treat as eBLOCK if currently tested shape is cached
394 // Using eRESERVED flag as a special condition to default to eTOUCH hits while only looking for a single blocking hit
395 // from a nested query (see other comments containing #LABEL1)
396 PxQueryHitType::Enum shapeHitType =
397 ((mHitCall.maxNbTouches || (mFilterData.flags & PxQueryFlag::eRESERVED)) && !mIsCached)
398 ? PxQueryHitType::eTOUCH
399 : PxQueryHitType::eBLOCK;
400
401 // apply pre-filter
402 PxHitFlags filteredHitFlags = mHitFlags;
403 if(!mIsCached) // don't run filters on single item cache
404 if(!applyAllPreFiltersSQ(&actorShape, shapeHitType/*in&out*/, filterFlags, mFilterData, mFilterCall,
405 mBfd, filteredHitFlags/*, mHitCall.maxNbTouches*/))
406 return true; // skip this shape from reporting if prefilter said to do so
407 if(shapeHitType == PxQueryHitType::eNONE)
408 return true;
409
410 PX_ASSERT(actorShape.actor && actorShape.shape);
411 const Scb::Shape* shape = actorShape.scbShape;
412 const Scb::Actor* actor = actorShape.scbActor;
413
414 // compute the global pose for the cached shape and actor
415 PX_ALIGN(16, PxTransform) globalPose;
416 NpActor::getGlobalPose(globalPose, *shape, *actor);
417
418 const PxGeometry& shapeGeom = shape->getGeometry();
419
420 // Here we decide whether to use the user provided buffer in place or a local stack buffer
421 // see if we have more room left in the callback results buffer than in the parent stack buffer
422 // if so get subHits in-place in the hit buffer instead of the parent stack buffer
423 // nbTouches is the number of accumulated touch hits so far
424 // maxNbTouches is the size of the user buffer
425 PxU32 maxSubHits1 = mHitCall.maxNbTouches - mHitCall.nbTouches; // how much room is left in the user buffer
426 HitType* subHits1 = mHitCall.touches + mHitCall.nbTouches; // pointer to the first free hit in the user buffer
427 if(mHitCall.nbTouches >= mHitCall.maxNbTouches)
428 // if there's no room left in the user buffer, use a stack buffer
429 {
430 // tried using 64 here - causes check stack code to get generated on xbox, perhaps because of guard page
431 // need this buffer in case the input buffer is full but we still want to correctly merge results from later hits
432 maxSubHits1 = tempCount;
433 subHits1 = reinterpret_cast<HitType*>(tempBuf);
434 }
435
436 // limit number of hits to 1 for meshes if eMESH_MULTIPLE wasn't specified. this tells geomQuery to only look for a closest hit
437 if(shapeGeom.getType() == PxGeometryType::eTRIANGLEMESH && !(filteredHitFlags & PxHitFlag::eMESH_MULTIPLE))
438 maxSubHits1 = 1; // required to only receive 1 hit to pass UTs

Callers 1

multiQueryMethod · 0.45

Calls 10

populateFunction · 0.85
applyAllPreFiltersSQFunction · 0.85
getDirMethod · 0.80
getQueryFilterDataMethod · 0.80
isSetMethod · 0.80
errorMethod · 0.80
getGeometryMethod · 0.45
getTypeMethod · 0.45
postFilterMethod · 0.45
processTouchesMethod · 0.45

Tested by

no test coverage detected