Skip to content

Commit

Permalink
[thirdparty] added meshoptimizer to the third party libraries table
Browse files Browse the repository at this point in the history
  • Loading branch information
PanosK92 committed Jan 13, 2025
1 parent 4396f8e commit 719be40
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion editor/ImGui/ImGui_TransformGizmo.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

namespace ImGui::TransformGizmo
{
const spartan::math::Vector3 snap = spartan::math::Vector3(0.1f, 0.1f, 0.1f);
const spartan::math::Vector3 snap = spartan::math::Vector3(0.1f, 0.1f, 0.1f);

bool first_use = true;
spartan::math::Vector3 position_previous;
Expand Down
19 changes: 19 additions & 0 deletions runtime/Core/GeometryProcessing.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,25 @@ namespace spartan::geometry_processing
generate_cylinder(vertices, indices, 0.0f, radius, height);
}

static void register_meshoptimizer()
{
static bool registered = false;
if (registered)
return;

// always give credit where credit is due
const int major = MESHOPTIMIZER_VERSION / 1000;
const int minor = (MESHOPTIMIZER_VERSION % 1000) / 10;
const int rev = MESHOPTIMIZER_VERSION % 10;
Settings::RegisterThirdPartyLib("meshoptimizer", std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(rev), "https://github.com/zeux/meshoptimizer");

registered = true;
}

static void simplify(std::vector<uint32_t>& indices, const std::vector<RHI_Vertex_PosTexNorTan>& vertices, size_t triangle_target)
{
register_meshoptimizer();

float reduction = 0.1f;
float error = 0.1f;
size_t index_count = indices.size();
Expand Down Expand Up @@ -378,6 +395,8 @@ namespace spartan::geometry_processing

static void optimize(std::vector<RHI_Vertex_PosTexNorTan>& vertices, std::vector<uint32_t>& indices)
{
register_meshoptimizer();

size_t vertex_count = vertices.size();
size_t index_count = indices.size();

Expand Down

0 comments on commit 719be40

Please sign in to comment.