Skip to content

Commit

Permalink
remove old ticker
Browse files Browse the repository at this point in the history
  • Loading branch information
meetric1 committed Aug 8, 2024
1 parent bef3f0a commit 2892e88
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 56 deletions.
19 changes: 0 additions & 19 deletions lua/autorun/client/gwater_menu2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ local options = {
["Depth Fix"] = {text = "Makes particles appear spherical instead of flat, creating a cleaner and smoother water surface.\n\nCauses shader overdraw.\n\nMedium-High performance impact."},
["Particle Limit"] = {text = "USE THIS PARAMETER AT YOUR OWN RISK.\n\nChanges the limit of particles.\n\nNote that a higher limit will negatively impact performance even with the same number of particles spawned."},
["Reaction Forces"] = {text = "0 = No reaction forces\n\n1 = Simple reaction forces. (Swimming)\n\n2 = Full reaction forces (Water can move props).\n\nNote that reaction forces only work with 'New Solver' on."},
["New Solver"] = {text = "If unchecked, uses the solver used in 0.1b and 0.2b.\n\nThe old solver usually grants better performance, but causes more particle leakage.\n\nI suggest using the old solver when recording."},

["Size"] = {text = "Size of the box the particles spawn in"},
["Density"] = {text = "Density of particles.\n Controls how far apart they are"},
Expand Down Expand Up @@ -701,7 +700,6 @@ concommand.Add("gwater2_menu", function()
Color(255, 0, 0),
Color(250, 250, 0),
Color(255, 127, 0),
Color(255, 0, 0),
}

local slider
Expand Down Expand Up @@ -847,23 +845,6 @@ I DO NOT take responsiblity for any hardware damage this may cause]], "DermaDefa
normals:SetInt("$depthfix", val and 1 or 0)
end

-- Solver checkbox
local label = vgui.Create("DLabel", scrollPanel)
label:SetPos(10, 260)
label:SetSize(100, 100)
label:SetFont("GWater2Param")
label:SetText("New Solver")
label:SetContentAlignment(7)
labels[8] = label

local box = vgui.Create("DCheckBox", scrollPanel)
box:SetPos(132, 260)
box:SetSize(20, 20)
box:SetChecked(gwater2.new_ticker)
function box:OnChange(val)
gwater2.new_ticker = !gwater2.new_ticker
end

-- light up & change explanation area
function scrollPanel:AnimationThink()
if !mainFrame:HasFocus() then return end
Expand Down
30 changes: 1 addition & 29 deletions lua/autorun/gwater2_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ end
gwater2 = {
solver = FlexSolver(100000),
renderer = FlexRenderer(),
new_ticker = true,
cloth_pos = Vector(),
material = Material("gwater2/finalpass"),--Material("vgui/circle"),--Material("sprites/sent_ball"),
update_meshes = function(index, id, rep)
Expand Down Expand Up @@ -140,23 +139,8 @@ gwater2["force_multiplier"] = 0.01
gwater2["force_buoyancy"] = 0
gwater2["force_dampening"] = 0

-- tick particle solver
local last_systime = os.clock()
local limit_fps = 1 / 60
local average_frametime = limit_fps
local function gwater_tick()
if gwater2.new_ticker then return end

-- Defined in C++
GWATER2_QuickHackRemoveMeASAP(LocalPlayer():EntIndex(), 0) -- TODO: REMOVE THIS HACKY SHIT!!!!!!!!!!!!!
LocalPlayer().GWATER2_CONTACTS = 0

local systime = os.clock()
hook.Run("gwater2_posttick", gwater2.solver:Tick(limit_fps, 1))
end

local function gwater_tick2()
last_systime = os.clock()
gwater2.solver:ApplyContacts(limit_fps * gwater2["force_multiplier"], 3, gwater2["force_buoyancy"], gwater2["force_dampening"])
local particles_in_radius = gwater2.solver:GetParticlesInRadius(LocalPlayer():GetPos() + LocalPlayer():OBBCenter(), gwater2.solver:GetParameter("fluid_rest_distance") * 3, GWATER2_PARTICLES_TO_SWIM)
GWATER2_QuickHackRemoveMeASAP( -- TODO: REMOVE THIS HACKY SHIT!!!!!!!!!!!!!
Expand All @@ -170,19 +154,7 @@ local function gwater_tick2()
hook.Run("gwater2_posttick", gwater2.solver:Tick(limit_fps, 0))
end

// run whenever possible, as often as possible. we dont know when flex will finish calculations
local no = function() end
hook.Add("PreRender", "gwater_tick", gwater_tick)
hook.Add("PostRender", "gwater_tick", gwater_tick)
hook.Add("Think", "gwater_tick", function()
if gwater2.new_ticker then return end
gwater2.solver:IterateMeshes(gwater2.update_meshes)
end)

timer.Create("gwater2_tick", limit_fps, 0, function()
if !gwater2.new_ticker then return end
gwater_tick2()
end)
timer.Create("gwater2_tick", limit_fps, 0, gwater_tick2)

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
Expand Down
2 changes: 1 addition & 1 deletion lua/entities/gwater2_cloth_200.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ end

-- dont.
function ENT:Draw()

self:SetNoDraw(true)
end

-- remove all cloth, as theres not a way to remove individually yet
Expand Down
2 changes: 1 addition & 1 deletion lua/entities/gwater2_cloth_50.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ end

-- dont.
function ENT:Draw()

self:SetNoDraw(true)
end

-- remove all cloth, as theres not a way to remove individually yet
Expand Down
6 changes: 3 additions & 3 deletions lua/entities/gwater2_emitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ENT.PrintName = "Emitter"
ENT.Author = "Mee"
ENT.Purpose = ""
ENT.Instructions = ""
ENT.Spawnable = true
ENT.Spawnable = true

function ENT:Initialize()
if CLIENT then
Expand All @@ -19,8 +19,8 @@ function ENT:Initialize()
--mat:SetAngles(self:LocalToWorldAngles(Angle(0, CurTime() * 200, 0)))
mat:SetAngles(self:LocalToWorldAngles(Angle(0, 0, 0)))
mat:SetTranslation(self:GetPos() + self:GetUp() * 10)

gwater2.solver:AddCylinder(mat, Vector(6, 6, 1), {vel = self:GetUp() * 10})
gwater2.solver:AddCylinder(mat, Vector(6, 6, 1), {vel = self:GetUp() * 60})
end)
else
self:SetModel("models/mechanics/wheels/wheel_speed_72.mdl")
Expand Down
5 changes: 2 additions & 3 deletions lua/gwater2_shaders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ local function unfuck_lighting(pos0, pos1)
render.OverrideDepthEnable(false, false)
render.PopRenderTarget()
end
local wtf = FlexSolver(1)
wtf:AddParticle(Vector())

-- gwater2 shader pipeline
hook.Add("PostDrawOpaqueRenderables", "gwater2_render", function(depth, sky, sky3d) --PreDrawViewModels
if gwater2.solver:GetActiveParticles() < 1 then return end
Expand All @@ -72,7 +71,7 @@ hook.Add("PostDrawOpaqueRenderables", "gwater2_render", function(depth, sky, sky
local scrh = ScrH()
local water = gwater2.material
local radius = gwater2.solver:GetParameter("radius")
--wtf:Tick(1/60, 0)

gwater2.renderer:BuildMeshes(gwater2.solver, 0.2)
--render.SetMaterial(Material("models/props_combine/combine_interface_disp"))

Expand Down

0 comments on commit 2892e88

Please sign in to comment.