Skip to content

Commit

Permalink
fix majority of particle clipping issues
Browse files Browse the repository at this point in the history
  • Loading branch information
meetric1 committed Jul 26, 2024
1 parent 3f9b847 commit cd09b33
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 3 additions & 3 deletions binary/src/flex_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ FlexSolver::FlexSolver(NvFlexLibrary* library, int particles) {
params->shockPropagation = 0.0f;
params->restitution = 0.0f;

params->maxSpeed = 1e10;
params->maxAcceleration = 200.0f;
params->maxSpeed = 1e5;
params->maxAcceleration = 1e5;
params->relaxationMode = eNvFlexRelaxationLocal;
params->relaxationFactor = 0.25f; // only works with eNvFlexRelaxationGlobal
params->solidPressure = 0.5f;
Expand All @@ -367,7 +367,7 @@ FlexSolver::FlexSolver(NvFlexLibrary* library, int particles) {
params->diffuseThreshold = 100.f;
params->diffuseBuoyancy = 1.f;
params->diffuseDrag = 0.8f;
params->diffuseBallistic = 0;
params->diffuseBallistic = 2;
params->diffuseLifetime = 5.f; // not actually in seconds

params->numPlanes = 0;
Expand Down
6 changes: 3 additions & 3 deletions binary/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,9 @@ LUA_FUNCTION(FLEXSOLVER_AddCube) {
LUA_FUNCTION(FLEXSOLVER_AddForceField) {
LUA->CheckType(1, FLEXSOLVER_METATABLE);
LUA->CheckType(2, Type::Vector);
LUA->CheckNumber(3);
LUA->CheckNumber(4);
LUA->CheckNumber(5);
LUA->CheckNumber(3); // radius
LUA->CheckNumber(4); // strength
LUA->CheckNumber(5); // mode
LUA->CheckType(6, Type::Bool);

FlexSolver* flex = GET_FLEXSOLVER(1);
Expand Down
10 changes: 9 additions & 1 deletion lua/autorun/gwater2_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,18 @@ end)
hook.Add("InitPostEntity", "gwater2_addprop", gwater2.reset_solver)
hook.Add("OnEntityCreated", "gwater2_addprop", function(ent) timer.Simple(0, function() add_prop(ent) end) end) // timer.0 so data values are setup correctly

hook.Add("gwater2_pretick", "gravgun", function()
hook.Add("gwater2_pretick", "gwater2_gravgun_grab", function()
local lp = LocalPlayer()
if !lp:KeyDown(IN_ATTACK2) then return end
if IsValid(LocalPlayer():GetActiveWeapon()) and LocalPlayer():GetActiveWeapon():GetClass() == "weapon_physcannon" then
gwater2.solver:AddForceField(LocalPlayer():EyePos() + LocalPlayer():GetAimVector() * 170, 150, -200, 0, true)
end
end)

hook.Add("Think", "gwater2_gravgun_punt", function() -- + LocalPlayer():GetAimVector() * 85
local lp = LocalPlayer()
if !lp:KeyPressed(IN_ATTACK) then return end
if IsValid(LocalPlayer():GetActiveWeapon()) and LocalPlayer():GetActiveWeapon():GetClass() == "weapon_physcannon" then
gwater2.solver:AddForceField(LocalPlayer():EyePos(), 300, 100, 1, false)
end
end)

0 comments on commit cd09b33

Please sign in to comment.