From aff6408da5788fbe23ba81256c500c00d63b008c Mon Sep 17 00:00:00 2001 From: deltamolfar <72973198+deltamolfar@users.noreply.github.com> Date: Fri, 26 Dec 2025 13:16:40 +0200 Subject: [PATCH 1/2] Add FCVAR_REPLICATED --- lua/entities/gmod_wire_customprop/init.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/entities/gmod_wire_customprop/init.lua b/lua/entities/gmod_wire_customprop/init.lua index 6167c7fc70..7be8c3f8ba 100644 --- a/lua/entities/gmod_wire_customprop/init.lua +++ b/lua/entities/gmod_wire_customprop/init.lua @@ -10,11 +10,11 @@ local Ent_GetTable = ENT_META.GetTable -- Reason why there are more max convexes but less max vertices by default is that client's ENT:BuildPhysics is the main bottleneck. -- It seems to require more time exponentially to the vertices amount. -- The same amount of vertices in total, but broken into different convexes greatly reduces the performance hit. -local wire_customprops_hullsize_max = CreateConVar("wire_customprops_hullsize_max", 2048, FCVAR_ARCHIVE, "The max hull size of a custom prop") -local wire_customprops_minvertexdistance = CreateConVar("wire_customprops_minvertexdistance", 0.2, FCVAR_ARCHIVE, "The min distance between two vertices in a custom prop.") -local wire_customprops_vertices_max = CreateConVar("wire_customprops_vertices_max", 64, FCVAR_ARCHIVE, "How many vertices custom props can have.", 4) -local wire_customprops_convexes_max = CreateConVar("wire_customprops_convexes_max", 12, FCVAR_ARCHIVE, "How many convexes custom props can have.", 1) -local wire_customprops_max = CreateConVar("wire_customprops_max", 16, FCVAR_ARCHIVE, "The maximum number of custom props a player can spawn. (0 to disable)", 0) +local wire_customprops_hullsize_max = CreateConVar("wire_customprops_hullsize_max", 2048, {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "The max hull size of a custom prop") +local wire_customprops_minvertexdistance = CreateConVar("wire_customprops_minvertexdistance", 0.2, {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "The min distance between two vertices in a custom prop.") +local wire_customprops_vertices_max = CreateConVar("wire_customprops_vertices_max", 64, {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "How many vertices custom props can have.", 4) +local wire_customprops_convexes_max = CreateConVar("wire_customprops_convexes_max", 12, {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "How many convexes custom props can have.", 1) +local wire_customprops_max = CreateConVar("wire_customprops_max", 16, {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "The maximum number of custom props a player can spawn. (0 to disable)", 0) WireLib = WireLib or {} WireLib.CustomProp = WireLib.CustomProp or {} From 8e142648ac6e1792575c10702467a39043f24eca Mon Sep 17 00:00:00 2001 From: deltamolfar <72973198+deltamolfar@users.noreply.github.com> Date: Fri, 26 Dec 2025 13:22:14 +0200 Subject: [PATCH 2/2] Move convar creation to shared.lua --- lua/entities/gmod_wire_customprop/init.lua | 13 +++++-------- lua/entities/gmod_wire_customprop/shared.lua | 9 +++++++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lua/entities/gmod_wire_customprop/init.lua b/lua/entities/gmod_wire_customprop/init.lua index 7be8c3f8ba..b8f5f6f54d 100644 --- a/lua/entities/gmod_wire_customprop/init.lua +++ b/lua/entities/gmod_wire_customprop/init.lua @@ -7,14 +7,11 @@ util.AddNetworkString(shared.classname) local ENT_META = FindMetaTable("Entity") local Ent_GetTable = ENT_META.GetTable --- Reason why there are more max convexes but less max vertices by default is that client's ENT:BuildPhysics is the main bottleneck. --- It seems to require more time exponentially to the vertices amount. --- The same amount of vertices in total, but broken into different convexes greatly reduces the performance hit. -local wire_customprops_hullsize_max = CreateConVar("wire_customprops_hullsize_max", 2048, {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "The max hull size of a custom prop") -local wire_customprops_minvertexdistance = CreateConVar("wire_customprops_minvertexdistance", 0.2, {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "The min distance between two vertices in a custom prop.") -local wire_customprops_vertices_max = CreateConVar("wire_customprops_vertices_max", 64, {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "How many vertices custom props can have.", 4) -local wire_customprops_convexes_max = CreateConVar("wire_customprops_convexes_max", 12, {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "How many convexes custom props can have.", 1) -local wire_customprops_max = CreateConVar("wire_customprops_max", 16, {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "The maximum number of custom props a player can spawn. (0 to disable)", 0) +local wire_customprops_hullsize_max = GetConVar("wire_customprops_hullsize_max") +local wire_customprops_minvertexdistance = GetConVar("wire_customprops_minvertexdistance") +local wire_customprops_vertices_max = GetConVar("wire_customprops_vertices_max") +local wire_customprops_convexes_max = GetConVar("wire_customprops_convexes_max") +local wire_customprops_max = GetConVar("wire_customprops_max") WireLib = WireLib or {} WireLib.CustomProp = WireLib.CustomProp or {} diff --git a/lua/entities/gmod_wire_customprop/shared.lua b/lua/entities/gmod_wire_customprop/shared.lua index 59f6c99c5a..9a20f66050 100644 --- a/lua/entities/gmod_wire_customprop/shared.lua +++ b/lua/entities/gmod_wire_customprop/shared.lua @@ -7,6 +7,15 @@ ENT.Author = "Sparky & DeltaMolfar" ENT.Spawnable = false ENT.AdminSpawnable = false +-- Reason why there are more max convexes but less max vertices by default is that client's ENT:BuildPhysics is the main bottleneck. +-- It seems to require more time exponentially to the vertices amount. +-- The same amount of vertices in total, but broken into different convexes greatly reduces the performance hit. +CreateConVar("wire_customprops_hullsize_max", 2048, {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "The max hull size of a custom prop") +CreateConVar("wire_customprops_minvertexdistance", 0.2, {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "The min distance between two vertices in a custom prop.") +CreateConVar("wire_customprops_vertices_max", 64, {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "How many vertices custom props can have.", 4) +CreateConVar("wire_customprops_convexes_max", 12, {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "How many convexes custom props can have.", 1) +CreateConVar("wire_customprops_max", 16, {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "The maximum number of custom props a player can spawn. (0 to disable)", 0) + function ENT:SetupDataTables() self:NetworkVar("String", 0, "PhysMaterial")