Terrain Physics Heightfield support

* New Heightfield Components

Signed-off-by: John Jones-Steele <jjjoness@amazon.com>

* Misc PR fixes
* Fixed linux build failure from bad #include
* Renamed "Terrain Physics Collider" to "Terrain Physics Heightfield Collider" per physics team feedback
* Fixed 1/5 -> 1/4 typo in a comment
* Added missing member copies in HeightfieldShapeConfiguration

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Addressed PR feedback

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Changes from review

Signed-off-by: John Jones-Steele <jjjoness@amazon.com>

* Remove tabs accidently added

Signed-off-by: John Jones-Steele <jjjoness@amazon.com>

* Fixed overly complicated scaling math.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Added comments to make it more obvious what's happening on CreateEnd / DestroyBegin.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Moved Heightfield CreatePxGeometryFromConfig into its own function

Signed-off-by: John Jones-Steele <jjjoness@amazon.com>

Co-authored-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
This commit is contained in:
John Jones-Steele
2021-10-22 16:19:36 +01:00
committed by GitHub
parent 775dda8ed2
commit 3d67be162c
53 changed files with 3218 additions and 436 deletions
@@ -252,6 +252,22 @@ namespace PhysX
return convex;
}
physx::PxHeightField* SystemComponent::CreateHeightField(const physx::PxHeightFieldSample* samples, AZ::u32 numRows, AZ::u32 numColumns)
{
physx::PxHeightFieldDesc desc;
desc.format = physx::PxHeightFieldFormat::eS16_TM;
desc.nbColumns = numColumns;
desc.nbRows = numRows;
desc.samples.data = samples;
desc.samples.stride = sizeof(physx::PxHeightFieldSample);
physx::PxHeightField* heightfield =
m_physXSystem->GetPxCooking()->createHeightField(desc, m_physXSystem->GetPxPhysics()->getPhysicsInsertionCallback());
AZ_Error("PhysX", heightfield, "Error. Unable to create heightfield");
return heightfield;
}
bool SystemComponent::CookConvexMeshToFile(const AZStd::string& filePath, const AZ::Vector3* vertices, AZ::u32 vertexCount)
{
AZStd::vector<AZ::u8> physxData;
@@ -342,6 +358,14 @@ namespace PhysX
return AZStd::make_shared<PhysX::Material>(materialConfiguration);
}
void SystemComponent::ReleaseNativeHeightfieldObject(void* nativeHeightfieldObject)
{
if (nativeHeightfieldObject)
{
static_cast<physx::PxBase*>(nativeHeightfieldObject)->release();
}
}
void SystemComponent::ReleaseNativeMeshObject(void* nativeMeshObject)
{
if (nativeMeshObject)