PxController.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
3  *
4  * NVIDIA CORPORATION and its licensors retain all intellectual property
5  * and proprietary rights in and to this software, related documentation
6  * and any modifications thereto. Any use, reproduction, disclosure or
7  * distribution of this software and related documentation without an express
8  * license agreement from NVIDIA CORPORATION is strictly prohibited.
9  */
10 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
11 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
12 
13 
14 
15 #ifndef PX_PHYSICS_CCT_CONTROLLER
16 #define PX_PHYSICS_CCT_CONTROLLER
17 
24 #include "PxQueryFiltering.h"
27 
28 #ifndef PX_DOXYGEN
29 namespace physx
30 {
31 #endif
32 
37 {
38  enum Enum
39  {
46 
53 
54  eFORCE_DWORD = 0x7fffffff
55  };
56 };
57 
58 class PxShape;
59 class PxScene;
60 class PxController;
61 class PxRigidDynamic;
62 class PxMaterial;
63 struct PxFilterData;
66 class PxObstacleContext;
67 class PxObstacle;
68 
75 {
76  enum Enum
77  {
80 
81  eFORCE_SLIDING = ePREVENT_CLIMBING_AND_FORCE_SLIDING
82  };
83 };
86 
91 {
92  enum Enum
93  {
94  eCOLLISION_SIDES = (1<<0),
95  eCOLLISION_UP = (1<<1),
96  eCOLLISION_DOWN = (1<<2)
97  };
98 };
99 
107 
108 
112 
113 
118 {
122  ObstacleHandle touchedObstacleHandle; // Obstacle on which the CCT is standing
126  bool isMovingUp;
127 };
128 
133 {
138 };
139 
144 {
150 };
153 
160 {
164 };
165 
172 {
174 };
175 
182 {
183  const void* userData;
184 };
185 
194 {
195 public:
196 
206  virtual void onShapeHit(const PxControllerShapeHit& hit) = 0;
207 
215  virtual void onControllerHit(const PxControllersHit& hit) = 0;
216 
224  virtual void onObstacleHit(const PxControllerObstacleHit& hit) = 0;
225 
226 protected:
228 };
229 
230 
243 {
244 public:
246 
254  virtual bool filter(const PxController& a, const PxController& b) = 0;
255 };
256 
275 {
276  public:
277  //*********************************************************************
278  // DEPRECATED MEMBERS:
279  //
280  // PX_DEPRECATED PxU32 mActiveGroups;
281  //
282  // => replaced with:
283  //
284  // PxControllerFilters::mCCTFilterCallback. Please define a PxControllerFilterCallback object and emulate the old interaction mode there.
285  //
286  //*********************************************************************
287 
289  mFilterData (filterData),
290  mFilterCallback (cb),
291  mFilterFlags (PxQueryFlag::eSTATIC|PxQueryFlag::eDYNAMIC|PxQueryFlag::ePREFILTER),
292  mCCTFilterCallback (cctFilterCb)
293  {}
294 
295  // CCT-vs-shapes:
296  const PxFilterData* mFilterData;
297 
300  // CCT-vs-CCT:
302 };
303 
304 
311 {
312 public:
313  //*********************************************************************
314  // DEPRECATED MEMBERS:
315  //
316  // PX_DEPRECATED PxUserControllerHitReport* callback;
317  //
318  // => replaced with:
319  //
320  // PxUserControllerHitReport* reportCallback;
321  //
322  // ----------------------------
323  //
324  // PX_DEPRECATED PxCCTInteractionMode::Enum interactionMode;
325  // PX_DEPRECATED PxU32 groupsBitmask;
326  //
327  // => replaced with:
328  //
329  // PxControllerFilters::mCCTFilterCallback. Please define a PxControllerFilterCallback object and emulate the old interaction mode there.
330  //
331  //*********************************************************************
332 
338  PX_INLINE virtual bool isValid() const;
339 
348 
357 
367 
383 
396 
421 
434 
447 
456 
466 
476 
490 
503 
514 
525 
531  void* userData;
532 
533 protected:
535 
540  PX_INLINE virtual ~PxControllerDesc();
541 
546 
550  PX_INLINE PxControllerDesc& operator=(const PxControllerDesc&);
551 
552  PX_INLINE void copy(const PxControllerDesc&);
553 };
554 
556 {
557  upDirection = PxVec3(0.0f, 1.0f, 0.0f);
558  slopeLimit = 0.707f;
559  contactOffset = 0.1f;
560  stepOffset = 0.5f;
561  density = 10.0f;
562  scaleCoeff = 0.8f;
563  volumeGrowth = 1.5f;
565  callback = NULL;
567  userData = NULL;
569  position.x = PxExtended(0.0);
570  position.y = PxExtended(0.0);
571  position.z = PxExtended(0.0);
572  material = NULL;
573  invisibleWallHeight = 0.0f;
574  maxJumpHeight = 0.0f;
575 }
576 
578 {
579  copy(other);
580 }
581 
583 {
584  copy(other);
585  return *this;
586 }
587 
589 {
590  upDirection = other.upDirection;
591  slopeLimit = other.slopeLimit;
593  stepOffset = other.stepOffset;
594  density = other.density;
595  scaleCoeff = other.scaleCoeff;
596  volumeGrowth = other.volumeGrowth;
598  callback = other.callback;
600  userData = other.userData;
602  position.x = other.position.x;
603  position.y = other.position.y;
604  position.z = other.position.z;
605  material = other.material;
608 }
609 
611 {
612 }
613 
615 {
618  return false;
619  if(scaleCoeff<0.0f) return false;
620  if(volumeGrowth<1.0f) return false;
621  if(density<0.0f) return false;
622  if(slopeLimit<0.0f) return false;
623  if(stepOffset<0.0f) return false;
624  if(contactOffset<=0.0f) return false;
625  if(!material) return false;
626 
627  if(callback && !reportCallback)
628  {
629  (const_cast<PxControllerDesc*>(this))->reportCallback = callback;
630  PxGetFoundation().getErrorCallback().reportError(PxErrorCode::eDEBUG_WARNING, "PxControllerDesc::callback is deprecated, please use PxControllerDesc::reportCallback instead.", __FILE__, __LINE__);
631  }
632  return true;
633 }
634 
635 
642 {
643 public:
644  //*********************************************************************
645  // DEPRECATED FUNCTIONS:
646  //
647  // PX_DEPRECATED virtual void setInteraction(PxCCTInteractionMode::Enum flag) = 0;
648  // PX_DEPRECATED virtual PxCCTInteractionMode::Enum getInteraction() const = 0;
649  // PX_DEPRECATED virtual void setGroupsBitmask(PxU32 bitmask) = 0;
650  // PX_DEPRECATED virtual PxU32 getGroupsBitmask() const = 0;
651  //
652  // => replaced with:
653  //
654  // PxControllerFilters::mCCTFilterCallback. Please define a PxControllerFilterCallback object and emulate the old interaction mode there.
655  //
656  //*********************************************************************
657 
663  virtual PxControllerShapeType::Enum getType() const = 0;
664 
668  virtual void release() = 0;
669 
681  virtual PxControllerCollisionFlags move(const PxVec3& disp, PxF32 minDist, PxF32 elapsedTime, const PxControllerFilters& filters, const PxObstacleContext* obstacles=NULL) = 0;
682 
698  virtual bool setPosition(const PxExtendedVec3& position) = 0;
699 
713  virtual const PxExtendedVec3& getPosition() const = 0;
714 
731  virtual bool setFootPosition(const PxExtendedVec3& position) = 0;
732 
742  virtual PxExtendedVec3 getFootPosition() const = 0;
743 
751  virtual PxRigidDynamic* getActor() const = 0;
752 
760  virtual void setStepOffset(const PxF32 offset) =0;
761 
769  virtual PxF32 getStepOffset() const =0;
770 
779 
788 
796  virtual PxF32 getContactOffset() const =0;
797 
805  virtual void setContactOffset(PxF32 offset) =0;
806 
814  virtual PxVec3 getUpDirection() const =0;
815 
823  virtual void setUpDirection(const PxVec3& up) =0;
824 
832  virtual PxF32 getSlopeLimit() const =0;
833 
845  virtual void setSlopeLimit(PxF32 slopeLimit) =0;
846 
862  virtual void invalidateCache() = 0;
863 
869  virtual PxScene* getScene() = 0;
870 
878  virtual void* getUserData() const = 0;
879 
887  virtual void setUserData(void* userData) = 0;
888 
896  virtual void getState(PxControllerState& state) const = 0;
897 
905  virtual void getStats(PxControllerStats& stats) const = 0;
906 
917  virtual void resize(PxReal height) = 0;
918 
919 protected:
921  virtual ~PxController() {}
922 };
923 
924 #ifndef PX_DOXYGEN
925 } // namespace physx
926 #endif
927 
929 #endif


Copyright © 2008-2015 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com