Files
Mike Balfour 2fe4524458 Terrain API cleanups (#4914)
* Terrain API fixups
Moved SurfaceData definitions in AzFramework out of terrain into separate files.
Added some missing API calls: Get*FromVector2, GetSurfacePoint*
Changed OrderedSurfaceTagWeightSet to SurfaceTagWeightList

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

* PR feedback - remove IsClose check.

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

* Fixed PhysX test compile failures by redcoding a bunch of "dummy terrain" implementation that's unused.
It was originally added for the PhysX Terrain component, but that component is long gone and has been superceded by the more generic PhysX Heightfield Collider.

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

* Fixed up failing terrain unit tests.
Added API changes, and changed the assumption on where the surface weight sort is taking place.  The component is no longer expected to provide the sorted list, it only needs to be sorted at the end coming out of the terrain system, so the unit tests have been modified to reflect that.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
2021-10-22 14:22:57 -05:00

67 lines
2.8 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include "AzCore/Component/Component.h"
#include <AzFramework/Physics/Collision/CollisionEvents.h>
#include <AzFramework/Physics/Common/PhysicsSimulatedBodyEvents.h>
#include <AzFramework/Terrain/TerrainDataRequestBus.h>
namespace PhysX
{
//! CollisionCallbacksListener listens to collision events for a particular sceneHandle and simulatedBodyHandle
class CollisionCallbacksListener
{
public:
explicit CollisionCallbacksListener(AZ::EntityId entityId);
CollisionCallbacksListener(AzPhysics::SceneHandle sceneHandle, AzPhysics::SimulatedBodyHandle bodyHandle);
~CollisionCallbacksListener();
AZStd::vector<AzPhysics::CollisionEvent> m_beginCollisions;
AZStd::vector<AzPhysics::CollisionEvent> m_persistCollisions;
AZStd::vector<AzPhysics::CollisionEvent> m_endCollisions;
AZStd::function<void(const AzPhysics::CollisionEvent& collisionEvent)> m_onCollisionBegin;
AZStd::function<void(const AzPhysics::CollisionEvent& collisionEvent)> m_onCollisionPersist;
AZStd::function<void(const AzPhysics::CollisionEvent& collisionEvent)> m_onCollisionEnd;
private:
void InitCollisionHandlers();
AzPhysics::SimulatedBodyEvents::OnCollisionBegin::Handler m_onCollisionBeginHandler;
AzPhysics::SimulatedBodyEvents::OnCollisionPersist::Handler m_onCollisionPersistHandler;
AzPhysics::SimulatedBodyEvents::OnCollisionEnd::Handler m_onCollisionEndHandler;
};
//! TestTriggerAreaNotificationListener listens to trigger events for a particular sceneHandle and simulatedBodyHandle
class TestTriggerAreaNotificationListener
{
public:
explicit TestTriggerAreaNotificationListener(AZ::EntityId entityId);
TestTriggerAreaNotificationListener(AzPhysics::SceneHandle sceneHandle, AzPhysics::SimulatedBodyHandle bodyHandle);
~TestTriggerAreaNotificationListener();
const AZStd::vector<AzPhysics::TriggerEvent>& GetEnteredEvents() const { return m_enteredEvents; }
const AZStd::vector<AzPhysics::TriggerEvent>& GetExitedEvents() const { return m_exitedEvents; }
AZStd::function<void(const AzPhysics::TriggerEvent& event)> m_onTriggerEnter;
AZStd::function<void(const AzPhysics::TriggerEvent& event)> m_onTriggerExit;
private:
void InitTriggerHandlers();
AZStd::vector<AzPhysics::TriggerEvent> m_enteredEvents;
AZStd::vector<AzPhysics::TriggerEvent> m_exitedEvents;
AzPhysics::SimulatedBodyEvents::OnTriggerEnter::Handler m_onTriggerEnterHandler;
AzPhysics::SimulatedBodyEvents::OnTriggerExit::Handler m_onTriggerExitHandler;
};
} // namespace PhysX