vkQuake2 doxygen  1.0 dev
r_part.c File Reference
#include "r_local.h"

Go to the source code of this file.

Classes

struct  partparms_t
 

Macros

#define PARTICLE_33   0
 
#define PARTICLE_66   1
 
#define PARTICLE_OPAQUE   2
 

Functions

static byte BlendParticle33 (int pcolor, int dstcolor)
 
static byte BlendParticle66 (int pcolor, int dstcolor)
 
static byte BlendParticle100 (int pcolor, int dstcolor)
 
void R_DrawParticle (void)
 
void R_DrawParticles (void)
 

Variables

vec3_t r_pright
 
vec3_t r_pup
 
vec3_t r_ppn
 
static partparms_t partparms
 
static vec3_t local
 
static vec3_t transformed
 
static float zi
 
static bytepdest
 
static short * pz
 
static int i
 
static int izi
 
static int pix
 
static int count
 
static int u
 
static int v
 
static byte(* blendparticle )(int, int)
 

Macro Definition Documentation

◆ PARTICLE_33

#define PARTICLE_33   0

Definition at line 24 of file r_part.c.

◆ PARTICLE_66

#define PARTICLE_66   1

Definition at line 25 of file r_part.c.

◆ PARTICLE_OPAQUE

#define PARTICLE_OPAQUE   2

Definition at line 26 of file r_part.c.

Function Documentation

◆ BlendParticle100()

static byte BlendParticle100 ( int  pcolor,
int  dstcolor 
)
static

Definition at line 448 of file r_part.c.

449 {
450  dstcolor = dstcolor;
451  return pcolor;
452 }

Referenced by R_DrawParticle().

◆ BlendParticle33()

static byte BlendParticle33 ( int  pcolor,
int  dstcolor 
)
static

Definition at line 438 of file r_part.c.

439 {
440  return vid.alphamap[pcolor + dstcolor*256];
441 }

Referenced by R_DrawParticle().

◆ BlendParticle66()

static byte BlendParticle66 ( int  pcolor,
int  dstcolor 
)
static

Definition at line 443 of file r_part.c.

444 {
445  return vid.alphamap[pcolor*256+dstcolor];
446 }

Referenced by R_DrawParticle().

◆ R_DrawParticle()

void R_DrawParticle ( void  )

Definition at line 475 of file r_part.c.

476 {
477  particle_t *pparticle = partparms.particle;
478  int level = partparms.level;
479  int color = pparticle->color;
480 
481  /*
482  ** transform the particle
483  */
484  VectorSubtract (pparticle->origin, r_origin, local);
485 
489 
490  if (transformed[2] < PARTICLE_Z_CLIP)
491  return;
492 
493  /*
494  ** bind the blend function pointer to the appropriate blender
495  */
496  if ( level == PARTICLE_33 )
498  else if ( level == PARTICLE_66 )
500  else
502 
503  /*
504  ** project the point
505  */
506  // FIXME: preadjust xcenter and ycenter
507  zi = 1.0 / transformed[2];
508  u = (int)(xcenter + zi * transformed[0] + 0.5);
509  v = (int)(ycenter - zi * transformed[1] + 0.5);
510 
511  if ((v > d_vrectbottom_particle) ||
512  (u > d_vrectright_particle) ||
513  (v < d_vrecty) ||
514  (u < d_vrectx))
515  {
516  return;
517  }
518 
519  /*
520  ** compute addresses of zbuffer, framebuffer, and
521  ** compute the Z-buffer reference value.
522  */
523  pz = d_pzbuffer + (d_zwidth * v) + u;
525  izi = (int)(zi * 0x8000);
526 
527  /*
528  ** determine the screen area covered by the particle,
529  ** which also means clamping to a min and max
530  */
531  pix = izi >> d_pix_shift;
532  if (pix < d_pix_min)
533  pix = d_pix_min;
534  else if (pix > d_pix_max)
535  pix = d_pix_max;
536 
537  /*
538  ** render the appropriate pixels
539  */
540  count = pix;
541 
542  switch (level) {
543  case PARTICLE_33 :
544  for ( ; count ; count--, pz += d_zwidth, pdest += r_screenwidth)
545  {
546 //FIXME--do it in blocks of 8?
547  for (i=0 ; i<pix ; i++)
548  {
549  if (pz[i] <= izi)
550  {
551  pz[i] = izi;
552  pdest[i] = vid.alphamap[color + ((int)pdest[i]<<8)];
553  }
554  }
555  }
556  break;
557 
558  case PARTICLE_66 :
559  for ( ; count ; count--, pz += d_zwidth, pdest += r_screenwidth)
560  {
561  for (i=0 ; i<pix ; i++)
562  {
563  if (pz[i] <= izi)
564  {
565  pz[i] = izi;
566  pdest[i] = vid.alphamap[(color<<8) + (int)pdest[i]];
567  }
568  }
569  }
570  break;
571 
572  default: //100
573  for ( ; count ; count--, pz += d_zwidth, pdest += r_screenwidth)
574  {
575  for (i=0 ; i<pix ; i++)
576  {
577  if (pz[i] <= izi)
578  {
579  pz[i] = izi;
580  pdest[i] = color;
581  }
582  }
583  }
584  break;
585  }
586 }

Referenced by R_DrawParticles().

◆ R_DrawParticles()

void R_DrawParticles ( void  )

Definition at line 598 of file r_part.c.

599 {
600  particle_t *p;
601  int i;
602 
603 #if !defined __linux__ && !defined __FreeBSD__
604  extern unsigned long fpu_sp24_cw, fpu_chop_cw;
605 #endif
606 
609  VectorCopy( vpn, r_ppn );
610 
611 #if id386 && !defined __linux__ && !defined __FreeBSD__
612  __asm fldcw word ptr [fpu_sp24_cw]
613 #endif
614 
615  for (p=r_newrefdef.particles, i=0 ; i<r_newrefdef.num_particles ; i++,p++)
616  {
617 
618  if ( p->alpha > 0.66 )
620  else if ( p->alpha > 0.33 )
622  else
624 
625  partparms.particle = p;
626  partparms.color = p->color;
627 
628 #if id386 && !defined __linux__ && !defined __FreeBSD__
629  if ( i < r_newrefdef.num_particles-1 )
630  s_prefetch_address = ( unsigned int ) ( p + 1 );
631  else
632  s_prefetch_address = ( unsigned int ) r_newrefdef.particles;
633 #endif
634 
635  R_DrawParticle();
636  }
637 
638 #if id386 && !defined __linux__ && !defined __FreeBSD__
639  __asm fldcw word ptr [fpu_chop_cw]
640 #endif
641 
642 }

Variable Documentation

◆ blendparticle

byte(* blendparticle) (int, int)
static

Definition at line 473 of file r_part.c.

Referenced by R_DrawParticle().

◆ count

int count
static

Definition at line 472 of file r_part.c.

Referenced by R_DrawParticle().

◆ i

int i
static

Definition at line 472 of file r_part.c.

Referenced by R_DrawParticle(), and R_DrawParticles().

◆ izi

◆ local

vec3_t local
static

◆ partparms

partparms_t partparms
static

Definition at line 35 of file r_part.c.

Referenced by R_DrawParticle(), and R_DrawParticles().

◆ pdest

◆ pix

◆ pz

◆ r_ppn

vec3_t r_ppn

Definition at line 22 of file r_part.c.

Referenced by R_DrawParticle(), and R_DrawParticles().

◆ r_pright

vec3_t r_pright

Definition at line 22 of file r_part.c.

Referenced by R_DrawParticle(), and R_DrawParticles().

◆ r_pup

vec3_t r_pup

Definition at line 22 of file r_part.c.

Referenced by R_DrawParticle(), and R_DrawParticles().

◆ transformed

vec3_t transformed
static

Definition at line 468 of file r_part.c.

Referenced by R_AliasCheckFrameBBox(), R_ClipAndDrawPoly(), R_DrawParticle(), and R_EmitEdge().

◆ u

◆ v

int v
static

Definition at line 472 of file r_part.c.

Referenced by R_DrawParticle().

◆ zi

float zi
static
yscaleshrink
float yscaleshrink
Definition: r_local.h:577
int
CONST PIXELFORMATDESCRIPTOR int
Definition: qgl_win.c:35
transformed
static vec3_t transformed
Definition: r_part.c:468
VectorSubtract
#define VectorSubtract(a, b, c)
Definition: q_shared.h:163
vright
vec3_t vright
Definition: r_main.c:74
pix
static int pix
Definition: r_part.c:472
VectorScale
void VectorScale(vec3_t in, vec_t scale, vec3_t out)
Definition: q_shared.c:782
d_viewbuffer
pixel_t * d_viewbuffer
Definition: r_main.c:196
PARTICLE_66
#define PARTICLE_66
Definition: r_part.c:25
r_origin
vec3_t r_origin
Definition: r_main.c:75
PARTICLE_Z_CLIP
#define PARTICLE_Z_CLIP
Definition: d_ifacea.h:37
r_pright
vec3_t r_pright
Definition: r_part.c:22
vup
vec3_t vup
Definition: r_main.c:72
PARTICLE_OPAQUE
#define PARTICLE_OPAQUE
Definition: r_part.c:26
partparms_t::color
int color
Definition: r_part.c:32
u
static int u
Definition: r_part.c:472
v
static int v
Definition: r_part.c:472
partparms_t::particle
particle_t * particle
Definition: r_part.c:30
d_pix_max
int d_pix_max
Definition: r_local.h:534
xscaleshrink
float xscaleshrink
Definition: r_main.c:84
d_vrectx
int d_vrectx
Definition: r_misc.c:38
BlendParticle33
static byte BlendParticle33(int pcolor, int dstcolor)
Definition: r_part.c:438
particle_t::alpha
float alpha
Definition: ref.h:93
d_pix_shift
int d_pix_shift
Definition: r_local.h:534
partparms_t::level
int level
Definition: r_part.c:31
r_newrefdef
refdef_t r_newrefdef
Definition: r_main.c:38
DotProduct
#define DotProduct(x, y)
Definition: q_shared.h:162
pz
static short * pz
Definition: r_part.c:471
r_pup
vec3_t r_pup
Definition: r_part.c:22
d_scantable
int d_scantable[MAXHEIGHT]
Definition: r_misc.c:42
particle_t
Definition: ref.h:89
refdef_t::num_particles
int num_particles
Definition: ref.h:122
r_screenwidth
int r_screenwidth
Definition: r_main.c:87
ycenter
float ycenter
Definition: r_local.h:574
particle_t::origin
vec3_t origin
Definition: ref.h:91
d_pix_min
int d_pix_min
Definition: r_misc.c:40
VectorCopy
#define VectorCopy(a, b)
Definition: q_shared.h:165
refdef_t::particles
particle_t * particles
Definition: ref.h:123
d_vrectbottom_particle
int d_vrectbottom_particle
Definition: r_local.h:532
pdest
static byte * pdest
Definition: r_part.c:470
level
GLint level
Definition: qgl_win.c:116
local
static vec3_t local
Definition: r_part.c:468
d_zwidth
unsigned int d_zwidth
Definition: r_local.h:538
d_vrectright_particle
int d_vrectright_particle
Definition: r_local.h:532
particle_t::color
int color
Definition: ref.h:92
partparms
static partparms_t partparms
Definition: r_part.c:35
d_vrecty
int d_vrecty
Definition: r_local.h:532
blendparticle
static byte(* blendparticle)(int, int)
Definition: r_part.c:473
BlendParticle100
static byte BlendParticle100(int pcolor, int dstcolor)
Definition: r_part.c:448
R_DrawParticle
void R_DrawParticle(void)
Definition: r_part.c:475
count
static int count
Definition: r_part.c:472
i
static int i
Definition: r_part.c:472
BlendParticle66
static byte BlendParticle66(int pcolor, int dstcolor)
Definition: r_part.c:443
d_pzbuffer
short * d_pzbuffer
Definition: r_main.c:197
r_ppn
vec3_t r_ppn
Definition: r_part.c:22
xcenter
float xcenter
Definition: r_main.c:81
viddef_t::alphamap
pixel_t * alphamap
Definition: r_local.h:96
vpn
vec3_t vpn
Definition: r_main.c:73
PARTICLE_33
#define PARTICLE_33
Definition: r_part.c:24
zi
static float zi
Definition: r_part.c:469
izi
static int izi
Definition: r_part.c:472
vid
viddef_t vid
Definition: r_main.c:24