Main Page Class List Class Members

NvBlastExtStressSolver.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 NVBLASTEXTSTRESSSOLVER_H
30 #define NVBLASTEXTSTRESSSOLVER_H
31
32 #include "NvBlastTypes.h"
33 #include "NvCTypes.h"
34
35
36 namespace Nv
37 {
38 namespace Blast
39 {
40
41
56 struct ExtStressSolverSettings
57 {
58 float hardness;
59 float stressLinearFactor;
60 float stressAngularFactor;
61 uint32_t bondIterationsPerFrame;
62 uint32_t graphReductionLevel;
63
64 ExtStressSolverSettings() :
65 hardness(1000.0f),
66 stressLinearFactor(0.25f),
67 stressAngularFactor(0.75f),
68 bondIterationsPerFrame(18000),
69 graphReductionLevel(3)
70 {}
71 };
72
73
79 struct ExtForceMode
80 {
81 enum Enum
82 {
83 IMPULSE,
84 VELOCITY,
85 };
86 };
87
88
104 class NV_DLL_EXPORT ExtStressSolver
105 {
106 public:
108
117 static ExtStressSolver* create(NvBlastFamily& family, ExtStressSolverSettings settings = ExtStressSolverSettings());
118
119
121
125 virtual void release() = 0;
126
138 virtual void setNodeInfo(uint32_t graphNodeIndex, float mass, float volume, NvcVec3 localPosition, bool isStatic) = 0;
139
147 virtual void setAllNodesInfoFromLL(float density = 1.0f) = 0;
148
156 virtual void setSettings(const ExtStressSolverSettings& settings) = 0;
157
163 virtual const ExtStressSolverSettings& getSettings() const = 0;
164
174 virtual bool notifyActorCreated(const NvBlastActor& actor) = 0;
175
183 virtual void notifyActorDestroyed(const NvBlastActor& actor) = 0;
184
195 virtual bool addForce(const NvBlastActor& actor, NvcVec3 localPosition, NvcVec3 localForce, ExtForceMode::Enum mode = ExtForceMode::IMPULSE) = 0;
196
204 virtual void addForce(uint32_t graphNodeIndex, NvcVec3 localForce, ExtForceMode::Enum mode = ExtForceMode::IMPULSE) = 0;
205
214 virtual bool addGravityForce(const NvBlastActor& actor, NvcVec3 localGravity) = 0;
215
225 virtual bool addAngularVelocity(const NvBlastActor& actor, NvcVec3 localCenterMass, NvcVec3 localAngularVelocity) = 0;
226
232 virtual void update() = 0;
233
241 virtual uint32_t getOverstressedBondCount() const = 0;
242
255 virtual void generateFractureCommands(const NvBlastActor& actor, NvBlastFractureBuffers& commands) = 0;
256
267 virtual void generateFractureCommands(NvBlastFractureBuffers& commands) = 0;
268
285 virtual uint32_t generateFractureCommandsPerActor(const NvBlastActor** actorBuffer, NvBlastFractureBuffers* commandsBuffer, uint32_t bufferSize) = 0;
286
293 virtual void reset() = 0;
294
300 virtual float getStressErrorLinear() const = 0;
301
307 virtual float getStressErrorAngular() const = 0;
308
314 virtual uint32_t getFrameCount() const = 0;
315
321 virtual uint32_t getBondCount() const = 0;
322
323
327 enum DebugRenderMode
328 {
329 STRESS_GRAPH = 0,
330 STRESS_GRAPH_NODES_IMPULSES = 1,
331 STRESS_GRAPH_BONDS_IMPULSES = 2
332 };
333
337 struct DebugLine
338 {
339 DebugLine(const NvcVec3& p0, const NvcVec3& p1, const uint32_t& c)
340 : pos0(p0), color0(c), pos1(p1), color1(c) {}
341
342 NvcVec3 pos0;
343 uint32_t color0;
344 NvcVec3 pos1;
345 uint32_t color1;
346 };
347
351 struct DebugBuffer
352 {
353 const DebugLine* lines;
354 uint32_t lineCount;
355 };
356
369 virtual const DebugBuffer fillDebugRender(const uint32_t* nodes, uint32_t nodeCount, DebugRenderMode mode, float scale = 1.0f) = 0;
370
371
373
385 static uint32_t getIterationsPerFrame(const ExtStressSolverSettings& settings, uint32_t bondCount)
386 {
387 uint32_t perFrame = settings.bondIterationsPerFrame / (bondCount + 1);
388 return perFrame > 0 ? perFrame : 1;
389 }
390
398 uint32_t getIterationsPerFrame() const
399 {
400 return getIterationsPerFrame(getSettings(), getBondCount());
401 }
402
403 };
404
405 } // namespace Blast
406 } // namespace Nv
407
408
409 #endif // ifndef NVBLASTEXTSTRESSSOLVER_H
Nv::Blast::ExtStressSolver::DebugLine::color1
uint32_t color1
Definition: NvBlastExtStressSolver.h:345
Nv::Blast::ExtStressSolverSettings::graphReductionLevel
uint32_t graphReductionLevel
graph reduction level
Definition: NvBlastExtStressSolver.h:62
Nv::Blast::ExtStressSolverSettings::bondIterationsPerFrame
uint32_t bondIterationsPerFrame
number of bond iterations to perform per frame,
Definition: NvBlastExtStressSolver.h:61
Nv::Blast::ExtForceMode::IMPULSE
parameter has unit of mass * distance /time
Definition: NvBlastExtStressSolver.h:83
Nv::Blast::ExtStressSolver::DebugLine::pos0
NvcVec3 pos0
Definition: NvBlastExtStressSolver.h:342
Nv::Blast::ExtStressSolverSettings
Definition: NvBlastExtStressSolver.h:56
Nv::Blast::ExtStressSolver::DebugBuffer::lines
const DebugLine * lines
Definition: NvBlastExtStressSolver.h:353
NvBlastTypes.h
Nv::Blast::ExtStressSolver::getIterationsPerFrame
uint32_t getIterationsPerFrame() const
Definition: NvBlastExtStressSolver.h:398
Nv::Blast::ExtStressSolverSettings::stressAngularFactor
float stressAngularFactor
angular stress on bond multiplier
Definition: NvBlastExtStressSolver.h:60
Nv::Blast::ExtStressSolver::DebugLine
Definition: NvBlastExtStressSolver.h:337
Nv::Blast::ExtStressSolverSettings::ExtStressSolverSettings
ExtStressSolverSettings()
Definition: NvBlastExtStressSolver.h:64
Nv::Blast::ExtStressSolverSettings::hardness
float hardness
hardness of bond&#39;s material
Definition: NvBlastExtStressSolver.h:58
Nv::Blast::ExtStressSolver::getIterationsPerFrame
static uint32_t getIterationsPerFrame(const ExtStressSolverSettings &settings, uint32_t bondCount)
Definition: NvBlastExtStressSolver.h:385
Nv::Blast::ExtStressSolver::DebugBuffer::lineCount
uint32_t lineCount
Definition: NvBlastExtStressSolver.h:354
Nv::Blast::ExtStressSolver::DebugLine::color0
uint32_t color0
Definition: NvBlastExtStressSolver.h:343
Nv::Blast::ExtStressSolver::DebugRenderMode
DebugRenderMode
Definition: NvBlastExtStressSolver.h:327
Nv::Blast::ExtStressSolver
Definition: NvBlastExtStressSolver.h:104
Nv::Blast::ExtStressSolver::DebugLine::pos1
NvcVec3 pos1
Definition: NvBlastExtStressSolver.h:344
Nv::Blast::ExtStressSolver::DebugLine::DebugLine
DebugLine(const NvcVec3 &p0, const NvcVec3 &p1, const uint32_t &c)
Definition: NvBlastExtStressSolver.h:339
Nv::Blast::ExtForceMode::VELOCITY
parameter has unit of distance / time, i.e. the effect is mass independent: a velocity change...
Definition: NvBlastExtStressSolver.h:84
Nv::Blast::ExtForceMode
Definition: NvBlastExtStressSolver.h:79
Nv::Blast::ExtForceMode::Enum
Enum
Definition: NvBlastExtStressSolver.h:81
NvBlastFractureBuffers
Definition: NvBlastTypes.h:468
Nv
Definition: NvBlastExtAuthoring.h:34
NvcVec3
Definition: NvCTypes.h:49
Nv::Blast::ExtStressSolver::DebugBuffer
Definition: NvBlastExtStressSolver.h:351
NvBlastActor
Definition: NvBlastTypes.h:387
Nv::Blast::ExtStressSolverSettings::stressLinearFactor
float stressLinearFactor
linear stress on bond multiplier
Definition: NvBlastExtStressSolver.h:59
NvCTypes.h
NvBlastFamily
Definition: NvBlastTypes.h:376