JoltPhysics3D: Fix JoltConvexHullCollider3D::BuildDebugMesh
This commit is contained in:
parent
f7d0f4ca23
commit
4f1f0c6418
|
|
@ -279,7 +279,7 @@ int main()
|
|||
Nz::SparsePtr<Nz::Vector3f> vertices = vertexMapper.GetComponentPtr<Nz::Vector3f>(Nz::VertexComponent::Position);
|
||||
|
||||
#if USE_JOLT
|
||||
auto shipCollider = std::make_shared<Nz::JoltConvexHullCollider3D>(vertices, vertexMapper.GetVertexCount());
|
||||
auto shipCollider = std::make_shared<Nz::JoltConvexHullCollider3D>(vertices, vertexMapper.GetVertexCount(), 0.1f);
|
||||
#else
|
||||
auto shipCollider = std::make_shared<Nz::BulletConvexCollider3D>(vertices, vertexMapper.GetVertexCount());
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#include <Nazara/Utility/SoftwareBuffer.hpp>
|
||||
#include <Nazara/Utility/StaticMesh.hpp>
|
||||
#include <Nazara/Utility/VertexBuffer.hpp>
|
||||
#include <NazaraUtils/MemoryHelper.hpp>
|
||||
#include <NazaraUtils/StackArray.hpp>
|
||||
#include <tsl/ordered_map.h>
|
||||
#include <Jolt/Core/Core.h>
|
||||
#include <Jolt/Physics/Collision/Shape/BoxShape.h>
|
||||
|
|
@ -320,14 +320,27 @@ namespace Nz
|
|||
const JPH::ConvexHullShapeSettings* settings = GetShapeSettingsAs<JPH::ConvexHullShapeSettings>();
|
||||
const JPH::ConvexHullShape* shape = SafeCast<const JPH::ConvexHullShape*>(settings->Create().Get().GetPtr());
|
||||
|
||||
unsigned int pointCount = shape->GetNumPoints();
|
||||
for (int i = 1; i < pointCount; ++i)
|
||||
unsigned int faceCount = shape->GetNumFaces();
|
||||
unsigned int maxVerticesInFace = 0;
|
||||
for (unsigned int i = 0; i < faceCount; ++i)
|
||||
maxVerticesInFace = std::max(maxVerticesInFace, shape->GetNumVerticesInFace(i));
|
||||
|
||||
StackArray<unsigned int> faceVertices = NazaraStackArrayNoInit(unsigned int, maxVerticesInFace);
|
||||
for (unsigned int i = 0; i < faceCount; ++i)
|
||||
{
|
||||
indices.push_back(InsertVertex(offsetMatrix * FromJolt(shape->GetPoint(i - 1))));
|
||||
indices.push_back(InsertVertex(offsetMatrix * FromJolt(shape->GetPoint(i))));
|
||||
unsigned int vertexCount = shape->GetFaceVertices(i, maxVerticesInFace, faceVertices.data());
|
||||
if (vertexCount > 2)
|
||||
{
|
||||
for (unsigned int i = 1; i < vertexCount; ++i)
|
||||
{
|
||||
indices.push_back(InsertVertex(offsetMatrix * FromJolt(shape->GetPoint(faceVertices[i - 1]))));
|
||||
indices.push_back(InsertVertex(offsetMatrix * FromJolt(shape->GetPoint(faceVertices[i]))));
|
||||
}
|
||||
|
||||
indices.push_back(InsertVertex(offsetMatrix * FromJolt(shape->GetPoint(faceVertices[vertexCount - 1]))));
|
||||
indices.push_back(InsertVertex(offsetMatrix * FromJolt(shape->GetPoint(faceVertices[0]))));
|
||||
}
|
||||
}
|
||||
indices.push_back(InsertVertex(offsetMatrix* FromJolt(shape->GetPoint(pointCount - 1))));
|
||||
indices.push_back(InsertVertex(offsetMatrix* FromJolt(shape->GetPoint(0))));
|
||||
}
|
||||
|
||||
JoltColliderType3D JoltConvexHullCollider3D::GetType() const
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ add_requires(
|
|||
"minimp3",
|
||||
"ordered_map",
|
||||
"stb")
|
||||
add_requires("joltphysics 352550fdd562ce6034b27ab12d1470840e879b56", { configs = { debug = is_mode("debug") }})
|
||||
add_requires("joltphysics 24147a6936c63f4f09c6c37173169d8f366f9fb4", { configs = { debug = is_mode("debug") }})
|
||||
add_requires("freetype", { configs = { bzip2 = true, png = true, woff2 = true, zlib = true, debug = is_mode("debug") } })
|
||||
add_requires("libvorbis", { configs = { with_vorbisenc = false } })
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue