problem with rel_for_screen in A8.30.3, maybe bug?

Posted By: Iglarion

problem with rel_for_screen in A8.30.3, maybe bug? - 09/30/11 12:24

I have problems with difference betwen old and new engine version. In some situation with 8.30.3 rel_for_screen and vec_to_screen not work, and i thinking it's maybe a bug?

I made example where rel_for_screen work good in some previous version (tested in 8.03.2) but not in new beta:
Code:
ENTITY panel_ent {
	type = "test_panel.mdl";
	VIEW = camera;
	flags = visible;
	layer = 14;
	pan = 35; tilt = 15; roll = -10;
}

var panel_distance[2] = 200,200;
var panel_distance_y[2] = 0,0;

function handle_panels_startup {
	while (1) {
		temp.x = 20 * screen_size.x/800;
		temp.y = (20 + panel_distance_y[1]) * screen_size.y/600;
		temp.z = panel_distance[1];
		rel_for_screen(temp.x,camera);
		vec_set(panel_ent.x,temp.x);
		wait(1);
	}
}

Now i have almost good results when i change rel_for_screen to vec_for_screen.

There also problem with vec_to_screen. I have different result in last beta. Here example where i check did entity is visible on screen, but this now not work like before:
Code:
vec_set(temp.x,vector(my.x,my.y,my.z + 5));
vec_to_screen(temp.x,camera);
if (temp.x < screen_size.x + 100 && temp.y < screen_size.y + 50 && vec_dist(my.x,vector(camera.x,0,camera.z)) < 1500){


I wonder why this happen?
Posted By: Iglarion

Re: problem with rel_for_screen in A8.30.3, maybe bug? - 10/13/11 11:44

...i still wonder this is a bug or...?
Posted By: djfeeler

Re: problem with rel_for_screen in A8.30.3, maybe bug? - 10/13/11 12:40

Hello,

you forgot the * behind ENTITY and the =

the good code is

Code:
ENTITY* panel_ent = {
	type = "test_panel.mdl";
	view = camera;
	flags = SHOW;
	layer = 14;
	pan = 35; tilt = 15; roll = -10;
}

var panel_distance[2] = {200,200};
var panel_distance_y[2] = {0,0};

function handle_panels_startup() {
	
	VECTOR temp;
	while(1) 
	{
		temp.x = 20 * screen_size.x/800;
		temp.y = (20 + panel_distance_y[1]) * screen_size.y/600;
		temp.z = panel_distance[1];
		rel_for_screen(temp.x,camera);
		vec_set(panel_ent.x,temp.x);
		wait(1);
	}
}



Djfeeler
Posted By: jcl

Re: problem with rel_for_screen in A8.30.3, maybe bug? - 10/13/11 13:00

As to answer the first question: Yes, rel_for_screen indeed behaved differently in the last beta - this will be corrected. But vec_to_screen is ok - we've looked into it to be sure. For checking an entity visibility, use the return value of vec_to_screen. Your method can only work when the entity is on the screen, but not when it is out of the screen, as then the screen coordinates are not guaranteed to be valid.
Posted By: Iglarion

Re: problem with rel_for_screen in A8.30.3, maybe bug? - 10/13/11 13:02

Thank you JCL, you help me a lot, now i understand what is problem in vec_to screen and i will update my old code! Also great to know that i do not need change anything in rel_for_screen, i will wait new update smile .

Thanks a lot!!
© 2024 lite-C Forums