PeriDyno 1.0.0
Loading...
Searching...
No Matches
DiscreteElementsToTriangleSet.cpp
Go to the documentation of this file.
2
3#include "VkTransfer.h"
4
5namespace dyno
6{
8
11 {
12 this->addKernel(
13 "SetupFacets",
14 std::make_shared<VkProgram>(
15 BUFFER(Vec3f), //out: vertices
16 BUFFER(TopologyModule::Triangle), //out: indices
17 BUFFER(px::Box), //in: boxes
18 BUFFER(px::Capsule), //in: capsules
19 BUFFER(px::Sphere), //in: spheres
20 UNIFORM(ElementOffset), //in: offset
21 CONSTANT(uint32_t)) //in: number of boxes
22 );
23 kernel("SetupFacets")->load(getAssetPath() + "shaders/glsl/topology/SetupFacets.comp.spv");
24 }
25
27 {
28 auto elements = this->inDiscreteElements()->getDataPtr();
29
30 if (this->outTriangleSet()->isEmpty()) {
31 this->outTriangleSet()->allocate();
32 }
33
34 auto outTopo = this->outTriangleSet()->getDataPtr();
35
36 auto& boxes = elements->getBoxes();
37 auto& spheres = elements->getSpheres();
38 auto& capsules = elements->getCapsules();
39
40 uint32_t totalSize = boxes.size() * 36 + capsules.size() * 48 + spheres.size() * 24;
41
42 auto& vertices = outTopo->mPoints;
43 auto& indices = outTopo->mTriangleIndex;
44
45 vertices.resize(totalSize);
46 indices.resize(totalSize / 3);
47
48 uint32_t eleSize = elements->getTotalElementSize();
49
51 offset.setValue(elements->getElementOffset());
52
53 VkConstant<uint32_t> constUint;
54 constUint.setValue(eleSize);
55
56 kernel("SetupFacets")->flush(
57 vkDispatchSize(eleSize, 64),
58 vertices.handle(),
59 indices.handle(),
60 &elements->getBoxes(),
61 &elements->getCapsules(),
62 &elements->getSpheres(),
63 &offset,
64 &constUint);
65
66 outTopo->update();
67
68 return true;
69 }
70}
#define IMPLEMENT_CLASS(name)
Definition Object.h:79
#define UNIFORM(T)
Definition VkProgram.h:99
#define BUFFER(T)
Definition VkProgram.h:96
#define CONSTANT(T)
Definition VkProgram.h:100
Vector< PointType, 3 > Triangle
void setValue(const T val)
void setValue(T val)
Definition VkUniform.inl:32
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
static dim3 vkDispatchSize(uint totalSize, uint blockSize)
Definition VkProgram.h:34
Vector< float, 3 > Vec3f
Definition Vector3D.h:93