Converts physx console commands from cry console to az console, fixes some bugs in the multiplayer gem

This commit is contained in:
karlberg
2021-06-02 14:44:02 -07:00
parent e737307168
commit a69db3bf76
4 changed files with 75 additions and 68 deletions
+15 -34
View File
@@ -15,6 +15,7 @@
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Component/TransformBus.h>
#include <AzCore/Console/IConsole.h>
#include <PhysX/SystemComponentBus.h>
#include <PhysX/MathConversion.h>
@@ -183,9 +184,7 @@ namespace PhysXDebug
void SystemComponent::OnCrySystemInitialized([[maybe_unused]] ISystem& system, const SSystemInitParams&)
{
InitPhysXColorMappings();
RegisterCommands();
ConfigurePhysXVisualizationParameters();
}
void SystemComponent::Reflect(AZ::ReflectContext* context)
@@ -537,12 +536,13 @@ namespace PhysXDebug
}
}
static void CmdEnableWireFrame([[maybe_unused]] IConsoleCmdArgs* args)
static void physx_EnableWireFrame([[maybe_unused]] const AZ::ConsoleCommandContainer& arguments)
{
PhysXDebug::PhysXDebugRequestBus::Broadcast(&PhysXDebug::PhysXDebugRequestBus::Events::ToggleCullingWireFrame);
}
AZ_CONSOLEFREEFUNC(physx_EnableWireFrame, AZ::ConsoleFunctorFlags::DontReplicate, "Enables physx wireframe view");
static void CmdConnectToPvd([[maybe_unused]] IConsoleCmdArgs* args)
static void physx_ConnectToPvd([[maybe_unused]] const AZ::ConsoleCommandContainer& arguments)
{
auto* debug = AZ::Interface<PhysX::Debug::PhysXDebugInterface>::Get();
if (debug)
@@ -550,8 +550,9 @@ namespace PhysXDebug
debug->ConnectToPvd();
}
}
AZ_CONSOLEFREEFUNC(physx_ConnectToPvd, AZ::ConsoleFunctorFlags::DontReplicate, "Connects to the physx visual debugger");
static void CmdDisconnectFromPvd([[maybe_unused]] IConsoleCmdArgs* args)
static void physx_DisconnectFromPvd([[maybe_unused]] const AZ::ConsoleCommandContainer& arguments)
{
auto* debug = AZ::Interface<PhysX::Debug::PhysXDebugInterface>::Get();
if (debug)
@@ -559,13 +560,14 @@ namespace PhysXDebug
debug->DisconnectFromPvd();
}
}
AZ_CONSOLEFREEFUNC(physx_DisconnectFromPvd, AZ::ConsoleFunctorFlags::DontReplicate, "Disconnects from the physx visual debugger");
static void CmdSetPhysXDebugCullingBoxSize(IConsoleCmdArgs* args)
static void physx_SetPhysXDebugCullingBoxSize([[maybe_unused]] const AZ::ConsoleCommandContainer& arguments)
{
const int argumentCount = args->GetArgCount();
const int argumentCount = arguments.size();
if (argumentCount == 2)
{
float newCullingBoxSize = (float)strtol(args->GetArg(1), nullptr, 10);
float newCullingBoxSize = (float)strtol(AZ::CVarFixedString(arguments[1]).c_str(), nullptr, 10);
PhysXDebug::PhysXDebugRequestBus::Broadcast(&PhysXDebug::PhysXDebugRequestBus::Events::SetCullingBoxSize, newCullingBoxSize);
}
else
@@ -574,16 +576,17 @@ namespace PhysXDebug
"Please use physx_SetDebugCullingBoxSize <boxSize> e.g. physx_SetDebugCullingBoxSize 100.");
}
}
AZ_CONSOLEFREEFUNC(physx_SetPhysXDebugCullingBoxSize, AZ::ConsoleFunctorFlags::DontReplicate, "Sets physx debug culling box size");
static void CmdTogglePhysXDebugVisualization(IConsoleCmdArgs* args)
static void physx_TogglePhysXDebugVisualization([[maybe_unused]] const AZ::ConsoleCommandContainer& arguments)
{
using namespace CryStringUtils;
const int argumentCount = args->GetArgCount();
const int argumentCount = arguments.size();
if (argumentCount == 2)
{
const auto userPreference = static_cast<DebugCVarValues>(strtol(args->GetArg(1), nullptr, 10));
const auto userPreference = static_cast<DebugCVarValues>(strtol(AZ::CVarFixedString(arguments[1]).c_str(), nullptr, 10));
switch (userPreference)
{
@@ -609,29 +612,7 @@ namespace PhysXDebug
AZ_Warning("PhysXDebug", false, "Invalid physx_Debug Arguments. Please use physx_Debug 1 to enable, physx_Debug 0 to disable or physx_Debug 2 to enable all configuration settings.");
}
}
void SystemComponent::RegisterCommands()
{
if (m_registered)
{
return;
}
if (gEnv)
{
IConsole* console = gEnv->pSystem->GetIConsole();
if (console)
{
console->AddCommand("physx_Debug", CmdTogglePhysXDebugVisualization);
console->AddCommand("physx_CullingBox", CmdEnableWireFrame);
console->AddCommand("physx_CullingBoxSize", CmdSetPhysXDebugCullingBoxSize);
console->AddCommand("physx_PvdConnect", CmdConnectToPvd);
console->AddCommand("physx_PvdDisconnect", CmdDisconnectFromPvd);
}
m_registered = true;
}
}
AZ_CONSOLEFREEFUNC(physx_TogglePhysXDebugVisualization, AZ::ConsoleFunctorFlags::DontReplicate, "Toggles physx debug visualization");
void SystemComponent::ConfigurePhysXVisualizationParameters()
{