Main Page Class List Class Members

NvBlastExtAuthoringCutoutImpl.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 NVBLASTAUTHORINGFCUTOUTIMPL_H
30 #define NVBLASTAUTHORINGFCUTOUTIMPL_H
31
32 #include "NvBlastExtAuthoringCutout.h"
33 #include <vector>
34 #include <PxVec2.h>
35 #include <PxVec3.h>
36 #include <PxMat44.h>
37
38 namespace Nv
39 {
40 namespace Blast
41 {
42
43 struct PolyVert
44 {
45 uint16_t index;
46 uint16_t flags;
47 };
48
49 struct ConvexLoop
50 {
51 std::vector<PolyVert> polyVerts;
52 };
53
54 struct Cutout
55 {
56 std::vector<physx::PxVec3> vertices;
57 //std::vector<ConvexLoop> convexLoops;
58 std::vector<physx::PxVec3> smoothingGroups;
59 };
60
61 struct POINT2D
62 {
63 POINT2D() {}
64 POINT2D(int32_t _x, int32_t _y) : x(_x), y(_y) {}
65
66 int32_t x;
67 int32_t y;
68
69 bool operator==(const POINT2D& other) const
70 {
71 return x == other.x && y == other.y;
72 }
73 bool operator<(const POINT2D& other) const
74 {
75 if (x == other.x) return y < other.y;
76 return x < other.x;
77 }
78 };
79
80 struct CutoutSetImpl : public CutoutSet
81 {
82 CutoutSetImpl() : periodic(false), dimensions(0.0f)
83 {
84 }
85
86 uint32_t getCutoutCount() const
87 {
88 return (uint32_t)cutouts.size() - 1;
89 }
90
91 uint32_t getCutoutVertexCount(uint32_t cutoutIndex, uint32_t loopIndex) const
92 {
93 return (uint32_t)cutoutLoops[cutouts[cutoutIndex] + loopIndex].vertices.size();
94 }
95 uint32_t getCutoutLoopCount(uint32_t cutoutIndex) const
96 {
97 return (uint32_t)cutouts[cutoutIndex + 1] - cutouts[cutoutIndex];
98 }
99
100 const NvcVec3& getCutoutVertex(uint32_t cutoutIndex, uint32_t loopIndex, uint32_t vertexIndex) const;
101
102 bool isCutoutVertexToggleSmoothingGroup(uint32_t cutoutIndex, uint32_t loopIndex, uint32_t vertexIndex) const
103 {
104 auto& vRef = cutoutLoops[cutouts[cutoutIndex] + loopIndex].vertices[vertexIndex];
105 for (auto& v : cutoutLoops[cutouts[cutoutIndex] + loopIndex].smoothingGroups)
106 {
107 if ((vRef - v).magnitudeSquared() < 1e-5)
108 {
109 return true;
110 }
111 }
112 return false;
113 }
114
115 bool isPeriodic() const
116 {
117 return periodic;
118 }
119 const NvcVec2& getDimensions() const;
120
121 //void serialize(physx::PxFileBuf& stream) const;
122 //void deserialize(physx::PxFileBuf& stream);
123
124 void release()
125 {
126 delete this;
127 }
128
129 std::vector<Cutout> cutoutLoops;
130 std::vector<uint32_t> cutouts;
131 bool periodic;
132 physx::PxVec2 dimensions;
133 };
134
135 void createCutoutSet(Nv::Blast::CutoutSetImpl& cutoutSet, const uint8_t* pixelBuffer, uint32_t bufferWidth, uint32_t bufferHeight,
136 float segmentationErrorThreshold, float snapThreshold, bool periodic, bool expandGaps);
137
138
139 } // namespace Blast
140 } // namespace Nv
141
142 #endif // ifndef NVBLASTAUTHORINGFCUTOUTIMPL_H
Nv::Blast::Cutout::vertices
std::vector< physx::PxVec3 > vertices
Definition: NvBlastExtAuthoringCutoutImpl.h:56
x
SIMD_FORCE_INLINE const btScalar & x() const
Return the x value.
Definition: btVector3.h:275
Nv::Blast::CutoutSet
Definition: NvBlastExtAuthoringCutout.h:36
Nv::Blast::POINT2D
Definition: NvBlastExtAuthoringCutoutImpl.h:61
Nv::Blast::POINT2D::operator==
bool operator==(const POINT2D &other) const
Definition: NvBlastExtAuthoringCutoutImpl.h:69
Nv::Blast::POINT2D::operator<
bool operator<(const POINT2D &other) const
Definition: NvBlastExtAuthoringCutoutImpl.h:73
NvcVec2
Definition: NvCTypes.h:43
Nv::Blast::Cutout::smoothingGroups
std::vector< physx::PxVec3 > smoothingGroups
Definition: NvBlastExtAuthoringCutoutImpl.h:58
Nv::Blast::POINT2D::y
int32_t y
Definition: NvBlastExtAuthoringCutoutImpl.h:67
Nv::Blast::CutoutSetImpl::dimensions
physx::PxVec2 dimensions
Definition: NvBlastExtAuthoringCutoutImpl.h:132
Nv::Blast::CutoutSetImpl::cutouts
std::vector< uint32_t > cutouts
Definition: NvBlastExtAuthoringCutoutImpl.h:130
Nv::Blast::CutoutSetImpl::getCutoutVertexCount
uint32_t getCutoutVertexCount(uint32_t cutoutIndex, uint32_t loopIndex) const
Definition: NvBlastExtAuthoringCutoutImpl.h:91
Nv::Blast::Cutout
Definition: NvBlastExtAuthoringCutoutImpl.h:54
Nv::Blast::PolyVert
Definition: NvBlastExtAuthoringCutoutImpl.h:43
Nv::Blast::CutoutSetImpl::isCutoutVertexToggleSmoothingGroup
bool isCutoutVertexToggleSmoothingGroup(uint32_t cutoutIndex, uint32_t loopIndex, uint32_t vertexIndex) const
Definition: NvBlastExtAuthoringCutoutImpl.h:102
Nv::Blast::ConvexLoop::polyVerts
std::vector< PolyVert > polyVerts
Definition: NvBlastExtAuthoringCutoutImpl.h:51
Nv::Blast::CutoutSetImpl::release
void release()
Definition: NvBlastExtAuthoringCutoutImpl.h:124
Nv::Blast::CutoutSetImpl::cutoutLoops
std::vector< Cutout > cutoutLoops
Definition: NvBlastExtAuthoringCutoutImpl.h:129
y
SIMD_FORCE_INLINE const btScalar & y() const
Return the y value.
Definition: btVector3.h:277
Nv::Blast::createCutoutSet
void createCutoutSet(Nv::Blast::CutoutSetImpl &cutoutSet, const uint8_t *pixelBuffer, uint32_t bufferWidth, uint32_t bufferHeight, float segmentationErrorThreshold, float snapThreshold, bool periodic, bool expandGaps)
Nv::Blast::POINT2D::x
int32_t x
Definition: NvBlastExtAuthoringCutoutImpl.h:66
Nv::Blast::CutoutSetImpl::getCutoutLoopCount
uint32_t getCutoutLoopCount(uint32_t cutoutIndex) const
Definition: NvBlastExtAuthoringCutoutImpl.h:95
Nv::Blast::CutoutSetImpl
Definition: NvBlastExtAuthoringCutoutImpl.h:80
Nv::Blast::CutoutSetImpl::isPeriodic
bool isPeriodic() const
Definition: NvBlastExtAuthoringCutoutImpl.h:115
Nv::Blast::ConvexLoop
Definition: NvBlastExtAuthoringCutoutImpl.h:49
Nv::Blast::POINT2D::POINT2D
POINT2D()
Definition: NvBlastExtAuthoringCutoutImpl.h:63
Nv::Blast::POINT2D::POINT2D
POINT2D(int32_t _x, int32_t _y)
Definition: NvBlastExtAuthoringCutoutImpl.h:64
Nv::Blast::PolyVert::flags
uint16_t flags
Definition: NvBlastExtAuthoringCutoutImpl.h:46
NvBlastExtAuthoringCutout.h
Nv
Definition: NvBlastArray.h:37
Nv::Blast::CutoutSetImpl::periodic
bool periodic
Definition: NvBlastExtAuthoringCutoutImpl.h:131
Nv::Blast::CutoutSetImpl::CutoutSetImpl
CutoutSetImpl()
Definition: NvBlastExtAuthoringCutoutImpl.h:82
NvcVec3
Definition: NvCTypes.h:49
Nv::Blast::PolyVert::index
uint16_t index
Definition: NvBlastExtAuthoringCutoutImpl.h:45
Nv::Blast::CutoutSetImpl::getCutoutCount
uint32_t getCutoutCount() const
Definition: NvBlastExtAuthoringCutoutImpl.h:86