mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-10 02:53:51 +00:00
refactor(editor): adopt addClosedCylinderZ in bedroll + archery-target
Two more handlers retire their open-coded Z-axis cylinder
geometry and call addClosedCylinderZ instead:
• --gen-mesh-bedroll: 60-line inline cylinder (side wall +
end-cap fans) → 1 helper call.
• --gen-mesh-archery-target: same 60-line block for the
target face → 1 helper call. The unused local pi
constant drops out as a side benefit.
Output bytes verified identical: bedroll surface area
1.6746 m² unchanged; archery-target 1.9504 m² unchanged.
Cylinder-helper rollout now complete on the Z-axis side:
woodpile (last batch) + bedroll + archery-target all use
addClosedCylinderZ. Future Z-axis tubes (e.g. mine-cart
axles, well-pail handles, scroll cases) opt in by
including cli_box_emitter.hpp.
This commit is contained in:
parent
b47649b078
commit
67e1a7246e
1 changed files with 4 additions and 115 deletions
|
|
@ -5778,7 +5778,6 @@ int handleArcheryTarget(int& i, int argc, char** argv) {
|
|||
stripExt(womBase, ".wom");
|
||||
wowee::pipeline::WoweeModel wom;
|
||||
initWomDefaults(wom, womBase);
|
||||
const float pi = 3.14159265358979f;
|
||||
const float halfStanceX = faceR + postW * 0.5f;
|
||||
// Two vertical posts of the stand, sized to reach from ground
|
||||
// to the bottom of the face.
|
||||
|
|
@ -5800,61 +5799,7 @@ int handleArcheryTarget(int& i, int argc, char** argv) {
|
|||
// (0, postH, 0). Flat ±Z caps face the archer line; side
|
||||
// wall is the rim.
|
||||
const float halfT = faceT * 0.5f;
|
||||
uint32_t back = static_cast<uint32_t>(wom.vertices.size());
|
||||
for (int s = 0; s <= sides; ++s) {
|
||||
float u = static_cast<float>(s) / sides;
|
||||
float ang = u * 2.0f * pi;
|
||||
glm::vec3 dir(std::cos(ang), std::sin(ang), 0.0f);
|
||||
glm::vec3 p(faceR * dir.x, postH + faceR * dir.y, -halfT);
|
||||
addVertex(wom, p, dir, {u, 0});
|
||||
}
|
||||
uint32_t front = static_cast<uint32_t>(wom.vertices.size());
|
||||
for (int s = 0; s <= sides; ++s) {
|
||||
float u = static_cast<float>(s) / sides;
|
||||
float ang = u * 2.0f * pi;
|
||||
glm::vec3 dir(std::cos(ang), std::sin(ang), 0.0f);
|
||||
glm::vec3 p(faceR * dir.x, postH + faceR * dir.y, +halfT);
|
||||
addVertex(wom, p, dir, {u, 1});
|
||||
}
|
||||
for (int s = 0; s < sides; ++s) {
|
||||
wom.indices.insert(wom.indices.end(), {
|
||||
back + s, front + s, back + s + 1,
|
||||
back + s + 1, front + s, front + s + 1
|
||||
});
|
||||
}
|
||||
// Cap fans on -Z and +Z so the face is closed.
|
||||
uint32_t backCenter = addVertex(wom, {0, postH, -halfT},
|
||||
{0, 0, -1}, {0.5f, 0.5f});
|
||||
uint32_t backRing = static_cast<uint32_t>(wom.vertices.size());
|
||||
for (int s = 0; s <= sides; ++s) {
|
||||
float u = static_cast<float>(s) / sides;
|
||||
float ang = u * 2.0f * pi;
|
||||
glm::vec3 p(faceR * std::cos(ang),
|
||||
postH + faceR * std::sin(ang), -halfT);
|
||||
addVertex(wom, p, {0, 0, -1},
|
||||
{0.5f + 0.5f * std::cos(ang),
|
||||
0.5f + 0.5f * std::sin(ang)});
|
||||
}
|
||||
for (int s = 0; s < sides; ++s) {
|
||||
wom.indices.insert(wom.indices.end(),
|
||||
{backCenter, backRing + s + 1, backRing + s});
|
||||
}
|
||||
uint32_t frontCenter = addVertex(wom, {0, postH, +halfT},
|
||||
{0, 0, +1}, {0.5f, 0.5f});
|
||||
uint32_t frontRing = static_cast<uint32_t>(wom.vertices.size());
|
||||
for (int s = 0; s <= sides; ++s) {
|
||||
float u = static_cast<float>(s) / sides;
|
||||
float ang = u * 2.0f * pi;
|
||||
glm::vec3 p(faceR * std::cos(ang),
|
||||
postH + faceR * std::sin(ang), +halfT);
|
||||
addVertex(wom, p, {0, 0, +1},
|
||||
{0.5f + 0.5f * std::cos(ang),
|
||||
0.5f + 0.5f * std::sin(ang)});
|
||||
}
|
||||
for (int s = 0; s < sides; ++s) {
|
||||
wom.indices.insert(wom.indices.end(),
|
||||
{frontCenter, frontRing + s, frontRing + s + 1});
|
||||
}
|
||||
addClosedCylinderZ(wom, 0.0f, postH, faceR, -halfT, +halfT, sides);
|
||||
finalizeAsSingleBatch(wom);
|
||||
setCenteredBoundsXZ(wom, halfStanceX + postW * 0.5f, halfT,
|
||||
postH + faceR);
|
||||
|
|
@ -6429,66 +6374,10 @@ int handleBedroll(int& i, int argc, char** argv) {
|
|||
stripExt(womBase, ".wom");
|
||||
wowee::pipeline::WoweeModel wom;
|
||||
initWomDefaults(wom, womBase);
|
||||
const float pi = 3.14159265358979f;
|
||||
const float halfL = length * 0.5f;
|
||||
// Z-axis cylinder centered at (0, radius, 0). Same end-cap fan
|
||||
// pattern used by --gen-mesh-woodpile's logs.
|
||||
uint32_t back = static_cast<uint32_t>(wom.vertices.size());
|
||||
for (int s = 0; s <= sides; ++s) {
|
||||
float u = static_cast<float>(s) / sides;
|
||||
float ang = u * 2.0f * pi;
|
||||
glm::vec3 dir(std::cos(ang), std::sin(ang), 0.0f);
|
||||
glm::vec3 p(radius * dir.x, radius + radius * dir.y, -halfL);
|
||||
addVertex(wom, p, dir, {u, 0});
|
||||
}
|
||||
uint32_t front = static_cast<uint32_t>(wom.vertices.size());
|
||||
for (int s = 0; s <= sides; ++s) {
|
||||
float u = static_cast<float>(s) / sides;
|
||||
float ang = u * 2.0f * pi;
|
||||
glm::vec3 dir(std::cos(ang), std::sin(ang), 0.0f);
|
||||
glm::vec3 p(radius * dir.x, radius + radius * dir.y, +halfL);
|
||||
addVertex(wom, p, dir, {u, 1});
|
||||
}
|
||||
for (int s = 0; s < sides; ++s) {
|
||||
wom.indices.insert(wom.indices.end(), {
|
||||
back + s, front + s, back + s + 1,
|
||||
back + s + 1, front + s, front + s + 1
|
||||
});
|
||||
}
|
||||
// Back cap (-Z) fan.
|
||||
uint32_t backCenter = addVertex(wom, {0, radius, -halfL},
|
||||
{0, 0, -1}, {0.5f, 0.5f});
|
||||
uint32_t backRing = static_cast<uint32_t>(wom.vertices.size());
|
||||
for (int s = 0; s <= sides; ++s) {
|
||||
float u = static_cast<float>(s) / sides;
|
||||
float ang = u * 2.0f * pi;
|
||||
glm::vec3 p(radius * std::cos(ang),
|
||||
radius + radius * std::sin(ang), -halfL);
|
||||
addVertex(wom, p, {0, 0, -1},
|
||||
{0.5f + 0.5f * std::cos(ang),
|
||||
0.5f + 0.5f * std::sin(ang)});
|
||||
}
|
||||
for (int s = 0; s < sides; ++s) {
|
||||
wom.indices.insert(wom.indices.end(),
|
||||
{backCenter, backRing + s + 1, backRing + s});
|
||||
}
|
||||
// Front cap (+Z) fan.
|
||||
uint32_t frontCenter = addVertex(wom, {0, radius, +halfL},
|
||||
{0, 0, +1}, {0.5f, 0.5f});
|
||||
uint32_t frontRing = static_cast<uint32_t>(wom.vertices.size());
|
||||
for (int s = 0; s <= sides; ++s) {
|
||||
float u = static_cast<float>(s) / sides;
|
||||
float ang = u * 2.0f * pi;
|
||||
glm::vec3 p(radius * std::cos(ang),
|
||||
radius + radius * std::sin(ang), +halfL);
|
||||
addVertex(wom, p, {0, 0, +1},
|
||||
{0.5f + 0.5f * std::cos(ang),
|
||||
0.5f + 0.5f * std::sin(ang)});
|
||||
}
|
||||
for (int s = 0; s < sides; ++s) {
|
||||
wom.indices.insert(wom.indices.end(),
|
||||
{frontCenter, frontRing + s, frontRing + s + 1});
|
||||
}
|
||||
// Z-axis cylinder centered at (0, radius). Sits on the ground
|
||||
// (cy = radius means the bottom of the cylinder is at y=0).
|
||||
addClosedCylinderZ(wom, 0.0f, radius, radius, -halfL, +halfL, sides);
|
||||
// Optional pillow box at +Z end. Sits flat on the ground and
|
||||
// pushes a bit past the bedroll's front cap so it reads as a
|
||||
// separate prop.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue