sdk/extensions/stress/include/NvBlastExtStressSolver.h

Go to the documentation of this file.
00001 // This code contains NVIDIA Confidential Information and is disclosed to you
00002 // under a form of NVIDIA software license agreement provided separately to you.
00003 //
00004 // Notice
00005 // NVIDIA Corporation and its licensors retain all intellectual property and
00006 // proprietary rights in and to this software and related documentation and
00007 // any modifications thereto. Any use, reproduction, disclosure, or
00008 // distribution of this software and related documentation without an express
00009 // license agreement from NVIDIA Corporation is strictly prohibited.
00010 //
00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
00015 //
00016 // Information and code furnished is believed to be accurate and reliable.
00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
00018 // information or for any infringement of patents or other rights of third parties that may
00019 // result from its use. No license is granted by implication or otherwise under any patent
00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
00021 // This code supersedes and replaces all information previously supplied.
00022 // NVIDIA Corporation products are not authorized for use as critical
00023 // components in life support devices or systems without express written approval of
00024 // NVIDIA Corporation.
00025 //
00026 // Copyright (c) 2016-2018 NVIDIA Corporation. All rights reserved.
00027 
00028 
00029 #ifndef NVBLASTEXTSTRESSSOLVER_H
00030 #define NVBLASTEXTSTRESSSOLVER_H
00031 
00032 #include "NvBlastTypes.h"
00033 #include "PxVec3.h"
00034 #include <vector>
00035 
00036 
00037 namespace Nv
00038 {
00039 namespace Blast
00040 {
00041 
00042 
00057 struct ExtStressSolverSettings
00058 {
00059     float       hardness;                   
00060     float       stressLinearFactor;         
00061     float       stressAngularFactor;        
00062     uint32_t    bondIterationsPerFrame;     
00063     uint32_t    graphReductionLevel;        
00064 
00065     ExtStressSolverSettings() :
00066         hardness(1000.0f),
00067         stressLinearFactor(0.25f),
00068         stressAngularFactor(0.75f),
00069         bondIterationsPerFrame(18000),
00070         graphReductionLevel(3)
00071     {}
00072 };
00073 
00074 
00080 struct ExtForceMode
00081 {
00082     enum Enum
00083     {
00084         IMPULSE,    
00085         VELOCITY,   
00086     };
00087 };
00088 
00089 
00105 class NV_DLL_EXPORT ExtStressSolver
00106 {
00107 public:
00109 
00118     static ExtStressSolver*                 create(NvBlastFamily& family, ExtStressSolverSettings settings = ExtStressSolverSettings());
00119 
00120 
00122 
00126     virtual void                            release() = 0;
00127 
00139     virtual void                            setNodeInfo(uint32_t graphNodeIndex, float mass, float volume, physx::PxVec3 localPosition, bool isStatic) = 0;
00140 
00148     virtual void                            setAllNodesInfoFromLL(float density = 1.0f) = 0;
00149 
00157     virtual void                            setSettings(const ExtStressSolverSettings& settings) = 0;
00158 
00164     virtual const ExtStressSolverSettings&  getSettings() const = 0;
00165 
00175     virtual bool                            notifyActorCreated(const NvBlastActor& actor) = 0;
00176 
00184     virtual void                            notifyActorDestroyed(const NvBlastActor& actor) = 0;
00185 
00196     virtual bool                            addForce(const NvBlastActor& actor, physx::PxVec3 localPosition, physx::PxVec3 localForce, ExtForceMode::Enum mode = ExtForceMode::IMPULSE) = 0;
00197 
00205     virtual void                            addForce(uint32_t graphNodeIndex, physx::PxVec3 localForce, ExtForceMode::Enum mode = ExtForceMode::IMPULSE) = 0;
00206 
00215     virtual bool                            addGravityForce(const NvBlastActor& actor, physx::PxVec3 localGravity) = 0;
00216 
00226     virtual bool                            addAngularVelocity(const NvBlastActor& actor, physx::PxVec3 localCenterMass, physx::PxVec3 localAngularVelocity) = 0;
00227 
00233     virtual void                            update() = 0;
00234 
00242     virtual uint32_t                        getOverstressedBondCount() const = 0;
00243 
00256     virtual void                            generateFractureCommands(const NvBlastActor& actor, NvBlastFractureBuffers& commands) = 0;
00257 
00268     virtual void                            generateFractureCommands(NvBlastFractureBuffers& commands) = 0;
00269 
00286     virtual uint32_t                        generateFractureCommandsPerActor(const NvBlastActor** actorBuffer, NvBlastFractureBuffers* commandsBuffer, uint32_t bufferSize) = 0;
00287 
00294     virtual void                            reset() = 0;
00295 
00301     virtual float                           getStressErrorLinear() const = 0;
00302 
00308     virtual float                           getStressErrorAngular() const = 0;
00309 
00315     virtual uint32_t                        getFrameCount() const = 0;
00316 
00322     virtual uint32_t                        getBondCount() const = 0;
00323 
00324 
00328     enum DebugRenderMode
00329     {
00330         STRESS_GRAPH = 0,                   
00331         STRESS_GRAPH_NODES_IMPULSES = 1,    
00332         STRESS_GRAPH_BONDS_IMPULSES = 2     
00333     };
00334 
00338     struct DebugLine
00339     {
00340         DebugLine(const physx::PxVec3& p0, const physx::PxVec3& p1, const uint32_t& c)
00341             : pos0(p0), color0(c), pos1(p1), color1(c) {}
00342 
00343         physx::PxVec3   pos0;
00344         uint32_t        color0;
00345         physx::PxVec3   pos1;
00346         uint32_t        color1;
00347     };
00348 
00352     struct DebugBuffer
00353     {
00354         const DebugLine* lines;
00355         uint32_t         lineCount;
00356     };
00357 
00370     virtual const DebugBuffer               fillDebugRender(const uint32_t* nodes, uint32_t nodeCount, DebugRenderMode mode, float scale = 1.0f) = 0;
00371 
00372 
00374 
00386     static uint32_t                         getIterationsPerFrame(const ExtStressSolverSettings& settings, uint32_t bondCount)
00387     {
00388         uint32_t perFrame = settings.bondIterationsPerFrame / (bondCount + 1);
00389         return perFrame > 0 ? perFrame : 1;
00390     }
00391 
00399     uint32_t                                getIterationsPerFrame() const
00400     {
00401         return getIterationsPerFrame(getSettings(), getBondCount());
00402     }
00403 
00404 };
00405 
00406 } // namespace Blast
00407 } // namespace Nv
00408 
00409 
00410 #endif // ifndef NVBLASTEXTSTRESSSOLVER_H