Files
o3de/Code/Framework/AzFramework/AzFramework/Render/GeometryIntersectionStructures.h
T
lumberyard-employee-dm 090aa8f053 Removed ununeeded includes from EBus EBus.h and Policies.h (#4256)
* Removed ununeeded includes from EBus EBus.h and Policies.h

Updated the locations which needed those includes

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Adding missing include for <memory> to AWsClientAuthBus.h

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Remove the while true loop in the EBusQueuePolicy Execute() function

The while true loop in Execute was for allowing additional functions to be queued in the middle of execution of current list of functions.
That functionality was dangerous, because if a queued function added itself during execution unconditionally, then it would result in an infinite loop

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Updated the AssetManager::DispatchEvents function to pump the AssetBus event queue until empty

Queued Events on the AssetBus is able to queue additional events on that Bus during execution of those events.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Changed the AssetManager::DispatchEvents function to only execute the
AssetBus queued events once

Changed the AssetJobsFloodTest.AssetWithNoLoadReference_LoadDependencies_BehaviorObeyed test to dispatch events until the OnAssetContainerReady callback is signaled.

This happens after every asset load to make sure that the
expiring AssetContainer instances are removed from `AssetManager::m_ownedAssetContainer` container before retrying to load the same asset.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Added a MaxTimeoutSeconds constant for the maximum amount of the time to run a single DispatchEvents loop

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
2021-09-29 18:13:37 -05:00

100 lines
3.7 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/Math/Aabb.h>
#include <AzCore/Math/Vector2.h>
#include <AzCore/Math/Vector3.h>
#include <AzCore/Component/ComponentBus.h>
#include <AzCore/std/containers/unordered_set.h>
#include <AzCore/std/functional.h>
//! Common structures for Render geometry queries
namespace AzFramework
{
//! Aggregator for usage with EBus BroadcastResult or EventResult
//! Contains the AABB union of all the handlers
struct AabbUnionAggregator
{
AZ::Aabb operator()(AZ::Aabb lhs, const AZ::Aabb& rhs) const
{
lhs.AddAabb(rhs);
return lhs;
}
};
namespace RenderGeometry
{
struct EntityFilter
{
bool operator()(AZ::EntityId entityId) const
{
bool isIgnored = m_ignoreEntities.find(entityId) != m_ignoreEntities.end();
if (!isIgnored)
{
bool noExclusivesOrIsExclusive = (m_exclusiveEntities.empty()) || (m_exclusiveEntities.find(entityId) != m_ignoreEntities.end());
if (noExclusivesOrIsExclusive)
{
bool considered = !m_filterFunction || m_filterFunction(entityId);
return considered;
}
}
return false;
}
bool HasFilter() const
{
return !m_exclusiveEntities.empty() || !m_ignoreEntities.empty() || m_filterFunction;
}
AZStd::unordered_set<AZ::EntityId> m_exclusiveEntities; //! If *not empty*, will only raycast against these entities
AZStd::unordered_set<AZ::EntityId> m_ignoreEntities; //! Entities to ignore
AZStd::function<bool(AZ::EntityId)> m_filterFunction; //! Optional custom filter callback, return true for using argument's entityid for raycast
//! return false for not considering this entity
};
//! Ray intersection request
struct RayRequest
{
AZ::Vector3 m_startWorldPosition; //!< Ray start position in world space
AZ::Vector3 m_endWorldPosition; //!< Ray end position in world space
bool m_onlyVisible = true; //!< Whether to only consider visible objects
EntityFilter m_entityFilter; //!< Filter for entities
};
//! Result of intersection
struct RayResult
{
AZ::Vector3 m_worldPosition; //!< Hit position in world space
AZ::Vector3 m_worldNormal; //!< Normal of the surface hit in world space
AZ::Vector2 m_uv; //!< UV texture coordinates of the intersected geometry
AZ::EntityComponentIdPair m_entityAndComponent; //!< Entity and component hit, for non-entity systems this can be invalid
float m_distance = FLT_MAX; //!< Distance from ray start to hit collision, FLT_MAX if there is no hit
explicit operator bool() const
{
return m_distance != FLT_MAX;
}
};
//! Aggregator for usage with EBus BroadcastResult or EventResult
//! Contains the closet successful hit of all the handlers
struct RayResultClosestAggregator
{
RayResult operator()(RayResult lhs, const RayResult& rhs) const
{
if (rhs && rhs.m_distance < lhs.m_distance)
{
lhs = rhs;
}
return lhs;
}
};
}
}