Main Page
Class Hierarchy
Compound List
Compound Members
Include
characterkinematic
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
21
#include "
characterkinematic/PxCharacter.h
"
22
#include "
characterkinematic/PxExtended.h
"
23
#include "
characterkinematic/PxControllerObstacles.h
"
24
#include "
PxQueryFiltering.h
"
25
#include "
foundation/PxFoundation.h
"
26
#include "
foundation/PxErrorCallback.h
"
27
28
#ifndef PX_DOXYGEN
29
namespace
physx
30
{
31
#endif
32
36
struct
PxControllerShapeType
37
{
38
enum
Enum
39
{
45
eBOX
,
46
52
eCAPSULE
,
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
;
64
class
PxQueryFilterCallback
;
65
class
PxControllerBehaviorCallback
;
66
class
PxObstacleContext
;
67
class
PxObstacle
;
68
74
struct
PxControllerNonWalkableMode
75
{
76
enum
Enum
77
{
78
ePREVENT_CLIMBING
,
79
ePREVENT_CLIMBING_AND_FORCE_SLIDING
,
80
81
eFORCE_SLIDING = ePREVENT_CLIMBING_AND_FORCE_SLIDING
82
};
83
};
85
typedef
PX_DEPRECATED
PxControllerNonWalkableMode
PxCCTNonWalkableMode
;
86
90
struct
PxControllerCollisionFlag
91
{
92
enum
Enum
93
{
94
eCOLLISION_SIDES = (1<<0),
95
eCOLLISION_UP = (1<<1),
96
eCOLLISION_DOWN = (1<<2)
97
};
98
};
99
105
typedef
PxFlags<PxControllerCollisionFlag::Enum, PxU8>
PxControllerCollisionFlags
;
106
PX_FLAGS_OPERATORS
(
PxControllerCollisionFlag::Enum
,
PxU8
)
107
108
109
typedef
PX_DEPRECATED
PxControllerCollisionFlag
PxControllerFlag
;
111
typedef
PX_DEPRECATED
PxControllerCollisionFlags
PxControllerFlags
;
112
113
117
struct
PxControllerState
118
{
119
PxVec3
deltaXP
;
120
PxShape
*
touchedShape
;
121
PxRigidActor
*
touchedActor
;
122
ObstacleHandle
touchedObstacleHandle
;
// Obstacle on which the CCT is standing
123
PxU32
collisionFlags
;
124
bool
standOnAnotherCCT
;
125
bool
standOnObstacle
;
126
bool
isMovingUp
;
127
};
128
132
struct
PxControllerStats
133
{
134
PxU16
nbIterations
;
135
PxU16
nbFullUpdates
;
136
PxU16
nbPartialUpdates
;
137
PxU16
nbTessellation
;
138
};
139
143
struct
PxControllerHit
144
{
145
PxController
*
controller
;
146
PxExtendedVec3
worldPos
;
147
PxVec3
worldNormal
;
148
PxVec3
dir
;
149
PxF32
length
;
150
};
152
typedef
PX_DEPRECATED
PxControllerHit
PxCCTHit
;
153
159
struct
PxControllerShapeHit
:
PxControllerHit
160
{
161
PxShape
*
shape
;
162
PxRigidActor
*
actor
;
163
PxU32
triangleIndex
;
164
};
165
171
struct
PxControllersHit
:
PxControllerHit
172
{
173
PxController
*
other
;
174
};
175
181
struct
PxControllerObstacleHit
:
PxControllerHit
182
{
183
const
void
*
userData
;
184
};
185
193
class
PxUserControllerHitReport
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
:
227
virtual
~PxUserControllerHitReport
(){}
228
};
229
230
242
class
PxControllerFilterCallback
243
{
244
public
:
245
virtual
~PxControllerFilterCallback
(){}
246
254
virtual
bool
filter(
const
PxController
& a,
const
PxController
& b) = 0;
255
};
256
274
class
PxControllerFilters
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
288
PX_INLINE
PxControllerFilters
(
const
PxFilterData
* filterData=
NULL
,
PxQueryFilterCallback
* cb=
NULL
,
PxControllerFilterCallback
* cctFilterCb=
NULL
) :
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
298
PxQueryFilterCallback
*
mFilterCallback
;
299
PxQueryFlags
mFilterFlags
;
300
// CCT-vs-CCT:
301
PxControllerFilterCallback
*
mCCTFilterCallback
;
302
};
303
304
310
class
PxControllerDesc
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
347
PX_INLINE
PxControllerShapeType::Enum
getType
()
const
{
return
mType; }
348
356
PxExtendedVec3
position
;
357
366
PxVec3
upDirection
;
367
382
PxF32
slopeLimit
;
383
395
PxF32
invisibleWallHeight
;
396
420
PxF32
maxJumpHeight
;
421
433
PxF32
contactOffset
;
434
446
PxF32
stepOffset
;
447
455
PxF32
density
;
456
465
PxF32
scaleCoeff
;
466
475
PxF32
volumeGrowth
;
476
488
PxUserControllerHitReport
*
reportCallback
;
489
PX_DEPRECATED
PxUserControllerHitReport
*
callback
;
490
502
PxControllerBehaviorCallback
*
behaviorCallback
;
503
513
PxControllerNonWalkableMode::Enum
nonWalkableMode
;
514
524
PxMaterial
*
material
;
525
531
void
*
userData
;
532
533
protected
:
534
const
PxControllerShapeType::Enum
mType
;
535
539
PX_INLINE
PxControllerDesc
(
PxControllerShapeType::Enum
);
540
PX_INLINE
virtual
~
PxControllerDesc
();
541
545
PX_INLINE
PxControllerDesc
(
const
PxControllerDesc
&);
546
550
PX_INLINE
PxControllerDesc
& operator=(
const
PxControllerDesc
&);
551
552
PX_INLINE
void
copy(
const
PxControllerDesc
&);
553
};
554
555
PX_INLINE
PxControllerDesc::PxControllerDesc
(
PxControllerShapeType::Enum
t) : mType(t)
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;
564
reportCallback
=
NULL
;
565
callback
=
NULL
;
566
behaviorCallback
=
NULL
;
567
userData
=
NULL
;
568
nonWalkableMode
=
PxControllerNonWalkableMode::ePREVENT_CLIMBING
;
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
577
PX_INLINE
PxControllerDesc::PxControllerDesc
(
const
PxControllerDesc
& other) : mType(other.mType)
578
{
579
copy
(other);
580
}
581
582
PX_INLINE
PxControllerDesc
&
PxControllerDesc::operator=
(
const
PxControllerDesc
& other)
583
{
584
copy
(other);
585
return
*
this
;
586
}
587
588
PX_INLINE
void
PxControllerDesc::copy
(
const
PxControllerDesc
& other)
589
{
590
upDirection
= other.
upDirection
;
591
slopeLimit
= other.
slopeLimit
;
592
contactOffset
= other.
contactOffset
;
593
stepOffset
= other.
stepOffset
;
594
density
= other.
density
;
595
scaleCoeff
= other.
scaleCoeff
;
596
volumeGrowth
= other.
volumeGrowth
;
597
reportCallback
= other.
reportCallback
;
598
callback
= other.
callback
;
599
behaviorCallback
= other.
behaviorCallback
;
600
userData
= other.
userData
;
601
nonWalkableMode
= other.
nonWalkableMode
;
602
position
.
x
= other.
position
.
x
;
603
position
.
y
= other.
position
.
y
;
604
position
.
z
= other.
position
.
z
;
605
material
= other.
material
;
606
invisibleWallHeight
= other.
invisibleWallHeight
;
607
maxJumpHeight
= other.
maxJumpHeight
;
608
}
609
610
PX_INLINE
PxControllerDesc::~PxControllerDesc
()
611
{
612
}
613
614
PX_INLINE
bool
PxControllerDesc::isValid
()
const
615
{
616
if
(
mType
!=
PxControllerShapeType::eBOX
617
&&
mType
!=
PxControllerShapeType::eCAPSULE
)
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
641
class
PxController
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
778
virtual
void
setNonWalkableMode
(
PxControllerNonWalkableMode::Enum
flag) = 0;
779
787
virtual
PxControllerNonWalkableMode::Enum
getNonWalkableMode
()
const
= 0;
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
:
920
PX_INLINE
PxController
() {}
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