Main Page   Class List   Class Members  

  • Main Page
  • User's Guide
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

sdk/extensions/authoring/source/NvBlastExtAuthoringCutoutImpl.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 NVBLASTAUTHORINGFCUTOUTIMPL_H
00030 #define NVBLASTAUTHORINGFCUTOUTIMPL_H
00031 
00032 #include "NvBlastExtAuthoringCutout.h"
00033 #include <vector>
00034 #include <PxVec2.h>
00035 #include <PxVec3.h>
00036 #include <PxMat44.h>
00037 
00038 namespace Nv
00039 {
00040 namespace Blast
00041 {
00042 
00043 struct PolyVert
00044 {
00045     uint16_t index;
00046     uint16_t flags;
00047 };
00048 
00049 struct ConvexLoop
00050 {
00051     std::vector<PolyVert> polyVerts;
00052 };
00053 
00054 struct Cutout
00055 {
00056     std::vector<physx::PxVec3> vertices;
00057     //std::vector<ConvexLoop> convexLoops;
00058     std::vector<physx::PxVec3> smoothingGroups;
00059 };
00060 
00061 struct POINT2D
00062 {
00063     POINT2D() {}
00064     POINT2D(int32_t _x, int32_t _y) : x(_x), y(_y) {}
00065 
00066     int32_t x;
00067     int32_t y;
00068 
00069     bool operator==(const POINT2D& other) const
00070     {
00071         return x == other.x && y == other.y;
00072     }
00073     bool operator<(const POINT2D& other) const
00074     {
00075         if (x == other.x) return y < other.y;
00076         return x < other.x;
00077     }
00078 };
00079 
00080 struct CutoutSetImpl : public CutoutSet
00081 {
00082     CutoutSetImpl() : periodic(false), dimensions(0.0f)
00083     {
00084     }
00085 
00086     uint32_t            getCutoutCount() const
00087     {
00088         return (uint32_t)cutouts.size() - 1;
00089     }
00090 
00091     uint32_t            getCutoutVertexCount(uint32_t cutoutIndex, uint32_t loopIndex) const
00092     {
00093         return (uint32_t)cutoutLoops[cutouts[cutoutIndex] + loopIndex].vertices.size();
00094     }
00095     uint32_t            getCutoutLoopCount(uint32_t cutoutIndex) const
00096     {
00097         return (uint32_t)cutouts[cutoutIndex + 1] - cutouts[cutoutIndex];
00098     }
00099 
00100     const NvcVec3& getCutoutVertex(uint32_t cutoutIndex, uint32_t loopIndex, uint32_t vertexIndex) const;
00101 
00102     bool                isCutoutVertexToggleSmoothingGroup(uint32_t cutoutIndex, uint32_t loopIndex, uint32_t vertexIndex) const
00103     {
00104         auto& vRef = cutoutLoops[cutouts[cutoutIndex] + loopIndex].vertices[vertexIndex];
00105         for (auto& v : cutoutLoops[cutouts[cutoutIndex] + loopIndex].smoothingGroups)
00106         {
00107             if ((vRef - v).magnitudeSquared() < 1e-5)
00108             {
00109                 return true;
00110             }
00111         }
00112         return false;
00113     }
00114 
00115     bool                    isPeriodic() const
00116     {
00117         return periodic;
00118     }
00119     const NvcVec2& getDimensions() const;
00120 
00121     //void                  serialize(physx::PxFileBuf& stream) const;
00122     //void                  deserialize(physx::PxFileBuf& stream);
00123 
00124     void                    release()
00125     {
00126         delete this;
00127     }
00128 
00129     std::vector<Cutout>     cutoutLoops;
00130     std::vector<uint32_t>   cutouts;
00131     bool                    periodic;
00132     physx::PxVec2           dimensions;
00133 };
00134 
00135 void createCutoutSet(Nv::Blast::CutoutSetImpl& cutoutSet, const uint8_t* pixelBuffer, uint32_t bufferWidth, uint32_t bufferHeight,
00136     float segmentationErrorThreshold, float snapThreshold, bool periodic, bool expandGaps);
00137 
00138 
00139 } // namespace Blast
00140 } // namespace Nv
00141 
00142 #endif // ifndef NVBLASTAUTHORINGFCUTOUTIMPL_H
Copyright © 2015-2017 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com