MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / cache

Method cache

examples/ExampleBrowser/GL_ShapeDrawer.cpp:176–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174}
175
176GL_ShapeDrawer::ShapeCache* GL_ShapeDrawer::cache(btConvexShape* shape)
177{
178 ShapeCache* sc = (ShapeCache*)shape->getUserPointer();
179 if (!sc)
180 {
181 sc = new (btAlignedAlloc(sizeof(ShapeCache), 16)) ShapeCache(shape);
182 sc->m_shapehull.buildHull(shape->getMargin());
183 m_shapecaches.push_back(sc);
184 shape->setUserPointer(sc);
185 /* Build edges */
186 const int ni = sc->m_shapehull.numIndices();
187 const int nv = sc->m_shapehull.numVertices();
188 const unsigned int* pi = sc->m_shapehull.getIndexPointer();
189 const btVector3* pv = sc->m_shapehull.getVertexPointer();
190 btAlignedObjectArray<ShapeCache::Edge*> edges;
191 sc->m_edges.reserve(ni);
192 edges.resize(nv * nv, 0);
193 for (int i = 0; i < ni; i += 3)
194 {
195 const unsigned int* ti = pi + i;
196 const btVector3 nrm = btCross(pv[ti[1]] - pv[ti[0]], pv[ti[2]] - pv[ti[0]]).normalized();
197 for (int j = 2, k = 0; k < 3; j = k++)
198 {
199 const unsigned int a = ti[j];
200 const unsigned int b = ti[k];
201 ShapeCache::Edge*& e = edges[btMin(a, b) * nv + btMax(a, b)];
202 if (!e)
203 {
204 sc->m_edges.push_back(ShapeCache::Edge());
205 e = &sc->m_edges[sc->m_edges.size() - 1];
206 e->n[0] = nrm;
207 e->n[1] = -nrm;
208 e->v[0] = a;
209 e->v[1] = b;
210 }
211 else
212 {
213 e->n[1] = nrm;
214 }
215 }
216 }
217 }
218 return (sc);
219}
220
221void renderSquareA(float x, float y, float z)
222{

Callers

nothing calls this directly

Calls 11

btCrossFunction · 0.85
buildHullMethod · 0.80
numIndicesMethod · 0.80
numVerticesMethod · 0.80
EdgeClass · 0.70
getMarginMethod · 0.45
push_backMethod · 0.45
reserveMethod · 0.45
resizeMethod · 0.45
normalizedMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected