MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / AddWireMesh

Method AddWireMesh

Source/Graphics/pxdebugdraw.cpp:299–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297}
298
299int DebugDraw::AddWireMesh(const std::string &path, const mat4 &transform, const vec4 &color, const DDLifespan lifespan) {
300 RC_VBOContainer vbo;
301 std::vector<vec3> vertices;
302
303 std::map<std::string, RC_VBOContainer>::iterator me_iter = mesh_edges_map.find(path);
304
305 if (me_iter == mesh_edges_map.end()) {
306 Model model;
307 model.LoadObj(path, _MDL_SIMPLE);
308 model.RemoveDuplicatedVerts();
309
310 for (unsigned i = 0; i < (model.faces.size() / 3) * 3; i += 3) {
311 for (unsigned j = 0; j < 3; j++) {
312 int f = model.faces[i + j];
313 int s = model.faces[i + ((j + 1) % 3)];
314
315 vertices.push_back(vec3(model.vertices[f * 3 + 0],
316 model.vertices[f * 3 + 1],
317 model.vertices[f * 3 + 2]));
318 vertices.push_back(vec3(model.vertices[s * 3 + 0],
319 model.vertices[s * 3 + 1],
320 model.vertices[s * 3 + 2]));
321 }
322 }
323
324 // One of the few cases in this codebase where kVBOStream makes sense
325 //(Creating the buffer, filling it once, reading a couple of times then destroying, as per spec)
326 vbo->Fill(kVBOFloat | kVBOStream, vertices.size() * sizeof(vertices[0]), &vertices[0]);
327
328 mesh_edges_map[path] = vbo;
329 } else {
330 vbo = me_iter->second;
331 }
332
333 DebugDrawElement *element = new DebugDrawWireMesh(vbo, transform, color);
334
335 return AddElement(element, lifespan);
336}
337
338int DebugDraw::AddLineObject(const RC_VBOContainer &vbo,
339 const mat4 &transform,

Callers 2

DrawMethod · 0.80
ASDebugDrawWireMeshFunction · 0.80

Calls 8

LoadObjMethod · 0.80
RemoveDuplicatedVertsMethod · 0.80
vec3Class · 0.50
findMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
FillMethod · 0.45

Tested by

no test coverage detected