00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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
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
00122
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 }
00140 }
00141
00142 #endif // ifndef NVBLASTAUTHORINGFCUTOUTIMPL_H