misyltoad / VPhysics-Jolt

Volt (VPhysics Jolt) is a replacement physics module for the Source Engine.
MIT License
1.26k stars 72 forks source link

How to install vphysics jolt on gmod server? #217

Open ForvatorDMC opened 3 months ago

ForvatorDMC commented 3 months ago

Tell me as a dumb vegetable how to install this on a gmod server, linux x32.

maxobur0001 commented 3 months ago

just drop all the content from the archive into the root folder of the game.

selenter-c commented 3 months ago

maxobur0001

All my 4 servers are on the standard Linux x32 gmod branch and not one of them has the “vphysics.so” file in the “bin” folder; instead, the “vphysics_srv.so” file is used. Screenshot 2024-08-19 011046

Initially, I tried to simply rename this file by adding the word “_srv”, but after that my server basically stopped starting with the error “AppFramework: Unable to load module vphysics_srv.so!”. Screenshot 2024-08-19 011537

I also tried to rename the rest of the vjolt files, and freaking out, I finally had about 20 files in the “bin” folder with different names, where the word “_srv” was in different places, or it was not there at all, but this again did not give anything and The error above was repeated. I also tried to rebuild this project personally, in the hope that I could get this treasured file (since the word “vphysics_jolt_srv.so” was in “build.md”), but after compilation it also did not create this file for me, and created a complete a copy of those files that are already in the archive.

ForvatorDMC commented 3 months ago

@selenter-c I have exactly the same problem.

BerntA commented 3 months ago

same here

RaphaelIT7 commented 3 months ago

It seems like the issue why it crashes is that it searches for libtier0.so but on a Linux 32x server, there it should be a libtier0_srv.so so it can't find that dependency and fails to load.
If that would be fixed, there would be another crash which seems to be caused by Jolt.

Crash 1

It depends on libtier0.so and libvstdlib.so which don't exist.

root@wsl:/funnypath/gmod/bin# readelf -d vphysics_srv.so

Dynamic section at offset 0xeee8 contains 29 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libtier0.so] <---------------------------------
 0x00000001 (NEEDED)                     Shared library: [libm.so.6]
 0x00000001 (NEEDED)                     Shared library: [libdl.so.2]
 0x00000001 (NEEDED)                     Shared library: [libstdc++.so.6]
 0x00000001 (NEEDED)                     Shared library: [ld-linux.so.2]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
[...] -- unimportant stuff

root@wsl:/funnypath/gmod/bin# readelf -d vphysics_srv_orig.so

Dynamic section at offset 0x19f0c4 contains 28 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libtier0_srv.so] <---------------------------------
 0x00000001 (NEEDED)                     Shared library: [libvstdlib_srv.so]
 0x00000001 (NEEDED)                     Shared library: [libm.so.6]
 0x00000001 (NEEDED)                     Shared library: [libdl.so.2]
 0x00000001 (NEEDED)                     Shared library: [libstdc++.so.6]
 0x00000001 (NEEDED)                     Shared library: [libpthread.so.0]
 0x00000001 (NEEDED)                     Shared library: [ld-linux.so.2]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
[...] -- unimportant stuff

It's possible to manually solve this one like this:

patchelf --replace-needed libtier0.so libtier0_srv.so vphysics_srv.so
patchelf --replace-needed libtier0.so libtier0_srv.so vphysics_jolt_avx2.so
patchelf --replace-needed libtier0.so libtier0_srv.so vphysics_jolt_sse2.so
patchelf --replace-needed libtier0.so libtier0_srv.so vphysics_jolt_sse42.so

# same issue with libvstdlib.so
patchelf --replace-needed libvstdlib.so libvstdlib_srv.so vphysics_jolt_avx2.so
patchelf --replace-needed libvstdlib.so libvstdlib_srv.so vphysics_jolt_sse2.so
patchelf --replace-needed libvstdlib.so libvstdliba_srv.so vphysics_jolt_sse42.so

Crash 2

So it seems like with the Jolt update ValidationContext was added which now seems to cause it to crash? I tested a bit around to try to find the cause of it, but It's getting late, so I'll stop for now. MY guess would be that something inside JoltPhysicsCollision::CreateVirtualMesh is broken.
This is what I got so far:

Currently, there is a server crash which is caused by jolt trying to use vertices that don't seem to exist? - Crash Cause:

for (const IndexedTriangle &i : inTriangles)
    for (uint32 idx : i.mIdx)
        mBounds.Encapsulate(Vec3(inVertices[idx])); -- Vec3 constructor crashes

- Possible Cause: indexedTriangleList[xyz].m_Idx[idx] = Invalid vertex index?

Stacktrace (If someone want's to take a look into it): 0 - _mm_set_ss
1 - _mm_load_ss
2 - JPH::Vec3::Vec3 - Vec3.inl#L56
3 - JPH::TriangleCodecIndexed8BitPackSOA4Flags::ValidationContext::ValidationContext
- - - TriangleCodecIndexed8BitPackSOA4Flags.h#L102
4 - JPH::MeshShapeSettings::Sanitize - MeshShape.cpp:96
5 - JPH::MeshShapeSettings::MeshShapeSettings - MeshShape.cpp:88
6 - JoltPhysicsCollision::CreateVirtualMesh - vjolt_collide.cpp:865
7 - CM_CreateDispPhysCollide - engine_srv.so

DatGuy64 commented 2 months ago

Anyone found a fix ? i want to try it on my server too

Malifox commented 2 months ago

@RaphaelIT7

For crash 2, I made the following change to: https://github.com/misyltoad/VPhysics-Jolt/blob/9f3bff409fdf1c5e997f4619d42c95703e4c12bd/vphysics_jolt/vjolt_collide.cpp#L826

- indexedTriangleList.resize( meshList.indexCount * 2 );
+ indexedTriangleList.resize( meshList.indexCount / 3 * 2 );

Seemed to fix the out of bounds issue based on some testing.