Forum

strange bug ?

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

strange bug ?

Postby revelator » Sun Jan 03, 2010 12:58 pm

ive been working a bit on the culling in realm wanted to make a uniform system but i ran into some problems.

Code: Select all
void R_VisCullEntities (void)
{
   int         i;
   entity_t   *ent;

   if (!r_drawentities.value) return;

   ent->occluded = false;

   for (i = 0; i < cl_numvisedicts; i++)
   {
      // store current entity
      ent = cl_visedicts[i];
 
      // not an alias model (sprite checks are skipped)
      if (ent->model->type != mod_alias) continue;

      // get entity origin
      VectorAdd (ent->origin, ent->model->mins, ent->mins);
      VectorAdd (ent->origin, ent->model->maxs, ent->maxs);

      // approximate the correct leaf for the entity in order to properly set fog and caustics.
      // this isn't 100% accurate (no method ever could be unless we use water surfs as clipping
      // planes) but it suffices pretty good for id1
      ent->modelleaf = R_LeafForEntity (ent->mins, ent->maxs);

      // adjust the bounding box if the model has been rotated
      if (ent->angles[0] || ent->angles[1] || ent->angles[2])
      {
         // mark as occluded if the sphere is outside the frustum so that it wont have to be tested again
         ent->occluded = R_CullSphere (ent->origin, ent->model->radius);
      }
      else
      {
         // mark as occluded if the box is outside the frustum so that it wont have to be tested again
         ent->occluded = R_CullBox (ent->mins, ent->maxs);
      }
   }
}


mh might notice where i pulled in these from. the problem im facing is that it pushes the viewent outside of the frustum in some odd angles the gun dissapears at other angles particle effects go boom
and to top it off sometimes the ground dissapears :lol:

not sure what gives i took great care calling this function before any rendering was done any ideas ?
User avatar
revelator
 
Posts: 2567
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Postby metlslime » Sun Jan 03, 2010 10:34 pm

first of all,

Code: Select all
ent->occluded = false;


is being called before ent is even initialized. Did you mean to put this line inside the loop?
metlslime
 
Posts: 316
Joined: Tue Feb 05, 2008 11:03 pm

Postby revelator » Mon Jan 04, 2010 5:16 am

added as an afterthought originally didnt have that cause the boolean value of the bounding box check can only be true/false.

and yes it actually made it worse so i removed it again.

its still not right though :(

maybe i should let someone have a look at the entire thing its pretty hard to post all the changes i made considering the numerous changes mh made before my messing around.

i did add in the sphere culling from tochris (might be that) ill try to disable it. the weird thing is in its original form it actually worked but was a mess.
User avatar
revelator
 
Posts: 2567
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger


Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest