Visible entities higher than created entities?

Posted By: Walori

Visible entities higher than created entities? - 08/21/11 16:24

Picture says it all:


What I'm missing here? Creating an entity creates 2 visible entities? There is nothing special in entity creation itself. The entity is created runtime and its pointed to structure then. c_mimax called for each entity. Flags I'm using are(is) UNLIT, nothing more. Their material's are changed every 1 second if needed and are not dynamic. There is only one sky entity.

Tried with simple code that creates 100 cubes and it didn't occur there. What could cause this? Any thoughts appreceated.
Posted By: Aku_Aku

Re: Visible entities higher than created entities? - 08/21/11 17:43

I don't know this handy magic spell.
Please provide the code i would really appreciate that.
Posted By: Anonymous

Re: Visible entities higher than created entities? - 08/22/11 06:11

its probably the sky entity.
Try to remove it for testing, then the "ent" and "vis" should be the same.
Posted By: Asgadir

Re: Visible entities higher than created entities? - 08/22/11 07:22

Here the same. ent 16, vis 52. Strange...
Posted By: rojart

Re: Visible entities higher than created entities? - 08/22/11 09:07

Hmm, You use the older A7.862 version, try to A7.866 patch it here.
But anyway better is to testing with the newer A8.2 version from here.
Posted By: bart_the_13th

Re: Visible entities higher than created entities? - 08/22/11 10:12

could be caused by another view...
Do you accidentally include any postprocessing effect? I know that free version can't use shader, but it does can create another view
Posted By: Walori

Re: Visible entities higher than created entities? - 08/22/11 18:29

Quote:

its probably the sky entity.
Try to remove it for testing, then the "ent" and "vis" should be the same.

Tried to remove, no change.

Quote:

Hmm, You use the older A7.862 version, try to A7.866 patch it here.
But anyway better is to testing with the newer A8.2 version from here.

Happens in both versions, 8.20 and 7.86

Quote:

could be caused by another view...
Do you accidentally include any postprocessing effect? I know that free version can't use shader, but it does can create another view

Nope, I'm only attaching materials to entities. And removing those materials doesn't fix it.

Below the crucial codes:

Entity creation
Code:
ACTOR[id]->entity = ent_create(ACTOR[id]->mesh,vector(ACTOR[id]->x,ACTOR[id]->y,ACTOR[id]->z),NULL);
		ACTOR[id]->entity->scale_x = ACTOR[id]->scale.x;
		ACTOR[id]->entity->scale_y = ACTOR[id]->scale.y;
		ACTOR[id]->entity->scale_z = ACTOR[id]->scale.z;
		ACTOR[id]->entity->pan = ACTOR[id]->pan;
		ACTOR[id]->entity->tilt = ACTOR[id]->tilt;
		ACTOR[id]->entity->roll = ACTOR[id]->roll;
		ACTOR[id]->entity->flags |= SHADOW|UNLIT|CAST;
		wait(1);
		c_setminmax(ACTOR[id]->entity);
		ACTOR[id]->entity->skill1 = id;
		ACTOR[id]->entity->skill2 = 1;
		ACTOR[id]->entity->skill3 = ACTOR[id];



Material assigment function
Code:
ENTITY* ent = NULL;
	while(1)
	{
		ent = ent_next(NULL);
		while(ent)
		{
			if(ent != ent_select && ent.skill3 != NULL)
			{
				if(ent.skill2 < 3 ||ent.skill2 == 4)
				{
					if(ent_type(ent) != 4)ent.material = NULL;
					else ent.material = mtl_terraintex;
				}
				else if(ent.skill2 == 3) ent.material = NULL;
				else if(ent.skill2 == 5) ent.material = NULL ;
				else ent.material =NULL;
				
				ent.emask &=~DYNAMIC;
				ent.flags &=~LIGHT;
			}
			else 	if(ent == ent_select)
			{
				ent.material = mtl_red;
				ent.emask |=DYNAMIC;
				ent.flags |=LIGHT;
			}
			ent = ent_next(ent);
		}
		
		if(ent_select)
		{
			if(win_ent.pos_x == -1110)
			{
				win_edit_ent.pos_x =  0;
				win_ent.pos_x = screen_size.x-300;
				LBG_update_window(win_ent);
				LBG_update_window(win_edit_ent);
			}
			if(!key_ctrl && mouse_panel)
			{		
				UpdateModelFrom();
			}
		}
		else
		{
			lock_select = 0;
			if(win_ent.pos_x != -1110)
			{
				win_edit_ent.pos_x = -1110;
				win_ent.pos_x = -1110;
				LBG_update_window(win_ent);
				LBG_update_window(win_edit_ent);
			}
		}
		wait(-0.5);
	}



The struct that's linked to entity:
Code:
typedef struct MODEL
{
	var id;
	var flags;
	var use_billboard;
	VECTOR scale;
	var x;
	var y;
	var z;
	VECTOR size;
	var pan;
	var tilt;
	var roll;
	var ambient;
	var red;
	var blue;
	var green;
	var lightrange;
	STRING* mesh;
	ENTITY* entity;
}MODEL;


Posted By: Walori

Re: Visible entities higher than created entities? - 08/30/11 07:22

Any thoughts about this? The weird thing is, when I remove the entity/model wit this function:
Code:
function DeleteModel(MODEL* model)
{
	if(!model)return 0;

	if(model->entity)
	{
		switch(model->entity.skill2)
		{
			case 1:
			ACTOR[model->entity.skill1] = NULL;
			actor_count--;
			break;
			
			case 2:
			MAP_TERRAIN[model->entity.skill1] = NULL;
			terrain_count--;
			break;
			
			case 3:
			ALIGHT[model->entity.skill1] = NULL;
			light_count--;
			break;
			
			case 4:
			PORTAL[model->entity.skill1] = NULL;
			portal_count--;
			break;
			
			case 5:
			WATER[model->entity.skill1] = NULL;
			water_count--;
			break;
		}
		ptr_remove(model->entity);
	}
	model_count--;
	if(model->mesh)ptr_remove(model->mesh);

	memset(model,0,sizeof(MODEL));
	free(model);
	return 1;
}


The entity is deleted as should, however the visible entities also decrease by two.
Posted By: JibbSmart

Re: Visible entities higher than created entities? - 08/30/11 13:29

As bart said, this is something that would be caused by having another view. However, I don't think a pp-view would do it.

Do a search for "VIEW" and tell us how many you've got going.

Jibb
© 2024 lite-C Forums