1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/*
* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA CORPORATION and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an express
* license agreement from NVIDIA CORPORATION is strictly prohibited.
*/
#ifndef NVBLASTAUTHORINGFCUTOUTIMPL_H
#define NVBLASTAUTHORINGFCUTOUTIMPL_H
#include "NvBlastExtAuthoringCutout.h"
#include <vector>
#include "PxMat44.h" // TODO Should replace?
namespace Nv
{
namespace Blast
{
struct PolyVert
{
uint16_t index;
uint16_t flags;
};
struct ConvexLoop
{
std::vector<PolyVert> polyVerts;
};
struct Cutout
{
std::vector<physx::PxVec3> vertices;
std::vector<ConvexLoop> convexLoops;
};
struct POINT2D
{
POINT2D() {}
POINT2D(int32_t _x, int32_t _y) : x(_x), y(_y) {}
int32_t x;
int32_t y;
bool operator==(const POINT2D& other) const
{
return x == other.x && y == other.y;
}
bool operator<(const POINT2D& other) const
{
if (x == other.x) return y < other.y;
return x < other.x;
}
};
void convertTracesToIncremental(std::vector< std::vector<POINT2D>* >& traces);
struct CutoutSetImpl : public CutoutSet
{
CutoutSetImpl() : periodic(false), dimensions(0.0f)
{
}
uint32_t getCutoutCount() const
{
return (uint32_t)cutouts.size();
}
uint32_t getCutoutVertexCount(uint32_t cutoutIndex) const
{
return (uint32_t)cutouts[cutoutIndex].vertices.size();
}
uint32_t getCutoutLoopCount(uint32_t cutoutIndex) const
{
return (uint32_t)cutouts[cutoutIndex].convexLoops.size();
}
const physx::PxVec3& getCutoutVertex(uint32_t cutoutIndex, uint32_t vertexIndex) const
{
return cutouts[cutoutIndex].vertices[vertexIndex];
}
uint32_t getCutoutLoopSize(uint32_t cutoutIndex, uint32_t loopIndex) const
{
return (uint32_t)cutouts[cutoutIndex].convexLoops[loopIndex].polyVerts.size();
}
uint32_t getCutoutLoopVertexIndex(uint32_t cutoutIndex, uint32_t loopIndex, uint32_t vertexNum) const
{
return cutouts[cutoutIndex].convexLoops[loopIndex].polyVerts[vertexNum].index;
}
uint32_t getCutoutLoopVertexFlags(uint32_t cutoutIndex, uint32_t loopIndex, uint32_t vertexNum) const
{
return cutouts[cutoutIndex].convexLoops[loopIndex].polyVerts[vertexNum].flags;
}
bool isPeriodic() const
{
return periodic;
}
const physx::PxVec2& getDimensions() const
{
return dimensions;
}
//void serialize(physx::PxFileBuf& stream) const;
//void deserialize(physx::PxFileBuf& stream);
void release()
{
delete this;
}
std::vector<Cutout> cutouts;
bool periodic;
physx::PxVec2 dimensions;
};
void createCutoutSet(Nv::Blast::CutoutSetImpl& cutoutSet, const uint8_t* pixelBuffer, uint32_t bufferWidth, uint32_t bufferHeight,
float segmentationErrorThreshold, float snapThreshold, bool periodic, bool expandGaps);
} // namespace Blast
} // namespace Nv
#endif // ifndef NVBLASTAUTHORINGFCUTOUTIMPL_H
|