Jump to content

Map generation and instancing


VeTaL
 Share

Recommended Posts

I noted that i have too little fps on the map with 30-40 wall models, the same number of tower models and 10-20 house models (in summary, about 100 entities).

 

On the other hand, i remember my playing with instancing and also i remember post on this forum with 500K cubes.

 

So, lets see: first, i procedurally generate map, and then i need to generate SBX file by my hands so i would be able to load level in editor or game. So the question is: how engine knows that this object (that is loading now) is instanced or not? I see two ways:

1)

- while saving map into SBX, Editor puts in order models with the same name

- while LoadMap, engine looks at the name of previous entity (because they are already categorized by name) and make CopyEntity if the names are the same

 

2)

- engine just have list of all entities and while it loads new one, it checked by that list, and if entity already exists, it makes CopyEntity, if not - creates new one.

 

So, generated file looking like this:

Model {
path="tower.gmf"
position=35.75,0,35.75
rotation=0,0,0
scale=1,1,1
id=22979576
"class"="Model"
"collisiontype"="2"
"intensity"="1.0000000000000000"
"name"="GeneratedModel_0"
}

Model {
path="wall_large.gmf"
position=30.25,0,35.75
rotation=0,0,0
scale=1,1,1
id=22979576
"class"="Model"
"collisiontype"="2"
"intensity"="1.0000000000000000"
"name"="GeneratedModel_1"
}

Model {
path="tower.gmf"
position=24.75,0,35.75
rotation=0,0,0
scale=1,1,1
id=22979576
"class"="Model"
"collisiontype"="2"
"intensity"="1.0000000000000000"
"name"="GeneratedModel_2"
}

Model {
path="wall_large.gmf"
position=19.25,0,35.75
rotation=0,0,0
scale=1,1,1
id=22979576
"class"="Model"
"collisiontype"="2"
"intensity"="1.0000000000000000"
"name"="GeneratedModel_3"
}

Model {
path="tower.gmf"
position=13.75,0,35.75
rotation=0,0,0
scale=1,1,1
id=22979576
"class"="Model"
"collisiontype"="2"
"intensity"="1.0000000000000000"
"name"="GeneratedModel_4"
}

 

Do i need to group it like "tower", "tower", "tower", "wall", "wall", "wall" for enabling instancing?

Working on LeaFAQ :)

Link to comment
Share on other sites

Okay, just tested:

 

for (int i=0; i<100; i+=1)
{
	for (int j=0; j<100; j+=1)
	{
		// instancing
		cube = CopyEntity(cube);  			

		//// non-instancing
		//cube = CreateCube();

		PositionEntity(cube, Vec3(i*2,0,j*2));

		PaintEntity(cube, mat);
	}
}

CopyEntity() works fast enough

CreateCube() very slooow

LoadModel() also fast

Working on LeaFAQ :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...