Facepunch / garrysmod-requests

Feature requests for Garry's Mod
85 stars 24 forks source link

Add an API for creating separate IPhysicsEnvironment's #2522

Open marchc1 opened 2 weeks ago

marchc1 commented 2 weeks ago

Details

According to the VPhysics page on the Valve Developer Wiki, multiple IPhysicsEnvironments are possible.

A VPhysics environment within which objects are simulated. New IPhysicsObjects are created here, and global settings like gravity can be configured. IPhysicsEnvironment* physenv is created by default. Multiple environments are entirely possible, which is how Portal and Portal 2 work.

I don't see anything that states this is only a part of Portal and Portal 2, so I am inclined to believe this is possible. Could we get some methods to create/destroy physics environments and move physics objects between them? Adding this would result in better lua-based portals/"bigger on the inside" effects (since it seems adding linked_portal_door) isn't happening due to limitations).

More Details

Was thinking something like this;

local physenv = physenv.CreateEnvironment()
physenv:Destroy()

A PhysicsEnvironment could have most of the methods that the physenv library have, except as self-calling functions, ie.

physenv:GetAirDensity()
physenv:GetGravity()
physenv:SetAirDensity(airDensity)
etc...

As to add physics objects to the physics environment, I don't know how that works under the hood (can physics objects be in multiple physics environments, etc...)

Potential problems??

Bonyoze commented 1 week ago

This or a method to remove player collisions with the world would be really useful.