2 registered members (TipmyPip, AndrewAMD),
1,151
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
view_check() rerturns incorrect results
#358218
02/09/11 22:52
02/09/11 22:52
|
Joined: Feb 2011
Posts: 135
Myrkling
OP
Member
|
OP
Member
Joined: Feb 2011
Posts: 135
|
Remark: This is a bug report. As I wasn't able to create a new thread in the Bug Hunt forums, I posted this here instead. Perhaps someone could be so kind to move this thread to the right place. Thanks.In certain circumstances view_check() returns incorrect results for both bounding boxes and points (A8.10.1). The following example demonstrates the issue (you have to fly around a little bit). Depending on the camera's position and angle view_check() returns 0, even though the box/point is inside the view frustum completely.
#include <acknex.h>
#include <default.c>
#define PRAGMA_PATH "%EXE_DIR%\templates\models";
void main()
{
level_load(NULL);
ent_create("sf_alien.mdl", vector(90,90,0), NULL);
ent_create("sf_alien.mdl", NULLVECTOR, NULL);
wait(2);
while (1)
{
draw_box3d(vector(-16,-16,-16), vector(16,16,16), COLOR_GREEN, 100);
if (view_check(camera,vector(-16,-16,-16),vector(16,16,16)) != 0) {
draw_text("IN VIEW",100,50, COLOR_GREEN);
}
draw_point3d(vector(0,-128,0), COLOR_RED, 100, 1);
if (view_check(camera,vector(0,-128,0),vector(0,-128,0)) != 0) {
draw_text("IN VIEW",100,80, COLOR_RED);
}
wait(1);
}
}
PS, as far as I can tell the problem doesn't occur in empty levels.
|
|
|
Re: view_check() rerturns incorrect results
[Re: Myrkling]
#358632
02/12/11 14:57
02/12/11 14:57
|
Joined: Oct 2004
Posts: 900 Lgh
rojart
User
|
User
Joined: Oct 2004
Posts: 900
Lgh
|
I checked your code and I came to the conclusion, that the view_check don't returns 2 as in my example. I've mentioned this in the beta thread, too.
#include <default.c>
STRING* sDrawTxt1;
STRING* sDrawTxt2;
void uu1ViewCheck(){
switch(uu1){
case 0:
sDrawTxt1="0 - Box is fully outside the view frustum.";
break;
case 1:
sDrawTxt1="1 - Box is partially inside the view frustum.";
break;
case 2:
sDrawTxt1="2 - Box is fully inside the view frustum.";
break;
}
}
void uu2ViewCheck(){
switch(uu2){
case 0:
sDrawTxt2="0 - Point is fully outside the view frustum.";
break;
case 1:
sDrawTxt2="1 - Point is partially inside the view frustum.";
break;
case 2:
sDrawTxt2="2 - Point is fully inside the view frustum.";
break;
}
}
void main()
{
video_aspect = 4./3.;
level_load(0);
wait(2);
vec_set(camera.x,vector(0,0,10));
vec_set(camera.pan,vector(-10,-20,0));
camera.clip_near = 1;
camera.clip_far = 60;
camera.arc = 90;
def_debug();
int i=2;
while (1){
uu1ViewCheck();uu2ViewCheck();
draw_box3d(vector(-4,-4,-4), vector(4,4,4), COLOR_GREEN, 100);
draw_point3d(vector(0,-30,0), COLOR_RED, 100, 1);
if(uu1 = view_check(camera,vector(-4,-4,-4),vector(4,4,4))){}
draw_text(sDrawTxt1,5,120, COLOR_GREEN);
if(uu2 = view_check(camera,vector(0,-30,0),vector(0,-30,0))){}
draw_text(sDrawTxt2,5,140, COLOR_RED);
if(camera.x <= -90) i=-2;
if(camera.x >= 30) i= 2;
camera.x -= i * time_step;
camera.x = clamp (camera.x,-90,30);
wait(1);
}
}
|
|
|
Re: view_check() rerturns incorrect results
[Re: Benni003]
#438886
03/22/14 21:22
03/22/14 21:22
|
Joined: Aug 2008
Posts: 394 Germany
Benni003
Senior Member
|
Senior Member
Joined: Aug 2008
Posts: 394
Germany
|
Ich habe doch tatsächlich eine Möglichkeit gefunden, diesen Bug zu umgehen Die Funktion, die view_check() enthält einfach aufrufen, bevor irgendeine Entity gerendert wurde.: render_sky = f_view_check;
|
|
|
|