diff options
| author | sschirm <[email protected]> | 2016-12-23 14:20:36 +0100 |
|---|---|---|
| committer | sschirm <[email protected]> | 2016-12-23 14:56:17 +0100 |
| commit | ef6937e69e8ee3f409cf9d460d5ad300a65d5924 (patch) | |
| tree | 710426e8daa605551ce3f34b581897011101c30f /PhysX_3.4/Source/PhysXCharacterKinematic | |
| parent | Initial commit: (diff) | |
| download | physx-3.4-ef6937e69e8ee3f409cf9d460d5ad300a65d5924.tar.xz physx-3.4-ef6937e69e8ee3f409cf9d460d5ad300a65d5924.zip | |
PhysX 3.4 / APEX 1.4 release candidate @21506124
Diffstat (limited to 'PhysX_3.4/Source/PhysXCharacterKinematic')
4 files changed, 80 insertions, 56 deletions
diff --git a/PhysX_3.4/Source/PhysXCharacterKinematic/src/CctCharacterController.cpp b/PhysX_3.4/Source/PhysXCharacterKinematic/src/CctCharacterController.cpp index 00a49316..292eaee0 100644 --- a/PhysX_3.4/Source/PhysXCharacterKinematic/src/CctCharacterController.cpp +++ b/PhysX_3.4/Source/PhysXCharacterKinematic/src/CctCharacterController.cpp @@ -27,6 +27,7 @@ // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. +#include "foundation/PxProfiler.h" #include "CctCharacterController.h" #include "CctCharacterControllerManager.h" #include "CctSweptBox.h" @@ -56,6 +57,7 @@ using namespace physx; using namespace Cct; using namespace Gu; +using namespace Cm; static const PxU32 gObstacleDebugColor = PxU32(PxDebugColor::eARGB_CYAN); //static const PxU32 gCCTBoxDebugColor = PxU32(PxDebugColor::eARGB_YELLOW); @@ -1140,7 +1142,7 @@ void SweepTest::findTouchedObstacles(const UserObstacles& userObstacles, const P if(!Gu::intersectOBBAABB(obb, singlePrecisionWorldBox)) continue; - TouchedUserBox* UserBox = reinterpret_cast<TouchedUserBox*>(reserve(mGeomStream, sizeof(TouchedUserBox)/sizeof(PxU32))); + TouchedUserBox* UserBox = reinterpret_cast<TouchedUserBox*>(reserveContainerMemory(mGeomStream, sizeof(TouchedUserBox)/sizeof(PxU32))); UserBox->mType = TouchedGeomType::eUSER_BOX; UserBox->mTGUserData = boxUserData[i]; UserBox->mActor = NULL; @@ -1181,7 +1183,7 @@ void SweepTest::findTouchedObstacles(const UserObstacles& userObstacles, const P if(d2>r*r) continue; - TouchedUserCapsule* UserCapsule = reinterpret_cast<TouchedUserCapsule*>(reserve(mGeomStream, sizeof(TouchedUserCapsule)/sizeof(PxU32))); + TouchedUserCapsule* UserCapsule = reinterpret_cast<TouchedUserCapsule*>(reserveContainerMemory(mGeomStream, sizeof(TouchedUserCapsule)/sizeof(PxU32))); UserCapsule->mType = TouchedGeomType::eUSER_CAPSULE; UserCapsule->mTGUserData = capsuleUserData[i]; UserCapsule->mActor = NULL; @@ -1319,12 +1321,12 @@ void SweepTest::updateTouchedGeoms( const InternalCBData_FindTouchedGeom* userDa if(mRenderBuffer) { // PT: worldTemporalBox = temporal BV for this frame - Cm::RenderOutput out(*mRenderBuffer); + RenderOutput out(*mRenderBuffer); if(mRenderFlags & PxControllerDebugRenderFlag::eTEMPORAL_BV) { out << gTBVDebugColor; - out << Cm::DebugBox(getBounds3(worldTemporalBox)); + out << DebugBox(getBounds3(worldTemporalBox)); } if(mRenderFlags & PxControllerDebugRenderFlag::eCACHED_BV) @@ -1333,7 +1335,7 @@ void SweepTest::updateTouchedGeoms( const InternalCBData_FindTouchedGeom* userDa out << PxU32(PxDebugColor::eARGB_RED); else out << PxU32(PxDebugColor::eARGB_GREEN); - out << Cm::DebugBox(getBounds3(mCacheBounds)); + out << DebugBox(getBounds3(mCacheBounds)); } } } @@ -1345,13 +1347,16 @@ bool SweepTest::doSweepTest(const InternalCBData_FindTouchedGeom* userData, SweptVolume& swept_volume, const PxVec3& direction, const PxVec3& sideVector, PxU32 max_iter, PxU32* nb_collisions, float min_dist, const PxControllerFilters& filters, SweepPass sweepPass, - const PxRigidActor*& touchedActorOut, const PxShape*& touchedShapeOut) + const PxRigidActor*& touchedActorOut, const PxShape*& touchedShapeOut, PxU64 contextID) { // Early exit when motion is zero. Since the motion is decomposed into several vectors // and this function is called for each of them, it actually happens quite often. if(direction.isZero()) return false; + PX_PROFILE_ZONE("CharacterController.doSweepTest", contextID); + PX_UNUSED(contextID); + bool hasMoved = false; mFlags &= ~(STF_VALIDATE_TRIANGLE_DOWN|STF_TOUCH_OTHER_CCT|STF_TOUCH_OBSTACLE); touchedShapeOut = NULL; @@ -1640,9 +1645,12 @@ PxControllerCollisionFlags SweepTest::moveCharacter( bool constrainedClimbingMode, bool standingOnMoving, const PxRigidActor*& touchedActor, - const PxShape*& touchedShape - ) + const PxShape*& touchedShape, + PxU64 contextID) { + PX_PROFILE_ZONE("CharacterController.moveCharacter", contextID); + PX_UNUSED(contextID); + bool standingOnMovingUp = standingOnMoving; mFlags &= ~STF_HIT_NON_WALKABLE; @@ -1766,7 +1774,7 @@ PxControllerCollisionFlags SweepTest::moveCharacter( if(!(mFlags & STF_WALK_EXPERIMENT)) { // ### maxIter here seems to "solve" the V bug - if(doSweepTest(userData, userHitData, userObstacles, volume, UpVector, SideVector, maxIterUp, &NbCollisions, min_dist, filters, SWEEP_PASS_UP, touchedActor, touchedShape)) + if(doSweepTest(userData, userHitData, userObstacles, volume, UpVector, SideVector, maxIterUp, &NbCollisions, min_dist, filters, SWEEP_PASS_UP, touchedActor, touchedShape, contextID)) { if(NbCollisions) { @@ -1795,7 +1803,7 @@ PxControllerCollisionFlags SweepTest::moveCharacter( { NbCollisions=0; //printf("BS:%.2f %.2f %.2f NS=%d\n", volume.mCenter.x, volume.mCenter.y, volume.mCenter.z, mNbCachedStatic); - if(doSweepTest(userData, userHitData, userObstacles, volume, SideVector, SideVector, maxIterSides, &NbCollisions, min_dist, filters, SWEEP_PASS_SIDE, touchedActor, touchedShape)) + if(doSweepTest(userData, userHitData, userObstacles, volume, SideVector, SideVector, maxIterSides, &NbCollisions, min_dist, filters, SWEEP_PASS_SIDE, touchedActor, touchedShape, contextID)) { if(NbCollisions) CollisionFlags |= PxControllerCollisionFlag::eCOLLISION_SIDES; @@ -1815,7 +1823,7 @@ PxControllerCollisionFlags SweepTest::moveCharacter( NbCollisions=0; //printf("BS:%.2f %.2f %.2f NS=%d\n", volume.mCenter.x, volume.mCenter.y, volume.mCenter.z, mNbCachedStatic); const PxExtendedVec3 saved = volume.mCenter; - doSweepTest(userData, userHitData, userObstacles, volume, sensor, SideVector, 1, &NbCollisions, min_dist, filters, SWEEP_PASS_SENSOR, touchedActor, touchedShape); + doSweepTest(userData, userHitData, userObstacles, volume, sensor, SideVector, 1, &NbCollisions, min_dist, filters, SWEEP_PASS_SENSOR, touchedActor, touchedShape, contextID); volume.mCenter = saved; } } @@ -1842,7 +1850,7 @@ PxControllerCollisionFlags SweepTest::moveCharacter( // min_dist actually makes a big difference :( // AAARRRGGH: if we get culled because of min_dist here, mValidateTriangle never becomes valid! - if(doSweepTest(userData, userHitData, userObstacles, volume, DownVector, SideVector, maxIterDown, &NbCollisions, min_dist, filters, SWEEP_PASS_DOWN, touchedActor, touchedShape)) + if(doSweepTest(userData, userHitData, userObstacles, volume, DownVector, SideVector, maxIterDown, &NbCollisions, min_dist, filters, SWEEP_PASS_DOWN, touchedActor, touchedShape, contextID)) { if(NbCollisions) { @@ -1931,7 +1939,7 @@ PxControllerCollisionFlags SweepTest::moveCharacter( RecoverPoint = -upDirection*Recover; // PT: we pass "SWEEP_PASS_UP" for compatibility with previous code, but it's technically wrong (this is a 'down' pass) - if(doSweepTest(userData, userHitData, userObstacles, volume, RecoverPoint, SideVector, maxIter, &NbCollisions, MD, filters, SWEEP_PASS_UP, touchedActor, touchedShape)) + if(doSweepTest(userData, userHitData, userObstacles, volume, RecoverPoint, SideVector, maxIter, &NbCollisions, MD, filters, SWEEP_PASS_UP, touchedActor, touchedShape, contextID)) { // if(NbCollisions) CollisionFlags |= COLLISION_Y_DOWN; // PT: why did we do this ? Removed for now. It creates a bug (non registered event) when we land on a steep poly. @@ -2212,7 +2220,7 @@ PxControllerCollisionFlags Controller::move(SweptVolume& volume, const PxVec3& o mGlobalTime += PxF64(elapsedTime); // Init CCT with per-controller settings - Cm::RenderBuffer* renderBuffer = mManager->mRenderBuffer; + RenderBuffer* renderBuffer = mManager->mRenderBuffer; const PxU32 debugRenderFlags = mManager->mDebugRenderingFlags; mCctModule.mRenderBuffer = renderBuffer; mCctModule.mRenderFlags = debugRenderFlags; @@ -2311,6 +2319,8 @@ PxControllerCollisionFlags Controller::move(SweptVolume& volume, const PxVec3& o PX_ASSERT(!capsules.size()); { + PX_PROFILE_ZONE("CharacterController.filterCandidateControllers", getContextId()); + // Experiment - to do better const PxU32 nbControllers = mManager->getNbControllers(); Controller** controllers = mManager->getControllers(); @@ -2339,12 +2349,12 @@ PxControllerCollisionFlags Controller::move(SweptVolume& volume, const PxVec3& o #ifdef REMOVED if(renderBuffer /*&& (debugRenderFlags & PxControllerDebugRenderFlag::eOBSTACLES)*/) { - Cm::RenderOutput out(*renderBuffer); + RenderOutput out(*renderBuffer); out << gCCTBoxDebugColor; out << PxTransform(toVec3(obb.center), obb.rot); - out << Cm::DebugBox(obb.extents, true); + out << DebugBox(obb.extents, true); } #endif const size_t code = encodeUserObject(i, USER_OBJECT_CCT); @@ -2389,12 +2399,12 @@ PxControllerCollisionFlags Controller::move(SweptVolume& volume, const PxVec3& o if(renderBuffer && (debugRenderFlags & PxControllerDebugRenderFlag::eOBSTACLES)) { - Cm::RenderOutput out(*renderBuffer); + RenderOutput out(*renderBuffer); out << gObstacleDebugColor; out << PxTransform(toVec3(userBoxObstacle.mPos), userBoxObstacle.mRot); - out << Cm::DebugBox(userBoxObstacle.mHalfExtents, true); + out << DebugBox(userBoxObstacle.mHalfExtents, true); } } @@ -2419,7 +2429,7 @@ PxControllerCollisionFlags Controller::move(SweptVolume& volume, const PxVec3& o if(renderBuffer && (debugRenderFlags & PxControllerDebugRenderFlag::eOBSTACLES)) { - Cm::RenderOutput out(*renderBuffer); + RenderOutput out(*renderBuffer); out << gObstacleDebugColor; out.outputCapsule(userCapsuleObstacle.mRadius, userCapsuleObstacle.mHalfHeight, PxTransform(toVec3(userCapsuleObstacle.mPos), userCapsuleObstacle.mRot)); } @@ -2458,7 +2468,7 @@ PxControllerCollisionFlags Controller::move(SweptVolume& volume, const PxVec3& o const PxRigidActor* touchedActor = NULL; const PxShape* touchedShape = NULL; PxExtendedVec3 Backup = volume.mCenter; - collisionFlags = mCctModule.moveCharacter(&findGeomData, &userHitData, volume, disp, userObstacles, minDist, filters, constrainedClimbingMode, standingOnMoving, touchedActor, touchedShape); + collisionFlags = mCctModule.moveCharacter(&findGeomData, &userHitData, volume, disp, userObstacles, minDist, filters, constrainedClimbingMode, standingOnMoving, touchedActor, touchedShape, getContextId()); if(mCctModule.mFlags & STF_HIT_NON_WALKABLE) { @@ -2474,7 +2484,7 @@ PxControllerCollisionFlags Controller::move(SweptVolume& volume, const PxVec3& o } else xpDisp = disp; - collisionFlags = mCctModule.moveCharacter(&findGeomData, &userHitData, volume, xpDisp, userObstacles, minDist, filters, constrainedClimbingMode, standingOnMoving, touchedActor, touchedShape); + collisionFlags = mCctModule.moveCharacter(&findGeomData, &userHitData, volume, xpDisp, userObstacles, minDist, filters, constrainedClimbingMode, standingOnMoving, touchedActor, touchedShape, getContextId()); mCctModule.mFlags &= ~STF_WALK_EXPERIMENT; } @@ -2511,6 +2521,8 @@ PxControllerCollisionFlags Controller::move(SweptVolume& volume, const PxVec3& o PxControllerCollisionFlags BoxController::move(const PxVec3& disp, PxF32 minDist, PxF32 elapsedTime, const PxControllerFilters& filters, const PxObstacleContext* obstacles) { + PX_PROFILE_ZONE("CharacterController.move", getContextId()); + PX_SIMD_GUARD; // Create internal swept box @@ -2523,6 +2535,8 @@ PxControllerCollisionFlags BoxController::move(const PxVec3& disp, PxF32 minDist PxControllerCollisionFlags CapsuleController::move(const PxVec3& disp, PxF32 minDist, PxF32 elapsedTime, const PxControllerFilters& filters, const PxObstacleContext* obstacles) { + PX_PROFILE_ZONE("CharacterController.move", getContextId()); + PX_SIMD_GUARD; // Create internal swept capsule diff --git a/PhysX_3.4/Source/PhysXCharacterKinematic/src/CctCharacterController.h b/PhysX_3.4/Source/PhysXCharacterKinematic/src/CctCharacterController.h index f87f7512..1157f2e5 100644 --- a/PhysX_3.4/Source/PhysXCharacterKinematic/src/CctCharacterController.h +++ b/PhysX_3.4/Source/PhysXCharacterKinematic/src/CctCharacterController.h @@ -75,14 +75,6 @@ namespace Cct bool mPreventVerticalSlidingAgainstCeiling; }; - template<class T, class A> - PX_INLINE T* reserve(Ps::Array<T, A>& array, PxU32 nb) - { - const PxU32 currentSize = array.size(); - array.resizeUninitialized(array.size() + nb); - return array.begin() + currentSize; - } - // typedef Ps::Array<PxTriangle> TriArray; typedef Ps::Array<PxU32> IntArray; @@ -93,17 +85,28 @@ namespace Cct PX_FORCE_INLINE PxTriangle* reserve(PxU32 nbTris) { - const PxU32 currentSize = Ps::Array<PxTriangle>::size(); + // PT: customized version of "reserveContainerMemory" + + const PxU32 maxNbEntries = Ps::Array<PxTriangle>::capacity(); // PT: allocate one more tri to make sure we can safely V4Load the last one... - Ps::Array<PxTriangle>::resizeUninitialized(currentSize + nbTris + 1); + const PxU32 realRequiredSize = Ps::Array<PxTriangle>::size() + nbTris; + const PxU32 requiredSize = realRequiredSize + 1; + + if(requiredSize>maxNbEntries) + { + const PxU32 naturalGrowthSize = maxNbEntries ? maxNbEntries*2 : 2; + const PxU32 newSize = PxMax(requiredSize, naturalGrowthSize); + Ps::Array<PxTriangle>::reserve(newSize); + } + + PxTriangle* buf = Ps::Array<PxTriangle>::end(); // ...but we still want the size to reflect the correct number - Ps::Array<PxTriangle>::forceSize_Unsafe(currentSize + nbTris); - return Ps::Array<PxTriangle>::begin() + currentSize; + Ps::Array<PxTriangle>::forceSize_Unsafe(realRequiredSize); + return buf; } PX_FORCE_INLINE void pushBack(const PxTriangle& tri) { -// Ps::Array<PxTriangle>::pushBack(tri); PxTriangle* memory = reserve(1); memory->verts[0] = tri.verts[0]; memory->verts[1] = tri.verts[1]; @@ -323,8 +326,8 @@ namespace Cct bool constrainedClimbingMode, bool standingOnMoving, const PxRigidActor*& touchedActor, - const PxShape*& touchedShape - ); + const PxShape*& touchedShape, + PxU64 contextID); bool doSweepTest(const InternalCBData_FindTouchedGeom* userDataTouchedGeom, InternalCBData_OnHit* userDataOnHit, @@ -332,7 +335,7 @@ namespace Cct SweptVolume& swept_volume, const PxVec3& direction, const PxVec3& sideVector, PxU32 max_iter, PxU32* nb_collisions, PxF32 min_dist, const PxControllerFilters& filters, SweepPass sweepPass, - const PxRigidActor*& touchedActor, const PxShape*& touchedShape); + const PxRigidActor*& touchedActor, const PxShape*& touchedShape, PxU64 contextID); void findTouchedObstacles(const UserObstacles& userObstacles, const PxExtendedBounds3& world_box); diff --git a/PhysX_3.4/Source/PhysXCharacterKinematic/src/CctCharacterControllerCallbacks.cpp b/PhysX_3.4/Source/PhysXCharacterKinematic/src/CctCharacterControllerCallbacks.cpp index dc59ca59..c0e93d5e 100644 --- a/PhysX_3.4/Source/PhysXCharacterKinematic/src/CctCharacterControllerCallbacks.cpp +++ b/PhysX_3.4/Source/PhysXCharacterKinematic/src/CctCharacterControllerCallbacks.cpp @@ -27,6 +27,7 @@ // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. +#include "foundation/PxProfiler.h" #include "CctInternalStructs.h" #include "PxScene.h" #include "PxSphereGeometry.h" @@ -49,11 +50,12 @@ static const float gDebugVisOffset = 0.01f; using namespace physx; using namespace Cct; using namespace Gu; +using namespace Cm; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // PT: HINT: disable gUsePartialUpdates for easier visualization -static void visualizeTouchedTriangles(PxU32 nbTrisToRender, PxU32 startIndex, const PxTriangle* triangles, Cm::RenderBuffer* renderBuffer, const PxVec3& offset, const PxVec3& upDirection) +static void visualizeTouchedTriangles(PxU32 nbTrisToRender, PxU32 startIndex, const PxTriangle* triangles, RenderBuffer* renderBuffer, const PxVec3& offset, const PxVec3& upDirection) { if(!renderBuffer) return; @@ -65,11 +67,11 @@ static void visualizeTouchedTriangles(PxU32 nbTrisToRender, PxU32 startIndex, co { const PxTriangle& currentTriangle = triangles[i+startIndex]; -// Cm::RenderOutput(*renderBuffer) -// << PxDebugColor::eARGB_GREEN << Cm::RenderOutput::TRIANGLES +// RenderOutput(*renderBuffer) +// << PxDebugColor::eARGB_GREEN << RenderOutput::TRIANGLES // << currentTriangle.verts[0]+yy << currentTriangle.verts[1]+yy << currentTriangle.verts[2]+yy; - Cm::RenderOutput(*renderBuffer) - << PxU32(PxDebugColor::eARGB_GREEN) << Cm::RenderOutput::LINES + RenderOutput(*renderBuffer) + << PxU32(PxDebugColor::eARGB_GREEN) << RenderOutput::LINES << currentTriangle.verts[0]+yy << currentTriangle.verts[1]+yy << currentTriangle.verts[1]+yy << currentTriangle.verts[2]+yy << currentTriangle.verts[2]+yy << currentTriangle.verts[0]+yy; @@ -195,7 +197,7 @@ static void tessellateTriangle(PxU32& nbNewTris, const TrianglePadded& tr, PxU32 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// static void outputPlaneToStream(PxShape* planeShape, const PxRigidActor* actor, const PxTransform& globalPose, IntArray& geomStream, TriArray& worldTriangles, IntArray& triIndicesArray, - const PxExtendedVec3& origin, const PxBounds3& tmpBounds, const CCTParams& params, Cm::RenderBuffer* renderBuffer) + const PxExtendedVec3& origin, const PxBounds3& tmpBounds, const CCTParams& params, RenderBuffer* renderBuffer) { PX_ASSERT(planeShape->getGeometryType() == PxGeometryType::ePLANE); @@ -219,7 +221,7 @@ static void outputPlaneToStream(PxShape* planeShape, const PxRigidActor* actor, const PxVec3 offset(float(-origin.x), float(-origin.y), float(-origin.z)); - TouchedMesh* touchedMesh = reinterpret_cast<TouchedMesh*>(reserve(geomStream, sizeof(TouchedMesh)/sizeof(PxU32))); + TouchedMesh* touchedMesh = reinterpret_cast<TouchedMesh*>(reserveContainerMemory(geomStream, sizeof(TouchedMesh)/sizeof(PxU32))); touchedMesh->mType = TouchedGeomType::eMESH; touchedMesh->mTGUserData = planeShape; touchedMesh->mActor = actor; @@ -259,7 +261,7 @@ static void outputSphereToStream(PxShape* sphereShape, const PxRigidActor* actor WorldSphere.center.z = PxExtended(globalPose.p.z); } - TouchedSphere* PX_RESTRICT touchedSphere = reinterpret_cast<TouchedSphere*>(reserve(geomStream, sizeof(TouchedSphere)/sizeof(PxU32))); + TouchedSphere* PX_RESTRICT touchedSphere = reinterpret_cast<TouchedSphere*>(reserveContainerMemory(geomStream, sizeof(TouchedSphere)/sizeof(PxU32))); touchedSphere->mType = TouchedGeomType::eSPHERE; touchedSphere->mTGUserData = sphereShape; touchedSphere->mActor = actor; @@ -294,7 +296,7 @@ static void outputCapsuleToStream(PxShape* capsuleShape, const PxRigidActor* act WorldCapsule.p1.z = PxExtended(p1.z); } - TouchedCapsule* PX_RESTRICT touchedCapsule = reinterpret_cast<TouchedCapsule*>(reserve(geomStream, sizeof(TouchedCapsule)/sizeof(PxU32))); + TouchedCapsule* PX_RESTRICT touchedCapsule = reinterpret_cast<TouchedCapsule*>(reserveContainerMemory(geomStream, sizeof(TouchedCapsule)/sizeof(PxU32))); touchedCapsule->mType = TouchedGeomType::eCAPSULE; touchedCapsule->mTGUserData = capsuleShape; touchedCapsule->mActor = actor; @@ -361,7 +363,7 @@ static void outputBoxToStream( PxShape* boxShape, const PxRigidActor* actor, con {5,2,6} //2,1,5,6 }; - TouchedMesh* touchedMesh = reinterpret_cast<TouchedMesh*>(reserve(geomStream, sizeof(TouchedMesh)/sizeof(PxU32))); + TouchedMesh* touchedMesh = reinterpret_cast<TouchedMesh*>(reserveContainerMemory(geomStream, sizeof(TouchedMesh)/sizeof(PxU32))); touchedMesh->mType = TouchedGeomType::eMESH; touchedMesh->mTGUserData = boxShape; touchedMesh->mActor = actor; @@ -483,7 +485,7 @@ static PxU32 createInvisibleWalls(const CCTParams& params, const PxTriangle& cur /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// static void outputMeshToStream( PxShape* meshShape, const PxRigidActor* actor, const PxTransform& meshPose, IntArray& geomStream, TriArray& worldTriangles, IntArray& triIndicesArray, - const PxExtendedVec3& origin, const PxBounds3& tmpBounds, const CCTParams& params, Cm::RenderBuffer* renderBuffer, PxU16& nbTessellation) + const PxExtendedVec3& origin, const PxBounds3& tmpBounds, const CCTParams& params, RenderBuffer* renderBuffer, PxU16& nbTessellation) { PX_ASSERT(meshShape->getGeometryType() == PxGeometryType::eTRIANGLEMESH); // Do AABB-mesh query @@ -500,7 +502,7 @@ static void outputMeshToStream( PxShape* meshShape, const PxRigidActor* actor, c const PxVec3 offset(float(-origin.x), float(-origin.y), float(-origin.z)); - TouchedMesh* touchedMesh = reinterpret_cast<TouchedMesh*>(reserve(geomStream, sizeof(TouchedMesh)/sizeof(PxU32))); + TouchedMesh* touchedMesh = reinterpret_cast<TouchedMesh*>(reserveContainerMemory(geomStream, sizeof(TouchedMesh)/sizeof(PxU32))); touchedMesh->mType = TouchedGeomType::eMESH; touchedMesh->mTGUserData = meshShape; touchedMesh->mActor = actor; @@ -627,7 +629,7 @@ static void outputMeshToStream( PxShape* meshShape, const PxRigidActor* actor, c /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// static void outputHeightFieldToStream( PxShape* hfShape, const PxRigidActor* actor, const PxTransform& heightfieldPose, IntArray& geomStream, TriArray& worldTriangles, IntArray& triIndicesArray, - const PxExtendedVec3& origin, const PxBounds3& tmpBounds, const CCTParams& params, Cm::RenderBuffer* renderBuffer, PxU16& nbTessellation) + const PxExtendedVec3& origin, const PxBounds3& tmpBounds, const CCTParams& params, RenderBuffer* renderBuffer, PxU16& nbTessellation) { PX_ASSERT(hfShape->getGeometryType() == PxGeometryType::eHEIGHTFIELD); // Do AABB-mesh query @@ -644,7 +646,7 @@ static void outputHeightFieldToStream( PxShape* hfShape, const PxRigidActor* act const PxVec3 offset(float(-origin.x), float(-origin.y), float(-origin.z)); - TouchedMesh* touchedMesh = reinterpret_cast<TouchedMesh*>(reserve(geomStream, sizeof(TouchedMesh)/sizeof(PxU32))); + TouchedMesh* touchedMesh = reinterpret_cast<TouchedMesh*>(reserveContainerMemory(geomStream, sizeof(TouchedMesh)/sizeof(PxU32))); touchedMesh->mType = TouchedGeomType::eMESH; // ptchernev: seems to work touchedMesh->mTGUserData = hfShape; touchedMesh->mActor = actor; @@ -767,7 +769,7 @@ static void outputHeightFieldToStream( PxShape* hfShape, const PxRigidActor* act /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// static void outputConvexToStream(PxShape* convexShape, const PxRigidActor* actor, const PxTransform& absPose_, IntArray& geomStream, TriArray& worldTriangles, IntArray& triIndicesArray, - const PxExtendedVec3& origin, const PxBounds3& tmpBounds, const CCTParams& params, Cm::RenderBuffer* renderBuffer, PxU16& nbTessellation) + const PxExtendedVec3& origin, const PxBounds3& tmpBounds, const CCTParams& params, RenderBuffer* renderBuffer, PxU16& nbTessellation) { PX_ASSERT(convexShape->getGeometryType() == PxGeometryType::eCONVEXMESH); PxConvexMeshGeometry cg; @@ -832,7 +834,7 @@ static void outputConvexToStream(PxShape* convexShape, const PxRigidActor* actor const PxVec3 offset(float(-origin.x), float(-origin.y), float(-origin.z)); - TouchedMesh* touchedMesh = reinterpret_cast<TouchedMesh*>(reserve(geomStream, sizeof(TouchedMesh)/sizeof(PxU32))); + TouchedMesh* touchedMesh = reinterpret_cast<TouchedMesh*>(reserveContainerMemory(geomStream, sizeof(TouchedMesh)/sizeof(PxU32))); touchedMesh->mType = TouchedGeomType::eMESH; touchedMesh->mTGUserData = convexShape; touchedMesh->mActor = actor; @@ -920,7 +922,10 @@ void Cct::findTouchedGeometry( const PxInternalCBData_FindTouchedGeom* internalData = static_cast<const PxInternalCBData_FindTouchedGeom*>(userData); PxScene* scene = internalData->scene; - Cm::RenderBuffer* renderBuffer = internalData->renderBuffer; + + PX_PROFILE_ZONE("CharacterController.findTouchedGeometry", PxU64(reinterpret_cast<size_t>(scene))); + + RenderBuffer* renderBuffer = internalData->renderBuffer; PxExtendedVec3 Origin; // Will be TouchedGeom::mOffset getCenter(worldBounds, Origin); @@ -943,7 +948,8 @@ void Cct::findTouchedGeometry( const PxBounds3 tmpBounds(toVec3(worldBounds.minimum), toVec3(worldBounds.maximum)); // LOSS OF ACCURACY // PT: unfortunate conversion forced by the PxGeometry API - PxVec3 center = tmpBounds.getCenter(), extents = tmpBounds.getExtents(); + const PxVec3 center = tmpBounds.getCenter(); + const PxVec3 extents = tmpBounds.getExtents(); const PxU32 size = 100; PxOverlapHit hits[size]; diff --git a/PhysX_3.4/Source/PhysXCharacterKinematic/src/CctController.h b/PhysX_3.4/Source/PhysXCharacterKinematic/src/CctController.h index beab7ee4..3d27313a 100644 --- a/PhysX_3.4/Source/PhysXCharacterKinematic/src/CctController.h +++ b/PhysX_3.4/Source/PhysXCharacterKinematic/src/CctController.h @@ -74,8 +74,9 @@ namespace Cct mManager = cm; mCctModule.setCctManager(cm); } - CharacterControllerManager* getCctManager() { return mManager; } + PX_FORCE_INLINE CharacterControllerManager* getCctManager() { return mManager; } + PX_FORCE_INLINE PxU64 getContextId() const { return PxU64(reinterpret_cast<size_t>(mScene)); } PxControllerShapeType::Enum mType; // User params |