From dd4ca2a5d4848141aefcca6987e71e1734a50856 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 ::stable-branch::merge=b1d6f1dfb96bedba50fbe394ca3f0c710f99381b --- 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 54848d8e..7d2ccfd4 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -1872,6 +1872,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 8d54fc0f..1a7c57de 100644 --- a/csprogs.c +++ b/csprogs.c @@ -882,7 +882,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 a62b0832..582a58f9 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -964,7 +964,7 @@ static void Host_Loadgame_f (void) 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 d724aa1f..12632eb3 100644 --- a/sv_main.c +++ b/sv_main.c @@ -3595,7 +3595,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 e4969440..fc1449f3 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -1772,6 +1772,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