From b1d6f1dfb96bedba50fbe394ca3f0c710f99381b Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Tue, 26 May 2020 13:59:03 +0000 Subject: [PATCH] Fix pure data entities being linked into the area grid, causing performance hit From Mario (Xonotic). git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12586 d7cf8633-e32d-0410-b094-e92efae38249 --- clvm_cmds.c | 3 +++ csprogs.c | 2 +- host_cmd.c | 2 +- sv_main.c | 2 +- svvm_cmds.c | 2 ++ 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/clvm_cmds.c b/clvm_cmds.c index e6f754f4..56e4517f 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -1860,6 +1860,9 @@ static void VM_CL_copyentity (prvm_prog_t *prog) return; } memcpy(out->fields.fp, in->fields.fp, prog->entityfields * sizeof(prvm_vec_t)); + + if (VectorCompare(PRVM_clientedictvector(out, absmin), PRVM_clientedictvector(out, absmax))) + return; CL_LinkEdict(out); } diff --git a/csprogs.c b/csprogs.c index 189c6bb1..4f47741b 100644 --- a/csprogs.c +++ b/csprogs.c @@ -884,7 +884,7 @@ static void CLVM_end_increase_edicts(prvm_prog_t *prog) // link every entity except world for (i = 1, ent = prog->edicts;i < prog->num_edicts;i++, ent++) - if (!ent->priv.server->free) + if (!ent->priv.server->free && !VectorCompare(PRVM_clientedictvector(ent, absmin), PRVM_clientedictvector(ent, absmax))) CL_LinkEdict(ent); } diff --git a/host_cmd.c b/host_cmd.c index 9df142ef..ab429673 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -953,7 +953,7 @@ static void Host_Loadgame_f(cmd_state_t *cmd) PRVM_ED_ParseEdict (prog, start, ent); // link it into the bsp tree - if (!ent->priv.server->free) + if (!ent->priv.server->free && !VectorCompare(PRVM_serveredictvector(ent, absmin), PRVM_serveredictvector(ent, absmax))) SV_LinkEdict(ent); } diff --git a/sv_main.c b/sv_main.c index 19d26750..3496bc2c 100644 --- a/sv_main.c +++ b/sv_main.c @@ -3599,7 +3599,7 @@ static void SVVM_end_increase_edicts(prvm_prog_t *prog) // link every entity except world for (i = 1, ent = prog->edicts;i < prog->num_edicts;i++, ent++) - if (!ent->priv.server->free) + if (!ent->priv.server->free && !VectorCompare(PRVM_serveredictvector(ent, absmin), PRVM_serveredictvector(ent, absmax))) SV_LinkEdict(ent); } diff --git a/svvm_cmds.c b/svvm_cmds.c index 0e1a8720..8e8b00ad 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -1780,6 +1780,8 @@ static void VM_SV_copyentity(prvm_prog_t *prog) return; } memcpy(out->fields.fp, in->fields.fp, prog->entityfields * sizeof(prvm_vec_t)); + if (VectorCompare(PRVM_serveredictvector(out, absmin), PRVM_serveredictvector(out, absmax))) + return; SV_LinkEdict(out); } -- 2.39.2