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

Function ApplyNewEdgeCollapseToModel

Source/Objects/riggedobject.cpp:1464–1525  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1462 return a.weight > b.weight;
1463}
1464void ApplyNewEdgeCollapseToModel(const Model& base_model,
1465 Model& model,
1466 const WOLFIRE_SIMPLIFY::SimplifyModel& sm,
1467 const WOLFIRE_SIMPLIFY::ParentRecordListVec& vert_parent,
1468 const WOLFIRE_SIMPLIFY::ParentRecordListVec& tex_parent) {
1469 std::vector<float> sm_vertices(sm.vertices.size());
1470 std::vector<float> sm_tex_coords(sm.tex_coords.size());
1471 for (auto parents : vert_parent) {
1472 float total[3];
1473 for (float& j : total) {
1474 j = 0.0f;
1475 }
1476 for (auto& parent : parents) {
1477 WOLFIRE_SIMPLIFY::ParentRecord pr = parent;
1478 if (pr.weight > 0.0f) {
1479 int parent_vert = sm.old_vert_id[pr.id];
1480 int parent_vert_index = parent_vert * 3;
1481 for (int j = 0; j < 3; ++j) {
1482 total[j] += base_model.vertices[parent_vert_index + j] * pr.weight;
1483 }
1484 }
1485 }
1486 for (auto& parent : parents) {
1487 WOLFIRE_SIMPLIFY::ParentRecord pr = parent;
1488 int parent_vert_index = pr.id * 3;
1489 for (int j = 0; j < 3; ++j) {
1490 sm_vertices[parent_vert_index + j] = total[j];
1491 }
1492 }
1493 }
1494 for (auto parents : tex_parent) {
1495 float total[2];
1496 for (float& j : total) {
1497 j = 0.0f;
1498 }
1499 for (auto& parent : parents) {
1500 WOLFIRE_SIMPLIFY::ParentRecord pr = parent;
1501 int parent_tex_index = sm.old_tex_id[pr.id] * 2;
1502 for (int j = 0; j < 2; ++j) {
1503 total[j] += base_model.tex_coords[parent_tex_index + j] * pr.weight;
1504 }
1505 }
1506 for (auto& parent : parents) {
1507 WOLFIRE_SIMPLIFY::ParentRecord pr = parent;
1508 int parent_tex_index = pr.id * 2;
1509 for (int j = 0; j < 2; ++j) {
1510 sm_tex_coords[parent_tex_index + j] = total[j];
1511 }
1512 }
1513 }
1514 int num_indices = sm.vert_indices.size();
1515 for (int i = 0; i < num_indices; ++i) {
1516 int vert_index = sm.vert_indices[i] * 3;
1517 for (int j = 0; j < 3; ++j) {
1518 model.vertices.push_back(sm_vertices[vert_index + j]);
1519 }
1520 int tex_index = sm.tex_indices[i] * 2;
1521 for (int j = 0; j < 2; ++j) {

Callers 1

LoadMethod · 0.85

Calls 2

sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected