Skip to content

Commit

Permalink
PopcornFX Gem 2.15.16
Browse files Browse the repository at this point in the history
  • Loading branch information
PopcornFX Bot committed Dec 1, 2023
1 parent 187e5f5 commit e32a01a
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 132 deletions.
1 change: 1 addition & 0 deletions Assets/PopcornFX_Dependencies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@
<Dependency path="shaders/depth/billboard/depthpasstransparentminbillboard.azshadervarianttree" optional="true" />
<Dependency path="shaders/mesh/legacy/mesh_legacy.azshadervarianttree" optional="true" />
<Dependency path="shaders/mesh/legacy/meshlit_legacy.azshadervarianttree" optional="true" />
<Dependency path="library/popcornfxcore/materials/defaulttextures/*.streamingimage" optional="true" />
</EngineDependencies>
22 changes: 19 additions & 3 deletions Code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# https://www.popcornfx.com/terms-and-conditions/
#----------------------------------------------------------------------------

set(POPCORNFX_VERSION 2.18.1)
set(POPCORNFX_VERSION 2.15.16)
set(POPCORNFX_LICENSE O3DE)

if (PK_O3DE_MAJOR_VERSION GREATER_EQUAL 2205)
Expand Down Expand Up @@ -33,6 +33,22 @@ ly_add_target(
Include
)

set(PK_OPTIONAL_REGISTER_NODEABLE_FILES
*.ScriptCanvasNodeable.xml,ScriptCanvasNodeableRegistry_Header.jinja,AutoGenNodeableRegistry.generated.h
*.ScriptCanvasNodeable.xml,ScriptCanvasNodeableRegistry_Source.jinja,AutoGenNodeableRegistry.generated.cpp
)
set(PK_OPTIONAL_REGISTER_NODEABLE_DEFINES PK_REGISTER_NODEABLE)

if(DEFINED O3DE_VERSION_MAJOR)
# O3DE 3.x.x and higher no longer need the autogen nodeable registry source files
# Also include special case to handle bug where SDK 23.05.0 engine version was set to the display version
if(O3DE_VERSION_MAJOR GREATER_EQUAL 3 AND
NOT (O3DE_VERSION_MAJOR EQUAL 23 AND O3DE_VERSION_MINOR EQUAL 05 AND O3DE_VERSION_PATCH EQUAL 0))
unset(PK_OPTIONAL_REGISTER_NODEABLE_FILES)
unset(PK_OPTIONAL_REGISTER_NODEABLE_DEFINES)
endif()
endif()

ly_add_target(
NAME PopcornFX.Static STATIC
NAMESPACE Gem
Expand All @@ -46,6 +62,7 @@ ly_add_target(
PK_USE_PHYSX
PK_USE_EMOTIONFX
PK_USE_STARTINGPOINTINPUT
${PK_OPTIONAL_REGISTER_NODEABLE_DEFINES}
INCLUDE_DIRECTORIES
PRIVATE
Source
Expand All @@ -72,8 +89,7 @@ ly_add_target(
AUTOGEN_RULES
*.ScriptCanvasNodeable.xml,ScriptCanvasNodeable_Header.jinja,$path/$fileprefix.generated.h
*.ScriptCanvasNodeable.xml,ScriptCanvasNodeable_Source.jinja,$path/$fileprefix.generated.cpp
*.ScriptCanvasNodeable.xml,ScriptCanvasNodeableRegistry_Header.jinja,AutoGenNodeableRegistry.generated.h
*.ScriptCanvasNodeable.xml,ScriptCanvasNodeableRegistry_Source.jinja,AutoGenNodeableRegistry.generated.cpp
${PK_OPTIONAL_REGISTER_NODEABLE_FILES}
)

ly_add_target(
Expand Down
8 changes: 4 additions & 4 deletions Code/Platform/Linux/PAL_linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
set(LY_PACKAGE_SERVER_URLS ${LY_PACKAGE_SERVER_URLS} "https://downloads.popcornfx.com/o3de-packages")
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(package_name PopcornFX-${POPCORNFX_VERSION}-${POPCORNFX_LICENSE}-linux)
set(pk_package_hash 08e30c12813e29e53eae075f4f9f02a1a308c7e8713bcf73abd9b207659abcd9)
set(pk_package_id Ng3RaXuqyAUWAgHy)
set(pk_package_hash a93262660d1f15cf86f7b5d1f674f9530b574d8b4ad480aceb8d4bb67a091836)
set(pk_package_id kX8RSRt2hZWQZutp)
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
set(package_name PopcornFX-${POPCORNFX_VERSION}-${POPCORNFX_LICENSE}-linux-aarch64)
set(pk_package_hash 0a81eb7ca2d717416efe2aa9ea4c5c3014e1b56c2acdb190556b8c490214beb4)
set(pk_package_id ZDEps23sNQA5p7q5)
set(pk_package_hash a93262660d1f15cf86f7b5d1f674f9530b574d8b4ad480aceb8d4bb67a091836_ARM64)
set(pk_package_id kX8RSRt2hZWQZutp_ARM64)
else()
message(FATAL_ERROR "Unsupported linux architecture ${CMAKE_SYSTEM_PROCESSOR}")
endif()
Expand Down
4 changes: 2 additions & 2 deletions Code/Platform/Mac/PAL_mac.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

set(LY_PACKAGE_SERVER_URLS ${LY_PACKAGE_SERVER_URLS} "https://downloads.popcornfx.com/o3de-packages")
set(package_name PopcornFX-${POPCORNFX_VERSION}-${POPCORNFX_LICENSE}-mac)
set(pk_package_hash 8e371903268af71a1a362194c7b58f43094b1ff9accc27f0fd4a117df470e760)
set(pk_package_id Kph45AXPVnUw9u6K)
set(pk_package_hash 5146d7599485b397f6e53c8b5cc628bbbb72e9a22b9a0feef60cf524d5e71abb)
set(pk_package_id roDQZpBI1HS7O2SX)

ly_associate_package(PACKAGE_NAME ${package_name} TARGETS PopcornFX PACKAGE_HASH ${pk_package_hash})
pk_download_package_ifn(${package_name} ${pk_package_id})
Expand Down
4 changes: 2 additions & 2 deletions Code/Platform/Windows/PAL_windows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

set(LY_PACKAGE_SERVER_URLS ${LY_PACKAGE_SERVER_URLS} "https://downloads.popcornfx.com/o3de-packages")
set(package_name PopcornFX-${POPCORNFX_VERSION}-${POPCORNFX_LICENSE}-windows)
set(pk_package_hash 4813982cd76ea251972abd8868f09a71d7f03fe3bd486dc1fc0ecbe243327354)
set(pk_package_id UntkQKUXJ57BnbcB)
set(pk_package_hash 50ef4f2879a49b9e10c438076dce1c9ea5b6f70f92bd61f8abdf8a770c26e968)
set(pk_package_id PsvjDNhF0Trboq2I)

ly_associate_package(PACKAGE_NAME ${package_name} TARGETS PopcornFX PACKAGE_HASH ${pk_package_hash})
pk_download_package_ifn(${package_name} ${pk_package_id})
Expand Down
177 changes: 66 additions & 111 deletions Code/Source/Integration/SceneInterface/SceneInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,57 +9,34 @@

#if defined(O3DE_USE_PK)

#include <AzCore/Component/ComponentApplicationBus.h>

#if defined(PK_USE_PHYSX)
#include <AzFramework/Physics/PhysicsScene.h>
#include <AzFramework/Physics/Material/PhysicsMaterialManager.h>
#include <AzCore/Interface/Interface.h>
#include <AzFramework/Physics/ShapeConfiguration.h>
#include <AzCore/Interface/Interface.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <PhysX/Material/PhysXMaterial.h>
#if RESOLVE_MATERIAL_PROPERTIES
#include <AzFramework/Physics/Material.h>
#endif
#if RESOLVE_CONTACT_OBJECT
#include <AzFramework/Physics/RigidBodyBus.h>
#endif
#endif

#include <AzCore/Console/IConsole.h>

#include "Integration/PopcornFXIntegrationBus.h"
#include "Integration/PopcornFXUtils.h"

namespace PopcornFX {

static void PrintPopcornFXPhysicsSurfaceTypesConstants(const AZ::ConsoleCommandContainer&)
{
if (auto *materialManager = AZ::Interface<Physics::MaterialManager>::Get())
{
AZStd::shared_ptr<Physics::Material> defaultMaterial = materialManager->GetDefaultMaterial();
if (defaultMaterial != null)
{
AZ_Printf("PopcornFX", "physics.surfaceTypes.Default %u", AZ::Crc32(defaultMaterial->GetId().ToString<AZStd::string>()));
}
}

AZ::Data::AssetCatalogRequests::AssetEnumerationCB popcornFxAssetReloadCb = [](const AZ::Data::AssetId id, const AZ::Data::AssetInfo& info)
{
if (info.m_assetType == ::Physics::MaterialAsset::RTTI_Type())
{
Physics::MaterialId materialId = Physics::MaterialId::CreateFromAssetId(id);
AZStd::string materialName = info.m_relativePath;

AZ::StringFunc::Replace(materialName, ".physicsmaterial", "");
AZ::StringFunc::Replace(materialName, "/", ".");

AZ_Printf("PopcornFX", "physics.surfaceTypes.%s %u", materialName.c_str(), AZ::Crc32(materialId.ToString<AZStd::string>()));
}
};
AZ::Data::AssetCatalogRequestBus::Broadcast(&AZ::Data::AssetCatalogRequestBus::Events::EnumerateAssets, null, popcornFxAssetReloadCb, null);
}

AZ_CONSOLEFREEFUNC(PrintPopcornFXPhysicsSurfaceTypesConstants, AZ::ConsoleFunctorFlags::Null, "Print the physics surface types constants to add in your PopcornFX project settings.");

#if defined(PK_USE_PHYSX)
void CSceneInterface::RayTracePacket(const Colliders::STraceFilter &traceFilter,
const Colliders::SRayPacket &packet,
const Colliders::STracePacket &results)
{
AzPhysics::SceneHandle sceneHandle = AzPhysics::InvalidSceneHandle;
AzPhysics::SceneInterface *sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get();
#if defined(PK_USE_PHYSX)
AzPhysics::SceneHandle sceneHandle = AzPhysics::InvalidSceneHandle;
auto *sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get();

if (sceneInterface != null)
{
#if defined(POPCORNFX_EDITOR)
Expand All @@ -75,14 +52,6 @@ namespace PopcornFX {
if (!PK_VERIFY(sceneHandle != AzPhysics::InvalidSceneHandle))
return;

Physics::MaterialManager *materialManager = null;
if (results.m_ContactSurfaces_Aligned16 != null)
{
materialManager = AZ::Interface<Physics::MaterialManager>::Get();
if (!PK_VERIFY(materialManager != null))
return;
}

AzPhysics::CollisionGroup collisionGroup(traceFilter.m_FilterFlags == 0 ? AzPhysics::CollisionGroup::All.GetMask() : traceFilter.m_FilterFlags);

const u32 resCount = results.Count();
Expand All @@ -109,7 +78,6 @@ namespace PopcornFX {
request.m_direction = ToAZ(dir);
request.m_distance = _rayDirAndLen.w();
request.m_collisionGroup = collisionGroup;
PK_ASSERT(request.m_reportMultipleHits == false);

hitResult = sceneInterface->QueryScene(sceneHandle, &request);
}
Expand All @@ -121,94 +89,81 @@ namespace PopcornFX {
request.m_direction = ToAZ(dir);
request.m_shapeConfiguration = AZStd::make_shared<Physics::SphereShapeConfiguration>(packet.m_RaySweepRadii_Aligned16[rayi]);
request.m_collisionGroup = collisionGroup;
PK_ASSERT(request.m_reportMultipleHits == false);

hitResult = sceneInterface->QueryScene(sceneHandle, &request);
}
if (!hitResult.m_hits.empty())
{
//m_reportMultipleHits in AzPhysics::RayCastRequest and AzPhysics::ShapeCastRequest are set to false by default, only 1 hit possible
//m_reportMultipleHits in AzPhysics::RayCastRequest and AzPhysics::ShapeCastRequest are set to false, only 1 hit possible
const AzPhysics::SceneQueryHit &hit = hitResult.m_hits[0];

results.m_HitTimes_Aligned16[rayi] = hit.m_distance;
if (results.m_ContactObjects_Aligned16 != null)
{
const bool haveBodyHandle = hit.m_resultFlags & AzPhysics::SceneQuery::ResultFlags::BodyHandle;
if (!haveBodyHandle)
results.m_ContactObjects_Aligned16[rayi] = null;
else
results.m_ContactObjects_Aligned16[rayi] = sceneInterface->GetSimulatedBodyFromHandle(sceneHandle, hit.m_bodyHandle);
}
if (results.m_ContactSurfaces_Aligned16 != null)
{
const bool havePhysicsMaterial = hit.m_resultFlags & AzPhysics::SceneQuery::ResultFlags::Material;
if (!havePhysicsMaterial)
results.m_ContactSurfaces_Aligned16[rayi] = null;
else
#if RESOLVE_CONTACT_OBJECT
Physics::RigidBody *rigidbody = null;
AZ::Entity *entity = null;
EBUS_EVENT_RESULT(entity, AZ::ComponentApplicationBus, FindEntity, hit.m_body->GetEntityId());
if (entity)
{
AZStd::shared_ptr<PhysX::Material> material = AZStd::rtti_pointer_cast<PhysX::Material>(materialManager->GetMaterial(hit.m_physicsMaterialId));
results.m_ContactSurfaces_Aligned16[rayi] = material.get();
Physics::RigidBodyRequestBus::EventResult(rigidbody, hit.m_body->GetEntityId(), &Physics::RigidBodyRequests::GetRigidBody);
}
if (rigidbody)
results.m_ContactObjects_Aligned16[rayi] = rigidbody;
else
#endif
results.m_ContactObjects_Aligned16[rayi] = CollidableObject::DEFAULT;
}
if (results.m_ContactPoints_Aligned16 != null)
results.m_ContactPoints_Aligned16[rayi].xyz() = ToPk(hit.m_position);
if (results.m_ContactNormals_Aligned16 != null)
results.m_ContactNormals_Aligned16[rayi].xyz() = ToPk(hit.m_normal);
#if RESOLVE_MATERIAL_PROPERTIES
if (results.m_ContactSurfaces_Aligned16 != null)
{
AZ::Entity *entity = null;
EBUS_EVENT_RESULT(entity, AZ::ComponentApplicationBus, FindEntity, hit.m_entityId);
if (entity)
{
Physics::RigidBody *rigidbody;
Physics::RigidBodyRequestBus::EventResult(rigidbody, hit.m_body->GetEntityId(), &Physics::RigidBodyRequests::GetRigidBody);
if (rigidbody)
{
Physics::MaterialId materialId = rigidbody->GetMaterialIdForShapeHierarchy(hit.m_hitShapeIdHierarchy);
Physics::MaterialProperties *matProperties = null;
Physics::MaterialRequestBus::BroadcastResult(matProperties, &Physics::MaterialRequests::GetPhysicsMaterialProperties, materialId);
results.m_ContactSurfaces_Aligned16[rayi] = matProperties;
}
}
}
#endif //RESOLVE_MATERIAL_PROPERTIES
}
}
#endif
}

void CSceneInterface::ResolveContactMaterials( [[maybe_unused]] const TMemoryView<void * const> &contactObjects,
const TMemoryView<void * const> &contactSurfaces,
const TMemoryView<Colliders::SSurfaceProperties> &outSurfaceProperties) const
{
PK_ASSERT(contactObjects.Count() == contactSurfaces.Count());
PK_ASSERT(contactObjects.Count() == outSurfaceProperties.Count());

static const PopcornFX::Colliders::SSurfaceProperties kDefaultSurface;

const u32 materialCount = contactSurfaces.Count();
for (u32 iMaterial = 0; iMaterial < materialCount; ++iMaterial)
{
PopcornFX::Colliders::SSurfaceProperties &surface = outSurfaceProperties[iMaterial];
surface = kDefaultSurface;
#if RESOLVE_MATERIAL_PROPERTIES
void CSceneInterface::ResolveContactMaterials( const TMemoryView<void * const> &contactObjects,
const TMemoryView<void * const> &contactSurfaces,
const TMemoryView<Colliders::SSurfaceProperties>&outSurfaceProperties) const
{
const u32 materialCount = contactSurfaces.Count();

PhysX::Material *material = reinterpret_cast<PhysX::Material*>(contactSurfaces[iMaterial]);
if (material == null)
continue;

surface.m_Restitution = material->GetRestitution();
surface.m_StaticFriction = material->GetStaticFriction();
surface.m_DynamicFriction = material->GetDynamicFriction();
surface.m_SurfaceType = AZ::Crc32(material->GetId().ToString<AZStd::string>());

#define REMAP_COMBINE_MODE(__member, __val) \
switch (__val) \
{ \
case PhysX::CombineMode::Average: \
surface.__member = PopcornFX::Colliders::ECombineMode::Combine_Average; \
break; \
case PhysX::CombineMode::Minimum: \
surface.__member = PopcornFX::Colliders::ECombineMode::Combine_Min; \
break; \
case PhysX::CombineMode::Maximum: \
surface.__member = PopcornFX::Colliders::ECombineMode::Combine_Max; \
break; \
case PhysX::CombineMode::Multiply: \
surface.__member = PopcornFX::Colliders::ECombineMode::Combine_Multiply; \
break; \
default: \
PK_ASSERT_NOT_REACHED(); \
break; \
}

REMAP_COMBINE_MODE(m_FrictionCombineMode, material->GetFrictionCombineMode());
REMAP_COMBINE_MODE(m_RestitutionCombineMode, material->GetRestitutionCombineMode());

#undef REMAP_COMBINE_MODE
}
for (u32 iMaterial = 0; iMaterial < materialCount; ++iMaterial)
{
PopcornFX::Colliders::SSurfaceProperties &surface = outSurfaceProperties[iMaterial];
Physics::MaterialProperties *matProperties = reinterpret_cast<Physics::MaterialProperties*>(contactSurfaces[iMaterial]);
if (matProperties == null)
continue;
surface.m_Restitution = matProperties->m_restitution;
surface.m_StaticFriction = matProperties->m_friction;
surface.m_DynamicFriction = surface.m_StaticFriction;
surface.m_SurfaceType = AZStd::hash<AZStd::string>{}(matProperties->m_name);
surface.m_RestitutionCombineMode = Colliders::Combine_Average;
surface.m_FrictionCombineMode = Colliders::Combine_Average;
}
#endif //PK_USE_PHYSX
}
#endif //RESOLVE_MATERIAL_PROPERTIES

}

Expand Down
7 changes: 5 additions & 2 deletions Code/Source/Integration/SceneInterface/SceneInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@

#include <pk_particles/include/ps_scene.h>

#define RESOLVE_MATERIAL_PROPERTIES 0
#define RESOLVE_CONTACT_OBJECT 0

namespace PopcornFX {

class CSceneInterface : public IParticleScene
{
public:
#if defined(PK_USE_PHYSX)
virtual void RayTracePacket( const Colliders::STraceFilter &traceFilter,
const Colliders::SRayPacket &packet,
const Colliders::STracePacket &results) override;

#if RESOLVE_MATERIAL_PROPERTIES
virtual void ResolveContactMaterials(const TMemoryView<void * const> &contactObjects,
const TMemoryView<void * const> &contactSurfaces,
const TMemoryView<Colliders::SSurfaceProperties>&outSurfaceProperties) const override;
#endif //PK_USE_PHYSX
#endif

void SetInGameMode(bool inGameMode) { m_InGameMode = inGameMode; }

Expand Down
19 changes: 19 additions & 0 deletions Code/Source/Integration/Startup/PopcornFxStartup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,23 @@ namespace PopcornFX {
};
}
};
#else
class CLogListenerO3DERelease : public ILogListener
{
public:
virtual void Notify(CLog::ELogLevel level, CGuid logClass, const char* message) override
{
const CString s = CString::Format("[%s] ERROR: %s", CLog::LogClassToString(logClass), message);

switch (level)
{
case PopcornFX::CLog::Level_Error:
case PopcornFX::CLog::Level_ErrorCritical:
AZ_Printf("PopcornFX", s.Data());
break;
};
}
};
#endif

//----------------------------------------------------------------------------
Expand All @@ -95,6 +112,8 @@ namespace PopcornFX {

#ifndef PK_RETAIL
CLog::AddGlobalListener(PK_NEW(CLogListenerO3DE));
#else
CLog::AddGlobalListener(PK_NEW(CLogListenerO3DERelease));
#endif
}

Expand Down
Loading

0 comments on commit e32a01a

Please sign in to comment.