| 125 | } |
| 126 | |
| 127 | PxController* ControlledActor::init(const ControlledActorDesc& desc, PxControllerManager* manager) |
| 128 | { |
| 129 | const float radius = desc.mRadius; |
| 130 | float height = desc.mHeight; |
| 131 | float crouchHeight = desc.mCrouchHeight; |
| 132 | |
| 133 | PxControllerDesc* cDesc; |
| 134 | PxBoxControllerDesc boxDesc; |
| 135 | PxCapsuleControllerDesc capsuleDesc; |
| 136 | |
| 137 | if(desc.mType==PxControllerShapeType::eBOX) |
| 138 | { |
| 139 | height *= 0.5f; |
| 140 | height += radius; |
| 141 | crouchHeight *= 0.5f; |
| 142 | crouchHeight += radius; |
| 143 | boxDesc.halfHeight = height; |
| 144 | boxDesc.halfSideExtent = radius; |
| 145 | boxDesc.halfForwardExtent = radius; |
| 146 | cDesc = &boxDesc; |
| 147 | } |
| 148 | else |
| 149 | { |
| 150 | PX_ASSERT(desc.mType==PxControllerShapeType::eCAPSULE); |
| 151 | capsuleDesc.height = height; |
| 152 | capsuleDesc.radius = radius; |
| 153 | capsuleDesc.climbingMode = PxCapsuleClimbingMode::eCONSTRAINED; |
| 154 | cDesc = &capsuleDesc; |
| 155 | } |
| 156 | |
| 157 | cDesc->density = desc.mProxyDensity; |
| 158 | cDesc->scaleCoeff = desc.mProxyScale; |
| 159 | cDesc->material = &mOwner.getDefaultMaterial(); |
| 160 | cDesc->position = desc.mPosition; |
| 161 | cDesc->slopeLimit = desc.mSlopeLimit; |
| 162 | cDesc->contactOffset = desc.mContactOffset; |
| 163 | cDesc->stepOffset = desc.mStepOffset; |
| 164 | cDesc->invisibleWallHeight = desc.mInvisibleWallHeight; |
| 165 | cDesc->maxJumpHeight = desc.mMaxJumpHeight; |
| 166 | // cDesc->nonWalkableMode = PxControllerNonWalkableMode::ePREVENT_CLIMBING_AND_FORCE_SLIDING; |
| 167 | cDesc->reportCallback = desc.mReportCallback; |
| 168 | cDesc->behaviorCallback = desc.mBehaviorCallback; |
| 169 | cDesc->volumeGrowth = desc.mVolumeGrowth; |
| 170 | |
| 171 | mType = desc.mType; |
| 172 | mInitialPosition = desc.mPosition; |
| 173 | mStandingSize = height; |
| 174 | mCrouchingSize = crouchHeight; |
| 175 | mControllerRadius = radius; |
| 176 | |
| 177 | PxController* ctrl = static_cast<PxBoxController*>(manager->createController(*cDesc)); |
| 178 | PX_ASSERT(ctrl); |
| 179 | |
| 180 | // remove controller shape from scene query for standup overlap test |
| 181 | PxRigidDynamic* actor = ctrl->getActor(); |
| 182 | if(actor) |
| 183 | { |
| 184 | if(actor->getNbShapes()) |
nothing calls this directly
no test coverage detected