speed up more csqc ent drawing
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / modeleffects.qc
1 .float frame1time;
2 .float lifetime, fadetime;
3 .float teleport_time;
4 .float scale1, scale2;
5
6 void ModelEffect_Draw()
7 {
8         self.angles = self.angles + frametime * self.avelocity;
9         self.origin = self.origin + frametime * self.velocity;
10         self.scale = self.scale1 + (self.scale2 - self.scale1) * (time - self.teleport_time) / (self.lifetime + self.fadetime - self.teleport_time);
11         self.alpha = self.cnt * bound(0, 1 - (time - self.lifetime) / self.fadetime, 1);
12         if(self.alpha < ALPHA_MIN_VISIBLE)
13         {
14                 remove(self);
15                 return;
16         }
17         self.drawmask = MASK_NORMAL;
18         if(self.scale <= 0)
19         {
20                 self.drawmask = 0;
21                 return;
22         }
23 }
24
25 void Ent_ModelEffect(float isNew)
26 {
27         float f;
28         entity e;
29
30         self.classname = "modeleffect_spawner";
31
32         f = ReadByte();
33
34         e = spawn();
35         e.classname = "modeleffect";
36         e.model = "from network";
37         e.modelindex = ReadShort();
38         e.skin = ReadByte();
39         e.frame = ReadByte();
40         e.frame1time = time;
41         e.origin_x = ReadCoord();
42         e.origin_y = ReadCoord();
43         e.origin_z = ReadCoord();
44         if(f & 1)
45         {
46                 e.velocity_x = ReadCoord();
47                 e.velocity_y = ReadCoord();
48                 e.velocity_z = ReadCoord();
49         }
50         if(f & 2)
51         {
52                 e.angles_x = ReadAngle();
53                 e.angles_y = ReadAngle();
54                 e.angles_z = ReadAngle();
55         }
56         if(f & 4)
57         {
58                 e.avelocity_x = ReadAngle();
59                 e.avelocity_y = ReadAngle();
60                 e.avelocity_z = ReadAngle();
61         }
62         e.scale1 = ReadShort() / 256.0;
63         e.scale2 = ReadShort() / 256.0;
64         e.lifetime = time + ReadByte() * 0.01;
65         e.fadetime = ReadByte() * 0.01;
66         e.teleport_time = time;
67         e.cnt = ReadByte() / 255.0; // actually alpha
68
69         e.draw = ModelEffect_Draw;
70
71         if(!isNew)
72                 remove(e); // yes, this IS stupid, but I don't need to duplicate all the read* stuff then
73 }