MCPcopy Create free account
hub / github.com/RenderKit/embree / addRandomSubdivFeatures

Function addRandomSubdivFeatures

tutorials/verify/verify.cpp:89–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87 typedef SceneGraph::TriangleMeshNode::Triangle Triangle;
88
89 void addRandomSubdivFeatures(RandomSampler& sampler, Ref<SceneGraph::SubdivMeshNode> mesh, size_t numEdgeCreases, size_t numVertexCreases, size_t numHoles)
90 {
91 std::vector<unsigned> offsets;
92 std::vector<unsigned>& faces = mesh->verticesPerFace;
93 std::vector<unsigned>& indices = mesh->position_indices;
94 for (size_t i=0, j=0; i<mesh->verticesPerFace.size(); i++) {
95 offsets.push_back(unsigned(j)); j+=mesh->verticesPerFace[i];
96 }
97
98 for (size_t i=0; i<numEdgeCreases; i++)
99 {
100 if (faces.size()) {
101 int f = RandomSampler_getInt(sampler) % faces.size();
102 int n = faces[f];
103 int e = RandomSampler_getInt(sampler) % n;
104 mesh->edge_creases.push_back(Vec2i(indices[offsets[f]+(e+0)%n],indices[offsets[f]+(e+1)%n]));
105 } else {
106 mesh->edge_creases.push_back(Vec2i(0,0));
107 }
108 mesh->edge_crease_weights.push_back(10.0f*RandomSampler_getFloat(sampler));
109 }
110
111 for (size_t i=0; i<numVertexCreases; i++)
112 {
113 if (faces.size()) {
114 size_t f = RandomSampler_getInt(sampler) % faces.size();
115 size_t e = RandomSampler_getInt(sampler) % faces[f];
116 mesh->vertex_creases.push_back(indices[offsets[f] + e]);
117 mesh->vertex_crease_weights.push_back(10.0f*RandomSampler_getFloat(sampler));
118 }
119 }
120
121 for (size_t i=0; i<numHoles; i++) {
122 mesh->holes.push_back(RandomSampler_getInt(sampler) % faces.size());
123 }
124 }
125
126 struct Sphere
127 {

Callers 1

addSubdivSphereMethod · 0.85

Calls 4

RandomSampler_getIntFunction · 0.85
RandomSampler_getFloatFunction · 0.85
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected