Skip to content

Commit

Permalink
A couple of fixes (ezEngine#1413)
Browse files Browse the repository at this point in the history
* Don't assert in filesystem when encountering a non-absolute path
* Don't use RG16_UNORM for uncompressed normal maps
* Fixed uninitialized variable in navmesh steering, that could result in bots not starting to move
* Added a couple of static link references
  • Loading branch information
jankrassnigg authored Oct 22, 2024
1 parent 40e3b84 commit ccc8e4f
Show file tree
Hide file tree
Showing 24 changed files with 165 additions and 3 deletions.
79 changes: 78 additions & 1 deletion Code/BuildSystem/CMake/Platforms/Configure_Web.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,81 @@ macro(ez_platform_detect_generator)
else()
message(FATAL_ERROR "Generator '${CMAKE_GENERATOR}' is not supported on Web! Please extend ez_platform_detect_generator()")
endif()
endmacro()
endmacro()

macro (ez_platformhook_set_build_flags_clang TARGET_NAME)

target_compile_options(${TARGET_NAME} PRIVATE
"-pthread"
"-mbulk-memory"
"-matomics"
"-fno-exceptions"

"-msimd128"
"-msse4.2"

# Debug Build
"$<$<CONFIG:${EZ_BUILDTYPENAME_DEBUG_UPPER}>:-gsource-map>"
"$<$<CONFIG:${EZ_BUILDTYPENAME_DEBUG_UPPER}>:-g3>"

# Dev Build
"$<$<CONFIG:${EZ_BUILDTYPENAME_DEV_UPPER}>:-gsource-map>"
"$<$<CONFIG:${EZ_BUILDTYPENAME_DEV_UPPER}>:-g2>"

# Shipping Build
"$<$<CONFIG:${EZ_BUILDTYPENAME_SHIPPING_UPPER}>:-g0>"
)

endmacro()

macro(ez_platformhook_set_application_properties TARGET_NAME)

target_link_options(${TARGET_NAME} PRIVATE

# General
"-sWASM=1"
"-lembind"
# "-sMODULARIZE=1" # Doesn't work at startup
"-sDISABLE_EXCEPTION_CATCHING=1"
# "-sWASM_BIGINT" # depends on browser support (https://emscripten.org/docs/tools_reference/settings_reference.html?highlight=environment#wasm-bigint)
"-sFETCH=1"

# Webpage Template
"--shell-file" "${CMAKE_SOURCE_DIR}/Code/BuildSystem/Web/em-default.html"

# Main memory and main thread stack size
"-sINITIAL_MEMORY=512MB"
"-sTOTAL_MEMORY=512MB"
"-sSTACK_SIZE=4MB"

# Threads
"-pthread"
"-sUSE_PTHREADS=1"
"-sPROXY_TO_PTHREAD=1"
"-sPTHREAD_POOL_SIZE=20"
"-sDEFAULT_PTHREAD_STACK_SIZE=1MB"

# WebGPU
"-sUSE_WEBGPU=1"
"-sOFFSCREENCANVAS_SUPPORT"

# Debug Build
"$<$<CONFIG:${EZ_BUILDTYPENAME_DEBUG_UPPER}>:-sSTACK_OVERFLOW_CHECK=1>"
"$<$<CONFIG:${EZ_BUILDTYPENAME_DEBUG_UPPER}>:-sASSERTIONS=1>"
"$<$<CONFIG:${EZ_BUILDTYPENAME_DEBUG_UPPER}>:-g3>"

# Dev Build
"$<$<CONFIG:${EZ_BUILDTYPENAME_DEV_UPPER}>:-sASSERTIONS=1>"
"$<$<CONFIG:${EZ_BUILDTYPENAME_DEV_UPPER}>:-g2>"

# Shipping Build
"$<$<CONFIG:${EZ_BUILDTYPENAME_SHIPPING_UPPER}>:-g0>"
)

endmacro()

macro(ez_platformhook_package_files TARGET_NAME SRC_FOLDER DST_FOLDER)

target_link_options(${TARGET_NAME} PRIVATE "SHELL: --preload-file ${SRC_FOLDER}@/${DST_FOLDER}")

endmacro()
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ namespace ezDataDirectory

ezStringBuilder sPath = GetRedirectedDataDirectoryPath();
sPath.AppendPath(sRedirectedAsset);
sPath.MakeCleanPath();

return sPath.IsAbsolutePath() && ezOSFile::ExistsFile(sPath);
}

Expand Down
5 changes: 4 additions & 1 deletion Code/Engine/Texture/TexConv/Implementation/OutputFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ static ezImageFormat::Enum DetermineOutputFormatPC(
if (compressionMode >= ezTexConvCompressionMode::Medium)
return ezImageFormat::R8G8_UNORM;

return ezImageFormat::R16G16_UNORM;
// TODO: in the rare case that the input texture has higher precision, we could use R16G16_UNORM or R16G16_FLOAT here
// R16G16_UNORM isn't supported on all platforms, so R16G16_FLOAT may be better
// return ezImageFormat::R16G16_FLOAT;
return ezImageFormat::R8G8_UNORM;
}

if (targetFormat == ezTexConvUsage::Color)
Expand Down
5 changes: 5 additions & 0 deletions Code/EnginePlugins/AiPlugin/AiPluginPCH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ EZ_STATICLINK_LIBRARY(AiPlugin)
{
if (bReturn)
return;

EZ_STATICLINK_REFERENCE(AiPlugin_Navigation_Components_NavMeshObstacleComponent);
EZ_STATICLINK_REFERENCE(AiPlugin_Navigation_Components_NavMeshPathTestComponent);
EZ_STATICLINK_REFERENCE(AiPlugin_Navigation_Components_NavigationComponent);
EZ_STATICLINK_REFERENCE(AiPlugin_Navigation_Implementation_NavMeshWorldModule);
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,6 @@ void ezNavMeshObstacleComponent::InvalidateSectors()
}
}
}


EZ_STATICLINK_FILE(AiPlugin, AiPlugin_Navigation_Components_NavMeshObstacleComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,6 @@ void ezAiNavMeshPathTestComponent::Update()
// GetOwner()->SetGlobalPosition(m_Steering.m_vPosition);
// GetOwner()->SetGlobalRotation(m_Steering.m_qRotation);
}


EZ_STATICLINK_FILE(AiPlugin, AiPlugin_Navigation_Components_NavMeshPathTestComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,6 @@ void ezAiNavigationComponent::PlaceOnGround(ezTransform& transform, float tDiff)
transform.m_vPosition.z += fFallDist;
}
}


EZ_STATICLINK_FILE(AiPlugin, AiPlugin_Navigation_Components_NavigationComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,6 @@ const dtQueryFilter& ezAiNavMeshWorldModule::GetPathSearchFilter(ezStringView sN
ezLog::Warning("Ai Path Search Filter '{}' does not exist.", sName);
return it.Value();
}


EZ_STATICLINK_FILE(AiPlugin, AiPlugin_Navigation_Implementation_NavMeshWorldModule);
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ bool ezAiNavigation::UpdatePathSearch()
// the target position here may already differ from the target position when the search was started
// so we need to use m_vPathSearchTargetPos
// the final target position will be updated in the next Update()
m_PathCorridor.reset(resultPolys[0], ezRcPos(m_vCurrentPosition));
m_PathCorridor.setCorridor(ezRcPos(m_vPathSearchTargetPos), resultPolys, (ezUInt32)iPathCorridorLength);

m_uiOptimizeTopologyCounter = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,6 @@ void ezCreatureCrawlComponent::Update()
}
}
}


EZ_STATICLINK_FILE(GameComponentsPlugin, GameComponentsPlugin_Animation_Implementation_CreatureCrawlComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,6 @@ void ezMoveToComponent::Update()

pOwner->SetGlobalPosition(vCurPos + vDir * fTravelDist);
}


EZ_STATICLINK_FILE(GameComponentsPlugin, GameComponentsPlugin_Animation_Implementation_MoveToComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,6 @@ void ezLineToComponentManager::Update(const ezWorldModule::UpdateContext& contex
}
}
}


EZ_STATICLINK_FILE(GameComponentsPlugin, GameComponentsPlugin_Debugging_Implementation_LineToComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,6 @@ void ezCameraShakeComponent::DeserializeComponent(ezWorldReader& inout_stream)
s >> m_MinShake;
s >> m_MaxShake;
}


EZ_STATICLINK_FILE(GameComponentsPlugin, GameComponentsPlugin_Effects_Shake_Implementation_CameraShakeComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,6 @@ void ezCameraShakeVolumeSphereComponent::OnUpdateLocalBounds(ezMsgUpdateLocalBou
{
msg.AddBounds(ezBoundingSphere::MakeFromCenterAndRadius(ezVec3::MakeZero(), m_fRadius), ezCameraShakeVolumeComponent::SpatialDataCategory);
}


EZ_STATICLINK_FILE(GameComponentsPlugin, GameComponentsPlugin_Effects_Shake_Implementation_CameraShakeVolumeComponent);
21 changes: 21 additions & 0 deletions Code/EnginePlugins/GameComponentsPlugin/GameComponentsPCH.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
#include <GameComponentsPlugin/GameComponentsPCH.h>


EZ_STATICLINK_LIBRARY(GameComponentsPlugin)
{
if (bReturn)
return;

EZ_STATICLINK_REFERENCE(GameComponentsPlugin_Animation_Implementation_CreatureCrawlComponent);
EZ_STATICLINK_REFERENCE(GameComponentsPlugin_Animation_Implementation_MoveToComponent);
EZ_STATICLINK_REFERENCE(GameComponentsPlugin_Debugging_Implementation_LineToComponent);
EZ_STATICLINK_REFERENCE(GameComponentsPlugin_Effects_Shake_Implementation_CameraShakeComponent);
EZ_STATICLINK_REFERENCE(GameComponentsPlugin_Effects_Shake_Implementation_CameraShakeVolumeComponent);
EZ_STATICLINK_REFERENCE(GameComponentsPlugin_Gameplay_Implementation_AreaDamageComponent);
EZ_STATICLINK_REFERENCE(GameComponentsPlugin_Gameplay_Implementation_HeadBoneComponent);
EZ_STATICLINK_REFERENCE(GameComponentsPlugin_Gameplay_Implementation_PowerConnectorComponent);
EZ_STATICLINK_REFERENCE(GameComponentsPlugin_Gameplay_Implementation_ProjectileComponent);
EZ_STATICLINK_REFERENCE(GameComponentsPlugin_Gameplay_Implementation_RaycastComponent);
EZ_STATICLINK_REFERENCE(GameComponentsPlugin_Physics_Implementation_ClothSheetComponent);
EZ_STATICLINK_REFERENCE(GameComponentsPlugin_Physics_Implementation_FakeRopeComponent);
EZ_STATICLINK_REFERENCE(GameComponentsPlugin_Terrain_Implementation_HeightfieldComponent);
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,6 @@ void ezAreaDamageComponentManager::Initialize()

m_pPhysicsInterface = GetWorld()->GetOrCreateModule<ezPhysicsWorldModuleInterface>();
}


EZ_STATICLINK_FILE(GameComponentsPlugin, GameComponentsPlugin_Gameplay_Implementation_AreaDamageComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,6 @@ void ezHeadBoneComponent::ChangeVerticalRotation(float fRadians)
{
m_NewVerticalRotation += ezAngle::MakeFromRadian(fRadians);
}


EZ_STATICLINK_FILE(GameComponentsPlugin, GameComponentsPlugin_Gameplay_Implementation_HeadBoneComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -389,3 +389,6 @@ void ezPowerConnectorComponent::OutputChanged(ezUInt16 uiOutput)
}
}
}


EZ_STATICLINK_FILE(GameComponentsPlugin, GameComponentsPlugin_Gameplay_Implementation_PowerConnectorComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -475,3 +475,6 @@ class ezProjectileComponentPatch_5_6 : public ezGraphPatch
};

ezProjectileComponentPatch_1_2 g_ezProjectileComponentPatch_1_2;


EZ_STATICLINK_FILE(GameComponentsPlugin, GameComponentsPlugin_Gameplay_Implementation_ProjectileComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,6 @@ void ezRaycastComponent::PostTriggerMessage(ezTriggerState::Enum state, ezGameOb

m_TriggerEventSender.PostEventMessage(msg, this, GetOwner(), ezTime::MakeZero(), ezObjectMsgQueueType::PostTransform);
}


EZ_STATICLINK_FILE(GameComponentsPlugin, GameComponentsPlugin_Gameplay_Implementation_RaycastComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -647,3 +647,6 @@ void ezClothSheetComponentManager::UpdateBounds(const ezWorldModule::UpdateConte
}
}
}


EZ_STATICLINK_FILE(GameComponentsPlugin, GameComponentsPlugin_Physics_Implementation_ClothSheetComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -494,3 +494,6 @@ void ezFakeRopeComponentManager::Update(const ezWorldModule::UpdateContext& cont
}
}
}


EZ_STATICLINK_FILE(GameComponentsPlugin, GameComponentsPlugin_Physics_Implementation_FakeRopeComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -646,3 +646,6 @@ void ezHeightfieldComponentManager::AddToUpdateList(ezHeightfieldComponent* pCom
m_ComponentsToUpdate.PushBack(hComponent);
}
}


EZ_STATICLINK_FILE(GameComponentsPlugin, GameComponentsPlugin_Terrain_Implementation_HeightfieldComponent);
4 changes: 3 additions & 1 deletion Utilities/RunStaticLinkUtil.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
..\Output\Bin\WinVs2022Debug64\ezStaticLinkUtil.exe ..\Code\Engine\Utilities
..\Output\Bin\WinVs2022Debug64\ezStaticLinkUtil.exe ..\Code\EnginePlugins\JoltPlugin
..\Output\Bin\WinVs2022Debug64\ezStaticLinkUtil.exe ..\Code\EnginePlugins\VisualScriptPlugin
..\Output\Bin\WinVs2022Debug64\ezStaticLinkUtil.exe ..\Code\UnitTests\TestFramework
..\Output\Bin\WinVs2022Debug64\ezStaticLinkUtil.exe ..\Code\EnginePlugins\AiPlugin
..\Output\Bin\WinVs2022Debug64\ezStaticLinkUtil.exe ..\Code\EnginePlugins\GameComponentsPlugin
..\Output\Bin\WinVs2022Debug64\ezStaticLinkUtil.exe ..\Code\UnitTests\TestFramework

0 comments on commit ccc8e4f

Please sign in to comment.