1#include "ContactsToEdgeSet.h"
5 IMPLEMENT_TCLASS(ContactsToEdgeSet, TDataType);
7 template<typename TDataType>
8 ContactsToEdgeSet<TDataType>::ContactsToEdgeSet()
13 template<typename Coord, typename Edge>
14 __global__ void SetupContactInfo(
15 DArray<Coord> vertices,
17 DArray<TContactPair<Real>> contacts,
20 int tId = threadIdx.x + (blockIdx.x * blockDim.x);
21 if (tId >= contacts.size()) return;
23 auto contact = contacts[tId];
24 Coord v0 = contact.pos1;
25 Coord v1 = contact.pos1 + contact.normal1 * scale;
27 vertices[2 * tId] = v0;
28 vertices[2 * tId + 1] = v1;
29 indices[tId] = Edge(2 * tId, 2 * tId + 1);
32 template<typename TDataType>
33 bool ContactsToEdgeSet<TDataType>::apply()
35 if (this->outEdgeSet()->isEmpty())
37 this->outEdgeSet()->allocate();
40 auto& inContacts = this->inContacts()->getData();
41 auto outSet = this->outEdgeSet()->getDataPtr();
43 auto& vertices = outSet->getPoints();
44 auto& indices = outSet->getEdges();
46 uint contactNum = inContacts.size();
47 vertices.resize(2 * contactNum);
48 indices.resize(contactNum);
55 this->varScale()->getData());
60 DEFINE_CLASS(ContactsToEdgeSet);