/// <summary> /// R_LavaSplash /// </summary> public static void LavaSplash(ref Vector3 org) { Vector3 dir; for (int i = -16; i < 16; i++) { for (int j = -16; j < 16; j++) { for (int k = 0; k < 1; k++) { particle_t p = AllocParticle(); if (p == null) { return; } p.die = (float)(Client.cl.time + 2 + (Sys.Random() & 31) * 0.02); p.color = 224 + (Sys.Random() & 7); p.type = ptype_t.pt_slowgrav; dir.X = j * 8 + (Sys.Random() & 7); dir.Y = i * 8 + (Sys.Random() & 7); dir.Z = 256; p.org = org + dir; p.org.Z += Sys.Random() & 63; Mathlib.Normalize(ref dir); float vel = 50 + (Sys.Random() & 63); p.vel = dir * vel; } } } }
/// <summary> /// R_TeleportSplash /// </summary> public static void TeleportSplash(ref Vector3 org) { for (int i = -16; i < 16; i += 4) { for (int j = -16; j < 16; j += 4) { for (int k = -24; k < 32; k += 4) { particle_t p = AllocParticle(); if (p == null) { return; } p.die = (float)(Client.cl.time + 0.2 + (Sys.Random() & 7) * 0.02); p.color = 7 + (Sys.Random() & 7); p.type = ptype_t.pt_slowgrav; Vector3 dir = new Vector3(j * 8, i * 8, k * 8); p.org = org + new Vector3(i + (Sys.Random() & 3), j + (Sys.Random() & 3), k + (Sys.Random() & 3)); Mathlib.Normalize(ref dir); float vel = 50 + (Sys.Random() & 63); p.vel = dir * vel; } } } }
/// <summary> /// R_BlobExplosion /// </summary> public static void BlobExplosion(ref Vector3 org) { for (int i = 0; i < 1024; i++) { particle_t p = AllocParticle(); if (p == null) { return; } p.die = (float)(Client.cl.time + 1 + (Sys.Random() & 8) * 0.05); if ((i & 1) != 0) { p.type = ptype_t.pt_blob; p.color = 66 + Sys.Random() % 6; } else { p.type = ptype_t.pt_blob2; p.color = 150 + Sys.Random() % 6; } p.org = org + new Vector3((Sys.Random() % 32) - 16, (Sys.Random() % 32) - 16, (Sys.Random() % 32) - 16); p.vel = new Vector3((Sys.Random() % 512) - 256, (Sys.Random() % 512) - 256, (Sys.Random() % 512) - 256); } }
/// <summary> /// R_ParticleExplosion /// </summary> public static void ParticleExplosion(ref Vector3 org) { for (int i = 0; i < 1024; i++) // Uze: Why 1024 if MAX_PARTICLES = 2048? { particle_t p = AllocParticle(); if (p == null) { return; } p.die = (float)Client.cl.time + 5; p.color = _Ramp1[0]; p.ramp = Sys.Random() & 3; if ((i & 1) != 0) { p.type = ptype_t.pt_explode; } else { p.type = ptype_t.pt_explode2; } p.org = org + new Vector3((Sys.Random() % 32) - 16, (Sys.Random() % 32) - 16, (Sys.Random() % 32) - 16); p.vel = new Vector3((Sys.Random() % 512) - 256, (Sys.Random() % 512) - 256, (Sys.Random() % 512) - 256); } }
static void R_ClearParticles() { free_particles = _Particles[0]; active_particles = null; for (int i = 0; i < r_numparticles - 1; i++) { _Particles[i].next = _Particles[i + 1]; } _Particles[r_numparticles - 1].next = null; }
/// <summary> /// R_ClearParticles /// </summary> static void ClearParticles() { _FreeParticles = _Particles[0]; _ActiveParticles = null; for (int i = 0; i < _NumParticles - 1; i++) { _Particles[i].next = _Particles[i + 1]; } _Particles[_NumParticles - 1].next = null; }
private static particle_t AllocParticle() { if (_FreeParticles == null) { return(null); } particle_t p = _FreeParticles; _FreeParticles = p.next; p.next = _ActiveParticles; _ActiveParticles = p; return(p); }
private static particle_t AllocParticle() { if (free_particles == null) { return(null); } particle_t p = free_particles; free_particles = p.next; p.next = active_particles; active_particles = p; return(p); }
/// <summary> /// R_ParticleExplosion2 /// </summary> public static void ParticleExplosion(ref Vector3 org, int colorStart, int colorLength) { int colorMod = 0; for (int i = 0; i < 512; i++) { particle_t p = AllocParticle(); if (p == null) { return; } p.die = (float)(Client.cl.time + 0.3); p.color = colorStart + (colorMod % colorLength); colorMod++; p.type = ptype_t.pt_blob; p.org = org + new Vector3((Sys.Random() % 32) - 16, (Sys.Random() % 32) - 16, (Sys.Random() % 32) - 16); p.vel = new Vector3((Sys.Random() % 512) - 256, (Sys.Random() % 512) - 256, (Sys.Random() % 512) - 256); } }
public static void R_EntityParticles(entity_t ent) { float dist = 64; if (avelocities[0].X == 0) { for (int i = 0; i < q_shared.NUMVERTEXNORMALS; i++) { avelocities[i].X = (Random() & 255) * 0.01f; avelocities[i].Y = (Random() & 255) * 0.01f; avelocities[i].Z = (Random() & 255) * 0.01f; } } for (int i = 0; i < q_shared.NUMVERTEXNORMALS; i++) { double angle = cl.time * avelocities[i].X; double sy = Math.Sin(angle); double cy = Math.Cos(angle); angle = cl.time * avelocities[i].Y; double sp = Math.Sin(angle); double cp = Math.Cos(angle); angle = cl.time * avelocities[i].Z; double sr = Math.Sin(angle); double cr = Math.Cos(angle); Vector3 forward = new Vector3((float)(cp * cy), (float)(cp * sy), (float)-sp); particle_t p = AllocParticle(); if (p == null) { return; } p.die = (float)(cl.time + 0.01); p.color = 0x6f; p.type = ptype_t.pt_explode; p.org = ent.origin + anorms[i] * dist + forward * beamlength; } }
/// <summary> /// R_EntityParticles /// </summary> public static void EntityParticles(entity_t ent) { float dist = 64; if (_AVelocities[0].X == 0) { for (int i = 0; i < NUMVERTEXNORMALS; i++) { _AVelocities[i].X = (Sys.Random() & 255) * 0.01f; _AVelocities[i].Y = (Sys.Random() & 255) * 0.01f; _AVelocities[i].Z = (Sys.Random() & 255) * 0.01f; } } for (int i = 0; i < NUMVERTEXNORMALS; i++) { double angle = Client.cl.time * _AVelocities[i].X; double sy = Math.Sin(angle); double cy = Math.Cos(angle); angle = Client.cl.time * _AVelocities[i].Y; double sp = Math.Sin(angle); double cp = Math.Cos(angle); angle = Client.cl.time * _AVelocities[i].Z; double sr = Math.Sin(angle); double cr = Math.Cos(angle); Vector3 forward = new Vector3((float)(cp * cy), (float)(cp * sy), (float)-sp); particle_t p = AllocParticle(); if (p == null) { return; } p.die = (float)(Client.cl.time + 0.01); p.color = 0x6f; p.type = ptype_t.pt_explode; p.org = ent.origin + Anorms.Values[i] * dist + forward * _BeamLength; } }
static void R_InitParticles() { int i = COM_CheckParm("-particles"); if (i > 0 && i < com_argv.Length - 1) { r_numparticles = int.Parse(Argv(i + 1)); if (r_numparticles < q_shared.ABSOLUTE_MIN_PARTICLES) { r_numparticles = q_shared.ABSOLUTE_MIN_PARTICLES; } } else { r_numparticles = q_shared.MAX_PARTICLES; } _Particles = new particle_t[r_numparticles]; for (i = 0; i < r_numparticles; i++) { _Particles[i] = new particle_t(); } }
static float _BeamLength = 16; // beamlength // R_InitParticles static void InitParticles() { int i = Common.CheckParm("-particles"); if (i > 0 && i < Common.Argc - 1) { _NumParticles = int.Parse(Common.Argv(i + 1)); if (_NumParticles < ABSOLUTE_MIN_PARTICLES) { _NumParticles = ABSOLUTE_MIN_PARTICLES; } } else { _NumParticles = MAX_PARTICLES; } _Particles = new particle_t[_NumParticles]; for (i = 0; i < _NumParticles; i++) { _Particles[i] = new particle_t(); } }
/// <summary> /// R_RunParticleEffect /// </summary> public static void RunParticleEffect(ref Vector3 org, ref Vector3 dir, int color, int count) { for (int i = 0; i < count; i++) { particle_t p = AllocParticle(); if (p == null) { return; } if (count == 1024) { // rocket explosion p.die = (float)Client.Cl.time + 5; p.color = _Ramp1[0]; p.ramp = Sys.Random() & 3; if ((i & 1) != 0) { p.type = ptype_t.pt_explode; } else { p.type = ptype_t.pt_explode2; } p.org = org + new Vector3((Sys.Random() % 32) - 16, (Sys.Random() % 32) - 16, (Sys.Random() % 32) - 16); p.vel = new Vector3((Sys.Random() % 512) - 256, (Sys.Random() % 512) - 256, (Sys.Random() % 512) - 256); } else { p.die = (float)Client.Cl.time + 0.1f * (Sys.Random() % 5); p.color = (color & ~7) + (Sys.Random() & 7); p.type = ptype_t.pt_slowgrav; p.org = org + new Vector3((Sys.Random() & 15) - 8, (Sys.Random() & 15) - 8, (Sys.Random() & 15) - 8); p.vel = dir * 15.0f; } } }
/// <summary> /// R_RocketTrail /// </summary> public static void RocketTrail(ref Vector3 start, ref Vector3 end, int type) { Vector3 vec = end - start; float len = Mathlib.Normalize(ref vec); int dec; if (type < 128) { dec = 3; } else { dec = 1; type -= 128; } while (len > 0) { len -= dec; particle_t p = AllocParticle(); if (p == null) { return; } p.vel = Vector3.Zero; p.die = (float)Client.cl.time + 2; switch (type) { case 0: // rocket trail p.ramp = (Sys.Random() & 3); p.color = _Ramp3[(int)p.ramp]; p.type = ptype_t.pt_fire; p.org = new Vector3(start.X + ((Sys.Random() % 6) - 3), start.Y + ((Sys.Random() % 6) - 3), start.Z + ((Sys.Random() % 6) - 3)); break; case 1: // smoke smoke p.ramp = (Sys.Random() & 3) + 2; p.color = _Ramp3[(int)p.ramp]; p.type = ptype_t.pt_fire; p.org = new Vector3(start.X + ((Sys.Random() % 6) - 3), start.Y + ((Sys.Random() % 6) - 3), start.Z + ((Sys.Random() % 6) - 3)); break; case 2: // blood p.type = ptype_t.pt_grav; p.color = 67 + (Sys.Random() & 3); p.org = new Vector3(start.X + ((Sys.Random() % 6) - 3), start.Y + ((Sys.Random() % 6) - 3), start.Z + ((Sys.Random() % 6) - 3)); break; case 3: case 5: // tracer p.die = (float)Client.cl.time + 0.5f; p.type = ptype_t.pt_static; if (type == 3) { p.color = 52 + ((_TracerCount & 4) << 1); } else { p.color = 230 + ((_TracerCount & 4) << 1); } _TracerCount++; p.org = start; if ((_TracerCount & 1) != 0) { p.vel.X = 30 * vec.Y; // Uze: why??? p.vel.Y = 30 * -vec.X; } else { p.vel.X = 30 * -vec.Y; p.vel.Y = 30 * vec.X; } break; case 4: // slight blood p.type = ptype_t.pt_grav; p.color = 67 + (Sys.Random() & 3); p.org = new Vector3(start.X + ((Sys.Random() % 6) - 3), start.Y + ((Sys.Random() % 6) - 3), start.Z + ((Sys.Random() % 6) - 3)); len -= 3; break; case 6: // voor trail p.color = 9 * 16 + 8 + (Sys.Random() & 3); p.type = ptype_t.pt_static; p.die = (float)Client.cl.time + 0.3f; p.org = new Vector3(start.X + ((Sys.Random() % 15) - 8), start.Y + ((Sys.Random() % 15) - 8), start.Z + ((Sys.Random() % 15) - 8)); break; } start += vec; } }
/// <summary> /// R_DrawParticles /// </summary> private static void DrawParticles() { Drawer.Bind(_ParticleTexture); GL.Enable(EnableCap.Blend); GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (int)TextureEnvMode.Modulate); GL.Begin(BeginMode.Triangles); Vector3 up = Render.ViewUp * 1.5f; Vector3 right = Render.ViewRight * 1.5f; float frametime = (float)(Client.cl.time - Client.cl.oldtime); float time3 = frametime * 15; float time2 = frametime * 10; float time1 = frametime * 5; float grav = frametime * Server.Gravity * 0.05f; float dvel = 4 * frametime; while (true) { particle_t kill = _ActiveParticles; if (kill != null && kill.die < Client.cl.time) { _ActiveParticles = kill.next; kill.next = _FreeParticles; _FreeParticles = kill; continue; } break; } for (particle_t p = _ActiveParticles; p != null; p = p.next) { while (true) { particle_t kill = p.next; if (kill != null && kill.die < Client.cl.time) { p.next = kill.next; kill.next = _FreeParticles; _FreeParticles = kill; continue; } break; } // hack a scale up to keep particles from disapearing float scale = Vector3.Dot((p.org - Render.Origin), Render.ViewPn); if (scale < 20) scale = 1; else scale = 1 + scale * 0.004f; // Uze todo: check if this is correct uint color = Vid.Table8to24[(byte)p.color]; GL.Color4((byte)(color & 0xff), (byte)((color >> 8) & 0xff), (byte)((color >> 16) & 0xff), (byte)((color >> 24) & 0xff)); GL.TexCoord2(0f, 0); GL.Vertex3(p.org); GL.TexCoord2(1f, 0); Vector3 v = p.org + up * scale; GL.Vertex3(v); GL.TexCoord2(0f, 1); v = p.org + right * scale; GL.Vertex3(v); p.org += p.vel * frametime; switch (p.type) { case ptype_t.pt_static: break; case ptype_t.pt_fire: p.ramp += time1; if (p.ramp >= 6) p.die = -1; else p.color = _Ramp3[(int)p.ramp]; p.vel.Z += grav; break; case ptype_t.pt_explode: p.ramp += time2; if (p.ramp >= 8) p.die = -1; else p.color = _Ramp1[(int)p.ramp]; p.vel += p.vel * dvel; p.vel.Z -= grav; break; case ptype_t.pt_explode2: p.ramp += time3; if (p.ramp >= 8) p.die = -1; else p.color = _Ramp2[(int)p.ramp]; p.vel -= p.vel * frametime; p.vel.Z -= grav; break; case ptype_t.pt_blob: p.vel += p.vel * dvel; p.vel.Z -= grav; break; case ptype_t.pt_blob2: p.vel -= p.vel * dvel; p.vel.Z -= grav; break; case ptype_t.pt_grav: case ptype_t.pt_slowgrav: p.vel.Z -= grav; break; } } GL.End(); GL.Disable(EnableCap.Blend); GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (int)TextureEnvMode.Replace); }
// R_InitParticles static void InitParticles() { int i = Common.CheckParm("-particles"); if (i > 0 && i < Common.Argc - 1) { _NumParticles = int.Parse(Common.Argv(i + 1)); if (_NumParticles < ABSOLUTE_MIN_PARTICLES) _NumParticles = ABSOLUTE_MIN_PARTICLES; } else _NumParticles = MAX_PARTICLES; _Particles = new particle_t[_NumParticles]; for (i = 0; i < _NumParticles; i++) _Particles[i] = new particle_t(); }
/* * ============== * D_DrawParticle * ============== */ public static void D_DrawParticle(particle_t pparticle) { double[] local = new double[3], transformed = new double[3]; double zi; int pdest; int pz; int i, izi, pix, count, u, v; // transform point mathlib.VectorSubtract(pparticle.org, render.r_origin, ref local); transformed[0] = mathlib.DotProduct(local, render.r_pright); transformed[1] = mathlib.DotProduct(local, render.r_pup); transformed[2] = mathlib.DotProduct(local, render.r_ppn); if (transformed[2] < PARTICLE_Z_CLIP) { return; } // project the point // FIXME: preadjust xcenter and ycenter zi = 1.0 / transformed[2]; u = (int)(render.xcenter + zi * transformed[0] + 0.5); v = (int)(render.ycenter - zi * transformed[1] + 0.5); if ((v > d_vrectbottom_particle) || (u > d_vrectright_particle) || (v < d_vrecty) || (u < d_vrectx)) { return; } pz = (int)((d_zwidth * v) + u); pdest = d_scantable[v] + u; izi = (int)(zi * 0x8000); pix = izi >> d_pix_shift; if (pix < d_pix_min) { pix = d_pix_min; } else if (pix > d_pix_max) { pix = d_pix_max; } switch (pix) { case 1: count = 1 << d_y_aspect_shift; for ( ; count != 0; count--, pz += (int)d_zwidth, pdest += screenwidth) { if (d_pzbuffer[pz + 0] <= izi) { d_pzbuffer[pz + 0] = (short)izi; d_viewbuffer[pdest + 0] = (byte)pparticle.color; } } break; case 2: count = 2 << d_y_aspect_shift; for ( ; count != 0; count--, pz += (int)d_zwidth, pdest += screenwidth) { if (d_pzbuffer[pz + 0] <= izi) { d_pzbuffer[pz + 0] = (short)izi; d_viewbuffer[pdest + 0] = (byte)pparticle.color; } if (d_pzbuffer[pz + 1] <= izi) { d_pzbuffer[pz + 1] = (short)izi; d_viewbuffer[pdest + 1] = (byte)pparticle.color; } } break; case 3: count = 3 << d_y_aspect_shift; for ( ; count != 0; count--, pz += (int)d_zwidth, pdest += screenwidth) { if (d_pzbuffer[pz + 0] <= izi) { d_pzbuffer[pz + 0] = (short)izi; d_viewbuffer[pdest + 0] = (byte)pparticle.color; } if (d_pzbuffer[pz + 1] <= izi) { d_pzbuffer[pz + 1] = (short)izi; d_viewbuffer[pdest + 1] = (byte)pparticle.color; } if (d_pzbuffer[pz + 2] <= izi) { d_pzbuffer[pz + 2] = (short)izi; d_viewbuffer[pdest + 2] = (byte)pparticle.color; } } break; case 4: count = 4 << d_y_aspect_shift; for ( ; count != 0; count--, pz += (int)d_zwidth, pdest += screenwidth) { if (d_pzbuffer[pz + 0] <= izi) { d_pzbuffer[pz + 0] = (short)izi; d_viewbuffer[pdest + 0] = (byte)pparticle.color; } if (d_pzbuffer[pz + 1] <= izi) { d_pzbuffer[pz + 1] = (short)izi; d_viewbuffer[pdest + 1] = (byte)pparticle.color; } if (d_pzbuffer[pz + 2] <= izi) { d_pzbuffer[pz + 2] = (short)izi; d_viewbuffer[pdest + 2] = (byte)pparticle.color; } if (d_pzbuffer[pz + 3] <= izi) { d_pzbuffer[pz + 3] = (short)izi; d_viewbuffer[pdest + 3] = (byte)pparticle.color; } } break; default: count = pix << d_y_aspect_shift; for ( ; count != 0; count--, pz += (int)d_zwidth, pdest += screenwidth) { for (i = 0; i < pix; i++) { if (d_pzbuffer[pz + i] <= izi) { d_pzbuffer[pz + i] = (short)izi; d_viewbuffer[pdest + i] = (byte)pparticle.color; } } } break; } }
/// <summary> /// R_DrawParticles /// </summary> private static void DrawParticles() { Drawer.Bind(_ParticleTexture); GL.Enable(EnableCap.Blend); GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (int)TextureEnvMode.Modulate); GL.Begin(BeginMode.Triangles); Vector3 up = Render.ViewUp * 1.5f; Vector3 right = Render.ViewRight * 1.5f; float frametime = (float)(Client.cl.time - Client.cl.oldtime); float time3 = frametime * 15; float time2 = frametime * 10; float time1 = frametime * 5; float grav = frametime * Server.Gravity * 0.05f; float dvel = 4 * frametime; while (true) { particle_t kill = _ActiveParticles; if (kill != null && kill.die < Client.cl.time) { _ActiveParticles = kill.next; kill.next = _FreeParticles; _FreeParticles = kill; continue; } break; } for (particle_t p = _ActiveParticles; p != null; p = p.next) { while (true) { particle_t kill = p.next; if (kill != null && kill.die < Client.cl.time) { p.next = kill.next; kill.next = _FreeParticles; _FreeParticles = kill; continue; } break; } // hack a scale up to keep particles from disapearing float scale = Vector3.Dot((p.org - Render.Origin), Render.ViewPn); if (scale < 20) { scale = 1; } else { scale = 1 + scale * 0.004f; } // Uze todo: check if this is correct uint color = Vid.Table8to24[(byte)p.color]; GL.Color4((byte)(color & 0xff), (byte)((color >> 8) & 0xff), (byte)((color >> 16) & 0xff), (byte)((color >> 24) & 0xff)); GL.TexCoord2(0f, 0); GL.Vertex3(p.org); GL.TexCoord2(1f, 0); Vector3 v = p.org + up * scale; GL.Vertex3(v); GL.TexCoord2(0f, 1); v = p.org + right * scale; GL.Vertex3(v); p.org += p.vel * frametime; switch (p.type) { case ptype_t.pt_static: break; case ptype_t.pt_fire: p.ramp += time1; if (p.ramp >= 6) { p.die = -1; } else { p.color = _Ramp3[(int)p.ramp]; } p.vel.Z += grav; break; case ptype_t.pt_explode: p.ramp += time2; if (p.ramp >= 8) { p.die = -1; } else { p.color = _Ramp1[(int)p.ramp]; } p.vel += p.vel * dvel; p.vel.Z -= grav; break; case ptype_t.pt_explode2: p.ramp += time3; if (p.ramp >= 8) { p.die = -1; } else { p.color = _Ramp2[(int)p.ramp]; } p.vel -= p.vel * frametime; p.vel.Z -= grav; break; case ptype_t.pt_blob: p.vel += p.vel * dvel; p.vel.Z -= grav; break; case ptype_t.pt_blob2: p.vel -= p.vel * dvel; p.vel.Z -= grav; break; case ptype_t.pt_grav: case ptype_t.pt_slowgrav: p.vel.Z -= grav; break; } } GL.End(); GL.Disable(EnableCap.Blend); GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (int)TextureEnvMode.Replace); }
/// <summary> /// R_ClearParticles /// </summary> static void ClearParticles() { _FreeParticles = _Particles[0]; _ActiveParticles = null; for (int i = 0; i < _NumParticles - 1; i++) _Particles[i].next = _Particles[i + 1]; _Particles[_NumParticles - 1].next = null; }
/* ============== D_DrawParticle ============== */ public static void D_DrawParticle(particle_t pparticle) { double[] local = new double[3] {0, 0, 0}, transformed = new double[3] {0, 0, 0}; double zi; int pdest; int pz; int i, izi, pix, count, u, v; // transform point mathlib.VectorSubtract (pparticle.org, render.r_origin, local); transformed[0] = mathlib.DotProduct(local, render.r_pright); transformed[1] = mathlib.DotProduct(local, render.r_pup); transformed[2] = mathlib.DotProduct(local, render.r_ppn); if (transformed[2] < PARTICLE_Z_CLIP) return; // project the point // FIXME: preadjust xcenter and ycenter zi = 1.0 / transformed[2]; u = (int)(render.xcenter + zi * transformed[0] + 0.5); v = (int)(render.ycenter - zi * transformed[1] + 0.5); if ((v > d_vrectbottom_particle) || (u > d_vrectright_particle) || (v < d_vrecty) || (u < d_vrectx)) { return; } pz = (int)((d_zwidth * v) + u); pdest = d_scantable[v] + u; izi = (int)(zi * 0x8000); pix = izi >> d_pix_shift; if (pix < d_pix_min) pix = d_pix_min; else if (pix > d_pix_max) pix = d_pix_max; switch (pix) { case 1: count = 1 << d_y_aspect_shift; for ( ; count != 0 ; count--, pz += (int)d_zwidth, pdest += screenwidth) { if (d_pzbuffer[pz+0] <= izi) { d_pzbuffer[pz+0] = (short)izi; d_viewbuffer[pdest+0] = (byte)pparticle.color; } } break; case 2: count = 2 << d_y_aspect_shift; for ( ; count != 0 ; count--, pz += (int)d_zwidth, pdest += screenwidth) { if (d_pzbuffer[pz+0] <= izi) { d_pzbuffer[pz+0] = (short)izi; d_viewbuffer[pdest+0] = (byte)pparticle.color; } if (d_pzbuffer[pz+1] <= izi) { d_pzbuffer[pz+1] = (short)izi; d_viewbuffer[pdest+1] = (byte)pparticle.color; } } break; case 3: count = 3 << d_y_aspect_shift; for ( ; count != 0 ; count--, pz += (int)d_zwidth, pdest += screenwidth) { if (d_pzbuffer[pz+0] <= izi) { d_pzbuffer[pz+0] = (short)izi; d_viewbuffer[pdest+0] = (byte)pparticle.color; } if (d_pzbuffer[pz+1] <= izi) { d_pzbuffer[pz+1] = (short)izi; d_viewbuffer[pdest+1] = (byte)pparticle.color; } if (d_pzbuffer[pz+2] <= izi) { d_pzbuffer[pz+2] = (short)izi; d_viewbuffer[pdest+2] = (byte)pparticle.color; } } break; case 4: count = 4 << d_y_aspect_shift; for ( ; count != 0 ; count--, pz += (int)d_zwidth, pdest += screenwidth) { if (d_pzbuffer[pz+0] <= izi) { d_pzbuffer[pz+0] = (short)izi; d_viewbuffer[pdest+0] = (byte)pparticle.color; } if (d_pzbuffer[pz+1] <= izi) { d_pzbuffer[pz+1] = (short)izi; d_viewbuffer[pdest+1] = (byte)pparticle.color; } if (d_pzbuffer[pz+2] <= izi) { d_pzbuffer[pz+2] = (short)izi; d_viewbuffer[pdest+2] = (byte)pparticle.color; } if (d_pzbuffer[pz+3] <= izi) { d_pzbuffer[pz+3] = (short)izi; d_viewbuffer[pdest+3] = (byte)pparticle.color; } } break; default: count = pix << d_y_aspect_shift; for ( ; count != 0 ; count--, pz += (int)d_zwidth, pdest += screenwidth) { for (i=0 ; i<pix ; i++) { if (d_pzbuffer[pz+i] <= izi) { d_pzbuffer[pz+i] = (short)izi; d_viewbuffer[pdest+i] = (byte)pparticle.color; } } } break; } }
private static particle_t AllocParticle() { if (_FreeParticles == null) return null; particle_t p = _FreeParticles; _FreeParticles = p.next; p.next = _ActiveParticles; _ActiveParticles = p; return p; }