feat: updated engine version to 4.4-rc1
This commit is contained in:
parent
ee00efde1f
commit
21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions
40
engine/thirdparty/jolt_physics/Jolt/TriangleSplitter/TriangleSplitterMean.cpp
vendored
Normal file
40
engine/thirdparty/jolt_physics/Jolt/TriangleSplitter/TriangleSplitterMean.cpp
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <Jolt/Jolt.h>
|
||||
|
||||
#include <Jolt/TriangleSplitter/TriangleSplitterMean.h>
|
||||
|
||||
JPH_NAMESPACE_BEGIN
|
||||
|
||||
TriangleSplitterMean::TriangleSplitterMean(const VertexList &inVertices, const IndexedTriangleList &inTriangles) :
|
||||
TriangleSplitter(inVertices, inTriangles)
|
||||
{
|
||||
}
|
||||
|
||||
bool TriangleSplitterMean::Split(const Range &inTriangles, Range &outLeft, Range &outRight)
|
||||
{
|
||||
// Calculate mean value for these triangles
|
||||
Vec3 mean = Vec3::sZero();
|
||||
for (uint t = inTriangles.mBegin; t < inTriangles.mEnd; ++t)
|
||||
mean += Vec3(mCentroids[mSortedTriangleIdx[t]]);
|
||||
mean *= 1.0f / inTriangles.Count();
|
||||
|
||||
// Calculate deviation
|
||||
Vec3 deviation = Vec3::sZero();
|
||||
for (uint t = inTriangles.mBegin; t < inTriangles.mEnd; ++t)
|
||||
{
|
||||
Vec3 delta = Vec3(mCentroids[mSortedTriangleIdx[t]]) - mean;
|
||||
deviation += delta * delta;
|
||||
}
|
||||
deviation *= 1.0f / inTriangles.Count();
|
||||
|
||||
// Calculate split plane
|
||||
uint dimension = deviation.GetHighestComponentIndex();
|
||||
float split = mean[dimension];
|
||||
|
||||
return SplitInternal(inTriangles, dimension, split, outLeft, outRight);
|
||||
}
|
||||
|
||||
JPH_NAMESPACE_END
|
||||
Loading…
Add table
Add a link
Reference in a new issue