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

Method createGarbageQuadMesh

tutorials/common/scenegraph/geometry_creation.cpp:484–521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

482 }
483
484 Ref<SceneGraph::Node> SceneGraph::createGarbageQuadMesh (int hash, size_t numQuads, bool mblur, Ref<MaterialNode> material)
485 {
486 RandomSampler sampler;
487 RandomSampler_init(sampler,hash);
488 Ref<SceneGraph::QuadMeshNode> mesh = new SceneGraph::QuadMeshNode(material,BBox1f(0,1),mblur?2:1);
489
490 mesh->quads.resize(numQuads);
491 for (size_t i=0; i<numQuads; i++) {
492 const unsigned v0 = (RandomSampler_getInt(sampler) % 32 == 0) ? RandomSampler_getUInt(sampler) : unsigned(4*i+0);
493 const unsigned v1 = (RandomSampler_getInt(sampler) % 32 == 0) ? RandomSampler_getUInt(sampler) : unsigned(4*i+1);
494 const unsigned v2 = (RandomSampler_getInt(sampler) % 32 == 0) ? RandomSampler_getUInt(sampler) : unsigned(4*i+2);
495 const unsigned v3 = (RandomSampler_getInt(sampler) % 32 == 0) ? RandomSampler_getUInt(sampler) : unsigned(4*i+3);
496 mesh->quads[i] = QuadMeshNode::Quad(v0,v1,v2,v3);
497 }
498
499 mesh->positions[0].resize(4*numQuads);
500 for (size_t i=0; i<4*numQuads; i++) {
501 const float x = cast_i2f(RandomSampler_getUInt(sampler));
502 const float y = cast_i2f(RandomSampler_getUInt(sampler));
503 const float z = cast_i2f(RandomSampler_getUInt(sampler));
504 const float w = cast_i2f(RandomSampler_getUInt(sampler));
505 mesh->positions[0][i] = Vec3fa(Vec3ff(x,y,z,w));
506 }
507
508 if (mblur)
509 {
510 mesh->positions[1].resize(4*numQuads);
511 for (size_t i=0; i<4*numQuads; i++) {
512 const float x = cast_i2f(RandomSampler_getUInt(sampler));
513 const float y = cast_i2f(RandomSampler_getUInt(sampler));
514 const float z = cast_i2f(RandomSampler_getUInt(sampler));
515 const float w = cast_i2f(RandomSampler_getUInt(sampler));
516 mesh->positions[1][i] = Vec3fa(Vec3ff(x,y,z,w));
517 }
518 }
519
520 return mesh.dynamicCast<SceneGraph::Node>();
521 }
522
523 Ref<SceneGraph::Node> SceneGraph::createGarbageGridMesh (int hash, size_t numGrids, bool mblur, Ref<MaterialNode> material)
524 {

Callers

nothing calls this directly

Calls 7

RandomSampler_initFunction · 0.85
RandomSampler_getIntFunction · 0.85
RandomSampler_getUIntFunction · 0.85
QuadClass · 0.70
cast_i2fFunction · 0.50
Vec3faClass · 0.50
resizeMethod · 0.45

Tested by

no test coverage detected