1 | // |
2 | // Redistribution and use in source and binary forms, with or without |
3 | // modification, are permitted provided that the following conditions |
4 | // are met: |
5 | // * Redistributions of source code must retain the above copyright |
6 | // notice, this list of conditions and the following disclaimer. |
7 | // * Redistributions in binary form must reproduce the above copyright |
8 | // notice, this list of conditions and the following disclaimer in the |
9 | // documentation and/or other materials provided with the distribution. |
10 | // * Neither the name of NVIDIA CORPORATION nor the names of its |
11 | // contributors may be used to endorse or promote products derived |
12 | // from this software without specific prior written permission. |
13 | // |
14 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY |
15 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
16 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
17 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
18 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
19 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
20 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
21 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
22 | // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 | // |
26 | // Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved. |
27 | // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. |
28 | // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. |
29 | |
30 | |
31 | #ifndef PXS_SIMULATION_CONTROLLER_H |
32 | #define PXS_SIMULATION_CONTROLLER_H |
33 | |
34 | #include "foundation/PxSimpleTypes.h" |
35 | #include "foundation/PxPreprocessor.h" |
36 | #include "foundation/PxTransform.h" |
37 | #include "CmBitMap.h" |
38 | #include "PsArray.h" |
39 | |
40 | |
41 | namespace physx |
42 | { |
43 | namespace Dy |
44 | { |
45 | class Context; |
46 | struct Constraint; |
47 | class ArticulationV; |
48 | class FeatherstoneArticulation; |
49 | struct ArticulationJointCore; |
50 | } |
51 | |
52 | namespace Cm |
53 | { |
54 | class EventProfiler; |
55 | } |
56 | |
57 | namespace Bp |
58 | { |
59 | class BoundsArray; |
60 | class BroadPhase; |
61 | } |
62 | |
63 | namespace IG |
64 | { |
65 | class SimpleIslandManager; |
66 | class IslandSim; |
67 | class NodeIndex; |
68 | } |
69 | |
70 | class PxsTransformCache; |
71 | class PxvNphaseImplementationContext; |
72 | class PxBaseTask; |
73 | |
74 | struct PxsBodySim; |
75 | struct PxsShapeSim; |
76 | class PxsRigidBody; |
77 | class PxsKernelWranglerManager; |
78 | class PxsHeapMemoryAllocatorManager; |
79 | |
80 | template<typename T> class PxgIterator; |
81 | struct PxgSolverConstraintManagerConstants; |
82 | |
83 | |
84 | class PxsSimulationControllerCallback |
85 | { |
86 | public: |
87 | virtual void updateScBodyAndShapeSim(PxBaseTask* continuation) = 0; |
88 | virtual PxU32 getNbCcdBodies() = 0; |
89 | |
90 | virtual ~PxsSimulationControllerCallback() {} |
91 | }; |
92 | |
93 | |
94 | class PxsSimulationController |
95 | { |
96 | public: |
97 | PxsSimulationController(PxsSimulationControllerCallback* callback): mCallback(callback){} |
98 | virtual ~PxsSimulationController(){} |
99 | |
100 | virtual void addJoint(const PxU32 edgeIndex, Dy::Constraint* constraint, IG::IslandSim& islandSim, Ps::Array<PxU32>& jointIndices, |
101 | Ps::Array<PxgSolverConstraintManagerConstants, Ps::VirtualAllocator>& managerIter, PxU32 uniqueId) = 0; |
102 | virtual void removeJoint(const PxU32 edgeIndex, Dy::Constraint* constraint, Ps::Array<PxU32>& jointIndices, IG::IslandSim& islandSim) = 0; |
103 | virtual void addShape(PxsShapeSim* shapeSim, const PxU32 index) = 0; |
104 | virtual void removeShape(const PxU32 index) = 0; |
105 | virtual void addDynamic(PxsRigidBody* rigidBody, const IG::NodeIndex& nodeIndex) = 0; |
106 | virtual void addDynamics(PxsRigidBody** rigidBody, const PxU32* nodeIndex, PxU32 nbToProcess) = 0; |
107 | virtual void addArticulation(Dy::ArticulationV* articulation, const IG::NodeIndex& nodeIndex) = 0; |
108 | virtual void releaseArticulation(Dy::ArticulationV* articulation, const IG::NodeIndex& nodeIndex) = 0; |
109 | virtual void releaseDeferredArticulationIds() = 0; |
110 | virtual void updateDynamic(const bool isArticulationLink, const IG::NodeIndex&) = 0; |
111 | virtual void updateJoint(const PxU32 edgeIndex, Dy::Constraint* constraint) = 0; |
112 | virtual void updateBodies(PxsRigidBody** rigidBodies, PxU32* nodeIndices, const PxU32 nbBodies) = 0; |
113 | virtual void updateBodiesAndShapes(PxBaseTask* continuation) = 0; |
114 | virtual void update(const PxU32 bitMapWordCounts) = 0; |
115 | virtual void updateArticulation(Dy::ArticulationV* articulation, const IG::NodeIndex& nodeIndex) = 0; |
116 | virtual void updateArticulationJoint(Dy::ArticulationV* articulation, const IG::NodeIndex& nodeIndex) = 0; |
117 | virtual void gpuDmabackData(PxsTransformCache& cache, Bp::BoundsArray& boundArray, Cm::BitMapPinned& changedAABBMgrHandles) = 0; |
118 | virtual void udpateScBodyAndShapeSim(PxsTransformCache& cache, Bp::BoundsArray& boundArray, PxBaseTask* continuation) = 0; |
119 | virtual PxU32* getActiveBodies() = 0; |
120 | virtual PxU32* getDeactiveBodies() = 0; |
121 | virtual void** getRigidBodies() = 0; |
122 | virtual PxU32 getNbBodies() = 0; |
123 | |
124 | virtual PxU32* getUnfrozenShapes() = 0; |
125 | virtual PxU32* getFrozenShapes() = 0; |
126 | virtual PxsShapeSim** getShapeSims() = 0; |
127 | virtual PxU32 getNbFrozenShapes() = 0; |
128 | virtual PxU32 getNbUnfrozenShapes() = 0; |
129 | |
130 | virtual void clear() = 0; |
131 | virtual void setBounds(Bp::BoundsArray* boundArray) = 0; |
132 | virtual void reserve(const PxU32 nbBodies) = 0; |
133 | |
134 | virtual PxU32 getArticulationRemapIndex(const PxU32 nodeIndex) = 0; |
135 | |
136 | protected: |
137 | PxsSimulationControllerCallback* mCallback; |
138 | |
139 | }; |
140 | |
141 | PxsSimulationController* createSimulationController(PxsSimulationControllerCallback* callback); |
142 | } |
143 | |
144 | #endif |
145 | |