Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, Quad, EternallyCurious, 1 invisible), 726 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Tip of the Week #12: ent_pvs for multiple views #463609
12/16/16 08:41
12/16/16 08:41
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
My code uses ent_pvs() a lot for gameplay, AI and effects but it broke when I changed the view rendering chain recently. ent_pvs only lists the entities of the last rendered view so "this week's tip" deals with ent_pvs for multiple views:
http://opserver.de/swik10/index.php?title=Ent_pvs


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Tip of the Week #12: ent_pvs for multiple views [Re: Superku] #463611
12/16/16 12:11
12/16/16 12:11
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Thanks, this may prove usefull laugh

Re: Tip of the Week #12: ent_pvs for multiple views [Re: Reconnoiter] #463612
12/16/16 17:51
12/16/16 17:51
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
Thank you for the effort! It's a very interesting way to solve this problem!


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: Tip of the Week #12: ent_pvs for multiple views [Re: alibaba] #463613
12/16/16 18:12
12/16/16 18:12
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Thanks, may it come in useful (or not)!


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Tip of the Week #12: ent_pvs for multiple views [Re: Superku] #463620
12/17/16 13:42
12/17/16 13:42
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
There was a bug or oversight in that approach which caused my game to behave strangely and crash while debugging it:
Because of timing issues some entities might be (ptr_)removed already before you access the ent_pvs2 list which is why you will need to add an (or extend your) on_ent_remove event:

Code:
void on_ent_remove_event(ENTITY* ent)
{
	int i,j;
	
	for(j = 0; j < 2; j++)
	{
		for(i = 0; i < ent_pvs2_list_max[j]; i++)
		{
			if(ent == ent_pvs2_list[j][i])
			{
				ent_pvs2_list_max[j]--;
				ent_pvs2_list[j][i] = ent_pvs2_list[j][ent_pvs2_list_max[j]];
				ent_pvs2_list[j][ent_pvs2_list_max[j]] = NULL;
			}
		}
	}
}




EDIT: And
"num > ent_pvs2_list_max[mode]"
has to be strictly greater than, otherwise you will skip the last element. Both issues have been fixed on the wiki page.

Last edited by Superku; 12/17/16 13:49.

"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Tip of the Week #12: ent_pvs for multiple views [Re: Superku] #463624
12/17/16 22:43
12/17/16 22:43
Joined: Dec 2016
Posts: 12
K
KingHeroov333 Offline
Newbie
KingHeroov333  Offline
Newbie
K

Joined: Dec 2016
Posts: 12
I didn't even know that this function existed LOL


Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1