AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   [TUT] Usage EngFunc_EntitiesInPVS (https://forums.alliedmods.net/showthread.php?t=103629)

joropito 09-14-2009 19:04

[TUT] Usage EngFunc_EntitiesInPVS
 
This is my first tutorial.

After interpreting trigger.cpp (from HLDS), I decided to make this tutorial.

EngFunc_EntitiesInPVS (maybe the same for EngFunc_FindClientInPVS)
It returns an entity in PVS (potential visible set) of a player.
It never returns worldspawn.

In that entity returned, you have a set of chained entities using pev_chain.

Example
Code:
public whatisonPVS(id) {     static next, chain;     static class[32];     next = engfunc(EngFunc_EntitiesInPVS, id);     while(next)     {         pev(next, pev_classname, class, charsmax(class));         chain = pev(next, pev_chain);         server_print("Found entity in player (%i) PVS: ent(%i) class(%s)", id, next, class);         if(!chain)             break;         next = chain;     } }

So this function iterates over and over every entity until pev_chain is NULL.

ot_207 09-15-2009 02:32

Re: [TUT] Usage EngFunc_EntitiesInPVS
 
Good job! This will be useful for some tests.
It would have been better if you have added it here->
http://forums.alliedmods.net/showthread.php?t=93229

Also it would be a good idea to tell people how PVS works (not as function) as a system.
If you are interested I can give you some info about it.

Edit: Tested and it works! :wink:

Arkshine 09-15-2009 03:19

Re: [TUT] Usage EngFunc_EntitiesInPVS
 
Quote:

(maybe the same for EngFunc_FindClientInPVS)
When I was tested, I remember that you need to call severals times EngFunc_FindClientInPVS to get the next value of the list. Which is a pain is there is it seems a delay like 0.3s before it updates. So if you call a lot of times while 0.2s you will get the same value.

Quote:

It never returns a player entity
Just tested and it returns players. "player" is an entity.

Found entity in player (1) PVS: ent(5) class(player)
Found entity in player (1) PVS: ent(3) class(player)
Found entity in player (1) PVS: ent(1) class(player)

ot_207 09-15-2009 03:40

Re: [TUT] Usage EngFunc_EntitiesInPVS
 
Quote:

Originally Posted by Arkshine (Post 933388)
Just tested and it returns players. "player" is an entity.

Found entity in player (1) PVS: ent(5) class(player)
Found entity in player (1) PVS: ent(3) class(player)
Found entity in player (1) PVS: ent(1) class(player)

That is true, forgot to post that :).

I haven't done any tests relating but since this function already does its job properly we don't really need EngFunc_FindClientInPVS.

joropito 09-15-2009 07:34

Re: [TUT] Usage EngFunc_EntitiesInPVS
 
Quote:

Originally Posted by ot_207 (Post 933367)
Good job! This will be useful for some tests.
It would have been better if you have added it here->
http://forums.alliedmods.net/showthread.php?t=93229

Please, could you add this there?

I use your tutorial a couple of times.

ot_207 09-15-2009 08:12

Re: [TUT] Usage EngFunc_EntitiesInPVS
 
Ok.
After I do some tests.

joropito 09-15-2009 13:30

Re: [TUT] Usage EngFunc_EntitiesInPVS
 
Quote:

Originally Posted by ot_207 (Post 933367)
If you are interested I can give you some info about it.

Yes please!

I thought PVS was just what you can see (visual area) but it's like what you could see in a 360* fashion from the point where you are.

And, during my tests, I saw that the walls were ignored...

ot_207 09-15-2009 15:06

Re: [TUT] Usage EngFunc_EntitiesInPVS
 
Quote:

Originally Posted by joropito (Post 933830)
Yes please!

I thought PVS was just what you can see (visual area) but it's like what you could see in a 360* fashion from the point where you are.

And, during my tests, I saw that the walls were ignored...

Quote:

Originally Posted by ot_207 (Post 933833)
What is PVS?
PVS means potentially visible set, this means that the entities that we have in this list can be seen.
PVS does not hold just the entities that we see!
By knowing this we can get to the conclusion that PVS has the role of limiting data transfer for better internet connection/lower amount of data transfer!

So in small words I want to say something like this:
Code:

Entity that is in PVS => Can be seen => Data Transfer about that entity
Entity that it is not in PVS => Can not be seen => No data transfer => Save bandwidth

How does it work?
Well let's say that every room of the map is a cube.
We find ourselves in a room and that also means that we are in the cube of that room.
We can see the entities in the next rooms because the cubes of that room touch with the cube of the room we are in.

And yes the walls should be ignored! Because info about the worldspawn isn't sent to the client!

joropito 09-15-2009 15:35

Re: [TUT] Usage EngFunc_EntitiesInPVS
 
Quote:

Originally Posted by ot_207 (Post 933939)
And yes the walls should be ignored! Because info about the worldspawn isn't sent to the client!

Thanks!


All times are GMT -4. The time now is 09:27.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.