NvBlastExtImpactDamageManager.h
Go to the documentation of this file.
1 // This code contains NVIDIA Confidential Information and is disclosed to you
2 // under a form of NVIDIA software license agreement provided separately to you.
3 //
4 // Notice
5 // NVIDIA Corporation and its licensors retain all intellectual property and
6 // proprietary rights in and to this software and related documentation and
7 // any modifications thereto. Any use, reproduction, disclosure, or
8 // distribution of this software and related documentation without an express
9 // license agreement from NVIDIA Corporation is strictly prohibited.
10 //
11 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
12 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
13 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
14 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
15 //
16 // Information and code furnished is believed to be accurate and reliable.
17 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
18 // information or for any infringement of patents or other rights of third parties that may
19 // result from its use. No license is granted by implication or otherwise under any patent
20 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
21 // This code supersedes and replaces all information previously supplied.
22 // NVIDIA Corporation products are not authorized for use as critical
23 // components in life support devices or systems without express written approval of
24 // NVIDIA Corporation.
25 //
26 // Copyright (c) 2016-2020 NVIDIA Corporation. All rights reserved.
27 
28 
29 #ifndef NVBLASTEXTIMPACTDAMAGEMANAGER_H
30 #define NVBLASTEXTIMPACTDAMAGEMANAGER_H
31 
32 #include "PxFiltering.h"
33 #include "NvPreprocessor.h"
34 
35 // Forward declarations
36 namespace physx
37 {
38 struct PxContactPair;
39 struct PxContactPairHeader;
40 }
41 
42 
43 namespace Nv
44 {
45 namespace Blast
46 {
47 
48 // Forward declarations
49 class ExtPxActor;
50 class ExtPxManager;
51 
52 
56 typedef bool(*ExtImpactDamageFunction)(void* data, ExtPxActor* actor, physx::PxShape* shape, physx::PxVec3 worldPos, physx::PxVec3 worldForce);
57 
58 
63 {
65  bool shearDamage;
66  float hardness;
73 
74 
76  isSelfCollissionEnabled(false),
77  shearDamage(true),
78  hardness(10.0f),
79  damageRadiusMax(2.0f),
80  damageThresholdMin(0.1f), // to filter small damage events
81  damageThresholdMax(1.0f),
82  damageFalloffRadiusFactor(2.0f),
83  damageFunction(nullptr),
84  damageFunctionData(nullptr)
85  {}
86 };
87 
88 
97 {
98 public:
100 
109  static ExtImpactDamageManager* create(ExtPxManager* pxManager, ExtImpactSettings settings = ExtImpactSettings());
110 
114  virtual void release() = 0;
115 
116 
118 
124  virtual void setSettings(const ExtImpactSettings& settings) = 0;
125 
139  virtual void onContact(const physx::PxContactPairHeader& pairHeader, const physx::PxContactPair* pairs, uint32_t nbPairs) = 0;
140 
141 
145  virtual void applyDamage() = 0;
146 
147 
149 
156  static physx::PxFilterFlags FilterShader(
157  physx::PxFilterObjectAttributes attributes0,
158  physx::PxFilterData filterData0,
159  physx::PxFilterObjectAttributes attributes1,
160  physx::PxFilterData filterData1,
161  physx::PxPairFlags& pairFlags,
162  const void* constantBlock,
163  uint32_t constantBlockSize);
164 
165 };
166 
167 } // namespace Blast
168 } // namespace Nv
169 
170 
171 #endif // ifndef NVBLASTEXTIMPACTDAMAGEMANAGER_H
Definition: NvBlastExtApexSharedParts.h:34
bool(* ExtImpactDamageFunction)(void *data, ExtPxActor *actor, physx::PxShape *shape, physx::PxVec3 worldPos, physx::PxVec3 worldForce)
Definition: NvBlastExtImpactDamageManager.h:56
float damageFalloffRadiusFactor
damage attenuation radius factor. Given a radius R for full damage, for [R, R * damageFalloffRadiusFa...
Definition: NvBlastExtImpactDamageManager.h:70
float damageRadiusMax
the maximum radius in which full damage is applied.
Definition: NvBlastExtImpactDamageManager.h:67
float hardness
hardness of material for impact damage. Damage = impulse / hardness . This damage is capped by the ma...
Definition: NvBlastExtImpactDamageManager.h:66
Definition: NvBlastExtImpactDamageManager.h:96
Definition: NvBlastExtImpactDamageManager.h:62
#define NV_DLL_EXPORT
Definition: NvPreprocessor.h:293
ExtImpactDamageFunction damageFunction
custom damage function, can be nullptr, default internal one will be used in that case...
Definition: NvBlastExtImpactDamageManager.h:71
float damageThresholdMax
maximum damage fraction threshold to be applied. Range [0, 1]. For example 0.8 won't allow more then ...
Definition: NvBlastExtImpactDamageManager.h:69
Definition: NvBlastExtPxActor.h:57
void * damageFunctionData
data to be passed in custom damage function.
Definition: NvBlastExtImpactDamageManager.h:72
float damageThresholdMin
minimum damage fraction threshold to be applied. Range [0, 1]. For example 0.1 filters all damage bel...
Definition: NvBlastExtImpactDamageManager.h:68
Definition: NvBlastExtPxManager.h:99
bool isSelfCollissionEnabled
family's self collision enabled.
Definition: NvBlastExtImpactDamageManager.h:64
ExtImpactSettings()
Definition: NvBlastExtImpactDamageManager.h:75
Definition: NvBlastArray.h:37
bool shearDamage
use shear damage program (otherwise simple radial damage is used)
Definition: NvBlastExtImpactDamageManager.h:65