Main Page Class List Class Members

- Main Page
- User's Guide
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# sdk/lowlevel/source/NvBlastFamilyGraph.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-2020 NVIDIA Corporation. All rights reserved.
    00027
    00028
    00029 #ifndef NVBLASTFAMILYGRAPH_H
    00030 #define NVBLASTFAMILYGRAPH_H
    00031
    00032
    00033 #include "NvBlastSupportGraph.h"
    00034 #include "NvBlastFixedArray.h"
    00035 #include "NvBlastFixedBitmap.h"
    00036 #include "NvBlastFixedBoolArray.h"
    00037 #include "NvBlastMath.h"
    00038 #include "NvBlastFixedPriorityQueue.h"
    00039 #include "NvBlastMemory.h"
    00040
    00041
    00042 namespace Nv
    00043 {
    00044 namespace Blast
    00045 {
    00046
    00047
    00048 typedef uint32_t NodeIndex;
    00049 typedef NodeIndex IslandId;
    00050 typedef uint32_t ActorIndex;
    00051
    00058 class FamilyGraph
    00059 {
    00060 public:
    00061
    00063
    00069     FamilyGraph(const SupportGraph* graph);
    00070
    00071
    00080     static size_t   requiredMemorySize(uint32_t nodeCount, uint32_t bondCount)
    00081     {
    00082         return fillMemory(nullptr, nodeCount, bondCount);
    00083     }
    00084
    00085
    00087
    00094     void            initialize(ActorIndex actorIndex, const SupportGraph* graph);
    00095
    00104     bool            notifyEdgeRemoved(ActorIndex actorIndex, NodeIndex node0, NodeIndex node1, const SupportGraph* graph);
    00105     bool            notifyEdgeRemoved(ActorIndex actorIndex, NodeIndex node0, NodeIndex node1, uint32_t bondIndex, const SupportGraph* graph);
    00106
    00107     bool            notifyNodeRemoved(ActorIndex actorIndex, NodeIndex nodeIndex, const SupportGraph* graph);
    00108
    00119     uint32_t        findIslands(ActorIndex actorIndex, void* scratch, const SupportGraph* graph);
    00120
    00128     static size_t   findIslandsRequiredScratch(uint32_t graphNodeCount);
    00129
    00130
    00132
    00139     NvBlastBlockData(IslandId, m_islandIdsOffset, getIslandIds);
    00140
    00144     NvBlastBlockData(NodeIndex, m_dirtyNodeLinksOffset, getDirtyNodeLinks);
    00145
    00149     NvBlastBlockData(uint32_t, m_firstDirtyNodeIndicesOffset, getFirstDirtyNodeIndices);
    00150
    00154     NvBlastBlockData(NodeIndex, m_fastRouteOffset, getFastRoute);
    00155
    00159     NvBlastBlockData(uint32_t, m_hopCountsOffset, getHopCounts);
    00160
    00164     NvBlastBlockData(FixedBoolArray, m_isEdgeRemovedOffset, getIsEdgeRemoved);
    00165
    00169     NvBlastBlockData(FixedBoolArray, m_isNodeInDirtyListOffset, getIsNodeInDirtyList);
    00170
    00171
    00173
    00174     uint32_t    getEdgesCount(const SupportGraph* graph) const;
    00175     bool        hasEdge(NodeIndex node0, NodeIndex node1, const SupportGraph* graph) const;
    00176     bool        canFindRoot(NodeIndex startNode, NodeIndex targetNode, FixedArray<NodeIndex>* visitedNodes, const SupportGraph* graph);
    00177
    00178
    00179 private:
    00180
    00181     FamilyGraph& operator = (const FamilyGraph&);
    00182
    00184
    00188     struct TraversalState
    00189     {
    00190         NodeIndex mNodeIndex;
    00191         uint32_t mCurrentIndex;
    00192         uint32_t mPrevIndex;
    00193         uint32_t mDepth;
    00194
    00195         TraversalState()
    00196         {
    00197         }
    00198
    00199         TraversalState(NodeIndex nodeIndex, uint32_t currentIndex, uint32_t prevIndex, uint32_t depth) :
    00200             mNodeIndex(nodeIndex), mCurrentIndex(currentIndex), mPrevIndex(prevIndex), mDepth(depth)
    00201         {
    00202         }
    00203     };
    00204
    00208     struct QueueElement
    00209     {
    00210         TraversalState* mState;
    00211         uint32_t mHopCount;
    00212
    00213         QueueElement()
    00214         {
    00215         }
    00216
    00217         QueueElement(TraversalState* state, uint32_t hopCount) : mState(state), mHopCount(hopCount)
    00218         {
    00219         }
    00220     };
    00221
    00225     struct NodeComparator
    00226     {
    00227         NodeComparator()
    00228         {
    00229         }
    00230
    00231         bool operator() (const QueueElement& node0, const QueueElement& node1) const
    00232         {
    00233             return node0.mHopCount < node1.mHopCount;
    00234         }
    00235     private:
    00236         NodeComparator& operator = (const NodeComparator&);
    00237     };
    00238
    00242     typedef FixedPriorityQueue<QueueElement, NodeComparator> NodePriorityQueue;
    00243
    00244
    00246
    00257     static size_t   fillMemory(FamilyGraph* familyGraph, uint32_t nodeCount, uint32_t bondCount);
    00258
    00262     bool            findRoute(NodeIndex startNode, NodeIndex targetNode, IslandId islandId, FixedArray<TraversalState>* visitedNodes, FixedBitmap* isNodeWitness, NodePriorityQueue* priorityQueue, const SupportGraph* graph);
    00263
    00267     bool            tryFastPath(NodeIndex startNode, NodeIndex targetNode, IslandId islandId, FixedArray<TraversalState>* visitedNodes, FixedBitmap* isNodeWitness, const SupportGraph* graph);
    00268
    00274     void            unwindRoute(uint32_t traversalIndex, NodeIndex lastNode, uint32_t hopCount, IslandId id, FixedArray<TraversalState>* visitedNodes);
    00275
    00279     void            addToDirtyNodeList(ActorIndex actorIndex, NodeIndex node);
    00280
    00284     NodeIndex       getAdjacentNode(uint32_t adjacencyIndex, const SupportGraph* graph) const
    00285     {
    00286         const uint32_t bondIndex = graph->getAdjacentBondIndices()[adjacencyIndex];
    00287         return getIsEdgeRemoved()->test(bondIndex) ? invalidIndex<uint32_t>() : graph->getAdjacentNodeIndices()[adjacencyIndex];
    00288     }
    00289
    00290 };
    00291
    00292
    00293 } // namespace Blast
    00294 } // namespace Nv
    00295
    00296
    00297 #endif // ifndef NVBLASTFAMILYGRAPH_H

Copyright © 2015-2017 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com