Gamestudio Links
Zorro Links
Newest Posts
How is this possible ? winning percentage 100%
by MatPed
50 minutes 13 seconds ago
Next contest?
by Michael_Schwarz
Today at 10:33
Help! 1.88.6 Crashes <5 minutes after clicking Trade!
by jcl
Today at 10:28
WFO
by jcl
Today at 10:27
TA-Lib not updated
by jcl
Today at 10:24
CyberCycle Adaptive Cy
by OptimusPrime
Today at 05:26
video memory and d3d_texfree
by Superku
Yesterday at 11:17
AUM Magazine
Latest Screens
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Evonet Beta v1.0 : Online Project Development Template
Lake scene
Who's Online
16 registered (CocaCola, kvm, MatPed, Iglarion, AndrewAMD, brax, Michael_Schwarz, Mio, 2 invisible), 454 Guests and 3 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
fandi, Deedee, avgtrader, aventador, gokhanuck
18103 Registered Users
Topic Options
Rate This Topic
#474014 - 09/07/18 18:11 About auto hide invisible entitiesl
20BN Offline
Member

Registered: 02/08/03
Posts: 110
Loc: RP China
Hi, all.
If every game levels has 3000-5000 entities,
need to hide outside of camera sight.
Do you have any plans?

Top
#474161 - 09/26/18 05:19 Re: About auto hide invisible entitiesl [Re: 20BN]
Dooley Offline
User

Registered: 05/12/05
Posts: 587
Loc: Chicago, IL
camera.clip_near
camera.clip_far

Look these up in manual
_________________________
Check out "Star Explorers" on Steam:
http://store.steampowered.com/app/502720/Star_Explorers/

Anomalies released on Steam: http://store.steampowered.com/app/546780


Top
#474163 - 09/26/18 08:36 Re: About auto hide invisible entitiesl [Re: 20BN]
HellThunder Online
Member

Registered: 11/14/05
Posts: 197
Loc: Bavaria
You could use the part of this while loop for hiding entities. Related to the camera position and the culling_distance, it will hide your entities or show them again. This code snippet was a part of AUM - original was C-Script.
Code:
var culling_distance = 4000;
action NULL_() 
{
 while(me)
 {
	if (vec_dist (my.x, camera.x) < culling_distance) // the player has come close to this entity?
	{
		reset(my, INVISIBLE); // then show it!
		while (my.alpha < 100) // run this loop until the entity becomes opaque again
		{
			my.alpha = minv(100, my.alpha + 15 * time_step); // increase my.alpha (15 = speed) and limit it to 100
			wait (1);
		}
		reset(my, TRANSLUCENT); // get rid of some nasty artifacts when the entity is completely visible
	}
	else // the player has moved away from this entity?
	{
		set(my, TRANSLUCENT);  // then set the "transparent" flag again
		while (my.alpha > 0) // run this loop until the entity becomes practically invisible (alpha = 0)
		{
			my.alpha = maxv(0, my.alpha - 15 * time_step); // decrease my.alpha (15 = speed) and limit it to 0
			wait (1);
		}
		set(my, INVISIBLE); // now hide the entity in order to increase the frame rate

	}
        wait(1);
 }
}


Top
#474175 - 09/26/18 16:26 Re: About auto hide invisible entitiesl [Re: HellThunder]
20BN Offline
Member

Registered: 02/08/03
Posts: 110
Loc: RP China
In other words, 1000 entities, there will be 1000 processes?

Top
#474176 - 09/26/18 17:06 Re: About auto hide invisible entitiesl [Re: 20BN]
Superku Offline
Senior Expert

Registered: 09/13/03
Posts: 6771
Loc: Kiel (Germany)
I'm sorry but don't use that code quoted by HellThunder. Do not do this manually, esp. not with dedicated wait(1) loops per entity. This is an engine's task.

Entities not on screen in the sense of the camera's frustum are set to invisible/ CLIPPED automatically.


For distance based clipping camera.clip_far or LOD is the correct approach.
For special cases such as a building full of entities you can use region_set in A8 to hide all entities contained in that region manually.


If the entity count (and draw count) is a problem performance wise, you may want to think about combining multiple entities into one.
_________________________
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Superku The Game

Severely outdated footage: http://store.steampowered.com/app/407570

Top
#474177 - 09/26/18 22:43 Re: About auto hide invisible entitiesl [Re: Superku]
HellThunder Online
Member

Registered: 11/14/05
Posts: 197
Loc: Bavaria
Entity loops would result with additional tasks, true - But should this result in a bottleneck?

In order to validate the production quality of this method, I used the snippet within the main loop of a testlevel with over 600 Entities. Every entity got an action. Some models use normal maps. HDR + DOF and a screen resolution of 1920*1080.

Result:
Quote:
culling_distance: 10000 fps: about 80



Quote:
culling_distance: 3400 fps: 105-110



The fading works flawlessly, plus selection of entities which should be hidden and which should stay would be possible.
e.g. Would work fine for hiding vegetation or other environment entities, but could also be able to force mountains to stay visible.

Conclusion:
For grouping entities and hiding groups of entities, the snippet works very fine and results with a fps increase.
For just limiting the view I would suggest to use the approach of Superku, which is mentioned within the official manual for cases like this.


Top
#474227 - 10/01/18 13:33 Re: About auto hide invisible entitiesl [Re: HellThunder]
20BN Offline
Member

Registered: 02/08/03
Posts: 110
Loc: RP China
@HellThunder

your fuc = 8.(600 entities loop = 8?)

Top
#474242 - 10/01/18 22:02 Re: About auto hide invisible entitiesl [Re: 20BN]
HellThunder Online
Member

Registered: 11/14/05
Posts: 197
Loc: Bavaria
I don't know, if I understand your question.
In my case it is just a single function, which will be started after the camera or player is moving. The function itself will be called within a mainloop, which runs all the time.

Top


Moderator:  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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

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