Gamestudio Links
Zorro Links
Newest Posts
TradeVars not working with pending trades
by jcl
2 seconds ago
Creating a Directory
by txesmi
Yesterday at 10:15
Multi asset correlation
by jcl
Yesterday at 09:57
Help in analysis...
by MINER
Yesterday at 09:13
Strange problem with a global int
by jcl
Yesterday at 08:48
New Zorro version 2.03
by jcl
Yesterday at 08:28
not using profit targets during strategy development
by laz
Yesterday at 00:23
AUM Magazine
Latest Screens
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Evonet Beta v1.0 : Online Project Development Template
Who's Online
6 registered (kvm, 20BN, Dalla, AndrewAMD, 2 invisible), 581 Guests and 7 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
Pelin27, Aziz, lucianopneto, j45p41, Max_Ahn
18173 Registered Users
Topic Options
Rate This Topic
#474014 - 09/07/18 18:11 About auto hide invisible entitiesl
20BN Online
Member

Registered: 02/08/03
Posts: 120
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: 606
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 Offline
Member

Registered: 11/14/05
Posts: 199
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 Online
Member

Registered: 02/08/03
Posts: 120
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: 6813
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 - stuck in development hell: http://store.steampowered.com/app/407570

Check out my new game: Pogostuck: Rage With Your Friends

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

Registered: 11/14/05
Posts: 199
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 Online
Member

Registered: 02/08/03
Posts: 120
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 Offline
Member

Registered: 11/14/05
Posts: 199
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