Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (TipmyPip, 1 invisible), 18,787 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
More than 1000 entities = death for a game? #227605
09/15/08 10:58
09/15/08 10:58
Joined: Aug 2008
Posts: 55
United Kingdom
CdeathJD Offline OP
Junior Member
CdeathJD  Offline OP
Junior Member

Joined: Aug 2008
Posts: 55
United Kingdom
Hey there i have just started using Lite-C (a few weeks experience) but have managed to code up a basic particle spawner of my own. However, it seems that anything more than 1000 particles alive at a time is nothing but death for ones framerate. Surely there is a way to alter this, i have a good system, but a much older engine i used to use (blitz3d - thats like made in about 2001 i think) can handle about 10,000 easy and upto 15,000 without crashing!

Any advice is helpful!


I am a noob to this... Blitz3D is where i am best at!
Re: More than 1000 entities = death for a game? [Re: CdeathJD] #227637
09/15/08 13:56
09/15/08 13:56
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
I was helping someone else with their project, and we were
getting up to over 40,000 textured, shadered,in-camera,
rotating, and visible entitys before things started getting doggy.
But we werent using any physics.

Unless your box-spawner has changed a-lot since I last saw it,
I think its lag is probably due to too many physics collisions
happening per second due to the huge number of overlapping blocks.

Once I get some free time in the next few days I'll take a look and see
if I cant squeeze any improvements out of it.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: More than 1000 entities = death for a game? [Re: EvilSOB] #227736
09/15/08 22:04
09/15/08 22:04
Joined: Aug 2008
Posts: 55
United Kingdom
CdeathJD Offline OP
Junior Member
CdeathJD  Offline OP
Junior Member

Joined: Aug 2008
Posts: 55
United Kingdom
This is happening in some other code where physics is not present in more than about 10 objects, and all others are PASSABLE. Would i have to have a physics free level altogether to get that amount?

Code:
#include <acknex.h>
#include <default.c>

ENTITY* FLOOR;

VECTOR box_rotation;
VECTOR centre = vector(0,0,0);

var dampener;
var c1;  
var num_box;
var new_ball_delay;
var iveruntheIamFlyfunk;
STRING* num_box_string;

d3d_alpharef = 180;

typedef struct
{
	var velx;
	var vely;
	var velz;
	var lifetime;
	ENTITY* model;
} box; 

PANEL* panDisplay =
{
	digits(35, 10, "smokes = %0.f", *, 1, num_box);
	flags = VISIBLE;
}


function do_sprite(ENTITY* ThisModel,var xv,var yv,var zv)
{
	while(ThisModel.skill25>0)
	{
		wait(1);			//wait 1 frame
		ThisModel.skill25 -= 15;	//reduce counter
		if (random(100)>97)
		{
			ThisModel.skill25 += 150;	//reduce counter
		}
		ThisModel.x += xv;
		ThisModel.y += yv;
		ThisModel.z += zv - (ThisModel.skill27/8);
		ThisModel.skill27 += 1;
		if (ThisModel.skill25>ThisModel.skill26)
		{
			ThisModel.scale_x = (ThisModel.skill25 * ThisModel.skill25)/14000;
			ThisModel.scale_y = (ThisModel.skill25 * ThisModel.skill25)/14000;
		}
		
		if (ThisModel.skill25<10)
		{
			ThisModel.alpha = ThisModel.skill25*0.01;
		}
		
	}
	ent_remove(ThisModel);		//remove timed-out model
	num_box -= 1;
}
 
function new_sprite(var xpos, var ypos, var zpos)
{
	c1 = 0;
	while (c1<15)
	{
		c1 += 1;
		box my_box;
		my_box.model = ent_create("bluspark.bmp",vector(xpos,ypos,zpos),NULL);
		my_box.model.skill25 = 200+random(500);
		//my_box.model.pan = 180 - angle1;
		my_box.model.scale_x = 1.925;
		my_box.model.scale_y = 1.925;
		my_box.model.roll = 1;
		my_box.velx = (random(25)-12.5)/2;
		my_box.vely = (random(25)-12.5)/2;
		my_box.velz = (-5+random(25))*5;
		my_box.model.skill26 = 180 - random(100);
		set(my_box.model,BRIGHT|OVERLAY|TRANSLUCENT|PASSABLE);
		my_box.model.alpha = 50;
		do_sprite(my_box.model,my_box.velx,my_box.vely,my_box.velz);
		//my_box.model.scale_z = 10.925;
		my_box.lifetime = 100;
		num_box += 1;
	}
}

function do_bomb(ENTITY* ThisModel)
{
	while(ThisModel.skill25>0)
	{
		ThisModel.skill25 -= 2;	//reduce counter	
		wait(1);			//wait 1 frame		
	}
	new_sprite(ThisModel.x,ThisModel.y,ThisModel.z);
	ent_remove(ThisModel);		//remove timed-out model
	num_box -= 1;
}

function new_bomb()
{
	box my_box;
	my_box.model = ent_create("cube_smaller.x",vector(0,0,0),NULL);
	my_box.model.x = 0;
	my_box.model.y = 0;
	my_box.model.z = 800;
	my_box.model.scale_x = 16.925;
	my_box.model.scale_y = 16.925;
	my_box.model.scale_z = 16.925;
	my_box.model.skill25 = 500 + random(1000);
	c_setminmax(my_box.model);
	wait(1);
	phent_settype (my_box.model, PH_RIGID, PH_SPHERE); // set the physics entity type
	phent_setmass (my_box.model, 200, PH_SPHERE); // and its mass
	phent_setfriction (my_box.model, 68); // set the friction
	phent_setdamping (my_box.model, 5, 5); // set the damping
	phent_setelasticity (my_box.model, 62, 12); // set the elasticity
	dampener = 0.285;
	phent_addvelglobal(my_box.model, vector((-50+random(100))*dampener,(-50+random(100))*dampener,(-5+random(10))*dampener), vector(100,0,0) );
	do_bomb(my_box.model);
	//wait(1);	
}

function main()
{
	video_mode=9;
	fps_max = 60;
	max_entities = 15000;
	max_nexus = 100000;
	level_load("");
	vec_set(screen_color,vector(0,0,0));
	wait(1);
	ph_setautodisable(0.00001, 0.0002, 4, 41); // turn on and set default values
	camera.ambient = -92; 
	FLOOR = ent_create ("plain3d1.x", vector(-400, 0, -4800), NULL); // create the floor
	set(FLOOR,LIGHT);
	camera.x = 5500;
	camera.y = 20;
	camera.z = 250;
	camera.arc = 110;
	camera.pan = 180;
	FLOOR.scale_x=5000;
	FLOOR.scale_y=5000;
	FLOOR.scale_z=30;
	FLOOR.z = -5;
	FLOOR.red = 0;
	FLOOR.green =0;
	FLOOR.blue =0;
	FLOOR.ambient = 25;
	FLOOR.z=-50;
	
	ph_setgravity (vector(0, 0, -886)); // set the gravity
	
	while (1)
	{
		new_ball_delay -= 1;

		
		// CONTROLS
		mouse_pos.x = mouse_cursor.x;
		mouse_pos.y = mouse_cursor.y;
		camera.pan -= mouse_force.x * 26;
		camera.tilt += mouse_force.y * 26;
		mouse_pos.x = 160;
		mouse_pos.y = 120;
		if (key_cuu) camera.x -= 52 * time_step; 
		if (key_cud) camera.x += 52 * time_step; 
		if (key_cul) camera.y += 52 * time_step;
		if (key_cur) camera.y -= 52 * time_step;	
		if (key_ins) camera.z -= 52 * time_step;
		if (key_del) camera.z += 52 * time_step;
		if (mouse_left)
		{
		   camera.ambient += 1;
 		   //bowling_ball();
 		}
		if (mouse_right)
  			  camera.ambient -= 1;
		if (key_e) 
		{
			if (new_ball_delay<0)
			{
			new_sprite(0,0,800);
			new_ball_delay = 1;
			}
		}
		if (random(100)>97)
		{
			new_bomb();
		}
	    //on_e = 
		wait(1);
	}
}




I am a noob to this... Blitz3D is where i am best at!
Re: More than 1000 entities = death for a game? [Re: CdeathJD] #227772
09/16/08 02:58
09/16/08 02:58
Joined: Aug 2008
Posts: 55
United Kingdom
CdeathJD Offline OP
Junior Member
CdeathJD  Offline OP
Junior Member

Joined: Aug 2008
Posts: 55
United Kingdom
I just thought, perhaps it is because each sprite is loaded from disk? It's the only thing i can think of! In Blitz3D i would use the "COPYENTITY" function to simply copy the already loaded entity from a reference object.

Could this be the case with this example?


I am a noob to this... Blitz3D is where i am best at!
Re: More than 1000 entities = death for a game? [Re: CdeathJD] #227778
09/16/08 05:05
09/16/08 05:05
Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Nidhogg Offline
Serious User
Nidhogg  Offline
Serious User

Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Ok I just had a quick looksee and I saw that you had wait(1) in wrong places.

Also wait(1) is supposed to before c_setminmax(my) not after.

Try adding the wait(1) at the end of the process, unless you ment
for them to be that way.

eg:
while(1)
{
do some stuff here
wait(1)
}

Hope this helps..
There is a physics demo getting around, on acknex resource site.
Also have a quick look in the physics forum, some good tips in there
as well.

Good luck..


Windows XP SP3
Intel Dual Core CPU: E5200 @ 2.5GHz
4.00GB DDR3 Ram
ASUS P5G41T-M LX
PCIE x16 GeForce GTS 450 1Gb
SB Audigy 4
Spyware Doctor with AntiVirus
Re: More than 1000 entities = death for a game? [Re: Nidhogg] #227876
09/16/08 15:49
09/16/08 15:49
Joined: Apr 2008
Posts: 594
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 594
Austria
When you have frame rate problems, the first thing is to find out WHY you have those problems. Press F11 and check the render time display: that will tell you what the problem is.

After that the next step is making a plan how to fix that.

1000 particles are nothing for A7, they wont have noticeable impact on the frame rate. But 1000 physics entities are certainly a different matter.

Re: More than 1000 entities = death for a game? [Re: Nidhogg] #227890
09/16/08 17:55
09/16/08 17:55
Joined: Aug 2008
Posts: 55
United Kingdom
CdeathJD Offline OP
Junior Member
CdeathJD  Offline OP
Junior Member

Joined: Aug 2008
Posts: 55
United Kingdom
Originally Posted By: Nidhogg
Ok I just had a quick looksee and I saw that you had wait(1) in wrong places.

Also wait(1) is supposed to before c_setminmax(my) not after.

Try adding the wait(1) at the end of the process, unless you ment
for them to be that way.

eg:
while(1)
{
do some stuff here
wait(1)
}

Hope this helps..
There is a physics demo getting around, on acknex resource site.
Also have a quick look in the physics forum, some good tips in there
as well.

Good luck..



Which function is that in?


I am a noob to this... Blitz3D is where i am best at!
Re: More than 1000 entities = death for a game? [Re: Petra] #227891
09/16/08 17:57
09/16/08 17:57
Joined: Aug 2008
Posts: 55
United Kingdom
CdeathJD Offline OP
Junior Member
CdeathJD  Offline OP
Junior Member

Joined: Aug 2008
Posts: 55
United Kingdom
Originally Posted By: Petra
When you have frame rate problems, the first thing is to find out WHY you have those problems. Press F11 and check the render time display: that will tell you what the problem is.

After that the next step is making a plan how to fix that.

1000 particles are nothing for A7, they wont have noticeable impact on the frame rate. But 1000 physics entities are certainly a different matter.


There are only at max 20 physics entities! Not 1000!

It seems i cant get past 1000 (particles) without very significant slowdown though.


I am a noob to this... Blitz3D is where i am best at!
Re: More than 1000 entities = death for a game? [Re: CdeathJD] #227936
09/16/08 21:55
09/16/08 21:55
Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Nidhogg Offline
Serious User
Nidhogg  Offline
Serious User

Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Ok I put the wait statements where I think they should be...
Changed x to mdl, don't know if this was your problem as it looked
like you where trying to load microsoft.x models instead of 3DGS mdl
format..

Compare this code to your old..
My system kept at 60 framerate np.
Kept getting a invalid argument error in entity after every 2 secs..


Hope this will help..

Code:
#include <acknex.h>
#include <default.c>

ENTITY* FLOOR;

VECTOR box_rotation;
VECTOR centre = vector(0,0,0);

var dampener;
var c1;  
var num_box;
var new_ball_delay;
var iveruntheIamFlyfunk;
STRING* num_box_string;

d3d_alpharef = 180;

typedef struct
{
	var velx;
	var vely;
	var velz;
	var lifetime;
	ENTITY* model;
} box; 

PANEL* panDisplay =
{
	digits(35, 10, "smokes = %0.f", *, 1, num_box);
	flags = VISIBLE;
}


function do_sprite(ENTITY* ThisModel,var xv,var yv,var zv)
{
	while(ThisModel.skill25>0)
	{
		//wait(1);			//wait 1 frame
		ThisModel.skill25 -= 15;	//reduce counter
		if (random(100)>97)
		{
			ThisModel.skill25 += 150;	//reduce counter
		}
		ThisModel.x += xv;
		ThisModel.y += yv;
		ThisModel.z += zv - (ThisModel.skill27/8);
		ThisModel.skill27 += 1;
		if (ThisModel.skill25>ThisModel.skill26)
		{
			ThisModel.scale_x = (ThisModel.skill25 * ThisModel.skill25)/14000;
			ThisModel.scale_y = (ThisModel.skill25 * ThisModel.skill25)/14000;
		}
		
		if (ThisModel.skill25<10)
		{
			ThisModel.alpha = ThisModel.skill25*0.01;
		}
		wait(1);
		
	}
	ent_remove(ThisModel);		//remove timed-out model
	num_box -= 1;
}
 
function new_sprite(var xpos, var ypos, var zpos)
{
	c1 = 0;
	while (c1<15)
	{
		c1 += 1;
		box my_box;
		my_box.model = ent_create("bluspark.bmp",vector(xpos,ypos,zpos),NULL);
		my_box.model.skill25 = 200+random(500);
		//my_box.model.pan = 180 - angle1;
		my_box.model.scale_x = 1.925;
		my_box.model.scale_y = 1.925;
		wait(1);
		c_setminmax(my);
		my_box.model.roll = 1;
		my_box.velx = (random(25)-12.5)/2;
		my_box.vely = (random(25)-12.5)/2;
		my_box.velz = (-5+random(25))*5;
		my_box.model.skill26 = 180 - random(100);
		set(my_box.model,BRIGHT|OVERLAY|TRANSLUCENT|PASSABLE);
		my_box.model.alpha = 50;
		do_sprite(my_box.model,my_box.velx,my_box.vely,my_box.velz);
		//my_box.model.scale_z = 10.925;
		my_box.lifetime = 100;
		num_box += 1;
		wait(1);
	}
}

function do_bomb(ENTITY* ThisModel)
{
	while(ThisModel.skill25>0)
	{
		ThisModel.skill25 -= 2;	//reduce counter	
		wait(1);			//wait 1 frame		
	}
	new_sprite(ThisModel.x,ThisModel.y,ThisModel.z);
	ent_remove(ThisModel);		//remove timed-out model
	num_box -= 1;
}

function new_bomb()
{
	box my_box;
	my_box.model = ent_create("cube_smaller.mdl",vector(0,0,0),NULL);
	my_box.model.x = 0;
	my_box.model.y = 0;
	my_box.model.z = 800;
	my_box.model.scale_x = 16.925;
	my_box.model.scale_y = 16.925;
	my_box.model.scale_z = 16.925;
	my_box.model.skill25 = 500 + random(1000);
	wait(1);
	c_setminmax(my_box.model);
	//wait(1);
	phent_settype (my_box.model, PH_RIGID, PH_SPHERE); // set the physics entity type
	phent_setmass (my_box.model, 200, PH_SPHERE); // and its mass
	phent_setfriction (my_box.model, 68); // set the friction
	phent_setdamping (my_box.model, 5, 5); // set the damping
	phent_setelasticity (my_box.model, 62, 12); // set the elasticity
	dampener = 0.285;
	phent_addvelglobal(my_box.model, vector((-50+random(100))*dampener,(-50+random(100))*dampener,(-5+random(10))*dampener), vector(100,0,0) );
	do_bomb(my_box.model);
	//wait(1);	
}

function main()
{
	video_mode=9;
	fps_max = 60;
	max_entities = 15000;
	max_nexus = 100000;
	level_load("");
	vec_set(screen_color,vector(0,0,0));
	wait(1);
	ph_setautodisable(0.00001, 0.0002, 4, 41); // turn on and set default values
	camera.ambient = -92; 
	FLOOR = ent_create ("plain3d1.mdl", vector(-400, 0, -4800), NULL); // create the floor
	set(FLOOR,LIGHT);
	camera.x = 5500;
	camera.y = 20;
	camera.z = 250;
	camera.arc = 110;
	camera.pan = 180;
	FLOOR.scale_x=5000;
	FLOOR.scale_y=5000;
	FLOOR.scale_z=30;
	FLOOR.z = -5;
	FLOOR.red = 0;
	FLOOR.green =0;
	FLOOR.blue =0;
	FLOOR.ambient = 25;
	FLOOR.z=-50;
	
	ph_setgravity (vector(0, 0, -886)); // set the gravity
	
	while (1)
	{
		new_ball_delay -= 1;

		
		// CONTROLS
		mouse_pos.x = mouse_cursor.x;
		mouse_pos.y = mouse_cursor.y;
		camera.pan -= mouse_force.x * 26;
		camera.tilt += mouse_force.y * 26;
		mouse_pos.x = 160;
		mouse_pos.y = 120;
		if (key_cuu) camera.x -= 52 * time_step; 
		if (key_cud) camera.x += 52 * time_step; 
		if (key_cul) camera.y += 52 * time_step;
		if (key_cur) camera.y -= 52 * time_step;	
		if (key_ins) camera.z -= 52 * time_step;
		if (key_del) camera.z += 52 * time_step;
		if (mouse_left)
		{
		   camera.ambient += 1;
 		   //bowling_ball();
 		}
		if (mouse_right)
  			  camera.ambient -= 1;
		if (key_e) 
		{
			if (new_ball_delay<0)
			{
			new_sprite(0,0,800);
			new_ball_delay = 1;
			}
		}
		if (random(100)>97)
		{
			new_bomb();
		}
	    //on_e = 
		wait(1);
	}
}



Windows XP SP3
Intel Dual Core CPU: E5200 @ 2.5GHz
4.00GB DDR3 Ram
ASUS P5G41T-M LX
PCIE x16 GeForce GTS 450 1Gb
SB Audigy 4
Spyware Doctor with AntiVirus
Re: More than 1000 entities = death for a game? [Re: Nidhogg] #227938
09/16/08 22:03
09/16/08 22:03
Joined: Aug 2008
Posts: 55
United Kingdom
CdeathJD Offline OP
Junior Member
CdeathJD  Offline OP
Junior Member

Joined: Aug 2008
Posts: 55
United Kingdom
Sorry, but its not working!

When sprites are supposed to be made its just errors with:

ERROR E1515
Invalid arguments in new_sprite:ENTITY

This happens all the time, not every few seconds!

Last edited by CdeathJD; 09/16/08 22:04.

I am a noob to this... Blitz3D is where i am best at!
Page 1 of 3 1 2 3

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | 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