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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
//
// 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 __DESTRUCTIBLEACTOR_PROXY_H__
#define __DESTRUCTIBLEACTOR_PROXY_H__

#include "Apex.h"
#include "DestructibleActor.h"
#include "DestructibleActorJointProxy.h"
#include "DestructibleActorImpl.h"
#include "DestructibleScene.h"
#include "PsUserAllocated.h"
#include "ApexActor.h"
#if APEX_USE_PARTICLES
#include "EmitterActor.h"
#endif

#include "ApexRWLockable.h"
#include "ReadCheck.h"
#include "WriteCheck.h"

namespace nvidia
{
namespace destructible
{

class DestructibleActorProxy : public DestructibleActor, public ApexResourceInterface, public UserAllocated, public ApexRWLockable
{
public:
	APEX_RW_LOCKABLE_BOILERPLATE

	DestructibleActorImpl impl;

#pragma warning(disable : 4355) // disable warning about this pointer in argument list
	DestructibleActorProxy(const NvParameterized::Interface& input, DestructibleAssetImpl& asset, ResourceList& list, DestructibleScene& scene)
		: impl(this, asset, scene)
	{
		WRITE_ZONE();
		NvParameterized::Interface* clonedInput = NULL;
		input.clone(clonedInput);
		list.add(*this);	// Doing this before impl.initialize, since the render proxy created in that function wants a unique ID (only needs to be unique at any given time, can be recycled)
		impl.initialize(clonedInput);
	}

	DestructibleActorProxy(NvParameterized::Interface* input, DestructibleAssetImpl& asset, ResourceList& list, DestructibleScene& scene)
		: impl(this, asset, scene)
	{
		WRITE_ZONE();
		impl.initialize(input);
		list.add(*this);
	}

	~DestructibleActorProxy()
	{
	}

	virtual const DestructibleParameters& getDestructibleParameters() const
	{
		READ_ZONE();
		return impl.getDestructibleParameters();
	}

	virtual void setDestructibleParameters(const DestructibleParameters& destructibleParameters)
	{
		WRITE_ZONE();
		impl.setDestructibleParameters(destructibleParameters);
	}

	virtual const RenderMeshActor* getRenderMeshActor(DestructibleActorMeshType::Enum type = DestructibleActorMeshType::Skinned) const
	{
		READ_ZONE();
		return impl.getRenderMeshActor(type);
	}

	virtual PxMat44	getInitialGlobalPose() const
	{
		READ_ZONE();
		return impl.getInitialGlobalPose();
	}

	virtual void setInitialGlobalPose(const PxMat44& pose)
	{
		WRITE_ZONE();
		impl.setInitialGlobalPose(pose);
	}

	virtual PxVec3	getScale() const
	{
		READ_ZONE();
		return impl.getScale();
	}

	virtual void	applyDamage(float damage, float momentum, const PxVec3& position, const PxVec3& direction, int32_t chunkIndex = ModuleDestructibleConst::INVALID_CHUNK_INDEX, void* damageActorUserData = NULL)
	{
		WRITE_ZONE();
		return impl.applyDamage(damage, momentum, position, direction, chunkIndex, damageActorUserData);
	}

	virtual void	applyRadiusDamage(float damage, float momentum, const PxVec3& position, float radius, bool falloff, void* damageActorUserData = NULL)
	{
		WRITE_ZONE();
		return impl.applyRadiusDamage(damage, momentum, position, radius, falloff, damageActorUserData);
	}	

	virtual void	getChunkVisibilities(uint8_t* visibilityArray, uint32_t visibilityArraySize) const
	{
		READ_ZONE();
		impl.getChunkVisibilities(visibilityArray, visibilityArraySize);
	}

	virtual uint32_t	getNumVisibleChunks() const
	{
		READ_ZONE();
		return impl.getNumVisibleChunks();
	}

	virtual const uint16_t*	getVisibleChunks() const
	{
		READ_ZONE();
		return impl.getVisibleChunks();
	}

	virtual bool					acquireChunkEventBuffer(const DestructibleChunkEvent*& buffer, uint32_t& bufferSize)
	{
		READ_ZONE();
		return impl.acquireChunkEventBuffer(buffer, bufferSize);
	}

	virtual bool					releaseChunkEventBuffer(bool clearBuffer = true)
	{
		READ_ZONE();
		return impl.releaseChunkEventBuffer(clearBuffer);
	}

	virtual bool					acquirePhysXActorBuffer(physx::PxRigidDynamic**& buffer, uint32_t& bufferSize, uint32_t flags = DestructiblePhysXActorQueryFlags::AllStates)
	{
		READ_ZONE();
		return impl.acquirePhysXActorBuffer(buffer, bufferSize, flags);
	}

	virtual bool					releasePhysXActorBuffer()
	{
		READ_ZONE();
		return impl.releasePhysXActorBuffer();
	}

	virtual physx::PxRigidDynamic*	getChunkPhysXActor(uint32_t index)
	{
		READ_ZONE();
		physx::PxActor* actor = impl.getChunkActor(index);
		PX_ASSERT(actor == NULL || actor->is<physx::PxRigidDynamic>());
		return (physx::PxRigidDynamic*)actor;
	}

	virtual uint32_t		getChunkPhysXShapes(physx::PxShape**& shapes, uint32_t chunkIndex) const
	{
		READ_ZONE();
		return impl.getChunkPhysXShapes(shapes, chunkIndex);
	}

	virtual PxTransform		getChunkPose(uint32_t index) const
	{
		READ_ZONE();
		return impl.getChunkPose(index);
	}

	virtual PxTransform		getChunkTransform(uint32_t index) const
	{
		READ_ZONE();
		return impl.getChunkTransform(index);
	}

	virtual PxVec3			getChunkLinearVelocity(uint32_t index) const
	{
		READ_ZONE();
		return impl.getChunkLinearVelocity(index);
	}

	virtual PxVec3			getChunkAngularVelocity(uint32_t index) const
	{
		READ_ZONE();
		return impl.getChunkAngularVelocity(index);
	}

	virtual const PxMat44	getChunkTM(uint32_t index) const
	{
		READ_ZONE();
		return impl.getChunkTM(index);
	}

	virtual int32_t			getChunkBehaviorGroupIndex(uint32_t chunkIndex) const
	{
		READ_ZONE();
		return impl.getBehaviorGroupIndex(chunkIndex);
	}

	virtual uint32_t		 	getChunkActorFlags(uint32_t chunkIndex) const
	{
		READ_ZONE();
		return impl.getChunkActorFlags(chunkIndex);
	}

	virtual bool					isChunkDestroyed(int32_t chunkIndex) const
	{
		READ_ZONE();
		return impl.isChunkDestroyed((uint32_t)chunkIndex);
	}

	virtual void			setSkinnedOverrideMaterial(uint32_t index, const char* overrideMaterialName)
	{
		WRITE_ZONE();
		impl.setSkinnedOverrideMaterial(index, overrideMaterialName);
	}

	virtual void			setStaticOverrideMaterial(uint32_t index, const char* overrideMaterialName)
	{
		WRITE_ZONE();
		impl.setStaticOverrideMaterial(index, overrideMaterialName);
	}

	virtual void			setRuntimeFractureOverridePattern(const char* overridePatternName)
	{
		WRITE_ZONE();
		impl.setRuntimeFracturePattern(overridePatternName);
	}

	virtual bool			isInitiallyDynamic() const
	{
		READ_ZONE();
		return impl.isInitiallyDynamic();
	}

	virtual void			setLinearVelocity(const PxVec3& linearVelocity)
	{
		WRITE_ZONE();
		impl.setLinearVelocity(linearVelocity);
	}

	virtual void			setGlobalPose(const PxMat44& pose)
	{
		WRITE_ZONE();
		impl.setGlobalPose(pose);
	}

	virtual bool			getGlobalPose(PxMat44& pose)
	{
		READ_ZONE();
		return impl.getGlobalPoseForStaticChunks(pose);
	}

	virtual void			setAngularVelocity(const PxVec3& angularVelocity)
	{
		WRITE_ZONE();
		impl.setAngularVelocity(angularVelocity);
	}

	virtual void setDynamic(int32_t chunkIndex = ModuleDestructibleConst::INVALID_CHUNK_INDEX)
	{
		WRITE_ZONE();
		impl.setDynamic(chunkIndex);
	}

	virtual bool isDynamic(uint32_t chunkIndex) const
	{
		READ_ZONE();
		if (impl.getDestructibleAsset() != NULL && chunkIndex < impl.getDestructibleAsset()->getChunkCount())
		{
			return impl.getDynamic((int32_t)chunkIndex);
		}
		return false;
	}

	virtual void enableHardSleeping()
	{
		WRITE_ZONE();
		impl.enableHardSleeping();
	}

	virtual void disableHardSleeping(bool wake = false)
	{
		WRITE_ZONE();
		impl.disableHardSleeping(wake);
	}

	virtual bool isHardSleepingEnabled() const
	{
		READ_ZONE();
		return impl.useHardSleeping();
	}

	virtual	bool setChunkPhysXActorAwakeState(uint32_t chunkIndex, bool awake)
	{
		WRITE_ZONE();
		return impl.setChunkPhysXActorAwakeState(chunkIndex, awake);
	}

	virtual bool addForce(uint32_t chunkIndex, const PxVec3& force, physx::PxForceMode::Enum mode, const PxVec3* position = NULL, bool wakeup = true)
	{
		WRITE_ZONE();
		return impl.addForce(chunkIndex, force, mode, position, wakeup);
	}

	virtual int32_t			rayCast(float& time, PxVec3& normal, const PxVec3& worldRayOrig, const PxVec3& worldRayDir, DestructibleActorRaycastFlags::Enum flags, int32_t parentChunkIndex = ModuleDestructibleConst::INVALID_CHUNK_INDEX) const
	{
		READ_ZONE();
		return impl.rayCast(time, normal, worldRayOrig, worldRayDir, flags, parentChunkIndex);
	}

	virtual int32_t			obbSweep(float& time, PxVec3& normal, const PxVec3& worldBoxCenter, const PxVec3& worldBoxExtents, const PxMat33& worldBoxRot, const PxVec3& worldDisplacement, DestructibleActorRaycastFlags::Enum flags) const
	{
		READ_ZONE();
		return impl.obbSweep(time, normal, worldBoxCenter, worldBoxExtents, worldBoxRot, worldDisplacement, flags);
	}

	virtual void cacheModuleData() const
	{
		READ_ZONE();
		return impl.cacheModuleData();
	}

	virtual PxBounds3		getLocalBounds() const
	{
		READ_ZONE();
		return impl.getLocalBounds();
	}

	virtual PxBounds3		getOriginalBounds() const
	{ 
		READ_ZONE();
		return impl.getOriginalBounds();
	}

	virtual bool					isChunkSolitary(int32_t chunkIndex) const
	{
		READ_ZONE();
		return impl.isChunkSolitary( chunkIndex );
	}

	virtual PxBounds3		getChunkBounds(uint32_t chunkIndex) const
	{
		READ_ZONE();
		return impl.getChunkBounds( chunkIndex );
	}

	virtual PxBounds3		getChunkLocalBounds(uint32_t chunkIndex) const
	{
		READ_ZONE();
		return impl.getChunkLocalBounds( chunkIndex );
	}

	virtual uint32_t			getSupportDepthChunkIndices(uint32_t* const OutChunkIndices, uint32_t MaxOutIndices) const
	{
		READ_ZONE();
		return impl.getSupportDepthChunkIndices( OutChunkIndices, MaxOutIndices );
	}

	virtual uint32_t			getSupportDepth() const
	{ 
		READ_ZONE();
		return impl.getSupportDepth();
	}

	// Actor methods
	virtual Asset* getOwner() const
	{
		READ_ZONE();
		return impl.mAsset->getAsset();
	}
	virtual void release()
	{
		impl.release();
	}
	virtual void destroy()
	{
		impl.destroy();

		delete this;
	}

	virtual DestructibleRenderable* acquireRenderableReference()
	{
		return impl.acquireRenderableReference();
	}

	// Renderable methods
	virtual void updateRenderResources(bool rewriteBuffers, void* userRenderData)
	{
		URR_SCOPE;
		impl.updateRenderResources(rewriteBuffers, userRenderData);
	}

	virtual void dispatchRenderResources(UserRenderer& api)
	{
		impl.dispatchRenderResources(api);
	}

	virtual void lockRenderResources()
	{
		Renderable* renderable = impl.getRenderable();
		if (renderable != NULL)
		{
			renderable->lockRenderResources();
		}
	}

	virtual void unlockRenderResources()
	{
		Renderable* renderable = impl.getRenderable();
		if (renderable != NULL)
		{
			renderable->unlockRenderResources();
		}
	}

	virtual PxBounds3 getBounds() const
	{
		READ_ZONE();
		Renderable* renderable = const_cast<DestructibleActorImpl*>(&impl)->getRenderable();
		if (renderable != NULL)
		{
			return renderable->getBounds();
		}
		return impl.getBounds();
	}

	virtual void setPhysX3Template(const PhysX3DescTemplate* desc)
	{
		WRITE_ZONE();
		impl.setPhysX3Template(desc);
	}

	virtual bool getPhysX3Template(PhysX3DescTemplate& dest) const
	{
		READ_ZONE();
		return impl.getPhysX3Template(dest);
	}

	PhysX3DescTemplate* createPhysX3DescTemplate() const
	{
		return impl.createPhysX3DescTemplate();
	}

	// ApexResourceInterface methods
	virtual void	setListIndex(ResourceList& list, uint32_t index)
	{
		WRITE_ZONE();
		impl.m_listIndex = index;
		impl.m_list = &list;
	}
	virtual uint32_t	getListIndex() const
	{
		READ_ZONE();
		return impl.m_listIndex;
	}

	virtual void getLodRange(float& min, float& max, bool& intOnly) const
	{
		READ_ZONE();
		impl.getLodRange(min, max, intOnly);
	}

	virtual float getActiveLod() const
	{
		READ_ZONE();
		return impl.getActiveLod();
	}

	virtual void forceLod(float lod)
	{
		WRITE_ZONE();
		impl.forceLod(lod);
	}

	/**
	\brief Selectively enables/disables debug visualization of a specific APEX actor.  Default value it true.
	*/
	virtual void setEnableDebugVisualization(bool state)
	{
		WRITE_ZONE();
		impl.setEnableDebugVisualization(state);
	}


	virtual void setCrumbleEmitterState(bool enable)
	{
		WRITE_ZONE();
		impl.setCrumbleEmitterEnabled(enable);
	}

	virtual void setDustEmitterState(bool enable)
	{
		WRITE_ZONE();
		impl.setDustEmitterEnabled(enable);
	}

	/**
		Sets a preferred render volume for a dust or crumble emitter
	*/
	virtual void setPreferredRenderVolume(RenderVolume* volume, DestructibleEmitterType::Enum type)
	{
		WRITE_ZONE();
		impl.setPreferredRenderVolume(volume, type);
	}

	virtual EmitterActor* getApexEmitter(DestructibleEmitterType::Enum type)
	{
		READ_ZONE();
		return impl.getApexEmitter(type);
	}

	virtual bool recreateApexEmitter(DestructibleEmitterType::Enum type)
	{
		WRITE_ZONE();
		return impl.recreateApexEmitter(type);
	}

	const NvParameterized::Interface* getNvParameterized(DestructibleParameterizedType::Enum type) const
	{
		READ_ZONE();
		switch (type) 
		{
		case DestructibleParameterizedType::State:
			return (const NvParameterized::Interface*)impl.getState();
		case DestructibleParameterizedType::Params:
			return (const NvParameterized::Interface*)impl.getParams();
		default:
			return NULL;
		}
	}

	void setNvParameterized(NvParameterized::Interface* params)
	{
		WRITE_ZONE();
		impl.initialize(params);
	}

	const NvParameterized::Interface* getChunks() const
	{
		return (const NvParameterized::Interface*)impl.getChunks();
	}

	void setChunks(NvParameterized::Interface* chunks)
	{
		impl.initialize(chunks);
	}

    virtual bool setSyncParams(uint32_t userActorID, uint32_t actorSyncFlags, const DestructibleActorSyncState * actorSyncState, const DestructibleChunkSyncState * chunkSyncState)
    {
		WRITE_ZONE();
        return impl.setSyncParams(userActorID, actorSyncFlags, actorSyncState, chunkSyncState);
    }

	virtual bool setHitChunkTrackingParams(bool flushHistory, bool startTracking, uint32_t trackingDepth, bool trackAllChunks)
	{
		WRITE_ZONE();
		return impl.setHitChunkTrackingParams(flushHistory, startTracking, trackingDepth, trackAllChunks);
	}

	virtual bool getHitChunkHistory(const DestructibleHitChunk *& hitChunkContainer, uint32_t & hitChunkCount) const
	{
		READ_ZONE();
		return impl.getHitChunkHistory(hitChunkContainer, hitChunkCount);
	}

	virtual bool forceChunkHits(const DestructibleHitChunk * hitChunkContainer, uint32_t hitChunkCount, bool removeChunks = true, bool deferredEvent = false, PxVec3 damagePosition = PxVec3(0.0f), PxVec3 damageDirection = PxVec3(0.0f))
	{
		WRITE_ZONE();
		return impl.forceChunkHits(hitChunkContainer, hitChunkCount, removeChunks, deferredEvent, damagePosition, damageDirection);
	}

	virtual bool getDamageColoringHistory(const DamageEventCoreData *& damageEventCoreDataContainer, uint32_t & damageEventCoreDataCount) const
	{
		READ_ZONE();
		return impl.getDamageColoringHistory(damageEventCoreDataContainer, damageEventCoreDataCount);
	}

	virtual bool forceDamageColoring(const DamageEventCoreData * damageEventCoreDataContainer, uint32_t damageEventCoreDataCount)
	{
		WRITE_ZONE();
		return impl.forceDamageColoring(damageEventCoreDataContainer, damageEventCoreDataCount);
	}

	virtual void setDeleteFracturedChunks(bool inDeleteChunkMode)
	{
		WRITE_ZONE();
		impl.setDeleteFracturedChunks(inDeleteChunkMode);
	}

	virtual void takeImpact(const PxVec3& force, const PxVec3& position, uint16_t chunkIndex, PxActor const* damageImpactActor)
	{
		WRITE_ZONE();
		impl.takeImpact(force, position, chunkIndex, damageImpactActor);
	}

	virtual uint32_t			getCustomBehaviorGroupCount() const
	{
		READ_ZONE();
		return impl.getCustomBehaviorGroupCount();
	}

	virtual bool					getBehaviorGroup(DestructibleBehaviorGroupDesc& behaviorGroupDesc, int32_t index = -1) const
	{
		READ_ZONE();
		return impl.getBehaviorGroup(behaviorGroupDesc, index);
	}
};


}
} // end namespace nvidia

#endif // __DESTRUCTIBLEACTOR_PROXY_H__

Commits for Divide-Dependencies/physx/APEX_1.4/module/destructible/include/DestructibleActorProxy.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