Пример #1
0
  /** R_RenderView r_newrefdef must be set before the first call */
  void R_RenderView(refdef_t fd) {

    if (r_norefresh.value != 0.0f) return;

    r_newrefdef = fd;

    // included by cwei
    if (r_newrefdef == null) {
      Com.Error(Defines.ERR_DROP, "R_RenderView: refdef_t fd is null");
    }

    if (r_worldmodel == null && (r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) == 0)
      Com.Error(Defines.ERR_DROP, "R_RenderView: NULL worldmodel");

    if (r_speeds.value != 0.0f) {
      c_brush_polys = 0;
      c_alias_polys = 0;
    }

    R_PushDlights();

    if (gl_finish.value != 0.0f) GL11.glFinish();

    R_SetupFrame();

    R_SetFrustum();

    R_SetupGL();

    R_MarkLeaves(); // done here so we know if we're in water

    R_DrawWorld();

    R_DrawEntitiesOnList();

    R_RenderDlights();

    R_DrawParticles();

    R_DrawAlphaSurfaces();

    R_Flash();

    if (r_speeds.value != 0.0f) {
      VID.Printf(
          Defines.PRINT_ALL,
          "%4i wpoly %4i epoly %i tex %i lmaps\n",
          new Vargs(4)
              .add(c_brush_polys)
              .add(c_alias_polys)
              .add(c_visible_textures)
              .add(c_visible_lightmaps));
    }
  }
Пример #2
0
  /** Runs thinking code for this frame if necessary. */
  public static boolean SV_RunThink(edict_t ent) {
    float thinktime;

    thinktime = ent.nextthink;
    if (thinktime <= 0) return true;
    if (thinktime > GameBase.level.time + 0.001) return true;

    ent.nextthink = 0;

    if (ent.think == null) Com.Error(Defines.ERR_FATAL, "NULL ent.think");

    ent.think.think(ent);

    return false;
  }
Пример #3
0
  public static void SV_NewChaseDir(edict_t actor, edict_t enemy, float dist) {
    float deltax, deltay;
    float d[] = {0, 0, 0};
    float tdir, olddir, turnaround;

    // FIXME: how did we get here with no enemy
    if (enemy == null) {
      Com.DPrintf("SV_NewChaseDir without enemy!\n");
      return;
    }
    olddir = Math3D.anglemod((int) (actor.ideal_yaw / 45) * 45);
    turnaround = Math3D.anglemod(olddir - 180);

    deltax = enemy.s.origin[0] - actor.s.origin[0];
    deltay = enemy.s.origin[1] - actor.s.origin[1];
    if (deltax > 10) d[1] = 0;
    else if (deltax < -10) d[1] = 180;
    else d[1] = DI_NODIR;
    if (deltay < -10) d[2] = 270;
    else if (deltay > 10) d[2] = 90;
    else d[2] = DI_NODIR;

    //	   try direct route
    if (d[1] != DI_NODIR && d[2] != DI_NODIR) {
      if (d[1] == 0) tdir = d[2] == 90 ? 45 : 315;
      else tdir = d[2] == 90 ? 135 : 215;

      if (tdir != turnaround && SV_StepDirection(actor, tdir, dist)) return;
    }

    //	   try other directions
    if (((Lib.rand() & 3) & 1) != 0 || Math.abs(deltay) > Math.abs(deltax)) {
      tdir = d[1];
      d[1] = d[2];
      d[2] = tdir;
    }

    if (d[1] != DI_NODIR && d[1] != turnaround && SV_StepDirection(actor, d[1], dist)) return;

    if (d[2] != DI_NODIR && d[2] != turnaround && SV_StepDirection(actor, d[2], dist)) return;

    /* there is no direct path to the player, so pick another direction */

    if (olddir != DI_NODIR && SV_StepDirection(actor, olddir, dist)) return;

    if ((Lib.rand() & 1) != 0) /* randomly determine direction of search */ {
      for (tdir = 0; tdir <= 315; tdir += 45)
        if (tdir != turnaround && SV_StepDirection(actor, tdir, dist)) return;
    } else {
      for (tdir = 315; tdir >= 0; tdir -= 45)
        if (tdir != turnaround && SV_StepDirection(actor, tdir, dist)) return;
    }

    if (turnaround != DI_NODIR && SV_StepDirection(actor, turnaround, dist)) return;

    actor.ideal_yaw = olddir; // can't move

    // if a bridge was pulled out from underneath a monster, it may not have
    // a valid standing position at all

    if (!M.M_CheckBottom(actor)) SV_FixCheckBottom(actor);
  }
Пример #4
0
  /** R_DrawEntitiesOnList */
  void R_DrawEntitiesOnList() {
    if (r_drawentities.value == 0.0f) return;

    // draw non-transparent first
    int i;
    for (i = 0; i < r_newrefdef.num_entities; i++) {
      currententity = r_newrefdef.entities[i];
      if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) continue; // solid

      if ((currententity.flags & Defines.RF_BEAM) != 0) {
        R_DrawBeam(currententity);
      } else {
        currentmodel = currententity.model;
        if (currentmodel == null) {
          R_DrawNullModel();
          continue;
        }
        switch (currentmodel.type) {
          case mod_alias:
            R_DrawAliasModel(currententity);
            break;
          case mod_brush:
            R_DrawBrushModel(currententity);
            break;
          case mod_sprite:
            R_DrawSpriteModel(currententity);
            break;
          default:
            Com.Error(Defines.ERR_DROP, "Bad modeltype");
            break;
        }
      }
    }
    // draw transparent entities
    // we could sort these if it ever becomes a problem...
    GL11.glDepthMask(false); // no z writes
    for (i = 0; i < r_newrefdef.num_entities; i++) {
      currententity = r_newrefdef.entities[i];
      if ((currententity.flags & Defines.RF_TRANSLUCENT) == 0) continue; // solid

      if ((currententity.flags & Defines.RF_BEAM) != 0) {
        R_DrawBeam(currententity);
      } else {
        currentmodel = currententity.model;

        if (currentmodel == null) {
          R_DrawNullModel();
          continue;
        }
        switch (currentmodel.type) {
          case mod_alias:
            R_DrawAliasModel(currententity);
            break;
          case mod_brush:
            R_DrawBrushModel(currententity);
            break;
          case mod_sprite:
            R_DrawSpriteModel(currententity);
            break;
          default:
            Com.Error(Defines.ERR_DROP, "Bad modeltype");
            break;
        }
      }
    }
    GL11.glDepthMask(true); // back to writing
  }