From 2892e88f2a5e9ff056db907ef8b19e7f5624314f Mon Sep 17 00:00:00 2001 From: Meetric <73554599+meetric1@users.noreply.github.com> Date: Wed, 7 Aug 2024 20:47:07 -0400 Subject: [PATCH] remove old ticker --- lua/autorun/client/gwater_menu2.lua | 19 ------------------ lua/autorun/gwater2_init.lua | 30 +---------------------------- lua/entities/gwater2_cloth_200.lua | 2 +- lua/entities/gwater2_cloth_50.lua | 2 +- lua/entities/gwater2_emitter.lua | 6 +++--- lua/gwater2_shaders.lua | 5 ++--- 6 files changed, 8 insertions(+), 56 deletions(-) diff --git a/lua/autorun/client/gwater_menu2.lua b/lua/autorun/client/gwater_menu2.lua index 881f84e..4b646d2 100644 --- a/lua/autorun/client/gwater_menu2.lua +++ b/lua/autorun/client/gwater_menu2.lua @@ -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"}, @@ -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 @@ -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 diff --git a/lua/autorun/gwater2_init.lua b/lua/autorun/gwater2_init.lua index 0b452bc..ddd9182 100644 --- a/lua/autorun/gwater2_init.lua +++ b/lua/autorun/gwater2_init.lua @@ -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) @@ -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!!!!!!!!!!!!! @@ -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 diff --git a/lua/entities/gwater2_cloth_200.lua b/lua/entities/gwater2_cloth_200.lua index f54ff18..bb56b09 100644 --- a/lua/entities/gwater2_cloth_200.lua +++ b/lua/entities/gwater2_cloth_200.lua @@ -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 diff --git a/lua/entities/gwater2_cloth_50.lua b/lua/entities/gwater2_cloth_50.lua index 4d84542..fa29afb 100644 --- a/lua/entities/gwater2_cloth_50.lua +++ b/lua/entities/gwater2_cloth_50.lua @@ -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 diff --git a/lua/entities/gwater2_emitter.lua b/lua/entities/gwater2_emitter.lua index fe782fb..dc9702f 100644 --- a/lua/entities/gwater2_emitter.lua +++ b/lua/entities/gwater2_emitter.lua @@ -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 @@ -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") diff --git a/lua/gwater2_shaders.lua b/lua/gwater2_shaders.lua index bef7581..21490c0 100644 --- a/lua/gwater2_shaders.lua +++ b/lua/gwater2_shaders.lua @@ -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 @@ -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"))