Your Ad Here

Subscribe
 Post #1
 5th August 2008 Last edited by Jinto; 25th November 2009 at 08:47AM..
Jinto's Avatar
May 2005
1,121 Posts
Deprecated!! Use the physenv functions.
Here is the modifed physics.lua file to work with the physenv functions.

local MaxVelocity = CreateConVar( "phys_maxvelocity", "4000", FCVAR_NOTIFY | FCVAR_ARCHIVE | FCVAR_GAMEDLL );
local MaxAngularVelocity = CreateConVar( "phys_maxangularvelocity", "3600", FCVAR_NOTIFY | FCVAR_ARCHIVE | FCVAR_GAMEDLL );
local GravityX = CreateConVar( "phys_gravity_x", "0", FCVAR_NOTIFY | FCVAR_GAMEDLL );
local GravityY = CreateConVar( "phys_gravity_y", "0", FCVAR_NOTIFY | FCVAR_GAMEDLL );
local GravityZ = CreateConVar( "phys_gravity_z", "-600", FCVAR_NOTIFY | FCVAR_GAMEDLL );
local CollisionsPerObjectPerTimestep = CreateConVar( "phys_collisions_object_timestep", "10", FCVAR_NOTIFY | FCVAR_GAMEDLL );
local CollisionsPerTimestep = CreateConVar( "phys_collisions_timestep", "250", FCVAR_NOTIFY | FCVAR_GAMEDLL );
local MinFrictionMass = CreateConVar( "phys_minfrictionmass", "10", FCVAR_NOTIFY | FCVAR_GAMEDLL );
local MaxFrictionMass = CreateConVar( "phys_maxfrictionmass", "2500", FCVAR_NOTIFY | FCVAR_GAMEDLL );
local AirDensity = CreateConVar( "phys_airdensity", "2", FCVAR_NOTIFY | FCVAR_GAMEDLL );

/*------------------------------------
	UpdatePerformanceSettings()
------------------------------------*/
local function UpdatePerformanceSettings()

	local settings = physenv.GetPerformanceSettings();

	settings.MaxVelocity = MaxVelocity:GetFloat();
	settings.MaxAngularVelocity = MaxAngularVelocity:GetFloat();
	settings.MinFrictionMass = MinFrictionMass:GetFloat();
	settings.MaxFrictionMass = MaxFrictionMass:GetFloat();
	settings.MaxCollisionsPerObjectPerTimestep = CollisionsPerObjectPerTimestep:GetInt();
	settings.MaxCollisionChecksPerTimestep = CollisionsPerTimestep:GetInt();

	physenv.SetPerformanceSettings( settings );

end

/*------------------------------------
	UpdateGravity()
------------------------------------*/
local function UpdateGravity()

	physenv.SetGravity( Vector( GravityX:GetFloat(), GravityY:GetFloat(), GravityZ:GetFloat() ) );
	
end

/*------------------------------------
	UpdateAirDensity()
------------------------------------*/
local function UpdateAirDensity()

	physenv.SetAirDensity( AirDensity:GetFloat() );
	
end

/*------------------------------------
	InitPostEntity()
------------------------------------*/
local function InitPostEntity()

	UpdatePerformanceSettings();
	UpdateGravity();
	UpdateAirDensity();

end
hook.Add( "InitPostEntity", "PhysicsSettingsStartup", InitPostEntity );

// watch for changes on these convars
cvars.AddChangeCallback( "phys_maxvelocity", UpdatePerformanceSettings );
cvars.AddChangeCallback( "phys_maxangularvelocity", UpdatePerformanceSettings );
cvars.AddChangeCallback( "phys_collisions_object_timestep", UpdatePerformanceSettings );
cvars.AddChangeCallback( "phys_collisions_timestep", UpdatePerformanceSettings );
cvars.AddChangeCallback( "phys_minfrictionmass", UpdatePerformanceSettings );
cvars.AddChangeCallback( "phys_maxfrictionmass", UpdatePerformanceSettings );
cvars.AddChangeCallback( "phys_gravity_x", UpdateGravity );
cvars.AddChangeCallback( "phys_gravity_y", UpdateGravity );
cvars.AddChangeCallback( "phys_gravity_z", UpdateGravity );
cvars.AddChangeCallback( "phys_airdensity", UpdateAirDensity );


Alright, this will let you increase the maximum velocity of physics objects, currently 2000 in/s or 113mph, among other things. I wrote this a while ago, was going to add more stuff to it, but chose to remove it and release it as a simple performance/settings module. Here is a list of extra ConVars this adds.

ConVars:
  • phys_maxvelocity
    • Default: 2000 in/sec
  • phys_maxangularvelocity
    • Default: 3600 deg/sec
  • phys_collisions_object_timestep
    • Default: 10
    • Description: Objects may collide this many times before they are frozen for performance reasons.
  • phys_collisions_timestep
    • Default: 250
    • Description: Same as phys_collisions_object_timestep, but against the world.
  • phys_minfrictionmass
    • Default: 10
  • phys_maxfrictionmass
    • Default: 2500
  • phys_gravity_x
  • phys_gravity_y
  • phys_gravity_z
    • Description: Changes gravity for physics objects on any combination of axes.
  • phys_airdensity
    • Description: Changes the density of air in the physics simulation ( Doesn't require cheats ).

Module:
  • physics.GetPerformanceSettings()
  • physics.SetPerformanceSettings( [table] settings )
  • physics.GetGravity()
  • physics.SetGravity( [vector] gravity )
  • physics.GetAirDensity()
  • physics.SetAirDensity( [float] density )
For a list of the fields SetPerformanceSettings uses, check physics.lua.

Download:
http://cdbarrett.com/dump/releases/gmsv_vphysics.zip
http://cdbarrett.com/dump/releases/g...hysics_src.zip

Download:
 Post #2
 5th August 2008
Gold Member
Kogitsune's Avatar
September 2005
6,461 Posts
Awesome. Just awesome.
 Post #3
 5th August 2008
Jinto's Avatar
May 2005
1,121 Posts
Some interesting things to do with it are.

Code:
phys_maxvelocity 0
phys_maxangularvelocity 3600
Props will only rotate and can't be moved.

Code:
phys_maxvelocity 2000
phys_maxangularvelocity 0
Props will only move and not rotate. This leads to some reality defying structures to be built. Balance a pole on a soda can, horizontally.


If you raise phys_maxvelocity, it's up to you to accelerate objects to that new speed. Explosives won't really cut it, not unless you raise the damage push scale. So good luck trying to utilize the extra speed!
 Post #4
 5th August 2008
Dennab
February 2006
2,409 Posts
This is unbelievably awesome. I might have some use for this in Crazy Delivery...
 Post #5
 5th August 2008
Gold Member
conman420's Avatar
January 2007
4,999 Posts
Wow! Another excellent release, this is going to be so useful, are there any side effects to setting the max velocity to something stupidly high?
 Post #6
 5th August 2008
DrogenViech's Avatar
December 2006
115 Posts
conman420 posted:
Wow! Another excellent release, this is going to be so useful, are there any side effects to setting the max velocity to something stupidly high?
Objects may go through the world if they gain like 999999999 speed, but dunno :D
 Post #7
 5th August 2008
Gold Member
Dennab
June 2007
8,686 Posts
This...is...AWESOME!!!
 Post #8
 5th August 2008
Kill coDer's Avatar
April 2006
848 Posts
Wait, so this allows us to bypass that stupid 115 mph limit thing?

If so, I love you.

EDIT: I love you.
 Post #9
 5th August 2008
Jinto's Avatar
May 2005
1,121 Posts
conman420 posted:
Wow! Another excellent release, this is going to be so useful, are there any side effects to setting the max velocity to something stupidly high?
Objects moving really fast may penetrate other objects. I don't think Havok was built for really fast collision detection, but I could be wrong.
 Post #10
 5th August 2008
Gold Member
tepholman's Avatar
March 2008
3,215 Posts
Hang on, this has a .dll, does this need Metamod or something?
 Post #11
 5th August 2008
GMOD Moderator
mahalis's Avatar
January 2007
5,104 Posts
tepholman posted:
Hang on, this has a .dll, does this need Metamod or something?
It's a module. GMod has built-in support for those.
 Post #12
 5th August 2008
Gold Member
aVoN's Avatar
December 2005
8,527 Posts
I never really used modules before, but can modules now be loaded within the /addons folder, or do you have to copy them into /lua/modules directly?

I'm thinking about adding this as addition to the stargate mod to make the staffblasts faster
(Sidenote: I could use effects instead of real physical objects to make them move faster, but this causes trouble needing me to trace "probable hits" with stuff moving into the shot's way)
 Post #13
 5th August 2008
Gold Member
tepholman's Avatar
March 2008
3,215 Posts
mahalis posted:
It's a module. GMod has built-in support for those.
*dances*
 Post #14
 5th August 2008
Jinto's Avatar
May 2005
1,121 Posts
aVoN posted:
I never really used modules before, but can modules now be loaded within the /addons folder, or do you have to copy them into /lua/modules directly?

I'm thinking about adding this as addition to the stargate mod to make the staffblasts faster
(Sidenote: I could use effects instead of real physical objects to make them move faster, but this causes trouble needing me to trace "probable hits" with stuff moving into the shot's way)
You used to be able to load modules from addons, but it was removed in the switch to the newer engine.

It only affects objects with MOVETYPE_VPHYSICS, otherwise it's bound by sv_maxvelocity which appears to have been removed :(.
 Post #15
 5th August 2008
Gold Member
Dennab
June 2007
8,686 Posts
Reversed gravity FUCK YEAH!

 Post #16
 5th August 2008
Gold Member
xamllew's Avatar
November 2005
9,939 Posts
Dlaor posted:
Reversed gravity FUCK YEAH!

Awesome.
 Post #17
 5th August 2008
Gold Member
Night-Eagle's Avatar
January 2005
2,378 Posts
Jinto posted:
...was going to add more stuff to it...
I really don't see a need for anything else, here.
Good/excellent/awesome job. If only this could spread like a virus...or maybe a virus would be too slow...
 Post #18
 5th August 2008
Gold Member
Gmod4ever's Avatar
August 2005
13,087 Posts
Devenger posted:
This is unbelievably awesome. I might have some use for this in Crazy Delivery...
So you made Crazy Delivery?

I played on it with a friend a while ago. It needs a help menu, and the ability to toggle camera views. I hate driving the jalopy in top-down.

Anyways, this looks freaking awesome Jinto.

I can imagine it now: cars that break the Source sound barrier!

That'd be awesome!

:4chan:
 Post #19
 5th August 2008
Vir's Avatar
January 2008
494 Posts
Try setting maxvelocity to something like 20000, making a explosive barrel, attaching a thruster with thrust of 100000, then pressing the button.
 Post #20
 5th August 2008
Gold Member
Dragory's Avatar
January 2006
5,098 Posts
This is absolutely awesome!

Also, me and my friend had the maximum velocity at around 500 000, and made a test, and got the speed very high, but no prop penetration happened.
 Post #21
 5th August 2008
dev127's Avatar
September 2006
162 Posts
Turn phys_maxangularvelocity to 0, then spawn a jeep, put a bunch of thrusters on the front grill thing set to 10k force and pull, then put a speedometer and a screen to wire the speed...then put up phys_maxvelocity to say, 10000. It's pretty awesome, but you need a map like hugeflatconstruct.
 Post #22
 5th August 2008
Gold Member
slayer3032's Avatar
November 2007
3,098 Posts
-snip-
 Post #23
 5th August 2008
Gold Member
kirderf's Avatar
October 2005
4,869 Posts
This is absolutely amazing. It works like a charm!
 Post #24
 5th August 2008
otoris's Avatar
March 2007
412 Posts
The perfect physics modification!
 Post #25
 5th August 2008
Arkantos's Avatar
July 2006
376 Posts
After messing with the gravity, and then resetting the values to default, the props seemed "floaty".

The props would behave at a slightly lower gravity, even though gravity_z was set to -600, or even default.
 Post #26
 5th August 2008
MadMoe's Avatar
November 2005
508 Posts
Dlaor posted:
Reversed gravity FUCK YEAH!

High-speed test #1.
 Post #27
 5th August 2008
Gold Member
Dennab
June 2007
8,686 Posts
MadMoe posted:
High-speed test #1.
You almost reached the speed of sound!!! (770 mph, http://en.wikipedia.org/wiki/Speed_of_sound)

Edit:

New goal: the speed of light! (670616629 mph, http://en.wikipedia.org/wiki/Speed_of_light)
 Post #28
 5th August 2008
Gold Member
cheeseman52's Avatar
June 2007
3,041 Posts
MadMoe posted:
High-speed test #1.

Were you just running or what were you doing to get that fast?
 Post #29
 5th August 2008
Dennab
April 2008
1,022 Posts
This is when we start wondering if you don't have some kind of nano-sized Cray chip embedded in your cerebral cortex.
:tizzy:

Edit:

Now I feel insufficient. DAMN YOU!

Edit:

Uhh, is the phys engine a continuous collision detection variant or is it a discrete collision detection variant?

Edit:

Why does everyone use degrees instead of radians? Radians just make more sense.
 Post #30
 5th August 2008
Gold Member
Dennab
June 2007
8,686 Posts
OlivierHamel posted:
Why does everyone use degrees instead of radians? Radians just make more sense.
I think degrees are easier, because 360 is a nice number to divide (180, 90, 45, 22.5).
 Post #31
 5th August 2008
Dennab
April 2008
1,022 Posts
2 is a nice number two. And it's smaller and more intuitive.
.25 | 45
.5 | 90
.75 | 135 (nice number right?)
1 | 180
1.25 | 225 (nice number right?)
1.5 | 270 (nice number right?)
1.75 | 315 (nice number right?)
2 | 360
 Post #32
 5th August 2008
MTOMalley's Avatar
October 2007
110 Posts
This is beautiful.
 Post #33
 5th August 2008
Dennab
April 2008
1,022 Posts
So? Does someone know if the source physics engine is a continuous detection engine or not?

Edit:

Dragory posted:
This is absolutely awesome!

Also, me and my friend had the maximum velocity at around 500 000, and made a test, and got the speed very high, but no prop penetration happened.
Question answered. Use this at your own risk, too high a velocity and collision checks will be invalidated and you might go sailing out of the world and crash the game.

Edit:

Jinto posted:
Objects moving really fast may penetrate other objects. I don't think Havok was built for really fast collision detection, but I could be wrong.
Recent Havok implementations offer continuous physics detection.
 Post #34
 5th August 2008
Arts Moderator
daijitsu's Avatar
February 2006
5,867 Posts
I wonder... someone make the max velocity some insane amount of 9's, then make a spaz contraption and get the speed...

:tizzy:
 Post #35
 5th August 2008
Gold Member
Kogitsune's Avatar
September 2005
6,461 Posts
OlivierHamel posted:
2 is a nice number two. And it's smaller and more intuitive.
.25 | 45
.5 | 90
.75 | 135 (nice number right?)
1 | 180
1.25 | 225 (nice number right?)
1.5 | 270 (nice number right?)
1.75 | 315 (nice number right?)
2 | 360
That only works if you specify that you're speaking in terms of pi, because you're completely wrong if you aren't .

While you may think more clearly in terms of pi, the average end user might not. People are just more familiar with degrees, being they make more logical sense to the average person.
 Post #36
 5th August 2008
F12Bwth's Avatar
March 2006
1,802 Posts
Now fun can be had. I think.. Projectiles Will rape bitches at a billion FPS..
 Post #37
 5th August 2008
0D0A's Avatar
July 2008
107 Posts
You might know I like pushing GMOD to it's limits.

Today, thanks to this, I did it with new "MASSIVE" prop accelerator.



It's a huge pipe that spans entire gm_wireconstruct - that should be roughly 1.5 km.



Using this apparatus I registered speed, which is, I believe, is the biggest speed you can reach in garry's mod (just due to that prop hits the map border).

I reached 29930 u/s, which is approx 2823 KPH, and 1700 MPH. Of course this is not the top limit - but the barrel (particle) went so fast, that you could not see it at 60 FPS.

P.S. It's a linear accelerator, prop goes along a single line, it should be the fastest contraption (except ones that use any bugs in physics engine)
 Post #38
 5th August 2008
Dennab
April 2008
1,022 Posts
IT'S OVER NINE THOUSAND! :freeman:
Anyways, has anyone else gotten any phys glitches yet?
 Post #39
 5th August 2008
0D0A's Avatar
July 2008
107 Posts
Yeah, I got a barrel go through a metal panel at speed of almost 3000 kph (without collision)
 Post #40
 5th August 2008
Gold Member
Dennab
June 2007
8,686 Posts
0D0A posted:
I reached 29930 u/s, which is approx 2823 KPH, and 1700 MPH. Of course this is not the top limit - but the barrel (particle) went so fast, that you could not see it at 60 FPS.
That's like, three times the speed of sound!
Reply

All times are GMT. The time now is 12:05AM.

Facepunch Studios 2010 - Server 'MARGE'