Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PhysX 4.1 #690

Merged
merged 11 commits into from
Dec 16, 2020
15 changes: 14 additions & 1 deletion .github/workflows/linux-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
libogg-dev libopus-dev libspeex-dev uuid-dev libvpx-dev \
libvorbis-dev qtbase5-dev
sudo pip install -r ${GITHUB_WORKSPACE}/requirements.txt

- name: Build string_theory
run: |
mkdir -p build_deps && cd build_deps
Expand All @@ -31,11 +32,23 @@ jobs:
cmake -DCMAKE_BUILD_TYPE=Debug -DST_BUILD_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX="${GITHUB_WORKSPACE}/build_deps/prefix" ..
make -j2 && make install

- name: Build PhysX
run: |
mkdir -p build_deps && cd build_deps
git clone -b 4.1 --depth 1 https://github.com/NVIDIAGameWorks/PhysX.git
cd PhysX/physx
./generate_projects.sh linux
cd compiler/linux-debug
cmake -DPX_BUILDPUBLICSAMPLES=OFF -DPX_BUILDSNIPPETS=OFF ../public
make -j2 && make install

- name: Build Plasma
run: |
cd ${GITHUB_WORKSPACE}
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/build_deps/prefix" \
cmake -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/build_deps/prefix;${GITHUB_WORKSPACE}/build_deps/PhysX/physx/install" \
-DPython_ADDITIONAL_VERSIONS=2.7 -DPLASMA_BUILD_TESTS=ON \
-DPLASMA_BUILD_TOOLS=ON -DPLASMA_BUILD_RESOURCE_DAT=ON ..
make -j2
Expand Down
10 changes: 0 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,6 @@ set_package_properties(BZip2 PROPERTIES
PURPOSE "Required only if FreeType is built statically against bzip2"
)

if(WIN32)
#TODO: Not required if we aren't building the client
find_package(PhysX REQUIRED)
set_package_properties(PhysX PROPERTIES
URL "https://developer.nvidia.com/physx-sdk"
DESCRIPTION "Library for hardware-accelerated physics simulation for gaming"
TYPE REQUIRED
)
endif(WIN32)

if(UNIX AND NOT APPLE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBSECRET libsecret-1)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Library Dependencies

Plasma currently requires the following third-party libraries:

- nVidia PhysX 2.6.4 - https://web.archive.org/web/20170501130625/http://developer.download.nvidia.com/PhysX/2.6.4/PhysX_2.6.4_SDK_Core.exe
- NVIDIA PhysX 4.1 - https://github.com/NVIDIAGameWorks/PhysX
- Microsoft DirectX SDK - https://www.microsoft.com/en-us/download/details.aspx?id=6812
- Python 3.8 (or higher) - https://www.python.org/downloads/
- libOgg and libVorbis - http://www.xiph.org/downloads/
Expand All @@ -48,7 +48,7 @@ The following libraries are optional:
Reducing the use of proprietary libraries is a focus of development and should
be expected to change.

PhysX and DirectX SDK will need to be acquired through the above links.
DirectX SDK will need to be acquired through the above link.
All other required libraries are available as precompiled binaries and
associated files in the [development libraries bundle](https://github.com/H-uru/PlasmaPrefix/releases/download/2020.05.01/devlibs.zip)
or can be built using their individual build instructions.
Expand Down
50 changes: 10 additions & 40 deletions Sources/Plasma/Apps/plClient/plClientLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,45 +53,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plPhysX/plSimulationMgr.h"
#include "plResMgr/plResManager.h"

static plFileName s_physXSetupExe = "PhysX_Setup.exe";

static bool InitPhysX()
{
#ifdef HS_BUILD_FOR_WIN32
plSimulationMgr::Init();
if (!plSimulationMgr::GetInstance()) {
if (plFileInfo(s_physXSetupExe).Exists()) {
// launch the PhysX installer
SHELLEXECUTEINFOW info;
memset(&info, 0, sizeof(info));
info.cbSize = sizeof(info);
ST::wchar_buffer exeW = s_physXSetupExe.WideString();
info.lpFile = exeW.data();
info.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NOASYNC;
ShellExecuteExW(&info);

// wait for completion
WaitForSingleObject(info.hProcess, INFINITE);

// cleanup
CloseHandle(info.hProcess);
} else {
hsMessageBox("You must install PhysX before you can play URU.", "Error", hsMessageBoxNormal, hsMessageBoxIconError);
return false;
}
}
if (plSimulationMgr::GetInstance()) {
plSimulationMgr::GetInstance()->Suspend();
return true;
} else {
hsMessageBox("PhysX install failed. You will not be able to play URU.", "Error", hsMessageBoxNormal, hsMessageBoxIconError);
return false;
}
#else
return false;
#endif // HS_BUILD_FOR_WIN32
}

void plClientLoader::Run()
{
plResManager *resMgr = new plResManager;
Expand All @@ -106,7 +67,16 @@ void plClientLoader::Run()

fClient = new plClient;
fClient->SetWindowHandle(fWindow);
if (!InitPhysX() || fClient->InitPipeline() || !fClient->StartInit()) {

plSimulationMgr::Init();
if (plSimulationMgr::GetInstance()) {
plSimulationMgr::GetInstance()->Suspend();
} else {
fClient->SetDone(true);
return;
}

if (fClient->InitPipeline() || !fClient->StartInit()) {
fClient->SetDone(true);
}
}
Expand Down
5 changes: 5 additions & 0 deletions Sources/Plasma/Apps/plClient/winmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plStatusLog/plStatusLog.h"
#include "plProduct.h"
#include "plNetGameLib/plNetGameLib.h"
#include "plPhysX/plPXSimulation.h"

#include "res/resource.h"

Expand Down Expand Up @@ -97,6 +98,7 @@ enum
kArgSkipPreload,
kArgPlayerId,
kArgStartUpAgeName,
kArgPvdFile,
};

static const plCmdArgDef s_cmdLineArgs[] = {
Expand All @@ -106,6 +108,7 @@ static const plCmdArgDef s_cmdLineArgs[] = {
{ kCmdArgFlagged | kCmdTypeBool, "SkipPreload", kArgSkipPreload },
{ kCmdArgFlagged | kCmdTypeInt, "PlayerId", kArgPlayerId },
{ kCmdArgFlagged | kCmdTypeString, "Age", kArgStartUpAgeName },
{ kCmdArgFlagged | kCmdTypeString, "PvdFile", kArgPvdFile },
};

/// Made globals now, so we can set them to zero if we take the border and
Expand Down Expand Up @@ -1028,6 +1031,8 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC
NetCommSetIniPlayerId(cmdParser.GetInt(kArgPlayerId));
if (cmdParser.IsSpecified(kArgStartUpAgeName))
NetCommSetIniStartUpAge(cmdParser.GetString(kArgStartUpAgeName));
if (cmdParser.IsSpecified(kArgPvdFile))
plPXSimulation::SetDefaultDebuggerEndpoint(cmdParser.GetString(kArgPvdFile));
#endif

plFileName serverIni = "server.ini";
Expand Down
24 changes: 24 additions & 0 deletions Sources/Plasma/CoreLib/hsMatrix44.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,30 @@ hsVector3 hsMatrix44::operator*(const hsVector3& p) const
return rVal;
}

bool hsMatrix44::Compare(const hsMatrix44& rhs, float tolerance) const
{
return
(fabs(fMap[0][0] - rhs.fMap[0][0]) < tolerance) &&
(fabs(fMap[0][1] - rhs.fMap[0][1]) < tolerance) &&
(fabs(fMap[0][2] - rhs.fMap[0][2]) < tolerance) &&
(fabs(fMap[0][3] - rhs.fMap[0][3]) < tolerance) &&

(fabs(fMap[1][0] - rhs.fMap[1][0]) < tolerance) &&
(fabs(fMap[1][1] - rhs.fMap[1][1]) < tolerance) &&
(fabs(fMap[1][2] - rhs.fMap[1][2]) < tolerance) &&
(fabs(fMap[1][3] - rhs.fMap[1][3]) < tolerance) &&

(fabs(fMap[2][0] - rhs.fMap[2][0]) < tolerance) &&
(fabs(fMap[2][1] - rhs.fMap[2][1]) < tolerance) &&
(fabs(fMap[2][2] - rhs.fMap[2][2]) < tolerance) &&
(fabs(fMap[2][3] - rhs.fMap[2][3]) < tolerance) &&

(fabs(fMap[3][0] - rhs.fMap[3][0]) < tolerance) &&
(fabs(fMap[3][1] - rhs.fMap[3][1]) < tolerance) &&
(fabs(fMap[3][2] - rhs.fMap[3][2]) < tolerance) &&
(fabs(fMap[3][3] - rhs.fMap[3][3]) < tolerance);
}

bool hsMatrix44::operator==(const hsMatrix44& ss) const
{
if( ss.fFlags & fFlags & hsMatrix44::kIsIdent )
Expand Down
1 change: 1 addition & 0 deletions Sources/Plasma/CoreLib/hsMatrix44.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ struct hsMatrix44 {
bool IsIdentity();
void NotIdentity() { fFlags &= ~kIsIdent; }

bool Compare(const hsMatrix44& rhs, float tolerance) const;
bool operator==(const hsMatrix44& ss) const;
bool operator!=(const hsMatrix44& ss) const { return !(ss == *this); }

Expand Down
2 changes: 2 additions & 0 deletions Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,7 @@ void plCameraBrain1_Avatar::CalculatePosition()
{
plLOSRequestMsg* pMsg = new plLOSRequestMsg( GetCamera()->GetKey(), fPOAGoal, fGoal, plSimDefs::kLOSDBCameraBlockers,
plLOSRequestMsg::kTestClosest, plLOSRequestMsg::kReportHitOrMiss);
pMsg->SetRequestName(ST::format("Camera Brain [{}]: Find Blockers", GetKeyName()));
plgDispatch::MsgSend( pMsg );
}

Expand Down Expand Up @@ -1432,6 +1433,7 @@ void plCameraBrain1_FirstPerson::CalculatePosition()
{
plLOSRequestMsg* pMsg = new plLOSRequestMsg( GetCamera()->GetKey(), fPOAGoal, fGoal, plSimDefs::kLOSDBCameraBlockers,
plLOSRequestMsg::kTestClosest, plLOSRequestMsg::kReportHitOrMiss);
pMsg->SetRequestName(ST::format("Camera Brain [{}]: Find Blockers", GetKeyName()));
plgDispatch::MsgSend( pMsg );
}

Expand Down
62 changes: 8 additions & 54 deletions Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4873,26 +4873,16 @@ PF_CONSOLE_CMD( SceneObject, Detach, // Group name, Function name
#endif // LIMIT_CONSOLE_COMMANDS

//////////////////////////////////////////////////////////////
// PHYSICS (The Havok Flavour)
// PHYSICS
//////////////////////////////////////////////////////////////

#ifndef LIMIT_CONSOLE_COMMANDS

#include "plPhysX/plPXPhysicalControllerCore.h"
#include "plPhysX/plSimulationMgr.h"

PF_CONSOLE_GROUP( Physics )

PF_CONSOLE_CMD( Physics, Rebuild, "", "Rebuilds the avatars collision cache")
{
plPXPhysicalControllerCore::RebuildCache();
}

PF_CONSOLE_CMD(Physics, MaxPhysicalAvatars, "int max", "Set the maximum number of avatar physicals allowed. Default = 0 (meaning no limit)")
{
int max = params[0];
plPXPhysicalControllerCore::SetMaxNumberOfControllers(max);
}

/*
PF_CONSOLE_CMD( Physics, SetStepsPerSecond, "int steps", "Sets the number of physics substeps per second, regardless of rendering framerate.")
{
Expand Down Expand Up @@ -5134,36 +5124,6 @@ PF_CONSOLE_CMD(Physics, ExtraProfile, "", "Toggle extra simulation profiling")
}
PrintString(str);
}
PF_CONSOLE_CMD(Physics, SubworldOptimization, "", "Toggle subworld optimization")
{
const char *str;
if (plSimulationMgr::fSubworldOptimization)
{
plSimulationMgr::fSubworldOptimization = false;
str = "Stop subworld optimization";
}
else
{
plSimulationMgr::fSubworldOptimization = true;
str = "Start subworld optimization";
}
PrintString(str);
}
PF_CONSOLE_CMD(Physics, ClampingOnStep, "", "Toggle whether to clamp the step size on advance")
{
const char *str;
if (plSimulationMgr::fDoClampingOnStep)
{
plSimulationMgr::fDoClampingOnStep = false;
str = "Stop clamping the step size";
}
else
{
plSimulationMgr::fDoClampingOnStep = true;
str = "Start clamping the step size";
}
PrintString(str);
}

PF_CONSOLE_CMD(Physics,
ShowControllerDebugDisplay,
Expand All @@ -5172,21 +5132,15 @@ PF_CONSOLE_CMD(Physics,
{
plPXPhysicalControllerCore::fDebugDisplay = !plPXPhysicalControllerCore::fDebugDisplay;
}
PF_CONSOLE_CMD(Physics,
ListAwakeActors,
"",
"Toggles displaying the list of awake actors")
{
plSimulationMgr::fDisplayAwakeActors= !plSimulationMgr::fDisplayAwakeActors;
}

/*
PF_CONSOLE_CMD( Physics, PlayPhysicsSounds, "bool b", "Turn physics sounds on/off.")
PF_CONSOLE_CMD(Physics,
ResetKickables,
"",
"Reset kickables in this Age to their default poses")
{
bool b = params[0];
plHKCollision::TogglePhysicsSounds(b);
plSimulationMgr::GetInstance()->ResetKickables();
}
*/

#endif // LIMIT_CONSOLE_COMMANDS


Expand Down
4 changes: 4 additions & 0 deletions Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2113,16 +2113,20 @@ bool cyMisc::RequestLOSScreen(pyKey &selfkey, int32_t ID, float xPos, float yPos
{
case kClickables:
pMsg = new plLOSRequestMsg( selfkey.getKey(), startPos, endPos, plSimDefs::kLOSDBUIItems, plLOSRequestMsg::kTestClosest );
pMsg->SetRequestName(ST::format("Python [{}]: Clickables", selfkey.getName()));
pMsg->SetCullDB(plSimDefs::kLOSDBUIBlockers);
break;
case kCameraBlockers:
pMsg = new plLOSRequestMsg( selfkey.getKey(), startPos, endPos, plSimDefs::kLOSDBCameraBlockers, plLOSRequestMsg::kTestClosest );
pMsg->SetRequestName(ST::format("Python [{}]: Camera Blockers", selfkey.getName()));
break;
case kCustom:
pMsg = new plLOSRequestMsg( selfkey.getKey(), startPos, endPos, plSimDefs::kLOSDBCustom, plLOSRequestMsg::kTestClosest );
pMsg->SetRequestName(ST::format("Python [{}]: Custom", selfkey.getName()));
break;
case kShootable:
pMsg = new plLOSRequestMsg( selfkey.getKey(), startPos, endPos, plSimDefs::kLOSDBShootableItems, plLOSRequestMsg::kTestClosest );
pMsg->SetRequestName(ST::format("Python [{}]: Shootables", selfkey.getName()));
break;
}

Expand Down
12 changes: 6 additions & 6 deletions Sources/Plasma/NucleusLib/inc/plPhysical.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,12 @@ class plPhysical : public plSynchedObject
virtual plKey GetSceneNode() const = 0;

virtual bool GetLinearVelocitySim(hsVector3& vel) const = 0;
virtual void SetLinearVelocitySim(const hsVector3& vel) = 0;
virtual void SetLinearVelocitySim(const hsVector3& vel, bool wakeup=true) = 0;
virtual void ClearLinearVelocity() = 0;

virtual bool GetAngularVelocitySim(hsVector3& vel) const = 0;
virtual void SetAngularVelocitySim(const hsVector3& vel) = 0;
virtual void SetAngularVelocitySim(const hsVector3& vel, bool wakeup=true) = 0;

virtual void SetHitForce(const hsVector3& force, const hsPoint3& pos)=0;
/** Standard plasma transform interface, in global coordinates by convention.
If you send in the same matrix that the physical last sent out in its correction message,
it will be ignored as an "echo" -- UNLESS you set force to true, in which case the transform
Expand All @@ -96,6 +95,7 @@ class plPhysical : public plSynchedObject

// From plSimDefs::Group
virtual int GetGroup() const = 0;
virtual void SetGroup(int group) = 0;

// Flags in plSimDefs::plLOSDB
virtual void AddLOSDB(uint16_t flag) = 0;
Expand All @@ -121,10 +121,10 @@ class plPhysical : public plSynchedObject
virtual void GetSyncState(hsPoint3& pos, hsQuat& rot, hsVector3& linV, hsVector3& angV) = 0;
virtual void SetSyncState(hsPoint3* pos, hsQuat* rot, hsVector3* linV, hsVector3* angV) = 0;

/** Resets the physical to its default state. */
virtual void ResetSyncState() = 0;

virtual float GetMass() = 0;
// I wish I could think of a better way to do this, but this is how it's
// going to be for now.
virtual void ExcludeRegionHack(bool cleared) = 0;

virtual plDrawableSpans* CreateProxy(hsGMaterial* mat, hsTArray<uint32_t>& idx, plDrawableSpans* addTo) = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion Sources/Plasma/NucleusLib/pnModifier/plLogicModBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class plLogicModBase : public plSingleModifier
virtual void Reset(bool bCounterReset);

void SetDisabled(bool disabled) { fDisabled = disabled; }
bool Disabled() { return fDisabled; }
bool Disabled() const { return fDisabled; }

plNotifyMsg* GetNotify() { return fNotify; }

Expand Down
4 changes: 1 addition & 3 deletions Sources/Plasma/PubUtilLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ add_subdirectory(plNetMessage)
add_subdirectory(plNetTransport)
add_subdirectory(plParticleSystem)
add_subdirectory(plPhysical)
if(WIN32)
add_subdirectory(plPhysX)
endif()
add_subdirectory(plPhysX)
add_subdirectory(plPipeline)
add_subdirectory(plProgressMgr)
add_subdirectory(plResMgr)
Expand Down
Loading