-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cmake_minimum_required(VERSION 3.20) | ||
|
||
message(STATUS "----------------------------------------------------------------") | ||
message(STATUS "quickhull") | ||
message(STATUS "----------------------------------------------------------------") | ||
|
||
file(GLOB SOURCES quickhull/*.cpp quickhull/*.hpp quickhull/Structs/*) | ||
|
||
add_library(quickhull STATIC ${SOURCES}) | ||
|
||
target_include_directories(quickhull INTERFACE .) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <quickhull/QuickHull.hpp> | ||
|
||
#include "mesh.h" | ||
|
||
#include <cage-core/meshAlgorithms.h> | ||
#include <cage-core/serialization.h> | ||
|
||
namespace cage | ||
{ | ||
CAGE_CORE_API Holder<Mesh> meshConvexHull(const Mesh *msh, const MeshConvexHullConfig &config) | ||
{ | ||
if (msh->type() != MeshTypeEnum::Triangles) | ||
CAGE_THROW_ERROR(Exception, "mesh convex hull requires triangles mesh"); | ||
|
||
quickhull::QuickHull<float> qh; | ||
const auto tmp = qh.getConvexHull(reinterpret_cast<const float *>(msh->positions().data()), msh->positions().size(), false, false); | ||
|
||
Holder<Mesh> res = newMesh(); | ||
{ | ||
static_assert(sizeof(quickhull::Vector3<float>) == sizeof(Vec3)); | ||
PointerRange r(tmp.getVertexBuffer().begin(), tmp.getVertexBuffer().end()); | ||
res->positions(bufferCast<const Vec3>(r)); | ||
} | ||
{ | ||
std::vector<uint32> inds; | ||
inds.reserve(tmp.getIndexBuffer().size()); | ||
for (auto it : tmp.getIndexBuffer()) | ||
inds.push_back(numeric_cast<uint32>(it)); | ||
res->indices(inds); | ||
} | ||
return res; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters