Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
csqcmodel_hooks.qh File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void CSQCModel_Effects_Apply (entity this)
void CSQCModel_Hook_PreDraw (entity this, bool isplayer)
void CSQCModel_LOD_Apply (entity this, bool isplayer)

Variables

int autocvar__cl_color
string autocvar__cl_playermodel
int autocvar__cl_playerskin
float autocvar_cl_deathglow
float autocvar_cl_deathglow_min = 0.5
int autocvar_cl_forcemyplayercolors
string autocvar_cl_forcemyplayermodel
int autocvar_cl_forcemyplayerskin
bool autocvar_cl_forceplayercolors
bool autocvar_cl_forceplayermodels
bool autocvar_cl_forceuniqueplayercolors
float autocvar_cl_jetpack_attenuation = 2
float autocvar_cl_loddistance1 = 768
float autocvar_cl_loddistance2 = 2048
int autocvar_cl_modeldetailreduction
int autocvar_cl_playerdetailreduction
bool autocvar_cl_respawn_ghosts_keepcolors
float autocvar_r_hdr_glowintensity
int csqcmodel_effects
bool csqcmodel_isdead
int csqcmodel_modelflags
int csqcmodel_traileffect
float death_time
const int EF_BRIGHTFIELD = BIT(0)
const int EF_BRIGHTLIGHT = BIT(2)
const int EF_DIMLIGHT = BIT(3)
const int EF_DOUBLESIDED = BIT(15)
const int EF_DYNAMICMODELLIGHT = BIT(17)
const int EF_NOSELFSHADOW = BIT(16)
const int EF_RESTARTANIM_BIT = BIT(20)
const int EF_TELEPORT_BIT = BIT(21)
int isplayermodel
const int MF_GIB = BIT(2)
const int MF_GRENADE = BIT(1)
const int MF_ROCKET = BIT(0)
const int MF_ROTATE = BIT(3)
const int MF_TRACER = BIT(4)
const int MF_TRACER2 = BIT(6)
const int MF_TRACER3 = BIT(7)
const int MF_ZOMGIB = BIT(5)

Function Documentation

◆ CSQCModel_Effects_Apply()

void CSQCModel_Effects_Apply ( entity this)

Definition at line 546 of file csqcmodel_hooks.qc.

547{
548 float dt = bound(0, frametime, 0.1);
550 int tref = this.csqcmodel_traileffect;
551
553 this.effects = 0;
554 this.traileffect = 0;
555
556 float pl_alpha = (!this.alpha ? 1 : this.alpha);
557 if (eff & EF_BRIGHTFIELD)
558 tref = EFFECT_TR_NEXUIZPLASMA.m_id;
559 // ignoring EF_MUZZLEFLASH
560 if ((eff & EF_NODRAW) || pl_alpha < 0)
561 this.drawmask = 0;
562 if (eff & EF_ADDITIVE)
563 this.renderflags |= RF_ADDITIVE;
564 // ignoring EF_NOGUNBOB
565 if (eff & EF_FULLBRIGHT)
567
568 if (pl_alpha > 0)
569 {
570 if (eff & EF_BLUE)
571 adddynamiclight(this.origin, 200 * pl_alpha, '0.15 0.15 1.5');
572 if (eff & EF_RED)
573 adddynamiclight(this.origin, 200 * pl_alpha, '1.5 0.15 0.15');
574 if (eff & EF_BRIGHTLIGHT)
575 adddynamiclight(this.origin, 400 * pl_alpha, '3 3 3');
576 if (eff & EF_DIMLIGHT)
577 adddynamiclight(this.origin, 200 * pl_alpha, '1.5 1.5 1.5');
578 if (eff & EF_FLAME)
579 {
580 particles_alphamin = particles_alphamax = pl_alpha; // scale by player alpha
581 // XONRELEASE TODO: xonotic-v0.9.0 after release remove the ef_shock_num check
582 // NOTE here we check if EF_SHOCK exists because it was added together with the change to EF_FLAME
583 int ef_shock_num = particleeffectnum(EFFECT_EF_SHOCK);
584 if (ef_shock_num >= 0) // in the old version of EF_FLAME the light was spawned by boxparticles
585 adddynamiclight2(this.origin + '0 0 10', 200 * particles_alphamin, '1 0.35 0', 6, "", PFLAGS_FULLDYNAMIC); // no PFLAGS_CORONA, it looks bad
586 int ef_flame_num = particleeffectnum(EFFECT_EF_FLAME);
587 boxparticles(ef_flame_num, this, this.absmin, this.absmax, this.velocity, this.velocity, dt, PARTICLES_USEALPHA);
588 //pointparticles(EFFECT_EF_FLAME, this.origin, '0 0 0', dt);
589 }
590 if (eff & EF_SHOCK)
591 {
592 particles_alphamin = particles_alphamax = pl_alpha; // scale by player alpha
593 // XONRELEASE TODO: xonotic-v0.9.0 after release remove the ef_shock_num check
594 int ef_shock_num = particleeffectnum(EFFECT_EF_SHOCK);
595 if (ef_shock_num >= 0) // in ARC_LIGHTNING the light is spawned by boxparticles
596 adddynamiclight2(this.origin, 50 * particles_alphamin, '3.1 4.4 10', 10, "", PFLAGS_FULLDYNAMIC); // no PFLAGS_CORONA, it looks bad
597 else
598 ef_shock_num = particleeffectnum(EFFECT_ARC_LIGHTNING);
599 boxparticles(ef_shock_num, this, this.absmin, this.absmax, '0 0 0', '0 0 0', dt, PARTICLES_USEALPHA);
600 //pointparticles(EFFECT_ARC_LIGHTNING, this.origin, '0 0 0', dt);
601 }
602 if (eff & EF_SPEED)
603 {
604 float speed = vlen(this.velocity);
605 if (speed > 0)
606 {
607 particles_alphamin = particles_alphamax = pl_alpha * min(speed / PHYS_MAXSPEED(this), 1); // scale by player alpha, and more transparent at lower speeds
608 vector dir = this.velocity * 1 / speed;
609 // XONRELEASE TODO: xonotic-v0.9.0 post-release remove the ef_speed_num check
610 int ef_speed_num = particleeffectnum(EFFECT_EF_SPEED);
611 int foot_L_idx = gettagindex(this, "foot_L"); // left & right feet on the playermodel,
612 int foot_R_idx = gettagindex(this, "foot_R"); // roughly at the heel
613 if (foot_L_idx && foot_R_idx)
614 {
615 vector foot_L_org = gettaginfo(this, foot_L_idx);
616 vector foot_R_org = gettaginfo(this, foot_R_idx);
617 if (ef_speed_num >= 0)
618 {
619 // NOTE: to make this a proper trail the old foot_*_org will need to be stored, however it looks fine as-is
620 WarpZone_TrailParticles_WithMultiplier(this, ef_speed_num, foot_L_org - dir, foot_L_org + dir, dt, PARTICLES_USEALPHA);
621 WarpZone_TrailParticles_WithMultiplier(this, ef_speed_num, foot_R_org - dir, foot_R_org + dir, dt, PARTICLES_USEALPHA);
622 }
623 // No fallback since nothing looks similar, light will still draw though
624 adddynamiclight(foot_L_org, 45 * particles_alphamin, STATUSEFFECT_Speed.m_color);
625 adddynamiclight(foot_R_org, 45 * particles_alphamin, STATUSEFFECT_Speed.m_color);
626 }
627 else
628 {
629 vector org = this.origin + 0.5 * (this.mins + this.maxs); // center
630 if (ef_speed_num >= 0)
632 //pointparticles(EFFECT_EF_SPEED, org, '0 0 0', dt);
633 adddynamiclight(org, 45 * particles_alphamin, STATUSEFFECT_Speed.m_color);
634 }
635 }
636 }
637 if (eff & EF_STARDUST)
638 {
639 particles_alphamin = particles_alphamax = pl_alpha; // scale by player alpha
640 boxparticles(particleeffectnum(EFFECT_EF_STARDUST), this, this.absmin, this.absmax, this.velocity, this.velocity, dt, PARTICLES_USEALPHA);
641 //pointparticles(EFFECT_EF_STARDUST, this.origin, '0 0 0', dt);
642 }
643 }
644
645 if (eff & EF_NOSHADOW)
646 this.renderflags |= RF_NOSHADOW;
647 if (eff & EF_NODEPTHTEST)
649 // ignoring EF_SELECTABLE
650 if (eff & EF_DOUBLESIDED)
651 this.effects |= EF_DOUBLESIDED;
652 if (eff & EF_NOSELFSHADOW)
653 this.effects |= EF_NOSELFSHADOW;
654 if (eff & EF_DYNAMICMODELLIGHT)
656 // ignoring EF_UNUSED18, EF_UNUSED19, EF_RESTARTANIM_BIT, EF_TELEPORT_BIT, EF_LOWPRECISION
657
658 if (false)
659 ;
660#define TRAIL_FROM_MODEL(modelflag, trailent) \
661 else if (this.csqcmodel_modelflags & (modelflag)) \
662 tref = EFFECT_##trailent.m_id
663 TRAIL_FROM_MODEL(MF_TRACER3, TR_VORESPIKE);
664 TRAIL_FROM_MODEL(MF_TRACER2, TR_KNIGHTSPIKE);
665 TRAIL_FROM_MODEL(MF_ZOMGIB, TR_SLIGHTBLOOD);
666 TRAIL_FROM_MODEL(MF_TRACER, TR_WIZSPIKE);
667 TRAIL_FROM_MODEL(MF_GIB, TR_BLOOD);
668 TRAIL_FROM_MODEL(MF_GRENADE, TR_GRENADE);
669 TRAIL_FROM_MODEL(MF_ROCKET, TR_ROCKET);
670#undef TRAIL_FROM_MODEL
672 {
673 // This will be hard to replace with MAKE_VECTORS because it's called as part of the predraw function
674 // as documented in csprogs.h in the engine. The globals can then be read in many places in the engine.
675 // However MF_ROTATE is currently only used in one place - might be possible to get rid of it entirely.
676 this.renderflags |= RF_USEAXIS;
677 makevectors(this.angles + '0 100 0' * fmod(time, 3.6));
678 }
679
680 this.traileffect = tref;
681
682 if (this.drawmask)
683 Projectile_DrawTrail(this, this.origin);
684 else
685 Projectile_ResetTrail(this, this.origin);
686
688 this.renderflags |= RF_ADDITIVE;
689 // also special in CSQCPlayer_GlowMod_Apply
690
692 {
693 if (!this.snd_looping)
694 {
697 }
698 }
699 else
700 {
701 if (this.snd_looping)
702 {
704 this.snd_looping = 0;
705 }
706 }
707}
float alpha
Definition items.qc:13
float renderflags
Definition main.qh:111
#define PHYS_MAXSPEED(s)
Definition player.qh:138
const int EF_SPEED
Definition constants.qh:96
const int EF_SHOCK
Definition constants.qh:95
const float EF_STARDUST
float drawmask
const float RF_ADDITIVE
const float RF_USEAXIS
float frametime
vector mins
const float EF_RED
vector velocity
const float EF_ADDITIVE
const float EF_FULLBRIGHT
float effects
float time
vector maxs
const float EF_FLAME
float particles_alphamax
const float EF_BLUE
vector absmax
const float EF_NODEPTHTEST
vector origin
float PARTICLES_USEALPHA
float particles_alphamin
vector absmin
const float RF_FULLBRIGHT
float RF_DYNAMICMODELLIGHT
const float EF_NOSHADOW
const float EF_NODRAW
const float RF_NOSHADOW
const float RF_DEPTHHACK
const float PFLAGS_FULLDYNAMIC
#define TRAIL_FROM_MODEL(modelflag, trailent)
int snd_looping
const int MF_ROTATE
const int MF_GRENADE
const int MF_TRACER3
int csqcmodel_traileffect
int csqcmodel_effects
const int MF_TRACER
const int EF_BRIGHTFIELD
const int MF_ROCKET
const int MF_GIB
const int EF_BRIGHTLIGHT
const int MF_ZOMGIB
const int EF_DIMLIGHT
float autocvar_cl_jetpack_attenuation
int csqcmodel_modelflags
const int MF_TRACER2
const int EF_NOSELFSHADOW
const int EF_DOUBLESIDED
const int EF_DYNAMICMODELLIGHT
#define CSQCMODEL_EF_RESPAWNGHOST
#define gettagindex
float speed
Definition dynlight.qc:9
#define particleeffectnum(e)
Definition effect.qh:3
ent angles
Definition ent_cs.qc:146
void WarpZone_TrailParticles_WithMultiplier(entity own, float eff, vector org, vector end, float f, int boxflags)
Definition common.qc:466
float fmod(float e, float f)
Definition mathlib.qc:203
float bound(float min, float value, float max)
float vlen(vector v)
float min(float f,...)
#define makevectors
Definition post.qh:21
#define adddynamiclight2
Definition post.qh:30
#define gettaginfo
Definition post.qh:32
#define adddynamiclight
Definition post.qh:29
void Projectile_DrawTrail(entity this, vector to)
Definition projectile.qc:32
void Projectile_ResetTrail(entity this, vector to)
Definition projectile.qc:26
vector
Definition self.qh:96
vector org
Definition self.qh:96
int dir
Definition impulse.qc:89
const int CH_TRIGGER_SINGLE
Definition sound.qh:13
const float VOL_BASE
Definition sound.qh:36
#define sound(e, c, s, v, a)
Definition sound.qh:52

References absmax, absmin, adddynamiclight, adddynamiclight2, alpha, angles, autocvar_cl_jetpack_attenuation, bound(), CH_TRIGGER_SINGLE, CSQCMODEL_EF_RESPAWNGHOST, csqcmodel_effects, csqcmodel_modelflags, csqcmodel_traileffect, dir, drawmask, EF_ADDITIVE, EF_BLUE, EF_BRIGHTFIELD, EF_BRIGHTLIGHT, EF_DIMLIGHT, EF_DOUBLESIDED, EF_DYNAMICMODELLIGHT, EF_FLAME, EF_FULLBRIGHT, EF_NODEPTHTEST, EF_NODRAW, EF_NOSELFSHADOW, EF_NOSHADOW, EF_RED, EF_SHOCK, EF_SPEED, EF_STARDUST, effects, entity(), fmod(), frametime, gettagindex, gettaginfo, makevectors, maxs, MF_GIB, MF_GRENADE, MF_ROCKET, MF_ROTATE, MF_TRACER, MF_TRACER2, MF_TRACER3, MF_ZOMGIB, min(), mins, org, origin, particleeffectnum, particles_alphamax, particles_alphamin, PARTICLES_USEALPHA, PFLAGS_FULLDYNAMIC, PHYS_MAXSPEED, Projectile_DrawTrail(), Projectile_ResetTrail(), renderflags, RF_ADDITIVE, RF_DEPTHHACK, RF_DYNAMICMODELLIGHT, RF_FULLBRIGHT, RF_NOSHADOW, RF_USEAXIS, snd_looping, sound, speed, time, TRAIL_FROM_MODEL, vector, velocity, vlen(), VOL_BASE, and WarpZone_TrailParticles_WithMultiplier().

Referenced by CSQCModel_Hook_PreDraw(), and viewmodel_draw().

◆ CSQCModel_Hook_PreDraw()

void CSQCModel_Hook_PreDraw ( entity this,
bool isplayer )

Definition at line 720 of file csqcmodel_hooks.qc.

721{
723 return;
725
726 if(!this.modelindex || this.model == "null")
727 {
728 this.drawmask = 0;
729 if(this.snd_looping > 0)
730 {
732 this.snd_looping = 0;
733 }
734 return;
735 }
736 else
737 this.drawmask = MASK_NORMAL;
738
739 if((this.isplayermodel & ISPLAYER_MODEL) && this.drawmask) // this checks if it's a player MODEL!
740 {
742 CSQCModel_LOD_Apply(this, true);
743
744 if(!isplayer)
745 {
746 skeleton_loadinfo(this);
747 bool doblend = (this.bone_upperbody >= 0);
749 if(doblend)
750 {
752 }
753 else
754 {
756 // just in case, clear these (we're animating in frame and frame3)
757 this.lerpfrac = 0;
758 this.lerpfrac4 = 0;
759 }
760 }
761 else
762 {
763 // we know that frame3 and frame4 fields, used by InterpolateAnimation, are left alone - but that is all we know!
764 skeleton_loadinfo(this);
765 bool doblend = (this.bone_upperbody >= 0);
766 bool onground = 0;
767 if(this == csqcplayer)
768 {
769 if(IS_ONGROUND(this))
770 onground = 1;
771 this.anim_prev_pmove_flags = this.flags;
772 if(this.flags & FL_DUCKED)
773 animdecide_setstate(this, this.anim_state | ANIMSTATE_DUCK, false);
774 else if(this.anim_state & ANIMSTATE_DUCK)
775 animdecide_setstate(this, this.anim_state - ANIMSTATE_DUCK, false);
776 }
777 else
778 {
779 tracebox(this.origin + '0 0 1', this.mins, this.maxs, this.origin - '0 0 4', MOVE_NORMAL, this);
781 onground = 1;
782 // predicted clients handle smoothing in the prediction code
783 this.origin = CSQCModel_ApplyStairSmoothing(this, onground, this.origin);
784 }
786 animdecide_setimplicitstate(this, onground);
788 int sf = 0;
789 if(this.anim_saveframe != this.anim_frame || this.anim_saveframe1time != this.anim_frame1time)
791 if(this.anim_saveframe2 != this.anim_frame2 || this.anim_saveframe2time != this.anim_frame2time)
793 this.anim_saveframe = this.anim_frame;
795 this.anim_saveframe2 = this.anim_frame2;
797 // Note: we always consider lerpfrac "changed", as it uses fixed values every time anyway.
798 // This ensures that .frame etc. are always written.
800 this.lerpfrac = (doblend ? 0.5 : 0);
801 this.frame = this.anim_frame;
802 this.frame1time = this.anim_frame1time;
803 this.frame2 = this.anim_frame2;
804 this.frame2time = this.anim_frame2time;
807 if(doblend)
808 {
810 }
811 else
812 {
814 // just in case, clear these (we're animating in frame and frame3)
815 this.lerpfrac = 0;
816 this.lerpfrac4 = 0;
817 }
818 }
819 }
820 else
821 CSQCModel_LOD_Apply(this, false);
822
824
826}
float frame1time
start time of framegroup animation
Definition anim.qh:22
float frame2time
start time of framegroup animation
Definition anim.qh:24
float frame2
secondary framegroup animation (strength = lerpfrac)
Definition anim.qh:8
float lerpfrac
strength of framegroup blend
Definition anim.qh:15
float lerpfrac4
strength of framegroup blend
Definition anim.qh:19
float frame
primary framegroup animation (strength = 1 - lerpfrac - lerpfrac3 - lerpfrac4)
Definition anim.qh:6
void animdecide_setimplicitstate(entity e, float onground)
void animdecide_load_if_needed(entity e)
Definition animdecide.qc:53
void animdecide_setframes(entity e, float support_blending,.float fld_frame,.float fld_frame1time,.float fld_frame2,.float fld_frame2time)
void animdecide_setstate(entity e, int newstate, float restart)
int anim_state
const int ANIMSTATE_DUCK
void CSQCModel_InterpolateAnimation_2To4_PreNote(entity this, int sf)
Definition cl_model.qc:37
void CSQCModel_InterpolateAnimation_2To4_Note(entity this, int sf, bool set_times)
Definition cl_model.qc:73
void CSQCModel_InterpolateAnimation_2To4_Do(entity this)
Definition cl_model.qc:109
vector CSQCModel_ApplyStairSmoothing(entity this, bool isonground, vector v)
Definition cl_player.qc:248
entity csqcplayer
Definition cl_player.qh:26
int framecount
Definition main.qh:180
const int FL_DUCKED
Definition constants.qh:81
float flags
float modelindex
const float MASK_NORMAL
const float MOVE_NORMAL
float trace_startsolid
float trace_fraction
int anim_prev_pmove_flags
int anim_saveframe2
int anim_frame2
void CSQCModel_AutoTagIndex_Apply(entity this)
void CSQCPlayer_FallbackFrame_Apply(entity this)
int anim_frame
int anim_frame1time
int anim_frame2time
void CSQCPlayer_ModelAppearance_Apply(entity this, bool islocalplayer)
void CSQCModel_LOD_Apply(entity this, bool isplayer)
int anim_saveframe1time
void CSQCModel_Effects_Apply(entity this)
int csqcmodel_predraw_run
int anim_saveframe
int anim_saveframe2time
bool csqcmodel_isdead
int isplayermodel
model
Definition ent_cs.qc:164
const int CSQCMODEL_PROPERTY_FRAME2
Definition common.qh:67
const int ISPLAYER_LOCAL
Definition common.qh:58
const int CSQCMODEL_PROPERTY_FRAME
Definition common.qh:61
const int ISPLAYER_MODEL
Definition common.qh:56
const int CSQCMODEL_PROPERTY_LERPFRAC
Definition common.qh:68
#define IS_ONGROUND(s)
Definition movetypes.qh:16
void skeleton_loadinfo(entity e)
void skeleton_from_frames(entity e, bool is_dead)
void free_skeleton_from_frames(entity e)

References anim_frame, anim_frame1time, anim_frame2, anim_frame2time, anim_prev_pmove_flags, anim_saveframe, anim_saveframe1time, anim_saveframe2, anim_saveframe2time, anim_state, animdecide_load_if_needed(), animdecide_setframes(), animdecide_setimplicitstate(), animdecide_setstate(), ANIMSTATE_DUCK, autocvar_cl_jetpack_attenuation, CSQCModel_ApplyStairSmoothing(), CSQCModel_AutoTagIndex_Apply(), CSQCModel_Effects_Apply(), CSQCModel_InterpolateAnimation_2To4_Do(), CSQCModel_InterpolateAnimation_2To4_Note(), CSQCModel_InterpolateAnimation_2To4_PreNote(), csqcmodel_isdead, CSQCModel_LOD_Apply(), csqcmodel_predraw_run, CSQCMODEL_PROPERTY_FRAME, CSQCMODEL_PROPERTY_FRAME2, CSQCMODEL_PROPERTY_LERPFRAC, csqcplayer, CSQCPlayer_FallbackFrame_Apply(), CSQCPlayer_ModelAppearance_Apply(), drawmask, entity(), FL_DUCKED, flags, frame, frame1time, frame2, frame2time, framecount, free_skeleton_from_frames(), IS_ONGROUND, ISPLAYER_LOCAL, ISPLAYER_MODEL, isplayermodel, lerpfrac, lerpfrac4, MASK_NORMAL, maxs, mins, model, modelindex, MOVE_NORMAL, origin, skeleton_from_frames(), skeleton_loadinfo(), snd_looping, sound, trace_fraction, trace_startsolid, and VOL_BASE.

Referenced by CSQCModel_AutoTagIndex_Apply(), and CSQCModel_Draw().

◆ CSQCModel_LOD_Apply()

void CSQCModel_LOD_Apply ( entity this,
bool isplayer )

Definition at line 28 of file csqcmodel_hooks.qc.

29{
30 int detailreduction = ((isplayer) ? autocvar_cl_playerdetailreduction : autocvar_cl_modeldetailreduction);
31
32 // LOD model loading
33 if(this.lodmodelindex0 != this.modelindex && this.lodmodelindex1 != this.modelindex && this.lodmodelindex2 != this.modelindex)
34 {
35 string modelname = this.model;
36 string s;
37
38 vector mi = this.mins;
39 vector ma = this.maxs;
40
41 // set modelindex
42 this.lodmodelindex0 = this.modelindex;
43 this.lodmodelindex1 = this.modelindex;
44 this.lodmodelindex2 = this.modelindex;
45
46 // FIXME: this only supports 3-letter extensions
47 s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod1", substring(modelname, -4, 4));
48 if(fexists(s))
49 {
50 precache_model(s);
51 _setmodel(this, s);
52 if(this.modelindex)
53 this.lodmodelindex2 = this.lodmodelindex1 = this.modelindex;
54 }
55
56 s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod2", substring(modelname, -4, 4));
57 if(fexists(s))
58 {
59 precache_model(s);
60 _setmodel(this, s);
61 if(this.modelindex)
62 this.lodmodelindex2 = this.modelindex;
63 }
64
65 _setmodel(this, modelname); // make everything normal again
66 setsize(this, mi, ma);
67 }
68
69 // apply LOD
70 if(detailreduction <= 0)
71 {
72 if(detailreduction <= -2)
73 this.modelindex = this.lodmodelindex2;
74 else if(detailreduction <= -1)
75 this.modelindex = this.lodmodelindex1;
76 else
77 this.modelindex = this.lodmodelindex0;
78 }
79 else
80 {
81 float distance = vlen(((isplayer) ? this.origin : NearestPointOnBox(this, view_origin)) - view_origin); // TODO: perhaps it should just use NearestPointOnBox all the time, player hitbox can potentially be huge
82 float dist1 = (this.loddistance1 > 0) ? this.loddistance1 : autocvar_cl_loddistance1;
83 float dist2 = (this.loddistance2 > 0) ? this.loddistance2 : autocvar_cl_loddistance2;
84 float f = (distance * current_viewzoom + 100.0) * detailreduction;
85 f *= 1.0 / bound(0.01, view_quality, 1);
86 if(f > dist2)
87 this.modelindex = this.lodmodelindex2;
88 else if(f > dist1)
89 this.modelindex = this.lodmodelindex1;
90 else
91 this.modelindex = this.lodmodelindex0;
92 }
93}
float current_viewzoom
Definition main.qh:118
vector view_origin
Definition main.qh:109
float view_quality
Definition main.qh:174
int lodmodelindex2
float loddistance2
int lodmodelindex1
float loddistance1
int lodmodelindex0
int autocvar_cl_modeldetailreduction
float autocvar_cl_loddistance1
float autocvar_cl_loddistance2
int autocvar_cl_playerdetailreduction
#define strlen
ERASEABLE bool fexists(string f)
Definition file.qh:4
string substring(string s, float start, float length)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
ERASEABLE vector NearestPointOnBox(entity box, vector org)
Definition vector.qh:187

References autocvar_cl_loddistance1, autocvar_cl_loddistance2, autocvar_cl_modeldetailreduction, autocvar_cl_playerdetailreduction, bound(), current_viewzoom, entity(), fexists(), loddistance1, loddistance2, lodmodelindex0, lodmodelindex1, lodmodelindex2, maxs, mins, model, modelindex, NearestPointOnBox(), origin, strcat(), strlen, substring(), vector, view_origin, view_quality, and vlen().

Referenced by CSQCModel_Hook_PreDraw().

Variable Documentation

◆ autocvar__cl_color

int autocvar__cl_color

Definition at line 14 of file csqcmodel_hooks.qh.

Referenced by CSQCPlayer_ModelAppearance_Apply().

◆ autocvar__cl_playermodel

string autocvar__cl_playermodel

Definition at line 16 of file csqcmodel_hooks.qh.

Referenced by CSQCPlayer_ModelAppearance_Apply().

◆ autocvar__cl_playerskin

int autocvar__cl_playerskin

Definition at line 15 of file csqcmodel_hooks.qh.

Referenced by CSQCPlayer_ModelAppearance_Apply().

◆ autocvar_cl_deathglow

float autocvar_cl_deathglow

Definition at line 17 of file csqcmodel_hooks.qh.

Referenced by CSQCPlayer_ModelAppearance_Apply().

◆ autocvar_cl_deathglow_min

float autocvar_cl_deathglow_min = 0.5

Definition at line 18 of file csqcmodel_hooks.qh.

Referenced by CSQCPlayer_ModelAppearance_Apply().

◆ autocvar_cl_forcemyplayercolors

int autocvar_cl_forcemyplayercolors

Definition at line 13 of file csqcmodel_hooks.qh.

Referenced by CSQCPlayer_ModelAppearance_Apply().

◆ autocvar_cl_forcemyplayermodel

string autocvar_cl_forcemyplayermodel

Definition at line 11 of file csqcmodel_hooks.qh.

Referenced by CSQCPlayer_ModelAppearance_Apply().

◆ autocvar_cl_forcemyplayerskin

int autocvar_cl_forcemyplayerskin

Definition at line 12 of file csqcmodel_hooks.qh.

Referenced by CSQCPlayer_ModelAppearance_Apply().

◆ autocvar_cl_forceplayercolors

bool autocvar_cl_forceplayercolors

Definition at line 9 of file csqcmodel_hooks.qh.

◆ autocvar_cl_forceplayermodels

bool autocvar_cl_forceplayermodels

Definition at line 8 of file csqcmodel_hooks.qh.

Referenced by CSQCPlayer_ModelAppearance_Apply().

◆ autocvar_cl_forceuniqueplayercolors

bool autocvar_cl_forceuniqueplayercolors

Definition at line 10 of file csqcmodel_hooks.qh.

Referenced by CSQCPlayer_ModelAppearance_Apply().

◆ autocvar_cl_jetpack_attenuation

float autocvar_cl_jetpack_attenuation = 2

Definition at line 19 of file csqcmodel_hooks.qh.

Referenced by CSQCModel_Effects_Apply(), CSQCModel_Hook_PreDraw(), and Ent_Remove().

◆ autocvar_cl_loddistance1

float autocvar_cl_loddistance1 = 768

Definition at line 6 of file csqcmodel_hooks.qh.

Referenced by CSQCModel_LOD_Apply().

◆ autocvar_cl_loddistance2

float autocvar_cl_loddistance2 = 2048

Definition at line 7 of file csqcmodel_hooks.qh.

Referenced by CSQCModel_LOD_Apply().

◆ autocvar_cl_modeldetailreduction

int autocvar_cl_modeldetailreduction

Definition at line 5 of file csqcmodel_hooks.qh.

Referenced by CSQCModel_LOD_Apply().

◆ autocvar_cl_playerdetailreduction

int autocvar_cl_playerdetailreduction

Definition at line 4 of file csqcmodel_hooks.qh.

Referenced by CSQCModel_LOD_Apply().

◆ autocvar_cl_respawn_ghosts_keepcolors

bool autocvar_cl_respawn_ghosts_keepcolors

Definition at line 3 of file csqcmodel_hooks.qh.

Referenced by CSQCPlayer_ModelAppearance_Apply().

◆ autocvar_r_hdr_glowintensity

float autocvar_r_hdr_glowintensity

Definition at line 20 of file csqcmodel_hooks.qh.

Referenced by CSQCPlayer_ModelAppearance_Apply().

◆ csqcmodel_effects

◆ csqcmodel_isdead

◆ csqcmodel_modelflags

◆ csqcmodel_traileffect

int csqcmodel_traileffect

◆ death_time

◆ EF_BRIGHTFIELD

const int EF_BRIGHTFIELD = BIT(0)

Definition at line 23 of file csqcmodel_hooks.qh.

Referenced by CSQCModel_Effects_Apply(), and W_Nexball_Attack2().

◆ EF_BRIGHTLIGHT

const int EF_BRIGHTLIGHT = BIT(2)

Definition at line 24 of file csqcmodel_hooks.qh.

Referenced by CSQCModel_Effects_Apply().

◆ EF_DIMLIGHT

const int EF_DIMLIGHT = BIT(3)

Definition at line 25 of file csqcmodel_hooks.qh.

Referenced by CSQCModel_Effects_Apply(), and ctf_FlagSetup().

◆ EF_DOUBLESIDED

const int EF_DOUBLESIDED = BIT(15)

◆ EF_DYNAMICMODELLIGHT

const int EF_DYNAMICMODELLIGHT = BIT(17)

Definition at line 28 of file csqcmodel_hooks.qh.

Referenced by CSQCModel_Effects_Apply().

◆ EF_NOSELFSHADOW

const int EF_NOSELFSHADOW = BIT(16)

Definition at line 27 of file csqcmodel_hooks.qh.

Referenced by CSQCModel_Effects_Apply().

◆ EF_RESTARTANIM_BIT

const int EF_RESTARTANIM_BIT = BIT(20)

◆ EF_TELEPORT_BIT

◆ isplayermodel

◆ MF_GIB

const int MF_GIB = BIT(2)

Definition at line 34 of file csqcmodel_hooks.qh.

Referenced by CSQCModel_Effects_Apply().

◆ MF_GRENADE

const int MF_GRENADE = BIT(1)

Definition at line 33 of file csqcmodel_hooks.qh.

Referenced by CSQCModel_Effects_Apply().

◆ MF_ROCKET

const int MF_ROCKET = BIT(0)

◆ MF_ROTATE

const int MF_ROTATE = BIT(3)

Definition at line 35 of file csqcmodel_hooks.qh.

Referenced by CSQCModel_Effects_Apply(), and spawn_item_key().

◆ MF_TRACER

const int MF_TRACER = BIT(4)

Definition at line 36 of file csqcmodel_hooks.qh.

Referenced by CSQCModel_Effects_Apply().

◆ MF_TRACER2

const int MF_TRACER2 = BIT(6)

Definition at line 38 of file csqcmodel_hooks.qh.

Referenced by CSQCModel_Effects_Apply().

◆ MF_TRACER3

const int MF_TRACER3 = BIT(7)

Definition at line 39 of file csqcmodel_hooks.qh.

Referenced by CSQCModel_Effects_Apply().

◆ MF_ZOMGIB

const int MF_ZOMGIB = BIT(5)

Definition at line 37 of file csqcmodel_hooks.qh.

Referenced by CSQCModel_Effects_Apply().