From f4e7d9854485a3ad105226fda9b71639abe9ac7f Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Thu, 13 Nov 2025 18:37:03 +0300 Subject: [PATCH 1/4] Don't throw errors inside meshlab These errors are kind of useless if you're not a developer and can confuse players by creating errors out of nowhere Therefore, i suggest throwing them only if developer is set to 1 --- lua/prop2mesh/cl_meshlab.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lua/prop2mesh/cl_meshlab.lua b/lua/prop2mesh/cl_meshlab.lua index 04b0caa..4e86a4b 100644 --- a/lua/prop2mesh/cl_meshlab.lua +++ b/lua/prop2mesh/cl_meshlab.lua @@ -46,10 +46,22 @@ cvars.AddChangeCallback("prop2mesh_render_disable_obj", function(cvar, old, new) disable_obj = tobool(new) end, "swapdrawdisable_obj") +local devcvar = GetConVar("developer") + +local function throwerror(withstack, ...) + if devcvar:GetBool() then + if withstack then + ErrorNoHaltWithStack(...) + else + ErrorNoHalt(...) + end + end +end --[[ ]] + local function calcbounds(min, max, pos) if pos.x < min.x then min.x = pos.x elseif pos.x > max.x then max.x = pos.x end if pos.y < min.y then min.y = pos.y elseif pos.y > max.y then max.y = pos.y end @@ -865,7 +877,7 @@ local function getVertsFromOBJ(custom, partnext, meshtex, meshbump, vmins, vmaxs local smooth = partnext.vsmooth local parseErr, errChar, errLine = tryParseObj(modelobj, vmesh, vlook, vmins, vmaxs, pos, ang, scale, invert, meshtex) if parseErr then - ErrorNoHalt("Prop2Mesh getVertsFromOBJ failure at line " .. errLine .. ", char " .. errChar .. ": " .. tostring(parseErr) .. "\n") + throwerror(false, "Prop2Mesh getVertsFromOBJ failure at line " .. errLine .. ", char " .. errChar .. ": " .. tostring(parseErr) .. "\n") coroutine_yield(false) end @@ -1093,7 +1105,7 @@ hook.Add("Think", "prop2mesh_meshlab", function() local ok, err, mdata = coroutine.resume(lab.coro, lab.data, lab.uniqueID) if not ok then - ErrorNoHaltWithStack("Prop2Mesh Meshlab error: " .. (tostring(err) or "")) + throwerror(true, "Prop2Mesh Meshlab error: " .. (tostring(err) or "")) meshlabs[key] = nil break end From 04bd73f66425a7cbeece5978c69006cab4300a04 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Thu, 13 Nov 2025 18:37:49 +0300 Subject: [PATCH 2/4] Less diff --- lua/prop2mesh/cl_meshlab.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/prop2mesh/cl_meshlab.lua b/lua/prop2mesh/cl_meshlab.lua index 4e86a4b..0dc9442 100644 --- a/lua/prop2mesh/cl_meshlab.lua +++ b/lua/prop2mesh/cl_meshlab.lua @@ -61,7 +61,6 @@ end --[[ ]] - local function calcbounds(min, max, pos) if pos.x < min.x then min.x = pos.x elseif pos.x > max.x then max.x = pos.x end if pos.y < min.y then min.y = pos.y elseif pos.y > max.y then max.y = pos.y end From 907639080d77931fc8a46304c4ab18c10392fb4a Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Fri, 14 Nov 2025 20:31:42 +0300 Subject: [PATCH 3/4] Do it another way --- lua/prop2mesh/cl_meshlab.lua | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/lua/prop2mesh/cl_meshlab.lua b/lua/prop2mesh/cl_meshlab.lua index 0dc9442..7865240 100644 --- a/lua/prop2mesh/cl_meshlab.lua +++ b/lua/prop2mesh/cl_meshlab.lua @@ -39,6 +39,7 @@ local coroutine_yield = coroutine.yield local a90 = Angle(0, -90, 0) local YIELD_THRESHOLD = 30 +local devcvar = GetConVar("developer") local cvar = CreateClientConVar("prop2mesh_render_disable_obj", 0, true, false) local disable_obj = cvar:GetBool() @@ -46,18 +47,6 @@ cvars.AddChangeCallback("prop2mesh_render_disable_obj", function(cvar, old, new) disable_obj = tobool(new) end, "swapdrawdisable_obj") -local devcvar = GetConVar("developer") - -local function throwerror(withstack, ...) - if devcvar:GetBool() then - if withstack then - ErrorNoHaltWithStack(...) - else - ErrorNoHalt(...) - end - end -end - --[[ ]] @@ -876,7 +865,10 @@ local function getVertsFromOBJ(custom, partnext, meshtex, meshbump, vmins, vmaxs local smooth = partnext.vsmooth local parseErr, errChar, errLine = tryParseObj(modelobj, vmesh, vlook, vmins, vmaxs, pos, ang, scale, invert, meshtex) if parseErr then - throwerror(false, "Prop2Mesh getVertsFromOBJ failure at line " .. errLine .. ", char " .. errChar .. ": " .. tostring(parseErr) .. "\n") + if devcvar:GetBool() then + ErrorNoHalt("Prop2Mesh getVertsFromOBJ failure at line " .. errLine .. ", char " .. errChar .. ": " .. tostring(parseErr) .. "\n") + end + coroutine_yield(false) end @@ -1104,7 +1096,10 @@ hook.Add("Think", "prop2mesh_meshlab", function() local ok, err, mdata = coroutine.resume(lab.coro, lab.data, lab.uniqueID) if not ok then - throwerror(true, "Prop2Mesh Meshlab error: " .. (tostring(err) or "")) + if devcvar:GetBool() then + ErrorNoHaltWithStack("Prop2Mesh Meshlab error: " .. (tostring(err) or "")) + end + meshlabs[key] = nil break end From ea104451a2ab740e1ee17a178c33b85c80da4959 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Fri, 14 Nov 2025 20:32:09 +0300 Subject: [PATCH 4/4] Less diff --- lua/prop2mesh/cl_meshlab.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/prop2mesh/cl_meshlab.lua b/lua/prop2mesh/cl_meshlab.lua index 7865240..250dbc1 100644 --- a/lua/prop2mesh/cl_meshlab.lua +++ b/lua/prop2mesh/cl_meshlab.lua @@ -47,6 +47,7 @@ cvars.AddChangeCallback("prop2mesh_render_disable_obj", function(cvar, old, new) disable_obj = tobool(new) end, "swapdrawdisable_obj") + --[[ ]]