PDA

View Full Version : [TUT] Usage EngFunc_EntitiesInPVS


joropito
09-14-2009, 19:04
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

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
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
(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.

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
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
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
Ok.
After I do some tests.

joropito
09-15-2009, 13:30
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
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...

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:
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
And yes the walls should be ignored! Because info about the worldspawn isn't sent to the client!

Thanks!