JoltPhysics3D/JoltCollider3D: Fix offsetMatrix not taken into account

This commit is contained in:
SirLynix 2023-04-05 08:45:54 +02:00 committed by Jérôme Leclercq
parent 61724cc4b9
commit 77ee7d8c92
1 changed files with 10 additions and 10 deletions

View File

@ -166,8 +166,8 @@ namespace Nz
float radius = capsuleSettings->mRadius; float radius = capsuleSettings->mRadius;
float halfHeight = capsuleSettings->mHalfHeightOfCylinder; float halfHeight = capsuleSettings->mHalfHeightOfCylinder;
std::optional<std::size_t> firstVertex; std::optional<UInt16> firstVertex;
std::optional<std::size_t> lastVertex; std::optional<UInt16> lastVertex;
for (unsigned int slice = 0; slice < sliceCount; ++slice) for (unsigned int slice = 0; slice < sliceCount; ++slice)
{ {
@ -178,20 +178,20 @@ namespace Nz
{ {
auto [sin, cos] = RadianAnglef(0.5f * Pi<float> * i / cornerStepCount).GetSinCos(); auto [sin, cos] = RadianAnglef(0.5f * Pi<float> * i / cornerStepCount).GetSinCos();
std::size_t index; UInt16 index;
if (firstVertex && i == 0) if (firstVertex && i == 0)
index = *firstVertex; index = *firstVertex;
else else
{ {
index = vertices.size(); index = SafeCast<UInt16>(vertices.size());
vertices.push_back(top + rot * (radius * Vector3f(sin, cos, 0.f))); vertices.push_back(offsetMatrix * (top + rot * (radius * Vector3f(sin, cos, 0.f))));
if (i == 0) if (i == 0)
firstVertex = index; firstVertex = index;
} }
if (i > 1) if (i > 1)
{ {
indices.push_back(index - 1); indices.push_back(static_cast<UInt16>(index - 1));
indices.push_back(index); indices.push_back(index);
} }
else if (i == 1) else if (i == 1)
@ -206,18 +206,18 @@ namespace Nz
{ {
auto [sin, cos] = RadianAnglef(0.5f * Pi<float> * i / cornerStepCount).GetSinCos(); auto [sin, cos] = RadianAnglef(0.5f * Pi<float> * i / cornerStepCount).GetSinCos();
std::size_t index; UInt16 index;
if (lastVertex && i == sliceCount - 1) if (lastVertex && i == sliceCount - 1)
index = *lastVertex; index = *lastVertex;
else else
{ {
index = vertices.size(); index = SafeCast<UInt16>(vertices.size());
vertices.push_back(bottom - rot * (radius * Vector3f(-cos, sin, 0.f))); vertices.push_back(offsetMatrix * (bottom - rot * (radius * Vector3f(-cos, sin, 0.f))));
if (i == sliceCount - 1) if (i == sliceCount - 1)
lastVertex = index; lastVertex = index;
} }
indices.push_back(index - 1); indices.push_back(static_cast<UInt16>(index - 1));
indices.push_back(index); indices.push_back(index);
} }
} }