Subversion Repository Public Repository

Divide-Dependencies

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//  * Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
//  * Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
//  * Neither the name of NVIDIA CORPORATION nor the names of its
//    contributors may be used to endorse or promote products derived
//    from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2018 NVIDIA Corporation. All rights reserved.



#ifndef MIRROR_SCENE_IMPL_H

#define MIRROR_SCENE_IMPL_H

#include "PhysXSDKVersion.h"

#if PX_PHYSICS_VERSION_MAJOR == 3

#include "MirrorScene.h"
#include "PsUserAllocated.h"
#include "PsMutex.h"
#include "PxSimulationEventCallback.h"
#include "PxClient.h"
#include "PsHashMap.h"
#include "PxDeletionListener.h"
#include "PxTransform.h"
#include "PsArray.h"

namespace nvidia
{
	namespace apex
	{
		class MirrorSceneImpl;
		class MirrorActor;

		enum MirrorCommandType
		{
			MCT_CREATE_ACTOR,
			MCT_RELEASE_ACTOR,
			MCT_UPDATE_POSE,
			MCT_LAST
		};

		class MirrorCommand
		{
		public:
			MirrorCommand(MirrorCommandType type,MirrorActor *ma)
			{
				mType = type;
				mMirrorActor = ma;
			}
			MirrorCommand(MirrorCommandType type,MirrorActor *ma,const PxTransform &pose)
			{
				mType = type;
				mMirrorActor = ma;
				mPose = pose;
			}
			MirrorCommandType	mType;
			MirrorActor			*mMirrorActor;
			PxTransform	mPose;
		};

		class MirrorActor : public shdfnd::UserAllocated
		{
		public:

			// The constructor is only ever called from the PrimaryScene thread
			MirrorActor(size_t actorHash,physx::PxRigidActor &actor,MirrorSceneImpl &parentScene);
			// The destructor is only ever called from the MirrorSceneImpl thread
			virtual ~MirrorActor(void);

			// Increments the reference count for the number of shapes on this actor
			// currently inside the trigger volume.
			// Only ever called from the primary scene thread
			void addShape(void)
			{
				mShapeCount++;
			}

			// Decrements the reference count for the number of shapes on this actor
			// which are currently in the trigger volume. 
			// If the reference count goes to zero, then no part of this actor is 
			// any longer inside the trigger volume and it's mirror should in turn be released
			// This is only ever called from the PrimaryScene thread
			bool removeShape(void)
			{
				mShapeCount--;
				return mShapeCount == 0;
			}

			// This method is called when the reference count goes to zero and/or the primary
			// actor is released.
			// This method posts on the MirrorSceneImpl thread queue for this object to be deleted
			// the next time it does an update.
			// At this point the primary scene should remove this actor from the hash table.
			void release(void);


			// Required by the PxObserver class we inherited
			virtual	uint32_t getObjectSize()const
			{
				return sizeof(MirrorActor);
			}
	
			// This method is only called by the PrimaryScene thread
			// If the pose of the actor we are mirroring has 
			void synchronizePose(void); // called from the primary scene thread; see if the pose of the mirrored actor has changed.

			void createActor(PxScene &scene);
			void updatePose(const PxTransform &pose);

			MirrorSceneImpl		&mMirrorScene;
			uint32_t			mShapeCount;
			uint32_t			mMirrorShapeCount;
			PxRigidActor	*mPrimaryActor;
			PxRigidActor	*mMirrorActor;
			bool			mReleasePosted;
			PxTransform		mPrimaryGlobalPose;
			size_t	mActorHash;	// hash in primary scene.

		private:
			MirrorActor& operator=(const MirrorActor&);
		};

		typedef nvidia::Array< MirrorCommand > MirrorCommandArray;

		class MirrorSceneImpl : public MirrorScene, public shdfnd::UserAllocated,
			public physx::PxSimulationEventCallback, physx::PxDeletionListener
		{
		public:

			typedef shdfnd::HashMap< size_t, MirrorActor * > ActorHash;
			typedef shdfnd::HashMap< size_t, MirrorActor * > ShapeHash;

			enum ActorChange
			{
				AC_DELETED,
				AC_FOUND,
				AC_LOST
			};

			MirrorSceneImpl(physx::PxScene &primaryScene,
				physx::PxScene &mirrorScene,
				MirrorScene::MirrorFilter &mirrorFilter,
				float mirrorStaticDistance,
				float mirrorDynamicDistance,
				float mirrorDistanceThreshold);

			MirrorScene::MirrorFilter & getMirrorFilter(void) const
			{
				return mMirrorFilter;
			}

			virtual void synchronizePrimaryScene(const PxVec3 &cameraPos);
			virtual void synchronizeMirrorScene(void);

			virtual void release(void);

			void postCommand(const MirrorCommand &mc);


			/**
			physx::PxSimulationEventCallback interface
			*/
			virtual void onConstraintBreak(physx::PxConstraintInfo* constraints, uint32_t count);
			virtual void onWake(PxActor** actors, uint32_t count);
			virtual void onSleep(PxActor** actors, uint32_t count);
			virtual void onContact(const physx::PxContactPairHeader& pairHeader, const physx::PxContactPair* pairs, uint32_t nbPairs);
			virtual void onTrigger(physx::PxTriggerPair* pairs, uint32_t count);
			virtual void onAdvance(const PxRigidBody*const* bodyBuffer, const PxTransform* poseBuffer, const PxU32 count);

			// This is a notification even that the PrimayScene actor we are mirroring has been
			// deleted.  If this is the case, we need to zero out PrimaryActor pointer so we
			// no longer attempt to access it.
			// However...we do not call release, because we should get trigger events which cause
			// the reference count to go to zero.
			virtual void onRelease(const PxBase* observed,
				void* userData,
				physx::PxDeletionEventFlag::Enum deletionEvent);



		protected:
			virtual ~MirrorSceneImpl(void);
		private:

			void mirrorShape(const physx::PxTriggerPair &tp);

			void createTriggerActor(const PxVec3 &cameraPosition);

			physx::PxScene				&mPrimaryScene;
			physx::PxScene				&mMirrorScene;
			MirrorScene::MirrorFilter &mMirrorFilter;
			float				mMirrorStaticDistance;
			float				mMirrorDynamicDistance;
			float				mMirrorDistanceThreshold;
			PxVec3				mLastCameraLocation;
			physx::PxRigidDynamic		*mTriggerActor;
			PxMaterial			*mTriggerMaterial;
			physx::PxShape				*mTriggerShapeStatic;
			physx::PxShape				*mTriggerShapeDynamic;
			ActorHash					mActors;
			ShapeHash					mShapes;
			shdfnd::Mutex		mMirrorCommandMutex;
			MirrorCommandArray			mMirrorCommands;
			physx::PxSimulationEventCallback	*mSimulationEventCallback;
			nvidia::Array< physx::PxTriggerPair > mTriggerPairs;
		};

	}; // end of apex namespace
}; // end of physx namespace

#endif // PX_PHYSICS_VERSION_MAJOR

#endif // MIRROR_SCENE_IMPL_H

Commits for Divide-Dependencies/physx/APEX_1.4/framework/include/MirrorSceneImpl.h

Diff revisions: vs.
Revision Author Commited Message
105 IonutCava picture IonutCava Tue 16 Apr, 2019 19:55:41 +0000

Forgot to actually add physx