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

Add an API for creating separate IPhysicsEnvironment's #2522

Open
marchc1 opened this issue Nov 5, 2024 · 2 comments
Open

Add an API for creating separate IPhysicsEnvironment's #2522

marchc1 opened this issue Nov 5, 2024 · 2 comments

Comments

@marchc1
Copy link

marchc1 commented Nov 5, 2024

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??

  • What to do when a physics environment is destroyed with physics objects in it? Just push them back to the main physics environment if they are no longer a part of any sub-environment?
  • The use cases I provided would be ones where the world is not a part of the physics object; is there a good way to have support for both including the world and not including the world? Not needed, but maybe someone would want a separate physics environment but still have world collision for whatever reason
  • Players in different physics objects?
  • Can this be done both clientside and serverside in a nice way to be seamless?
@Bonyoze
Copy link

Bonyoze commented Nov 9, 2024

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

@marchc1
Copy link
Author

marchc1 commented Nov 24, 2024

It appears that this is 100% possible to add and the work has already been done for it: https://github.com/RaphaelIT7/gmod-holylib/blob/04f96f64cc500aed9e308c7bf36bbb2f919e5a73/source/modules/physenv.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants