How to decrease the nexus after using ent_remove?

Posted By: Geist

How to decrease the nexus after using ent_remove? - 06/19/13 08:27

Hi,
I've been looking through related topics but there was no one fitting with my issue: I tried to generate a landscape at runtime using a chunks of tile-like entities and deforming them with the vertex functions. Once I remove an entity group (but keeping the entity pointer array) and re-create it after a while (depending on camera movement) the nexus hits implausible 2277 MB. As I create a new entity chunk the nexus reaches impossible dimensions of around 14361 MB.

I unsuccesfully tried to solve the problem using functions like level_free, ent_purge, sys_free as I thought it had something to do with the entity data that remains in cache after removing.. Do you have a solution for this?

Kind regards,
Geist
Posted By: Superku

Re: How to decrease the nexus after using ent_remove? - 06/20/13 09:36

Post more information! Are you using ent_create + ent_clone (a lot)? ent_clone has many limitations (such as increasing memory), check them in the manual and the forum.
AFAIK you cannot decrease the nexus size manually.
Posted By: Geist

Re: How to decrease the nexus after using ent_remove? - 06/20/13 10:47

I use a large entity array with this dimension ENTITY* ent[16][16][3][3];
As I use terrains there is no need for ent_clone before the vertex deformation. I tried both, deforming vertices on models with ent_clone and deforming them on terrains without ent_clone(which is the faster solution).
One Chunk has the size of 3 * 3 = 9 tiles. There are 9 Chunks loaded in the level, so there is a permanent amount of at least 81 terrain entities. All of these terrains are deformed with ent_setvertex.
Posted By: Anonymous

Re: How to decrease the nexus after using ent_remove? - 06/20/13 16:35

Quote:
I use a large entity array with this dimension ENTITY* ent[16][16][3][3];


I didn't think you could use a array of entity pointers like this. But I don't know for sure. You might be better using one array of pointers ENTITY* ent[16]; and another array for what ever data is in the rest. var ent_data[16][3][3]; But I am wildly guessing here. My question is what data is inside the other 3 dimension of this pointer array ?
Posted By: Geist

Re: How to decrease the nexus after using ent_remove? - 06/20/13 18:06

It worked quite fine, even for larger dimensions (such as [32][32][10][10]) but since I implemented the chunk limitation (which uses ent_remove) I get these nexus memory difficulties.
The 4 array dimensions were easy to manage when controlling the chunks and tiles: [ChunkCoordinateX]CunkCoordinateY][TileCoordinateX][TileCoordinateY]
But you made me aware of this beeing not efficient at all, as there are not more than 16 chunks á 9 tiles created at any time. So I try it with an one dimensional array. Thanks!
Posted By: Geist

Re: How to decrease the nexus after using ent_remove? - 06/20/13 18:19

I changed the Entity array to an one dimensional but I still get those nexus complications. That's gonna be a long weekend of bug research..
Btw. I have a ATI graphics card, does this matter?
Posted By: txesmi

Re: How to decrease the nexus after using ent_remove? - 06/20/13 18:49

This is a recursive topic with no clear answer by the moment. The dimension amount of the array has nothing to do with the nexus problem. Anyway, I can't understand the need of the secondary division, since a terrain area is bidimensional you only need two dimensions in your array.

How do you hide and show the visible chunks? Creating and removing entity terrains? If so, I would suggest you recycling the removed one.
Posted By: Anonymous

Re: How to decrease the nexus after using ent_remove? - 06/20/13 18:50

Quote:
The 4 array dimensions were easy to manage when controlling the chunks and tiles: [ChunkCoordinateX]CunkCoordinateY][TileCoordinateX][TileCoordinateY]


btw the first array value is not [chunkCoordinateX] but instead the pointer to the ENTITY* .

Or am I wrong ENTITY* ent[x]; ent[x] = pointer to ent.

EDIT* EDIT again because some of it was pointless
Code:
#define MAX_CHUCNKST 16
ENTITY* terrain_tiles[MAX_CHUNCKST];
var tiles = 0;

function a()
{
    if(tiles < MAX_CHUNKST)
    terrin_tile[tiles] = ent_create(....);
    tile +=1;
    array[tile-1][0] = terrain_tiles[tile-1]->x;
    array[tile-1][1] = terrain_tiles[tile-1]->y;;
    array[tile-1][2] = some more data
    array[tile-1][3] = even more data
}



I might not have a good idea how to use an array like that.. I stop posting with unhelpful confusion.

Posted By: txesmi

Re: How to decrease the nexus after using ent_remove? - 06/20/13 20:13

@Malice
Every member of an multidimensional pointers array is a pointer of the same type.
Code:
ENTITY *array[x]; // or...
ENTITY **array = (ENTITY**)sys_malloc ( sizeof(ENTITY*) * x );
array[a] == *(array+a)

ENTITY *array[x][y][z]; // or...
ENTITY **array = (ENTITY**)sys_malloc ( sizeof(ENTITY*) * z * y * x );
array[a][b][c] == *(array+(a*y*z)+(b*z)+c)
array[a][b][c] == *(array+((a*y)+b)*z)+c)

Posted By: Geist

Re: How to decrease the nexus after using ent_remove? - 06/20/13 20:38

Originally Posted By: Malice
Quote:
The 4 array dimensions were easy to manage when controlling the chunks and tiles: [ChunkCoordinateX]CunkCoordinateY][TileCoordinateX][TileCoordinateY]

btw the first array value is not [chunkCoordinateX] but instead the pointer to the ENTITY* .
[..]

I might not have a good idea how to use an array like that.. I stop posting with unhelpful confusion.


I tend to use it like this:
Code:
WorldPackSoilEntity[InputCoorX][InputCoorY][iSoilCoorX][iSoilCoorY] = 
ent_create("soil.hmp",
vector(WorldPackSoilData[InputCoorX][InputCoorY][iSoilCoorX][iSoilCoorY][getPositionX],
WorldPackSoilData[InputCoorX][InputCoorY][iSoilCoorX][iSoilCoorY][getPositionY],
4),0);


But it seems to be unefficient / redundant memory allocation(?) so I switch to a one dimensional array.

Originally Posted By: txesmi
Anyway, I can't understand the need of the secondary division, since a terrain area is bidimensional you only need two dimensions in your array.

Since I need a few but regular connections to the "underworld" underneath the landscape I have to bundle many small terrains to a group - a group of terrains makes a chunk.
Each Tile(terrain) has a idividual height value; each terrain is deformed depending on its surrounding terrains.

How do you hide and show the visible chunks? Creating and removing entity terrains? If so, I would suggest you recycling the removed one. [/quote]
Yes, thanks, recycling sounds nice to me, therefore I wouldnt need 4 dimensional arrays(Only 1)!

Thanks for you input wink
Regards,
Geist

EDIT: The rapdily increasing nexus and video memory was caused due to the fact that I used terrains. I've ported the basics to models and it worked fine with good fps. Everytime you delete a terrain but keep the pointer and then create a new terrain in the pointer the nexus will increase for some reason..
Thank you for your help, think it's solved so far grin
Posted By: txesmi

Re: How to decrease the nexus after using ent_remove? - 06/21/13 09:34

Fine to hear that you find a workaround laugh

You can get a clever code using data structs. I would use a bidimensional array of a data struct that represents the minimum ground hole size:

Code:
typedef struct SOILDATA
{
   var pos_x;
   var pos_y;
   var pos_z;
   var height;
   ENTITY *mesh;
} SOILDATA;

SOILDATA soilData[GRID_SIZE][GRID_SIZE];
...
SOILDATA *soilTemp = &soilData[coorX][coorY];
ENTITY *entity = ent_create ( "soil.hmp", soilTemp.pos_x, NULL );
soilTemp.mesh = entity;
entity.skill1 = (SOILDATA*)soilTemp;
...
SOILDATA *entSoilData = (SOILDATA*)actualSoilEntity.skill1;


© 2024 lite-C Forums