mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-19 14:52:40 +08:00
@@ -1,2 +1,5 @@
|
||||
# ignore third_party code from clang-format checks
|
||||
./cocos/bindings/auto/*
|
||||
./cocos/gi/light-probe/predicates.cpp
|
||||
./cocos/gi/light-probe/tetgen.cpp
|
||||
./cocos/gi/light-probe/tetgen.h
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# ignore third_party code from clang-format checks
|
||||
./cocos/gi/light-probe/predicates.cpp
|
||||
./cocos/gi/light-probe/tetgen.cpp
|
||||
./cocos/gi/light-probe/tetgen.h
|
||||
@@ -499,6 +499,9 @@ cocos_source_files(
|
||||
cocos/gi/light-probe/PolynomialSolver.h
|
||||
cocos/gi/light-probe/SH.cpp
|
||||
cocos/gi/light-probe/SH.h
|
||||
cocos/gi/light-probe/tetgen.cpp
|
||||
cocos/gi/light-probe/tetgen.h
|
||||
cocos/gi/light-probe/predicates.cpp
|
||||
)
|
||||
|
||||
############ main
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
#include "base/Log.h"
|
||||
#include "core/platform/Debug.h"
|
||||
#include "math/Mat3.h"
|
||||
#define CC_USE_TETGEN 1
|
||||
#ifdef CC_USE_TETGEN
|
||||
#include "tetgen.h"
|
||||
#endif
|
||||
|
||||
namespace cc {
|
||||
namespace gi {
|
||||
@@ -79,6 +83,51 @@ void Delaunay::reset() {
|
||||
_edges.clear();
|
||||
}
|
||||
|
||||
#ifdef CC_USE_TETGEN
|
||||
void Delaunay::tetrahedralize() {
|
||||
tetgenio in;
|
||||
tetgenio out;
|
||||
|
||||
in.numberofpoints = static_cast<int32_t>(_probes.size());
|
||||
in.pointlist = new REAL[_probes.size() * 3];
|
||||
|
||||
constexpr float minFloat = std::numeric_limits<float>::min();
|
||||
constexpr float maxFloat = std::numeric_limits<float>::max();
|
||||
|
||||
Vec3 minPos = {maxFloat, maxFloat, maxFloat};
|
||||
Vec3 maxPos = {minFloat, minFloat, minFloat};
|
||||
|
||||
for (auto i = 0; i < _probes.size(); i++) {
|
||||
const auto &position = _probes[i].position;
|
||||
|
||||
in.pointlist[i * 3 + 0] = position.x;
|
||||
in.pointlist[i * 3 + 1] = position.y;
|
||||
in.pointlist[i * 3 + 2] = position.z;
|
||||
|
||||
minPos.x = std::min(minPos.x, position.x);
|
||||
maxPos.x = std::max(maxPos.x, position.x);
|
||||
|
||||
minPos.y = std::min(minPos.y, position.y);
|
||||
maxPos.y = std::max(maxPos.y, position.y);
|
||||
|
||||
minPos.z = std::min(minPos.z, position.z);
|
||||
maxPos.z = std::max(maxPos.z, position.z);
|
||||
}
|
||||
|
||||
const Vec3 center = (maxPos + minPos) * 0.5F;
|
||||
|
||||
tetgenbehavior options;
|
||||
options.neighout = 0;
|
||||
options.quiet = 1;
|
||||
::tetrahedralize(&options, &in, &out);
|
||||
|
||||
for (auto i = 0; i < out.numberoftetrahedra; i++) {
|
||||
_tetrahedrons.emplace_back(this, out.tetrahedronlist[i * 4], out.tetrahedronlist[i * 4 + 1], out.tetrahedronlist[i * 4 + 2], out.tetrahedronlist[i * 4 + 3]);
|
||||
}
|
||||
|
||||
reorder(center);
|
||||
}
|
||||
#else
|
||||
void Delaunay::tetrahedralize() {
|
||||
// get probe count first
|
||||
const auto probeCount = _probes.size();
|
||||
@@ -106,6 +155,7 @@ void Delaunay::tetrahedralize() {
|
||||
|
||||
reorder(center);
|
||||
}
|
||||
#endif
|
||||
|
||||
Vec3 Delaunay::initTetrahedron() {
|
||||
constexpr float minFloat = std::numeric_limits<float>::min();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user